86 var i, c: LongInt; |
88 var i, c: LongInt; |
87 begin |
89 begin |
88 if isDeveloperMode then |
90 if isDeveloperMode then |
89 begin |
91 begin |
90 val(s, i, c); |
92 val(s, i, c); |
91 if (c <> 0) or (i = 0) then exit; |
93 if (c <> 0) or (i = 0) then |
|
94 exit; |
92 TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true); |
95 TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true); |
93 TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true); |
96 TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true); |
94 end |
97 end |
95 end; |
98 end; |
96 |
99 |
97 procedure chTeamLocal(var s: shortstring); |
100 procedure chTeamLocal(var s: shortstring); |
98 begin |
101 begin |
99 s:= s; // avoid compiler hint |
102 s:= s; // avoid compiler hint |
100 if not isDeveloperMode then exit; |
103 if not isDeveloperMode then |
101 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
104 exit; |
|
105 if CurrentTeam = nil then |
|
106 OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
102 CurrentTeam^.ExtDriven:= true |
107 CurrentTeam^.ExtDriven:= true |
103 end; |
108 end; |
104 |
109 |
105 procedure chGrave(var s: shortstring); |
110 procedure chGrave(var s: shortstring); |
106 begin |
111 begin |
107 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
112 if CurrentTeam = nil then |
108 if s[1]='"' then Delete(s, 1, 1); |
113 OutError(errmsgIncorrectUse + ' "/grave"', true); |
109 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
114 if s[1]='"' then |
|
115 Delete(s, 1, 1); |
|
116 if s[byte(s[0])]='"' then |
|
117 Delete(s, byte(s[0]), 1); |
110 CurrentTeam^.GraveName:= s |
118 CurrentTeam^.GraveName:= s |
111 end; |
119 end; |
112 |
120 |
113 procedure chFort(var s: shortstring); |
121 procedure chFort(var s: shortstring); |
114 begin |
122 begin |
115 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/fort"', true); |
123 if CurrentTeam = nil then |
116 if s[1]='"' then Delete(s, 1, 1); |
124 OutError(errmsgIncorrectUse + ' "/fort"', true); |
117 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
125 if s[1]='"' then |
|
126 Delete(s, 1, 1); |
|
127 if s[byte(s[0])]='"' then |
|
128 Delete(s, byte(s[0]), 1); |
118 CurrentTeam^.FortName:= s |
129 CurrentTeam^.FortName:= s |
119 end; |
130 end; |
120 |
131 |
121 procedure chFlag(var s: shortstring); |
132 procedure chFlag(var s: shortstring); |
122 begin |
133 begin |
123 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/flag"', true); |
134 if CurrentTeam = nil then |
124 if s[1]='"' then Delete(s, 1, 1); |
135 OutError(errmsgIncorrectUse + ' "/flag"', true); |
125 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
136 if s[1]='"' then |
|
137 Delete(s, 1, 1); |
|
138 if s[byte(s[0])]='"' then |
|
139 Delete(s, byte(s[0]), 1); |
126 CurrentTeam^.flag:= s |
140 CurrentTeam^.flag:= s |
127 end; |
141 end; |
128 |
142 |
129 procedure chScript(var s: shortstring); |
143 procedure chScript(var s: shortstring); |
130 begin |
144 begin |
131 if s[1]='"' then Delete(s, 1, 1); |
145 if s[1]='"' then |
132 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
146 Delete(s, 1, 1); |
|
147 if s[byte(s[0])]='"' then |
|
148 Delete(s, byte(s[0]), 1); |
133 cScriptName:= s; |
149 cScriptName:= s; |
134 ScriptLoad(s) |
150 ScriptLoad(s) |
135 end; |
151 end; |
136 |
152 |
137 procedure chSetHat(var s: shortstring); |
153 procedure chSetHat(var s: shortstring); |
138 begin |
154 begin |
139 if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
155 if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
140 with CurrentTeam^ do |
156 with CurrentTeam^ do |
141 begin |
157 begin |
142 if not CurrentHedgehog^.King then |
158 if not CurrentHedgehog^.King then |
143 if (s = '') or |
159 if (s = '') |
144 (((GameFlags and gfKing) <> 0) and (s = 'crown')) or |
160 or (((GameFlags and gfKing) <> 0) and (s = 'crown')) |
145 ((Length(s) > 39) and (Copy(s,1,8) = 'Reserved') and (Copy(s,9,32) <> PlayerHash)) then |
161 or ((Length(s) > 39) and (Copy(s,1,8) = 'Reserved') and (Copy(s,9,32) <> PlayerHash)) then |
146 CurrentHedgehog^.Hat:= 'NoHat' |
162 CurrentHedgehog^.Hat:= 'NoHat' |
147 else |
163 else |
148 CurrentHedgehog^.Hat:= s |
164 CurrentHedgehog^.Hat:= s |
149 end; |
165 end; |
150 end; |
166 end; |
198 end; |
214 end; |
199 |
215 |
200 procedure chLeft_p(var s: shortstring); |
216 procedure chLeft_p(var s: shortstring); |
201 begin |
217 begin |
202 s:= s; // avoid compiler hint |
218 s:= s; // avoid compiler hint |
203 if CheckNoTeamOrHH or isPaused then exit; |
219 if CheckNoTeamOrHH or isPaused then |
204 if not CurrentTeam^.ExtDriven then SendIPC('L'); |
220 exit; |
|
221 if not CurrentTeam^.ExtDriven then |
|
222 SendIPC('L'); |
205 bShowFinger:= false; |
223 bShowFinger:= false; |
206 with CurrentHedgehog^.Gear^ do |
224 with CurrentHedgehog^.Gear^ do |
207 Message:= Message or (gmLeft and InputMask); |
225 Message:= Message or (gmLeft and InputMask); |
208 ScriptCall('onLeft'); |
226 ScriptCall('onLeft'); |
209 end; |
227 end; |
210 |
228 |
211 procedure chLeft_m(var s: shortstring); |
229 procedure chLeft_m(var s: shortstring); |
212 begin |
230 begin |
213 s:= s; // avoid compiler hint |
231 s:= s; // avoid compiler hint |
214 if CheckNoTeamOrHH then exit; |
232 if CheckNoTeamOrHH then |
215 if not CurrentTeam^.ExtDriven then SendIPC('l'); |
233 exit; |
|
234 if not CurrentTeam^.ExtDriven then |
|
235 SendIPC('l'); |
216 with CurrentHedgehog^.Gear^ do |
236 with CurrentHedgehog^.Gear^ do |
217 Message:= Message and (not (gmLeft and InputMask)); |
237 Message:= Message and (not (gmLeft and InputMask)); |
218 ScriptCall('onLeftUp'); |
238 ScriptCall('onLeftUp'); |
219 end; |
239 end; |
220 |
240 |
221 procedure chRight_p(var s: shortstring); |
241 procedure chRight_p(var s: shortstring); |
222 begin |
242 begin |
223 s:= s; // avoid compiler hint |
243 s:= s; // avoid compiler hint |
224 if CheckNoTeamOrHH or isPaused then exit; |
244 if CheckNoTeamOrHH or isPaused then |
225 if not CurrentTeam^.ExtDriven then SendIPC('R'); |
245 exit; |
|
246 if not CurrentTeam^.ExtDriven then |
|
247 SendIPC('R'); |
226 bShowFinger:= false; |
248 bShowFinger:= false; |
227 with CurrentHedgehog^.Gear^ do |
249 with CurrentHedgehog^.Gear^ do |
228 Message:= Message or (gmRight and InputMask); |
250 Message:= Message or (gmRight and InputMask); |
229 ScriptCall('onRight'); |
251 ScriptCall('onRight'); |
230 end; |
252 end; |
231 |
253 |
232 procedure chRight_m(var s: shortstring); |
254 procedure chRight_m(var s: shortstring); |
233 begin |
255 begin |
234 s:= s; // avoid compiler hint |
256 s:= s; // avoid compiler hint |
235 if CheckNoTeamOrHH then exit; |
257 if CheckNoTeamOrHH then |
236 if not CurrentTeam^.ExtDriven then SendIPC('r'); |
258 exit; |
|
259 if not CurrentTeam^.ExtDriven then |
|
260 SendIPC('r'); |
237 with CurrentHedgehog^.Gear^ do |
261 with CurrentHedgehog^.Gear^ do |
238 Message:= Message and (not (gmRight and InputMask)); |
262 Message:= Message and (not (gmRight and InputMask)); |
239 ScriptCall('onRightUp'); |
263 ScriptCall('onRightUp'); |
240 end; |
264 end; |
241 |
265 |
242 procedure chUp_p(var s: shortstring); |
266 procedure chUp_p(var s: shortstring); |
243 begin |
267 begin |
244 s:= s; // avoid compiler hint |
268 s:= s; // avoid compiler hint |
245 if CheckNoTeamOrHH or isPaused then exit; |
269 if CheckNoTeamOrHH or isPaused then |
246 if not CurrentTeam^.ExtDriven then SendIPC('U'); |
270 exit; |
|
271 if not CurrentTeam^.ExtDriven then |
|
272 SendIPC('U'); |
247 bShowFinger:= false; |
273 bShowFinger:= false; |
248 with CurrentHedgehog^.Gear^ do |
274 with CurrentHedgehog^.Gear^ do |
249 Message:= Message or (gmUp and InputMask); |
275 Message:= Message or (gmUp and InputMask); |
250 ScriptCall('onUp'); |
276 ScriptCall('onUp'); |
251 end; |
277 end; |
252 |
278 |
253 procedure chUp_m(var s: shortstring); |
279 procedure chUp_m(var s: shortstring); |
254 begin |
280 begin |
255 s:= s; // avoid compiler hint |
281 s:= s; // avoid compiler hint |
256 if CheckNoTeamOrHH then exit; |
282 if CheckNoTeamOrHH then |
257 if not CurrentTeam^.ExtDriven then SendIPC('u'); |
283 exit; |
|
284 if not CurrentTeam^.ExtDriven then |
|
285 SendIPC('u'); |
258 with CurrentHedgehog^.Gear^ do |
286 with CurrentHedgehog^.Gear^ do |
259 Message:= Message and (not (gmUp and InputMask)); |
287 Message:= Message and (not (gmUp and InputMask)); |
260 ScriptCall('onUpUp'); |
288 ScriptCall('onUpUp'); |
261 end; |
289 end; |
262 |
290 |
263 procedure chDown_p(var s: shortstring); |
291 procedure chDown_p(var s: shortstring); |
264 begin |
292 begin |
265 s:= s; // avoid compiler hint |
293 s:= s; // avoid compiler hint |
266 if CheckNoTeamOrHH or isPaused then exit; |
294 if CheckNoTeamOrHH or isPaused then |
267 if not CurrentTeam^.ExtDriven then SendIPC('D'); |
295 exit; |
|
296 if not CurrentTeam^.ExtDriven then |
|
297 SendIPC('D'); |
268 bShowFinger:= false; |
298 bShowFinger:= false; |
269 with CurrentHedgehog^.Gear^ do |
299 with CurrentHedgehog^.Gear^ do |
270 Message:= Message or (gmDown and InputMask); |
300 Message:= Message or (gmDown and InputMask); |
271 ScriptCall('onDown'); |
301 ScriptCall('onDown'); |
272 end; |
302 end; |
273 |
303 |
274 procedure chDown_m(var s: shortstring); |
304 procedure chDown_m(var s: shortstring); |
275 begin |
305 begin |
276 s:= s; // avoid compiler hint |
306 s:= s; // avoid compiler hint |
277 if CheckNoTeamOrHH then exit; |
307 if CheckNoTeamOrHH then |
278 if not CurrentTeam^.ExtDriven then SendIPC('d'); |
308 exit; |
|
309 if not CurrentTeam^.ExtDriven then |
|
310 SendIPC('d'); |
279 with CurrentHedgehog^.Gear^ do |
311 with CurrentHedgehog^.Gear^ do |
280 Message:= Message and (not (gmDown and InputMask)); |
312 Message:= Message and (not (gmDown and InputMask)); |
281 ScriptCall('onDownUp'); |
313 ScriptCall('onDownUp'); |
282 end; |
314 end; |
283 |
315 |
284 procedure chPrecise_p(var s: shortstring); |
316 procedure chPrecise_p(var s: shortstring); |
285 begin |
317 begin |
286 s:= s; // avoid compiler hint |
318 s:= s; // avoid compiler hint |
287 if CheckNoTeamOrHH or isPaused then exit; |
319 if CheckNoTeamOrHH or isPaused then |
288 if not CurrentTeam^.ExtDriven then SendIPC('Z'); |
320 exit; |
|
321 if not CurrentTeam^.ExtDriven then |
|
322 SendIPC('Z'); |
289 bShowFinger:= false; |
323 bShowFinger:= false; |
290 with CurrentHedgehog^.Gear^ do |
324 with CurrentHedgehog^.Gear^ do |
291 Message:= Message or (gmPrecise and InputMask); |
325 Message:= Message or (gmPrecise and InputMask); |
292 ScriptCall('onPrecise'); |
326 ScriptCall('onPrecise'); |
293 end; |
327 end; |
294 |
328 |
295 procedure chPrecise_m(var s: shortstring); |
329 procedure chPrecise_m(var s: shortstring); |
296 begin |
330 begin |
297 s:= s; // avoid compiler hint |
331 s:= s; // avoid compiler hint |
298 if CheckNoTeamOrHH then exit; |
332 if CheckNoTeamOrHH then |
299 if not CurrentTeam^.ExtDriven then SendIPC('z'); |
333 exit; |
|
334 if not CurrentTeam^.ExtDriven then |
|
335 SendIPC('z'); |
300 with CurrentHedgehog^.Gear^ do |
336 with CurrentHedgehog^.Gear^ do |
301 Message:= Message and (not (gmPrecise and InputMask)); |
337 Message:= Message and (not (gmPrecise and InputMask)); |
302 ScriptCall('onPreciseUp'); |
338 ScriptCall('onPreciseUp'); |
303 end; |
339 end; |
304 |
340 |
305 procedure chLJump(var s: shortstring); |
341 procedure chLJump(var s: shortstring); |
306 begin |
342 begin |
307 s:= s; // avoid compiler hint |
343 s:= s; // avoid compiler hint |
308 if CheckNoTeamOrHH or isPaused then exit; |
344 if CheckNoTeamOrHH or isPaused then |
309 if not CurrentTeam^.ExtDriven then SendIPC('j'); |
345 exit; |
|
346 if not CurrentTeam^.ExtDriven then |
|
347 SendIPC('j'); |
310 bShowFinger:= false; |
348 bShowFinger:= false; |
311 with CurrentHedgehog^.Gear^ do |
349 with CurrentHedgehog^.Gear^ do |
312 Message:= Message or (gmLJump and InputMask); |
350 Message:= Message or (gmLJump and InputMask); |
313 ScriptCall('onLJump'); |
351 ScriptCall('onLJump'); |
314 end; |
352 end; |
315 |
353 |
316 procedure chHJump(var s: shortstring); |
354 procedure chHJump(var s: shortstring); |
317 begin |
355 begin |
318 s:= s; // avoid compiler hint |
356 s:= s; // avoid compiler hint |
319 if CheckNoTeamOrHH or isPaused then exit; |
357 if CheckNoTeamOrHH or isPaused then |
320 if not CurrentTeam^.ExtDriven then SendIPC('J'); |
358 exit; |
|
359 if not CurrentTeam^.ExtDriven then |
|
360 SendIPC('J'); |
321 bShowFinger:= false; |
361 bShowFinger:= false; |
322 with CurrentHedgehog^.Gear^ do |
362 with CurrentHedgehog^.Gear^ do |
323 Message:= Message or (gmHJump and InputMask); |
363 Message:= Message or (gmHJump and InputMask); |
324 ScriptCall('onHJump'); |
364 ScriptCall('onHJump'); |
325 end; |
365 end; |
326 |
366 |
327 procedure chAttack_p(var s: shortstring); |
367 procedure chAttack_p(var s: shortstring); |
328 begin |
368 begin |
329 s:= s; // avoid compiler hint |
369 s:= s; // avoid compiler hint |
330 if CheckNoTeamOrHH or isPaused then exit; |
370 if CheckNoTeamOrHH or isPaused then |
|
371 exit; |
331 bShowFinger:= false; |
372 bShowFinger:= false; |
332 with CurrentHedgehog^.Gear^ do |
373 with CurrentHedgehog^.Gear^ do |
333 begin |
374 begin |
334 AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State)); |
375 AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State)); |
335 if ((State and gstHHDriven) <> 0) then |
376 if ((State and gstHHDriven) <> 0) then |
336 begin |
377 begin |
337 FollowGear:= CurrentHedgehog^.Gear; |
378 FollowGear:= CurrentHedgehog^.Gear; |
338 if not CurrentTeam^.ExtDriven then SendIPC('A'); |
379 if not CurrentTeam^.ExtDriven then |
|
380 SendIPC('A'); |
339 Message:= Message or (gmAttack and InputMask); |
381 Message:= Message or (gmAttack and InputMask); |
340 ScriptCall('onAttack'); |
382 ScriptCall('onAttack'); |
341 end |
383 end |
342 end |
384 end |
343 end; |
385 end; |
344 |
386 |
345 procedure chAttack_m(var s: shortstring); |
387 procedure chAttack_m(var s: shortstring); |
346 begin |
388 begin |
347 s:= s; // avoid compiler hint |
389 s:= s; // avoid compiler hint |
348 if CheckNoTeamOrHH then exit; |
390 if CheckNoTeamOrHH then |
|
391 exit; |
349 with CurrentHedgehog^.Gear^ do |
392 with CurrentHedgehog^.Gear^ do |
350 begin |
393 begin |
351 if not CurrentTeam^.ExtDriven and |
394 if not CurrentTeam^.ExtDriven and |
352 ((Message and gmAttack) <> 0) then SendIPC('a'); |
395 ((Message and gmAttack) <> 0) then |
|
396 SendIPC('a'); |
353 Message:= Message and (not (gmAttack and InputMask)); |
397 Message:= Message and (not (gmAttack and InputMask)); |
354 ScriptCall('onAttackUp'); |
398 ScriptCall('onAttackUp'); |
355 end |
399 end |
356 end; |
400 end; |
357 |
401 |
358 procedure chSwitch(var s: shortstring); |
402 procedure chSwitch(var s: shortstring); |
359 begin |
403 begin |
360 s:= s; // avoid compiler hint |
404 s:= s; // avoid compiler hint |
361 if CheckNoTeamOrHH or isPaused then exit; |
405 if CheckNoTeamOrHH or isPaused then |
362 if not CurrentTeam^.ExtDriven then SendIPC('S'); |
406 exit; |
|
407 if not CurrentTeam^.ExtDriven then |
|
408 SendIPC('S'); |
363 bShowFinger:= false; |
409 bShowFinger:= false; |
364 with CurrentHedgehog^.Gear^ do |
410 with CurrentHedgehog^.Gear^ do |
365 Message:= Message or (gmSwitch and InputMask); |
411 Message:= Message or (gmSwitch and InputMask); |
366 ScriptCall('onSwitch'); |
412 ScriptCall('onSwitch'); |
367 end; |
413 end; |