Fix segfault on game halt (if no logfile)
authorsheepluva
Sat, 07 Apr 2018 22:16:36 +0200
changeset 13317 092adcf707c5
parent 13316 574d34577ee9
child 13318 93780a3b846a
Fix segfault on game halt (if no logfile)
hedgewars/uUtils.pas
--- a/hedgewars/uUtils.pas	Fri Apr 06 12:34:23 2018 -0400
+++ b/hedgewars/uUtils.pas	Sat Apr 07 22:16:36 2018 +0200
@@ -751,9 +751,14 @@
 procedure freeModule;
 begin
 {$IFDEF DEBUGFILE}
+if logFile <> nil then
+    begin
     pfsWriteLn(logFile, 'halt at ' + inttostr(GameTicks) + ' ticks. TurnTimeLeft = ' + inttostr(TurnTimeLeft));
     pfsFlush(logFile);
     pfsClose(logFile);
+    end
+else
+    WriteLn(stdout, 'halt at ' + inttostr(GameTicks) + ' ticks. TurnTimeLeft = ' + inttostr(TurnTimeLeft));
 {$IFDEF USE_VIDEO_RECORDING}
     DoneCriticalSection(logMutex);
 {$ENDIF}