equal
deleted
inserted
replaced
68 end; |
68 end; |
69 |
69 |
70 function AddCmd(Time: Word; str: shortstring): PCmd; |
70 function AddCmd(Time: Word; str: shortstring): PCmd; |
71 var command: PCmd; |
71 var command: PCmd; |
72 begin |
72 begin |
73 new(command); |
73 if (lastcmd <> nil) and (lastcmd^.cmd = '+') then |
74 FillChar(command^, sizeof(TCmd), 0); |
74 begin |
75 command^.loTime:= Time; |
75 command:= lastcmd; |
76 command^.str:= str; |
76 end else |
77 if (command^.cmd <> 'F') and (command^.cmd <> 'G') then dec(command^.len, 2); // cut timestamp |
77 begin |
78 if headcmd = nil then |
78 new(command); |
79 begin |
79 |
80 headcmd:= command; |
80 if headcmd = nil then |
81 lastcmd:= command |
81 begin |
82 end |
82 headcmd:= command; |
83 else |
83 lastcmd:= command |
84 begin |
84 end |
85 lastcmd^.Next:= command; |
85 else |
86 lastcmd:= command |
86 begin |
|
87 lastcmd^.Next:= command; |
|
88 lastcmd:= command |
|
89 end; |
87 end; |
90 end; |
88 AddCmd:= command; |
91 |
|
92 FillChar(command^, sizeof(TCmd), 0); |
|
93 command^.loTime:= Time; |
|
94 command^.str:= str; |
|
95 if (command^.cmd <> 'F') and (command^.cmd <> 'G') then dec(command^.len, 2); // cut timestamp |
|
96 |
|
97 AddCmd:= command; |
89 end; |
98 end; |
90 |
99 |
91 procedure RemoveCmd; |
100 procedure RemoveCmd; |
92 var tmp: PCmd; |
101 var tmp: PCmd; |
93 begin |
102 begin |
94 TryDo(headcmd <> nil, 'Engine bug: headcmd = nil', true); |
|
95 tmp:= headcmd; |
103 tmp:= headcmd; |
96 headcmd:= headcmd^.Next; |
104 headcmd:= headcmd^.Next; |
97 if headcmd = nil then |
105 if headcmd = nil then |
98 lastcmd:= nil; |
106 lastcmd:= nil; |
99 dispose(tmp) |
107 dispose(tmp) |
200 // set RDNLY on file open |
208 // set RDNLY on file open |
201 filemode:= 0; |
209 filemode:= 0; |
202 {$I-} |
210 {$I-} |
203 assign(f, fileName); |
211 assign(f, fileName); |
204 reset(f, 1); |
212 reset(f, 1); |
205 tryDo(IOResult = 0, 'Error opening file ' + fileName, true); |
213 if checkFails(IOResult = 0, 'Error opening file ' + fileName, true) then |
|
214 exit; |
206 |
215 |
207 i:= 0; // avoid compiler hints |
216 i:= 0; // avoid compiler hints |
208 s[0]:= #0; |
217 s[0]:= #0; |
209 repeat |
218 repeat |
210 BlockRead(f, s[1], 255 - Length(ss), i); |
219 BlockRead(f, s[1], 255 - Length(ss), i); |
211 if i > 0 then |
220 if i > 0 then |
212 begin |
221 begin |
213 s[0]:= char(i); |
222 s[0]:= char(i); |
214 ss:= ss + s; |
223 ss:= ss + s; |
215 while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do |
224 while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) and allOK do |
216 begin |
225 begin |
217 ParseIPCCommand(copy(ss, 2, byte(ss[1]))); |
226 ParseIPCCommand(copy(ss, 2, byte(ss[1]))); |
218 Delete(ss, 1, Succ(byte(ss[1]))); |
227 Delete(ss, 1, Succ(byte(ss[1]))); |
219 end |
228 end |
220 end |
229 end |
221 until i = 0; |
230 until (i = 0) or (not allOK); |
222 |
231 |
223 close(f) |
232 close(f) |
224 {$I+} |
233 {$I+} |
225 end; |
234 end; |
226 |
235 |
282 begin |
291 begin |
283 isPonged:= false; |
292 isPonged:= false; |
284 repeat |
293 repeat |
285 IPCCheckSock; |
294 IPCCheckSock; |
286 SDL_Delay(1) |
295 SDL_Delay(1) |
287 until isPonged |
296 until isPonged or (not allOK) |
288 end; |
297 end; |
289 |
298 |
290 procedure SendIPCAndWaitReply(s: shortstring); |
299 procedure SendIPCAndWaitReply(s: shortstring); |
291 begin |
300 begin |
292 SendIPC(s); |
301 SendIPC(s); |
389 end; |
398 end; |
390 RemoveCmd |
399 RemoveCmd |
391 end; |
400 end; |
392 |
401 |
393 if (headcmd <> nil) and tmpflag and (not CurrentTeam^.hasGone) then |
402 if (headcmd <> nil) and tmpflag and (not CurrentTeam^.hasGone) then |
394 TryDo(GameTicks < LongWord(hiTicks shl 16) + headcmd^.loTime, |
403 checkFails(GameTicks < LongWord(hiTicks shl 16) + headcmd^.loTime, |
395 'oops, queue error. in buffer: ' + headcmd^.cmd + |
404 'oops, queue error. in buffer: ' + headcmd^.cmd + |
396 ' (' + IntToStr(GameTicks) + ' > ' + |
405 ' (' + IntToStr(GameTicks) + ' > ' + |
397 IntToStr(hiTicks shl 16 + headcmd^.loTime) + ')', |
406 IntToStr(hiTicks shl 16 + headcmd^.loTime) + ')', |
398 true); |
407 true); |
399 |
408 |