author | unc0rr |
Sun, 01 Jun 2008 18:54:10 +0000 | |
changeset 969 | 7e8a87136fae |
parent 950 | feb18ec0c5c2 |
child 970 | 1bd9a4eafbc3 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
883 | 3 |
* Copyright (c) 2004-2008 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 |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
753
diff
changeset
|
59 |
Color:= Color or $FF000000; |
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
753
diff
changeset
|
60 |
|
549 | 61 |
AddTeam(Color); |
605 | 62 |
CurrentTeam^.TeamName:= ts; |
549 | 63 |
if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true |
546 | 64 |
end |
4 | 65 |
end; |
66 |
||
67 |
procedure chTeamLocal(var s: shortstring); |
|
68 |
begin |
|
69 |
if not isDeveloperMode then exit; |
|
70 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
|
351 | 71 |
CurrentTeam^.ExtDriven:= true |
4 | 72 |
end; |
73 |
||
74 |
procedure chGrave(var s: shortstring); |
|
75 |
begin |
|
76 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
|
77 |
if s[1]='"' then Delete(s, 1, 1); |
|
78 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 79 |
CurrentTeam^.GraveName:= s |
4 | 80 |
end; |
81 |
||
82 |
procedure chFort(var s: shortstring); |
|
83 |
begin |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
753
diff
changeset
|
84 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/fort"', true); |
4 | 85 |
if s[1]='"' then Delete(s, 1, 1); |
86 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 87 |
CurrentTeam^.FortName:= s |
4 | 88 |
end; |
89 |
||
312 | 90 |
procedure chAddHH(var id: shortstring); |
4 | 91 |
var s: shortstring; |
92 |
Gear: PGear; |
|
93 |
begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
94 |
if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
312 | 95 |
with CurrentTeam^ do |
96 |
begin |
|
97 |
SplitBySpace(id, s); |
|
602 | 98 |
CurrentHedgehog:= @Hedgehogs[HedgehogsNumber]; |
99 |
val(id, CurrentHedgehog^.BotLevel); |
|
498 | 100 |
Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0); |
605 | 101 |
SplitBySpace(s, id); |
495 | 102 |
val(s, Gear^.Health); |
351 | 103 |
TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true); |
104 |
PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam; |
|
606
9d800fdfd3bd
Add ammostores in frontend, should help further ammostores implemetation
unc0rr
parents:
605
diff
changeset
|
105 |
Hedgehogs[HedgehogsNumber].AmmoStore:= TeamsCount - 1; // FIXME HACK to get ammostores work |
312 | 106 |
Hedgehogs[HedgehogsNumber].Gear:= Gear; |
605 | 107 |
Hedgehogs[HedgehogsNumber].Name:= id; |
312 | 108 |
inc(HedgehogsNumber) |
109 |
end |
|
4 | 110 |
end; |
111 |
||
604
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
112 |
procedure chSetHHCoords(var x: shortstring); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
113 |
var y: shortstring; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
114 |
t: Longint; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
115 |
begin |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
116 |
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
|
117 |
SplitBySpace(x, y); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
118 |
val(x, t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
119 |
CurrentHedgehog^.Gear^.X:= int2hwFloat(t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
120 |
val(y, t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
121 |
CurrentHedgehog^.Gear^.Y:= int2hwFloat(t) |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
122 |
end; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
123 |
|
288 | 124 |
procedure chAddAmmoStore(var descr: shortstring); |
125 |
begin |
|
126 |
AddAmmoStore(descr) |
|
127 |
end; |
|
128 |
||
4 | 129 |
procedure chBind(var id: shortstring); |
130 |
var s: shortstring; |
|
371 | 131 |
b: LongInt; |
4 | 132 |
begin |
133 |
if CurrentTeam = nil then exit; |
|
134 |
SplitBySpace(id, s); |
|
135 |
if s[1]='"' then Delete(s, 1, 1); |
|
136 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
137 |
b:= KeyNameToCode(id); |
|
351 | 138 |
if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
139 |
else CurrentTeam^.Binds[b]:= s |
|
4 | 140 |
end; |
141 |
||
142 |
procedure chLeft_p(var s: shortstring); |
|
143 |
begin |
|
144 |
if CheckNoTeamOrHH then exit; |
|
176 | 145 |
bShowFinger:= false; |
351 | 146 |
if not CurrentTeam^.ExtDriven then SendIPC('L'); |
602 | 147 |
with CurrentHedgehog^.Gear^ do |
4 | 148 |
Message:= Message or gm_Left |
149 |
end; |
|
150 |
||
151 |
procedure chLeft_m(var s: shortstring); |
|
152 |
begin |
|
153 |
if CheckNoTeamOrHH then exit; |
|
351 | 154 |
if not CurrentTeam^.ExtDriven then SendIPC('l'); |
602 | 155 |
with CurrentHedgehog^.Gear^ do |
4 | 156 |
Message:= Message and not gm_Left |
157 |
end; |
|
158 |
||
159 |
procedure chRight_p(var s: shortstring); |
|
160 |
begin |
|
161 |
if CheckNoTeamOrHH then exit; |
|
176 | 162 |
bShowFinger:= false; |
351 | 163 |
if not CurrentTeam^.ExtDriven then SendIPC('R'); |
602 | 164 |
with CurrentHedgehog^.Gear^ do |
4 | 165 |
Message:= Message or gm_Right |
166 |
end; |
|
167 |
||
168 |
procedure chRight_m(var s: shortstring); |
|
169 |
begin |
|
170 |
if CheckNoTeamOrHH then exit; |
|
351 | 171 |
if not CurrentTeam^.ExtDriven then SendIPC('r'); |
602 | 172 |
with CurrentHedgehog^.Gear^ do |
4 | 173 |
Message:= Message and not gm_Right |
174 |
end; |
|
175 |
||
176 |
procedure chUp_p(var s: shortstring); |
|
177 |
begin |
|
178 |
if CheckNoTeamOrHH then exit; |
|
176 | 179 |
bShowFinger:= false; |
351 | 180 |
if not CurrentTeam^.ExtDriven then SendIPC('U'); |
602 | 181 |
with CurrentHedgehog^.Gear^ do |
4 | 182 |
Message:= Message or gm_Up |
183 |
end; |
|
184 |
||
185 |
procedure chUp_m(var s: shortstring); |
|
186 |
begin |
|
187 |
if CheckNoTeamOrHH then exit; |
|
351 | 188 |
if not CurrentTeam^.ExtDriven then SendIPC('u'); |
602 | 189 |
with CurrentHedgehog^.Gear^ do |
4 | 190 |
Message:= Message and not gm_Up |
191 |
end; |
|
192 |
||
193 |
procedure chDown_p(var s: shortstring); |
|
194 |
begin |
|
195 |
if CheckNoTeamOrHH then exit; |
|
176 | 196 |
bShowFinger:= false; |
351 | 197 |
if not CurrentTeam^.ExtDriven then SendIPC('D'); |
602 | 198 |
with CurrentHedgehog^.Gear^ do |
4 | 199 |
Message:= Message or gm_Down |
200 |
end; |
|
201 |
||
202 |
procedure chDown_m(var s: shortstring); |
|
203 |
begin |
|
204 |
if CheckNoTeamOrHH then exit; |
|
351 | 205 |
if not CurrentTeam^.ExtDriven then SendIPC('d'); |
602 | 206 |
with CurrentHedgehog^.Gear^ do |
4 | 207 |
Message:= Message and not gm_Down |
208 |
end; |
|
209 |
||
210 |
procedure chLJump(var s: shortstring); |
|
211 |
begin |
|
212 |
if CheckNoTeamOrHH then exit; |
|
176 | 213 |
bShowFinger:= false; |
351 | 214 |
if not CurrentTeam^.ExtDriven then SendIPC('j'); |
602 | 215 |
with CurrentHedgehog^.Gear^ do |
4 | 216 |
Message:= Message or gm_LJump |
217 |
end; |
|
218 |
||
219 |
procedure chHJump(var s: shortstring); |
|
220 |
begin |
|
221 |
if CheckNoTeamOrHH then exit; |
|
176 | 222 |
bShowFinger:= false; |
351 | 223 |
if not CurrentTeam^.ExtDriven then SendIPC('J'); |
602 | 224 |
with CurrentHedgehog^.Gear^ do |
4 | 225 |
Message:= Message or gm_HJump |
226 |
end; |
|
227 |
||
228 |
procedure chAttack_p(var s: shortstring); |
|
229 |
begin |
|
230 |
if CheckNoTeamOrHH then exit; |
|
176 | 231 |
bShowFinger:= false; |
602 | 232 |
with CurrentHedgehog^.Gear^ do |
4 | 233 |
begin |
351 | 234 |
{$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear^.State = '+inttostr(State));{$ENDIF} |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
927
diff
changeset
|
235 |
if ((State and gstHHDriven) <> 0) then |
4 | 236 |
begin |
602 | 237 |
FollowGear:= CurrentHedgehog^.Gear; |
351 | 238 |
if not CurrentTeam^.ExtDriven then SendIPC('A'); |
4 | 239 |
Message:= Message or gm_Attack |
240 |
end |
|
241 |
end |
|
242 |
end; |
|
243 |
||
244 |
procedure chAttack_m(var s: shortstring); |
|
245 |
begin |
|
246 |
if CheckNoTeamOrHH then exit; |
|
602 | 247 |
with CurrentHedgehog^.Gear^ do |
4 | 248 |
begin |
351 | 249 |
if not CurrentTeam^.ExtDriven and |
95 | 250 |
((Message and gm_Attack) <> 0) then SendIPC('a'); |
251 |
Message:= Message and not gm_Attack |
|
4 | 252 |
end |
253 |
end; |
|
254 |
||
255 |
procedure chSwitch(var s: shortstring); |
|
256 |
begin |
|
257 |
if CheckNoTeamOrHH then exit; |
|
351 | 258 |
if not CurrentTeam^.ExtDriven then SendIPC('S'); |
602 | 259 |
with CurrentHedgehog^.Gear^ do |
4 | 260 |
Message:= Message or gm_Switch |
261 |
end; |
|
262 |
||
263 |
procedure chNextTurn(var s: shortstring); |
|
264 |
begin |
|
265 |
if AllInactive then |
|
266 |
begin |
|
351 | 267 |
if not CurrentTeam^.ExtDriven then SendIPC('N'); |
593 | 268 |
TickTrigger(trigTurns); |
4 | 269 |
{$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF} |
270 |
SwitchHedgehog; |
|
271 |
end |
|
272 |
end; |
|
273 |
||
274 |
procedure chSay(var s: shortstring); |
|
275 |
begin |
|
950 | 276 |
s:= UserNick + ': ' + s; |
277 |
AddChatString(s); |
|
278 |
SendIPC('s' + s) |
|
4 | 279 |
end; |
280 |
||
281 |
procedure chTimer(var s: shortstring); |
|
282 |
begin |
|
283 |
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit; |
|
176 | 284 |
bShowFinger:= false; |
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
285 |
if not CurrentTeam^.ExtDriven then SendIPC(s); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
286 |
with CurrentHedgehog^.Gear^ do |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
287 |
begin |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
288 |
Message:= Message or gm_Timer; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
289 |
MsgParam:= byte(s[1]) - ord('0') |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
290 |
end |
4 | 291 |
end; |
292 |
||
293 |
procedure chSlot(var s: shortstring); |
|
294 |
var slot: LongWord; |
|
295 |
begin |
|
95 | 296 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
176 | 297 |
bShowFinger:= false; |
4 | 298 |
slot:= byte(s[1]) - 49; |
10 | 299 |
if slot > cMaxSlotIndex then exit; |
351 | 300 |
if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); |
783 | 301 |
with CurrentHedgehog^.Gear^ do |
4 | 302 |
begin |
783 | 303 |
Message:= Message or gm_Slot; |
304 |
MsgParam:= slot |
|
305 |
end |
|
306 |
end; |
|
307 |
||
308 |
procedure chSetWeapon(var s: shortstring); |
|
309 |
begin |
|
310 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
784 | 311 |
|
312 |
if TAmmoType(s[1]) > High(TAmmoType) then exit; |
|
313 |
||
314 |
if not CurrentTeam^.ExtDriven then SendIPC('w' + s); |
|
315 |
||
783 | 316 |
with CurrentHedgehog^.Gear^ do |
317 |
begin |
|
318 |
Message:= Message or gm_Weapon; |
|
784 | 319 |
MsgParam:= byte(s[1]) |
4 | 320 |
end |
321 |
end; |
|
322 |
||
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
323 |
procedure doPut(putX, putY: LongInt; fromAI: boolean); |
4 | 324 |
begin |
325 |
if CheckNoTeamOrHH then exit; |
|
162 | 326 |
if bShowAmmoMenu then |
327 |
begin |
|
328 |
bSelected:= true; |
|
329 |
exit |
|
330 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
331 |
|
602 | 332 |
with CurrentHedgehog^.Gear^, |
333 |
CurrentHedgehog^ do |
|
4 | 334 |
if (State and gstHHChooseTarget) <> 0 then |
335 |
begin |
|
336 |
isCursorVisible:= false; |
|
351 | 337 |
if not CurrentTeam^.ExtDriven then |
4 | 338 |
begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
339 |
if fromAI then |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
340 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
341 |
TargetPoint.X:= putX; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
342 |
TargetPoint.Y:= putY |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
343 |
end else |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
344 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
345 |
SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
346 |
dec(TargetPoint.X, WorldDx); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
347 |
dec(TargetPoint.Y, WorldDy) |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
348 |
end; |
154
5667e6f38704
Network protocol uses integers in network byte order
unc0rr
parents:
145
diff
changeset
|
349 |
SendIPCXY('p', TargetPoint.X, TargetPoint.Y); |
4 | 350 |
end; |
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
351 |
State:= State and not gstHHChooseTarget; |
351 | 352 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then |
263 | 353 |
Message:= Message or gm_Attack; |
351 | 354 |
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
|
355 |
end; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
356 |
|
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
357 |
procedure chPut(var s: shortstring); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
358 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
359 |
doPut(0, 0, false) |
4 | 360 |
end; |
361 |
||
362 |
procedure chCapture(var s: shortstring); |
|
363 |
begin |
|
364 |
flagMakeCapture:= true |
|
365 |
end; |
|
366 |
||
48 | 367 |
procedure chSkip(var s: shortstring); |
368 |
begin |
|
351 | 369 |
if not CurrentTeam^.ExtDriven then SendIPC(','); |
871 | 370 |
uStats.Skipped; |
917 | 371 |
skipFlag:= true |
48 | 372 |
end; |
373 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
374 |
procedure chSetMap(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
375 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
376 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
377 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
378 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
379 |
InitStepsFlags:= InitStepsFlags or cifMap |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
380 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
381 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
382 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
383 |
procedure chSetTheme(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
384 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
385 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
386 |
begin |
80 | 387 |
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
|
388 |
InitStepsFlags:= InitStepsFlags or cifTheme |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
389 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
390 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
391 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
392 |
procedure chSetSeed(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
393 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
394 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
395 |
begin |
102 | 396 |
SetRandomSeed(s); |
81 | 397 |
cSeed:= s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
398 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
399 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
400 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
401 |
|
161 | 402 |
procedure chAmmoMenu(var s: shortstring); |
403 |
begin |
|
404 |
if CheckNoTeamOrHH then exit; |
|
405 |
with CurrentTeam^ do |
|
406 |
with Hedgehogs[CurrHedgehog] do |
|
407 |
begin |
|
162 | 408 |
bSelected:= false; |
682 | 409 |
|
161 | 410 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
351 | 411 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
412 |
or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
|
161 | 413 |
end |
414 |
end; |
|
415 |
||
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
416 |
procedure chFullScr(var s: shortstring); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
417 |
var flags: Longword; |
192 | 418 |
{$IFDEF DEBUGFILE} |
419 |
buf: array[byte] of char; |
|
420 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
421 |
begin |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
422 |
if Length(s) = 0 then cFullScreen:= not cFullScreen |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
423 |
else cFullScreen:= s = '1'; |
192 | 424 |
|
905 | 425 |
{$IFDEF DEBUGFILE} |
426 |
AddFileLog('Prepare to change video parameters...'); |
|
427 |
{$ENDIF} |
|
753 | 428 |
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
429 |
||
430 |
flags:= SDL_OPENGL; |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
431 |
if cFullScreen then flags:= flags or SDL_FULLSCREEN |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
432 |
else SDL_WM_SetCaption('Hedgewars', nil); |
905 | 433 |
{$IFDEF DEBUGFILE} |
434 |
AddFileLog('Freeing old primary surface...'); |
|
435 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
436 |
SDL_FreeSurface(SDLPrimSurface); |
904 | 437 |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
438 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
904 | 439 |
SDLTry(SDLPrimSurface <> nil, true); |
192 | 440 |
|
905 | 441 |
{$IFDEF DEBUGFILE} |
442 |
AddFileLog('Setting up OpenGL...'); |
|
443 |
{$ENDIF} |
|
753 | 444 |
SetupOpenGL(); |
445 |
||
192 | 446 |
{$IFDEF DEBUGFILE} |
447 |
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); |
|
448 |
{$ENDIF} |
|
351 | 449 |
PixelFormat:= SDLPrimSurface^.format |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
450 |
end; |
161 | 451 |
|
175 | 452 |
procedure chVol_p(var s: shortstring); |
174 | 453 |
begin |
175 | 454 |
inc(cVolumeDelta, 3) |
174 | 455 |
end; |
456 |
||
175 | 457 |
procedure chVol_m(var s: shortstring); |
174 | 458 |
begin |
175 | 459 |
dec(cVolumeDelta, 3) |
174 | 460 |
end; |
461 |
||
176 | 462 |
procedure chFindhh(var s: shortstring); |
463 |
begin |
|
464 |
if CheckNoTeamOrHH then exit; |
|
465 |
bShowFinger:= true; |
|
602 | 466 |
FollowGear:= CurrentHedgehog^.Gear |
176 | 467 |
end; |
468 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
469 |
procedure chPause(var s: shortstring); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
470 |
begin |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
471 |
isPaused:= not isPaused; |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
472 |
SDL_ShowCursor(ord(isPaused)) |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
473 |
end; |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
474 |
|
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
475 |
procedure chRotateMask(var s: shortstring); |
691 | 476 |
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
|
477 |
begin |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
478 |
cTagsMask:= map[cTagsMask] |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
479 |
end; |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
480 |
|
589 | 481 |
procedure chAddTrigger(var s: shortstring); |
615 | 482 |
const MAXPARAMS = 16; |
483 |
var params: array[0..Pred(MAXPARAMS)] of Longword; |
|
484 |
i: LongInt; |
|
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
485 |
c: char; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
486 |
tmp: shortstring; |
589 | 487 |
begin |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
488 |
c:= s[1]; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
489 |
Delete(s, 1, 1); |
615 | 490 |
|
491 |
i:= 0; |
|
492 |
while (i < MAXPARAMS) and |
|
493 |
(Length(s) > 0) do |
|
494 |
begin |
|
495 |
SplitBySpace(s, tmp); |
|
496 |
val(s, params[i]); |
|
497 |
s:= tmp; |
|
498 |
inc(i) |
|
499 |
end; |
|
500 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
501 |
case c of |
613 | 502 |
's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER |
615 | 503 |
TryDo(i = 7, errmsgWrongNumber, true); |
504 |
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
|
505 |
end; |
613 | 506 |
'C': begin |
615 | 507 |
TryDo(i = 3, errmsgWrongNumber, true); |
508 |
AddTriggerSuccess(params[0], params[1], params[2]); |
|
509 |
end; |
|
510 |
'F': begin |
|
511 |
TryDo(i = 3, errmsgWrongNumber, true); |
|
512 |
AddTriggerFail(params[0], params[1], params[2]); |
|
613 | 513 |
end; |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
514 |
end |
589 | 515 |
end; |
626 | 516 |
|
517 |
procedure chSpeedup_p(var s: shortstring); |
|
518 |
begin |
|
519 |
isSpeed:= true |
|
520 |
end; |
|
521 |
||
522 |
procedure chSpeedup_m(var s: shortstring); |
|
523 |
begin |
|
524 |
isSpeed:= false |
|
525 |
end; |
|
946 | 526 |
|
527 |
procedure chChat(var s: shortstring); |
|
528 |
begin |
|
529 |
GameState:= gsChat |
|
530 |
end; |