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