author | koda |
Mon, 01 Jun 2015 14:39:25 +0200 | |
branch | 0.9.20 |
changeset 9934 | 57f9ce8b2854 |
parent 9797 | 1fdc1507e42d |
child 9902 | eb8e8b09b2f0 |
permissions | -rw-r--r-- |
4976 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
9080 | 3 |
* Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> |
4976 | 4 |
* |
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 |
|
8 |
* |
|
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. |
|
13 |
* |
|
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 |
|
17 |
*) |
|
18 |
||
4413 | 19 |
{$INCLUDE "options.inc"} |
4976 | 20 |
|
4413 | 21 |
unit uCommandHandlers; |
22 |
||
23 |
interface |
|
24 |
||
25 |
procedure initModule; |
|
26 |
procedure freeModule; |
|
27 |
||
28 |
implementation |
|
7629 | 29 |
uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uRandom, uCaptions |
30 |
{$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF}; |
|
4413 | 31 |
|
7028 | 32 |
var prevGState: TGameState = gsConfirm; |
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8025
diff
changeset
|
33 |
cTagsMasks : array[0..15] of byte = (7, 0, 0, 0, 15, 6, 4, 5, 0, 0, 0, 0, 0, 14, 12, 13); |
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8025
diff
changeset
|
34 |
cTagsMasksNoHealth: array[0..15] of byte = (3, 2, 11, 1, 0, 0, 0, 0, 0, 10, 0, 9, 0, 0, 0, 0); |
7028 | 35 |
|
4531
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
36 |
procedure chGenCmd(var s: shortstring); |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
37 |
begin |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
38 |
case s[1] of |
8924 | 39 |
'R': if ReadyTimeLeft > 1 then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
40 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
41 |
ReadyTimeLeft:= 1; |
7805 | 42 |
if not isExternalSource then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
43 |
SendIPC('c'+s); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
44 |
end |
4531
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
45 |
end |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
46 |
end; |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
47 |
|
4413 | 48 |
procedure chQuit(var s: shortstring); |
49 |
begin |
|
4751 | 50 |
s:= s; // avoid compiler hint |
5555
38e3d9347910
Don't switch to gsConfirm state (which is pretty same as gsGame) when not in gsGame or gsChat state. Prevents crashes and other possible kinds of wierd behaviour.
unc0rr
parents:
5524
diff
changeset
|
51 |
if (GameState = gsGame) or (GameState = gsChat) then |
38e3d9347910
Don't switch to gsConfirm state (which is pretty same as gsGame) when not in gsGame or gsChat state. Prevents crashes and other possible kinds of wierd behaviour.
unc0rr
parents:
5524
diff
changeset
|
52 |
begin |
4413 | 53 |
prevGState:= GameState; |
5523 | 54 |
GameState:= gsConfirm; |
55 |
SDL_ShowCursor(1) |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
56 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
57 |
else |
5555
38e3d9347910
Don't switch to gsConfirm state (which is pretty same as gsGame) when not in gsGame or gsChat state. Prevents crashes and other possible kinds of wierd behaviour.
unc0rr
parents:
5524
diff
changeset
|
58 |
if GameState = gsConfirm then |
38e3d9347910
Don't switch to gsConfirm state (which is pretty same as gsGame) when not in gsGame or gsChat state. Prevents crashes and other possible kinds of wierd behaviour.
unc0rr
parents:
5524
diff
changeset
|
59 |
begin |
38e3d9347910
Don't switch to gsConfirm state (which is pretty same as gsGame) when not in gsGame or gsChat state. Prevents crashes and other possible kinds of wierd behaviour.
unc0rr
parents:
5524
diff
changeset
|
60 |
GameState:= prevGState; |
38e3d9347910
Don't switch to gsConfirm state (which is pretty same as gsGame) when not in gsGame or gsChat state. Prevents crashes and other possible kinds of wierd behaviour.
unc0rr
parents:
5524
diff
changeset
|
61 |
SDL_ShowCursor(ord(isPaused)) |
38e3d9347910
Don't switch to gsConfirm state (which is pretty same as gsGame) when not in gsGame or gsChat state. Prevents crashes and other possible kinds of wierd behaviour.
unc0rr
parents:
5524
diff
changeset
|
62 |
end |
4413 | 63 |
end; |
64 |
||
4744
ecc2c757d0df
general uKey refactor in preparaiton of two new shortcuts
koda
parents:
4661
diff
changeset
|
65 |
procedure chForceQuit(var s: shortstring); |
ecc2c757d0df
general uKey refactor in preparaiton of two new shortcuts
koda
parents:
4661
diff
changeset
|
66 |
begin |
ecc2c757d0df
general uKey refactor in preparaiton of two new shortcuts
koda
parents:
4661
diff
changeset
|
67 |
s:= s; // avoid compiler hint |
4751 | 68 |
GameState:= gsConfirm; |
69 |
ParseCommand('confirm', true); |
|
4413 | 70 |
end; |
71 |
||
72 |
procedure chConfirm(var s: shortstring); |
|
73 |
begin |
|
4751 | 74 |
s:= s; // avoid compiler hint |
75 |
if GameState = gsConfirm then |
|
7722 | 76 |
begin |
7068 | 77 |
SendIPC(_S'Q'); |
4751 | 78 |
GameState:= gsExit |
7722 | 79 |
end |
80 |
else |
|
81 |
ParseCommand('chat team', true); |
|
4413 | 82 |
end; |
83 |
||
4751 | 84 |
procedure chHalt (var s: shortstring); |
4746
3ae448aebe7e
implemented actions for closing/enging program (needs testing over the net)
koda
parents:
4744
diff
changeset
|
85 |
begin |
3ae448aebe7e
implemented actions for closing/enging program (needs testing over the net)
koda
parents:
4744
diff
changeset
|
86 |
s:= s; // avoid compiler hint |
7068 | 87 |
SendIPC(_S'H'); |
4746
3ae448aebe7e
implemented actions for closing/enging program (needs testing over the net)
koda
parents:
4744
diff
changeset
|
88 |
GameState:= gsExit |
3ae448aebe7e
implemented actions for closing/enging program (needs testing over the net)
koda
parents:
4744
diff
changeset
|
89 |
end; |
3ae448aebe7e
implemented actions for closing/enging program (needs testing over the net)
koda
parents:
4744
diff
changeset
|
90 |
|
4413 | 91 |
procedure chCheckProto(var s: shortstring); |
8370 | 92 |
var i: LongInt; |
4413 | 93 |
begin |
6001 | 94 |
if isDeveloperMode then |
95 |
begin |
|
8370 | 96 |
i:= StrToInt(s); |
6001 | 97 |
TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true); |
98 |
TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true); |
|
7058 | 99 |
end |
4413 | 100 |
end; |
101 |
||
102 |
procedure chTeamLocal(var s: shortstring); |
|
103 |
begin |
|
104 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
105 |
if not isDeveloperMode then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
106 |
exit; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
107 |
if CurrentTeam = nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
108 |
OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
4413 | 109 |
CurrentTeam^.ExtDriven:= true |
110 |
end; |
|
111 |
||
112 |
procedure chScript(var s: shortstring); |
|
113 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
114 |
if s[1]='"' then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
115 |
Delete(s, 1, 1); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
116 |
if s[byte(s[0])]='"' then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
117 |
Delete(s, byte(s[0]), 1); |
6254
e90fb60cb46d
Force a desync if there is a script name mismatch. This avoids playing until the game desyncs due to script differences.
nemo
parents:
6245
diff
changeset
|
118 |
cScriptName:= s; |
4413 | 119 |
ScriptLoad(s) |
120 |
end; |
|
121 |
||
122 |
procedure chCurU_p(var s: shortstring); |
|
123 |
begin |
|
124 |
s:= s; // avoid compiler hint |
|
125 |
CursorMovementY:= -1; |
|
126 |
end; |
|
127 |
||
128 |
procedure chCurU_m(var s: shortstring); |
|
129 |
begin |
|
130 |
s:= s; // avoid compiler hint |
|
131 |
CursorMovementY:= 0; |
|
132 |
end; |
|
133 |
||
134 |
procedure chCurD_p(var s: shortstring); |
|
135 |
begin |
|
136 |
s:= s; // avoid compiler hint |
|
137 |
CursorMovementY:= 1; |
|
138 |
end; |
|
139 |
||
140 |
procedure chCurD_m(var s: shortstring); |
|
141 |
begin |
|
142 |
s:= s; // avoid compiler hint |
|
143 |
CursorMovementY:= 0; |
|
144 |
end; |
|
145 |
||
146 |
procedure chCurL_p(var s: shortstring); |
|
147 |
begin |
|
148 |
s:= s; // avoid compiler hint |
|
149 |
CursorMovementX:= -1; |
|
150 |
end; |
|
151 |
||
152 |
procedure chCurL_m(var s: shortstring); |
|
153 |
begin |
|
154 |
s:= s; // avoid compiler hint |
|
155 |
CursorMovementX:= 0; |
|
156 |
end; |
|
157 |
||
158 |
procedure chCurR_p(var s: shortstring); |
|
159 |
begin |
|
160 |
s:= s; // avoid compiler hint |
|
161 |
CursorMovementX:= 1; |
|
162 |
end; |
|
163 |
||
164 |
procedure chCurR_m(var s: shortstring); |
|
165 |
begin |
|
166 |
s:= s; // avoid compiler hint |
|
167 |
CursorMovementX:= 0; |
|
168 |
end; |
|
169 |
||
170 |
procedure chLeft_p(var s: shortstring); |
|
171 |
begin |
|
172 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
173 |
if CheckNoTeamOrHH or isPaused then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
174 |
exit; |
7805 | 175 |
if not isExternalSource then |
7068 | 176 |
SendIPC(_S'L'); |
4413 | 177 |
bShowFinger:= false; |
178 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
179 |
Message:= Message or (gmLeft and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
180 |
ScriptCall('onLeft'); |
4413 | 181 |
end; |
182 |
||
183 |
procedure chLeft_m(var s: shortstring); |
|
184 |
begin |
|
185 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
186 |
if CheckNoTeamOrHH then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
187 |
exit; |
7805 | 188 |
if not isExternalSource then |
7068 | 189 |
SendIPC(_S'l'); |
4413 | 190 |
with CurrentHedgehog^.Gear^ do |
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6415
diff
changeset
|
191 |
Message:= Message and (not (gmLeft and InputMask)); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
192 |
ScriptCall('onLeftUp'); |
4413 | 193 |
end; |
194 |
||
195 |
procedure chRight_p(var s: shortstring); |
|
196 |
begin |
|
197 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
198 |
if CheckNoTeamOrHH or isPaused then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
199 |
exit; |
7805 | 200 |
if not isExternalSource then |
7068 | 201 |
SendIPC(_S'R'); |
4413 | 202 |
bShowFinger:= false; |
203 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
204 |
Message:= Message or (gmRight and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
205 |
ScriptCall('onRight'); |
4413 | 206 |
end; |
207 |
||
208 |
procedure chRight_m(var s: shortstring); |
|
209 |
begin |
|
210 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
211 |
if CheckNoTeamOrHH then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
212 |
exit; |
7805 | 213 |
if not isExternalSource then |
7068 | 214 |
SendIPC(_S'r'); |
4413 | 215 |
with CurrentHedgehog^.Gear^ do |
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6415
diff
changeset
|
216 |
Message:= Message and (not (gmRight and InputMask)); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
217 |
ScriptCall('onRightUp'); |
4413 | 218 |
end; |
219 |
||
220 |
procedure chUp_p(var s: shortstring); |
|
221 |
begin |
|
222 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
223 |
if CheckNoTeamOrHH or isPaused then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
224 |
exit; |
7805 | 225 |
if not isExternalSource then |
7068 | 226 |
SendIPC(_S'U'); |
4413 | 227 |
bShowFinger:= false; |
228 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
229 |
Message:= Message or (gmUp and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
230 |
ScriptCall('onUp'); |
4413 | 231 |
end; |
232 |
||
233 |
procedure chUp_m(var s: shortstring); |
|
234 |
begin |
|
235 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
236 |
if CheckNoTeamOrHH then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
237 |
exit; |
7805 | 238 |
if not isExternalSource then |
7068 | 239 |
SendIPC(_S'u'); |
4413 | 240 |
with CurrentHedgehog^.Gear^ do |
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6415
diff
changeset
|
241 |
Message:= Message and (not (gmUp and InputMask)); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
242 |
ScriptCall('onUpUp'); |
4413 | 243 |
end; |
244 |
||
245 |
procedure chDown_p(var s: shortstring); |
|
246 |
begin |
|
247 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
248 |
if CheckNoTeamOrHH or isPaused then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
249 |
exit; |
7805 | 250 |
if not isExternalSource then |
7068 | 251 |
SendIPC(_S'D'); |
4413 | 252 |
bShowFinger:= false; |
253 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
254 |
Message:= Message or (gmDown and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
255 |
ScriptCall('onDown'); |
4413 | 256 |
end; |
257 |
||
258 |
procedure chDown_m(var s: shortstring); |
|
259 |
begin |
|
260 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
261 |
if CheckNoTeamOrHH then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
262 |
exit; |
7805 | 263 |
if not isExternalSource then |
7068 | 264 |
SendIPC(_S'd'); |
4413 | 265 |
with CurrentHedgehog^.Gear^ do |
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6415
diff
changeset
|
266 |
Message:= Message and (not (gmDown and InputMask)); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
267 |
ScriptCall('onDownUp'); |
4413 | 268 |
end; |
269 |
||
270 |
procedure chPrecise_p(var s: shortstring); |
|
271 |
begin |
|
272 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
273 |
if CheckNoTeamOrHH or isPaused then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
274 |
exit; |
7805 | 275 |
if not isExternalSource then |
7068 | 276 |
SendIPC(_S'Z'); |
4413 | 277 |
bShowFinger:= false; |
278 |
with CurrentHedgehog^.Gear^ do |
|
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4437
diff
changeset
|
279 |
Message:= Message or (gmPrecise and InputMask); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
280 |
ScriptCall('onPrecise'); |
4413 | 281 |
end; |
282 |
||
283 |
procedure chPrecise_m(var s: shortstring); |
|
284 |
begin |
|
285 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
286 |
if CheckNoTeamOrHH then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
287 |
exit; |
7805 | 288 |
if not isExternalSource then |
7068 | 289 |
SendIPC(_S'z'); |
4413 | 290 |
with CurrentHedgehog^.Gear^ do |
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6415
diff
changeset
|
291 |
Message:= Message and (not (gmPrecise and InputMask)); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
292 |
ScriptCall('onPreciseUp'); |
4413 | 293 |
end; |
294 |
||
295 |
procedure chLJump(var s: shortstring); |
|
296 |
begin |
|
297 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
298 |
if CheckNoTeamOrHH or isPaused then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
299 |
exit; |
7805 | 300 |
if not isExternalSource then |
7068 | 301 |
SendIPC(_S'j'); |
4413 | 302 |
bShowFinger:= false; |
303 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
304 |
Message:= Message or (gmLJump and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
305 |
ScriptCall('onLJump'); |
4413 | 306 |
end; |
307 |
||
308 |
procedure chHJump(var s: shortstring); |
|
309 |
begin |
|
310 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
311 |
if CheckNoTeamOrHH or isPaused then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
312 |
exit; |
7805 | 313 |
if not isExternalSource then |
7068 | 314 |
SendIPC(_S'J'); |
4413 | 315 |
bShowFinger:= false; |
316 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
317 |
Message:= Message or (gmHJump and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
318 |
ScriptCall('onHJump'); |
4413 | 319 |
end; |
320 |
||
321 |
procedure chAttack_p(var s: shortstring); |
|
322 |
begin |
|
323 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
324 |
if CheckNoTeamOrHH or isPaused then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
325 |
exit; |
4413 | 326 |
bShowFinger:= false; |
327 |
with CurrentHedgehog^.Gear^ do |
|
328 |
begin |
|
4900 | 329 |
AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State)); |
4413 | 330 |
if ((State and gstHHDriven) <> 0) then |
331 |
begin |
|
332 |
FollowGear:= CurrentHedgehog^.Gear; |
|
7805 | 333 |
if not isExternalSource then |
7068 | 334 |
SendIPC(_S'A'); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
335 |
Message:= Message or (gmAttack and InputMask); |
5247 | 336 |
ScriptCall('onAttack'); |
4413 | 337 |
end |
338 |
end |
|
339 |
end; |
|
340 |
||
341 |
procedure chAttack_m(var s: shortstring); |
|
342 |
begin |
|
343 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
344 |
if CheckNoTeamOrHH then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
345 |
exit; |
4413 | 346 |
with CurrentHedgehog^.Gear^ do |
347 |
begin |
|
7805 | 348 |
if not isExternalSource and |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
349 |
((Message and gmAttack) <> 0) then |
7068 | 350 |
SendIPC(_S'a'); |
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6415
diff
changeset
|
351 |
Message:= Message and (not (gmAttack and InputMask)); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
352 |
ScriptCall('onAttackUp'); |
4413 | 353 |
end |
354 |
end; |
|
355 |
||
356 |
procedure chSwitch(var s: shortstring); |
|
357 |
begin |
|
358 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
359 |
if CheckNoTeamOrHH or isPaused then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
360 |
exit; |
7805 | 361 |
if not isExternalSource then |
7068 | 362 |
SendIPC(_S'S'); |
4413 | 363 |
bShowFinger:= false; |
364 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
365 |
Message:= Message or (gmSwitch and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
366 |
ScriptCall('onSwitch'); |
4413 | 367 |
end; |
368 |
||
369 |
procedure chNextTurn(var s: shortstring); |
|
7671 | 370 |
var gi: PGear; |
4413 | 371 |
begin |
372 |
s:= s; // avoid compiler hint |
|
7103 | 373 |
|
4413 | 374 |
TryDo(AllInactive, '/nextturn called when not all gears are inactive', true); |
375 |
||
7389
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7218
diff
changeset
|
376 |
CheckSum:= CheckSum xor GameTicks; |
7104 | 377 |
gi := GearsList; |
378 |
while gi <> nil do |
|
379 |
begin |
|
9797
1fdc1507e42d
remove state from check, just to see if this was why we just desynced
nemo
parents:
9796
diff
changeset
|
380 |
with gi^ do CheckSum:= CheckSum xor X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac; |
7389
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7218
diff
changeset
|
381 |
AddRandomness(CheckSum); |
7104 | 382 |
gi := gi^.NextGear |
383 |
end; |
|
7103 | 384 |
|
7805 | 385 |
if not isExternalSource then |
7103 | 386 |
begin |
387 |
s[0]:= #5; |
|
388 |
s[1]:= 'N'; |
|
7389
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7218
diff
changeset
|
389 |
SDLNet_Write32(CheckSum, @s[2]); |
7103 | 390 |
SendIPC(s) |
391 |
end |
|
392 |
else |
|
7831 | 393 |
TryDo(CurrentTeam^.hasGone or (CheckSum = lastTurnChecksum), 'Desync detected', true); |
394 |
||
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7151
diff
changeset
|
395 |
AddFileLog('Next turn: time '+inttostr(GameTicks)); |
4413 | 396 |
end; |
397 |
||
398 |
procedure chTimer(var s: shortstring); |
|
399 |
begin |
|
7790 | 400 |
if CheckNoTeamOrHH then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
401 |
exit; |
4413 | 402 |
|
7790 | 403 |
TryDo((s[0] = #1) and (s[1] >= '1') and (s[1] <= '5'), 'Malformed /timer', true); |
404 |
||
7805 | 405 |
if not isExternalSource then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
406 |
SendIPC(s); |
4413 | 407 |
bShowFinger:= false; |
408 |
with CurrentHedgehog^.Gear^ do |
|
409 |
begin |
|
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4437
diff
changeset
|
410 |
Message:= Message or (gmTimer and InputMask); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
411 |
MsgParam:= byte(s[1]) - ord('0'); |
6818
136aa9c8c593
Add the parameters I missed the first time when I added these hooks.
mikade
parents:
6700
diff
changeset
|
412 |
ScriptCall('onTimer', MsgParam); |
4413 | 413 |
end |
414 |
end; |
|
415 |
||
416 |
procedure chSlot(var s: shortstring); |
|
417 |
var slot: LongWord; |
|
7068 | 418 |
ss: shortstring; |
4413 | 419 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
420 |
if (s[0] <> #1) or CheckNoTeamOrHH then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
421 |
exit; |
4413 | 422 |
slot:= byte(s[1]) - 49; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
423 |
if slot > cMaxSlotIndex then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
424 |
exit; |
7805 | 425 |
if not isExternalSource then |
7068 | 426 |
begin |
427 |
ss[0]:= #1; |
|
428 |
ss[1]:= char(byte(s[1]) + 79); |
|
429 |
SendIPC(ss); |
|
430 |
end; |
|
4413 | 431 |
bShowFinger:= false; |
432 |
with CurrentHedgehog^.Gear^ do |
|
433 |
begin |
|
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4437
diff
changeset
|
434 |
Message:= Message or (gmSlot and InputMask); |
8924 | 435 |
MsgParam:= slot; |
6818
136aa9c8c593
Add the parameters I missed the first time when I added these hooks.
mikade
parents:
6700
diff
changeset
|
436 |
ScriptCall('onSlot', MsgParam); |
4413 | 437 |
end |
438 |
end; |
|
439 |
||
440 |
procedure chSetWeapon(var s: shortstring); |
|
441 |
begin |
|
7790 | 442 |
if CheckNoTeamOrHH then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
443 |
exit; |
4413 | 444 |
|
7790 | 445 |
TryDo((s[0] = #1) and (s[1] <= char(High(TAmmoType))), 'Malformed /setweap', true); |
4413 | 446 |
|
7805 | 447 |
if not isExternalSource then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
448 |
SendIPC('w' + s); |
4413 | 449 |
|
450 |
with CurrentHedgehog^.Gear^ do |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
451 |
begin |
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4437
diff
changeset
|
452 |
Message:= Message or (gmWeapon and InputMask); |
4413 | 453 |
MsgParam:= byte(s[1]); |
6818
136aa9c8c593
Add the parameters I missed the first time when I added these hooks.
mikade
parents:
6700
diff
changeset
|
454 |
ScriptCall('onSetWeapon', MsgParam); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
455 |
end; |
4413 | 456 |
end; |
457 |
||
458 |
procedure chTaunt(var s: shortstring); |
|
459 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
460 |
if (s[0] <> #1) or CheckNoTeamOrHH then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
461 |
exit; |
4413 | 462 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
463 |
if TWave(s[1]) > High(TWave) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
464 |
exit; |
4413 | 465 |
|
7805 | 466 |
if not isExternalSource then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
467 |
SendIPC('t' + s); |
4413 | 468 |
|
469 |
with CurrentHedgehog^.Gear^ do |
|
470 |
begin |
|
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4437
diff
changeset
|
471 |
Message:= Message or (gmAnimate and InputMask); |
8924 | 472 |
MsgParam:= byte(s[1]) ; |
6818
136aa9c8c593
Add the parameters I missed the first time when I added these hooks.
mikade
parents:
6700
diff
changeset
|
473 |
ScriptCall('onTaunt', MsgParam); |
4413 | 474 |
end |
475 |
end; |
|
476 |
||
477 |
procedure chPut(var s: shortstring); |
|
478 |
begin |
|
479 |
s:= s; // avoid compiler hint |
|
480 |
doPut(0, 0, false); |
|
481 |
end; |
|
482 |
||
483 |
procedure chCapture(var s: shortstring); |
|
484 |
begin |
|
485 |
s:= s; // avoid compiler hint |
|
486 |
flagMakeCapture:= true |
|
487 |
end; |
|
488 |
||
7629 | 489 |
procedure chRecord(var s: shortstring); |
490 |
begin |
|
491 |
s:= s; // avoid compiler hint |
|
492 |
{$IFDEF USE_VIDEO_RECORDING} |
|
493 |
if flagPrerecording then |
|
494 |
StopPreRecording() |
|
495 |
else |
|
496 |
BeginPreRecording(); |
|
497 |
{$ENDIF} |
|
498 |
end; |
|
499 |
||
4413 | 500 |
procedure chSetMap(var s: shortstring); |
501 |
begin |
|
5679
505c6448069b
accidentally reverted this when reverting the rest of the override changes.
nemo
parents:
5555
diff
changeset
|
502 |
if isDeveloperMode then |
6088 | 503 |
begin |
6339 | 504 |
if s = '' then |
8025 | 505 |
cPathz[ptMapCurrent]:= s |
6339 | 506 |
else |
8025 | 507 |
cPathz[ptMapCurrent]:= cPathz[ptMaps] + '/' + s; |
6088 | 508 |
InitStepsFlags:= InitStepsFlags or cifMap |
509 |
end; |
|
6828
6a5d33bff0b0
At mikade's request. give scripting access to the map name prior to override.
nemo
parents:
6818
diff
changeset
|
510 |
cMapName:= s; |
6245 | 511 |
ScriptLoad('Maps/' + s + '/map.lua') |
4413 | 512 |
end; |
513 |
||
514 |
procedure chSetTheme(var s: shortstring); |
|
515 |
begin |
|
516 |
if isDeveloperMode then |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
517 |
begin |
8025 | 518 |
cPathz[ptCurrTheme]:= cPathz[ptThemes] + '/' + s; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
519 |
Theme:= s; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
520 |
InitStepsFlags:= InitStepsFlags or cifTheme |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
521 |
end |
4413 | 522 |
end; |
523 |
||
524 |
procedure chSetSeed(var s: shortstring); |
|
525 |
begin |
|
526 |
if isDeveloperMode then |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
527 |
begin |
8912 | 528 |
SetRandomSeed(s, true); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
529 |
cSeed:= s; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
530 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
531 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
532 |
end; |
4413 | 533 |
|
534 |
procedure chAmmoMenu(var s: shortstring); |
|
535 |
begin |
|
536 |
s:= s; // avoid compiler hint |
|
537 |
if CheckNoTeamOrHH then |
|
538 |
bShowAmmoMenu:= true |
|
539 |
else |
|
540 |
begin |
|
541 |
with CurrentTeam^ do |
|
542 |
with Hedgehogs[CurrHedgehog] do |
|
543 |
begin |
|
544 |
bSelected:= false; |
|
545 |
||
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
546 |
if bShowAmmoMenu then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
547 |
bShowAmmoMenu:= false |
7946
a99a79bbd857
Simplify ammo menu conditions so it shows up in more states. Should fix issue #465. The part w/ sliding in uworld is main #465 problem.
nemo
parents:
7831
diff
changeset
|
548 |
else if not(CurrentTeam^.Extdriven) and (((Gear^.State and (gstAttacking or gstAttacked)) <> 0) |
a99a79bbd857
Simplify ammo menu conditions so it shows up in more states. Should fix issue #465. The part w/ sliding in uworld is main #465 problem.
nemo
parents:
7831
diff
changeset
|
549 |
or ((Gear^.State and gstHHDriven) = 0)) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
550 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
551 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
552 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
553 |
bShowAmmoMenu:= true |
4413 | 554 |
end; |
555 |
end |
|
556 |
end; |
|
557 |
||
558 |
procedure chVol_p(var s: shortstring); |
|
559 |
begin |
|
560 |
s:= s; // avoid compiler hint |
|
561 |
inc(cVolumeDelta, 3) |
|
562 |
end; |
|
563 |
||
564 |
procedure chVol_m(var s: shortstring); |
|
565 |
begin |
|
566 |
s:= s; // avoid compiler hint |
|
567 |
dec(cVolumeDelta, 3) |
|
568 |
end; |
|
569 |
||
570 |
procedure chFindhh(var s: shortstring); |
|
571 |
begin |
|
572 |
s:= s; // avoid compiler hint |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
573 |
if CheckNoTeamOrHH or isPaused then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
574 |
exit; |
5247 | 575 |
|
7629 | 576 |
if autoCameraOn then |
5247 | 577 |
begin |
7629 | 578 |
FollowGear:= nil; |
5247 | 579 |
AddCaption('Auto Camera Off', $CCCCCC, capgrpVolume); |
580 |
autoCameraOn:= false |
|
581 |
end |
|
7629 | 582 |
else |
583 |
begin |
|
5247 | 584 |
AddCaption('Auto Camera On', $CCCCCC, capgrpVolume); |
585 |
bShowFinger:= true; |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
586 |
if not CurrentHedgehog^.Unplaced then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
587 |
FollowGear:= CurrentHedgehog^.Gear; |
5247 | 588 |
autoCameraOn:= true |
589 |
end |
|
4413 | 590 |
end; |
591 |
||
592 |
procedure chPause(var s: shortstring); |
|
593 |
begin |
|
594 |
s:= s; // avoid compiler hint |
|
595 |
if gameType <> gmtNet then |
|
9670
1954f692e8c6
Quick and simple implementation of afk mode (toggled by /pause)
unc0rr
parents:
9489
diff
changeset
|
596 |
isPaused:= not isPaused |
1954f692e8c6
Quick and simple implementation of afk mode (toggled by /pause)
unc0rr
parents:
9489
diff
changeset
|
597 |
else |
9671 | 598 |
if (CurrentTeam^.ExtDriven) or (CurrentHedgehog^.BotLevel > 0) then |
599 |
isAFK:= not isAFK |
|
600 |
else |
|
601 |
isAFK:= false; // for real ninjas |
|
5524
40b7f95d9f18
Oh, and fix cursor visibility correlations between gsConfirm state and paused state
unc0rr
parents:
5523
diff
changeset
|
602 |
|
9670
1954f692e8c6
Quick and simple implementation of afk mode (toggled by /pause)
unc0rr
parents:
9489
diff
changeset
|
603 |
if isPaused or isAFK then |
5524
40b7f95d9f18
Oh, and fix cursor visibility correlations between gsConfirm state and paused state
unc0rr
parents:
5523
diff
changeset
|
604 |
SDL_ShowCursor(1) |
40b7f95d9f18
Oh, and fix cursor visibility correlations between gsConfirm state and paused state
unc0rr
parents:
5523
diff
changeset
|
605 |
else |
40b7f95d9f18
Oh, and fix cursor visibility correlations between gsConfirm state and paused state
unc0rr
parents:
5523
diff
changeset
|
606 |
SDL_ShowCursor(ord(GameState = gsConfirm)) |
4413 | 607 |
end; |
608 |
||
609 |
procedure chRotateMask(var s: shortstring); |
|
610 |
begin |
|
611 |
s:= s; // avoid compiler hint |
|
9693 | 612 |
// this is just for me, 'cause I thought it'd be fun. using the old precise + switch to keep it out of people's way |
613 |
if LocalMessage and (gmPrecise or gmSwitch) = (gmPrecise or gmSwitch) then |
|
614 |
begin |
|
615 |
if UIDisplay <> uiNone then |
|
616 |
UIDisplay:= uiNone |
|
617 |
else UIDisplay:= uiAll |
|
618 |
end |
|
619 |
else if LocalMessage and gmPrecise = gmPrecise then |
|
620 |
begin |
|
621 |
if ((GameFlags and gfInvulnerable) = 0) then |
|
622 |
cTagsMask:= cTagsMasks[cTagsMask] |
|
623 |
else |
|
624 |
cTagsMask:= cTagsMasksNoHealth[cTagsMask] |
|
625 |
end |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6453
diff
changeset
|
626 |
else |
9693 | 627 |
begin |
628 |
if UIDisplay <> uiNoTeams then |
|
629 |
UIDisplay:= uiNoTeams |
|
630 |
else UIDisplay:= uiAll |
|
631 |
end |
|
4413 | 632 |
end; |
633 |
||
634 |
procedure chSpeedup_p(var s: shortstring); |
|
635 |
begin |
|
636 |
s:= s; // avoid compiler hint |
|
7629 | 637 |
SpeedStart:= RealTicks; |
4413 | 638 |
isSpeed:= true |
639 |
end; |
|
640 |
||
641 |
procedure chSpeedup_m(var s: shortstring); |
|
642 |
begin |
|
643 |
s:= s; // avoid compiler hint |
|
644 |
isSpeed:= false |
|
645 |
end; |
|
646 |
||
647 |
procedure chZoomIn(var s: shortstring); |
|
648 |
begin |
|
649 |
s:= s; // avoid compiler hint |
|
650 |
if ZoomValue < cMinZoomLevel then |
|
651 |
ZoomValue:= ZoomValue + cZoomDelta; |
|
652 |
end; |
|
653 |
||
654 |
procedure chZoomOut(var s: shortstring); |
|
655 |
begin |
|
656 |
s:= s; // avoid compiler hint |
|
657 |
if ZoomValue > cMaxZoomLevel then |
|
658 |
ZoomValue:= ZoomValue - cZoomDelta; |
|
659 |
end; |
|
660 |
||
661 |
procedure chZoomReset(var s: shortstring); |
|
662 |
begin |
|
663 |
s:= s; // avoid compiler hint |
|
664 |
ZoomValue:= cDefaultZoomLevel; |
|
665 |
end; |
|
666 |
||
6898 | 667 |
procedure chMapGen(var s: shortstring); |
668 |
begin |
|
7151 | 669 |
cMapGen:= StrToInt(s) |
6898 | 670 |
end; |
671 |
||
672 |
procedure chTemplateFilter(var s: shortstring); |
|
673 |
begin |
|
7151 | 674 |
cTemplateFilter:= StrToInt(s) |
6898 | 675 |
end; |
676 |
||
677 |
procedure chInactDelay(var s: shortstring); |
|
678 |
begin |
|
7151 | 679 |
cInactDelay:= StrToInt(s) |
6898 | 680 |
end; |
681 |
||
682 |
procedure chReadyDelay(var s: shortstring); |
|
683 |
begin |
|
7151 | 684 |
cReadyDelay:= StrToInt(s) |
6898 | 685 |
end; |
686 |
||
687 |
procedure chCaseFactor(var s: shortstring); |
|
688 |
begin |
|
7151 | 689 |
cCaseFactor:= StrToInt(s) |
6898 | 690 |
end; |
691 |
||
692 |
procedure chHealthCaseProb(var s: shortstring); |
|
693 |
begin |
|
7151 | 694 |
cHealthCaseProb:= StrToInt(s) |
6898 | 695 |
end; |
696 |
||
697 |
procedure chHealthCaseAmount(var s: shortstring); |
|
698 |
begin |
|
7151 | 699 |
cHealthCaseAmount:= StrToInt(s) |
6898 | 700 |
end; |
701 |
||
702 |
procedure chSuddenDTurns(var s: shortstring); |
|
703 |
begin |
|
7151 | 704 |
cSuddenDTurns:= StrToInt(s) |
6898 | 705 |
end; |
706 |
||
707 |
procedure chWaterRise(var s: shortstring); |
|
708 |
begin |
|
7151 | 709 |
cWaterRise:= StrToInt(s) |
6898 | 710 |
end; |
711 |
||
712 |
procedure chHealthDecrease(var s: shortstring); |
|
713 |
begin |
|
7151 | 714 |
cHealthDecrease:= StrToInt(s) |
6898 | 715 |
end; |
716 |
||
717 |
procedure chDamagePercent(var s: shortstring); |
|
718 |
begin |
|
7151 | 719 |
cDamagePercent:= StrToInt(s) |
6898 | 720 |
end; |
721 |
||
722 |
procedure chRopePercent(var s: shortstring); |
|
723 |
begin |
|
7151 | 724 |
cRopePercent:= StrToInt(s) |
6898 | 725 |
end; |
726 |
||
727 |
procedure chGetAwayTime(var s: shortstring); |
|
728 |
begin |
|
7151 | 729 |
cGetAwayTime:= StrToInt(s) |
6898 | 730 |
end; |
731 |
||
732 |
procedure chMineDudPercent(var s: shortstring); |
|
733 |
begin |
|
7151 | 734 |
cMineDudPercent:= StrToInt(s) |
6898 | 735 |
end; |
736 |
||
737 |
procedure chLandMines(var s: shortstring); |
|
738 |
begin |
|
7151 | 739 |
cLandMines:= StrToInt(s) |
6898 | 740 |
end; |
741 |
||
742 |
procedure chExplosives(var s: shortstring); |
|
743 |
begin |
|
7151 | 744 |
cExplosives:= StrToInt(s) |
6898 | 745 |
end; |
746 |
||
747 |
procedure chGameFlags(var s: shortstring); |
|
748 |
begin |
|
7218
9ecd5bc9810b
Ensure that Clan ammo always takes precedence over Per Hog Ammo in the flags. It'd be best for the user sake if these buttons acted more like radio buttons.
nemo
parents:
7187
diff
changeset
|
749 |
GameFlags:= StrToInt(s); |
7629 | 750 |
if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and (not gfPerHogAmmo) |
6898 | 751 |
end; |
752 |
||
753 |
procedure chHedgehogTurnTime(var s: shortstring); |
|
754 |
begin |
|
7151 | 755 |
cHedgehogTurnTime:= StrToInt(s) |
6898 | 756 |
end; |
757 |
||
758 |
procedure chMinesTime(var s: shortstring); |
|
759 |
begin |
|
7151 | 760 |
cMinesTime:= StrToInt(s) |
6898 | 761 |
end; |
762 |
||
763 |
procedure chFastUntilLag(var s: shortstring); |
|
764 |
begin |
|
7151 | 765 |
fastUntilLag:= StrToInt(s) <> 0 |
6898 | 766 |
end; |
4413 | 767 |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7187
diff
changeset
|
768 |
procedure chCampVar(var s:shortstring); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7187
diff
changeset
|
769 |
begin |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7187
diff
changeset
|
770 |
CampaignVariable := s; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7187
diff
changeset
|
771 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7187
diff
changeset
|
772 |
|
9489 | 773 |
procedure chWorldEdge(var s: shortstring); |
774 |
begin |
|
775 |
WorldEdge:= TWorldEdge(StrToInt(s)) |
|
776 |
end; |
|
777 |
||
4413 | 778 |
procedure initModule; |
779 |
begin |
|
4528
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
780 |
//////// Begin top sorted by freq analysis not including chatmsg |
7407 | 781 |
RegisterVariable('+right' , @chRight_p , false, true); |
782 |
RegisterVariable('-right' , @chRight_m , false, true); |
|
783 |
RegisterVariable('+up' , @chUp_p , false, true); |
|
784 |
RegisterVariable('-up' , @chUp_m , false, true); |
|
785 |
RegisterVariable('+left' , @chLeft_p , false, true); |
|
786 |
RegisterVariable('-left' , @chLeft_m , false, true); |
|
7629 | 787 |
RegisterVariable('+attack' , @chAttack_p , false); |
7407 | 788 |
RegisterVariable('+down' , @chDown_p , false, true); |
789 |
RegisterVariable('-down' , @chDown_m , false, true); |
|
790 |
RegisterVariable('hjump' , @chHJump , false, true); |
|
791 |
RegisterVariable('ljump' , @chLJump , false, true); |
|
7629 | 792 |
RegisterVariable('nextturn', @chNextTurn , false); |
793 |
RegisterVariable('-attack' , @chAttack_m , false); |
|
794 |
RegisterVariable('slot' , @chSlot , false); |
|
7407 | 795 |
RegisterVariable('setweap' , @chSetWeapon , false, true); |
4528
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
796 |
//////// End top by freq analysis |
7629 | 797 |
RegisterVariable('gencmd' , @chGenCmd , false); |
6898 | 798 |
RegisterVariable('script' , @chScript , false); |
799 |
RegisterVariable('proto' , @chCheckProto , true ); |
|
800 |
RegisterVariable('spectate', @chFastUntilLag , false); |
|
801 |
RegisterVariable('capture' , @chCapture , true ); |
|
802 |
RegisterVariable('rotmask' , @chRotateMask , true ); |
|
803 |
RegisterVariable('rdriven' , @chTeamLocal , false); |
|
804 |
RegisterVariable('map' , @chSetMap , false); |
|
805 |
RegisterVariable('theme' , @chSetTheme , false); |
|
806 |
RegisterVariable('seed' , @chSetSeed , false); |
|
807 |
RegisterVariable('template_filter', @chTemplateFilter, false); |
|
808 |
RegisterVariable('mapgen' , @chMapGen , false); |
|
809 |
RegisterVariable('maze_size',@chTemplateFilter, false); |
|
810 |
RegisterVariable('delay' , @chInactDelay , false); |
|
811 |
RegisterVariable('ready' , @chReadyDelay , false); |
|
812 |
RegisterVariable('casefreq', @chCaseFactor , false); |
|
813 |
RegisterVariable('healthprob', @chHealthCaseProb, false); |
|
814 |
RegisterVariable('hcaseamount', @chHealthCaseAmount, false); |
|
815 |
RegisterVariable('sd_turns', @chSuddenDTurns , false); |
|
816 |
RegisterVariable('waterrise', @chWaterRise , false); |
|
817 |
RegisterVariable('healthdec', @chHealthDecrease, false); |
|
818 |
RegisterVariable('damagepct',@chDamagePercent , false); |
|
819 |
RegisterVariable('ropepct' , @chRopePercent , false); |
|
820 |
RegisterVariable('getawaytime' , @chGetAwayTime , false); |
|
821 |
RegisterVariable('minedudpct',@chMineDudPercent, false); |
|
822 |
RegisterVariable('minesnum', @chLandMines , false); |
|
823 |
RegisterVariable('explosives',@chExplosives , false); |
|
824 |
RegisterVariable('gmflags' , @chGameFlags , false); |
|
825 |
RegisterVariable('turntime', @chHedgehogTurnTime, false); |
|
826 |
RegisterVariable('minestime',@chMinesTime , false); |
|
827 |
RegisterVariable('quit' , @chQuit , true ); |
|
828 |
RegisterVariable('forcequit', @chForceQuit , true ); |
|
829 |
RegisterVariable('confirm' , @chConfirm , true ); |
|
830 |
RegisterVariable('halt', @chHalt , true ); |
|
831 |
RegisterVariable('+speedup', @chSpeedup_p , true ); |
|
832 |
RegisterVariable('-speedup', @chSpeedup_m , true ); |
|
833 |
RegisterVariable('zoomin' , @chZoomIn , true ); |
|
834 |
RegisterVariable('zoomout' , @chZoomOut , true ); |
|
835 |
RegisterVariable('zoomreset',@chZoomReset , true ); |
|
836 |
RegisterVariable('ammomenu', @chAmmoMenu , true); |
|
7629 | 837 |
RegisterVariable('+precise', @chPrecise_p , false, true); |
838 |
RegisterVariable('-precise', @chPrecise_m , false, true); |
|
6898 | 839 |
RegisterVariable('switch' , @chSwitch , false); |
7629 | 840 |
RegisterVariable('timer' , @chTimer , false, true); |
6898 | 841 |
RegisterVariable('taunt' , @chTaunt , false); |
842 |
RegisterVariable('put' , @chPut , false); |
|
843 |
RegisterVariable('+volup' , @chVol_p , true ); |
|
844 |
RegisterVariable('-volup' , @chVol_m , true ); |
|
845 |
RegisterVariable('+voldown', @chVol_m , true ); |
|
846 |
RegisterVariable('-voldown', @chVol_p , true ); |
|
7404 | 847 |
RegisterVariable('findhh' , @chFindhh , true ); |
6898 | 848 |
RegisterVariable('pause' , @chPause , true ); |
849 |
RegisterVariable('+cur_u' , @chCurU_p , true ); |
|
850 |
RegisterVariable('-cur_u' , @chCurU_m , true ); |
|
851 |
RegisterVariable('+cur_d' , @chCurD_p , true ); |
|
852 |
RegisterVariable('-cur_d' , @chCurD_m , true ); |
|
853 |
RegisterVariable('+cur_l' , @chCurL_p , true ); |
|
854 |
RegisterVariable('-cur_l' , @chCurL_m , true ); |
|
855 |
RegisterVariable('+cur_r' , @chCurR_p , true ); |
|
856 |
RegisterVariable('-cur_r' , @chCurR_m , true ); |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7187
diff
changeset
|
857 |
RegisterVariable('campvar' , @chCampVar , true ); |
7629 | 858 |
RegisterVariable('record' , @chRecord , true ); |
9489 | 859 |
RegisterVariable('worldedge',@chWorldEdge , false); |
4413 | 860 |
end; |
861 |
||
862 |
procedure freeModule; |
|
863 |
begin |
|
864 |
end; |
|
865 |
||
866 |
end. |