author | smxx |
Mon, 15 Feb 2010 21:54:26 +0000 | |
changeset 2814 | 71e80c6e74bb |
parent 2812 | 0a24853de796 |
child 2817 | 4494dab9ef6a |
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; |
|
2808
8f48b538d591
Need this too to set it to last hog for current switch alg
nemo
parents:
2800
diff
changeset
|
159 |
CurrHedgehog:= HedgehogsNumber; |
1242 | 160 |
inc(HedgehogsNumber) |
161 |
end |
|
162 |
end; |
|
163 |
||
164 |
procedure chSetHat(var s: shortstring); |
|
165 |
begin |
|
166 |
if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
|
167 |
with CurrentTeam^ do |
|
2726 | 168 |
begin |
169 |
if not CurrentHedgehog^.King then |
|
170 |
if (s = '') or (((GameFlags and gfKing) <> 0) and (s = 'crown')) then |
|
171 |
CurrentHedgehog^.Hat:= 'NoHat' |
|
172 |
else |
|
173 |
CurrentHedgehog^.Hat:= s |
|
174 |
end; |
|
4 | 175 |
end; |
176 |
||
604
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
177 |
procedure chSetHHCoords(var x: shortstring); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
178 |
var y: shortstring; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
179 |
t: Longint; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
180 |
begin |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
181 |
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
|
182 |
SplitBySpace(x, y); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
183 |
val(x, t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
184 |
CurrentHedgehog^.Gear^.X:= int2hwFloat(t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
185 |
val(y, t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
186 |
CurrentHedgehog^.Gear^.Y:= int2hwFloat(t) |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
187 |
end; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
188 |
|
288 | 189 |
procedure chAddAmmoStore(var descr: shortstring); |
190 |
begin |
|
191 |
AddAmmoStore(descr) |
|
192 |
end; |
|
193 |
||
4 | 194 |
procedure chBind(var id: shortstring); |
195 |
var s: shortstring; |
|
371 | 196 |
b: LongInt; |
4 | 197 |
begin |
198 |
if CurrentTeam = nil then exit; |
|
199 |
SplitBySpace(id, s); |
|
200 |
if s[1]='"' then Delete(s, 1, 1); |
|
201 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
202 |
b:= KeyNameToCode(id); |
|
351 | 203 |
if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
204 |
else CurrentTeam^.Binds[b]:= s |
|
4 | 205 |
end; |
206 |
||
2428 | 207 |
procedure chCurU_p(var s: shortstring); |
208 |
begin |
|
209 |
CursorMovementY:= -1; |
|
210 |
end; |
|
211 |
||
212 |
procedure chCurU_m(var s: shortstring); |
|
213 |
begin |
|
214 |
CursorMovementY:= 0; |
|
215 |
end; |
|
216 |
||
217 |
procedure chCurD_p(var s: shortstring); |
|
218 |
begin |
|
219 |
CursorMovementY:= 1; |
|
220 |
end; |
|
221 |
||
222 |
procedure chCurD_m(var s: shortstring); |
|
223 |
begin |
|
224 |
CursorMovementY:= 0; |
|
225 |
end; |
|
226 |
||
227 |
procedure chCurL_p(var s: shortstring); |
|
228 |
begin |
|
229 |
CursorMovementX:= -1; |
|
230 |
end; |
|
231 |
||
232 |
procedure chCurL_m(var s: shortstring); |
|
233 |
begin |
|
234 |
CursorMovementX:= 0; |
|
235 |
end; |
|
236 |
||
237 |
procedure chCurR_p(var s: shortstring); |
|
238 |
begin |
|
239 |
CursorMovementX:= 1; |
|
240 |
end; |
|
241 |
||
242 |
procedure chCurR_m(var s: shortstring); |
|
243 |
begin |
|
244 |
CursorMovementX:= 0; |
|
245 |
end; |
|
246 |
||
4 | 247 |
procedure chLeft_p(var s: shortstring); |
248 |
begin |
|
249 |
if CheckNoTeamOrHH then exit; |
|
176 | 250 |
bShowFinger:= false; |
351 | 251 |
if not CurrentTeam^.ExtDriven then SendIPC('L'); |
602 | 252 |
with CurrentHedgehog^.Gear^ do |
4 | 253 |
Message:= Message or gm_Left |
254 |
end; |
|
255 |
||
256 |
procedure chLeft_m(var s: shortstring); |
|
257 |
begin |
|
258 |
if CheckNoTeamOrHH then exit; |
|
351 | 259 |
if not CurrentTeam^.ExtDriven then SendIPC('l'); |
602 | 260 |
with CurrentHedgehog^.Gear^ do |
4 | 261 |
Message:= Message and not gm_Left |
262 |
end; |
|
263 |
||
264 |
procedure chRight_p(var s: shortstring); |
|
265 |
begin |
|
266 |
if CheckNoTeamOrHH then exit; |
|
176 | 267 |
bShowFinger:= false; |
351 | 268 |
if not CurrentTeam^.ExtDriven then SendIPC('R'); |
602 | 269 |
with CurrentHedgehog^.Gear^ do |
4 | 270 |
Message:= Message or gm_Right |
271 |
end; |
|
272 |
||
273 |
procedure chRight_m(var s: shortstring); |
|
274 |
begin |
|
275 |
if CheckNoTeamOrHH then exit; |
|
351 | 276 |
if not CurrentTeam^.ExtDriven then SendIPC('r'); |
602 | 277 |
with CurrentHedgehog^.Gear^ do |
4 | 278 |
Message:= Message and not gm_Right |
279 |
end; |
|
280 |
||
281 |
procedure chUp_p(var s: shortstring); |
|
282 |
begin |
|
283 |
if CheckNoTeamOrHH then exit; |
|
176 | 284 |
bShowFinger:= false; |
351 | 285 |
if not CurrentTeam^.ExtDriven then SendIPC('U'); |
602 | 286 |
with CurrentHedgehog^.Gear^ do |
4 | 287 |
Message:= Message or gm_Up |
288 |
end; |
|
289 |
||
290 |
procedure chUp_m(var s: shortstring); |
|
291 |
begin |
|
292 |
if CheckNoTeamOrHH then exit; |
|
351 | 293 |
if not CurrentTeam^.ExtDriven then SendIPC('u'); |
602 | 294 |
with CurrentHedgehog^.Gear^ do |
4 | 295 |
Message:= Message and not gm_Up |
296 |
end; |
|
297 |
||
298 |
procedure chDown_p(var s: shortstring); |
|
299 |
begin |
|
300 |
if CheckNoTeamOrHH then exit; |
|
176 | 301 |
bShowFinger:= false; |
351 | 302 |
if not CurrentTeam^.ExtDriven then SendIPC('D'); |
602 | 303 |
with CurrentHedgehog^.Gear^ do |
4 | 304 |
Message:= Message or gm_Down |
305 |
end; |
|
306 |
||
307 |
procedure chDown_m(var s: shortstring); |
|
308 |
begin |
|
309 |
if CheckNoTeamOrHH then exit; |
|
351 | 310 |
if not CurrentTeam^.ExtDriven then SendIPC('d'); |
602 | 311 |
with CurrentHedgehog^.Gear^ do |
4 | 312 |
Message:= Message and not gm_Down |
313 |
end; |
|
314 |
||
1639 | 315 |
procedure chPrecise_p(var s: shortstring); |
316 |
begin |
|
317 |
if CheckNoTeamOrHH then exit; |
|
318 |
bShowFinger:= false; |
|
319 |
if not CurrentTeam^.ExtDriven then SendIPC('Z'); |
|
320 |
with CurrentHedgehog^.Gear^ do |
|
321 |
Message:= Message or gm_Precise |
|
322 |
end; |
|
323 |
||
324 |
procedure chPrecise_m(var s: shortstring); |
|
325 |
begin |
|
326 |
if CheckNoTeamOrHH then exit; |
|
327 |
if not CurrentTeam^.ExtDriven then SendIPC('z'); |
|
328 |
with CurrentHedgehog^.Gear^ do |
|
329 |
Message:= Message and not gm_Precise |
|
330 |
end; |
|
331 |
||
4 | 332 |
procedure chLJump(var s: shortstring); |
333 |
begin |
|
334 |
if CheckNoTeamOrHH then exit; |
|
176 | 335 |
bShowFinger:= false; |
351 | 336 |
if not CurrentTeam^.ExtDriven then SendIPC('j'); |
602 | 337 |
with CurrentHedgehog^.Gear^ do |
4 | 338 |
Message:= Message or gm_LJump |
339 |
end; |
|
340 |
||
341 |
procedure chHJump(var s: shortstring); |
|
342 |
begin |
|
343 |
if CheckNoTeamOrHH then exit; |
|
176 | 344 |
bShowFinger:= false; |
351 | 345 |
if not CurrentTeam^.ExtDriven then SendIPC('J'); |
602 | 346 |
with CurrentHedgehog^.Gear^ do |
4 | 347 |
Message:= Message or gm_HJump |
348 |
end; |
|
349 |
||
350 |
procedure chAttack_p(var s: shortstring); |
|
351 |
begin |
|
352 |
if CheckNoTeamOrHH then exit; |
|
176 | 353 |
bShowFinger:= false; |
602 | 354 |
with CurrentHedgehog^.Gear^ do |
4 | 355 |
begin |
2079 | 356 |
{$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
|
357 |
if ((State and gstHHDriven) <> 0) then |
4 | 358 |
begin |
602 | 359 |
FollowGear:= CurrentHedgehog^.Gear; |
351 | 360 |
if not CurrentTeam^.ExtDriven then SendIPC('A'); |
4 | 361 |
Message:= Message or gm_Attack |
362 |
end |
|
363 |
end |
|
364 |
end; |
|
365 |
||
366 |
procedure chAttack_m(var s: shortstring); |
|
367 |
begin |
|
368 |
if CheckNoTeamOrHH then exit; |
|
602 | 369 |
with CurrentHedgehog^.Gear^ do |
4 | 370 |
begin |
351 | 371 |
if not CurrentTeam^.ExtDriven and |
95 | 372 |
((Message and gm_Attack) <> 0) then SendIPC('a'); |
373 |
Message:= Message and not gm_Attack |
|
4 | 374 |
end |
375 |
end; |
|
376 |
||
377 |
procedure chSwitch(var s: shortstring); |
|
378 |
begin |
|
379 |
if CheckNoTeamOrHH then exit; |
|
351 | 380 |
if not CurrentTeam^.ExtDriven then SendIPC('S'); |
602 | 381 |
with CurrentHedgehog^.Gear^ do |
4 | 382 |
Message:= Message or gm_Switch |
383 |
end; |
|
384 |
||
385 |
procedure chNextTurn(var s: shortstring); |
|
386 |
begin |
|
2045
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
387 |
TryDo(AllInactive, '/nextturn called when not all gears are inactive', true); |
2046 | 388 |
|
2045
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
389 |
if not CurrentTeam^.ExtDriven then SendIPC('N'); |
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
390 |
TickTrigger(trigTurns); |
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
391 |
{$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF} |
4 | 392 |
end; |
393 |
||
394 |
procedure chSay(var s: shortstring); |
|
395 |
begin |
|
1356 | 396 |
SendIPC('s' + s); |
1378 | 397 |
|
398 |
if copy(s, 1, 4) = '/me ' then |
|
2396 | 399 |
s:= #2'* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4) |
1378 | 400 |
else |
2396 | 401 |
s:= #1 + UserNick + ': ' + s; |
1378 | 402 |
|
1356 | 403 |
AddChatString(s) |
4 | 404 |
end; |
405 |
||
2124 | 406 |
procedure chTeamSay(var s: shortstring); |
407 |
begin |
|
408 |
SendIPC('b' + s); |
|
409 |
||
2403 | 410 |
s:= #4 + UserNick + '(team): ' + s; |
2124 | 411 |
|
2396 | 412 |
AddChatString(s) |
2124 | 413 |
end; |
414 |
||
4 | 415 |
procedure chTimer(var s: shortstring); |
416 |
begin |
|
2314 | 417 |
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or CheckNoTeamOrHH then exit; |
176 | 418 |
bShowFinger:= false; |
2314 | 419 |
|
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
420 |
if not CurrentTeam^.ExtDriven then SendIPC(s); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
421 |
with CurrentHedgehog^.Gear^ do |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
422 |
begin |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
423 |
Message:= Message or gm_Timer; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
424 |
MsgParam:= byte(s[1]) - ord('0') |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
425 |
end |
4 | 426 |
end; |
427 |
||
428 |
procedure chSlot(var s: shortstring); |
|
429 |
var slot: LongWord; |
|
430 |
begin |
|
95 | 431 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
176 | 432 |
bShowFinger:= false; |
4 | 433 |
slot:= byte(s[1]) - 49; |
10 | 434 |
if slot > cMaxSlotIndex then exit; |
351 | 435 |
if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); |
783 | 436 |
with CurrentHedgehog^.Gear^ do |
4 | 437 |
begin |
783 | 438 |
Message:= Message or gm_Slot; |
439 |
MsgParam:= slot |
|
440 |
end |
|
441 |
end; |
|
442 |
||
443 |
procedure chSetWeapon(var s: shortstring); |
|
444 |
begin |
|
445 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
784 | 446 |
|
1850 | 447 |
if TAmmoType(s[1]) > High(TAmmoType) then exit; |
784 | 448 |
|
449 |
if not CurrentTeam^.ExtDriven then SendIPC('w' + s); |
|
450 |
||
783 | 451 |
with CurrentHedgehog^.Gear^ do |
452 |
begin |
|
453 |
Message:= Message or gm_Weapon; |
|
1850 | 454 |
MsgParam:= byte(s[1]) |
4 | 455 |
end |
456 |
end; |
|
457 |
||
1035 | 458 |
procedure chTaunt(var s: shortstring); |
459 |
begin |
|
460 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
461 |
||
462 |
if TWave(s[1]) > High(TWave) then exit; |
|
463 |
||
464 |
if not CurrentTeam^.ExtDriven then SendIPC('t' + s); |
|
465 |
||
466 |
with CurrentHedgehog^.Gear^ do |
|
467 |
begin |
|
468 |
Message:= Message or gm_Animate; |
|
469 |
MsgParam:= byte(s[1]) |
|
470 |
end |
|
471 |
end; |
|
472 |
||
2017 | 473 |
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
|
474 |
var Gear: PVisualGear; |
2017 | 475 |
text: shortstring; |
476 |
begin |
|
477 |
text:= copy(s, 2, Length(s)-1); |
|
2110 | 478 |
if CheckNoTeamOrHH |
2111 | 479 |
or ((CurrentHedgehog^.Gear^.State and gstHHDriven) = 0) then |
2017 | 480 |
begin |
481 |
chSay(text); |
|
482 |
exit |
|
483 |
end; |
|
484 |
||
485 |
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
|
486 |
|
2017 | 487 |
if byte(s[1]) < 4 then |
488 |
begin |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2022
diff
changeset
|
489 |
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
|
490 |
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
|
491 |
begin |
9a8ccc7bc3d8
Fix crash caused by speechbubbles when restoring from save or joining already started net game
unc0rr
parents:
2111
diff
changeset
|
492 |
Gear^.Hedgehog:= CurrentHedgehog; |
9a8ccc7bc3d8
Fix crash caused by speechbubbles when restoring from save or joining already started net game
unc0rr
parents:
2111
diff
changeset
|
493 |
Gear^.Text:= text; |
9a8ccc7bc3d8
Fix crash caused by speechbubbles when restoring from save or joining already started net game
unc0rr
parents:
2111
diff
changeset
|
494 |
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
|
495 |
end |
2017 | 496 |
end |
497 |
else |
|
498 |
begin |
|
2022 | 499 |
SpeechType:= byte(s[1])-3; |
2017 | 500 |
SpeechText:= text |
501 |
end; |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2022
diff
changeset
|
502 |
|
2017 | 503 |
end; |
504 |
||
1821
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
505 |
procedure chNewGrave; |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
506 |
begin |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
507 |
if CheckNoTeamOrHH then exit; |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
508 |
|
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
509 |
if not CurrentTeam^.ExtDriven then SendIPC('g'); |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
510 |
|
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
511 |
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
|
512 |
end; |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
513 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
514 |
procedure doPut(putX, putY: LongInt; fromAI: boolean); |
4 | 515 |
begin |
516 |
if CheckNoTeamOrHH then exit; |
|
162 | 517 |
if bShowAmmoMenu then |
2407
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
518 |
begin |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
519 |
bSelected:= true; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
520 |
exit |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
521 |
end; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
522 |
|
602 | 523 |
with CurrentHedgehog^.Gear^, |
2407
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
524 |
CurrentHedgehog^ do |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
525 |
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
|
526 |
begin |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
527 |
isCursorVisible:= false; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
528 |
if not CurrentTeam^.ExtDriven then |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
529 |
begin |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
530 |
if fromAI then |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
531 |
begin |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
532 |
TargetPoint.X:= putX; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
533 |
TargetPoint.Y:= putY |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
534 |
end else |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
535 |
begin |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
536 |
TargetPoint.X:= CursorPoint.X - WorldDx; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
537 |
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
|
538 |
end; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
539 |
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
|
540 |
end |
89aa2aa89066
Fix bug with cursor coordinates sent via net (or demo/save file)
unc0rr
parents:
2642
diff
changeset
|
541 |
else |
89aa2aa89066
Fix bug with cursor coordinates sent via net (or demo/save file)
unc0rr
parents:
2642
diff
changeset
|
542 |
begin |
89aa2aa89066
Fix bug with cursor coordinates sent via net (or demo/save file)
unc0rr
parents:
2642
diff
changeset
|
543 |
TargetPoint.X:= putX; |
89aa2aa89066
Fix bug with cursor coordinates sent via net (or demo/save file)
unc0rr
parents:
2642
diff
changeset
|
544 |
TargetPoint.Y:= putY |
2407
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
545 |
end; |
2642 | 546 |
{$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
|
547 |
State:= State and not gstHHChooseTarget; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
548 |
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
|
549 |
Message:= Message or gm_Attack; |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
550 |
end |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
551 |
else |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
552 |
if CurrentTeam^.ExtDriven then |
9f413bd5150e
- Fix mouse cursor bugs in net game (still has a bug near water)
unc0rr
parents:
2406
diff
changeset
|
553 |
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
|
554 |
end; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
555 |
|
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
556 |
procedure chPut(var s: shortstring); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
557 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
558 |
doPut(0, 0, false) |
4 | 559 |
end; |
560 |
||
561 |
procedure chCapture(var s: shortstring); |
|
562 |
begin |
|
563 |
flagMakeCapture:= true |
|
564 |
end; |
|
565 |
||
48 | 566 |
procedure chSkip(var s: shortstring); |
567 |
begin |
|
351 | 568 |
if not CurrentTeam^.ExtDriven then SendIPC(','); |
871 | 569 |
uStats.Skipped; |
917 | 570 |
skipFlag:= true |
48 | 571 |
end; |
572 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
573 |
procedure chSetMap(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
574 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
575 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
576 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
577 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
578 |
InitStepsFlags:= InitStepsFlags or cifMap |
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 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
581 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
582 |
procedure chSetTheme(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
583 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
584 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
585 |
begin |
80 | 586 |
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
|
587 |
InitStepsFlags:= InitStepsFlags or cifTheme |
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 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
590 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
591 |
procedure chSetSeed(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
592 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
593 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
594 |
begin |
102 | 595 |
SetRandomSeed(s); |
81 | 596 |
cSeed:= s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
597 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
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 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
600 |
|
161 | 601 |
procedure chAmmoMenu(var s: shortstring); |
602 |
begin |
|
603 |
if CheckNoTeamOrHH then exit; |
|
604 |
with CurrentTeam^ do |
|
605 |
with Hedgehogs[CurrHedgehog] do |
|
606 |
begin |
|
162 | 607 |
bSelected:= false; |
682 | 608 |
|
161 | 609 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
2608 | 610 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (MultiShootAttacks > 0) |
351 | 611 |
or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
161 | 612 |
end |
613 |
end; |
|
614 |
||
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
615 |
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
|
616 |
var flags: Longword = 0; |
2800 | 617 |
ico: PSDL_Surface; |
192 | 618 |
{$IFDEF DEBUGFILE} |
619 |
buf: array[byte] of char; |
|
620 |
{$ENDIF} |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
621 |
{$IFDEF SDL13} |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
622 |
window: PSDL_Window; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
623 |
{$ENDIF} |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
624 |
begin |
2697 | 625 |
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
|
626 |
else cFullScreen:= s = '1'; |
192 | 627 |
|
905 | 628 |
{$IFDEF DEBUGFILE} |
2697 | 629 |
AddFileLog('Prepare to change video parameters...'); |
905 | 630 |
{$ENDIF} |
2253 | 631 |
|
2697 | 632 |
flags:= SDL_OPENGL;// or SDL_RESIZABLE; |
753 | 633 |
|
2697 | 634 |
if cFullScreen then |
1121
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
635 |
begin |
2697 | 636 |
flags:= flags or SDL_FULLSCREEN; |
637 |
cScreenWidth:= cInitWidth; |
|
638 |
cScreenHeight:= cInitHeight |
|
2351
a4a17b8df591
Set window caption even in fullscreen mode (suggested by Smaxx)
unc0rr
parents:
2314
diff
changeset
|
639 |
end; |
a4a17b8df591
Set window caption even in fullscreen mode (suggested by Smaxx)
unc0rr
parents:
2314
diff
changeset
|
640 |
|
2800 | 641 |
// load window icon |
2812 | 642 |
ico:= LoadImage(Pathz[ptGraphics] + '/hwengine{$IFDEF DARWIN}_mac{$ENDIF}', ifIgnoreCaps); |
2800 | 643 |
if ico <> nil then |
644 |
begin |
|
645 |
SDL_WM_SetIcon(ico, 0); |
|
646 |
SDL_FreeSurface(ico) |
|
647 |
end; |
|
648 |
||
649 |
// set window caption |
|
2697 | 650 |
SDL_WM_SetCaption('Hedgewars', nil); |
2800 | 651 |
|
2697 | 652 |
if SDLPrimSurface <> nil then |
2428 | 653 |
begin |
2697 | 654 |
{$IFDEF DEBUGFILE} |
655 |
AddFileLog('Freeing old primary surface...'); |
|
656 |
{$ENDIF} |
|
657 |
SDL_FreeSurface(SDLPrimSurface); |
|
2428 | 658 |
end; |
2697 | 659 |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
660 |
{$IFDEF SDL13} |
2738
bfccb2ec4334
new graphics from Tiy and frontend is loaded in landscape mode
koda
parents:
2726
diff
changeset
|
661 |
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
|
662 |
SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
663 |
{$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS{$ENDIF}); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
664 |
SDL_CreateRenderer(window, -1, 0); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
665 |
PixelFormat:= nil; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
666 |
|
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
667 |
SDL_SetRenderDrawColor(0, 0, 0, 255); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
668 |
SDL_RenderFill(nil); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
669 |
SDL_RenderPresent(); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
670 |
{$ELSE} |
2697 | 671 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
672 |
SDLTry(SDLPrimSurface <> nil, true); |
|
673 |
PixelFormat:= SDLPrimSurface^.format; |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
674 |
{$ENDIF} |
192 | 675 |
|
905 | 676 |
{$IFDEF DEBUGFILE} |
2697 | 677 |
AddFileLog('Setting up OpenGL...'); |
678 |
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); |
|
905 | 679 |
{$ENDIF} |
2697 | 680 |
SetupOpenGL(); |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
681 |
end; |
161 | 682 |
|
175 | 683 |
procedure chVol_p(var s: shortstring); |
174 | 684 |
begin |
175 | 685 |
inc(cVolumeDelta, 3) |
174 | 686 |
end; |
687 |
||
175 | 688 |
procedure chVol_m(var s: shortstring); |
174 | 689 |
begin |
175 | 690 |
dec(cVolumeDelta, 3) |
174 | 691 |
end; |
692 |
||
176 | 693 |
procedure chFindhh(var s: shortstring); |
694 |
begin |
|
695 |
if CheckNoTeamOrHH then exit; |
|
696 |
bShowFinger:= true; |
|
602 | 697 |
FollowGear:= CurrentHedgehog^.Gear |
176 | 698 |
end; |
699 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
700 |
procedure chPause(var s: shortstring); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
701 |
begin |
1743 | 702 |
if gameType <> gmtNet then |
703 |
isPaused:= not isPaused; |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
704 |
SDL_ShowCursor(ord(isPaused)) |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
705 |
end; |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
706 |
|
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
707 |
procedure chRotateMask(var s: shortstring); |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
708 |
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
|
709 |
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
|
710 |
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
|
711 |
|
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
|
712 |
// 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
|
713 |
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
|
714 |
end; |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
715 |
|
589 | 716 |
procedure chAddTrigger(var s: shortstring); |
615 | 717 |
const MAXPARAMS = 16; |
718 |
var params: array[0..Pred(MAXPARAMS)] of Longword; |
|
719 |
i: LongInt; |
|
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
720 |
c: char; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
721 |
tmp: shortstring; |
589 | 722 |
begin |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
723 |
c:= s[1]; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
724 |
Delete(s, 1, 1); |
615 | 725 |
|
726 |
i:= 0; |
|
727 |
while (i < MAXPARAMS) and |
|
728 |
(Length(s) > 0) do |
|
729 |
begin |
|
730 |
SplitBySpace(s, tmp); |
|
731 |
val(s, params[i]); |
|
732 |
s:= tmp; |
|
733 |
inc(i) |
|
734 |
end; |
|
735 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
736 |
case c of |
613 | 737 |
's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER |
615 | 738 |
TryDo(i = 7, errmsgWrongNumber, true); |
739 |
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
|
740 |
end; |
613 | 741 |
'C': begin |
615 | 742 |
TryDo(i = 3, errmsgWrongNumber, true); |
743 |
AddTriggerSuccess(params[0], params[1], params[2]); |
|
744 |
end; |
|
745 |
'F': begin |
|
746 |
TryDo(i = 3, errmsgWrongNumber, true); |
|
747 |
AddTriggerFail(params[0], params[1], params[2]); |
|
613 | 748 |
end; |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
749 |
end |
589 | 750 |
end; |
626 | 751 |
|
752 |
procedure chSpeedup_p(var s: shortstring); |
|
753 |
begin |
|
754 |
isSpeed:= true |
|
755 |
end; |
|
756 |
||
757 |
procedure chSpeedup_m(var s: shortstring); |
|
758 |
begin |
|
759 |
isSpeed:= false |
|
760 |
end; |
|
946 | 761 |
|
2162 | 762 |
procedure chZoomIn(var s: shortstring); |
763 |
begin |
|
2579 | 764 |
{$IFDEF IPHONEOS} |
765 |
if ZoomValue < 3.5 then |
|
766 |
{$ELSE} |
|
767 |
if ZoomValue < 3.0 then |
|
768 |
{$ENDIF} |
|
769 |
ZoomValue:= ZoomValue + 0.25; |
|
2162 | 770 |
end; |
771 |
||
772 |
procedure chZoomOut(var s: shortstring); |
|
773 |
begin |
|
2579 | 774 |
{$IFDEF IPHONEOS} |
775 |
if ZoomValue > 0.5 then |
|
776 |
{$ELSE} |
|
777 |
if ZoomValue > 1.0 then |
|
778 |
{$ENDIF} |
|
779 |
ZoomValue:= ZoomValue - 0.25; |
|
2162 | 780 |
end; |
781 |
||
2379 | 782 |
procedure chZoomReset(var s: shortstring); |
783 |
begin |
|
784 |
ZoomValue:= 2.0 |
|
785 |
end; |
|
786 |
||
946 | 787 |
procedure chChat(var s: shortstring); |
788 |
begin |
|
990
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
789 |
GameState:= gsChat; |
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
790 |
KeyPressChat(27) |
946 | 791 |
end; |
991 | 792 |
|
793 |
procedure chHistory(var s: shortstring); |
|
794 |
begin |
|
795 |
uChat.showAll:= not uChat.showAll |
|
796 |
end; |