# HG changeset patch # User unc0rr # Date 1360563607 -14400 # Node ID eecadca7db50386c33a47221c65c011eda72613c # Parent c5605c6f5bb3df5e6598c64c9d832fab240fc61f Bring back full log strings for commands, just a bit sanitized diff -r c5605c6f5bb3 -r eecadca7db50 hedgewars/uCommands.pas --- a/hedgewars/uCommands.pas Mon Feb 11 00:19:15 2013 +0400 +++ b/hedgewars/uCommands.pas Mon Feb 11 10:20:07 2013 +0400 @@ -88,12 +88,14 @@ //WriteLnToConsole(CmdStr); if CmdStr[0]=#0 then exit; + +AddFileLog('[Cmd] ' + sanitizeForLog(CmdStr)); + c:= CmdStr[1]; if (c = '/') or (c = '$') then Delete(CmdStr, 1, 1); s:= ''; SplitBySpace(CmdStr, s); -AddFileLog('[Cmd] ' + CmdStr + ' (' + inttostr(length(s)) + ')'); t:= Variables; while t <> nil do diff -r c5605c6f5bb3 -r eecadca7db50 hedgewars/uIO.pas --- a/hedgewars/uIO.pas Mon Feb 11 00:19:15 2013 +0400 +++ b/hedgewars/uIO.pas Mon Feb 11 10:20:07 2013 +0400 @@ -144,7 +144,7 @@ else loTicks:= SDLNet_Read16(@s[byte(s[0]) - 1]); AddCmd(loTicks, s); - AddFileLog('[IPC in] '+s[1]+' ticks '+IntToStr(lastcmd^.loTime)); + AddFileLog('[IPC in] ' + sanitizeCharForLog(s[1]) + ' ticks ' + IntToStr(lastcmd^.loTime)); end end; @@ -239,7 +239,8 @@ s[0]:= #251; SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]); - AddFileLog('[IPC out] '+ s[1]); + + AddFileLog('[IPC out] '+ sanitizeCharForLog(s[1])); inc(s[0], 2); if isSyncedCommand(s[1]) then diff -r c5605c6f5bb3 -r eecadca7db50 hedgewars/uUtils.pas --- a/hedgewars/uUtils.pas Mon Feb 11 00:19:15 2013 +0400 +++ b/hedgewars/uUtils.pas Mon Feb 11 10:20:07 2013 +0400 @@ -84,6 +84,9 @@ procedure AudioServicesPlaySystemSound(num: LongInt); cdecl; external; {$ENDIF} +function sanitizeForLog(s: shortstring): shortstring; +function sanitizeCharForLog(c: char): shortstring; + procedure initModule(isNotPreview: boolean); procedure freeModule; @@ -441,6 +444,31 @@ {$ENDIF} end; +function sanitizeForLog(s: shortstring): shortstring; +var i: byte; + r: shortstring; +begin + r[0]:= s[0]; + for i:= 1 to length(s) do + if (s[i] < #32) or (s[i] > #127) then + r[i]:= '?' + else + r[i]:= s[i]; + + sanitizeForLog:= r +end; + +function sanitizeCharForLog(c: char): shortstring; +var r: shortstring; +begin + if (c < #32) or (c > #127) then + r:= '#' + inttostr(byte(c)) + else + r:= c; + + sanitizeCharForLog:= r +end; + procedure initModule(isNotPreview: boolean); {$IFDEF DEBUGFILE} var logfileBase: shortstring;