author  unc0rr 
Sun, 31 Aug 2008 17:22:50 +0000  
changeset 1242  4aca5f7b2504 
parent 1127  7e1b94a0fc1f 
child 1356  77ab8735401d 
permissions  rwrr 
4  1 
(* 
1066  2 
* Hedgewars, a free turn based strategy game 
883  3 
* Copyright (c) 20042008 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 021111307, USA 

4  17 
*) 
18 

19 
function CheckNoTeamOrHH: boolean; 

351  20 
var Result: boolean; 
4  21 
begin 
602  22 
Result:= (CurrentTeam = nil) or (CurrentHedgehog^.Gear = nil); 
4  23 
{$IFDEF DEBUGFILE} 
24 
if Result then 

25 
if CurrentTeam = nil then AddFileLog('CONSOLE: CurTeam = nil') 

351  26 
else AddFileLog('CONSOLE: CurTeam <> nil, Gear = nil'); 
4  27 
{$ENDIF} 
351  28 
CheckNoTeamOrHH:= Result 
4  29 
end; 
30 
//////////////////////////////////////////////////////////////////////////////// 

31 
procedure chQuit(var s: shortstring); 

1022  32 
const prevGState: TGameState = gsConfirm; 
4  33 
begin 
1022  34 
if GameState <> gsConfirm then 
35 
begin 

36 
prevGState:= GameState; 

37 
GameState:= gsConfirm 

38 
end else 

39 
GameState:= prevGState 

40 
end; 

41 

42 
procedure chConfirm(var s: shortstring); 

43 
begin 

44 
if GameState = gsConfirm then 

45 
begin 

46 
SendIPC('Q'); 

47 
GameState:= gsExit 

48 
end 

4  49 
end; 
50 

205  51 
procedure chCheckProto(var s: shortstring); 
371  52 
var i, c: LongInt; 
205  53 
begin 
54 
if isDeveloperMode then 

55 
begin 

56 
val(s, i, c); 

57 
if (c <> 0) or (i = 0) then exit; 

58 
TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old', true); 

59 
TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new', true) 

60 
end 

61 
end; 

62 

4  63 
procedure chAddTeam(var s: shortstring); 
549  64 
var Color: Longword; 
605  65 
ts: shortstring; 
4  66 
begin 
145  67 
if isDeveloperMode then 
68 
begin 

605  69 
SplitBySpace(s, ts); 
549  70 
val(s, Color); 
71 
TryDo(Color <> 0, 'Error: black team color', true); 

351  72 

764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
753
diff
changeset

73 
Color:= Color or $FF000000; 
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
753
diff
changeset

74 

549  75 
AddTeam(Color); 
605  76 
CurrentTeam^.TeamName:= ts; 
549  77 
if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true 
546  78 
end 
4  79 
end; 
80 

81 
procedure chTeamLocal(var s: shortstring); 

82 
begin 

83 
if not isDeveloperMode then exit; 

84 
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); 

351  85 
CurrentTeam^.ExtDriven:= true 
4  86 
end; 
87 

88 
procedure chGrave(var s: shortstring); 

89 
begin 

90 
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); 

91 
if s[1]='"' then Delete(s, 1, 1); 

92 
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); 

351  93 
CurrentTeam^.GraveName:= s 
4  94 
end; 
95 

96 
procedure chFort(var s: shortstring); 

97 
begin 

764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
753
diff
changeset

98 
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/fort"', true); 
4  99 
if s[1]='"' then Delete(s, 1, 1); 
100 
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); 

351  101 
CurrentTeam^.FortName:= s 
4  102 
end; 
103 

312  104 
procedure chAddHH(var id: shortstring); 
4  105 
var s: shortstring; 
106 
Gear: PGear; 

107 
begin 

394
4c017ae1226a
 Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset

108 
if (not isDeveloperMode) or (CurrentTeam = nil) then exit; 
312  109 
with CurrentTeam^ do 
1242  110 
begin 
111 
SplitBySpace(id, s); 

112 
CurrentHedgehog:= @Hedgehogs[HedgehogsNumber]; 

113 
val(id, CurrentHedgehog^.BotLevel); 

114 
Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0); 

115 
SplitBySpace(s, id); 

116 
val(s, Gear^.Health); 

117 
TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true); 

118 
PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam; 

119 
CurrentHedgehog^.AmmoStore:= TeamsCount  1; // FIXME HACK to get ammostores work 

120 
CurrentHedgehog^.Gear:= Gear; 

121 
CurrentHedgehog^.Name:= id; 

122 
inc(HedgehogsNumber) 

