equal
deleted
inserted
replaced
94 |
94 |
95 implementation |
95 implementation |
96 uses {$IFNDEF PAS2C}typinfo, {$ENDIF}Math, uConsts, uVariables, SysUtils; |
96 uses {$IFNDEF PAS2C}typinfo, {$ENDIF}Math, uConsts, uVariables, SysUtils; |
97 |
97 |
98 {$IFDEF DEBUGFILE} |
98 {$IFDEF DEBUGFILE} |
99 var f: textfile; |
99 var logFile: textfile; |
100 {$IFDEF USE_VIDEO_RECORDING} |
100 {$IFDEF USE_VIDEO_RECORDING} |
101 logMutex: TRTLCriticalSection; // mutex for debug file |
101 logMutex: TRTLCriticalSection; // mutex for debug file |
102 {$ENDIF} |
102 {$ENDIF} |
103 {$ENDIF} |
103 {$ENDIF} |
104 var CharArray: array[0..255] of Char; |
104 var CharArray: array[0..255] of Char; |
224 val(s, StrToInt); |
224 val(s, StrToInt); |
225 {$ELSE} |
225 {$ELSE} |
226 val(s, StrToInt, c); |
226 val(s, StrToInt, c); |
227 {$IFDEF DEBUGFILE} |
227 {$IFDEF DEBUGFILE} |
228 if c <> 0 then |
228 if c <> 0 then |
229 writeln(f, 'Error at position ' + IntToStr(c) + ' : ' + s[c]) |
229 writeln(logFile, 'Error at position ' + IntToStr(c) + ' : ' + s[c]) |
230 {$ENDIF} |
230 {$ENDIF} |
231 {$ENDIF} |
231 {$ENDIF} |
232 end; |
232 end; |
233 |
233 |
234 function FloatToStr(n: hwFloat): shortstring; |
234 function FloatToStr(n: hwFloat): shortstring; |
352 {$IFDEF DEBUGFILE} |
352 {$IFDEF DEBUGFILE} |
353 |
353 |
354 {$IFDEF USE_VIDEO_RECORDING} |
354 {$IFDEF USE_VIDEO_RECORDING} |
355 EnterCriticalSection(logMutex); |
355 EnterCriticalSection(logMutex); |
356 {$ENDIF} |
356 {$ENDIF} |
357 writeln(f, inttostr(GameTicks) + ': ' + s); |
357 writeln(logFile, inttostr(GameTicks) + ': ' + s); |
358 flush(f); |
358 flush(logFile); |
359 |
359 |
360 {$IFDEF USE_VIDEO_RECORDING} |
360 {$IFDEF USE_VIDEO_RECORDING} |
361 LeaveCriticalSection(logMutex); |
361 LeaveCriticalSection(logMutex); |
362 {$ENDIF} |
362 {$ENDIF} |
363 |
363 |
370 {$IFNDEF PAS2C} |
370 {$IFNDEF PAS2C} |
371 {$IFDEF DEBUGFILE} |
371 {$IFDEF DEBUGFILE} |
372 {$IFDEF USE_VIDEO_RECORDING} |
372 {$IFDEF USE_VIDEO_RECORDING} |
373 EnterCriticalSection(logMutex); |
373 EnterCriticalSection(logMutex); |
374 {$ENDIF} |
374 {$ENDIF} |
375 write(f, s); |
375 write(logFile, s); |
376 flush(f); |
376 flush(logFile); |
377 {$IFDEF USE_VIDEO_RECORDING} |
377 {$IFDEF USE_VIDEO_RECORDING} |
378 LeaveCriticalSection(logMutex); |
378 LeaveCriticalSection(logMutex); |
379 {$ENDIF} |
379 {$ENDIF} |
380 {$ENDIF} |
380 {$ENDIF} |
381 {$ENDIF} |
381 {$ENDIF} |
537 {$IFDEF USE_VIDEO_RECORDING} |
537 {$IFDEF USE_VIDEO_RECORDING} |
538 InitCriticalSection(logMutex); |
538 InitCriticalSection(logMutex); |
539 {$ENDIF} |
539 {$ENDIF} |
540 {$I-} |
540 {$I-} |
541 {$IFNDEF PAS2C} |
541 {$IFNDEF PAS2C} |
542 f:= stderr; // if everything fails, write to stderr |
542 logFile:= stderr; // if everything fails, write to stderr |
543 {$ENDIF} |
543 {$ENDIF} |
544 if (length(UserPathPrefix) > 0) then |
544 if (length(UserPathPrefix) > 0) then |
545 begin |
545 begin |
546 {$IFNDEF PAS2C} |
546 {$IFNDEF PAS2C} |
547 // create directory if it doesn't exist |
547 // create directory if it doesn't exist |
550 {$ENDIF} |
550 {$ENDIF} |
551 // if log is locked, write to the next one |
551 // if log is locked, write to the next one |
552 i:= 0; |
552 i:= 0; |
553 while(i < 7) do |
553 while(i < 7) do |
554 begin |
554 begin |
555 assign(f, shortstring(UserPathPrefix) + '/Logs/' + logfileBase + inttostr(i) + '.log'); |
555 assign(logFile, shortstring(UserPathPrefix) + '/Logs/' + logfileBase + inttostr(i) + '.log'); |
556 if IOResult = 0 then |
556 if IOResult = 0 then |
557 break; |
557 break; |
558 inc(i) |
558 inc(i) |
559 end; |
559 end; |
560 end; |
560 end; |
561 Rewrite(f); |
561 Rewrite(logFile); |
562 {$I+} |
562 {$I+} |
563 {$ENDIF} |
563 {$ENDIF} |
564 |
564 |
565 //mobile stuff |
565 //mobile stuff |
566 {$IFDEF IPHONEOS} |
566 {$IFDEF IPHONEOS} |
578 end; |
578 end; |
579 |
579 |
580 procedure freeModule; |
580 procedure freeModule; |
581 begin |
581 begin |
582 {$IFDEF DEBUGFILE} |
582 {$IFDEF DEBUGFILE} |
583 writeln(f, 'halt at ' + inttostr(GameTicks) + ' ticks. TurnTimeLeft = ' + inttostr(TurnTimeLeft)); |
583 writeln(logFile, 'halt at ' + inttostr(GameTicks) + ' ticks. TurnTimeLeft = ' + inttostr(TurnTimeLeft)); |
584 flush(f); |
584 flush(logFile); |
585 close(f); |
585 close(logFile); |
586 {$IFDEF USE_VIDEO_RECORDING} |
586 {$IFDEF USE_VIDEO_RECORDING} |
587 DoneCriticalSection(logMutex); |
587 DoneCriticalSection(logMutex); |
588 {$ENDIF} |
588 {$ENDIF} |
589 {$ENDIF} |
589 {$ENDIF} |
590 end; |
590 end; |