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