123 
end 

124 
end; 

125 

126 
procedure chSetHat(var s: shortstring); 

127 
begin 

128 
if (not isDeveloperMode) or (CurrentTeam = nil) then exit; 

129 
with CurrentTeam^ do 

130 
if s = '' then 

131 
CurrentHedgehog^.Hat:= 'NoHat' 

132 
else 

133 
CurrentHedgehog^.Hat:= s 

4  134 
end; 
135 

604
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset

136 
procedure chSetHHCoords(var x: shortstring); 
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset

137 
var y: shortstring; 
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset

138 
t: Longint; 
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset

139 
begin 
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset

140 
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

141 
SplitBySpace(x, y); 
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset

142 
val(x, t); 
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset

143 
CurrentHedgehog^.Gear^.X:= int2hwFloat(t); 
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset

144 
val(y, t); 
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset

145 
CurrentHedgehog^.Gear^.Y:= int2hwFloat(t) 
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset

146 
end; 
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset

147 

288  148 
procedure chAddAmmoStore(var descr: shortstring); 
149 
begin 

150 
AddAmmoStore(descr) 

151 
end; 

152 

4  153 
procedure chBind(var id: shortstring); 
154 
var s: shortstring; 

371  155 
b: LongInt; 
4  156 
begin 
157 
if CurrentTeam = nil then exit; 

158 
SplitBySpace(id, s); 

159 
if s[1]='"' then Delete(s, 1, 1); 

160 
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); 

161 
b:= KeyNameToCode(id); 

351  162 
if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false) 
163 
else CurrentTeam^.Binds[b]:= s 

4  164 
end; 
165 

166 
procedure chLeft_p(var s: shortstring); 

167 
begin 

168 
if CheckNoTeamOrHH then exit; 

176  169 
bShowFinger:= false; 
351  170 
if not CurrentTeam^.ExtDriven then SendIPC('L'); 
602  171 
with CurrentHedgehog^.Gear^ do 
4  172 
Message:= Message or gm_Left 
173 
end; 

174 

175 
procedure chLeft_m(var s: shortstring); 

176 
begin 

177 
if CheckNoTeamOrHH then exit; 

351  178 
if not CurrentTeam^.ExtDriven then SendIPC('l'); 
602  179 
with CurrentHedgehog^.Gear^ do 
4  180 
Message:= Message and not gm_Left 
181 
end; 

182 

183 
procedure chRight_p(var s: shortstring); 

184 
begin 

185 
if CheckNoTeamOrHH then exit; 

176  186 
bShowFinger:= false; 
351  187 
if not CurrentTeam^.ExtDriven then SendIPC('R'); 
602  188 
with CurrentHedgehog^.Gear^ do 
4  189 
Message:= Message or gm_Right 
190 
end; 

191 

192 
procedure chRight_m(var s: shortstring); 

193 
begin 

194 
if CheckNoTeamOrHH then exit; 

351  195 
if not CurrentTeam^.ExtDriven then SendIPC('r'); 
602  196 
with CurrentHedgehog^.Gear^ do 
4  197 
Message:= Message and not gm_Right 
198 
end; 

199 

200 
procedure chUp_p(var s: shortstring); 

201 
begin 

202 
if CheckNoTeamOrHH then exit; 

176  203 
bShowFinger:= false; 
351  204 
if not CurrentTeam^.ExtDriven then SendIPC('U'); 
602  205 
with CurrentHedgehog^.Gear^ do 
4  206 
Message:= Message or gm_Up 
207 
end; 

208 

209 
procedure chUp_m(var s: shortstring); 

210 
begin 

211 
if CheckNoTeamOrHH then exit; 

351  212 
if not CurrentTeam^.ExtDriven then SendIPC('u'); 
602  213 
with CurrentHedgehog^.Gear^ do 
4  214 
Message:= Message and not gm_Up 
215 
end; 

216 

217 
procedure chDown_p(var s: shortstring); 

218 
begin 

219 
if CheckNoTeamOrHH then exit; 

176  220 
bShowFinger:= false; 
351  221 
if not CurrentTeam^.ExtDriven then SendIPC('D'); 
602  222 
with CurrentHedgehog^.Gear^ do 
4  223 
Message:= Message or gm_Down 
224 
end; 

225 

226 
procedure chDown_m(var s: shortstring); 

227 
begin 

228 
if CheckNoTeamOrHH then exit; 

351  229 
if not CurrentTeam^.ExtDriven then SendIPC('d'); 
602  230 
with CurrentHedgehog^.Gear^ do 
4  231 
Message:= Message and not gm_Down 
232 
end; 

