author | smxx |
Sat, 20 Feb 2010 09:33:20 +0000 | |
changeset 2830 | 571a9deffeac |
parent 2817 | 4494dab9ef6a |
child 2831 | 797207d0c500 |
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 |
2817 | 642 |
{$IFNDEF DARWIN} |
643 |
ico:= LoadImage(Pathz[ptGraphics] + '/hwengine', ifIgnoreCaps); |
|
644 |
{$ELSE} |
|
645 |
ico:= LoadImage(Pathz[ptGraphics] + '/hwengine_mac', ifIgnoreCaps); |
|
646 |
{$ENDIF} |
|
2800 | 647 |
if ico <> nil then |
648 |
begin |
|
649 |
SDL_WM_SetIcon(ico, 0); |
|
650 |
SDL_FreeSurface(ico) |
|
651 |
end; |
|
652 |
||
653 |
// set window caption |
|
2697 | 654 |
SDL_WM_SetCaption('Hedgewars', nil); |
2800 | 655 |
|
2697 | 656 |
if SDLPrimSurface <> nil then |
2428 | 657 |
begin |
2697 | 658 |
{$IFDEF DEBUGFILE} |
659 |
AddFileLog('Freeing old primary surface...'); |
|
660 |
{$ENDIF} |
|
661 |
SDL_FreeSurface(SDLPrimSurface); |
|
2428 | 662 |
end; |
2697 | 663 |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
664 |
{$IFDEF SDL13} |
2738
bfccb2ec4334
new graphics from Tiy and frontend is loaded in landscape mode
koda
parents:
2726
diff
changeset
|
665 |
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
|
666 |
SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
667 |
{$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS{$ENDIF}); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
668 |
SDL_CreateRenderer(window, -1, 0); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
669 |
PixelFormat:= nil; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
670 |
|
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
671 |
SDL_SetRenderDrawColor(0, 0, 0, 255); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
672 |
SDL_RenderFill(nil); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
673 |
SDL_RenderPresent(); |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
674 |
{$ELSE} |
2697 | 675 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
676 |
SDLTry(SDLPrimSurface <> nil, true); |
|
677 |
PixelFormat:= SDLPrimSurface^.format; |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2714
diff
changeset
|
678 |
{$ENDIF} |
192 | 679 |
|
905 | 680 |
{$IFDEF DEBUGFILE} |
2697 | 681 |
AddFileLog('Setting up OpenGL...'); |
682 |
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); |
|
905 | 683 |
{$ENDIF} |
2697 | 684 |
SetupOpenGL(); |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
685 |
end; |
161 | 686 |
|
175 | 687 |
procedure chVol_p(var s: shortstring); |
174 | 688 |
begin |
175 | 689 |
inc(cVolumeDelta, 3) |
174 | 690 |
end; |
691 |
||
175 | 692 |
procedure chVol_m(var s: shortstring); |
174 | 693 |
begin |
175 | 694 |
dec(cVolumeDelta, 3) |
174 | 695 |
end; |
696 |
||
176 | 697 |
procedure chFindhh(var s: shortstring); |
698 |
begin |
|
699 |
if CheckNoTeamOrHH then exit; |
|
700 |
bShowFinger:= true; |
|
602 | 701 |
FollowGear:= CurrentHedgehog^.Gear |
176 | 702 |
end; |
703 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
704 |
procedure chPause(var s: shortstring); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
705 |
begin |
1743 | 706 |
if gameType <> gmtNet then |
707 |
isPaused:= not isPaused; |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
708 |
SDL_ShowCursor(ord(isPaused)) |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
709 |
end; |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
710 |
|
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
711 |
procedure chRotateMask(var s: shortstring); |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
712 |
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
|
713 |
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
|
714 |
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
|
715 |
|
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
|
716 |
// 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
|
717 |
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
|
718 |
end; |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
719 |
|
589 | 720 |
procedure chAddTrigger(var s: shortstring); |
615 | 721 |
const MAXPARAMS = 16; |
722 |
var params: array[0..Pred(MAXPARAMS)] of Longword; |
|
723 |
i: LongInt; |
|
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
724 |
c: char; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
725 |
tmp: shortstring; |
589 | 726 |
begin |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
727 |
c:= s[1]; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
728 |
Delete(s, 1, 1); |
615 | 729 |
|
730 |
i:= 0; |
|
731 |
while (i < MAXPARAMS) and |
|
732 |
(Length(s) > 0) do |
|
733 |
begin |
|
734 |
SplitBySpace(s, tmp); |
|
735 |
val(s, params[i]); |
|
736 |
s:= tmp; |
|
737 |
inc(i) |
|
738 |
end; |
|
739 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
740 |
case c of |
613 | 741 |
's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER |
615 | 742 |
TryDo(i = 7, errmsgWrongNumber, true); |
743 |
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
|
744 |
end; |
613 | 745 |
'C': begin |
615 | 746 |
TryDo(i = 3, errmsgWrongNumber, true); |
747 |
AddTriggerSuccess(params[0], params[1], params[2]); |
|
748 |
end; |
|
749 |
'F': begin |
|
750 |
TryDo(i = 3, errmsgWrongNumber, true); |
|
751 |
AddTriggerFail(params[0], params[1], params[2]); |
|
613 | 752 |
end; |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
753 |
end |
589 | 754 |
end; |
626 | 755 |
|
756 |
procedure chSpeedup_p(var s: shortstring); |
|
757 |
begin |
|
758 |
isSpeed:= true |
|
759 |
end; |
|
760 |
||
761 |
procedure chSpeedup_m(var s: shortstring); |
|
762 |
begin |
|
763 |
isSpeed:= false |
|
764 |
end; |
|
946 | 765 |
|
2162 | 766 |
procedure chZoomIn(var s: shortstring); |
767 |
begin |
|
2579 | 768 |
{$IFDEF IPHONEOS} |
769 |
if ZoomValue < 3.5 then |
|
770 |
{$ELSE} |
|
771 |
if ZoomValue < 3.0 then |
|
772 |
{$ENDIF} |
|
773 |
ZoomValue:= ZoomValue + 0.25; |
|
2162 | 774 |
end; |
775 |
||
776 |
procedure chZoomOut(var s: shortstring); |
|
777 |
begin |
|
2579 | 778 |
{$IFDEF IPHONEOS} |
779 |
if ZoomValue > 0.5 then |
|
780 |
{$ELSE} |
|
781 |
if ZoomValue > 1.0 then |
|
782 |
{$ENDIF} |
|
783 |
ZoomValue:= ZoomValue - 0.25; |
|
2162 | 784 |
end; |
785 |
||
2379 | 786 |
procedure chZoomReset(var s: shortstring); |
787 |
begin |
|
788 |
ZoomValue:= 2.0 |
|
789 |
end; |
|
790 |
||
946 | 791 |
procedure chChat(var s: shortstring); |
792 |
begin |
|
990
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
793 |
GameState:= gsChat; |
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
794 |
KeyPressChat(27) |
946 | 795 |
end; |
991 | 796 |
|
797 |
procedure chHistory(var s: shortstring); |
|
798 |
begin |
|
799 |
uChat.showAll:= not uChat.showAll |
|
800 |
end; |