equal
deleted
inserted
replaced
36 procedure IPCCheckSock; |
36 procedure IPCCheckSock; |
37 procedure NetGetNextCmd; |
37 procedure NetGetNextCmd; |
38 procedure doPut(putX, putY: LongInt; fromAI: boolean); |
38 procedure doPut(putX, putY: LongInt; fromAI: boolean); |
39 |
39 |
40 implementation |
40 implementation |
41 uses uConsole, uConsts, uVariables, uCommands, uUtils, uDebug, uFLIPC; |
41 uses uFLIPC, uFLTypes, uConsole, uConsts, uVariables, uCommands, uUtils, uDebug; |
42 |
42 |
43 const |
43 const |
44 cSendEmptyPacketTime = 1000; |
44 cSendEmptyPacketTime = 1000; |
45 cSendBufferSize = 1024; |
45 cSendBufferSize = 1024; |
46 |
46 |
54 2: (str: shortstring); |
54 2: (str: shortstring); |
55 end; |
55 end; |
56 |
56 |
57 var |
57 var |
58 isPonged: boolean; |
58 isPonged: boolean; |
59 |
59 |
60 headcmd: PCmd; |
60 headcmd: PCmd; |
61 lastcmd: PCmd; |
61 lastcmd: PCmd; |
62 |
62 |
63 flushDelayTicks: LongWord; |
63 flushDelayTicks: LongWord; |
|
64 SocketString: shortstring; |
64 sendBuffer: record |
65 sendBuffer: record |
65 buf: array[0..Pred(cSendBufferSize)] of byte; |
66 buf: array[0..Pred(cSendBufferSize)] of byte; |
66 count: Word; |
67 count: Word; |
67 end; |
68 end; |
68 |
69 |
154 AddFileLog('[IPC in] ' + sanitizeCharForLog(s[1]) + ' ticks ' + IntToStr(lastcmd^.loTime)); |
155 AddFileLog('[IPC in] ' + sanitizeCharForLog(s[1]) + ' ticks ' + IntToStr(lastcmd^.loTime)); |
155 end |
156 end |
156 end; |
157 end; |
157 |
158 |
158 procedure IPCCheckSock; |
159 procedure IPCCheckSock; |
|
160 var i, t: LongInt; |
|
161 msg: TIPCMessage; |
159 begin |
162 begin |
160 while ipcCheckFromFrontend() do |
163 while ipcCheckFromFrontend() do |
161 ParseIPCCommand(ipcReadFromFrontend()) |
164 begin |
|
165 msg:= ipcReadFromFrontend(); |
|
166 if msg.str[0] > #0 then |
|
167 ParseIPCCommand(msg.str) |
|
168 else begin |
|
169 i:= 0; |
|
170 while (i < msg.len) do |
|
171 begin |
|
172 if LongInt(SocketString[0]) + msg.len - i > 255 then |
|
173 t:= 255 - byte(SocketString[0]) |
|
174 else |
|
175 t:= msg.len - i; |
|
176 |
|
177 Move(PByteArray(msg.buf)^[i], SocketString[byte(SocketString[0]) + 1], t); |
|
178 inc(byte(SocketString[0]), t); |
|
179 inc(i, t); |
|
180 |
|
181 while byte(SocketString[0]) > byte(SocketString[1]) do |
|
182 begin |
|
183 ParseIPCCommand(copy(SocketString, 2, byte(SocketString[1]))); |
|
184 Delete(SocketString, 1, Succ(byte(SocketString[1]))) |
|
185 end; |
|
186 end; |
|
187 |
|
188 FreeMem(msg.buf, msg.len) |
|
189 end |
|
190 end |
162 end; |
191 end; |
163 |
192 |
164 procedure LoadRecordFromFile(fileName: shortstring); |
193 procedure LoadRecordFromFile(fileName: shortstring); |
165 var f : File; |
194 var f : File; |
166 ss : shortstring = ''; |
195 ss : shortstring = ''; |
439 RegisterVariable('fatal', @chFatalError, true ); |
468 RegisterVariable('fatal', @chFatalError, true ); |
440 |
469 |
441 headcmd:= nil; |
470 headcmd:= nil; |
442 lastcmd:= nil; |
471 lastcmd:= nil; |
443 isPonged:= false; |
472 isPonged:= false; |
|
473 SocketString:= ''; |
444 |
474 |
445 hiTicks:= 0; |
475 hiTicks:= 0; |
446 flushDelayTicks:= 0; |
476 flushDelayTicks:= 0; |
447 sendBuffer.count:= 0; |
477 sendBuffer.count:= 0; |
448 end; |
478 end; |