233 

234 
procedure chLJump(var s: shortstring); 

235 
begin 

236 
if CheckNoTeamOrHH then exit; 

176  237 
bShowFinger:= false; 
351  238 
if not CurrentTeam^.ExtDriven then SendIPC('j'); 
602  239 
with CurrentHedgehog^.Gear^ do 
4  240 
Message:= Message or gm_LJump 
241 
end; 

242 

243 
procedure chHJump(var s: shortstring); 

244 
begin 

245 
if CheckNoTeamOrHH then exit; 

176  246 
bShowFinger:= false; 
351  247 
if not CurrentTeam^.ExtDriven then SendIPC('J'); 
602  248 
with CurrentHedgehog^.Gear^ do 
4  249 
Message:= Message or gm_HJump 
250 
end; 

251 

252 
procedure chAttack_p(var s: shortstring); 

253 
begin 

254 
if CheckNoTeamOrHH then exit; 

176  255 
bShowFinger:= false; 
602  256 
with CurrentHedgehog^.Gear^ do 
4  257 
begin 
351  258 
{$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear^.State = '+inttostr(State));{$ENDIF} 
929
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
927
diff
changeset

259 
if ((State and gstHHDriven) <> 0) then 
4  260 
begin 
602  261 
FollowGear:= CurrentHedgehog^.Gear; 
351  262 
if not CurrentTeam^.ExtDriven then SendIPC('A'); 
4  263 
Message:= Message or gm_Attack 
264 
end 

265 
end 

266 
end; 

267 

268 
procedure chAttack_m(var s: shortstring); 

269 
begin 

270 
if CheckNoTeamOrHH then exit; 

602  271 
with CurrentHedgehog^.Gear^ do 
4  272 
begin 
351  273 
if not CurrentTeam^.ExtDriven and 
95  274 
((Message and gm_Attack) <> 0) then SendIPC('a'); 
275 
Message:= Message and not gm_Attack 

4  276 
end 
277 
end; 

278 

279 
procedure chSwitch(var s: shortstring); 

280 
begin 

281 
if CheckNoTeamOrHH then exit; 

351  282 
if not CurrentTeam^.ExtDriven then SendIPC('S'); 
602  283 
with CurrentHedgehog^.Gear^ do 
4  284 
Message:= Message or gm_Switch 
285 
end; 

286 

287 
procedure chNextTurn(var s: shortstring); 

288 
begin 

289 
if AllInactive then 

290 
begin 

351  291 
if not CurrentTeam^.ExtDriven then SendIPC('N'); 
593  292 
TickTrigger(trigTurns); 
4  293 
{$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF} 
294 
end 

295 
end; 

296 

297 
procedure chSay(var s: shortstring); 

298 
begin 

950  299 
s:= UserNick + ': ' + s; 
300 
AddChatString(s); 

301 
SendIPC('s' + s) 

4  302 
end; 
303 

304 
procedure chTimer(var s: shortstring); 

305 
begin 

306 
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit; 

176  307 
bShowFinger:= false; 
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset

308 
if not CurrentTeam^.ExtDriven then SendIPC(s); 
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset

309 
with CurrentHedgehog^.Gear^ do 
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset

310 
begin 
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset

311 
Message:= Message or gm_Timer; 
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset

312 
MsgParam:= byte(s[1])  ord('0') 
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset

313 
end 
4  314 
end; 
315 

316 
procedure chSlot(var s: shortstring); 

317 
var slot: LongWord; 

318 
begin 

95  319 
if (s[0] <> #1) or CheckNoTeamOrHH then exit; 
176  320 
bShowFinger:= false; 
4  321 
slot:= byte(s[1])  49; 
10  322 
if slot > cMaxSlotIndex then exit; 
351  323 
if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); 
783  324 
with CurrentHedgehog^.Gear^ do 
4  325 
begin 
783  326 
Message:= Message or gm_Slot; 
327 
MsgParam:= slot 

328 
end 

329 
end; 

330 

331 
procedure chSetWeapon(var s: shortstring); 

332 
begin 

333 
if (s[0] <> #1) or CheckNoTeamOrHH then exit; 

784  334 

335 
if TAmmoType(s[1]) > High(TAmmoType) then exit; 

336 

337 
if not CurrentTeam^.ExtDriven then SendIPC('w' + s); 

338 

783  339 
with CurrentHedgehog^.Gear^ do 
340 
begin 

341 
Message:= Message or gm_Weapon; 

784  342 
MsgParam:= byte(s[1]) 
4  343 
end 
344 
end; 

345 

1035  346 
procedure chTaunt(var s: shortstring); 
347 
begin 

348 
if (s[0] <> #1) or CheckNoTeamOrHH then exit; 

349 

350 
if TWave(s[1]) > High(TWave) then exit; 

351 

352 
if not CurrentTeam^.ExtDriven then SendIPC('t' + s); 

353 

354 
with CurrentHedgehog^.Gear^ do 

355 
begin 

356 
Message:= Message or gm_Animate; 

357 
MsgParam:= byte(s[1]) 

358 
end 

359 
end; 

360 

543
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

361 
procedure doPut(putX, putY: LongInt; fromAI: boolean); 
4  362 
begin 
363 
if CheckNoTeamOrHH then exit; 

162  364 
if bShowAmmoMenu then 
365 
begin 

366 
bSelected:= true; 

367 
exit 

368 
end; 

543
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

369 

602  370 
with CurrentHedgehog^.Gear^, 
371 
CurrentHedgehog^ do 

4  372 
if (State and gstHHChooseTarget) <> 0 then 
373 
begin 

374 
isCursorVisible:= false; 

351  375 
if not CurrentTeam^.ExtDriven then 
4  376 
begin 
543
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

377 
if fromAI then 
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

378 
begin 
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

379 
TargetPoint.X:= putX; 
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

380 
TargetPoint.Y:= putY 
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

381 
end else 
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

382 
begin 
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

383 
SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y); 
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

384 
dec(TargetPoint.X, WorldDx); 
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

385 
dec(TargetPoint.Y, WorldDy) 
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

386 
end; 
154
5667e6f38704
Network protocol uses integers in network byte order
unc0rr
parents:
145
diff
changeset

387 
SendIPCXY('p', TargetPoint.X, TargetPoint.Y); 
4  388 
end; 
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset

389 
State:= State and not gstHHChooseTarget; 
351  390 
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then 
263  391 
Message:= Message or gm_Attack; 
351  392 
end else if CurrentTeam^.ExtDriven then OutError('got /put while not being in choose target mode', false) 
543
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

393 
end; 
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

394 

465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

395 
procedure chPut(var s: shortstring); 
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

396 
begin 
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

397 
doPut(0, 0, false) 
4  398 
end; 
399 

400 
procedure chCapture(var s: shortstring); 

401 
begin 

402 
flagMakeCapture:= true 

403 
end; 

404 

48  405 
procedure chSkip(var s: shortstring); 
406 
begin 

351  407 
if not CurrentTeam^.ExtDriven then SendIPC(','); 
871  408 
uStats.Skipped; 
917  409 
skipFlag:= true 
48  410 
end; 
411 

55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

412 
procedure chSetMap(var s: shortstring); 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

413 
begin 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

414 
if isDeveloperMode then 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

415 
begin 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

416 
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

417 
InitStepsFlags:= InitStepsFlags or cifMap 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

418 
end 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

419 
end; 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

420 

e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

421 
procedure chSetTheme(var s: shortstring); 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

422 
begin 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

423 
if isDeveloperMode then 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

424 
begin 
80  425 
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

426 
InitStepsFlags:= InitStepsFlags or cifTheme 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

427 
end 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

428 
end; 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

429 

e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

430 
procedure chSetSeed(var s: shortstring); 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

431 
begin 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

432 
if isDeveloperMode then 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

433 
begin 
102  434 
SetRandomSeed(s); 
81  435 
cSeed:= s; 
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

436 
InitStepsFlags:= InitStepsFlags or cifRandomize 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

437 
end 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

438 
end; 
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset

439 

161  440 
procedure chAmmoMenu(var s: shortstring); 
441 
begin 

442 
if CheckNoTeamOrHH then exit; 

443 
with CurrentTeam^ do 

444 
with Hedgehogs[CurrHedgehog] do 

445 
begin 

162  446 
bSelected:= false; 
682  447 

161  448 
if bShowAmmoMenu then bShowAmmoMenu:= false 
351  449 
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) 
450 
or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true 

161  451 
end 
452 
end; 

453 

166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset

454 
procedure chFullScr(var s: shortstring); 
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset

455 
var flags: Longword; 
192  456 
{$IFDEF DEBUGFILE} 
457 
buf: array[byte] of char; 

458 
{$ENDIF} 

166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset

459 
begin 
1051
dfdd5dfe97d4
Enable fullscreen switching back, now it's bound on F12
unc0rr
parents:
1035
diff
changeset

460 
if Length(s) = 0 then cFullScreen:= not cFullScreen 
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset

461 
else cFullScreen:= s = '1'; 
192  462 

905  463 
{$IFDEF DEBUGFILE} 
464 
AddFileLog('Prepare to change video parameters...'); 

465 
{$ENDIF} 

753  466 
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); 
467 

