26 procedure SendIPC(s: shortstring); |
26 procedure SendIPC(s: shortstring); |
27 procedure SendIPCXY(cmd: char; X, Y: SmallInt); |
27 procedure SendIPCXY(cmd: char; X, Y: SmallInt); |
28 procedure SendIPCRaw(p: pointer; len: Longword); |
28 procedure SendIPCRaw(p: pointer; len: Longword); |
29 procedure SendIPCAndWaitReply(s: shortstring); |
29 procedure SendIPCAndWaitReply(s: shortstring); |
30 procedure SendIPCTimeInc; |
30 procedure SendIPCTimeInc; |
|
31 procedure LoadRecordFromFile(fileName: shortstring); |
31 procedure IPCWaitPongEvent; |
32 procedure IPCWaitPongEvent; |
32 procedure IPCCheckSock; |
33 procedure IPCCheckSock; |
33 procedure InitIPC; |
34 procedure InitIPC; |
34 procedure CloseIPC; |
35 procedure CloseIPC; |
35 procedure NetGetNextCmd; |
36 procedure NetGetNextCmd; |
134 end; |
135 end; |
135 |
136 |
136 procedure IPCCheckSock; |
137 procedure IPCCheckSock; |
137 const ss: string = ''; |
138 const ss: string = ''; |
138 var i: LongInt; |
139 var i: LongInt; |
139 buf: array[0..255] of byte; |
140 buf: array[0..255] of byte; |
140 s: shortstring absolute buf; |
141 s: shortstring absolute buf; |
141 begin |
142 begin |
|
143 if IPCSock = nil then |
|
144 exit; |
|
145 |
142 fds^.numsockets:= 0; |
146 fds^.numsockets:= 0; |
143 SDLNet_AddSocket(fds, IPCSock); |
147 SDLNet_AddSocket(fds, IPCSock); |
144 |
148 |
145 while SDLNet_CheckSockets(fds, 0) > 0 do |
149 while SDLNet_CheckSockets(fds, 0) > 0 do |
146 begin |
150 begin |
147 i:= SDLNet_TCP_Recv(IPCSock, @buf[1], 255 - Length(ss)); |
151 i:= SDLNet_TCP_Recv(IPCSock, @buf[1], 255 - Length(ss)); |
148 if i > 0 then |
152 if i > 0 then |
149 begin |
153 begin |
150 buf[0]:= i; |
154 buf[0]:= i; |
151 ss:= ss + s; |
155 ss:= ss + s; |
152 while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do |
156 while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do |
153 begin |
157 begin |
154 ParseIPCCommand(copy(ss, 2, byte(ss[1]))); |
158 ParseIPCCommand(copy(ss, 2, byte(ss[1]))); |
155 Delete(ss, 1, Succ(byte(ss[1]))) |
159 Delete(ss, 1, Succ(byte(ss[1]))) |
156 end |
160 end |
157 end else OutError('IPC connection lost', true) |
161 end else OutError('IPC connection lost', true) |
158 end; |
162 end; |
|
163 end; |
|
164 |
|
165 procedure LoadRecordFromFile(fileName: shortstring); |
|
166 var f: file; |
|
167 ss: string = ''; |
|
168 i: LongInt; |
|
169 buf: array[0..255] of byte; |
|
170 s: shortstring absolute buf; |
|
171 begin |
|
172 assign(f, fileName); |
|
173 |
|
174 reset(f, 1); |
|
175 |
|
176 repeat |
|
177 BlockRead(f, buf[1], 255 - Length(ss), i); |
|
178 if i > 0 then |
|
179 begin |
|
180 buf[0]:= i; |
|
181 ss:= ss + s; |
|
182 while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do |
|
183 begin |
|
184 ParseIPCCommand(copy(ss, 2, byte(ss[1]))); |
|
185 Delete(ss, 1, Succ(byte(ss[1]))) |
|
186 end |
|
187 end |
|
188 until i = 0; |
|
189 |
|
190 close(f) |
159 end; |
191 end; |
160 |
192 |
161 procedure SendIPC(s: shortstring); |
193 procedure SendIPC(s: shortstring); |
162 begin |
194 begin |
163 if IPCSock <> nil then |
195 if IPCSock <> nil then |