hedgewars/uIO.pas
branchwebgl
changeset 8330 aaefa587e277
parent 8096 453917e94e55
parent 8243 92a430205796
child 8444 75db7bb8dce8
equal deleted inserted replaced
8116:d24257910f8d 8330:aaefa587e277
    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;
    43 
    43 
       
    44 const
       
    45     cSendEmptyPacketTime = 1000;
       
    46 
    44 type PCmd = ^TCmd;
    47 type PCmd = ^TCmd;
    45      TCmd = packed record
    48      TCmd = packed record
    46             Next: PCmd;
    49             Next: PCmd;
    47             loTime: Word;
    50             loTime: Word;
    48             case byte of
    51             case byte of
   120      '?': SendIPC(_S'!');
   123      '?': SendIPC(_S'!');
   121      'e': ParseCommand(copy(s, 2, Length(s) - 1), true);
   124      'e': ParseCommand(copy(s, 2, Length(s) - 1), true);
   122      'E': OutError(copy(s, 2, Length(s) - 1), true);
   125      'E': OutError(copy(s, 2, Length(s) - 1), true);
   123      'W': OutError(copy(s, 2, Length(s) - 1), false);
   126      'W': OutError(copy(s, 2, Length(s) - 1), false);
   124      'M': ParseCommand('landcheck ' + s, true);
   127      'M': ParseCommand('landcheck ' + s, true);
       
   128      'o': if fastUntilLag then ParseCommand('forcequit', true);
   125      'T': case s[2] of
   129      'T': case s[2] of
   126                'L': GameType:= gmtLocal;
   130                'L': GameType:= gmtLocal;
   127                'D': GameType:= gmtDemo;
   131                'D': GameType:= gmtDemo;
   128                'N': GameType:= gmtNet;
   132                'N': GameType:= gmtNet;
   129                'S': GameType:= gmtSave;
   133                'S': GameType:= gmtSave;
   192         s[0]:= char(i);
   196         s[0]:= char(i);
   193         ss:= ss + s;
   197         ss:= ss + s;
   194         while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do
   198         while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do
   195             begin
   199             begin
   196             ParseIPCCommand(copy(ss, 2, byte(ss[1])));
   200             ParseIPCCommand(copy(ss, 2, byte(ss[1])));
   197 	       Delete(ss, 1, Succ(byte(ss[1])));
   201            Delete(ss, 1, Succ(byte(ss[1])));
   198             end
   202             end
   199         end
   203         end
   200 until i = 0;
   204 until i = 0;
   201 
   205 
   202 close(f)
   206 close(f)
   217 if IPCSock <> nil then
   221 if IPCSock <> nil then
   218     begin
   222     begin
   219     SendEmptyPacketTicks:= 0;
   223     SendEmptyPacketTicks:= 0;
   220     if s[0]>#251 then
   224     if s[0]>#251 then
   221         s[0]:= #251;
   225         s[0]:= #251;
   222         
   226 
   223     SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]);
   227     SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]);
   224     AddFileLog('[IPC out] '+ s[1]);
   228     AddFileLog('[IPC out] '+ s[1]);
   225     inc(s[0], 2);
   229     inc(s[0], 2);
   226        SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0])));
   230        SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0])));
   227        //log('SendIPC');
   231        //log('SendIPC');
   426 
   430 
   427     headcmd:= nil;
   431     headcmd:= nil;
   428     lastcmd:= nil;
   432     lastcmd:= nil;
   429     isPonged:= false;
   433     isPonged:= false;
   430     SocketString:= '';
   434     SocketString:= '';
   431     
   435 
   432     hiTicks:= 0;
   436     hiTicks:= 0;
   433     SendEmptyPacketTicks:= 0;
   437     SendEmptyPacketTicks:= 0;
   434 
   438 
   435 end;
   439 end;
   436 
   440