1127  468 
flags:= SDL_OPENGL;// or SDL_RESIZABLE; 
1121
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset

469 
if cFullScreen then 
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset

470 
begin 
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset

471 
flags:= flags or SDL_FULLSCREEN; 
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset

472 
cScreenWidth:= cInitWidth; 
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset

473 
cScreenHeight:= cInitHeight 
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset

474 
end 
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset

475 
else SDL_WM_SetCaption('Hedgewars', nil); 
905  476 
{$IFDEF DEBUGFILE} 
477 
AddFileLog('Freeing old primary surface...'); 

478 
{$ENDIF} 

166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset

479 
SDL_FreeSurface(SDLPrimSurface); 
904  480 

166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset

481 
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); 
904  482 
SDLTry(SDLPrimSurface <> nil, true); 
192  483 

905  484 
{$IFDEF DEBUGFILE} 
485 
AddFileLog('Setting up OpenGL...'); 

486 
{$ENDIF} 

753  487 
SetupOpenGL(); 
488 

192  489 
{$IFDEF DEBUGFILE} 
490 
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); 

491 
{$ENDIF} 

351  492 
PixelFormat:= SDLPrimSurface^.format 
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset

493 
end; 
161  494 

175  495 
procedure chVol_p(var s: shortstring); 
174  496 
begin 
175  497 
inc(cVolumeDelta, 3) 
174  498 
end; 
499 

