hedgewars/uIO.pas
changeset 13828 76a1d6275cd3
parent 13768 c084bd440009
child 13832 10a3b80130b5
--- a/hedgewars/uIO.pas	Thu Oct 04 14:54:57 2018 +0200
+++ b/hedgewars/uIO.pas	Thu Oct 04 17:07:17 2018 +0200
@@ -39,7 +39,7 @@
 procedure doPut(putX, putY: LongInt; fromAI: boolean);
 
 implementation
-uses uConsole, uConsts, uVariables, uCommands, uUtils, uDebug;
+uses uConsole, uConsts, uVariables, uCommands, uUtils, uDebug, uLocale;
 
 const
     cSendEmptyPacketTime = 1000;
@@ -147,6 +147,8 @@
 procedure ParseIPCCommand(s: shortstring);
 var loTicks: Word;
     isProcessed: boolean;
+    nick, msg: shortstring;
+    i: LongInt;
 begin
 isProcessed := true;
 
@@ -175,7 +177,30 @@
           else
              isProcessed:= false;
      'b': if gameType = gmtNet then
-             ParseChatCommand('chatmsg ' + #4, s, 2)
+             // parse team message from net
+             // expected format: <PLAYER NAME>]<MESSAGE>
+             begin
+             i:= 2;
+             nick:= '';
+             while (i <= length(s)) and (s[i] <> ']') do
+                begin
+                nick:= nick + s[i];
+                inc(i)
+                end;
+
+             inc(i);
+             msg:= '';
+             while (i <= length(s)) do
+                begin
+                msg:= msg + s[i];
+                inc(i)
+                end;
+             s:= 'b' + Format(trmsg[sidChatTeam], [nick, msg]);
+             if (nick = '') or (msg = '') then
+                 isProcessed:= false
+             else
+                 ParseChatCommand('chatmsg ' + #4, s, 2);
+             end
           else
              isProcessed:= false;
      else