--- 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
--- 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
--- 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;