equal
deleted
inserted
replaced
140 end; |
140 end; |
141 |
141 |
142 procedure IPCCheckSock; |
142 procedure IPCCheckSock; |
143 const ss: shortstring = ''; |
143 const ss: shortstring = ''; |
144 var i: LongInt; |
144 var i: LongInt; |
145 buf: array[0..255] of byte; |
145 s: shortstring; |
146 s: shortstring absolute buf; |
|
147 begin |
146 begin |
148 if IPCSock = nil then |
147 if IPCSock = nil then |
149 exit; |
148 exit; |
150 |
149 |
151 fds^.numsockets:= 0; |
150 fds^.numsockets:= 0; |
152 SDLNet_AddSocket(fds, IPCSock); |
151 SDLNet_AddSocket(fds, IPCSock); |
153 |
152 |
154 while SDLNet_CheckSockets(fds, 0) > 0 do |
153 while SDLNet_CheckSockets(fds, 0) > 0 do |
155 begin |
154 begin |
156 i:= SDLNet_TCP_Recv(IPCSock, @buf[1], 255 - Length(ss)); |
155 i:= SDLNet_TCP_Recv(IPCSock, @s[1], 255 - Length(ss)); |
157 if i > 0 then |
156 if i > 0 then |
158 begin |
157 begin |
159 buf[0]:= i; |
158 s[0]:= char(i); |
160 ss:= ss + s; |
159 ss:= ss + s; |
161 while (Length(ss) > 1) and (Length(ss) > byte(ss[1])) do |
160 while (Length(ss) > 1) and (Length(ss) > byte(ss[1])) do |
162 begin |
161 begin |
163 ParseIPCCommand(copy(ss, 2, byte(ss[1]))); |
162 ParseIPCCommand(copy(ss, 2, byte(ss[1]))); |
164 Delete(ss, 1, Succ(byte(ss[1]))) |
163 Delete(ss, 1, Succ(byte(ss[1]))) |
169 |
168 |
170 procedure LoadRecordFromFile(fileName: shortstring); |
169 procedure LoadRecordFromFile(fileName: shortstring); |
171 var f: file; |
170 var f: file; |
172 ss: shortstring = ''; |
171 ss: shortstring = ''; |
173 i: LongInt; |
172 i: LongInt; |
174 buf: array[0..255] of byte; |
173 s: shortstring; |
175 s: shortstring absolute buf; |
|
176 begin |
174 begin |
177 |
175 |
178 // set RDNLY on file open |
176 // set RDNLY on file open |
179 filemode:= 0; |
177 filemode:= 0; |
180 {$I-} |
178 {$I-} |
182 reset(f, 1); |
180 reset(f, 1); |
183 |
181 |
184 tryDo(IOResult = 0, 'Error opening file ' + fileName, true); |
182 tryDo(IOResult = 0, 'Error opening file ' + fileName, true); |
185 |
183 |
186 i:= 0; // avoid compiler hints |
184 i:= 0; // avoid compiler hints |
187 buf[0]:= 0; |
185 s[0]:= #0; |
188 repeat |
186 repeat |
189 BlockRead(f, buf[1], 255 - Length(ss), i); |
187 BlockRead(f, s[1], 255 - Length(ss), i); |
190 if i > 0 then |
188 if i > 0 then |
191 begin |
189 begin |
192 buf[0]:= i; |
190 s[0]:= char(i); |
193 ss:= ss + s; |
191 ss:= ss + s; |
194 while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do |
192 while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do |
195 begin |
193 begin |
196 ParseIPCCommand(copy(ss, 2, byte(ss[1]))); |
194 ParseIPCCommand(copy(ss, 2, byte(ss[1]))); |
197 Delete(ss, 1, Succ(byte(ss[1]))) |
195 Delete(ss, 1, Succ(byte(ss[1]))) |
313 ParseCommand('chatmsg ' + s, true); |
311 ParseCommand('chatmsg ' + s, true); |
314 WriteLnToConsole(s) |
312 WriteLnToConsole(s) |
315 end; |
313 end; |
316 'b': begin |
314 'b': begin |
317 s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); |
315 s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); |
318 ParseCommand('chatmsg '#4 + s, true); |
316 ParseCommand('chatmsg ' + #4 + s, true); |
319 WriteLnToConsole(s) |
317 WriteLnToConsole(s) |
320 end; |
318 end; |
321 // TODO: deprecate 'F' |
319 // TODO: deprecate 'F' |
322 'F': ParseCommand('teamgone ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
320 'F': ParseCommand('teamgone ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); |
323 'N': begin |
321 'N': begin |