author | unc0rr |
Fri, 08 Aug 2008 19:34:55 +0000 | |
changeset 1180 | e56317fdf78d |
parent 1127 | 7e1b94a0fc1f |
child 1242 | 4aca5f7b2504 |
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 |
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 |
end |
|
285 |
end; |
|
286 |
||
287 |
procedure chSay(var s: shortstring); |
|
288 |
begin |
|
950 | 289 |
s:= UserNick + ': ' + s; |
290 |
AddChatString(s); |
|
291 |
SendIPC('s' + s) |
|
4 | 292 |
end; |
293 |
||
294 |
procedure chTimer(var s: shortstring); |
|
295 |
begin |
|
296 |
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit; |
|
176 | 297 |
bShowFinger:= false; |
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
298 |
if not CurrentTeam^.ExtDriven then SendIPC(s); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
299 |
with CurrentHedgehog^.Gear^ do |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
300 |
begin |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
301 |
Message:= Message or gm_Timer; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
302 |
MsgParam:= byte(s[1]) - ord('0') |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
303 |
end |
4 | 304 |
end; |
305 |
||
306 |
procedure chSlot(var s: shortstring); |
|
307 |
var slot: LongWord; |
|
308 |
begin |
|
95 | 309 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
176 | 310 |
bShowFinger:= false; |
4 | 311 |
slot:= byte(s[1]) - 49; |
10 | 312 |
if slot > cMaxSlotIndex then exit; |
351 | 313 |
if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); |
783 | 314 |
with CurrentHedgehog^.Gear^ do |
4 | 315 |
begin |
783 | 316 |
Message:= Message or gm_Slot; |
317 |
MsgParam:= slot |
|
318 |
end |
|
319 |
end; |
|
320 |
||
321 |
procedure chSetWeapon(var s: shortstring); |
|
322 |
begin |
|
323 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
784 | 324 |
|
325 |
if TAmmoType(s[1]) > High(TAmmoType) then exit; |
|
326 |
||
327 |
if not CurrentTeam^.ExtDriven then SendIPC('w' + s); |
|
328 |
||
783 | 329 |
with CurrentHedgehog^.Gear^ do |
330 |
begin |
|
331 |
Message:= Message or gm_Weapon; |
|
784 | 332 |
MsgParam:= byte(s[1]) |
4 | 333 |
end |
334 |
end; |
|
335 |
||
1035 | 336 |
procedure chTaunt(var s: shortstring); |
337 |
begin |
|
338 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
339 |
||
340 |
if TWave(s[1]) > High(TWave) then exit; |
|
341 |
||
342 |
if not CurrentTeam^.ExtDriven then SendIPC('t' + s); |
|
343 |
||
344 |
with CurrentHedgehog^.Gear^ do |
|
345 |
begin |
|
346 |
Message:= Message or gm_Animate; |
|
347 |
MsgParam:= byte(s[1]) |
|
348 |
end |
|
349 |
end; |
|
350 |
||
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
351 |
procedure doPut(putX, putY: LongInt; fromAI: boolean); |
4 | 352 |
begin |
353 |
if CheckNoTeamOrHH then exit; |
|
162 | 354 |
if bShowAmmoMenu then |
355 |
begin |
|
356 |
bSelected:= true; |
|
357 |
exit |
|
358 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
359 |
|
602 | 360 |
with CurrentHedgehog^.Gear^, |
361 |
CurrentHedgehog^ do |
|
4 | 362 |
if (State and gstHHChooseTarget) <> 0 then |
363 |
begin |
|
364 |
isCursorVisible:= false; |
|
351 | 365 |
if not CurrentTeam^.ExtDriven then |
4 | 366 |
begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
367 |
if fromAI then |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
368 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
369 |
TargetPoint.X:= putX; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
370 |
TargetPoint.Y:= putY |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
371 |
end else |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
372 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
373 |
SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
374 |
dec(TargetPoint.X, WorldDx); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
375 |
dec(TargetPoint.Y, WorldDy) |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
376 |
end; |
154
5667e6f38704
Network protocol uses integers in network byte order
unc0rr
parents:
145
diff
changeset
|
377 |
SendIPCXY('p', TargetPoint.X, TargetPoint.Y); |
4 | 378 |
end; |
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
379 |
State:= State and not gstHHChooseTarget; |
351 | 380 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then |
263 | 381 |
Message:= Message or gm_Attack; |
351 | 382 |
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
|
383 |
end; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
384 |
|
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
385 |
procedure chPut(var s: shortstring); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
386 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
387 |
doPut(0, 0, false) |
4 | 388 |
end; |
389 |
||
390 |
procedure chCapture(var s: shortstring); |
|
391 |
begin |
|
392 |
flagMakeCapture:= true |
|
393 |
end; |
|
394 |
||
48 | 395 |
procedure chSkip(var s: shortstring); |
396 |
begin |
|
351 | 397 |
if not CurrentTeam^.ExtDriven then SendIPC(','); |
871 | 398 |
uStats.Skipped; |
917 | 399 |
skipFlag:= true |
48 | 400 |
end; |
401 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
402 |
procedure chSetMap(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
403 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
404 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
405 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
406 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
407 |
InitStepsFlags:= InitStepsFlags or cifMap |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
408 |
end |
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 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
411 |
procedure chSetTheme(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
412 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
413 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
414 |
begin |
80 | 415 |
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
|
416 |
InitStepsFlags:= InitStepsFlags or cifTheme |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
417 |
end |
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 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
420 |
procedure chSetSeed(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
421 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
422 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
423 |
begin |
102 | 424 |
SetRandomSeed(s); |
81 | 425 |
cSeed:= s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
426 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
427 |
end |
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 |
|
161 | 430 |
procedure chAmmoMenu(var s: shortstring); |
431 |
begin |
|
432 |
if CheckNoTeamOrHH then exit; |
|
433 |
with CurrentTeam^ do |
|
434 |
with Hedgehogs[CurrHedgehog] do |
|
435 |
begin |
|
162 | 436 |
bSelected:= false; |
682 | 437 |
|
161 | 438 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
351 | 439 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
440 |
or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
|
161 | 441 |
end |
442 |
end; |
|
443 |
||
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
444 |
procedure chFullScr(var s: shortstring); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
445 |
var flags: Longword; |
192 | 446 |
{$IFDEF DEBUGFILE} |
447 |
buf: array[byte] of char; |
|
448 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
449 |
begin |
1051
dfdd5dfe97d4
Enable fullscreen switching back, now it's bound on F12
unc0rr
parents:
1035
diff
changeset
|
450 |
if Length(s) = 0 then cFullScreen:= not cFullScreen |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
451 |
else cFullScreen:= s = '1'; |
192 | 452 |
|
905 | 453 |
{$IFDEF DEBUGFILE} |
454 |
AddFileLog('Prepare to change video parameters...'); |
|
455 |
{$ENDIF} |
|
753 | 456 |
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
457 |
||
1127 | 458 |
flags:= SDL_OPENGL;// or SDL_RESIZABLE; |
1121
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
459 |
if cFullScreen then |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
460 |
begin |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
461 |
flags:= flags or SDL_FULLSCREEN; |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
462 |
cScreenWidth:= cInitWidth; |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
463 |
cScreenHeight:= cInitHeight |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
464 |
end |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
465 |
else SDL_WM_SetCaption('Hedgewars', nil); |
905 | 466 |
{$IFDEF DEBUGFILE} |
467 |
AddFileLog('Freeing old primary surface...'); |
|
468 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
469 |
SDL_FreeSurface(SDLPrimSurface); |
904 | 470 |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
471 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
904 | 472 |
SDLTry(SDLPrimSurface <> nil, true); |
192 | 473 |
|
905 | 474 |
{$IFDEF DEBUGFILE} |
475 |
AddFileLog('Setting up OpenGL...'); |
|
476 |
{$ENDIF} |
|
753 | 477 |
SetupOpenGL(); |
478 |
||
192 | 479 |
{$IFDEF DEBUGFILE} |
480 |
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); |
|
481 |
{$ENDIF} |
|
351 | 482 |
PixelFormat:= SDLPrimSurface^.format |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
483 |
end; |
161 | 484 |
|
175 | 485 |
procedure chVol_p(var s: shortstring); |
174 | 486 |
begin |
175 | 487 |
inc(cVolumeDelta, 3) |
174 | 488 |
end; |
489 |
||
175 | 490 |
procedure chVol_m(var s: shortstring); |
174 | 491 |
begin |
175 | 492 |
dec(cVolumeDelta, 3) |
174 | 493 |
end; |
494 |
||
176 | 495 |
procedure chFindhh(var s: shortstring); |
496 |
begin |
|
497 |
if CheckNoTeamOrHH then exit; |
|
498 |
bShowFinger:= true; |
|
602 | 499 |
FollowGear:= CurrentHedgehog^.Gear |
176 | 500 |
end; |
501 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
502 |
procedure chPause(var s: shortstring); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
503 |
begin |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
504 |
isPaused:= not isPaused; |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
505 |
SDL_ShowCursor(ord(isPaused)) |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
506 |
end; |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
507 |
|
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
508 |
procedure chRotateMask(var s: shortstring); |
691 | 509 |
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
|
510 |
begin |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
511 |
cTagsMask:= map[cTagsMask] |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
512 |
end; |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
513 |
|
589 | 514 |
procedure chAddTrigger(var s: shortstring); |
615 | 515 |
const MAXPARAMS = 16; |
516 |
var params: array[0..Pred(MAXPARAMS)] of Longword; |
|
517 |
i: LongInt; |
|
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
518 |
c: char; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
519 |
tmp: shortstring; |
589 | 520 |
begin |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
521 |
c:= s[1]; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
522 |
Delete(s, 1, 1); |
615 | 523 |
|
524 |
i:= 0; |
|
525 |
while (i < MAXPARAMS) and |
|
526 |
(Length(s) > 0) do |
|
527 |
begin |
|
528 |
SplitBySpace(s, tmp); |
|
529 |
val(s, params[i]); |
|
530 |
s:= tmp; |
|
531 |
inc(i) |
|
532 |
end; |
|
533 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
534 |
case c of |
613 | 535 |
's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER |
615 | 536 |
TryDo(i = 7, errmsgWrongNumber, true); |
537 |
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
|
538 |
end; |
613 | 539 |
'C': begin |
615 | 540 |
TryDo(i = 3, errmsgWrongNumber, true); |
541 |
AddTriggerSuccess(params[0], params[1], params[2]); |
|
542 |
end; |
|
543 |
'F': begin |
|
544 |
TryDo(i = 3, errmsgWrongNumber, true); |
|
545 |
AddTriggerFail(params[0], params[1], params[2]); |
|
613 | 546 |
end; |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
547 |
end |
589 | 548 |
end; |
626 | 549 |
|
550 |
procedure chSpeedup_p(var s: shortstring); |
|
551 |
begin |
|
552 |
isSpeed:= true |
|
553 |
end; |
|
554 |
||
555 |
procedure chSpeedup_m(var s: shortstring); |
|
556 |
begin |
|
557 |
isSpeed:= false |
|
558 |
end; |
|
946 | 559 |
|
560 |
procedure chChat(var s: shortstring); |
|
561 |
begin |
|
990
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
562 |
GameState:= gsChat; |
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
563 |
KeyPressChat(27) |
946 | 564 |
end; |
991 | 565 |
|
566 |
procedure chHistory(var s: shortstring); |
|
567 |
begin |
|
568 |
uChat.showAll:= not uChat.showAll |
|
569 |
end; |