author | smxx |
Wed, 10 Feb 2010 15:42:00 +0000 | |
changeset 2793 | 6bcf173ba9be |
parent 2786 | 85f6425a4d74 |
child 2800 | f286d91157b8 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1656
209cf0e2fc36
Finish voicepacks support in engine (not tested though)
unc0rr
parents:
1654
diff
changeset
|
3 |
* Copyright (c) 2004-2009 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; |
|
2695 | 20 |
var bRes: boolean; |
4 | 21 |
begin |
2695 | 22 |
bRes:= (CurrentTeam = nil) or (CurrentHedgehog^.Gear = nil); |
4 | 23 |
{$IFDEF DEBUGFILE} |
2695 | 24 |
if bRes then |
4 | 25 |
if CurrentTeam = nil then AddFileLog('CONSOLE: CurTeam = nil') |
351 | 26 |
else AddFileLog('CONSOLE: CurTeam <> nil, Gear = nil'); |
4 | 27 |
{$ENDIF} |
2695 | 28 |
CheckNoTeamOrHH:= bRes; |
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 |
|
2130
708758635955
Please don't take away my checkin privileges - Tiy asked me to keep working on this
nemo
parents:
2125
diff
changeset
|
49 |
else |
708758635955
Please don't take away my checkin privileges - Tiy asked me to keep working on this
nemo
parents:
2125
diff
changeset
|
50 |
begin |
708758635955
Please don't take away my checkin privileges - Tiy asked me to keep working on this
nemo
parents:
2125
diff
changeset
|
51 |
GameState:= gsChat; |
708758635955
Please don't take away my checkin privileges - Tiy asked me to keep working on this
nemo
parents:
2125
diff
changeset
|
52 |
KeyPressChat(27); |
708758635955
Please don't take away my checkin privileges - Tiy asked me to keep working on this
nemo
parents:
2125
diff
changeset
|
53 |
KeyPressChat(47); |
708758635955
Please don't take away my checkin privileges - Tiy asked me to keep working on this
nemo
parents:
2125
diff
changeset
|
54 |
KeyPressChat(116); |
708758635955
Please don't take away my checkin privileges - Tiy asked me to keep working on this
nemo
parents:
2125
diff
changeset
|
55 |
KeyPressChat(101); |
708758635955
Please don't take away my checkin privileges - Tiy asked me to keep working on this
nemo
parents:
2125
diff
changeset
|
56 |
KeyPressChat(97); |
708758635955
Please don't take away my checkin privileges - Tiy asked me to keep working on this
nemo
parents:
2125
diff
changeset
|
57 |
KeyPressChat(109); |
708758635955
Please don't take away my checkin privileges - Tiy asked me to keep working on this
nemo
parents:
2125
diff
changeset
|
58 |
KeyPressChat(32) |
708758635955
Please don't take away my checkin privileges - Tiy asked me to keep working on this
nemo
parents:
2125
diff
changeset
|
59 |
end |
4 | 60 |
end; |
61 |
||
205 | 62 |
procedure chCheckProto(var s: shortstring); |
371 | 63 |
var i, c: LongInt; |
205 | 64 |
begin |
65 |
if isDeveloperMode then |
|
66 |
begin |
|
67 |
val(s, i, c); |
|
68 |
if (c <> 0) or (i = 0) then exit; |
|
69 |
TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old', true); |
|
70 |
TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new', true) |
|
71 |
end |
|
72 |
end; |
|
73 |
||
4 | 74 |
procedure chAddTeam(var s: shortstring); |
549 | 75 |
var Color: Longword; |
605 | 76 |
ts: shortstring; |
4 | 77 |
begin |
145 | 78 |
if isDeveloperMode then |
79 |
begin |
|
605 | 80 |
SplitBySpace(s, ts); |
549 | 81 |
val(s, Color); |
82 |
TryDo(Color <> 0, 'Error: black team color', true); |
|
351 | 83 |
|
2671
7e0f88013fe8
smaller patches, one missing Sky-lowres, IMG_Init and Mix_Init (might require newer libraries), updates to SDL bindings, code cleanup, new compile flags
koda
parents:
2645
diff
changeset
|
84 |
// color is always little endian so the mask must be constant also in big endian archs |
2624 | 85 |
Color:= Color or $FF000000; |
86 |
||
549 | 87 |
AddTeam(Color); |
605 | 88 |
CurrentTeam^.TeamName:= ts; |
1654 | 89 |
if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true; |
90 |
||
91 |
CurrentTeam^.voicepack:= AskForVoicepack('Default') |
|
546 | 92 |
end |
4 | 93 |
end; |
94 |
||
95 |
procedure chTeamLocal(var s: shortstring); |
|
96 |
begin |
|
97 |
if not isDeveloperMode then exit; |
|
98 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
|
351 | 99 |
CurrentTeam^.ExtDriven:= true |
4 | 100 |
end; |
101 |
||
102 |
procedure chGrave(var s: shortstring); |
|
103 |
begin |
|
104 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
|
105 |
if s[1]='"' then Delete(s, 1, 1); |
|
106 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 107 |
CurrentTeam^.GraveName:= s |
4 | 108 |
end; |
109 |
||
110 |
procedure chFort(var s: shortstring); |
|
111 |
begin |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
753
diff
changeset
|
112 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/fort"', true); |
4 | 113 |
if s[1]='"' then Delete(s, 1, 1); |
114 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 115 |
CurrentTeam^.FortName:= s |
4 | 116 |
end; |
117 |
||
1654 | 118 |
procedure chVoicepack(var s: shortstring); |
119 |
begin |
|
120 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/voicepack"', true); |
|
121 |
if s[1]='"' then Delete(s, 1, 1); |
|
122 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
123 |
CurrentTeam^.voicepack:= AskForVoicepack(s) |
|
124 |
end; |
|
125 |
||
2747 | 126 |
procedure chFlag(var s: shortstring); |
127 |
begin |
|
128 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/flag"', true); |
|
129 |
if s[1]='"' then Delete(s, 1, 1); |
|
130 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
131 |
CurrentTeam^.flag:= s |
|
132 |
end; |
|
133 |
||
2786 | 134 |
procedure chScript(var s: shortstring); |
135 |
begin |
|
136 |
if s[1]='"' then Delete(s, 1, 1); |
|
137 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
138 |
ScriptLoad(s) |
|
139 |
end; |
|
140 |
||
312 | 141 |
procedure chAddHH(var id: shortstring); |
4 | 142 |
var s: shortstring; |
143 |
Gear: PGear; |
|
144 |
begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
145 |
if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
312 | 146 |
with CurrentTeam^ do |
1242 | 147 |
begin |
148 |
SplitBySpace(id, s); |
|
149 |
CurrentHedgehog:= @Hedgehogs[HedgehogsNumber]; |
|
150 |
val(id, CurrentHedgehog^.BotLevel); |
|
151 |
Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0); |
|
152 |
SplitBySpace(s, id); |
|
153 |
val(s, Gear^.Health); |
|
154 |
TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true); |
|
155 |
PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam; |
|
2635 | 156 |
CurrentHedgehog^.AmmoStore:= ClansCount - 1; // FIXME HACK to get ammostores work |
1242 | 157 |
CurrentHedgehog^.Gear:= Gear; |
158 |
CurrentHedgehog^.Name:= id; |
|
159 |
inc(HedgehogsNumber) |
|
160 |
end |
|
161 |
end; |
|
162 |
||
163 |
procedure chSetHat(var s: shortstring); |
|
164 |
begin |
|
165 |
if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
|
166 |
with CurrentTeam^ do |
|
2726 | 167 |
begin |
168 |
if not CurrentHedgehog^.King then |
|
169 |
if (s = '') or (((GameFlags and gfKing) <> 0) and (s = 'crown')) then |
|
170 |
CurrentHedgehog^.Hat:= 'NoHat' |
|
171 |
else |
|
172 |
CurrentHedgehog^.Hat:= s |
|
173 |
end; |
|
4 | 174 |
end; |
175 |
||
604
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
176 |
procedure chSetHHCoords(var x: shortstring); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
177 |
var y: shortstring; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
178 |
t: Longint; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
179 |
begin |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
180 |
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
|
181 |
SplitBySpace(x, y); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
182 |
val(x, t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
183 |
CurrentHedgehog^.Gear^.X:= int2hwFloat(t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
184 |
val(y, t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
185 |
CurrentHedgehog^.Gear^.Y:= int2hwFloat(t) |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
186 |
end; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
187 |
|
288 | 188 |
procedure chAddAmmoStore(var descr: shortstring); |
189 |
begin |
|
190 |
AddAmmoStore(descr) |
|
191 |
end; |
|
192 |
||
4 | 193 |
procedure chBind(var id: shortstring); |
194 |
var s: shortstring; |
|
371 | 195 |
b: LongInt; |
4 | 196 |
begin |
197 |
if CurrentTeam = nil then exit; |
|
198 |
SplitBySpace(id, s); |
|
199 |
if s[1]='"' then Delete(s, 1, 1); |
|
200 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
201 |
b:= KeyNameToCode(id); |
|
351 | 202 |
if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
203 |
else CurrentTeam^.Binds[b]:= s |
|
4 | 204 |
end; |
205 |
||
2428 | 206 |
procedure chCurU_p(var s: shortstring); |
207 |
begin |
|
208 |
CursorMovementY:= -1; |
|
209 |
end; |
|
210 |
||
211 |
procedure chCurU_m(var s: shortstring); |
|
212 |
begin |
|
213 |
CursorMovementY:= 0; |
|
214 |
end; |
|
215 |
||
216 |
procedure chCurD_p(var s: shortstring); |
|
217 |
begin |
|
218 |
CursorMovementY:= 1; |
|
219 |
end; |
|
220 |
||
221 |
procedure chCurD_m(var s: shortstring); |
|
222 |
begin |
|
223 |
CursorMovementY:= 0; |
|
224 |
end; |
|
225 |
||
226 |
procedure chCurL_p(var s: shortstring); |
|
227 |
begin |
|
228 |
CursorMovementX:= -1; |
|
229 |
end; |
|
230 |
||
231 |
procedure chCurL_m(var s: shortstring); |
|
232 |
begin |
|
233 |
CursorMovementX:= 0; |
|
234 |
end; |
|
235 |
||
236 |
procedure chCurR_p(var s: shortstring); |
|
237 |
begin |
|
238 |
CursorMovementX:= 1; |
|
239 |
end; |
|
240 |
||
241 |
procedure chCurR_m(var s: shortstring); |
|
242 |
begin |
|
243 |
CursorMovementX:= 0; |
|
244 |
end; |
|
245 |
||
4 | 246 |
procedure chLeft_p(var s: shortstring); |
247 |
begin |
|
248 |
if CheckNoTeamOrHH then exit; |
|
176 | 249 |
bShowFinger:= false; |
351 | 250 |
if not CurrentTeam^.ExtDriven then SendIPC('L'); |
602 | 251 |
with CurrentHedgehog^.Gear^ do |
4 | 252 |
Message:= Message or gm_Left |
253 |
end; |
|
254 |
||
255 |
procedure chLeft_m(var s: shortstring); |
|
256 |
begin |
|
257 |
if CheckNoTeamOrHH then exit; |
|
351 | 258 |
if not CurrentTeam^.ExtDriven then SendIPC('l'); |
602 | 259 |
with CurrentHedgehog^.Gear^ do |
4 | 260 |
Message:= Message and not gm_Left |
261 |
end; |
|
262 |
||
263 |
procedure chRight_p(var s: shortstring); |
|
264 |
begin |
|
265 |
if CheckNoTeamOrHH then exit; |
|
176 | 266 |
bShowFinger:= false; |
351 | 267 |
if not CurrentTeam^.ExtDriven then SendIPC('R'); |
602 | 268 |
with CurrentHedgehog^.Gear^ do |
4 | 269 |
Message:= Message or gm_Right |
270 |
end; |
|
271 |
||
272 |
procedure chRight_m(var s: shortstring); |
|
273 |
begin |
|
274 |
if CheckNoTeamOrHH then exit; |
|
351 | 275 |
if not CurrentTeam^.ExtDriven then SendIPC('r'); |
602 | 276 |
with CurrentHedgehog^.Gear^ do |
4 | 277 |
Message:= Message and not gm_Right |
278 |
end; |
|
279 |
||
280 |
procedure chUp_p(var s: shortstring); |
|
281 |
begin |
|
282 |
if CheckNoTeamOrHH then exit; |
|
176 | 283 |
bShowFinger:= false; |
351 | 284 |
if not CurrentTeam^.ExtDriven then SendIPC('U'); |
602 | 285 |
with CurrentHedgehog^.Gear^ do |
4 | 286 |
Message:= Message or gm_Up |
287 |
end; |
|
288 |
||
289 |
procedure chUp_m(var s: shortstring); |
|
290 |
begin |
|
291 |
if CheckNoTeamOrHH then exit; |
|
351 | 292 |
if not CurrentTeam^.ExtDriven then SendIPC('u'); |
602 | 293 |
with CurrentHedgehog^.Gear^ do |
4 | 294 |
Message:= Message and not gm_Up |
295 |
end; |
|
296 |
||
297 |
procedure chDown_p(var s: shortstring); |
|
298 |
begin |
|
299 |
if CheckNoTeamOrHH then exit; |
|
176 | 300 |
bShowFinger:= false; |
351 | 301 |
if not CurrentTeam^.ExtDriven then SendIPC('D'); |
602 | 302 |
with CurrentHedgehog^.Gear^ do |
4 | 303 |
Message:= Message or gm_Down |
304 |
end; |
|
305 |
||
306 |
procedure chDown_m(var s: shortstring); |
|
307 |
begin |
|
308 |
if CheckNoTeamOrHH then exit; |
|
351 | 309 |
if not CurrentTeam^.ExtDriven then SendIPC('d'); |
602 | 310 |
with CurrentHedgehog^.Gear^ do |
4 | 311 |
Message:= Message and not gm_Down |
312 |
end; |
|
313 |
||
1639 | 314 |
procedure chPrecise_p(var s: shortstring); |
315 |
begin |
|
316 |
if CheckNoTeamOrHH then exit; |
|
317 |
bShowFinger:= false; |
|
318 |
if not CurrentTeam^.ExtDriven then SendIPC('Z'); |
|
319 |
with CurrentHedgehog^.Gear^ do |
|
320 |
Message:= Message or gm_Precise |
|
321 |
end; |
|
322 |
||
323 |
procedure chPrecise_m(var s: shortstring); |
|
324 |
begin |
|
325 |
if CheckNoTeamOrHH then exit; |
|
326 |
if not CurrentTeam^.ExtDriven then SendIPC('z'); |
|
327 |
with CurrentHedgehog^.Gear^ do |
|
328 |
Message:= Message and not gm_Precise |
|
329 |
end; |
|
330 |
||
4 | 331 |
procedure chLJump(var s: shortstring); |
332 |
begin |
|
333 |
if CheckNoTeamOrHH then exit; |
|
176 | 334 |
bShowFinger:= false; |
351 | 335 |
if not CurrentTeam^.ExtDriven then SendIPC('j'); |
602 | 336 |
with CurrentHedgehog^.Gear^ do |
4 | 337 |
Message:= Message or gm_LJump |
338 |
end; |
|
339 |
||
340 |
procedure chHJump(var s: shortstring); |
|
341 |
begin |
|
342 |
if CheckNoTeamOrHH then exit; |
|
176 | 343 |
bShowFinger:= false; |
351 | 344 |
if not CurrentTeam^.ExtDriven then SendIPC('J'); |
602 | 345 |
with CurrentHedgehog^.Gear^ do |
4 | 346 |
Message:= Message or gm_HJump |
347 |
end; |
|
348 |
||
349 |
procedure chAttack_p(var s: shortstring); |
|
350 |
begin |
|
351 |
if CheckNoTeamOrHH then exit; |
|
176 | 352 |
bShowFinger:= false; |
602 | 353 |
with CurrentHedgehog^.Gear^ do |
4 | 354 |
begin |
2079 | 355 |
{$IFDEF DEBUGFILE}AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));{$ENDIF} |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
927
diff
changeset
|
356 |
if ((State and gstHHDriven) <> 0) then |
4 | 357 |
begin |
602 | 358 |
FollowGear:= CurrentHedgehog^.Gear; |
351 | 359 |
if not CurrentTeam^.ExtDriven then SendIPC('A'); |
4 | 360 |
Message:= Message or gm_Attack |
361 |
end |
|
362 |
end |
|
363 |
end; |
|
364 |
||
365 |
procedure chAttack_m(var s: shortstring); |
|
366 |
begin |
|
367 |
if CheckNoTeamOrHH then exit; |
|
602 | 368 |
with CurrentHedgehog^.Gear^ do |
4 | 369 |
begin |
351 | 370 |
if not CurrentTeam^.ExtDriven and |
95 | 371 |
((Message and gm_Attack) <> 0) then SendIPC('a'); |
372 |
Message:= Message and not gm_Attack |
|
4 | 373 |
end |
374 |
end; |
|
375 |
||
376 |
procedure chSwitch(var s: shortstring); |
|
377 |
begin |
|
378 |
if CheckNoTeamOrHH then exit; |
|
351 | 379 |
if not CurrentTeam^.ExtDriven then SendIPC('S'); |
602 | 380 |
with CurrentHedgehog^.Gear^ do |
4 | 381 |
Message:= Message or gm_Switch |
382 |
end; |
|
383 |
||
384 |
procedure chNextTurn(var s: shortstring); |
|
385 |
begin |
|
2045
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
386 |
TryDo(AllInactive, '/nextturn called when not all gears are inactive', true); |
2046 | 387 |
|
2045
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
388 |
if not CurrentTeam^.ExtDriven then SendIPC('N'); |
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
389 |
TickTrigger(trigTurns); |
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
390 |
{$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF} |
4 | 391 |
end; |
392 |
||
393 |
procedure chSay(var s: shortstring); |
|
394 |
begin |
|
1356 | 395 |
SendIPC('s' + s); |
1378 | 396 |
|
397 |
if copy(s, 1, 4) = '/me ' then |
|
2396 | 398 |
s:= #2'* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4) |
1378 | 399 |
else |
2396 | 400 |
s:= #1 + UserNick + ': ' + s; |
1378 | 401 |
|
1356 | 402 |
AddChatString(s) |
4 | 403 |
end; |
404 |
||
2124 | 405 |
procedure chTeamSay(var s: shortstring); |
406 |
begin |
|
407 |
SendIPC('b' + s); |
|
408 |
||
2403 | 409 |
s:= #4 + UserNick + '(team): ' + s; |
2124 | 410 |
|
2396 | 411 |
AddChatString(s) |
2124 | 412 |
end; |
413 |
||
4 | 414 |
procedure chTimer(var s: shortstring); |
415 |
begin |
|
2314 | 416 |
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or CheckNoTeamOrHH then exit; |
176 | 417 |
bShowFinger:= false; |
2314 | 418 |
|
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
419 |
if not CurrentTeam^.ExtDriven then SendIPC(s); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
420 |
with CurrentHedgehog^.Gear^ do |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
421 |
begin |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
422 |
Message:= Message or gm_Timer; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
423 |
MsgParam:= byte(s[1]) - ord('0') |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
424 |
end |
4 | 425 |
end; |
426 |
||
427 |
procedure chSlot(var s: shortstring); |
|
428 |
var slot: LongWord; |
|
429 |
begin |
|
95 | 430 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
176 | 431 |
bShowFinger:= false; |
4 | 432 |
slot:= byte(s[1]) - 49; |
10 | 433 |
if slot > cMaxSlotIndex then exit; |
351 | 434 |
if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); |
783 | 435 |
with CurrentHedgehog^.Gear^ do |
4 | 436 |
begin |
783 | 437 |
Message:= Message or gm_Slot; |
438 |
MsgParam:= slot |
|
439 |
end |
|
440 |
end; |
|
441 |
||
442 |
procedure chSetWeapon(var s: shortstring); |
|
443 |
begin |
|
444 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
784 | 445 |
|
1850 | 446 |
if TAmmoType(s[1]) > High(TAmmoType) then exit; |
784 | 447 |
|
448 |
if not CurrentTeam^.ExtDriven then SendIPC('w' + s); |
|
449 |
||
783 | 450 |
with CurrentHedgehog^.Gear^ do |
451 |
begin |
|
452 |
Message:= Message or gm_Weapon; |
|
1850 | 453 |
MsgParam:= byte(s[1]) |
4 | 454 |
end |
455 |
end; |
|
456 |
||
1035 | 457 |
procedure chTaunt(var s: shortstring); |
458 |
begin |
|
459 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
460 |
||
461 |
if TWave(s[1]) > High(TWave) then exit; |
|
462 |
||
463 |
if not CurrentTeam^.ExtDriven then SendIPC('t' + s); |
|
464 |
||
465 |
with CurrentHedgehog^.Gear^ do |
|
466 |
begin |
|
467 |
Message:= Message or gm_Animate; |
|
468 |
MsgParam:= byte(s[1]) |
|
469 |
end |
|
470 |
end; |
|
471 |
||
2017 | 472 |
procedure chHogSay(var s: shortstring); |
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2022
diff
changeset
|
473 |
var Gear: PVisualGear; |
2017 | 474 |
text: shortstring; |
475 |
begin |
|
476 |
text:= copy(s, 2, Length(s)-1); |
|
2110 | 477 |
if CheckNoTeamOrHH |
2111 | 478 |
or ((CurrentHedgehog^.Gear^.State and gstHHDriven) = 0) then |
2017 | 479 |
begin |
480 |
chSay(text); |
|
481 |
exit |
|
482 |
end; |
|
483 |
||
484 |
if not CurrentTeam^.ExtDriven then SendIPC('h' + s); |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2022
diff
changeset
|
485 |
|
2017 | 486 |
if byte(s[1]) < 4 then |
487 |
begin |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2022
diff
changeset
|
488 |
Gear:= AddVisualGear(0, 0, vgtSpeechBubble); |
2114
9a8ccc7bc3d8
Fix crash caused by speechbubbles when restoring from save or joining already started net game
unc0rr
parents:
2111
diff
changeset
|
489 |
if Gear <> nil then |
9a8ccc7bc3d8
Fix crash caused by speechbubbles when restoring from save or joining already started net game
unc0rr
parents:
2111
diff
changeset
|
490 |
begin |
9a8ccc7bc3d8
Fix crash caused by speechbubbles when restoring from save or joining already started net game
unc0rr
parents:
2111
diff
changeset
|
491 |
Gear^.Hedgehog:= CurrentHedgehog; |
9a8ccc7bc3d8
Fix crash caused by speechbubbles when restoring from save or joining already started net game
unc0rr
parents:
2111
diff
changeset
|
492 |
Gear^.Text:= text; |
9a8ccc7bc3d8
Fix crash caused by speechbubbles when restoring from save or joining already started net game
unc0rr
parents:
2111
diff
changeset
|
493 |
Gear^.FrameTicks:= byte(s[1]) |
9a8ccc7bc3d8
Fix crash caused by speechbubbles when restoring from save or joining already started net game
unc0rr
parents:
2111
diff
changeset
|
494 |
end |
2017 | 495 |
end |
496 |
else |
|
497 |
begin |
|
2022 | 498 |
SpeechType:= byte(s[1])-3; |
2017 | 499 |
SpeechText:= text |
500 |
end; |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2022
diff
changeset
|
501 |
|
2017 | 502 |
end; |
503 |
||
1821
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
504 |
procedure chNewGrave; |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
505 |
begin |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
506 |
if CheckNoTeamOrHH then exit; |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
507 |
|
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
508 |
if not CurrentTeam^.ExtDriven then SendIPC('g'); |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
509 |
|
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
510 |
AddGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), gtGrave, 0, _0, _0, 0) |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
511 |
end; |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
512 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
513 |
procedure doPut(putX, putY: LongInt; fromAI: boolean); |
4 | 514 |
begin |
515 |
if CheckNoTeamOrHH then exit; |
|
162 | 516 |
if bShowAmmoMenu then |
2407
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
517 |
begin |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
518 |
bSelected:= true; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
519 |
exit |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
520 |
end; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
521 |
|
602 | 522 |
with CurrentHedgehog^.Gear^, |
2407
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
523 |
CurrentHedgehog^ do |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
524 |
if (State and gstHHChooseTarget) <> 0 then |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
525 |
begin |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
526 |
isCursorVisible:= false; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
527 |
if not CurrentTeam^.ExtDriven then |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
528 |
begin |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
529 |
if fromAI then |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
530 |
begin |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
531 |
TargetPoint.X:= putX; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
532 |
TargetPoint.Y:= putY |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
533 |
end else |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
534 |
begin |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
535 |
TargetPoint.X:= CursorPoint.X - WorldDx; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
536 |
TargetPoint.Y:= cScreenHeight - CursorPoint.Y - WorldDy; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
537 |
end; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
538 |
SendIPCXY('p', TargetPoint.X, TargetPoint.Y); |
2645
89aa2aa89066
Fix bug with cursor coordinates sent via net (or demo/save file)
unc0rr
parents:
2642
diff
changeset
|
539 |
end |
89aa2aa89066
Fix bug with cursor coordinates sent via net (or demo/save file)
unc0rr
parents:
2642
diff
changeset
|
540 |
else |
89aa2aa89066
Fix bug with cursor coordinates sent via net (or demo/save file)
unc0rr
parents:
2642
diff
changeset
|
541 |
begin |
89aa2aa89066
Fix bug with cursor coordinates sent via net (or demo/save file)
unc0rr
parents:
2642
diff
changeset
|
542 |
TargetPoint.X:= putX; |
89aa2aa89066
Fix bug with cursor coordinates sent via net (or demo/save file)
unc0rr
parents:
2642
diff
changeset
|
543 |
TargetPoint.Y:= putY |
2407
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
544 |
end; |
2642 | 545 |
{$IFDEF DEBUGFILE}AddFilelog('put: ' + inttostr(TargetPoint.X) + ', ' + inttostr(TargetPoint.Y));{$ENDIF} |
2407
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
546 |
State:= State and not gstHHChooseTarget; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
547 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
548 |
Message:= Message or gm_Attack; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
549 |
end |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
550 |
else |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
551 |
if CurrentTeam^.ExtDriven then |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
552 |
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
|
553 |
end; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
554 |
|
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
555 |
procedure chPut(var s: shortstring); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
556 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
557 |
doPut(0, 0, false) |
4 | 558 |
end; |
559 |
||
560 |
procedure chCapture(var s: shortstring); |
|
561 |
begin |
|
562 |
flagMakeCapture:= true |
|
563 |
end; |
|
564 |
||
48 | 565 |
procedure chSkip(var s: shortstring); |
566 |
begin |
|
351 | 567 |
if not CurrentTeam^.ExtDriven then SendIPC(','); |
871 | 568 |
uStats.Skipped; |
917 | 569 |
skipFlag:= true |
48 | 570 |
end; |
571 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
572 |
procedure chSetMap(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
573 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
574 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
575 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
576 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
577 |
InitStepsFlags:= InitStepsFlags or cifMap |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
578 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
579 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
580 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
581 |
procedure chSetTheme(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
582 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
583 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
584 |
begin |
80 | 585 |
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
|
586 |
InitStepsFlags:= InitStepsFlags or cifTheme |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
587 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
588 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
589 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
590 |
procedure chSetSeed(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
591 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
592 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
593 |
begin |
102 | 594 |
SetRandomSeed(s); |
81 | 595 |
cSeed:= s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
596 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
597 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
598 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
599 |
|
161 | 600 |
procedure chAmmoMenu(var s: shortstring); |
601 |
begin |
|
602 |
if CheckNoTeamOrHH then exit; |
|
603 |
with CurrentTeam^ do |
|
604 |
with Hedgehogs[CurrHedgehog] do |
|
605 |
begin |
|
162 | 606 |
bSelected:= false; |
682 | 607 |
|
161 | 608 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
2608 | 609 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (MultiShootAttacks > 0) |
351 | 610 |
or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
161 | 611 |
end |
612 |
end; |
|
613 |
||
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
614 |
procedure chFullScr(var s: shortstring); |
2671
7e0f88013fe8
smaller patches, one missing Sky-lowres, IMG_Init and Mix_Init (might require newer libraries), updates to SDL bindings, code cleanup, new compile flags
koda
parents:
2645
diff
changeset
|
615 |
var flags: Longword = 0; |
192 | 616 |
{$IFDEF DEBUGFILE} |
617 |
buf: array[byte] of char; |
|
618 |
{$ENDIF} |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
619 |
{$IFDEF SDL13} |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
620 |
window: PSDL_Window; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
621 |
{$ENDIF} |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
622 |
begin |
2697 | 623 |
if Length(s) = 0 then cFullScreen:= not cFullScreen |
2671
7e0f88013fe8
smaller patches, one missing Sky-lowres, IMG_Init and Mix_Init (might require newer libraries), updates to SDL bindings, code cleanup, new compile flags
koda
parents:
2645
diff
changeset
|
624 |
else cFullScreen:= s = '1'; |
192 | 625 |
|
905 | 626 |
{$IFDEF DEBUGFILE} |
2697 | 627 |
AddFileLog('Prepare to change video parameters...'); |
905 | 628 |
{$ENDIF} |
2253 | 629 |
|
2697 | 630 |
flags:= SDL_OPENGL;// or SDL_RESIZABLE; |
753 | 631 |
|
2697 | 632 |
if cFullScreen then |
1121
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
633 |
begin |
2697 | 634 |
flags:= flags or SDL_FULLSCREEN; |
635 |
cScreenWidth:= cInitWidth; |
|
636 |
cScreenHeight:= cInitHeight |
|
2351
a4a17b8df591
Set window caption even in fullscreen mode (suggested by Smaxx)
unc0rr
parents:
2314
diff
changeset
|
637 |
end; |
a4a17b8df591
Set window caption even in fullscreen mode (suggested by Smaxx)
unc0rr
parents:
2314
diff
changeset
|
638 |
|
2697 | 639 |
SDL_WM_SetCaption('Hedgewars', nil); |
640 |
if SDLPrimSurface <> nil then |
|
2428 | 641 |
begin |
2697 | 642 |
{$IFDEF DEBUGFILE} |
643 |
AddFileLog('Freeing old primary surface...'); |
|
644 |
{$ENDIF} |
|
645 |
SDL_FreeSurface(SDLPrimSurface); |
|
2428 | 646 |
end; |
2697 | 647 |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
648 |
{$IFDEF SDL13} |
2738
bfccb2ec4334
new graphics from Tiy and frontend is loaded in landscape mode
koda
parents:
2726
diff
changeset
|
649 |
window:= SDL_CreateWindow('Hedgewars', 0, 0, cScreenWidth, cScreenHeight, |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
650 |
SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
651 |
{$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS{$ENDIF}); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
652 |
SDL_CreateRenderer(window, -1, 0); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
653 |
PixelFormat:= nil; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
654 |
|
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
655 |
SDL_SetRenderDrawColor(0, 0, 0, 255); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
656 |
SDL_RenderFill(nil); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
657 |
SDL_RenderPresent(); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
658 |
{$ELSE} |
2697 | 659 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
660 |
SDLTry(SDLPrimSurface <> nil, true); |
|
661 |
PixelFormat:= SDLPrimSurface^.format; |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
662 |
{$ENDIF} |
192 | 663 |
|
905 | 664 |
{$IFDEF DEBUGFILE} |
2697 | 665 |
AddFileLog('Setting up OpenGL...'); |
666 |
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); |
|
905 | 667 |
{$ENDIF} |
2697 | 668 |
SetupOpenGL(); |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
669 |
end; |
161 | 670 |
|
175 | 671 |
procedure chVol_p(var s: shortstring); |
174 | 672 |
begin |
175 | 673 |
inc(cVolumeDelta, 3) |
174 | 674 |
end; |
675 |
||
175 | 676 |
procedure chVol_m(var s: shortstring); |
174 | 677 |
begin |
175 | 678 |
dec(cVolumeDelta, 3) |
174 | 679 |
end; |
680 |
||
176 | 681 |
procedure chFindhh(var s: shortstring); |
682 |
begin |
|
683 |
if CheckNoTeamOrHH then exit; |
|
684 |
bShowFinger:= true; |
|
602 | 685 |
FollowGear:= CurrentHedgehog^.Gear |
176 | 686 |
end; |
687 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
688 |
procedure chPause(var s: shortstring); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
689 |
begin |
1743 | 690 |
if gameType <> gmtNet then |
691 |
isPaused:= not isPaused; |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
692 |
SDL_ShowCursor(ord(isPaused)) |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
693 |
end; |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
694 |
|
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
695 |
procedure chRotateMask(var s: shortstring); |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
696 |
begin |
2568
e654cbfb23ba
Bunch of neat stuff by Smaxx. ATI check, translucent name tags to reduce terrain fail, disabling health crates on invulnerable hogs. Also tweaks to prior stuff.
nemo
parents:
2428
diff
changeset
|
697 |
inc(cTagsMaskIndex); |
e654cbfb23ba
Bunch of neat stuff by Smaxx. ATI check, translucent name tags to reduce terrain fail, disabling health crates on invulnerable hogs. Also tweaks to prior stuff.
nemo
parents:
2428
diff
changeset
|
698 |
if cTagsMaskIndex > High(cTagsMasks) then cTagsMaskIndex:= Low(cTagsMasks); |
e654cbfb23ba
Bunch of neat stuff by Smaxx. ATI check, translucent name tags to reduce terrain fail, disabling health crates on invulnerable hogs. Also tweaks to prior stuff.
nemo
parents:
2428
diff
changeset
|
699 |
|
e654cbfb23ba
Bunch of neat stuff by Smaxx. ATI check, translucent name tags to reduce terrain fail, disabling health crates on invulnerable hogs. Also tweaks to prior stuff.
nemo
parents:
2428
diff
changeset
|
700 |
// HACK: skip "health only" if all hogs are invulnerable |
e654cbfb23ba
Bunch of neat stuff by Smaxx. ATI check, translucent name tags to reduce terrain fail, disabling health crates on invulnerable hogs. Also tweaks to prior stuff.
nemo
parents:
2428
diff
changeset
|
701 |
if ((GameFlags and gfInvulnerable) <> 0) and ((cTagsMasks[cTagsMaskIndex] and not htTransparent) = htHealth) then chRotateMask(s); |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
702 |
end; |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
703 |
|
589 | 704 |
procedure chAddTrigger(var s: shortstring); |
615 | 705 |
const MAXPARAMS = 16; |
706 |
var params: array[0..Pred(MAXPARAMS)] of Longword; |
|
707 |
i: LongInt; |
|
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
708 |
c: char; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
709 |
tmp: shortstring; |
589 | 710 |
begin |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
711 |
c:= s[1]; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
712 |
Delete(s, 1, 1); |
615 | 713 |
|
714 |
i:= 0; |
|
715 |
while (i < MAXPARAMS) and |
|
716 |
(Length(s) > 0) do |
|
717 |
begin |
|
718 |
SplitBySpace(s, tmp); |
|
719 |
val(s, params[i]); |
|
720 |
s:= tmp; |
|
721 |
inc(i) |
|
722 |
end; |
|
723 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
724 |
case c of |
613 | 725 |
's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER |
615 | 726 |
TryDo(i = 7, errmsgWrongNumber, true); |
727 |
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
|
728 |
end; |
613 | 729 |
'C': begin |
615 | 730 |
TryDo(i = 3, errmsgWrongNumber, true); |
731 |
AddTriggerSuccess(params[0], params[1], params[2]); |
|
732 |
end; |
|
733 |
'F': begin |
|
734 |
TryDo(i = 3, errmsgWrongNumber, true); |
|
735 |
AddTriggerFail(params[0], params[1], params[2]); |
|
613 | 736 |
end; |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
737 |
end |
589 | 738 |
end; |
626 | 739 |
|
740 |
procedure chSpeedup_p(var s: shortstring); |
|
741 |
begin |
|
742 |
isSpeed:= true |
|
743 |
end; |
|
744 |
||
745 |
procedure chSpeedup_m(var s: shortstring); |
|
746 |
begin |
|
747 |
isSpeed:= false |
|
748 |
end; |
|
946 | 749 |
|
2162 | 750 |
procedure chZoomIn(var s: shortstring); |
751 |
begin |
|
2579 | 752 |
{$IFDEF IPHONEOS} |
753 |
if ZoomValue < 3.5 then |
|
754 |
{$ELSE} |
|
755 |
if ZoomValue < 3.0 then |
|
756 |
{$ENDIF} |
|
757 |
ZoomValue:= ZoomValue + 0.25; |
|
2162 | 758 |
end; |
759 |
||
760 |
procedure chZoomOut(var s: shortstring); |
|
761 |
begin |
|
2579 | 762 |
{$IFDEF IPHONEOS} |
763 |
if ZoomValue > 0.5 then |
|
764 |
{$ELSE} |
|
765 |
if ZoomValue > 1.0 then |
|
766 |
{$ENDIF} |
|
767 |
ZoomValue:= ZoomValue - 0.25; |
|
2162 | 768 |
end; |
769 |
||
2379 | 770 |
procedure chZoomReset(var s: shortstring); |
771 |
begin |
|
772 |
ZoomValue:= 2.0 |
|
773 |
end; |
|
774 |
||
946 | 775 |
procedure chChat(var s: shortstring); |
776 |
begin |
|
990
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
777 |
GameState:= gsChat; |
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
778 |
KeyPressChat(27) |
946 | 779 |
end; |
991 | 780 |
|
781 |
procedure chHistory(var s: shortstring); |
|
782 |
begin |
|
783 |
uChat.showAll:= not uChat.showAll |
|
784 |
end; |