112 end; |
112 end; |
113 |
113 |
114 procedure ParseIPCCommand(s: shortstring); |
114 procedure ParseIPCCommand(s: shortstring); |
115 var loTicks: Word; |
115 var loTicks: Word; |
116 begin |
116 begin |
|
117 |
117 case s[1] of |
118 case s[1] of |
118 '!': begin AddFileLog('Ping? Pong!'); isPonged:= true; end; |
119 '!': begin AddFileLog('Ping? Pong!'); isPonged:= true; end; |
119 '?': SendIPC(_S'!'); |
120 '?': SendIPC(_S'!'); |
120 'e': ParseCommand(copy(s, 2, Length(s) - 1), true); |
121 'e': ParseCommand(copy(s, 2, Length(s) - 1), true); |
121 'E': OutError(copy(s, 2, Length(s) - 1), true); |
122 'E': OutError(copy(s, 2, Length(s) - 1), true); |
166 OutError('IPC connection lost', true) |
167 OutError('IPC connection lost', true) |
167 end; |
168 end; |
168 end; |
169 end; |
169 |
170 |
170 procedure LoadRecordFromFile(fileName: shortstring); |
171 procedure LoadRecordFromFile(fileName: shortstring); |
171 var f: file; |
172 var f : File; |
172 ss: shortstring = ''; |
173 ss : shortstring = ''; |
173 i: LongInt; |
174 i : LongInt; |
174 s: shortstring; |
175 s : shortstring; |
|
176 t, tt : string; |
175 begin |
177 begin |
176 |
178 |
177 // set RDNLY on file open |
179 // set RDNLY on file open |
178 filemode:= 0; |
180 filemode:= 0; |
179 {$I-} |
181 {$I-} |
180 assign(f, fileName); |
182 assign(f, fileName); |
181 reset(f, 1); |
183 reset(f, 1); |
182 |
|
183 tryDo(IOResult = 0, 'Error opening file ' + fileName, true); |
184 tryDo(IOResult = 0, 'Error opening file ' + fileName, true); |
184 |
185 |
185 i:= 0; // avoid compiler hints |
186 i:= 0; // avoid compiler hints |
186 s[0]:= #0; |
187 s[0]:= #0; |
187 repeat |
188 repeat |
188 BlockRead(f, s[1], 255 - Length(ss), i); |
189 BlockRead(f, s[1], 255 - Length(ss), i); |
189 if i > 0 then |
190 if i > 0 then |
190 begin |
191 begin |
191 s[0]:= char(i); |
192 s[0]:= char(i); |
192 ss:= ss + s; |
193 ss:= ss + s; |
193 while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do |
194 while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do |
194 begin |
195 begin |
195 ParseIPCCommand(copy(ss, 2, byte(ss[1]))); |
196 ParseIPCCommand(copy(ss, 2, byte(ss[1]))); |
196 Delete(ss, 1, Succ(byte(ss[1]))) |
197 Delete(ss, 1, Succ(byte(ss[1]))); |
197 end |
198 end |
198 end |
199 end |
199 until i = 0; |
200 until i = 0; |
200 |
201 |
201 close(f) |
202 close(f) |
220 s[0]:= #251; |
221 s[0]:= #251; |
221 |
222 |
222 SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]); |
223 SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]); |
223 AddFileLog('[IPC out] '+ s[1]); |
224 AddFileLog('[IPC out] '+ s[1]); |
224 inc(s[0], 2); |
225 inc(s[0], 2); |
225 SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0]))) |
226 SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0]))); |
|
227 //log('SendIPC'); |
226 end |
228 end |
227 end; |
229 end; |
228 |
230 |
229 procedure SendIPCRaw(p: pointer; len: Longword); |
231 procedure SendIPCRaw(p: pointer; len: Longword); |
230 begin |
232 begin |