author | displacer |
Wed, 09 Jan 2008 20:26:31 +0000 | |
changeset 695 | 34a93d123712 |
parent 691 | 0a534a03437e |
child 753 | 40fc0deb388f |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
393 | 3 |
* Copyright (c) 2004-2007 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
4 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
4 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
19 |
function CheckNoTeamOrHH: boolean; |
|
351 | 20 |
var Result: boolean; |
4 | 21 |
begin |
602 | 22 |
Result:= (CurrentTeam = nil) or (CurrentHedgehog^.Gear = nil); |
4 | 23 |
{$IFDEF DEBUGFILE} |
24 |
if Result then |
|
25 |
if CurrentTeam = nil then AddFileLog('CONSOLE: CurTeam = nil') |
|
351 | 26 |
else AddFileLog('CONSOLE: CurTeam <> nil, Gear = nil'); |
4 | 27 |
{$ENDIF} |
351 | 28 |
CheckNoTeamOrHH:= Result |
4 | 29 |
end; |
30 |
//////////////////////////////////////////////////////////////////////////////// |
|
31 |
procedure chQuit(var s: shortstring); |
|
32 |
begin |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
312
diff
changeset
|
33 |
SendIPC('Q'); |
4 | 34 |
GameState:= gsExit |
35 |
end; |
|
36 |
||
205 | 37 |
procedure chCheckProto(var s: shortstring); |
371 | 38 |
var i, c: LongInt; |
205 | 39 |
begin |
40 |
if isDeveloperMode then |
|
41 |
begin |
|
42 |
val(s, i, c); |
|
43 |
if (c <> 0) or (i = 0) then exit; |
|
44 |
TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old', true); |
|
45 |
TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new', true) |
|
46 |
end |
|
47 |
end; |
|
48 |
||
4 | 49 |
procedure chAddTeam(var s: shortstring); |
549 | 50 |
var Color: Longword; |
605 | 51 |
ts: shortstring; |
4 | 52 |
begin |
145 | 53 |
if isDeveloperMode then |
54 |
begin |
|
605 | 55 |
SplitBySpace(s, ts); |
549 | 56 |
val(s, Color); |
57 |
TryDo(Color <> 0, 'Error: black team color', true); |
|
351 | 58 |
|
549 | 59 |
AddTeam(Color); |
605 | 60 |
CurrentTeam^.TeamName:= ts; |
549 | 61 |
if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true |
546 | 62 |
end |
4 | 63 |
end; |
64 |
||
65 |
procedure chTeamLocal(var s: shortstring); |
|
66 |
begin |
|
67 |
if not isDeveloperMode then exit; |
|
68 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
|
351 | 69 |
CurrentTeam^.ExtDriven:= true |
4 | 70 |
end; |
71 |
||
72 |
procedure chGrave(var s: shortstring); |
|
73 |
begin |
|
74 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
|
75 |
if s[1]='"' then Delete(s, 1, 1); |
|
76 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 77 |
CurrentTeam^.GraveName:= s |
4 | 78 |
end; |
79 |
||
80 |
procedure chFort(var s: shortstring); |
|
81 |
begin |
|
82 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
|
83 |
if s[1]='"' then Delete(s, 1, 1); |
|
84 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 85 |
CurrentTeam^.FortName:= s |
4 | 86 |
end; |
87 |
||
312 | 88 |
procedure chAddHH(var id: shortstring); |
4 | 89 |
var s: shortstring; |
90 |
Gear: PGear; |
|
91 |
begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
92 |
if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
312 | 93 |
with CurrentTeam^ do |
94 |
begin |
|
95 |
SplitBySpace(id, s); |
|
602 | 96 |
CurrentHedgehog:= @Hedgehogs[HedgehogsNumber]; |
97 |
val(id, CurrentHedgehog^.BotLevel); |
|
498 | 98 |
Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0); |
605 | 99 |
SplitBySpace(s, id); |
495 | 100 |
val(s, Gear^.Health); |
351 | 101 |
TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true); |
102 |
PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam; |
|
606
9d800fdfd3bd
Add ammostores in frontend, should help further ammostores implemetation
unc0rr
parents:
605
diff
changeset
|
103 |
Hedgehogs[HedgehogsNumber].AmmoStore:= TeamsCount - 1; // FIXME HACK to get ammostores work |
312 | 104 |
Hedgehogs[HedgehogsNumber].Gear:= Gear; |
605 | 105 |
Hedgehogs[HedgehogsNumber].Name:= id; |
312 | 106 |
inc(HedgehogsNumber) |
107 |
end |
|
4 | 108 |
end; |
109 |
||
604
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
110 |
procedure chSetHHCoords(var x: shortstring); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
111 |
var y: shortstring; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
112 |
t: Longint; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
113 |
begin |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
114 |
if (not isDeveloperMode) or (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then exit; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
115 |
SplitBySpace(x, y); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
116 |
val(x, t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
117 |
CurrentHedgehog^.Gear^.X:= int2hwFloat(t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
118 |
val(y, t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
119 |
CurrentHedgehog^.Gear^.Y:= int2hwFloat(t) |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
120 |
end; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
121 |
|
288 | 122 |
procedure chAddAmmoStore(var descr: shortstring); |
123 |
begin |
|
124 |
AddAmmoStore(descr) |
|
125 |
end; |
|
126 |
||
4 | 127 |
procedure chBind(var id: shortstring); |
128 |
var s: shortstring; |
|
371 | 129 |
b: LongInt; |
4 | 130 |
begin |
131 |
if CurrentTeam = nil then exit; |
|
132 |
SplitBySpace(id, s); |
|
133 |
if s[1]='"' then Delete(s, 1, 1); |
|
134 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
135 |
b:= KeyNameToCode(id); |
|
351 | 136 |
if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
137 |
else CurrentTeam^.Binds[b]:= s |
|
4 | 138 |
end; |
139 |
||
140 |
procedure chLeft_p(var s: shortstring); |
|
141 |
begin |
|
142 |
if CheckNoTeamOrHH then exit; |
|
176 | 143 |
bShowFinger:= false; |
351 | 144 |
if not CurrentTeam^.ExtDriven then SendIPC('L'); |
602 | 145 |
with CurrentHedgehog^.Gear^ do |
4 | 146 |
Message:= Message or gm_Left |
147 |
end; |
|
148 |
||
149 |
procedure chLeft_m(var s: shortstring); |
|
150 |
begin |
|
151 |
if CheckNoTeamOrHH then exit; |
|
351 | 152 |
if not CurrentTeam^.ExtDriven then SendIPC('l'); |
602 | 153 |
with CurrentHedgehog^.Gear^ do |
4 | 154 |
Message:= Message and not gm_Left |
155 |
end; |
|
156 |
||
157 |
procedure chRight_p(var s: shortstring); |
|
158 |
begin |
|
159 |
if CheckNoTeamOrHH then exit; |
|
176 | 160 |
bShowFinger:= false; |
351 | 161 |
if not CurrentTeam^.ExtDriven then SendIPC('R'); |
602 | 162 |
with CurrentHedgehog^.Gear^ do |
4 | 163 |
Message:= Message or gm_Right |
164 |
end; |
|
165 |
||
166 |
procedure chRight_m(var s: shortstring); |
|
167 |
begin |
|
168 |
if CheckNoTeamOrHH then exit; |
|
351 | 169 |
if not CurrentTeam^.ExtDriven then SendIPC('r'); |
602 | 170 |
with CurrentHedgehog^.Gear^ do |
4 | 171 |
Message:= Message and not gm_Right |
172 |
end; |
|
173 |
||
174 |
procedure chUp_p(var s: shortstring); |
|
175 |
begin |
|
176 |
if CheckNoTeamOrHH then exit; |
|
176 | 177 |
bShowFinger:= false; |
351 | 178 |
if not CurrentTeam^.ExtDriven then SendIPC('U'); |
602 | 179 |
with CurrentHedgehog^.Gear^ do |
4 | 180 |
Message:= Message or gm_Up |
181 |
end; |
|
182 |
||
183 |
procedure chUp_m(var s: shortstring); |
|
184 |
begin |
|
185 |
if CheckNoTeamOrHH then exit; |
|
351 | 186 |
if not CurrentTeam^.ExtDriven then SendIPC('u'); |
602 | 187 |
with CurrentHedgehog^.Gear^ do |
4 | 188 |
Message:= Message and not gm_Up |
189 |
end; |
|
190 |
||
191 |
procedure chDown_p(var s: shortstring); |
|
192 |
begin |
|
193 |
if CheckNoTeamOrHH then exit; |
|
176 | 194 |
bShowFinger:= false; |
351 | 195 |
if not CurrentTeam^.ExtDriven then SendIPC('D'); |
602 | 196 |
with CurrentHedgehog^.Gear^ do |
4 | 197 |
Message:= Message or gm_Down |
198 |
end; |
|
199 |
||
200 |
procedure chDown_m(var s: shortstring); |
|
201 |
begin |
|
202 |
if CheckNoTeamOrHH then exit; |
|
351 | 203 |
if not CurrentTeam^.ExtDriven then SendIPC('d'); |
602 | 204 |
with CurrentHedgehog^.Gear^ do |
4 | 205 |
Message:= Message and not gm_Down |
206 |
end; |
|
207 |
||
208 |
procedure chLJump(var s: shortstring); |
|
209 |
begin |
|
210 |
if CheckNoTeamOrHH then exit; |
|
176 | 211 |
bShowFinger:= false; |
351 | 212 |
if not CurrentTeam^.ExtDriven then SendIPC('j'); |
602 | 213 |
with CurrentHedgehog^.Gear^ do |
4 | 214 |
Message:= Message or gm_LJump |
215 |
end; |
|
216 |
||
217 |
procedure chHJump(var s: shortstring); |
|
218 |
begin |
|
219 |
if CheckNoTeamOrHH then exit; |
|
176 | 220 |
bShowFinger:= false; |
351 | 221 |
if not CurrentTeam^.ExtDriven then SendIPC('J'); |
602 | 222 |
with CurrentHedgehog^.Gear^ do |
4 | 223 |
Message:= Message or gm_HJump |
224 |
end; |
|
225 |
||
226 |
procedure chAttack_p(var s: shortstring); |
|
227 |
begin |
|
228 |
if CheckNoTeamOrHH then exit; |
|
176 | 229 |
bShowFinger:= false; |
602 | 230 |
with CurrentHedgehog^.Gear^ do |
4 | 231 |
begin |
351 | 232 |
{$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear^.State = '+inttostr(State));{$ENDIF} |
542 | 233 |
if ((State and gstHHDriven) <> 0) and |
234 |
((State and (gstAttacked or gstHHChooseTarget)) = 0) then |
|
4 | 235 |
begin |
602 | 236 |
FollowGear:= CurrentHedgehog^.Gear; |
351 | 237 |
if not CurrentTeam^.ExtDriven then SendIPC('A'); |
4 | 238 |
Message:= Message or gm_Attack |
239 |
end |
|
240 |
end |
|
241 |
end; |
|
242 |
||
243 |
procedure chAttack_m(var s: shortstring); |
|
244 |
begin |
|
245 |
if CheckNoTeamOrHH then exit; |
|
602 | 246 |
with CurrentHedgehog^.Gear^ do |
4 | 247 |
begin |
351 | 248 |
if not CurrentTeam^.ExtDriven and |
95 | 249 |
((Message and gm_Attack) <> 0) then SendIPC('a'); |
250 |
Message:= Message and not gm_Attack |
|
4 | 251 |
end |
252 |
end; |
|
253 |
||
254 |
procedure chSwitch(var s: shortstring); |
|
255 |
begin |
|
256 |
if CheckNoTeamOrHH then exit; |
|
351 | 257 |
if not CurrentTeam^.ExtDriven then SendIPC('S'); |
602 | 258 |
with CurrentHedgehog^.Gear^ do |
4 | 259 |
Message:= Message or gm_Switch |
260 |
end; |
|
261 |
||
262 |
procedure chNextTurn(var s: shortstring); |
|
263 |
begin |
|
264 |
if AllInactive then |
|
265 |
begin |
|
351 | 266 |
if not CurrentTeam^.ExtDriven then SendIPC('N'); |
593 | 267 |
TickTrigger(trigTurns); |
4 | 268 |
{$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF} |
269 |
SwitchHedgehog; |
|
270 |
end |
|
271 |
end; |
|
272 |
||
273 |
procedure chSay(var s: shortstring); |
|
274 |
begin |
|
275 |
WriteLnToConsole('> ' + s); |
|
276 |
SendIPC('s'+s) |
|
277 |
end; |
|
278 |
||
279 |
procedure chTimer(var s: shortstring); |
|
280 |
begin |
|
281 |
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit; |
|
176 | 282 |
bShowFinger:= false; |
602 | 283 |
with CurrentHedgehog^ do |
351 | 284 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then |
4 | 285 |
begin |
351 | 286 |
Ammo^[CurSlot, CurAmmo].Timer:= 1000 * (byte(s[1]) - 48); |
4 | 287 |
with CurrentTeam^ do |
70 | 288 |
ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); |
351 | 289 |
if not CurrentTeam^.ExtDriven then SendIPC(s); |
4 | 290 |
end |
291 |
end; |
|
292 |
||
293 |
procedure chSlot(var s: shortstring); |
|
294 |
var slot: LongWord; |
|
295 |
caSlot, caAmmo: PLongword; |
|
296 |
begin |
|
95 | 297 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
176 | 298 |
bShowFinger:= false; |
4 | 299 |
slot:= byte(s[1]) - 49; |
10 | 300 |
if slot > cMaxSlotIndex then exit; |
351 | 301 |
if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); |
4 | 302 |
with CurrentTeam^ do |
303 |
begin |
|
304 |
with Hedgehogs[CurrHedgehog] do |
|
305 |
begin |
|
351 | 306 |
if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
431 | 307 |
or ((Gear^.State and gstHHDriven) = 0) then exit; |
308 |
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
4 | 309 |
if CurAmmoGear = nil then begin caSlot:= @CurSlot; caAmmo:= @CurAmmo end |
310 |
else begin caSlot:= @AltSlot; caAmmo:= @AltAmmo end; |
|
311 |
if caSlot^ = slot then |
|
312 |
begin |
|
313 |
inc(caAmmo^); |
|
351 | 314 |
if (caAmmo^ > cMaxSlotAmmoIndex) or (Ammo^[slot, caAmmo^].Count = 0) then caAmmo^:= 0 |
4 | 315 |
end else |
351 | 316 |
if Ammo^[slot, 0].Count > 0 then |
4 | 317 |
begin |
318 |
caSlot^:= slot; |
|
319 |
caAmmo^:= 0; |
|
320 |
end; |
|
321 |
end; |
|
70 | 322 |
ApplyAmmoChanges(Hedgehogs[CurrHedgehog]) |
4 | 323 |
end |
324 |
end; |
|
325 |
||
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
326 |
procedure doPut(putX, putY: LongInt; fromAI: boolean); |
4 | 327 |
begin |
328 |
if CheckNoTeamOrHH then exit; |
|
162 | 329 |
if bShowAmmoMenu then |
330 |
begin |
|
331 |
bSelected:= true; |
|
332 |
exit |
|
333 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
334 |
|
602 | 335 |
with CurrentHedgehog^.Gear^, |
336 |
CurrentHedgehog^ do |
|
4 | 337 |
if (State and gstHHChooseTarget) <> 0 then |
338 |
begin |
|
339 |
isCursorVisible:= false; |
|
351 | 340 |
if not CurrentTeam^.ExtDriven then |
4 | 341 |
begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
342 |
if fromAI then |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
343 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
344 |
TargetPoint.X:= putX; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
345 |
TargetPoint.Y:= putY |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
346 |
end else |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
347 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
348 |
SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
349 |
dec(TargetPoint.X, WorldDx); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
350 |
dec(TargetPoint.Y, WorldDy) |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
351 |
end; |
154
5667e6f38704
Network protocol uses integers in network byte order
unc0rr
parents:
145
diff
changeset
|
352 |
SendIPCXY('p', TargetPoint.X, TargetPoint.Y); |
4 | 353 |
end; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
354 |
State:= State and not gstHHChooseTarget; |
351 | 355 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then |
263 | 356 |
Message:= Message or gm_Attack; |
351 | 357 |
end else if CurrentTeam^.ExtDriven then OutError('got /put while not being in choose target mode', false) |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
358 |
|
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
359 |
end; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
360 |
|
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
361 |
procedure chPut(var s: shortstring); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
362 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
363 |
doPut(0, 0, false) |
4 | 364 |
end; |
365 |
||
366 |
procedure chCapture(var s: shortstring); |
|
367 |
begin |
|
368 |
flagMakeCapture:= true |
|
369 |
end; |
|
370 |
||
48 | 371 |
procedure chSkip(var s: shortstring); |
372 |
begin |
|
351 | 373 |
if not CurrentTeam^.ExtDriven then SendIPC(','); |
48 | 374 |
TurnTimeLeft:= 0 |
375 |
end; |
|
376 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
377 |
procedure chSetMap(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
378 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
379 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
380 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
381 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
382 |
InitStepsFlags:= InitStepsFlags or cifMap |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
383 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
384 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
385 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
386 |
procedure chSetTheme(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
387 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
388 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
389 |
begin |
80 | 390 |
Pathz[ptCurrTheme]:= Pathz[ptThemes] + '/' + s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
391 |
InitStepsFlags:= InitStepsFlags or cifTheme |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
392 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
393 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
394 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
395 |
procedure chSetSeed(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
396 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
397 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
398 |
begin |
102 | 399 |
SetRandomSeed(s); |
81 | 400 |
cSeed:= s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
401 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
402 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
403 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
404 |
|
161 | 405 |
procedure chAmmoMenu(var s: shortstring); |
406 |
begin |
|
407 |
if CheckNoTeamOrHH then exit; |
|
408 |
with CurrentTeam^ do |
|
409 |
with Hedgehogs[CurrHedgehog] do |
|
410 |
begin |
|
162 | 411 |
bSelected:= false; |
682 | 412 |
|
161 | 413 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
351 | 414 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
415 |
or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
|
161 | 416 |
end |
417 |
end; |
|
418 |
||
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
419 |
procedure chFullScr(var s: shortstring); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
420 |
var flags: Longword; |
192 | 421 |
{$IFDEF DEBUGFILE} |
422 |
buf: array[byte] of char; |
|
423 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
424 |
begin |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
425 |
if Length(s) = 0 then cFullScreen:= not cFullScreen |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
426 |
else cFullScreen:= s = '1'; |
192 | 427 |
|
358 | 428 |
flags:= SDL_HWSURFACE or SDL_DOUBLEBUF or SDL_HWACCEL; |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
429 |
if cFullScreen then flags:= flags or SDL_FULLSCREEN |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
430 |
else SDL_WM_SetCaption('Hedgewars', nil); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
431 |
SDL_FreeSurface(SDLPrimSurface); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
432 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
192 | 433 |
|
434 |
{$IFDEF DEBUGFILE} |
|
435 |
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); |
|
436 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
437 |
TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true); |
351 | 438 |
PixelFormat:= SDLPrimSurface^.format |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
439 |
end; |
161 | 440 |
|
175 | 441 |
procedure chVol_p(var s: shortstring); |
174 | 442 |
begin |
175 | 443 |
inc(cVolumeDelta, 3) |
174 | 444 |
end; |
445 |
||
175 | 446 |
procedure chVol_m(var s: shortstring); |
174 | 447 |
begin |
175 | 448 |
dec(cVolumeDelta, 3) |
174 | 449 |
end; |
450 |
||
176 | 451 |
procedure chFindhh(var s: shortstring); |
452 |
begin |
|
453 |
if CheckNoTeamOrHH then exit; |
|
454 |
bShowFinger:= true; |
|
602 | 455 |
FollowGear:= CurrentHedgehog^.Gear |
176 | 456 |
end; |
457 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
458 |
procedure chPause(var s: shortstring); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
459 |
begin |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
460 |
isPaused:= not isPaused; |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
461 |
SDL_ShowCursor(ord(isPaused)) |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
462 |
end; |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
463 |
|
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
464 |
procedure chRotateMask(var s: shortstring); |
691 | 465 |
const map: array[0..7] of byte = (7,4,0,1,2,3,0,5); |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
466 |
begin |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
467 |
cTagsMask:= map[cTagsMask] |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
468 |
end; |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
469 |
|
589 | 470 |
procedure chAddTrigger(var s: shortstring); |
615 | 471 |
const MAXPARAMS = 16; |
472 |
var params: array[0..Pred(MAXPARAMS)] of Longword; |
|
473 |
i: LongInt; |
|
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
474 |
c: char; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
475 |
tmp: shortstring; |
589 | 476 |
begin |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
477 |
c:= s[1]; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
478 |
Delete(s, 1, 1); |
615 | 479 |
|
480 |
i:= 0; |
|
481 |
while (i < MAXPARAMS) and |
|
482 |
(Length(s) > 0) do |
|
483 |
begin |
|
484 |
SplitBySpace(s, tmp); |
|
485 |
val(s, params[i]); |
|
486 |
s:= tmp; |
|
487 |
inc(i) |
|
488 |
end; |
|
489 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
490 |
case c of |
613 | 491 |
's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER |
615 | 492 |
TryDo(i = 7, errmsgWrongNumber, true); |
493 |
AddTriggerSpawner(params[0], params[1], params[2], TGearType(params[3]), params[4], params[5], params[6]); |
|
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
494 |
end; |
613 | 495 |
'C': begin |
615 | 496 |
TryDo(i = 3, errmsgWrongNumber, true); |
497 |
AddTriggerSuccess(params[0], params[1], params[2]); |
|
498 |
end; |
|
499 |
'F': begin |
|
500 |
TryDo(i = 3, errmsgWrongNumber, true); |
|
501 |
AddTriggerFail(params[0], params[1], params[2]); |
|
613 | 502 |
end; |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
503 |
end |
589 | 504 |
end; |
626 | 505 |
|
506 |
procedure chSpeedup_p(var s: shortstring); |
|
507 |
begin |
|
508 |
isSpeed:= true |
|
509 |
end; |
|
510 |
||
511 |
procedure chSpeedup_m(var s: shortstring); |
|
512 |
begin |
|
513 |
isSpeed:= false |
|
514 |
end; |