27 |
27 |
28 procedure SendIPC(s: shortstring); |
28 procedure SendIPC(s: shortstring); |
29 procedure SendIPCXY(cmd: char; X, Y: SmallInt); |
29 procedure SendIPCXY(cmd: char; X, Y: SmallInt); |
30 procedure SendIPCRaw(p: pointer; len: Longword); |
30 procedure SendIPCRaw(p: pointer; len: Longword); |
31 procedure SendIPCAndWaitReply(s: shortstring); |
31 procedure SendIPCAndWaitReply(s: shortstring); |
32 procedure SendIPCTimeInc; |
|
33 procedure SendKeepAliveMessage(Lag: Longword); |
32 procedure SendKeepAliveMessage(Lag: Longword); |
34 procedure LoadRecordFromFile(fileName: shortstring); |
33 procedure LoadRecordFromFile(fileName: shortstring); |
35 procedure SendStat(sit: TStatInfoType; s: shortstring); |
34 procedure SendStat(sit: TStatInfoType; s: shortstring); |
36 procedure IPCWaitPongEvent; |
35 procedure IPCWaitPongEvent; |
37 procedure IPCCheckSock; |
36 procedure IPCCheckSock; |
244 SDLNet_Write16(X, @s[2]); |
243 SDLNet_Write16(X, @s[2]); |
245 SDLNet_Write16(Y, @s[4]); |
244 SDLNet_Write16(Y, @s[4]); |
246 SendIPC(s) |
245 SendIPC(s) |
247 end; |
246 end; |
248 |
247 |
249 procedure SendIPCTimeInc; |
|
250 const timeinc: shortstring = '#'; |
|
251 begin |
|
252 AddFileLog('[IPC out] <time increment>'); |
|
253 SendIPCRaw(@timeinc, 2) |
|
254 end; |
|
255 |
|
256 procedure IPCWaitPongEvent; |
248 procedure IPCWaitPongEvent; |
257 begin |
249 begin |
258 isPonged:= false; |
250 isPonged:= false; |
259 repeat |
251 repeat |
260 IPCCheckSock; |
252 IPCCheckSock; |
286 while (headcmd <> nil) |
278 while (headcmd <> nil) |
287 and (tmpflag or (headcmd^.cmd = '#')) // '#' is the only cmd which can be sent within same tick after 'N' |
279 and (tmpflag or (headcmd^.cmd = '#')) // '#' is the only cmd which can be sent within same tick after 'N' |
288 and ((GameTicks = hiTicks shl 16 + headcmd^.loTime) |
280 and ((GameTicks = hiTicks shl 16 + headcmd^.loTime) |
289 or (headcmd^.cmd = 's') // for these commands time is not specified |
281 or (headcmd^.cmd = 's') // for these commands time is not specified |
290 or (headcmd^.cmd = 'h') // seems the hedgewars protocol does not allow remote synced commands |
282 or (headcmd^.cmd = 'h') // seems the hedgewars protocol does not allow remote synced commands |
291 or (headcmd^.cmd = '#') |
283 or (headcmd^.cmd = '#') // must be synced for saves to work |
292 or (headcmd^.cmd = 'b') |
284 or (headcmd^.cmd = 'b') |
293 or (headcmd^.cmd = 'F')) do |
285 or (headcmd^.cmd = 'F')) do |
294 begin |
286 begin |
295 case headcmd^.cmd of |
287 case headcmd^.cmd of |
296 '+': ; // do nothing - it is just an empty packet |
288 '+': ; // do nothing - it is just an empty packet |
297 '#': inc(hiTicks); |
289 '#': begin |
|
290 AddFileLog('hiTicks increment by remote message'); |
|
291 inc(hiTicks); |
|
292 end; |
298 'L': ParseCommand('+left', true); |
293 'L': ParseCommand('+left', true); |
299 'l': ParseCommand('-left', true); |
294 'l': ParseCommand('-left', true); |
300 'R': ParseCommand('+right', true); |
295 'R': ParseCommand('+right', true); |
301 'r': ParseCommand('-right', true); |
296 'r': ParseCommand('-right', true); |
302 'U': ParseCommand('+up', true); |
297 'U': ParseCommand('+up', true); |