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