diff -r 959da8402cac -r bfd378dfc4e7 hedgewars/uIO.pas --- a/hedgewars/uIO.pas Wed Sep 16 12:48:27 2009 +0000 +++ b/hedgewars/uIO.pas Wed Sep 16 14:44:40 2009 +0000 @@ -28,6 +28,7 @@ procedure SendIPCRaw(p: pointer; len: Longword); procedure SendIPCAndWaitReply(s: shortstring); procedure SendIPCTimeInc; +procedure SendKeepAliveMessage(Lag: Longword); procedure LoadRecordFromFile(fileName: shortstring); procedure IPCWaitPongEvent; procedure IPCCheckSock; @@ -52,11 +53,15 @@ 2: (str: shortstring); end; -var IPCSock: PTCPSocket = nil; - fds: PSDLNet_SocketSet; +var + IPCSock: PTCPSocket = nil; + fds: PSDLNet_SocketSet; - headcmd: PCmd = nil; - lastcmd: PCmd = nil; + headcmd: PCmd = nil; + lastcmd: PCmd = nil; + + SendEmptyPacketTicks: LongWord = 0; + function AddCmd(Time: Longword; str: shortstring): PCmd; var Result: PCmd; @@ -196,13 +201,14 @@ procedure SendIPC(s: shortstring); begin if IPCSock <> nil then - begin - if s[0]>#251 then s[0]:= #251; - SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]); - {$IFDEF DEBUGFILE}AddFileLog('IPC send: '+s[1]);{$ENDIF} - inc(s[0], 2); - SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0]))) - end + begin + SendEmptyPacketTicks:= 0; + if s[0]>#251 then s[0]:= #251; + SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]); + {$IFDEF DEBUGFILE}AddFileLog('IPC send: '+s[1]);{$ENDIF} + inc(s[0], 2); + SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0]))) + end end; procedure SendIPCRaw(p: pointer; len: Longword); @@ -245,6 +251,13 @@ IPCWaitPongEvent end; +procedure SendKeepAliveMessage(Lag: Longword); +begin +inc(SendEmptyPacketTicks, Lag); +if (SendEmptyPacketTicks >= cSendEmptyPacketTime) then + SendIPC('+') +end; + procedure NetGetNextCmd; var tmpflag: boolean; s: shortstring;