175  500 
procedure chVol_m(var s: shortstring); 
174  501 
begin 
175  502 
dec(cVolumeDelta, 3) 
174  503 
end; 
504 

176  505 
procedure chFindhh(var s: shortstring); 
506 
begin 

507 
if CheckNoTeamOrHH then exit; 

508 
bShowFinger:= true; 

602  509 
FollowGear:= CurrentHedgehog^.Gear 
176  510 
end; 
511 

281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset

512 
procedure chPause(var s: shortstring); 
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset

513 
begin 
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset

514 
isPaused:= not isPaused; 
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset

515 
SDL_ShowCursor(ord(isPaused)) 
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset

516 
end; 
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset

517 

6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset

518 
procedure chRotateMask(var s: shortstring); 
691  519 
const map: array[0..7] of byte = (7,4,0,1,2,3,0,5); 
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset

520 
begin 
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset

521 
cTagsMask:= map[cTagsMask] 
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset

522 
end; 
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset

523 

589  524 
procedure chAddTrigger(var s: shortstring); 
615  525 
const MAXPARAMS = 16; 
526 
var params: array[0..Pred(MAXPARAMS)] of Longword; 

527 
i: LongInt; 

595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset

528 
c: char; 
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset

529 
tmp: shortstring; 
589  530 
begin 
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset

531 
c:= s[1]; 
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset

532 
Delete(s, 1, 1); 
615  533 

534 
i:= 0; 

535 
while (i < MAXPARAMS) and 

536 
(Length(s) > 0) do 

537 
begin 

538 
SplitBySpace(s, tmp); 

539 
val(s, params[i]); 

540 
s:= tmp; 

541 
inc(i) 

542 
end; 

543 

595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset

544 
case c of 
613  545 
's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER 
615  546 
TryDo(i = 7, errmsgWrongNumber, true); 
547 
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

548 
end; 
613  549 
'C': begin 
615  550 
TryDo(i = 3, errmsgWrongNumber, true); 
551 
AddTriggerSuccess(params[0], params[1], params[2]); 

552 
end; 

553 
'F': begin 

554 
TryDo(i = 3, errmsgWrongNumber, true); 

555 
AddTriggerFail(params[0], params[1], params[2]); 

613  556 
end; 
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset

557 
end 
589  558 
end; 
626  559 

560 
procedure chSpeedup_p(var s: shortstring); 

561 
begin 

562 
isSpeed:= true 

563 
end; 

564 

565 
procedure chSpeedup_m(var s: shortstring); 

566 
begin 

567 
isSpeed:= false 

568 
end; 

946  569 

570 
procedure chChat(var s: shortstring); 

571 
begin 

990
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset

572 
GameState:= gsChat; 
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset

573 
KeyPressChat(27) 
946  574 
end; 
991  575 

576 
procedure chHistory(var s: shortstring); 

577 
begin 

578 
uChat.showAll:= not uChat.showAll 

579 
end; 