# HG changeset patch # User Wuzzy # Date 1557863341 -7200 # Node ID 23fc5022bdeae50fbb822821478da1c0875564c3 # Parent 00cf807b7faa3ccf4f18df936f083d128482e976 Implement AddFileLogRaw diff -r 00cf807b7faa -r 23fc5022bdea hedgewars/uPhysFSLayer.pas --- a/hedgewars/uPhysFSLayer.pas Tue May 14 20:58:39 2019 +0200 +++ b/hedgewars/uPhysFSLayer.pas Tue May 14 21:49:01 2019 +0200 @@ -35,6 +35,7 @@ procedure pfsReadLn(f: PFSFile; var s: shortstring); procedure pfsReadLnA(f: PFSFile; var s: ansistring); procedure pfsWriteLn(f: PFSFile; s: shortstring); +procedure pfsWriteRaw(f: PFSFile; s: PChar; len: QWord); function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64; function pfsEOF(f: PFSFile): boolean; @@ -179,6 +180,11 @@ PHYSFS_writeBytes(f, @c, 1); end; +procedure pfsWriteRaw(f: PFSFile; s: PChar; len: QWord); +begin + PHYSFS_writeBytes(f, s, len); +end; + function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64; var r: Int64; begin diff -r 00cf807b7faa -r 23fc5022bdea hedgewars/uUtils.pas --- a/hedgewars/uUtils.pas Tue May 14 20:58:39 2019 +0200 +++ b/hedgewars/uUtils.pas Tue May 14 21:49:01 2019 +0200 @@ -526,6 +526,7 @@ end; procedure AddFileLogRaw(s: pchar); cdecl; +var tmp: shortstring; begin s:= s; {$IFNDEF PAS2C} @@ -534,9 +535,17 @@ if SDL_LockMutex(logMutex) <> 0 then OutError('Logging mutex could not be locked!', true); {$ENDIF} -// TODO: uncomment next two lines -// write(logFile, s); -// flush(logFile); +tmp:= IntToStr(GameTicks) + ': '; +if (logFile <> nil) then + begin + pfsWriteRaw(logFile, Str2PChar(tmp), StrLen(Str2PChar(tmp))); + pfsWriteRaw(logFile, s, StrLen(s)); + end +else + begin + Write(stdout, Str2PChar(tmp)); + Flush(stdout); + end; {$IFDEF USE_VIDEO_RECORDING} if SDL_UnlockMutex(logMutex) <> 0 then OutError('Logging mutex could not be unlocked!', true);