hedgewars/uIO.pas
changeset 526 e3689572bb15
parent 392 25be13ae29da
child 648 fc5234aa6493
equal deleted inserted replaced
525:ae21b8e86dd9 526:e3689572bb15
    34 procedure NetGetNextCmd;
    34 procedure NetGetNextCmd;
    35 
    35 
    36 implementation
    36 implementation
    37 uses uConsole, uConsts, uWorld, uMisc, uLand;
    37 uses uConsole, uConsts, uWorld, uMisc, uLand;
    38 const isPonged: boolean = false;
    38 const isPonged: boolean = false;
       
    39       MAXCMDS = 65535;
    39 var  IPCSock: PTCPSocket = nil;
    40 var  IPCSock: PTCPSocket = nil;
    40      fds: PSDLNet_SocketSet;
    41      fds: PSDLNet_SocketSet;
    41 
    42 
    42      extcmd: array[word] of packed record
    43      extcmd: array[0..MAXCMDS] of packed record
    43                                    Time: LongWord;
    44                                    Time: LongWord;
    44                                    case byte of
    45                                    case byte of
    45                                         1: (len: byte;
    46                                         1: (len: byte;
    46                                             cmd: Char;
    47                                             cmd: Char;
    47                                             X, Y: SmallInt);
    48                                             X, Y: SmallInt);
    87                'N': GameType:= gmtNet;
    88                'N': GameType:= gmtNet;
    88                'S': GameType:= gmtSave;
    89                'S': GameType:= gmtSave;
    89                else OutError(errmsgIncorrectUse + ' IPC "T" :' + s[2], true) end;
    90                else OutError(errmsgIncorrectUse + ' IPC "T" :' + s[2], true) end;
    90      else
    91      else
    91      inc(cmdendpos);
    92      inc(cmdendpos);
       
    93      TryDo(cmdendpos <= MAXCMDS, 'Too many commands in queue', true);
    92      extcmd[cmdendpos].Time := SDLNet_Read32(@s[byte(s[0]) - 3]);
    94      extcmd[cmdendpos].Time := SDLNet_Read32(@s[byte(s[0]) - 3]);
    93      extcmd[cmdendpos].str  := s;
    95      extcmd[cmdendpos].str  := s;
    94      {$IFDEF DEBUGFILE}AddFileLog('IPC in: '+s[1]+' ticks '+inttostr(extcmd[cmdendpos].Time)+' at '+inttostr(cmdendpos));{$ENDIF}
    96      {$IFDEF DEBUGFILE}AddFileLog('IPC in: '+s[1]+' ticks '+inttostr(extcmd[cmdendpos].Time)+' at '+inttostr(cmdendpos));{$ENDIF}
    95      dec(extcmd[cmdendpos].len, 4)
    97      dec(extcmd[cmdendpos].len, 4)
    96      end
    98      end