author | unc0rr |
Wed, 25 Jun 2008 09:40:23 +0000 | |
changeset 1027 | 85007fde2738 |
parent 1022 | f6a3fcb329ca |
child 1035 | 6f5842bc481b |
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 |
||
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
337 |
procedure doPut(putX, putY: LongInt; fromAI: boolean); |
4 | 338 |
begin |
339 |
if CheckNoTeamOrHH then exit; |
|
162 | 340 |
if bShowAmmoMenu then |
341 |
begin |
|
342 |
bSelected:= true; |
|
343 |
exit |
|
344 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
345 |
|
602 | 346 |
with CurrentHedgehog^.Gear^, |
347 |
CurrentHedgehog^ do |
|
4 | 348 |
if (State and gstHHChooseTarget) <> 0 then |
349 |
begin |
|
350 |
isCursorVisible:= false; |
|
351 | 351 |
if not CurrentTeam^.ExtDriven then |
4 | 352 |
begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
353 |
if fromAI then |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
354 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
355 |
TargetPoint.X:= putX; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
356 |
TargetPoint.Y:= putY |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
357 |
end else |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
358 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
359 |
SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
360 |
dec(TargetPoint.X, WorldDx); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
361 |
dec(TargetPoint.Y, WorldDy) |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
362 |
end; |
154
5667e6f38704
Network protocol uses integers in network byte order
unc0rr
parents:
145
diff
changeset
|
363 |
SendIPCXY('p', TargetPoint.X, TargetPoint.Y); |
4 | 364 |
end; |
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
365 |
State:= State and not gstHHChooseTarget; |
351 | 366 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then |
263 | 367 |
Message:= Message or gm_Attack; |
351 | 368 |
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
|
369 |
end; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
370 |
|
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
371 |
procedure chPut(var s: shortstring); |
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 |
doPut(0, 0, false) |
4 | 374 |
end; |
375 |
||
376 |
procedure chCapture(var s: shortstring); |
|
377 |
begin |
|
378 |
flagMakeCapture:= true |
|
379 |
end; |
|
380 |
||
48 | 381 |
procedure chSkip(var s: shortstring); |
382 |
begin |
|
351 | 383 |
if not CurrentTeam^.ExtDriven then SendIPC(','); |
871 | 384 |
uStats.Skipped; |
917 | 385 |
skipFlag:= true |
48 | 386 |
end; |
387 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
388 |
procedure chSetMap(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
389 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
390 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
391 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
392 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
393 |
InitStepsFlags:= InitStepsFlags or cifMap |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
394 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
395 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
396 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
397 |
procedure chSetTheme(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
398 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
399 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
400 |
begin |
80 | 401 |
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
|
402 |
InitStepsFlags:= InitStepsFlags or cifTheme |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
403 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
404 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
405 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
406 |
procedure chSetSeed(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
407 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
408 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
409 |
begin |
102 | 410 |
SetRandomSeed(s); |
81 | 411 |
cSeed:= s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
412 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
413 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
414 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
415 |
|
161 | 416 |
procedure chAmmoMenu(var s: shortstring); |
417 |
begin |
|
418 |
if CheckNoTeamOrHH then exit; |
|
419 |
with CurrentTeam^ do |
|
420 |
with Hedgehogs[CurrHedgehog] do |
|
421 |
begin |
|
162 | 422 |
bSelected:= false; |
682 | 423 |
|
161 | 424 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
351 | 425 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
426 |
or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
|
161 | 427 |
end |
428 |
end; |
|
429 |
||
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
430 |
procedure chFullScr(var s: shortstring); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
431 |
var flags: Longword; |
192 | 432 |
{$IFDEF DEBUGFILE} |
433 |
buf: array[byte] of char; |
|
434 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
435 |
begin |
970 | 436 |
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
|
437 |
else cFullScreen:= s = '1'; |
192 | 438 |
|
905 | 439 |
{$IFDEF DEBUGFILE} |
440 |
AddFileLog('Prepare to change video parameters...'); |
|
441 |
{$ENDIF} |
|
753 | 442 |
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
443 |
||
444 |
flags:= SDL_OPENGL; |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
445 |
if cFullScreen then flags:= flags or SDL_FULLSCREEN |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
446 |
else SDL_WM_SetCaption('Hedgewars', nil); |
905 | 447 |
{$IFDEF DEBUGFILE} |
448 |
AddFileLog('Freeing old primary surface...'); |
|
449 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
450 |
SDL_FreeSurface(SDLPrimSurface); |
904 | 451 |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
452 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
904 | 453 |
SDLTry(SDLPrimSurface <> nil, true); |
192 | 454 |
|
905 | 455 |
{$IFDEF DEBUGFILE} |
456 |
AddFileLog('Setting up OpenGL...'); |
|
457 |
{$ENDIF} |
|
753 | 458 |
SetupOpenGL(); |
459 |
||
192 | 460 |
{$IFDEF DEBUGFILE} |
461 |
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); |
|
462 |
{$ENDIF} |
|
351 | 463 |
PixelFormat:= SDLPrimSurface^.format |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
464 |
end; |
161 | 465 |
|
175 | 466 |
procedure chVol_p(var s: shortstring); |
174 | 467 |
begin |
175 | 468 |
inc(cVolumeDelta, 3) |
174 | 469 |
end; |
470 |
||
175 | 471 |
procedure chVol_m(var s: shortstring); |
174 | 472 |
begin |
175 | 473 |
dec(cVolumeDelta, 3) |
174 | 474 |
end; |
475 |
||
176 | 476 |
procedure chFindhh(var s: shortstring); |
477 |
begin |
|
478 |
if CheckNoTeamOrHH then exit; |
|
479 |
bShowFinger:= true; |
|
602 | 480 |
FollowGear:= CurrentHedgehog^.Gear |
176 | 481 |
end; |
482 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
483 |
procedure chPause(var s: shortstring); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
484 |
begin |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
485 |
isPaused:= not isPaused; |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
486 |
SDL_ShowCursor(ord(isPaused)) |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
487 |
end; |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
488 |
|
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
489 |
procedure chRotateMask(var s: shortstring); |
691 | 490 |
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
|
491 |
begin |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
492 |
cTagsMask:= map[cTagsMask] |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
493 |
end; |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
494 |
|
589 | 495 |
procedure chAddTrigger(var s: shortstring); |
615 | 496 |
const MAXPARAMS = 16; |
497 |
var params: array[0..Pred(MAXPARAMS)] of Longword; |
|
498 |
i: LongInt; |
|
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
499 |
c: char; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
500 |
tmp: shortstring; |
589 | 501 |
begin |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
502 |
c:= s[1]; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
503 |
Delete(s, 1, 1); |
615 | 504 |
|
505 |
i:= 0; |
|
506 |
while (i < MAXPARAMS) and |
|
507 |
(Length(s) > 0) do |
|
508 |
begin |
|
509 |
SplitBySpace(s, tmp); |
|
510 |
val(s, params[i]); |
|
511 |
s:= tmp; |
|
512 |
inc(i) |
|
513 |
end; |
|
514 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
515 |
case c of |
613 | 516 |
's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER |
615 | 517 |
TryDo(i = 7, errmsgWrongNumber, true); |
518 |
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
|
519 |
end; |
613 | 520 |
'C': begin |
615 | 521 |
TryDo(i = 3, errmsgWrongNumber, true); |
522 |
AddTriggerSuccess(params[0], params[1], params[2]); |
|
523 |
end; |
|
524 |
'F': begin |
|
525 |
TryDo(i = 3, errmsgWrongNumber, true); |
|
526 |
AddTriggerFail(params[0], params[1], params[2]); |
|
613 | 527 |
end; |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
528 |
end |
589 | 529 |
end; |
626 | 530 |
|
531 |
procedure chSpeedup_p(var s: shortstring); |
|
532 |
begin |
|
533 |
isSpeed:= true |
|
534 |
end; |
|
535 |
||
536 |
procedure chSpeedup_m(var s: shortstring); |
|
537 |
begin |
|
538 |
isSpeed:= false |
|
539 |
end; |
|
946 | 540 |
|
541 |
procedure chChat(var s: shortstring); |
|
542 |
begin |
|
990
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
543 |
GameState:= gsChat; |
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
544 |
KeyPressChat(27) |
946 | 545 |
end; |
991 | 546 |
|
547 |
procedure chHistory(var s: shortstring); |
|
548 |
begin |
|
549 |
uChat.showAll:= not uChat.showAll |
|
550 |
end; |