hedgewars/uIO.pas
changeset 10392 5012e1f9e893
parent 10349 a51de45dcc42
child 10410 669bfa55cd70
child 10510 9329dab04490
--- a/hedgewars/uIO.pas	Fri Aug 22 00:37:26 2014 +0400
+++ b/hedgewars/uIO.pas	Fri Aug 22 00:57:07 2014 +0400
@@ -118,9 +118,22 @@
     WriteLnToConsole(msgOK)
 end;
 
+procedure ParseChatCommand(command: shortstring; message: shortstring;
+                           messageStartIndex: Byte);
+var
+    text: shortstring;
+begin
+    text:= copy(message, messageStartIndex,
+                Length(message) - messageStartIndex + 1);
+    ParseCommand(command + text, true);
+    WriteLnToConsole(text)
+end;
+
 procedure ParseIPCCommand(s: shortstring);
 var loTicks: Word;
+    isProcessed: boolean;
 begin
+isProcessed := true;
 
 case s[1] of
      '!': begin AddFileLog('Ping? Pong!'); isPonged:= true; end;
@@ -140,12 +153,26 @@
      'V': begin
               if s[2] = '.' then
                   ParseCommand('campvar ' + copy(s, 3, length(s) - 2), true);
-          end
+          end;
+     'I': ParseCommand('pause server', true);
+     's': if gameType = gmtNet then
+             ParseChatCommand('chatmsg ', s, 2)
+          else 
+             isProcessed:= false;
+     'b': if gameType = gmtNet then
+             ParseChatCommand('chatmsg ' + #4, s, 2)
+          else 
+             isProcessed:= false;
      else
-     loTicks:= SDLNet_Read16(@s[byte(s[0]) - 1]);
-     AddCmd(loTicks, s);
-     AddFileLog('[IPC in] ' + sanitizeCharForLog(s[1]) + ' ticks ' + IntToStr(lastcmd^.loTime));
-     end
+        isProcessed:= false;
+     end;
+
+    if (not isProcessed) then
+    begin
+        loTicks:= SDLNet_Read16(@s[byte(s[0]) - 1]);
+        AddCmd(loTicks, s);
+        AddFileLog('[IPC in] ' + sanitizeCharForLog(s[1]) + ' ticks ' + IntToStr(lastcmd^.loTime));
+    end
 end;
 
 procedure IPCCheckSock;
@@ -357,16 +384,8 @@
             s:= copy(headcmd^.str, 2, Pred(headcmd^.len));
             ParseCommand('gencmd ' + s, true);
              end;
-        's': begin
-            s:= copy(headcmd^.str, 2, Pred(headcmd^.len));
-            ParseCommand('chatmsg ' + s, true);
-            WriteLnToConsole(s)
-             end;
-        'b': begin
-            s:= copy(headcmd^.str, 2, Pred(headcmd^.len));
-            ParseCommand('chatmsg ' + #4 + s, true);
-            WriteLnToConsole(s)
-             end;
+        's': ParseChatCommand('chatmsg ', headcmd^.str, 2);
+        'b': ParseChatCommand('chatmsg ' + #4, headcmd^.str, 2);
         'F': ParseCommand('teamgone u' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);
         'G': ParseCommand('teamback u' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);
         'f': ParseCommand('teamgone s' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);