author | unc0rr |
Sun, 17 Jun 2007 14:48:15 +0000 | |
changeset 542 | ec26095f1bed |
parent 539 | 6a9bf1852bbc |
child 543 | 465e2ec8f05f |
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 |
351 | 22 |
Result:= (CurrentTeam = nil) or (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].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 |
||
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
49 |
const TeamsCount: Longword = 0; |
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
50 |
|
4 | 51 |
procedure chAddTeam(var s: shortstring); |
52 |
begin |
|
145 | 53 |
if isDeveloperMode then |
54 |
begin |
|
55 |
inc(TeamsCount); |
|
534 | 56 |
ParseCommand('ammstore 93919294221912103323', true); |
145 | 57 |
TryDo(TeamsCount <= 5, 'Too many teams', true); |
58 |
AddTeam |
|
59 |
end; |
|
351 | 60 |
|
61 |
if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true |
|
4 | 62 |
end; |
63 |
||
64 |
procedure chTeamLocal(var s: shortstring); |
|
65 |
begin |
|
66 |
if not isDeveloperMode then exit; |
|
67 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
|
351 | 68 |
CurrentTeam^.ExtDriven:= true |
4 | 69 |
end; |
70 |
||
71 |
procedure chName(var id: shortstring); |
|
72 |
var s: shortstring; |
|
73 |
begin |
|
74 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/name"', true); |
|
75 |
SplitBySpace(id, s); |
|
76 |
if s[1]='"' then Delete(s, 1, 1); |
|
77 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 78 |
if id = 'team' then CurrentTeam^.TeamName:= s |
83 | 79 |
else if (id[1] = 'h') and (id[2] = 'h') |
80 |
and (id[3] >= '0') and (id[3] <= chr(ord('0')+cMaxHHIndex)) then |
|
351 | 81 |
CurrentTeam^.Hedgehogs[byte(id[3])-48].Name:= s |
82 |
else OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
|
4 | 83 |
end; |
84 |
||
85 |
procedure chGrave(var s: shortstring); |
|
86 |
begin |
|
87 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
|
88 |
if s[1]='"' then Delete(s, 1, 1); |
|
89 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 90 |
CurrentTeam^.GraveName:= s |
4 | 91 |
end; |
92 |
||
93 |
procedure chFort(var s: shortstring); |
|
94 |
begin |
|
95 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
|
96 |
if s[1]='"' then Delete(s, 1, 1); |
|
97 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 98 |
CurrentTeam^.FortName:= s |
4 | 99 |
end; |
100 |
||
101 |
procedure chColor(var id: shortstring); |
|
102 |
begin |
|
103 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/color"', true); |
|
495 | 104 |
val(id, CurrentTeam^.Color); |
351 | 105 |
CurrentTeam^.AdjColor:= CurrentTeam^.Color; |
106 |
AdjustColor(CurrentTeam^.AdjColor) |
|
4 | 107 |
end; |
108 |
||
312 | 109 |
procedure chAddHH(var id: shortstring); |
4 | 110 |
var s: shortstring; |
111 |
Gear: PGear; |
|
112 |
begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
113 |
if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
312 | 114 |
with CurrentTeam^ do |
115 |
begin |
|
116 |
SplitBySpace(id, s); |
|
495 | 117 |
val(id, Hedgehogs[HedgehogsNumber].BotLevel); |
498 | 118 |
Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0); |
351 | 119 |
Gear^.Hedgehog:= @Hedgehogs[HedgehogsNumber]; |
495 | 120 |
val(s, Gear^.Health); |
351 | 121 |
TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true); |
122 |
PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam; |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
123 |
Hedgehogs[HedgehogsNumber].AmmoStore:= TeamsCount - 1; |
312 | 124 |
Hedgehogs[HedgehogsNumber].Gear:= Gear; |
125 |
inc(HedgehogsNumber) |
|
126 |
end |
|
4 | 127 |
end; |
128 |
||
288 | 129 |
procedure chAddAmmoStore(var descr: shortstring); |
130 |
begin |
|
131 |
AddAmmoStore(descr) |
|
132 |
end; |
|
133 |
||
4 | 134 |
procedure chBind(var id: shortstring); |
135 |
var s: shortstring; |
|
371 | 136 |
b: LongInt; |
4 | 137 |
begin |
138 |
if CurrentTeam = nil then exit; |
|
139 |
SplitBySpace(id, s); |
|
140 |
if s[1]='"' then Delete(s, 1, 1); |
|
141 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
142 |
b:= KeyNameToCode(id); |
|
351 | 143 |
if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
144 |
else CurrentTeam^.Binds[b]:= s |
|
4 | 145 |
end; |
146 |
||
147 |
procedure chLeft_p(var s: shortstring); |
|
148 |
begin |
|
149 |
if CheckNoTeamOrHH then exit; |
|
176 | 150 |
bShowFinger:= false; |
351 | 151 |
if not CurrentTeam^.ExtDriven then SendIPC('L'); |
152 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
|
4 | 153 |
Message:= Message or gm_Left |
154 |
end; |
|
155 |
||
156 |
procedure chLeft_m(var s: shortstring); |
|
157 |
begin |
|
158 |
if CheckNoTeamOrHH then exit; |
|
351 | 159 |
if not CurrentTeam^.ExtDriven then SendIPC('l'); |
160 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
|
4 | 161 |
Message:= Message and not gm_Left |
162 |
end; |
|
163 |
||
164 |
procedure chRight_p(var s: shortstring); |
|
165 |
begin |
|
166 |
if CheckNoTeamOrHH then exit; |
|
176 | 167 |
bShowFinger:= false; |
351 | 168 |
if not CurrentTeam^.ExtDriven then SendIPC('R'); |
169 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
|
4 | 170 |
Message:= Message or gm_Right |
171 |
end; |
|
172 |
||
173 |
procedure chRight_m(var s: shortstring); |
|
174 |
begin |
|
175 |
if CheckNoTeamOrHH then exit; |
|
351 | 176 |
if not CurrentTeam^.ExtDriven then SendIPC('r'); |
177 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
|
4 | 178 |
Message:= Message and not gm_Right |
179 |
end; |
|
180 |
||
181 |
procedure chUp_p(var s: shortstring); |
|
182 |
begin |
|
183 |
if CheckNoTeamOrHH then exit; |
|
176 | 184 |
bShowFinger:= false; |
351 | 185 |
if not CurrentTeam^.ExtDriven then SendIPC('U'); |
186 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
|
4 | 187 |
Message:= Message or gm_Up |
188 |
end; |
|
189 |
||
190 |
procedure chUp_m(var s: shortstring); |
|
191 |
begin |
|
192 |
if CheckNoTeamOrHH then exit; |
|
351 | 193 |
if not CurrentTeam^.ExtDriven then SendIPC('u'); |
194 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
|
4 | 195 |
Message:= Message and not gm_Up |
196 |
end; |
|
197 |
||
198 |
procedure chDown_p(var s: shortstring); |
|
199 |
begin |
|
200 |
if CheckNoTeamOrHH then exit; |
|
176 | 201 |
bShowFinger:= false; |
351 | 202 |
if not CurrentTeam^.ExtDriven then SendIPC('D'); |
203 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
|
4 | 204 |
Message:= Message or gm_Down |
205 |
end; |
|
206 |
||
207 |
procedure chDown_m(var s: shortstring); |
|
208 |
begin |
|
209 |
if CheckNoTeamOrHH then exit; |
|
351 | 210 |
if not CurrentTeam^.ExtDriven then SendIPC('d'); |
211 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
|
4 | 212 |
Message:= Message and not gm_Down |
213 |
end; |
|
214 |
||
215 |
procedure chLJump(var s: shortstring); |
|
216 |
begin |
|
217 |
if CheckNoTeamOrHH then exit; |
|
176 | 218 |
bShowFinger:= false; |
351 | 219 |
if not CurrentTeam^.ExtDriven then SendIPC('j'); |
220 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
|
4 | 221 |
Message:= Message or gm_LJump |
222 |
end; |
|
223 |
||
224 |
procedure chHJump(var s: shortstring); |
|
225 |
begin |
|
226 |
if CheckNoTeamOrHH then exit; |
|
176 | 227 |
bShowFinger:= false; |
351 | 228 |
if not CurrentTeam^.ExtDriven then SendIPC('J'); |
229 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
|
4 | 230 |
Message:= Message or gm_HJump |
231 |
end; |
|
232 |
||
233 |
procedure chAttack_p(var s: shortstring); |
|
234 |
begin |
|
235 |
if CheckNoTeamOrHH then exit; |
|
176 | 236 |
bShowFinger:= false; |
351 | 237 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
4 | 238 |
begin |
351 | 239 |
{$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear^.State = '+inttostr(State));{$ENDIF} |
542 | 240 |
if ((State and gstHHDriven) <> 0) and |
241 |
((State and (gstAttacked or gstHHChooseTarget)) = 0) then |
|
4 | 242 |
begin |
351 | 243 |
FollowGear:= CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear; |
244 |
if not CurrentTeam^.ExtDriven then SendIPC('A'); |
|
4 | 245 |
Message:= Message or gm_Attack |
246 |
end |
|
247 |
end |
|
248 |
end; |
|
249 |
||
250 |
procedure chAttack_m(var s: shortstring); |
|
251 |
begin |
|
252 |
if CheckNoTeamOrHH then exit; |
|
351 | 253 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
4 | 254 |
begin |
351 | 255 |
if not CurrentTeam^.ExtDriven and |
95 | 256 |
((Message and gm_Attack) <> 0) then SendIPC('a'); |
257 |
Message:= Message and not gm_Attack |
|
4 | 258 |
end |
259 |
end; |
|
260 |
||
261 |
procedure chSwitch(var s: shortstring); |
|
262 |
begin |
|
263 |
if CheckNoTeamOrHH then exit; |
|
351 | 264 |
if not CurrentTeam^.ExtDriven then SendIPC('S'); |
265 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
|
4 | 266 |
Message:= Message or gm_Switch |
267 |
end; |
|
268 |
||
269 |
procedure chNextTurn(var s: shortstring); |
|
270 |
begin |
|
271 |
if AllInactive then |
|
272 |
begin |
|
351 | 273 |
if not CurrentTeam^.ExtDriven then SendIPC('N'); |
4 | 274 |
{$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF} |
275 |
SwitchHedgehog; |
|
276 |
end |
|
277 |
end; |
|
278 |
||
279 |
procedure chSay(var s: shortstring); |
|
280 |
begin |
|
281 |
WriteLnToConsole('> ' + s); |
|
282 |
SendIPC('s'+s) |
|
283 |
end; |
|
284 |
||
285 |
procedure chTimer(var s: shortstring); |
|
286 |
begin |
|
287 |
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit; |
|
176 | 288 |
bShowFinger:= false; |
351 | 289 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do |
290 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then |
|
4 | 291 |
begin |
351 | 292 |
Ammo^[CurSlot, CurAmmo].Timer:= 1000 * (byte(s[1]) - 48); |
4 | 293 |
with CurrentTeam^ do |
70 | 294 |
ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); |
351 | 295 |
if not CurrentTeam^.ExtDriven then SendIPC(s); |
4 | 296 |
end |
297 |
end; |
|
298 |
||
299 |
procedure chSlot(var s: shortstring); |
|
300 |
var slot: LongWord; |
|
301 |
caSlot, caAmmo: PLongword; |
|
302 |
begin |
|
95 | 303 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
176 | 304 |
bShowFinger:= false; |
4 | 305 |
slot:= byte(s[1]) - 49; |
10 | 306 |
if slot > cMaxSlotIndex then exit; |
351 | 307 |
if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); |
4 | 308 |
with CurrentTeam^ do |
309 |
begin |
|
310 |
with Hedgehogs[CurrHedgehog] do |
|
311 |
begin |
|
351 | 312 |
if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
431 | 313 |
or ((Gear^.State and gstHHDriven) = 0) then exit; |
314 |
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
4 | 315 |
if CurAmmoGear = nil then begin caSlot:= @CurSlot; caAmmo:= @CurAmmo end |
316 |
else begin caSlot:= @AltSlot; caAmmo:= @AltAmmo end; |
|
317 |
if caSlot^ = slot then |
|
318 |
begin |
|
319 |
inc(caAmmo^); |
|
351 | 320 |
if (caAmmo^ > cMaxSlotAmmoIndex) or (Ammo^[slot, caAmmo^].Count = 0) then caAmmo^:= 0 |
4 | 321 |
end else |
351 | 322 |
if Ammo^[slot, 0].Count > 0 then |
4 | 323 |
begin |
324 |
caSlot^:= slot; |
|
325 |
caAmmo^:= 0; |
|
326 |
end; |
|
327 |
end; |
|
70 | 328 |
ApplyAmmoChanges(Hedgehogs[CurrHedgehog]) |
4 | 329 |
end |
330 |
end; |
|
331 |
||
332 |
procedure chPut(var s: shortstring); |
|
333 |
begin |
|
334 |
if CheckNoTeamOrHH then exit; |
|
162 | 335 |
if bShowAmmoMenu then |
336 |
begin |
|
337 |
bSelected:= true; |
|
338 |
exit |
|
339 |
end; |
|
351 | 340 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^, |
341 |
CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do |
|
4 | 342 |
if (State and gstHHChooseTarget) <> 0 then |
343 |
begin |
|
344 |
isCursorVisible:= false; |
|
351 | 345 |
if not CurrentTeam^.ExtDriven then |
4 | 346 |
begin |
347 |
SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y); |
|
348 |
dec(TargetPoint.X, WorldDx); |
|
349 |
dec(TargetPoint.Y, WorldDy); |
|
154
5667e6f38704
Network protocol uses integers in network byte order
unc0rr
parents:
145
diff
changeset
|
350 |
SendIPCXY('p', TargetPoint.X, TargetPoint.Y); |
4 | 351 |
end; |
352 |
State:= State and not gstHHChooseTarget; |
|
351 | 353 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then |
263 | 354 |
Message:= Message or gm_Attack; |
351 | 355 |
end else if CurrentTeam^.ExtDriven then OutError('got /put while not being in choose target mode', false) |
4 | 356 |
end; |
357 |
||
358 |
procedure chCapture(var s: shortstring); |
|
359 |
begin |
|
360 |
flagMakeCapture:= true |
|
361 |
end; |
|
362 |
||
48 | 363 |
procedure chSkip(var s: shortstring); |
364 |
begin |
|
351 | 365 |
if not CurrentTeam^.ExtDriven then SendIPC(','); |
48 | 366 |
TurnTimeLeft:= 0 |
367 |
end; |
|
368 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
369 |
procedure chSetMap(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
370 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
371 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
372 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
373 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
374 |
InitStepsFlags:= InitStepsFlags or cifMap |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
375 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
376 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
377 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
378 |
procedure chSetTheme(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
379 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
380 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
381 |
begin |
80 | 382 |
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
|
383 |
InitStepsFlags:= InitStepsFlags or cifTheme |
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 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
386 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
387 |
procedure chSetSeed(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
388 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
389 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
390 |
begin |
102 | 391 |
SetRandomSeed(s); |
81 | 392 |
cSeed:= s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
393 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
394 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
395 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
396 |
|
161 | 397 |
procedure chAmmoMenu(var s: shortstring); |
398 |
begin |
|
399 |
if CheckNoTeamOrHH then exit; |
|
400 |
with CurrentTeam^ do |
|
401 |
with Hedgehogs[CurrHedgehog] do |
|
402 |
begin |
|
162 | 403 |
bSelected:= false; |
161 | 404 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
351 | 405 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
406 |
or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
|
161 | 407 |
end |
408 |
end; |
|
409 |
||
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
410 |
procedure chFullScr(var s: shortstring); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
411 |
var flags: Longword; |
192 | 412 |
{$IFDEF DEBUGFILE} |
413 |
buf: array[byte] of char; |
|
414 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
415 |
begin |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
416 |
if Length(s) = 0 then cFullScreen:= not cFullScreen |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
417 |
else cFullScreen:= s = '1'; |
192 | 418 |
|
358 | 419 |
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
|
420 |
if cFullScreen then flags:= flags or SDL_FULLSCREEN |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
421 |
else SDL_WM_SetCaption('Hedgewars', nil); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
422 |
SDL_FreeSurface(SDLPrimSurface); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
423 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
192 | 424 |
|
425 |
{$IFDEF DEBUGFILE} |
|
426 |
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); |
|
427 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
428 |
TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true); |
351 | 429 |
PixelFormat:= SDLPrimSurface^.format |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
430 |
end; |
161 | 431 |
|
175 | 432 |
procedure chVol_p(var s: shortstring); |
174 | 433 |
begin |
175 | 434 |
inc(cVolumeDelta, 3) |
174 | 435 |
end; |
436 |
||
175 | 437 |
procedure chVol_m(var s: shortstring); |
174 | 438 |
begin |
175 | 439 |
dec(cVolumeDelta, 3) |
174 | 440 |
end; |
441 |
||
176 | 442 |
procedure chFindhh(var s: shortstring); |
443 |
begin |
|
444 |
if CheckNoTeamOrHH then exit; |
|
445 |
bShowFinger:= true; |
|
351 | 446 |
FollowGear:= CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear |
176 | 447 |
end; |
448 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
449 |
procedure chPause(var s: shortstring); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
450 |
begin |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
451 |
isPaused:= not isPaused; |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
452 |
SDL_ShowCursor(ord(isPaused)) |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
453 |
end; |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
454 |
|
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
455 |
procedure chRotateMask(var s: shortstring); |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
456 |
const map: array[0..7] of byte = (7,4,0,5,2,1,0,3); |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
457 |
begin |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
458 |
cTagsMask:= map[cTagsMask] |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
459 |
end; |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
460 |