69 FillChar(command^, sizeof(TCmd), 0); |
69 FillChar(command^, sizeof(TCmd), 0); |
70 command^.loTime:= Time; |
70 command^.loTime:= Time; |
71 command^.str:= str; |
71 command^.str:= str; |
72 if command^.cmd <> 'F' then dec(command^.len, 2); // cut timestamp |
72 if command^.cmd <> 'F' then dec(command^.len, 2); // cut timestamp |
73 if headcmd = nil then |
73 if headcmd = nil then |
74 begin |
74 begin |
75 headcmd:= command; |
75 headcmd:= command; |
76 lastcmd:= command |
76 lastcmd:= command |
77 end else |
77 end |
78 begin |
78 else |
79 lastcmd^.Next:= command; |
79 begin |
80 lastcmd:= command |
80 lastcmd^.Next:= command; |
81 end; |
81 lastcmd:= command |
|
82 end; |
82 AddCmd:= command; |
83 AddCmd:= command; |
83 end; |
84 end; |
84 |
85 |
85 procedure RemoveCmd; |
86 procedure RemoveCmd; |
86 var tmp: PCmd; |
87 var tmp: PCmd; |
87 begin |
88 begin |
88 TryDo(headcmd <> nil, 'Engine bug: headcmd = nil', true); |
89 TryDo(headcmd <> nil, 'Engine bug: headcmd = nil', true); |
89 tmp:= headcmd; |
90 tmp:= headcmd; |
90 headcmd:= headcmd^.Next; |
91 headcmd:= headcmd^.Next; |
91 if headcmd = nil then lastcmd:= nil; |
92 if headcmd = nil then |
|
93 lastcmd:= nil; |
92 dispose(tmp) |
94 dispose(tmp) |
93 end; |
95 end; |
94 |
96 |
95 procedure InitIPC; |
97 procedure InitIPC; |
96 var ipaddr: TIPAddress; |
98 var ipaddr: TIPAddress; |
213 procedure SendIPC(s: shortstring); |
217 procedure SendIPC(s: shortstring); |
214 begin |
218 begin |
215 if IPCSock <> nil then |
219 if IPCSock <> nil then |
216 begin |
220 begin |
217 SendEmptyPacketTicks:= 0; |
221 SendEmptyPacketTicks:= 0; |
218 if s[0]>#251 then s[0]:= #251; |
222 if s[0]>#251 then |
|
223 s[0]:= #251; |
|
224 |
219 SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]); |
225 SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]); |
220 AddFileLog('[IPC out] '+ s[1]); |
226 AddFileLog('[IPC out] '+ s[1]); |
221 inc(s[0], 2); |
227 inc(s[0], 2); |
222 SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0]))) |
228 SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0]))) |
223 end |
229 end |
224 end; |
230 end; |
225 |
231 |
226 procedure SendIPCRaw(p: pointer; len: Longword); |
232 procedure SendIPCRaw(p: pointer; len: Longword); |
227 begin |
233 begin |
228 if IPCSock <> nil then |
234 if IPCSock <> nil then |
229 begin |
235 begin |
230 SDLNet_TCP_Send(IPCSock, p, len) |
236 SDLNet_TCP_Send(IPCSock, p, len) |
231 end |
237 end |
232 end; |
238 end; |
233 |
239 |
234 procedure SendIPCXY(cmd: char; X, Y: SmallInt); |
240 procedure SendIPCXY(cmd: char; X, Y: SmallInt); |
235 var s: shortstring; |
241 var s: shortstring; |
236 begin |
242 begin |
303 'J': ParseCommand('hjump', true); |
309 'J': ParseCommand('hjump', true); |
304 ',': ParseCommand('skip', true); |
310 ',': ParseCommand('skip', true); |
305 'c': begin |
311 'c': begin |
306 s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); |
312 s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); |
307 ParseCommand('gencmd ' + s, true); |
313 ParseCommand('gencmd ' + s, true); |
308 end; |
314 end; |
309 's': begin |
315 's': begin |
310 s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); |
316 s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); |
311 ParseCommand('chatmsg ' + s, true); |
317 ParseCommand('chatmsg ' + s, true); |
312 WriteLnToConsole(s) |
318 WriteLnToConsole(s) |
313 end; |
319 end; |
314 'b': begin |
320 'b': begin |
315 s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); |
321 s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); |
316 ParseCommand('chatmsg ' + #4 + s, true); |
322 ParseCommand('chatmsg ' + #4 + s, true); |
317 WriteLnToConsole(s) |
323 WriteLnToConsole(s) |
318 end; |
324 end; |
319 // TODO: deprecate 'F' |
325 // TODO: deprecate 'F' |
320 'F': ParseCommand('teamgone ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
326 'F': ParseCommand('teamgone ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
321 'N': begin |
327 'N': begin |
322 tmpflag:= false; |
328 tmpflag:= false; |
323 AddFileLog('got cmd "N": time '+IntToStr(hiTicks shl 16 + headcmd^.loTime)) |
329 AddFileLog('got cmd "N": time '+IntToStr(hiTicks shl 16 + headcmd^.loTime)) |
324 end; |
330 end; |
325 'p': begin |
331 'p': begin |
326 x16:= SDLNet_Read16(@(headcmd^.X)); |
332 x16:= SDLNet_Read16(@(headcmd^.X)); |
327 y16:= SDLNet_Read16(@(headcmd^.Y)); |
333 y16:= SDLNet_Read16(@(headcmd^.Y)); |
328 doPut(x16, y16, false) |
334 doPut(x16, y16, false) |
329 end; |
335 end; |
330 'P': begin |
336 'P': begin |
331 // these are equations solved for CursorPoint |
337 // these are equations solved for CursorPoint |
332 // SDLNet_Read16(@(headcmd^.X)) == CursorPoint.X - WorldDx; |
338 // SDLNet_Read16(@(headcmd^.X)) == CursorPoint.X - WorldDx; |
333 // SDLNet_Read16(@(headcmd^.Y)) == cScreenHeight - CursorPoint.Y - WorldDy; |
339 // SDLNet_Read16(@(headcmd^.Y)) == cScreenHeight - CursorPoint.Y - WorldDy; |
334 if not (CurrentTeam^.ExtDriven and bShowAmmoMenu) then |
340 if not (CurrentTeam^.ExtDriven and bShowAmmoMenu) then |
335 begin |
341 begin |
336 CursorPoint.X:= SmallInt(SDLNet_Read16(@(headcmd^.X))) + WorldDx; |
342 CursorPoint.X:= SmallInt(SDLNet_Read16(@(headcmd^.X))) + WorldDx; |
337 CursorPoint.Y:= cScreenHeight - SmallInt(SDLNet_Read16(@(headcmd^.Y))) - WorldDy |
343 CursorPoint.Y:= cScreenHeight - SmallInt(SDLNet_Read16(@(headcmd^.Y))) - WorldDy |
338 end |
344 end |
339 end; |
345 end; |
340 'w': ParseCommand('setweap ' + headcmd^.str[2], true); |
346 'w': ParseCommand('setweap ' + headcmd^.str[2], true); |
341 't': ParseCommand('taunt ' + headcmd^.str[2], true); |
347 't': ParseCommand('taunt ' + headcmd^.str[2], true); |
342 'h': ParseCommand('hogsay ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
348 'h': ParseCommand('hogsay ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
343 '1'..'5': ParseCommand('timer ' + headcmd^.cmd, true); |
349 '1'..'5': ParseCommand('timer ' + headcmd^.cmd, true); |
344 #128..char(128 + cMaxSlotIndex): ParseCommand('slot ' + char(byte(headcmd^.cmd) - 79), true) |
350 #128..char(128 + cMaxSlotIndex): ParseCommand('slot ' + char(byte(headcmd^.cmd) - 79), true) |