hedgewars/uIO.pas
changeset 13851 76a1d6275cd3
parent 13797 c084bd440009
child 13857 10a3b80130b5
equal deleted inserted replaced
13850:28a86816dc01 13851:76a1d6275cd3
    37 procedure IPCCheckSock;
    37 procedure IPCCheckSock;
    38 procedure NetGetNextCmd;
    38 procedure NetGetNextCmd;
    39 procedure doPut(putX, putY: LongInt; fromAI: boolean);
    39 procedure doPut(putX, putY: LongInt; fromAI: boolean);
    40 
    40 
    41 implementation
    41 implementation
    42 uses uConsole, uConsts, uVariables, uCommands, uUtils, uDebug;
    42 uses uConsole, uConsts, uVariables, uCommands, uUtils, uDebug, uLocale;
    43 
    43 
    44 const
    44 const
    45     cSendEmptyPacketTime = 1000;
    45     cSendEmptyPacketTime = 1000;
    46     cSendBufferSize = 1024;
    46     cSendBufferSize = 1024;
    47 
    47 
   145 end;
   145 end;
   146 
   146 
   147 procedure ParseIPCCommand(s: shortstring);
   147 procedure ParseIPCCommand(s: shortstring);
   148 var loTicks: Word;
   148 var loTicks: Word;
   149     isProcessed: boolean;
   149     isProcessed: boolean;
       
   150     nick, msg: shortstring;
       
   151     i: LongInt;
   150 begin
   152 begin
   151 isProcessed := true;
   153 isProcessed := true;
   152 
   154 
   153 case s[1] of
   155 case s[1] of
   154      '!': begin AddFileLog('Ping? Pong!'); isPonged:= true; end;
   156      '!': begin AddFileLog('Ping? Pong!'); isPonged:= true; end;
   173      's': if gameType = gmtNet then
   175      's': if gameType = gmtNet then
   174              ParseChatCommand('chatmsg ', s, 2)
   176              ParseChatCommand('chatmsg ', s, 2)
   175           else
   177           else
   176              isProcessed:= false;
   178              isProcessed:= false;
   177      'b': if gameType = gmtNet then
   179      'b': if gameType = gmtNet then
   178              ParseChatCommand('chatmsg ' + #4, s, 2)
   180              // parse team message from net
       
   181              // expected format: <PLAYER NAME>]<MESSAGE>
       
   182              begin
       
   183              i:= 2;
       
   184              nick:= '';
       
   185              while (i <= length(s)) and (s[i] <> ']') do
       
   186                 begin
       
   187                 nick:= nick + s[i];
       
   188                 inc(i)
       
   189                 end;
       
   190 
       
   191              inc(i);
       
   192              msg:= '';
       
   193              while (i <= length(s)) do
       
   194                 begin
       
   195                 msg:= msg + s[i];
       
   196                 inc(i)
       
   197                 end;
       
   198              s:= 'b' + Format(trmsg[sidChatTeam], [nick, msg]);
       
   199              if (nick = '') or (msg = '') then
       
   200                  isProcessed:= false
       
   201              else
       
   202                  ParseChatCommand('chatmsg ' + #4, s, 2);
       
   203              end
   179           else
   204           else
   180              isProcessed:= false;
   205              isProcessed:= false;
   181      else
   206      else
   182         isProcessed:= false;
   207         isProcessed:= false;
   183      end;
   208      end;