Rev 881 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5 | Plagman | 1 | //------------------------------------------------------------------------- |
2 | /* |
||
484 | terminx | 3 | Copyright (C) 1996, 2003 - 3D Realms Entertainment |
4 | Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) |
||
5 | Copyright (C) 2004, 2007 - EDuke32 developers |
||
5 | Plagman | 6 | |
7 | This file is part of EDuke32 |
||
8 | |||
9 | EDuke32 is free software; you can redistribute it and/or |
||
10 | modify it under the terms of the GNU General Public License version 2 |
||
11 | as published by the Free Software Foundation. |
||
12 | |||
13 | This program is distributed in the hope that it will be useful, |
||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
16 | |||
17 | See the GNU General Public License for more details. |
||
18 | |||
19 | You should have received a copy of the GNU General Public License |
||
20 | along with this program; if not, write to the Free Software |
||
21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
22 | */ |
||
23 | //------------------------------------------------------------------------- |
||
24 | |||
25 | #include "duke3d.h" |
||
26 | #include "gamedef.h" |
||
27 | |||
28 | #include "osd.h" |
||
29 | |||
602 | terminx | 30 | int g_ScriptVersion = 13; // 13 = 1.3D-style CON files, 14 = 1.4/1.5 style CON files |
5 | Plagman | 31 | |
398 | terminx | 32 | char compilefile[BMAX_PATH] = "(none)"; // file we're currently compiling |
5 | Plagman | 33 | static char parsing_item_name[MAXVARLABEL] = "(none)", previous_item_name[MAXVARLABEL] = "NULL"; |
34 | |||
432 | terminx | 35 | int total_lines,line_number; |
36 | static int checking_ifelse,parsing_state; |
||
5 | Plagman | 37 | char g_szBuf[1024]; |
38 | |||
619 | terminx | 39 | intptr_t *casescriptptr=NULL; // the pointer to the start of the case table in a switch statement |
5 | Plagman | 40 | // first entry is 'default' code. |
432 | terminx | 41 | static int casecount = 0; |
42 | static int checking_switch = 0, current_event = -1; |
||
43 | static int labelsonly = 0, nokeywordcheck = 0, dynamicremap = 0; |
||
622 | terminx | 44 | static int num_braces = 0; |
5 | Plagman | 45 | |
874 | terminx | 46 | static int increasescriptsize(int size); |
47 | |||
92 | terminx | 48 | int redefined_quote_count = 0; |
5 | Plagman | 49 | |
794 | qbix79 | 50 | intptr_t *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine |
51 | intptr_t *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) |
||
52 | intptr_t *aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire |
||
53 | intptr_t *aplWeaponHoldDelay[MAX_WEAPONS]; // delay after release fire button to fire (0 for none) |
||
54 | intptr_t *aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire. |
||
55 | intptr_t *aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon |
||
56 | intptr_t *aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots |
||
57 | intptr_t *aplWeaponSpawnTime[MAX_WEAPONS]; // the frame at which to spawn an item |
||
58 | intptr_t *aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn |
||
59 | intptr_t *aplWeaponShotsPerBurst[MAX_WEAPONS]; // number of shots per 'burst' (one ammo per 'burst' |
||
60 | intptr_t *aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like |
||
61 | intptr_t *aplWeaponInitialSound[MAX_WEAPONS]; // Sound made when initialy firing. zero for no sound |
||
62 | intptr_t *aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each time for automatic) |
||
63 | intptr_t *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time |
||
64 | intptr_t *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID |
||
65 | intptr_t *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being removed |
||
66 | intptr_t *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted |
||
5 | Plagman | 67 | |
68 | int g_iReturnVarID=-1; // var ID of "RETURN" |
||
69 | int g_iWeaponVarID=-1; // var ID of "WEAPON" |
||
70 | int g_iWorksLikeVarID=-1; // var ID of "WORKSLIKE" |
||
71 | int g_iZRangeVarID=-1; // var ID of "ZRANGE" |
||
72 | int g_iAngRangeVarID=-1; // var ID of "ANGRANGE" |
||
73 | int g_iAimAngleVarID=-1; // var ID of "AUTOAIMANGLE" |
||
74 | int g_iLoTagID=-1; // var ID of "LOTAG" |
||
75 | int g_iHiTagID=-1; // var ID of "HITAG" |
||
76 | int g_iTextureID=-1; // var ID of "TEXTURE" |
||
77 | int g_iThisActorID=-1; // var ID of "THISACTOR" |
||
78 | |||
619 | terminx | 79 | intptr_t *actorLoadEventScrptr[MAXTILES]; |
5 | Plagman | 80 | |
619 | terminx | 81 | intptr_t *apScriptGameEvent[MAXGAMEEVENTS]; |
82 | intptr_t *parsing_event=NULL; |
||
5 | Plagman | 83 | |
580 | terminx | 84 | gamevar_t aGameVars[MAXGAMEVARS]; |
676 | terminx | 85 | gamearray_t aGameArrays[MAXGAMEARRAYS]; |
5 | Plagman | 86 | int iGameVarCount=0; |
676 | terminx | 87 | int iGameArrayCount=0; |
5 | Plagman | 88 | |
584 | terminx | 89 | extern int qsetmode; |
5 | Plagman | 90 | |
432 | terminx | 91 | char *textptr; |
92 | int error,warning; |
||
93 | |||
886 | terminx | 94 | extern char *duke3dgrpstring; |
95 | |||
335 | terminx | 96 | enum labeltypes |
97 | { |
||
255 | terminx | 98 | LABEL_ANY = -1, |
99 | LABEL_DEFINE = 1, |
||
100 | LABEL_STATE = 2, |
||
101 | LABEL_ACTOR = 4, |
||
102 | LABEL_ACTION = 8, |
||
103 | LABEL_AI = 16, |
||
104 | LABEL_MOVE = 32, |
||
5 | Plagman | 105 | }; |
106 | |||
437 | terminx | 107 | static const char *labeltypenames[] = |
559 | terminx | 108 | { |
109 | "define", |
||
110 | "state", |
||
111 | "actor", |
||
112 | "action", |
||
113 | "ai", |
||
114 | "move" |
||
115 | }; |
||
5 | Plagman | 116 | |
584 | terminx | 117 | static const char *translatelabeltype(int type) |
5 | Plagman | 118 | { |
119 | int i; |
||
120 | char x[64]; |
||
121 | |||
122 | x[0] = 0; |
||
335 | terminx | 123 | for (i=0;i<6;i++) |
124 | { |
||
5 | Plagman | 125 | if (!(type & (1<<i))) continue; |
126 | if (x[0]) Bstrcat(x, " or "); |
||
127 | Bstrcat(x, labeltypenames[i]); |
||
128 | } |
||
129 | return strdup(x); |
||
130 | } |
||
131 | |||
132 | #define NUMKEYWORDS (signed int)(sizeof(keyw)/sizeof(keyw[0])) |
||
133 | |||
484 | terminx | 134 | static const char *keyw[] = |
559 | terminx | 135 | { |
136 | "definelevelname", // 0 defines level name |
||
137 | "actor", // 1 defines an actor |
||
138 | "addammo", // 2 adds ammo to a weapon |
||
139 | "ifrnd", // 3 checks against a randomizer |
||
140 | "enda", // 4 ends an actor definition |
||
141 | "ifcansee", // 5 checks if the player can see an object |
||
142 | "ifhitweapon", // 6 checks if an object was hit by a weapon |
||
143 | "action", // 7 defines an action if used outside a state or actor, otherwise triggers actor to perform action |
||
144 | "ifpdistl", // 8 checks if player distance is less than value |
||
145 | "ifpdistg", // 9 checks if player distance is more than value |
||
146 | "else", // 10 used with if checks |
||
147 | "strength", // 11 sets health |
||
148 | "break", // 12 stops processing |
||
149 | "shoot", // 13 shoots a projectile |
||
150 | "palfrom", // 14 used for player screen shading effect, sets p->pals_time and p->pals[0-2] |
||
151 | "sound", // 15 plays a sound that was defined with definesound |
||
152 | "fall", // 16 causes actor to fall to sector floor height |
||
153 | "state", // 17 begins defining a state if used outside a state or actor, otherwise calls a state |
||
154 | "ends", // 18 ends defining a state |
||
155 | "define", // 19 defines a value |
||
156 | "<null>", // 20 was previously used to define a comment |
||
157 | "ifai", // 21 checks if actor is currently performing a specific ai function |
||
158 | "killit", // 22 kills an actor |
||
159 | "addweapon", // 23 adds a weapon to the closest player |
||
160 | "ai", // 24 sets an ai function to be used by an actor |
||
161 | "addphealth", // 25 adds health to the player |
||
162 | "ifdead", // 26 checks if actor is dead |
||
163 | "ifsquished", // 27 checks if actor has been squished |
||
164 | "sizeto", // 28 gradually increases actor size until it matches parameters given |
||
165 | "{", // 29 used to indicate segments of code |
||
166 | "}", // 30 used to indicate segments of code |
||
167 | "spawn", // 31 spawns an actor |
||
168 | "move", // 32 |
||
169 | "ifwasweapon", // 33 |
||
170 | "ifaction", // 34 |
||
171 | "ifactioncount", // 35 |
||
172 | "resetactioncount", // 36 |
||
173 | "debris", // 37 |
||
174 | "pstomp", // 38 |
||
175 | "<null>", // 39 was previously used to define the start of a comment block |
||
176 | "cstat", // 40 |
||
177 | "ifmove", // 41 |
||
178 | "resetplayer", // 42 |
||
179 | "ifonwater", // 43 |
||
180 | "ifinwater", // 44 |
||
181 | "ifcanshoottarget", // 45 |
||
182 | "ifcount", // 46 |
||
183 | "resetcount", // 47 |
||
184 | "addinventory", // 48 |
||
185 | "ifactornotstayput", // 49 |
||
186 | "hitradius", // 50 |
||
187 | "ifp", // 51 |
||
188 | "count", // 52 |
||
189 | "ifactor", // 53 |
||
190 | "music", // 54 |
||
191 | "include", // 55 |
||
192 | "ifstrength", // 56 |
||
193 | "definesound", // 57 |
||
194 | "guts", // 58 |
||
195 | "ifspawnedby", // 59 |
||
196 | "gamestartup", // 60 |
||
197 | "wackplayer", // 61 |
||
198 | "ifgapzl", // 62 |
||
199 | "ifhitspace", // 63 |
||
200 | "ifoutside", // 64 |
||
201 | "ifmultiplayer", // 65 |
||
202 | "operate", // 66 |
||
203 | "ifinspace", // 67 |
||
204 | "debug", // 68 |
||
205 | "endofgame", // 69 |
||
206 | "ifbulletnear", // 70 |
||
207 | "ifrespawn", // 71 |
||
208 | "iffloordistl", // 72 |
||
209 | "ifceilingdistl", // 73 |
||
210 | "spritepal", // 74 |
||
211 | "ifpinventory", // 75 |
||
212 | "betaname", // 76 |
||
213 | "cactor", // 77 |
||
214 | "ifphealthl", // 78 |
||
215 | "definequote", // 79 |
||
216 | "quote", // 80 |
||
217 | "ifinouterspace", // 81 |
||
218 | "ifnotmoving", // 82 |
||
219 | "respawnhitag", // 83 |
||
220 | "tip", // 84 |
||
221 | "ifspritepal", // 85 |
||
222 | "money", // 86 |
||
223 | "soundonce", // 87 |
||
224 | "addkills", // 88 |
||
225 | "stopsound", // 89 |
||
226 | "ifawayfromwall", // 90 |
||
227 | "ifcanseetarget", // 91 |
||
228 | "globalsound", // 92 |
||
229 | "lotsofglass", // 93 |
||
230 | "ifgotweaponce", // 94 |
||
231 | "getlastpal", // 95 |
||
232 | "pkick", // 96 |
||
233 | "mikesnd", // 97 |
||
234 | "useractor", // 98 |
||
235 | "sizeat", // 99 |
||
236 | "addstrength", // 100 [#] |
||
237 | "cstator", // 101 |
||
238 | "mail", // 102 |
||
239 | "paper", // 103 |
||
240 | "tossweapon", // 104 |
||
241 | "sleeptime", // 105 |
||
242 | "nullop", // 106 |
||
243 | "definevolumename", // 107 |
||
244 | "defineskillname", // 108 |
||
245 | "ifnosounds", // 109 |
||
246 | "clipdist", // 110 |
||
247 | "ifangdiffl", // 111 |
||
248 | "gamevar", // 112 |
||
249 | "ifvarl", // 113 |
||
250 | "ifvarg", // 114 |
||
251 | "setvarvar", // 115 |
||
252 | "setvar", // 116 |
||
253 | "addvarvar", // 117 |
||
254 | "addvar", // 118 |
||
255 | "ifvarvarl", // 119 |
||
256 | "ifvarvarg", // 120 |
||
257 | "addlogvar", // 121 |
||
258 | "addlog", // 122 |
||
259 | "onevent", // 123 |
||
260 | "endevent", // 124 |
||
261 | "ifvare", // 125 |
||
262 | "ifvarvare", // 126 |
||
263 | "spgetlotag", // 127 |
||
264 | "spgethitag", // 128 |
||
265 | "sectgetlotag", // 129 |
||
266 | "sectgethitag", // 130 |
||
267 | "ifsound", // 131 |
||
268 | "gettexturefloor", // 132 |
||
269 | "gettextureceiling", // 133 |
||
270 | "inittimer", // 134 |
||
271 | "starttrack", // 135 |
||
272 | "randvar", // 136 |
||
273 | "enhanced", // 137 |
||
274 | "getangletotarget", // 138 |
||
275 | "getactorangle", // 139 |
||
276 | "setactorangle", // 140 |
||
277 | "mulvar", // 141 |
||
278 | "mulvarvar", // 142 |
||
279 | "divvar", // 143 |
||
280 | "divvarvar", // 144 |
||
281 | "modvar", // 145 |
||
282 | "modvarvar", // 146 |
||
283 | "andvar", // 147 |
||
284 | "andvarvar", // 148 |
||
285 | "orvar", // 149 |
||
286 | "orvarvar", // 150 |
||
287 | "getplayerangle", // 151 |
||
288 | "setplayerangle", // 152 |
||
289 | "lockplayer", // 153 |
||
290 | "setsector", // 154 |
||
291 | "getsector", // 155 |
||
292 | "setactor", // 156 |
||
293 | "getactor", // 157 |
||
294 | "setwall", // 158 |
||
295 | "getwall", // 159 |
||
296 | "findnearactor", // 160 |
||
297 | "findnearactorvar", // 161 |
||
298 | "setactorvar", // 162 |
||
299 | "getactorvar", // 163 |
||
300 | "espawn", // 164 |
||
301 | "getplayer", // 165 |
||
302 | "setplayer", // 166 |
||
303 | "sqrt", // 167 |
||
304 | "eventloadactor", // 168 |
||
305 | "espawnvar", // 169 |
||
306 | "getuserdef", // 170 |
||
307 | "setuserdef", // 171 |
||
308 | "subvarvar", // 172 |
||
309 | "subvar", // 173 |
||
310 | "ifvarn", // 174 |
||
311 | "ifvarvarn", // 175 |
||
312 | "ifvarand", // 176 |
||
313 | "ifvarvarand", // 177 |
||
314 | "myos", // 178 |
||
315 | "myospal", // 179 |
||
316 | "displayrand", // 180 |
||
317 | "sin", // 181 |
||
318 | "xorvarvar", // 182 |
||
319 | "xorvar", // 183 |
||
320 | "randvarvar", // 184 |
||
321 | "myosx", // 185 |
||
322 | "myospalx", // 186 |
||
323 | "gmaxammo", // 187 |
||
324 | "smaxammo", // 188 |
||
325 | "startlevel", // 189 |
||
326 | "eshoot", // 190 |
||
327 | "qspawn", // 191 |
||
328 | "rotatesprite", // 192 |
||
329 | "defineprojectile", // 193 |
||
330 | "spriteshadow", // 194 |
||
331 | "cos", // 195 |
||
332 | "eshootvar", // 196 |
||
333 | "findnearactor3d", // 197 |
||
334 | "findnearactor3dvar", // 198 |
||
335 | "flash", // 199 |
||
336 | "qspawnvar", // 200 |
||
337 | "eqspawn", // 201 |
||
338 | "eqspawnvar", // 202 |
||
339 | "minitext", // 203 |
||
340 | "gametext", // 204 |
||
341 | "digitalnumber", // 205 |
||
342 | "addweaponvar", // 206 |
||
343 | "setprojectile", // 207 |
||
344 | "angoff", // 208 |
||
345 | "updatesector", // 209 |
||
346 | "insertspriteq", // 210 |
||
347 | "angoffvar", // 211 |
||
348 | "whilevarn", // 212 |
||
349 | "switch", // 213 |
||
350 | "case", // 214 |
||
351 | "default", // 215 |
||
352 | "endswitch", // 216 |
||
353 | "shootvar", // 217 |
||
354 | "soundvar", // 218 |
||
355 | "findplayer", // 219 |
||
356 | "findotherplayer", // 220 |
||
357 | "activatebysector", // 221 sectnum, spriteid |
||
358 | "operatesectors", // 222 sectnum, spriteid |
||
359 | "operaterespawns", // 223 lotag |
||
360 | "operateactivators", // 224 lotag, player index |
||
361 | "operatemasterswitches", // 225 lotag |
||
362 | "checkactivatormotion", // 226 lotag |
||
363 | "zshoot", // 227 zvar projnum |
||
364 | "dist", // 228 sprite1 sprite2 |
||
365 | "ldist", // 229 sprite1 sprite2 |
||
366 | "shiftvarl", // 230 |
||
367 | "shiftvarr", // 231 |
||
368 | "spritenvg", // 232 |
||
369 | "getangle", // 233 |
||
370 | "whilevarvarn", // 234 |
||
371 | "hitscan", // 235 |
||
372 | "time", // 236 |
||
373 | "getplayervar", // 237 |
||
374 | "setplayervar", // 238 |
||
375 | "mulscale", // 239 |
||
376 | "setaspect", // 240 |
||
377 | "ezshoot", // 241 |
||
378 | "spritenoshade", // 242 |
||
379 | "movesprite", // 243 |
||
380 | "checkavailweapon", // 244 |
||
381 | "soundoncevar", // 245 |
||
382 | "updatesectorz", // 246 |
||
383 | "stopallsounds", // 247 |
||
384 | "ssp", // 248 |
||
385 | "stopsoundvar", // 249 |
||
386 | "displayrandvar", // 250 |
||
387 | "displayrandvarvar", // 251 |
||
388 | "checkavailinven", // 252 |
||
389 | "globalsoundvar", // 253 |
||
390 | "guniqhudid", // 254 |
||
391 | "getprojectile", // 255 |
||
392 | "getthisprojectile", // 256 |
||
393 | "setthisprojectile", // 257 |
||
394 | "definecheat", // 258 |
||
395 | "cheatkeys", // 259 |
||
396 | "userquote", // 260 |
||
397 | "precache", // 261 |
||
398 | "definegamefuncname", // 262 |
||
399 | "redefinequote", // 263 |
||
400 | "qsprintf", // 264 |
||
401 | "getpname", // 265 |
||
402 | "qstrcat", // 266 |
||
403 | "qstrcpy", // 267 |
||
404 | "setsprite", // 268 |
||
405 | "rotatepoint", // 269 |
||
406 | "dragpoint", // 270 |
||
407 | "getzrange", // 271 |
||
408 | "changespritestat", // 272 |
||
409 | "getceilzofslope", // 273 |
||
410 | "getflorzofslope", // 274 |
||
411 | "neartag", // 275 |
||
412 | "definegametype", // 276 |
||
413 | "changespritesect", // 277 |
||
414 | "spriteflags", // 278 |
||
415 | "savegamevar", // 279 |
||
416 | "readgamevar", // 280 |
||
417 | "findnearsprite", // 281 |
||
418 | "findnearspritevar", // 282 |
||
419 | "findnearsprite3d", // 283 |
||
420 | "findnearsprite3dvar", // 284 |
||
421 | "dynamicremap", // 285 |
||
422 | "setinput", // 286 |
||
423 | "getinput", // 287 |
||
652 | terminx | 424 | "save", // 288 |
559 | terminx | 425 | "cansee", // 289 |
426 | "canseespr", // 290 |
||
427 | "findnearactorz", // 291 |
||
428 | "findnearactorzvar", // 292 |
||
429 | "findnearspritez", // 293 |
||
430 | "findnearspritezvar", // 294 |
||
652 | terminx | 431 | "zshootvar", // 295 |
432 | "ezshootvar", // 296 |
||
433 | "getcurraddress", // 297 |
||
434 | "jump", // 298 |
||
435 | "qstrlen", // 299 |
||
559 | terminx | 436 | "getincangle", // 300 |
437 | "quake", // 301 |
||
438 | "showview", // 302 |
||
439 | "headspritestat", // 303 |
||
440 | "prevspritestat", // 304 |
||
441 | "nextspritestat", // 305 |
||
442 | "headspritesect", // 306 |
||
443 | "prevspritesect", // 307 |
||
444 | "nextspritesect", // 308 |
||
587 | terminx | 445 | "getkeyname", // 309 |
446 | "qsubstr", // 310 |
||
447 | "gametextz", // 311 |
||
448 | "digitalnumberz", // 312 |
||
449 | "spritenopal", // 313 |
||
617 | terminx | 450 | "hitradiusvar", // 314 |
642 | terminx | 451 | "rotatesprite16", // 315 |
676 | terminx | 452 | "gamearray", // 316 |
453 | "setarray", // 317 |
||
693 | terminx | 454 | "resizearray", // 318 |
455 | "writearraytofile", // 319 |
||
456 | "readarrayfromfile", // 320 |
||
723 | terminx | 457 | "starttrackvar", // 321 |
782 | terminx | 458 | "qgetsysstr", // 322 |
798 | terminx | 459 | "getticks", // 323 |
856 | terminx | 460 | "gettspr", // 324 |
461 | "settspr", // 325 |
||
859 | terminx | 462 | "savemapstate", // 326 |
463 | "loadmapstate", // 327 |
||
464 | "clearmapstate", // 328 |
||
874 | terminx | 465 | "scriptsize", // 329 |
886 | terminx | 466 | "definegamename", // 330 |
559 | terminx | 467 | "<null>" |
468 | }; |
||
5 | Plagman | 469 | |
859 | terminx | 470 | const memberlabel_t sectorlabels[]= |
559 | terminx | 471 | { |
472 | { "wallptr", SECTOR_WALLPTR, 0, 0 }, |
||
473 | { "wallnum", SECTOR_WALLNUM, 0, 0 }, |
||
474 | { "ceilingz", SECTOR_CEILINGZ, 0, 0 }, |
||
475 | { "floorz", SECTOR_FLOORZ, 0, 0 }, |
||
476 | { "ceilingstat", SECTOR_CEILINGSTAT, 0, 0 }, |
||
477 | { "floorstat", SECTOR_FLOORSTAT, 0, 0 }, |
||
478 | { "ceilingpicnum", SECTOR_CEILINGPICNUM, 0, 0 }, |
||
479 | { "ceilingslope", SECTOR_CEILINGSLOPE, 0, 0 }, |
||
480 | { "ceilingshade", SECTOR_CEILINGSHADE, 0, 0 }, |
||
481 | { "ceilingpal", SECTOR_CEILINGPAL, 0, 0 }, |
||
482 | { "ceilingxpanning", SECTOR_CEILINGXPANNING, 0, 0 }, |
||
483 | { "ceilingypanning", SECTOR_CEILINGYPANNING, 0, 0 }, |
||
484 | { "floorpicnum", SECTOR_FLOORPICNUM, 0, 0 }, |
||
485 | { "floorslope", SECTOR_FLOORSLOPE, 0, 0 }, |
||
486 | { "floorshade", SECTOR_FLOORSHADE, 0, 0 }, |
||
487 | { "floorpal", SECTOR_FLOORPAL, 0, 0 }, |
||
488 | { "floorxpanning", SECTOR_FLOORXPANNING, 0, 0 }, |
||
489 | { "floorypanning", SECTOR_FLOORYPANNING, 0, 0 }, |
||
490 | { "visibility", SECTOR_VISIBILITY, 0, 0 }, |
||
491 | { "alignto", SECTOR_ALIGNTO, 0, 0 }, |
||
492 | { "lotag", SECTOR_LOTAG, 0, 0 }, |
||
493 | { "hitag", SECTOR_HITAG, 0, 0 }, |
||
494 | { "extra", SECTOR_EXTRA, 0, 0 }, |
||
495 | { "", -1, 0, 0 } // END OF LIST |
||
496 | }; |
||
5 | Plagman | 497 | |
859 | terminx | 498 | const memberlabel_t walllabels[]= |
559 | terminx | 499 | { |
500 | { "x", WALL_X, 0, 0 }, |
||
501 | { "y", WALL_Y, 0, 0 }, |
||
502 | { "point2", WALL_POINT2, 0, 0 }, |
||
503 | { "nextwall", WALL_NEXTWALL, 0, 0 }, |
||
504 | { "nextsector", WALL_NEXTSECTOR, 0, 0 }, |
||
505 | { "cstat", WALL_CSTAT, 0, 0 }, |
||
506 | { "picnum", WALL_PICNUM, 0, 0 }, |
||
507 | { "overpicnum", WALL_OVERPICNUM, 0, 0 }, |
||
508 | { "shade", WALL_SHADE, 0, 0 }, |
||
509 | { "pal", WALL_PAL, 0, 0 }, |
||
510 | { "xrepeat", WALL_XREPEAT, 0, 0 }, |
||
511 | { "yrepeat", WALL_YREPEAT, 0, 0 }, |
||
512 | { "xpanning", WALL_XPANNING, 0, 0 }, |
||
513 | { "ypanning", WALL_YPANNING, 0, 0 }, |
||
514 | { "lotag", WALL_LOTAG, 0, 0 }, |
||
515 | { "hitag", WALL_HITAG, 0, 0 }, |
||
516 | { "extra", WALL_EXTRA, 0, 0 }, |
||
517 | { "", -1, 0, 0 } // END OF LIST |
||
518 | }; |
||
5 | Plagman | 519 | |
616 | terminx | 520 | const memberlabel_t actorlabels[]= |
559 | terminx | 521 | { |
522 | { "x", ACTOR_X, 0, 0 }, |
||
523 | { "y", ACTOR_Y, 0, 0 }, |
||
524 | { "z", ACTOR_Z, 0, 0 }, |
||
525 | { "cstat", ACTOR_CSTAT, 0, 0 }, |
||
526 | { "picnum", ACTOR_PICNUM, 0, 0 }, |
||
527 | { "shade", ACTOR_SHADE, 0, 0 }, |
||
528 | { "pal", ACTOR_PAL, 0, 0 }, |
||
529 | { "clipdist", ACTOR_CLIPDIST, 0, 0 }, |
||
530 | { "detail", ACTOR_DETAIL, 0, 0 }, |
||
531 | { "xrepeat", ACTOR_XREPEAT, 0, 0 }, |
||
532 | { "yrepeat", ACTOR_YREPEAT, 0, 0 }, |
||
533 | { "xoffset", ACTOR_XOFFSET, 0, 0 }, |
||
534 | { "yoffset", ACTOR_YOFFSET, 0, 0 }, |
||
535 | { "sectnum", ACTOR_SECTNUM, 0, 0 }, |
||
536 | { "statnum", ACTOR_STATNUM, 0, 0 }, |
||
537 | { "ang", ACTOR_ANG, 0, 0 }, |
||
538 | { "owner", ACTOR_OWNER, 0, 0 }, |
||
539 | { "xvel", ACTOR_XVEL, 0, 0 }, |
||
540 | { "yvel", ACTOR_YVEL, 0, 0 }, |
||
541 | { "zvel", ACTOR_ZVEL, 0, 0 }, |
||
542 | { "lotag", ACTOR_LOTAG, 0, 0 }, |
||
543 | { "hitag", ACTOR_HITAG, 0, 0 }, |
||
544 | { "extra", ACTOR_EXTRA, 0, 0 }, |
||
5 | Plagman | 545 | |
559 | terminx | 546 | // hittype labels... |
547 | { "htcgg", ACTOR_HTCGG, 0, 0 }, |
||
548 | { "htpicnum", ACTOR_HTPICNUM, 0, 0 }, |
||
549 | { "htang", ACTOR_HTANG, 0, 0 }, |
||
550 | { "htextra", ACTOR_HTEXTRA, 0, 0 }, |
||
551 | { "htowner", ACTOR_HTOWNER, 0, 0 }, |
||
552 | { "htmovflag", ACTOR_HTMOVFLAG, 0, 0 }, |
||
553 | { "httempang", ACTOR_HTTEMPANG, 0, 0 }, |
||
554 | { "htactorstayput", ACTOR_HTACTORSTAYPUT, 0, 0 }, |
||
555 | { "htdispicnum", ACTOR_HTDISPICNUM, 0, 0 }, |
||
556 | { "httimetosleep", ACTOR_HTTIMETOSLEEP, 0, 0 }, |
||
557 | { "htfloorz", ACTOR_HTFLOORZ, 0, 0 }, |
||
558 | { "htceilingz", ACTOR_HTCEILINGZ, 0, 0 }, |
||
559 | { "htlastvx", ACTOR_HTLASTVX, 0, 0 }, |
||
560 | { "htlastvy", ACTOR_HTLASTVY, 0, 0 }, |
||
561 | { "htbposx", ACTOR_HTBPOSX, 0, 0 }, |
||
562 | { "htbposy", ACTOR_HTBPOSY, 0, 0 }, |
||
563 | { "htbposz", ACTOR_HTBPOSZ, 0, 0 }, |
||
870 | terminx | 564 | { "htg_t", ACTOR_HTG_T, LABEL_HASPARM2, 10 }, |
5 | Plagman | 565 | |
559 | terminx | 566 | // model flags |
5 | Plagman | 567 | |
559 | terminx | 568 | { "angoff", ACTOR_ANGOFF, 0, 0 }, |
569 | { "pitch", ACTOR_PITCH, 0, 0 }, |
||
570 | { "roll", ACTOR_ROLL, 0, 0 }, |
||
571 | { "mdxoff", ACTOR_MDXOFF, 0, 0 }, |
||
572 | { "mdyoff", ACTOR_MDYOFF, 0, 0 }, |
||
573 | { "mdzoff", ACTOR_MDZOFF, 0, 0 }, |
||
574 | { "mdflags", ACTOR_MDFLAGS, 0, 0 }, |
||
590 | plagman | 575 | { "xpanning", ACTOR_XPANNING, 0, 0 }, |
576 | { "ypanning", ACTOR_YPANNING, 0, 0 }, |
||
853 | terminx | 577 | |
856 | terminx | 578 | { "", -1, 0, 0 } // END OF LIST |
579 | }; |
||
580 | |||
581 | const memberlabel_t tsprlabels[]= |
||
582 | { |
||
853 | terminx | 583 | // tsprite access |
584 | |||
585 | { "tsprx", ACTOR_TSPRX, 0, 0 }, |
||
586 | { "tspry", ACTOR_TSPRY, 0, 0 }, |
||
587 | { "tsprz", ACTOR_TSPRZ, 0, 0 }, |
||
588 | { "tsprcstat", ACTOR_TSPRCSTAT, 0, 0 }, |
||
589 | { "tsprpicnum", ACTOR_TSPRPICNUM, 0, 0 }, |
||
590 | { "tsprshade", ACTOR_TSPRSHADE, 0, 0 }, |
||
591 | { "tsprpal", ACTOR_TSPRPAL, 0, 0 }, |
||
592 | { "tsprxrepeat", ACTOR_TSPRXREPEAT, 0, 0 }, |
||
593 | { "tspryrepeat", ACTOR_TSPRYREPEAT, 0, 0 }, |
||
594 | { "tsprxoffset", ACTOR_TSPRXOFFSET, 0, 0 }, |
||
595 | { "tspryoffset", ACTOR_TSPRYOFFSET, 0, 0 }, |
||
596 | { "tsprsectnum", ACTOR_TSPRSECTNUM, 0, 0 }, |
||
597 | { "tsprang", ACTOR_TSPRANG, 0, 0 }, |
||
598 | |||
559 | terminx | 599 | { "", -1, 0, 0 } // END OF LIST |
600 | }; |
||
5 | Plagman | 601 | |
616 | terminx | 602 | const memberlabel_t playerlabels[]= |
559 | terminx | 603 | { |
604 | { "zoom", PLAYER_ZOOM, 0, 0 }, |
||
605 | { "exitx", PLAYER_EXITX, 0, 0 }, |
||
606 | { "exity", PLAYER_EXITY, 0, 0 }, |
||
870 | terminx | 607 | { "loogiex", PLAYER_LOOGIEX, LABEL_HASPARM2, 64 }, |
608 | { "loogiey", PLAYER_LOOGIEY, LABEL_HASPARM2, 64 }, |
||
559 | terminx | 609 | { "numloogs", PLAYER_NUMLOOGS, 0, 0 }, |
610 | { "loogcnt", PLAYER_LOOGCNT, 0, 0 }, |
||
611 | { "posx", PLAYER_POSX, 0, 0 }, |
||
612 | { "posy", PLAYER_POSY, 0, 0 }, |
||
613 | { "posz", PLAYER_POSZ, 0, 0 }, |
||
614 | { "horiz", PLAYER_HORIZ, 0, 0 }, |
||
615 | { "ohoriz", PLAYER_OHORIZ, 0, 0 }, |
||
616 | { "ohorizoff", PLAYER_OHORIZOFF, 0, 0 }, |
||
617 | { "invdisptime", PLAYER_INVDISPTIME, 0, 0 }, |
||
618 | { "bobposx", PLAYER_BOBPOSX, 0, 0 }, |
||
619 | { "bobposy", PLAYER_BOBPOSY, 0, 0 }, |
||
620 | { "oposx", PLAYER_OPOSX, 0, 0 }, |
||
621 | { "oposy", PLAYER_OPOSY, 0, 0 }, |
||
622 | { "oposz", PLAYER_OPOSZ, 0, 0 }, |
||
623 | { "pyoff", PLAYER_PYOFF, 0, 0 }, |
||
624 | { "opyoff", PLAYER_OPYOFF, 0, 0 }, |
||
625 | { "posxv", PLAYER_POSXV, 0, 0 }, |
||
626 | { "posyv", PLAYER_POSYV, 0, 0 }, |
||
627 | { "poszv", PLAYER_POSZV, 0, 0 }, |
||
628 | { "last_pissed_time", PLAYER_LAST_PISSED_TIME, 0, 0 }, |
||
629 | { "truefz", PLAYER_TRUEFZ, 0, 0 }, |
||
630 | { "truecz", PLAYER_TRUECZ, 0, 0 }, |
||
631 | { "player_par", PLAYER_PLAYER_PAR, 0, 0 }, |
||
632 | { "visibility", PLAYER_VISIBILITY, 0, 0 }, |
||
633 | { "bobcounter", PLAYER_BOBCOUNTER, 0, 0 }, |
||
634 | { "weapon_sway", PLAYER_WEAPON_SWAY, 0, 0 }, |
||
635 | { "pals_time", PLAYER_PALS_TIME, 0, 0 }, |
||
636 | { "randomflamex", PLAYER_RANDOMFLAMEX, 0, 0 }, |
||
637 | { "crack_time", PLAYER_CRACK_TIME, 0, 0 }, |
||
638 | { "aim_mode", PLAYER_AIM_MODE, 0, 0 }, |
||
639 | { "ang", PLAYER_ANG, 0, 0 }, |
||
640 | { "oang", PLAYER_OANG, 0, 0 }, |
||
641 | { "angvel", PLAYER_ANGVEL, 0, 0 }, |
||
642 | { "cursectnum", PLAYER_CURSECTNUM, 0, 0 }, |
||
643 | { "look_ang", PLAYER_LOOK_ANG, 0, 0 }, |
||
644 | { "last_extra", PLAYER_LAST_EXTRA, 0, 0 }, |
||
645 | { "subweapon", PLAYER_SUBWEAPON, 0, 0 }, |
||
646 | { "ammo_amount", PLAYER_AMMO_AMOUNT, LABEL_HASPARM2, MAX_WEAPONS }, |
||
647 | { "wackedbyactor", PLAYER_WACKEDBYACTOR, 0, 0 }, |
||
648 | { "frag", PLAYER_FRAG, 0, 0 }, |
||
649 | { "fraggedself", PLAYER_FRAGGEDSELF, 0, 0 }, |
||
650 | { "curr_weapon", PLAYER_CURR_WEAPON, 0, 0 }, |
||
651 | { "last_weapon", PLAYER_LAST_WEAPON, 0, 0 }, |
||
652 | { "tipincs", PLAYER_TIPINCS, 0, 0 }, |
||
653 | { "horizoff", PLAYER_HORIZOFF, 0, 0 }, |
||
654 | { "wantweaponfire", PLAYER_WANTWEAPONFIRE, 0, 0 }, |
||
655 | { "holoduke_amount", PLAYER_HOLODUKE_AMOUNT, 0, 0 }, |
||
656 | { "newowner", PLAYER_NEWOWNER, 0, 0 }, |
||
657 | { "hurt_delay", PLAYER_HURT_DELAY, 0, 0 }, |
||
658 | { "hbomb_hold_delay", PLAYER_HBOMB_HOLD_DELAY, 0, 0 }, |
||
659 | { "jumping_counter", PLAYER_JUMPING_COUNTER, 0, 0 }, |
||
660 | { "airleft", PLAYER_AIRLEFT, 0, 0 }, |
||
661 | { "knee_incs", PLAYER_KNEE_INCS, 0, 0 }, |
||
662 | { "access_incs", PLAYER_ACCESS_INCS, 0, 0 }, |
||
663 | { "fta", PLAYER_FTA, 0, 0 }, |
||
664 | { "ftq", PLAYER_FTQ, 0, 0 }, |
||
665 | { "access_wallnum", PLAYER_ACCESS_WALLNUM, 0, 0 }, |
||
666 | { "access_spritenum", PLAYER_ACCESS_SPRITENUM, 0, 0 }, |
||
667 | { "kickback_pic", PLAYER_KICKBACK_PIC, 0, 0 }, |
||
668 | { "got_access", PLAYER_GOT_ACCESS, 0, 0 }, |
||
669 | { "weapon_ang", PLAYER_WEAPON_ANG, 0, 0 }, |
||
670 | { "firstaid_amount", PLAYER_FIRSTAID_AMOUNT, 0, 0 }, |
||
671 | { "somethingonplayer", PLAYER_SOMETHINGONPLAYER, 0, 0 }, |
||
672 | { "on_crane", PLAYER_ON_CRANE, 0, 0 }, |
||
673 | { "i", PLAYER_I, 0, 0 }, |
||
674 | { "one_parallax_sectnum", PLAYER_ONE_PARALLAX_SECTNUM, 0, 0 }, |
||
675 | { "over_shoulder_on", PLAYER_OVER_SHOULDER_ON, 0, 0 }, |
||
676 | { "random_club_frame", PLAYER_RANDOM_CLUB_FRAME, 0, 0 }, |
||
677 | { "fist_incs", PLAYER_FIST_INCS, 0, 0 }, |
||
678 | { "one_eighty_count", PLAYER_ONE_EIGHTY_COUNT, 0, 0 }, |
||
679 | { "cheat_phase", PLAYER_CHEAT_PHASE, 0, 0 }, |
||
680 | { "dummyplayersprite", PLAYER_DUMMYPLAYERSPRITE, 0, 0 }, |
||
681 | { "extra_extra8", PLAYER_EXTRA_EXTRA8, 0, 0 }, |
||
682 | { "quick_kick", PLAYER_QUICK_KICK, 0, 0 }, |
||
683 | { "heat_amount", PLAYER_HEAT_AMOUNT, 0, 0 }, |
||
684 | { "actorsqu", PLAYER_ACTORSQU, 0, 0 }, |
||
685 | { "timebeforeexit", PLAYER_TIMEBEFOREEXIT, 0, 0 }, |
||
686 | { "customexitsound", PLAYER_CUSTOMEXITSOUND, 0, 0 }, |
||
687 | { "weaprecs[16]", PLAYER_WEAPRECS, 0, 0 }, |
||
688 | { "weapreccnt", PLAYER_WEAPRECCNT, 0, 0 }, |
||
689 | { "interface_toggle_flag", PLAYER_INTERFACE_TOGGLE_FLAG, 0, 0 }, |
||
690 | { "rotscrnang", PLAYER_ROTSCRNANG, 0, 0 }, |
||
691 | { "dead_flag", PLAYER_DEAD_FLAG, 0, 0 }, |
||
692 | { "show_empty_weapon", PLAYER_SHOW_EMPTY_WEAPON, 0, 0 }, |
||
693 | { "scuba_amount", PLAYER_SCUBA_AMOUNT, 0, 0 }, |
||
694 | { "jetpack_amount", PLAYER_JETPACK_AMOUNT, 0, 0 }, |
||
695 | { "steroids_amount", PLAYER_STEROIDS_AMOUNT, 0, 0 }, |
||
696 | { "shield_amount", PLAYER_SHIELD_AMOUNT, 0, 0 }, |
||
697 | { "holoduke_on", PLAYER_HOLODUKE_ON, 0, 0 }, |
||
698 | { "pycount", PLAYER_PYCOUNT, 0, 0 }, |
||
699 | { "weapon_pos", PLAYER_WEAPON_POS, 0, 0 }, |
||
700 | { "frag_ps", PLAYER_FRAG_PS, 0, 0 }, |
||
701 | { "transporter_hold", PLAYER_TRANSPORTER_HOLD, 0, 0 }, |
||
702 | { "last_full_weapon", PLAYER_LAST_FULL_WEAPON, 0, 0 }, |
||
703 | { "footprintshade", PLAYER_FOOTPRINTSHADE, 0, 0 }, |
||
704 | { "boot_amount", PLAYER_BOOT_AMOUNT, 0, 0 }, |
||
705 | { "scream_voice", PLAYER_SCREAM_VOICE, 0, 0 }, |
||
706 | { "gm", PLAYER_GM, 0, 0 }, |
||
707 | { "on_warping_sector", PLAYER_ON_WARPING_SECTOR, 0, 0 }, |
||
708 | { "footprintcount", PLAYER_FOOTPRINTCOUNT, 0, 0 }, |
||
709 | { "hbomb_on", PLAYER_HBOMB_ON, 0, 0 }, |
||
710 | { "jumping_toggle", PLAYER_JUMPING_TOGGLE, 0, 0 }, |
||
711 | { "rapid_fire_hold", PLAYER_RAPID_FIRE_HOLD, 0, 0 }, |
||
712 | { "on_ground", PLAYER_ON_GROUND, 0, 0 }, |
||
713 | { "name", PLAYER_NAME, LABEL_ISSTRING, 32 }, |
||
714 | { "inven_icon", PLAYER_INVEN_ICON, 0, 0 }, |
||
715 | { "buttonpalette", PLAYER_BUTTONPALETTE, 0, 0 }, |
||
716 | { "jetpack_on", PLAYER_JETPACK_ON, 0, 0 }, |
||
717 | { "spritebridge", PLAYER_SPRITEBRIDGE, 0, 0 }, |
||
718 | { "lastrandomspot", PLAYER_LASTRANDOMSPOT, 0, 0 }, |
||
719 | { "scuba_on", PLAYER_SCUBA_ON, 0, 0 }, |
||
720 | { "footprintpal", PLAYER_FOOTPRINTPAL, 0, 0 }, |
||
721 | { "heat_on", PLAYER_HEAT_ON, 0, 0 }, |
||
722 | { "holster_weapon", PLAYER_HOLSTER_WEAPON, 0, 0 }, |
||
723 | { "falling_counter", PLAYER_FALLING_COUNTER, 0, 0 }, |
||
724 | { "gotweapon", PLAYER_GOTWEAPON, LABEL_HASPARM2, MAX_WEAPONS }, |
||
725 | { "refresh_inventory", PLAYER_REFRESH_INVENTORY, 0, 0 }, |
||
726 | { "palette", PLAYER_PALETTE, 0, 0 }, |
||
727 | { "toggle_key_flag", PLAYER_TOGGLE_KEY_FLAG, 0, 0 }, |
||
728 | { "knuckle_incs", PLAYER_KNUCKLE_INCS, 0, 0 }, |
||
729 | { "walking_snd_toggle", PLAYER_WALKING_SND_TOGGLE, 0, 0 }, |
||
730 | { "palookup", PLAYER_PALOOKUP, 0, 0 }, |
||
731 | { "hard_landing", PLAYER_HARD_LANDING, 0, 0 }, |
||
732 | { "max_secret_rooms", PLAYER_MAX_SECRET_ROOMS, 0, 0 }, |
||
733 | { "secret_rooms", PLAYER_SECRET_ROOMS, 0, 0 }, |
||
869 | terminx | 734 | { "pals", PLAYER_PALS, LABEL_HASPARM2, 3 }, |
559 | terminx | 735 | { "max_actors_killed", PLAYER_MAX_ACTORS_KILLED, 0, 0 }, |
736 | { "actors_killed", PLAYER_ACTORS_KILLED, 0, 0 }, |
||
737 | { "return_to_center", PLAYER_RETURN_TO_CENTER, 0, 0 }, |
||
738 | { "runspeed", PLAYER_RUNSPEED, 0, 0 }, |
||
739 | { "sbs", PLAYER_SBS, 0, 0 }, |
||
740 | { "reloading", PLAYER_RELOADING, 0, 0 }, |
||
741 | { "auto_aim", PLAYER_AUTO_AIM, 0, 0 }, |
||
742 | { "movement_lock", PLAYER_MOVEMENT_LOCK, 0, 0 }, |
||
743 | { "sound_pitch", PLAYER_SOUND_PITCH, 0, 0 }, |
||
744 | { "weaponswitch", PLAYER_WEAPONSWITCH, 0, 0 }, |
||
745 | { "team", PLAYER_TEAM, 0, 0 }, |
||
566 | terminx | 746 | { "max_player_health", PLAYER_MAX_PLAYER_HEALTH, 0, 0 }, |
747 | { "max_shield_amount", PLAYER_MAX_SHIELD_AMOUNT, 0, 0 }, |
||
748 | { "max_ammo_amount", PLAYER_MAX_AMMO_AMOUNT, LABEL_HASPARM2, MAX_WEAPONS }, |
||
559 | terminx | 749 | { "", -1, 0, 0 } // END OF LIST |
750 | }; |
||
5 | Plagman | 751 | |
859 | terminx | 752 | const memberlabel_t projectilelabels[]= |
559 | terminx | 753 | { |
754 | { "workslike", PROJ_WORKSLIKE, 0, 0 }, |
||
755 | { "spawns", PROJ_SPAWNS, 0, 0 }, |
||
756 | { "sxrepeat", PROJ_SXREPEAT, 0, 0 }, |
||
757 | { "syrepeat", PROJ_SYREPEAT, 0, 0 }, |
||
758 | { "sound", PROJ_SOUND, 0, 0 }, |
||
759 | { "isound", PROJ_ISOUND, 0, 0 }, |
||
760 | { "vel", PROJ_VEL, 0, 0 }, |
||
761 | { "extra", PROJ_EXTRA, 0, 0 }, |
||
762 | { "decal", PROJ_DECAL, 0, 0 }, |
||
763 | { "trail", PROJ_TRAIL, 0, 0 }, |
||
764 | { "txrepeat", PROJ_TXREPEAT, 0, 0 }, |
||
765 | { "tyrepeat", PROJ_TYREPEAT, 0, 0 }, |
||
766 | { "toffset", PROJ_TOFFSET, 0, 0 }, |
||
767 | { "tnum", PROJ_TNUM, 0, 0 }, |
||
768 | { "drop", PROJ_DROP, 0, 0 }, |
||
769 | { "cstat", PROJ_CSTAT, 0, 0 }, |
||
770 | { "clipdist", PROJ_CLIPDIST, 0, 0 }, |
||
771 | { "shade", PROJ_SHADE, 0, 0 }, |
||
772 | { "xrepeat", PROJ_XREPEAT, 0, 0 }, |
||
773 | { "yrepeat", PROJ_YREPEAT, 0, 0 }, |
||
774 | { "pal", PROJ_PAL, 0, 0 }, |
||
775 | { "extra_rand", PROJ_EXTRA_RAND, 0, 0 }, |
||
776 | { "hitradius", PROJ_HITRADIUS, 0, 0 }, |
||
777 | { "velmult", PROJ_VEL_MULT, 0, 0 }, |
||
778 | { "offset", PROJ_OFFSET, 0, 0 }, |
||
779 | { "bounces", PROJ_BOUNCES, 0, 0 }, |
||
780 | { "bsound", PROJ_BSOUND, 0, 0 }, |
||
781 | { "range", PROJ_RANGE, 0, 0 }, |
||
782 | { "", -1, 0, 0 } // END OF LIST |
||
783 | }; |
||
5 | Plagman | 784 | |
859 | terminx | 785 | const memberlabel_t userdefslabels[]= |
559 | terminx | 786 | { |
787 | // { "<null>", 1, 0, 0 }, |
||
788 | { "god", USERDEFS_GOD, 0, 0 }, |
||
789 | { "warp_on", USERDEFS_WARP_ON, 0, 0 }, |
||
790 | { "cashman", USERDEFS_CASHMAN, 0, 0 }, |
||
791 | { "eog", USERDEFS_EOG, 0, 0 }, |
||
792 | { "showallmap", USERDEFS_SHOWALLMAP, 0, 0 }, |
||
793 | { "show_help", USERDEFS_SHOW_HELP, 0, 0 }, |
||
794 | { "scrollmode", USERDEFS_SCROLLMODE, 0, 0 }, |
||
795 | { "clipping", USERDEFS_CLIPPING, 0, 0 }, |
||
796 | { "user_name", USERDEFS_USER_NAME, LABEL_HASPARM2, MAXPLAYERS }, |
||
797 | { "ridecule", USERDEFS_RIDECULE, LABEL_HASPARM2 | LABEL_ISSTRING, 10 }, |
||
798 | { "savegame", USERDEFS_SAVEGAME, LABEL_HASPARM2 | LABEL_ISSTRING, 10 }, |
||
799 | { "pwlockout", USERDEFS_PWLOCKOUT, LABEL_ISSTRING, 128 }, |
||
800 | { "rtsname;", USERDEFS_RTSNAME, LABEL_ISSTRING, 128 }, |
||
801 | { "overhead_on", USERDEFS_OVERHEAD_ON, 0, 0 }, |
||
802 | { "last_overhead", USERDEFS_LAST_OVERHEAD, 0, 0 }, |
||
803 | { "showweapons", USERDEFS_SHOWWEAPONS, 0, 0 }, |
||
5 | Plagman | 804 | |
559 | terminx | 805 | { "pause_on", USERDEFS_PAUSE_ON, 0, 0 }, |
806 | { "from_bonus", USERDEFS_FROM_BONUS, 0, 0 }, |
||
807 | { "camerasprite", USERDEFS_CAMERASPRITE, 0, 0 }, |
||
808 | { "last_camsprite", USERDEFS_LAST_CAMSPRITE, 0, 0 }, |
||
809 | { "last_level", USERDEFS_LAST_LEVEL, 0, 0 }, |
||
810 | { "secretlevel", USERDEFS_SECRETLEVEL, 0, 0 }, |
||
5 | Plagman | 811 | |
559 | terminx | 812 | { "const_visibility", USERDEFS_CONST_VISIBILITY, 0, 0 }, |
813 | { "uw_framerate", USERDEFS_UW_FRAMERATE, 0, 0 }, |
||
814 | { "camera_time", USERDEFS_CAMERA_TIME, 0, 0 }, |
||
815 | { "folfvel", USERDEFS_FOLFVEL, 0, 0 }, |
||
816 | { "folavel", USERDEFS_FOLAVEL, 0, 0 }, |
||
817 | { "folx", USERDEFS_FOLX, 0, 0 }, |
||
818 | { "foly", USERDEFS_FOLY, 0, 0 }, |
||
819 | { "fola", USERDEFS_FOLA, 0, 0 }, |
||
820 | { "reccnt", USERDEFS_RECCNT, 0, 0 }, |
||
5 | Plagman | 821 | |
559 | terminx | 822 | { "entered_name", USERDEFS_ENTERED_NAME, 0, 0 }, |
823 | { "screen_tilting", USERDEFS_SCREEN_TILTING, 0, 0 }, |
||
824 | { "shadows", USERDEFS_SHADOWS, 0, 0 }, |
||
825 | { "fta_on", USERDEFS_FTA_ON, 0, 0 }, |
||
826 | { "executions", USERDEFS_EXECUTIONS, 0, 0 }, |
||
827 | { "auto_run", USERDEFS_AUTO_RUN, 0, 0 }, |
||
828 | { "coords", USERDEFS_COORDS, 0, 0 }, |
||
829 | { "tickrate", USERDEFS_TICKRATE, 0, 0 }, |
||
830 | { "m_coop", USERDEFS_M_COOP, 0, 0 }, |
||
831 | { "coop", USERDEFS_COOP, 0, 0 }, |
||
832 | { "screen_size", USERDEFS_SCREEN_SIZE, 0, 0 }, |
||
833 | { "lockout", USERDEFS_LOCKOUT, 0, 0 }, |
||
834 | { "crosshair", USERDEFS_CROSSHAIR, 0, 0 }, |
||
835 | { "wchoice[MAXPLAYERS][MAX_WEAPONS]", USERDEFS_WCHOICE, 0, 0 }, |
||
836 | { "playerai", USERDEFS_PLAYERAI, 0, 0 }, |
||
837 | { "respawn_monsters", USERDEFS_RESPAWN_MONSTERS, 0, 0 }, |
||
838 | { "respawn_items", USERDEFS_RESPAWN_ITEMS, 0, 0 }, |
||
839 | { "respawn_inventory", USERDEFS_RESPAWN_INVENTORY, 0, 0 }, |
||
840 | { "recstat", USERDEFS_RECSTAT, 0, 0 }, |
||
841 | { "monsters_off", USERDEFS_MONSTERS_OFF, 0, 0 }, |
||
842 | { "brightness", USERDEFS_BRIGHTNESS, 0, 0 }, |
||
843 | { "m_respawn_items", USERDEFS_M_RESPAWN_ITEMS, 0, 0 }, |
||
844 | { "m_respawn_monsters", USERDEFS_M_RESPAWN_MONSTERS, 0, 0 }, |
||
845 | { "m_respawn_inventory", USERDEFS_M_RESPAWN_INVENTORY, 0, 0 }, |
||
846 | { "m_recstat", USERDEFS_M_RECSTAT, 0, 0 }, |
||
847 | { "m_monsters_off", USERDEFS_M_MONSTERS_OFF, 0, 0 }, |
||
848 | { "detail", USERDEFS_DETAIL, 0, 0 }, |
||
849 | { "m_ffire", USERDEFS_M_FFIRE, 0, 0 }, |
||
850 | { "ffire", USERDEFS_FFIRE, 0, 0 }, |
||
851 | { "m_player_skill", USERDEFS_M_PLAYER_SKILL, 0, 0 }, |
||
852 | { "m_level_number", USERDEFS_M_LEVEL_NUMBER, 0, 0 }, |
||
853 | { "m_volume_number", USERDEFS_M_VOLUME_NUMBER, 0, 0 }, |
||
854 | { "multimode", USERDEFS_MULTIMODE, 0, 0 }, |
||
855 | { "player_skill", USERDEFS_PLAYER_SKILL, 0, 0 }, |
||
856 | { "level_number", USERDEFS_LEVEL_NUMBER, 0, 0 }, |
||
857 | { "volume_number", USERDEFS_VOLUME_NUMBER, 0, 0 }, |
||
858 | { "m_marker", USERDEFS_M_MARKER, 0, 0 }, |
||
859 | { "marker", USERDEFS_MARKER, 0, 0 }, |
||
860 | { "mouseflip", USERDEFS_MOUSEFLIP, 0, 0 }, |
||
861 | { "statusbarscale", USERDEFS_STATUSBARSCALE, 0, 0 }, |
||
862 | { "drawweapon", USERDEFS_DRAWWEAPON, 0, 0 }, |
||
863 | { "mouseaiming", USERDEFS_MOUSEAIMING, 0, 0 }, |
||
864 | { "weaponswitch", USERDEFS_WEAPONSWITCH, 0, 0 }, |
||
865 | { "democams", USERDEFS_DEMOCAMS, 0, 0 }, |
||
866 | { "color", USERDEFS_COLOR, 0, 0 }, |
||
867 | { "msgdisptime", USERDEFS_MSGDISPTIME, 0, 0 }, |
||
868 | { "statusbarmode", USERDEFS_STATUSBARMODE, 0, 0 }, |
||
869 | { "m_noexits", USERDEFS_M_NOEXITS, 0, 0 }, |
||
870 | { "noexits", USERDEFS_NOEXITS, 0, 0 }, |
||
871 | { "autovote", USERDEFS_AUTOVOTE, 0, 0 }, |
||
872 | { "automsg", USERDEFS_AUTOMSG, 0, 0 }, |
||
873 | { "idplayers", USERDEFS_IDPLAYERS, 0, 0 }, |
||
874 | { "team", USERDEFS_TEAM, 0, 0 }, |
||
875 | { "viewbob", USERDEFS_VIEWBOB, 0, 0 }, |
||
876 | { "weaponsway", USERDEFS_WEAPONSWAY, 0, 0 }, |
||
877 | { "angleinterpolation", USERDEFS_ANGLEINTERPOLATION, 0, 0 }, |
||
878 | { "deathmsgs", USERDEFS_DEATHMSGS, 0, 0 }, |
||
674 | terminx | 879 | { "levelstats", USERDEFS_LEVELSTATS, 0, 0 }, |
881 | terminx | 880 | { "crosshairscale", USERDEFS_CROSSHAIRSCALE, 0, 0 }, |
559 | terminx | 881 | { "", -1, 0, 0 } // END OF LIST |
882 | }; |
||
5 | Plagman | 883 | |
859 | terminx | 884 | const memberlabel_t inputlabels[]= |
559 | terminx | 885 | { |
886 | { "avel", INPUT_AVEL, 0, 0 }, |
||
887 | { "horz", INPUT_HORZ, 0, 0 }, |
||
888 | { "fvel", INPUT_FVEL, 0, 0 }, |
||
889 | { "svel", INPUT_SVEL, 0, 0 }, |
||
890 | { "bits", INPUT_BITS, 0, 0 }, |
||
891 | { "extbits", INPUT_EXTBITS, 0, 0 }, |
||
892 | { "", -1, 0, 0 } // END OF LIST |
||
893 | }; |
||
5 | Plagman | 894 | |
874 | terminx | 895 | static int increasescriptsize(int size) |
896 | { |
||
897 | intptr_t oscriptptr = (unsigned)(scriptptr-script); |
||
898 | intptr_t ocasescriptptr = (unsigned)(casescriptptr-script); |
||
899 | intptr_t oparsing_event = (unsigned)(parsing_event-script); |
||
900 | intptr_t oparsing_actor = (unsigned)(parsing_actor-script); |
||
901 | char *scriptptrs; |
||
902 | intptr_t *newscript; |
||
903 | intptr_t i, j; |
||
904 | int osize = g_ScriptSize; |
||
905 | |||
906 | for (i=0;i<MAXSECTORS;i++) |
||
907 | { |
||
908 | if (labelcode[i] && labeltype[i] != LABEL_DEFINE) |
||
909 | { |
||
910 | labelcode[i] -= (intptr_t)&script[0]; |
||
911 | } |
||
912 | } |
||
913 | |||
914 | scriptptrs = Bcalloc(1,g_ScriptSize * sizeof(char)); |
||
915 | for (i=0;i<g_ScriptSize;i++) |
||
916 | { |
||
917 | // initprintf("%d\n",i); |
||
918 | if ((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_ScriptSize])) |
||
919 | { |
||
920 | scriptptrs[i] = 1; |
||
921 | j = (intptr_t)script[i] - (intptr_t)&script[0]; |
||
922 | script[i] = j; |
||
923 | } |
||
924 | else scriptptrs[i] = 0; |
||
925 | } |
||
926 | |||
927 | for (i=0;i<MAXTILES;i++) |
||
928 | if (actorscrptr[i]) |
||
929 | { |
||
930 | j = (intptr_t)actorscrptr[i]-(intptr_t)&script[0]; |
||
931 | actorscrptr[i] = (intptr_t *)j; |
||
932 | } |
||
933 | |||
934 | for (i=0;i<MAXTILES;i++) |
||
935 | if (actorLoadEventScrptr[i]) |
||
936 | { |
||
937 | j = (intptr_t)actorLoadEventScrptr[i]-(intptr_t)&script[0]; |
||
938 | actorLoadEventScrptr[i] = (intptr_t *)j; |
||
939 | } |
||
940 | |||
941 | for (i=0;i<MAXGAMEEVENTS;i++) |
||
942 | if (apScriptGameEvent[i]) |
||
943 | { |
||
944 | j = (intptr_t)apScriptGameEvent[i]-(intptr_t)&script[0]; |
||
945 | apScriptGameEvent[i] = (intptr_t *)j; |
||
946 | } |
||
947 | |||
948 | //initprintf("offset: %d\n",(unsigned)(scriptptr-script)); |
||
949 | g_ScriptSize = size; |
||
950 | initprintf("Increasing script buffer size to %d bytes...\n",g_ScriptSize); |
||
951 | newscript = (intptr_t *)Brealloc(script, g_ScriptSize * sizeof(intptr_t)); |
||
952 | |||
953 | if (newscript == NULL) |
||
954 | { |
||
955 | ReportError(-1); |
||
956 | initprintf("%s:%d: out of memory: Aborted (%ud)\n",compilefile,line_number,(unsigned)(scriptptr-script)); |
||
957 | initprintf(tempbuf); |
||
958 | error++; |
||
959 | return 1; |
||
960 | } |
||
961 | script = newscript; |
||
962 | scriptptr = (intptr_t *)(script+oscriptptr); |
||
963 | //initprintf("offset: %d\n",(unsigned)(scriptptr-script)); |
||
964 | if (casescriptptr != NULL) |
||
965 | casescriptptr = (intptr_t *)(script+ocasescriptptr); |
||
966 | if (parsing_event != NULL) |
||
967 | parsing_event = (intptr_t *)(script+oparsing_event); |
||
968 | if (parsing_actor != NULL) |
||
969 | parsing_actor = (intptr_t *)(script+oparsing_actor); |
||
970 | |||
971 | for (i=0;i<MAXSECTORS;i++) |
||
972 | { |
||
973 | if (labelcode[i] && labeltype[i] != LABEL_DEFINE) |
||
974 | { |
||
975 | labelcode[i] += (intptr_t)&script[0]; |
||
976 | } |
||
977 | } |
||
978 | |||
979 | for (i=0;i<g_ScriptSize-(size-osize);i++) |
||
980 | if (scriptptrs[i]) |
||
981 | { |
||
982 | j = (intptr_t)script[i]+(intptr_t)&script[0]; |
||
983 | script[i] = j; |
||
984 | } |
||
985 | |||
986 | for (i=0;i<MAXTILES;i++) |
||
987 | if (actorscrptr[i]) |
||
988 | { |
||
989 | j = (intptr_t)actorscrptr[i]+(intptr_t)&script[0]; |
||
990 | actorscrptr[i] = (intptr_t *)j; |
||
991 | } |
||
992 | |||
993 | for (i=0;i<MAXTILES;i++) |
||
994 | if (actorLoadEventScrptr[i]) |
||
995 | { |
||
996 | j = (intptr_t)actorLoadEventScrptr[i]+(intptr_t)&script[0]; |
||
997 | actorLoadEventScrptr[i] = (intptr_t *)j; |
||
998 | } |
||
999 | |||
1000 | for (i=0;i<MAXGAMEEVENTS;i++) |
||
1001 | if (apScriptGameEvent[i]) |
||
1002 | { |
||
1003 | j = (intptr_t)apScriptGameEvent[i]+(intptr_t)&script[0]; |
||
1004 | apScriptGameEvent[i] = (intptr_t *)j; |
||
1005 | } |
||
1006 | Bfree(scriptptrs); |
||
1007 | return 0; |
||
1008 | } |
||
1009 | |||
570 | terminx | 1010 | static int skipcomments(void) |
5 | Plagman | 1011 | { |
1012 | char c; |
||
484 | terminx | 1013 | |
5 | Plagman | 1014 | while ((c = *textptr)) |
1015 | { |
||
1016 | if (c == ' ' || c == '\t' || c == '\r') |
||
1017 | textptr++; |
||
335 | terminx | 1018 | else if (c == '\n') |
1019 | { |
||
5 | Plagman | 1020 | line_number++; |
1021 | textptr++; |
||
1022 | } |
||
1023 | else if (c == '/' && textptr[1] == '/') |
||
1024 | { |
||
564 | terminx | 1025 | if (!(error || warning) && g_ScriptDebug > 1) |
584 | terminx | 1026 | initprintf("%s:%d: debug: got comment.\n",compilefile,line_number); |
333 | terminx | 1027 | while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) |
5 | Plagman | 1028 | textptr++; |
1029 | } |
||
1030 | else if (c == '/' && textptr[1] == '*') |
||
1031 | { |
||
564 | terminx | 1032 | if (!(error || warning) && g_ScriptDebug > 1) |
584 | terminx | 1033 | initprintf("%s:%d: debug: got start of comment block.\n",compilefile,line_number); |
5 | Plagman | 1034 | while (*textptr && !(textptr[0] == '*' && textptr[1] == '/')) |
1035 | { |
||
1036 | if (*textptr == '\n') |
||
1037 | line_number++; |
||
1038 | textptr++; |
||
1039 | } |
||
564 | terminx | 1040 | if ((!(error || warning) && g_ScriptDebug > 1) && (textptr[0] == '*' && textptr[1] == '/')) |
584 | terminx | 1041 | initprintf("%s:%d: debug: got end of comment block.\n",compilefile,line_number); |
5 | Plagman | 1042 | if (!*textptr) |
1043 | { |
||
564 | terminx | 1044 | if (!(error || warning) && g_ScriptDebug) |
584 | terminx | 1045 | initprintf("%s:%d: debug: EOF in comment!\n",compilefile,line_number); |
5 | Plagman | 1046 | ReportError(-1); |
584 | terminx | 1047 | initprintf("%s:%d: error: found `/*' with no `*/'.\n",compilefile,line_number); |
5 | Plagman | 1048 | parsing_state = num_braces = 0; |
1049 | parsing_actor = 0; |
||
1050 | error++; |
||
1051 | break; |
||
1052 | } |
||
1053 | else textptr+=2; |
||
1054 | } |
||
1055 | else break; |
||
1056 | } |
||
570 | terminx | 1057 | |
1058 | if ((unsigned)(scriptptr-script) > (unsigned)(g_ScriptSize-32)) |
||
874 | terminx | 1059 | return increasescriptsize(g_ScriptSize+16384); |
570 | terminx | 1060 | |
1061 | return 0; |
||
5 | Plagman | 1062 | } |
1063 | |||
584 | terminx | 1064 | static void DefineProjectile(int lVar1, int lLabelID, int lVar2) |
5 | Plagman | 1065 | { |
331 | terminx | 1066 | switch (lLabelID) |
5 | Plagman | 1067 | { |
337 | terminx | 1068 | case PROJ_WORKSLIKE: |
1069 | projectile[lVar1].workslike=lVar2; |
||
1070 | break; |
||
5 | Plagman | 1071 | |
337 | terminx | 1072 | case PROJ_SPAWNS: |
1073 | projectile[lVar1].spawns=lVar2; |
||
1074 | break; |
||
5 | Plagman | 1075 | |
337 | terminx | 1076 | case PROJ_SXREPEAT: |
1077 | projectile[lVar1].sxrepeat=lVar2; |
||
1078 | break; |
||
5 | Plagman | 1079 | |
337 | terminx | 1080 | case PROJ_SYREPEAT: |
1081 | projectile[lVar1].syrepeat=lVar2; |
||
1082 | break; |
||
5 | Plagman | 1083 | |
337 | terminx | 1084 | case PROJ_SOUND: |
1085 | projectile[lVar1].sound=lVar2; |
||
1086 | break; |
||
5 | Plagman | 1087 | |
337 | terminx | 1088 | case PROJ_ISOUND: |
1089 | projectile[lVar1].isound=lVar2; |
||
1090 | break; |
||
5 | Plagman | 1091 | |
337 | terminx | 1092 | case PROJ_VEL: |
1093 | projectile[lVar1].vel=lVar2; |
||
1094 | break; |
||
5 | Plagman | 1095 | |
337 | terminx | 1096 | case PROJ_EXTRA: |
1097 | projectile[lVar1].extra=lVar2; |
||
1098 | break; |
||
5 | Plagman | 1099 | |
337 | terminx | 1100 | case PROJ_DECAL: |
1101 | projectile[lVar1].decal=lVar2; |
||
1102 | break; |
||
5 | Plagman | 1103 | |
337 | terminx | 1104 | case PROJ_TRAIL: |
1105 | projectile[lVar1].trail=lVar2; |
||
1106 | break; |
||
5 | Plagman | 1107 | |
337 | terminx | 1108 | case PROJ_TXREPEAT: |
1109 | projectile[lVar1].txrepeat=lVar2; |
||
1110 | break; |
||
5 | Plagman | 1111 | |
337 | terminx | 1112 | case PROJ_TYREPEAT: |
1113 | projectile[lVar1].tyrepeat=lVar2; |
||
1114 | break; |
||
5 | Plagman | 1115 | |
337 | terminx | 1116 | case PROJ_TOFFSET: |
1117 | projectile[lVar1].toffset=lVar2; |
||
1118 | break; |
||
5 | Plagman | 1119 | |
337 | terminx | 1120 | case PROJ_TNUM: |
1121 | projectile[lVar1].tnum=lVar2; |
||
1122 | break; |
||
5 | Plagman | 1123 | |
337 | terminx | 1124 | case PROJ_DROP: |
1125 | projectile[lVar1].drop=lVar2; |
||
1126 | break; |
||
5 | Plagman | 1127 | |
337 | terminx | 1128 | case PROJ_CSTAT: |
1129 | projectile[lVar1].cstat=lVar2; |
||
1130 | break; |
||
5 | Plagman | 1131 | |
337 | terminx | 1132 | case PROJ_CLIPDIST: |
1133 | projectile[lVar1].clipdist=lVar2; |
||
1134 | break; |
||
5 | Plagman | 1135 | |
337 | terminx | 1136 | case PROJ_SHADE: |
1137 | projectile[lVar1].shade=lVar2; |
||
1138 | break; |
||
5 | Plagman | 1139 | |
337 | terminx | 1140 | case PROJ_XREPEAT: |
1141 | projectile[lVar1].xrepeat=lVar2; |
||
1142 | break; |
||
5 | Plagman | 1143 | |
337 | terminx | 1144 | case PROJ_YREPEAT: |
1145 | projectile[lVar1].yrepeat=lVar2; |
||
1146 | break; |
||
5 | Plagman | 1147 | |
337 | terminx | 1148 | case PROJ_PAL: |
1149 | projectile[lVar1].pal=lVar2; |
||
1150 | break; |
||
5 | Plagman | 1151 | |
337 | terminx | 1152 | case PROJ_EXTRA_RAND: |
1153 | projectile[lVar1].extra_rand=lVar2; |
||
1154 | break; |
||
5 | Plagman | 1155 | |
337 | terminx | 1156 | case PROJ_HITRADIUS: |
1157 | projectile[lVar1].hitradius=lVar2; |
||
1158 | break; |
||
5 | Plagman | 1159 | |
337 | terminx | 1160 | case PROJ_VEL_MULT: |
1161 | projectile[lVar1].velmult=lVar2; |
||
1162 | break; |
||
5 | Plagman | 1163 | |
337 | terminx | 1164 | case PROJ_OFFSET: |
1165 | projectile[lVar1].offset=lVar2; |
||
1166 | break; |
||
5 | Plagman | 1167 | |
337 | terminx | 1168 | case PROJ_BOUNCES: |
1169 | projectile[lVar1].bounces=lVar2; |
||
1170 | break; |
||
5 | Plagman | 1171 | |
337 | terminx | 1172 | case PROJ_BSOUND: |
1173 | projectile[lVar1].bsound=lVar2; |
||
1174 | break; |
||
5 | Plagman | 1175 | |
337 | terminx | 1176 | case PROJ_RANGE: |
1177 | projectile[lVar1].range=lVar2; |
||
1178 | break; |
||
5 | Plagman | 1179 | |
337 | terminx | 1180 | default: |
1181 | break; |
||
5 | Plagman | 1182 | } |
1183 | |||
1184 | // defaultprojectile[lVar1] = projectile[lVar1]; |
||
1185 | Bmemcpy(&defaultprojectile[lVar1], &projectile[lVar1], sizeof(projectile[lVar1])); |
||
1186 | |||
1187 | return; |
||
1188 | } |
||
1189 | |||
546 | terminx | 1190 | static int CheckEventSync(int iEventID) |
5 | Plagman | 1191 | { |
331 | terminx | 1192 | if (parsing_event || parsing_actor) |
5 | Plagman | 1193 | { |
331 | terminx | 1194 | switch (iEventID) |
5 | Plagman | 1195 | { |
853 | terminx | 1196 | case EVENT_ANIMATESPRITES: |
337 | terminx | 1197 | case EVENT_CHEATGETSTEROIDS: |
1198 | case EVENT_CHEATGETHEAT: |
||
1199 | case EVENT_CHEATGETBOOT: |
||
1200 | case EVENT_CHEATGETSHIELD: |
||
1201 | case EVENT_CHEATGETSCUBA: |
||
1202 | case EVENT_CHEATGETHOLODUKE: |
||
1203 | case EVENT_CHEATGETJETPACK: |
||
1204 | case EVENT_CHEATGETFIRSTAID: |
||
1205 | case EVENT_DISPLAYCROSSHAIR: |
||
1206 | case EVENT_DISPLAYREST: |
||
763 | terminx | 1207 | case EVENT_DISPLAYBONUSSCREEN: |
1208 | case EVENT_DISPLAYMENU: |
||
1209 | case EVENT_DISPLAYMENUREST: |
||
1210 | case EVENT_DISPLAYLOADINGSCREEN: |
||
487 | terminx | 1211 | case EVENT_DISPLAYROOMS: |
492 | terminx | 1212 | case EVENT_DISPLAYSBAR: |
491 | terminx | 1213 | case EVENT_DISPLAYWEAPON: |
1214 | case EVENT_DRAWWEAPON: |
||
337 | terminx | 1215 | case EVENT_ENTERLEVEL: |
1216 | case EVENT_FAKEDOMOVETHINGS: |
||
1217 | case EVENT_GETLOADTILE: |
||
1218 | case EVENT_GETMENUTILE: |
||
1219 | case EVENT_INIT: |
||
1220 | case EVENT_LOGO: |
||
1221 | return 0; |
||
1222 | default: |
||
1223 | return 1; |
||
5 | Plagman | 1224 | } |
1225 | } |
||
1226 | return 1; |
||
1227 | } |
||
1228 | |||
484 | terminx | 1229 | #if 0 |
1230 | void AddLog(const char *psz, ...) |
||
5 | Plagman | 1231 | { |
484 | terminx | 1232 | va_list va; |
1233 | |||
1234 | va_start(va, psz); |
||
1235 | Bvsnprintf(tempbuf, sizeof(tempbuf), psz, va); |
||
1236 | va_end(va); |
||
1237 | |||
1238 | if (tempbuf[Bstrlen(tempbuf)] != '\n') |
||
5 | Plagman | 1239 | Bstrcat(tempbuf,"\n"); |
1240 | if (qsetmode == 200) OSD_Printf(tempbuf); |
||
1241 | else initprintf(tempbuf); |
||
1242 | } |
||
484 | terminx | 1243 | #endif |
5 | Plagman | 1244 | |
584 | terminx | 1245 | static int GetDefID(const char *szGameLabel) |
5 | Plagman | 1246 | { |
1247 | int i; |
||
331 | terminx | 1248 | for (i=0;i<iGameVarCount;i++) |
5 | Plagman | 1249 | { |
331 | terminx | 1250 | if (aGameVars[i].szLabel != NULL) |
5 | Plagman | 1251 | { |
333 | terminx | 1252 | if (Bstrcmp(szGameLabel, aGameVars[i].szLabel) == 0) |
102 | terminx | 1253 | { |
1254 | return i; |
||
1255 | } |
||
5 | Plagman | 1256 | } |
1257 | } |
||
1258 | return -1; |
||
1259 | } |
||
676 | terminx | 1260 | static int GetADefID(const char *szGameLabel) |
1261 | { |
||
1262 | int i; |
||
1263 | // initprintf("iGameArrayCount is %i\n",iGameArrayCount); |
||
1264 | for (i=0;i<iGameArrayCount;i++) |
||
1265 | { |
||
1266 | if (aGameArrays[i].szLabel != NULL) |
||
1267 | { |
||
1268 | if (Bstrcmp(szGameLabel, aGameArrays[i].szLabel) == 0) |
||
1269 | { |
||
1270 | return i; |
||
1271 | } |
||
1272 | } |
||
1273 | } |
||
1274 | // initprintf("game array %s not found\n",szGameLabel); |
||
1275 | return -1; |
||
1276 | } |
||
437 | terminx | 1277 | static int ispecial(char c) |
5 | Plagman | 1278 | { |
331 | terminx | 1279 | if (c == 0x0a) |
5 | Plagman | 1280 | { |
1281 | line_number++; |
||
1282 | return 1; |
||
1283 | } |
||
1284 | |||
331 | terminx | 1285 | if (c == ' ' || c == 0x0d) |
5 | Plagman | 1286 | return 1; |
1287 | |||
1288 | return 0; |
||
1289 | } |
||
1290 | |||
398 | terminx | 1291 | static inline int isaltok(char c) |
5 | Plagman | 1292 | { |
333 | terminx | 1293 | return (isalnum(c) || c == '{' || c == '}' || c == '/' || c == '*' || c == '-' || c == '_' || c == '.'); |
5 | Plagman | 1294 | } |
1295 | |||
616 | terminx | 1296 | static int getlabelid(const memberlabel_t *pLabel, const char *psz) |
5 | Plagman | 1297 | { |
1298 | // find the label psz in the table pLabel. |
||
1299 | // returns the ID for the label, or -1 |
||
1300 | |||
584 | terminx | 1301 | int l=-1; |
5 | Plagman | 1302 | int i; |
1303 | |||
331 | terminx | 1304 | for (i=0;pLabel[i].lId >=0 ; i++) |
5 | Plagman | 1305 | { |
331 | terminx | 1306 | if (!Bstrcasecmp(pLabel[i].name,psz)) |
5 | Plagman | 1307 | { |
1308 | l= pLabel[i].lId; |
||
1309 | break; // stop for loop |
||
1310 | } |
||
1311 | } |
||
1312 | return l; |
||
1313 | } |
||
1314 | |||
616 | terminx | 1315 | static int getlabeloffset(const memberlabel_t *pLabel, const char *psz) |
5 | Plagman | 1316 | { |
1317 | // find the label psz in the table pLabel. |
||
1318 | // returns the offset in the array for the label, or -1 |
||
1319 | int i; |
||
1320 | |||
331 | terminx | 1321 | for (i=0;pLabel[i].lId >=0 ; i++) |
5 | Plagman | 1322 | { |
331 | terminx | 1323 | if (!Bstrcasecmp(pLabel[i].name,psz)) |
5 | Plagman | 1324 | { |
1325 | // printf("Label has flags of %02X\n",pLabel[i].flags); |
||
1326 | return i; |
||
1327 | } |
||
1328 | } |
||
1329 | return -1; |
||
1330 | } |
||
1331 | |||
398 | terminx | 1332 | static void getlabel(void) |
5 | Plagman | 1333 | { |
584 | terminx | 1334 | int i; |
5 | Plagman | 1335 | |
1336 | skipcomments(); |
||
1337 | |||
333 | terminx | 1338 | while (isalnum(*textptr) == 0) |
5 | Plagman | 1339 | { |
331 | terminx | 1340 | if (*textptr == 0x0a) line_number++; |
5 | Plagman | 1341 | textptr++; |
333 | terminx | 1342 | if (*textptr == 0) |
5 | Plagman | 1343 | return; |
1344 | } |
||
1345 | |||
1346 | i = 0; |
||
676 | terminx | 1347 | while (ispecial(*textptr) == 0 && *textptr!='['&& *textptr!=']' && *textptr!='\t' && *textptr!='\n' && *textptr!='\r') |
5 | Plagman | 1348 | label[(labelcnt<<6)+i++] = *(textptr++); |
1349 | |||
1350 | label[(labelcnt<<6)+i] = 0; |
||
564 | terminx | 1351 | if (!(error || warning) && g_ScriptDebug > 1) |
584 | terminx | 1352 | initprintf("%s:%d: debug: got label `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); |
5 | Plagman | 1353 | } |
1354 | |||
584 | terminx | 1355 | static int keyword(void) |
5 | Plagman | 1356 | { |
584 | terminx | 1357 | int i; |
5 | Plagman | 1358 | char *temptextptr; |
1359 | |||
1360 | skipcomments(); |
||
1361 | |||
1362 | temptextptr = textptr; |
||
1363 | |||
333 | terminx | 1364 | while (isaltok(*temptextptr) == 0) |
5 | Plagman | 1365 | { |
1366 | temptextptr++; |
||
333 | terminx | 1367 | if (*temptextptr == 0) |
5 | Plagman | 1368 | return 0; |
1369 | } |
||
1370 | |||
1371 | i = 0; |
||
333 | terminx | 1372 | while (isaltok(*temptextptr)) |
5 | Plagman | 1373 | { |
1374 | tempbuf[i] = *(temptextptr++); |
||
1375 | i++; |
||
1376 | } |
||
1377 | tempbuf[i] = 0; |
||
331 | terminx | 1378 | for (i=0;i<NUMKEYWORDS;i++) |
333 | terminx | 1379 | if (Bstrcmp(tempbuf,keyw[i]) == 0) |
5 | Plagman | 1380 | return i; |
1381 | |||
1382 | return -1; |
||
1383 | } |
||
1384 | |||
584 | terminx | 1385 | static int transword(void) //Returns its code # |
5 | Plagman | 1386 | { |
584 | terminx | 1387 | int i, l; |
5 | Plagman | 1388 | |
1389 | skipcomments(); |
||
1390 | |||
333 | terminx | 1391 | while (isaltok(*textptr) == 0) |
5 | Plagman | 1392 | { |
331 | terminx | 1393 | if (*textptr == 0x0a) line_number++; |
333 | terminx | 1394 | if (*textptr == 0) |
5 | Plagman | 1395 | return -1; |
1396 | textptr++; |
||
1397 | } |
||
1398 | |||
1399 | l = 0; |
||
333 | terminx | 1400 | while (isaltok(*(textptr+l)) && !(*(textptr + l) == '.')) |
5 | Plagman | 1401 | { |
1402 | tempbuf[l] = textptr[l]; |
||
1403 | l++; |
||
1404 | } |
||
333 | terminx | 1405 | while (isaltok(*(textptr+l))) |
5 | Plagman | 1406 | { |
1407 | tempbuf[l] = textptr[l]; |
||
1408 | l++; |
||
1409 | } |
||
1410 | tempbuf[l] = 0; |
||
1411 | |||
331 | terminx | 1412 | for (i=0;i<NUMKEYWORDS;i++) |
5 | Plagman | 1413 | { |
333 | terminx | 1414 | if (Bstrcmp(tempbuf,keyw[i]) == 0) |
5 | Plagman | 1415 | { |
871 | hnt_ts | 1416 | *scriptptr = i + (line_number<<12); |
5 | Plagman | 1417 | textptr += l; |
1418 | scriptptr++; |
||
564 | terminx | 1419 | if (!(error || warning) && g_ScriptDebug) |
584 | terminx | 1420 | initprintf("%s:%d: debug: translating keyword `%s'.\n",compilefile,line_number,keyw[i]); |
5 | Plagman | 1421 | return i; |
1422 | } |
||
1423 | } |
||
1424 | |||
1425 | textptr += l; |
||
1426 | |||
333 | terminx | 1427 | if (tempbuf[0] == '{' && tempbuf[1] != 0) |
5 | Plagman | 1428 | { |
1429 | ReportError(-1); |
||
584 | terminx | 1430 | initprintf("%s:%d: error: expected a SPACE or CR between `{' and `%s'.\n",compilefile,line_number,tempbuf+1); |
5 | Plagman | 1431 | } |
333 | terminx | 1432 | else if (tempbuf[0] == '}' && tempbuf[1] != 0) |
5 | Plagman | 1433 | { |
1434 | ReportError(-1); |
||
584 | terminx | 1435 | initprintf("%s:%d: error: expected a SPACE or CR between `}' and `%s'.\n",compilefile,line_number,tempbuf+1); |
5 | Plagman | 1436 | } |
1437 | else ReportError(ERROR_EXPECTEDKEYWORD); |
||
1438 | error++; |
||
1439 | return -1; |
||
1440 | } |
||
1441 | |||
398 | terminx | 1442 | static void transvartype(int type) |
5 | Plagman | 1443 | { |
91 | terminx | 1444 | int i=0,f=0; |
5 | Plagman | 1445 | |
1446 | skipcomments(); |
||
331 | terminx | 1447 | if (!type && !labelsonly && (isdigit(*textptr) || ((*textptr == '-') && (isdigit(*(textptr+1)))))) |
5 | Plagman | 1448 | { |
564 | terminx | 1449 | if (!(error || warning) && g_ScriptDebug) |
584 | terminx | 1450 | initprintf("%s:%d: debug: accepted constant %d in place of gamevar.\n",compilefile,line_number,atol(textptr)); |
5 | Plagman | 1451 | *scriptptr++=MAXGAMEVARS; |
622 | terminx | 1452 | if (tolower(textptr[1])=='x') |
795 | terminx | 1453 | sscanf(textptr+2,"%" PRIxPTR "",scriptptr); |
622 | terminx | 1454 | else |
1455 | *scriptptr=atol(textptr); |
||
587 | terminx | 1456 | scriptptr++; |
5 | Plagman | 1457 | getlabel(); |
1458 | return; |
||
1459 | } |
||
331 | terminx | 1460 | else if ((*textptr == '-') && !isdigit(*(textptr+1))) |
5 | Plagman | 1461 | { |
331 | terminx | 1462 | if (!type) |
5 | Plagman | 1463 | { |
564 | terminx | 1464 | if (!(error || warning) && g_ScriptDebug) |
584 | terminx | 1465 | initprintf("%s:%d: debug: flagging gamevar as negative.\n",compilefile,line_number,atol(textptr)); |
5 | Plagman | 1466 | f = (MAXGAMEVARS<<1); |
1467 | } |
||
1468 | else |
||
1469 | { |
||
1470 | error++; |
||
1471 | ReportError(ERROR_SYNTAXERROR); |
||
1472 | getlabel(); |
||
1473 | return; |
||
1474 | } |
||
1475 | } |
||
1476 | getlabel(); |
||
676 | terminx | 1477 | |
331 | terminx | 1478 | if (!nokeywordcheck) |
1479 | for (i=0;i<NUMKEYWORDS;i++) |
||
333 | terminx | 1480 | if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0) |
5 | Plagman | 1481 | { |
1482 | error++; |
||
1483 | ReportError(ERROR_ISAKEYWORD); |
||
1484 | return; |
||
1485 | } |
||
676 | terminx | 1486 | |
1487 | skipcomments(); //skip comments and whitespace |
||
1488 | if ((*textptr == '[')) //read of array as a gamevar |
||
1489 | { |
||
715 | terminx | 1490 | f |= (MAXGAMEVARS<<2); |
676 | terminx | 1491 | // initprintf("got an array"); |
1492 | textptr++; |
||
1493 | i=GetADefID(label+(labelcnt<<6)); |
||
715 | terminx | 1494 | if (i < 0) |
676 | terminx | 1495 | { |
1496 | error++; |
||
1497 | ReportError(ERROR_NOTAGAMEARRAY); |
||
1498 | return; |
||
1499 | } |
||
1500 | |||
715 | terminx | 1501 | *scriptptr++=(i|f); |
1502 | transvartype(0); |
||
676 | terminx | 1503 | skipcomments(); //skip comments and whitespace |
715 | terminx | 1504 | |
676 | terminx | 1505 | if (*textptr != ']') |
1506 | { |
||
1507 | error++; |
||
1508 | ReportError(ERROR_GAMEARRAYBNC); |
||
1509 | return; |
||
1510 | } |
||
1511 | textptr++; |
||
1512 | if (type) //writing arrays in this way is not supported because it would require too many changes to other code |
||
1513 | { |
||
1514 | error++; |
||
1515 | ReportError(ERROR_INVALIDARRAYWRITE); |
||
1516 | return; |
||
1517 | } |
||
1518 | return; |
||
1519 | } |
||
1520 | // initprintf("not an array"); |
||
5 | Plagman | 1521 | i=GetDefID(label+(labelcnt<<6)); |
676 | terminx | 1522 | if (i<0) //gamevar not found |
5 | Plagman | 1523 | { |
331 | terminx | 1524 | if (!type && !labelsonly) |
5 | Plagman | 1525 | { |
676 | terminx | 1526 | //try looking for a define instead |
5 | Plagman | 1527 | Bstrcpy(tempbuf,label+(labelcnt<<6)); |
331 | terminx | 1528 | for (i=0;i<labelcnt;i++) |
5 | Plagman | 1529 | { |
333 | terminx | 1530 | if (Bstrcmp(tempbuf,label+(i<<6)) == 0 && (labeltype[i] & LABEL_DEFINE)) |
5 | Plagman | 1531 | { |
564 | terminx | 1532 | if (!(error || warning) && g_ScriptDebug) |
584 | terminx | 1533 | initprintf("%s:%d: debug: accepted defined label `%s' instead of gamevar.\n",compilefile,line_number,label+(i<<6)); |
5 | Plagman | 1534 | *scriptptr++=MAXGAMEVARS; |
1535 | *scriptptr++=labelcode[i]; |
||
1536 | return; |
||
1537 | } |
||
1538 | } |
||
1539 | error++; |
||
1540 | ReportError(ERROR_NOTAGAMEVAR); |
||
1541 | return; |
||
1542 | } |
||
437 | terminx | 1543 | error++; |
1544 | ReportError(ERROR_NOTAGAMEVAR); |
||
1545 | textptr++; |
||
1546 | return; |
||
676 | terminx | 1547 | |
5 | Plagman | 1548 | } |
331 | terminx | 1549 | if (type == GAMEVAR_FLAG_READONLY && aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY) |
5 | Plagman | 1550 | { |
1551 | error++; |
||
1552 | ReportError(ERROR_VARREADONLY); |
||
1553 | return; |
||
1554 | } |
||
331 | terminx | 1555 | else if (aGameVars[i].dwFlags & type) |
5 | Plagman | 1556 | { |
1557 | error++; |
||
1558 | ReportError(ERROR_VARTYPEMISMATCH); |
||
1559 | return; |
||
1560 | } |
||
331 | terminx | 1561 | if ((aGameVars[i].dwFlags & GAMEVAR_FLAG_SYNCCHECK) && parsing_actor && CheckEventSync(current_event)) |
5 | Plagman | 1562 | { |
1563 | ReportError(-1); |
||
584 | terminx | 1564 | initprintf("%s:%d: warning: found local gamevar `%s' used within %s; expect multiplayer synchronization issues.\n",compilefile,line_number,label+(labelcnt<<6),parsing_event?"a synced event":"an actor"); |
5 | Plagman | 1565 | } |
564 | terminx | 1566 | if (!(error || warning) && g_ScriptDebug > 1) |
584 | terminx | 1567 | initprintf("%s:%d: debug: accepted gamevar `%s'.\n",compilefile,line_number,label+(labelcnt<<6)); |
715 | terminx | 1568 | |
1569 | *scriptptr++=(i|f); |
||
5 | Plagman | 1570 | } |
1571 | |||
296 | terminx | 1572 | static inline void transvar(void) |
5 | Plagman | 1573 | { |
1574 | transvartype(0); |
||
1575 | } |
||
1576 | |||
437 | terminx | 1577 | static inline void transmultvarstype(int type, int num) |
5 | Plagman | 1578 | { |
437 | terminx | 1579 | int i; |
331 | terminx | 1580 | for (i=0;i<num;i++) |
5 | Plagman | 1581 | transvartype(type); |
1582 | } |
||
1583 | |||
437 | terminx | 1584 | static inline void transmultvars(int num) |
5 | Plagman | 1585 | { |
1586 | transmultvarstype(0,num); |
||
1587 | } |
||
1588 | |||
584 | terminx | 1589 | static int transnum(int type) |
5 | Plagman | 1590 | { |
584 | terminx | 1591 | int i, l; |
5 | Plagman | 1592 | |
1593 | skipcomments(); |
||
1594 | |||
333 | terminx | 1595 | while (isaltok(*textptr) == 0) |
5 | Plagman | 1596 | { |
331 | terminx | 1597 | if (*textptr == 0x0a) line_number++; |
5 | Plagman | 1598 | textptr++; |
333 | terminx | 1599 | if (*textptr == 0) |
5 | Plagman | 1600 | return -1; // eof |
1601 | } |
||
1602 | |||
1603 | l = 0; |
||
333 | terminx | 1604 | while (isaltok(*(textptr+l))) |
5 | Plagman | 1605 | { |
1606 | tempbuf[l] = textptr[l]; |
||
1607 | l++; |
||
1608 | } |
||
1609 | tempbuf[l] = 0; |
||
1610 | |||
331 | terminx | 1611 | if (!nokeywordcheck) |
1612 | for (i=0;i<NUMKEYWORDS;i++) |
||
333 | terminx | 1613 | if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0) |
5 | Plagman | 1614 | { |
1615 | error++; |
||
1616 | ReportError(ERROR_ISAKEYWORD); |
||
1617 | textptr+=l; |
||
1618 | } |
||
121 | terminx | 1619 | |
331 | terminx | 1620 | for (i=0;i<labelcnt;i++) |
5 | Plagman | 1621 | { |
333 | terminx | 1622 | if (!Bstrcmp(tempbuf,label+(i<<6))) |
5 | Plagman | 1623 | { |
1624 | char *el,*gl; |
||
1625 | |||
1626 | if (labeltype[i] & type) |
||
1627 | { |
||
564 | terminx | 1628 | if (!(error || warning) && g_ScriptDebug > 1) |
5 | Plagman | 1629 | { |
437 | terminx | 1630 | gl = (char *)translatelabeltype(labeltype[i]); |
584 | terminx | 1631 | initprintf("%s:%d: debug: accepted %s label `%s'.\n",compilefile,line_number,gl,label+(i<<6)); |
5 | Plagman | 1632 | Bfree(gl); |
1633 | } |
||
1634 | *(scriptptr++) = labelcode[i]; |
||
1635 | textptr += l; |
||
1636 | return labeltype[i]; |
||
1637 | } |
||
1638 | *(scriptptr++) = 0; |
||
1639 | textptr += l; |
||
437 | terminx | 1640 | el = (char *)translatelabeltype(type); |
1641 | gl = (char *)translatelabeltype(labeltype[i]); |
||
5 | Plagman | 1642 | ReportError(-1); |
584 | terminx | 1643 | initprintf("%s:%d: warning: expected a %s, found a %s.\n",compilefile,line_number,el,gl); |
5 | Plagman | 1644 | Bfree(el); |
1645 | Bfree(gl); |
||
1646 | return -1; // valid label name, but wrong type |
||
1647 | } |
||
1648 | } |
||
1649 | |||
333 | terminx | 1650 | if (isdigit(*textptr) == 0 && *textptr != '-') |
5 | Plagman | 1651 | { |
1652 | ReportError(ERROR_PARAMUNDEFINED); |
||
1653 | error++; |
||
1654 | textptr+=l; |
||
1655 | return -1; // error! |
||
1656 | } |
||
1657 | |||
333 | terminx | 1658 | if (isdigit(*textptr) && labelsonly) |
5 | Plagman | 1659 | { |
1660 | ReportError(WARNING_LABELSONLY); |
||
1661 | // warning++; |
||
1662 | } |
||
564 | terminx | 1663 | if (!(error || warning) && g_ScriptDebug > 1) |
584 | terminx | 1664 | initprintf("%s:%d: debug: accepted constant %d.\n",compilefile,line_number,atol(textptr)); |
795 | terminx | 1665 | if (tolower(textptr[1])=='x')sscanf(textptr+2,"%" PRIxPTR "",scriptptr); |
622 | terminx | 1666 | else |
1667 | *scriptptr = atol(textptr); |
||
5 | Plagman | 1668 | scriptptr++; |
1669 | |||
1670 | textptr += l; |
||
1671 | |||
1672 | return 0; // literal value |
||
1673 | } |
||
1674 | |||
437 | terminx | 1675 | static int parsecommand(void); |
398 | terminx | 1676 | |
584 | terminx | 1677 | static int CountCaseStatements() |
5 | Plagman | 1678 | { |
584 | terminx | 1679 | int lCount; |
437 | terminx | 1680 | char *temptextptr = textptr; |
1681 | int temp_line_number = line_number; |
||
619 | terminx | 1682 | intptr_t scriptoffset = (unsigned)(scriptptr-script); |
1683 | intptr_t caseoffset = (unsigned)(casescriptptr-script); |
||
1684 | // int i; |
||
5 | Plagman | 1685 | |
1686 | casecount=0; |
||
1687 | casescriptptr=NULL; |
||
1688 | //Bsprintf(g_szBuf,"CSS: %.12s",textptr); |
||
1689 | //AddLog(g_szBuf); |
||
331 | terminx | 1690 | while (parsecommand() == 0) |
5 | Plagman | 1691 | { |
1692 | //Bsprintf(g_szBuf,"CSSL: %.20s",textptr); |
||
1693 | //AddLog(g_szBuf); |
||
1694 | ; |
||
1695 | } |
||
1696 | // since we processed the endswitch, we need to re-increment checking_switch |
||
1697 | checking_switch++; |
||
1698 | |||
1699 | textptr=temptextptr; |
||
619 | terminx | 1700 | scriptptr = (intptr_t *)(script+scriptoffset); |
5 | Plagman | 1701 | |
1702 | line_number = temp_line_number; |
||
1703 | |||
1704 | lCount=casecount; |
||
1705 | casecount=0; |
||
619 | terminx | 1706 | casescriptptr = (intptr_t *)(script+caseoffset); |
570 | terminx | 1707 | casecount = 0; |
5 | Plagman | 1708 | return lCount; |
1709 | } |
||
1710 | |||
437 | terminx | 1711 | static int parsecommand(void) |
5 | Plagman | 1712 | { |
584 | terminx | 1713 | int i, j=0, k=0, done, tw; |
437 | terminx | 1714 | char *temptextptr; |
619 | terminx | 1715 | intptr_t *tempscrptr; |
5 | Plagman | 1716 | |
569 | terminx | 1717 | if (quitevent) |
1718 | { |
||
1719 | initprintf("Aborted.\n"); |
||
1720 | Shutdown(); |
||
1721 | exit(0); |
||
1722 | } |
||
1723 | |||
333 | terminx | 1724 | if ((error+warning) > 63 || (*textptr == '\0') || (*(textptr+1) == '\0')) return 1; |
5 | Plagman | 1725 | |
564 | terminx | 1726 | if (g_ScriptDebug) |
296 | terminx | 1727 | ReportError(-1); |
1728 | |||
333 | terminx | 1729 | if (checking_switch > 0) |
5 | Plagman | 1730 | { |
1731 | //Bsprintf(g_szBuf,"PC(): '%.25s'",textptr); |
||
1732 | //AddLog(g_szBuf); |
||
1733 | } |
||
1734 | tw = transword(); |
||
1735 | // Bsprintf(tempbuf,"%s",keyw[tw]); |
||
1736 | // AddLog(tempbuf); |
||
1737 | |||
570 | terminx | 1738 | if (skipcomments()) |
1739 | return 1; |
||
5 | Plagman | 1740 | |
331 | terminx | 1741 | switch (tw) |
5 | Plagman | 1742 | { |
337 | terminx | 1743 | default: |
1744 | case -1: |
||
1745 | return 0; //End |
||
1746 | case CON_STATE: |
||
1747 | if (parsing_actor == 0 && parsing_state == 0) |
||
1748 | { |
||
1749 | getlabel(); |
||
1750 | scriptptr--; |
||
619 | terminx | 1751 | labelcode[labelcnt] = (intptr_t) scriptptr; |
337 | terminx | 1752 | labeltype[labelcnt] = LABEL_STATE; |
1753 | |||
1754 | parsing_state = 1; |
||
1755 | Bsprintf(parsing_item_name,"%s",label+(labelcnt<<6)); |
||
1756 | labelcnt++; |
||
1757 | return 0; |
||
1758 | } |
||
1759 | |||
1760 | getlabel(); |
||
1761 | |||
1762 | for (i=0;i<NUMKEYWORDS;i++) |
||
1763 | if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0) |
||
335 | terminx | 1764 | { |
337 | terminx | 1765 | error++; |
1766 | ReportError(ERROR_ISAKEYWORD); |
||
335 | terminx | 1767 | return 0; |
1768 | } |
||
337 | terminx | 1769 | for (j=0;j<labelcnt;j++) |
1770 | { |
||
1771 | if (Bstrcmp(label+(j<<6),label+(labelcnt<<6)) == 0) |
||
1772 | { |
||
1773 | if (labeltype[j] & LABEL_STATE) |
||
5 | Plagman | 1774 | { |
564 | terminx | 1775 | if (!(error || warning) && g_ScriptDebug > 1) |
584 | terminx | 1776 | initprintf("%s:%d: debug: accepted state label `%s'.\n",compilefile,line_number,label+(j<<6)); |
337 | terminx | 1777 | *scriptptr = labelcode[j]; |
1778 | break; |
||
5 | Plagman | 1779 | } |
337 | terminx | 1780 | else |
5 | Plagman | 1781 | { |
859 | terminx | 1782 | char *gl = (char *)translatelabeltype(labeltype[j]); |
337 | terminx | 1783 | ReportError(-1); |
584 | terminx | 1784 | initprintf("%s:%d: warning: expected a state, found a %s.\n",compilefile,line_number,gl); |
337 | terminx | 1785 | Bfree(gl); |
1786 | *(scriptptr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions |
||
1787 | return 0; // valid label name, but wrong type |
||
5 | Plagman | 1788 | } |
1789 | } |
||
337 | terminx | 1790 | } |
1791 | if (j==labelcnt) |
||
1792 | { |
||
1793 | ReportError(-1); |
||
584 | terminx | 1794 | initprintf("%s:%d: error: state `%s' not found.\n",compilefile,line_number,label+(labelcnt<<6)); |
337 | terminx | 1795 | error++; |
1796 | } |
||
1797 | scriptptr++; |
||
1798 | return 0; |
||
1799 | |||
1800 | case CON_ENDS: |
||
1801 | if (parsing_state == 0) |
||
1802 | { |
||
1803 | ReportError(-1); |
||
584 | terminx | 1804 | initprintf("%s:%d: error: found `ends' without open `state'.\n",compilefile,line_number); |
337 | terminx | 1805 | error++; |
1806 | } |
||
1807 | // else |
||
1808 | { |
||
1809 | if (num_braces > 0) |
||
5 | Plagman | 1810 | { |
337 | terminx | 1811 | ReportError(ERROR_OPENBRACKET); |
5 | Plagman | 1812 | error++; |
1813 | } |
||
337 | terminx | 1814 | if (num_braces < 0) |
5 | Plagman | 1815 | { |
337 | terminx | 1816 | ReportError(ERROR_CLOSEBRACKET); |
5 | Plagman | 1817 | error++; |
1818 | } |
||
337 | terminx | 1819 | if (checking_switch > 0) |
5 | Plagman | 1820 | { |
337 | terminx | 1821 | ReportError(ERROR_NOENDSWITCH); |
1822 | error++; |
||
5 | Plagman | 1823 | |
337 | terminx | 1824 | checking_switch = 0; // can't be checking anymore... |
1825 | } |
||
335 | terminx | 1826 | |
337 | terminx | 1827 | parsing_state = 0; |
1828 | Bsprintf(parsing_item_name,"(none)"); |
||
1829 | } |
||
1830 | return 0; |
||
1831 | |||
1832 | case CON_SETTHISPROJECTILE: |
||
1833 | case CON_SETPROJECTILE: |
||
1834 | if (!CheckEventSync(current_event)) |
||
1835 | ReportError(WARNING_EVENTSYNC); |
||
1836 | case CON_GETTHISPROJECTILE: |
||
1837 | case CON_GETPROJECTILE: |
||
1838 | { |
||
584 | terminx | 1839 | int lLabelID; |
337 | terminx | 1840 | |
1841 | // syntax getwall[<var>].x <VAR> |
||
1842 | // gets the value of wall[<var>].xxx into <VAR> |
||
1843 | |||
1844 | // now get name of .xxx |
||
1845 | while ((*textptr != '[')) |
||
1846 | { |
||
1847 | textptr++; |
||
1848 | } |
||
1849 | if (*textptr == '[') |
||
1850 | textptr++; |
||
1851 | |||
1852 | // get the ID of the DEF |
||
873 | terminx | 1853 | if (tw == CON_SETTHISPROJECTILE) |
877 | terminx | 1854 | labelsonly = 1; |
337 | terminx | 1855 | transvar(); |
1856 | labelsonly = 0; |
||
1857 | // now get name of .xxx |
||
1858 | while (*textptr != '.') |
||
1859 | { |
||
1860 | if (*textptr == 0xa) |
||
1861 | break; |
||
1862 | if (!*textptr) |
||
1863 | break; |
||
1864 | |||
1865 | textptr++; |
||
1866 | } |
||
1867 | if (*textptr!='.') |
||
1868 | { |
||
1869 | error++; |
||
1870 | ReportError(ERROR_SYNTAXERROR); |
||
331 | terminx | 1871 | return 0; |
337 | terminx | 1872 | } |
1873 | textptr++; |
||
1874 | /// now pointing at 'xxx' |
||
1875 | getlabel(); |
||
1876 | //printf("found xxx label of '%s'\n", label+(labelcnt<<6)); |
||
5 | Plagman | 1877 | |
337 | terminx | 1878 | lLabelID=getlabeloffset(projectilelabels,label+(labelcnt<<6)); |
584 | terminx | 1879 | //printf("LabelID is %d\n",lLabelID); |
337 | terminx | 1880 | if (lLabelID == -1) |
331 | terminx | 1881 | { |
337 | terminx | 1882 | error++; |
1883 | ReportError(ERROR_SYMBOLNOTRECOGNIZED); |
||
1884 | return 0; |
||
1885 | } |
||
5 | Plagman | 1886 | |
337 | terminx | 1887 | *scriptptr++=projectilelabels[lLabelID].lId; |
5 | Plagman | 1888 | |
337 | terminx | 1889 | //printf("member's flags are: %02Xh\n",playerlabels[lLabelID].flags); |
5 | Plagman | 1890 | |
337 | terminx | 1891 | // now at target VAR... |
1892 | |||
1893 | // get the ID of the DEF |
||
1894 | switch (tw) |
||
1895 | { |
||
1896 | case CON_SETPROJECTILE: |
||
1897 | case CON_SETTHISPROJECTILE: |
||
331 | terminx | 1898 | transvar(); |
337 | terminx | 1899 | break; |
1900 | default: |
||
1901 | transvartype(GAMEVAR_FLAG_READONLY); |
||
1902 | break; |
||
1903 | } |
||
1904 | break; |
||
1905 | } |
||
5 | Plagman | 1906 | |
337 | terminx | 1907 | case CON_GAMEVAR: |
1908 | // syntax: gamevar <var1> <initial value> <flags> |
||
1909 | // defines var1 and sets initial value. |
||
1910 | // flags are used to define usage |
||
1911 | // (see top of this files for flags) |
||
1912 | //printf("Got gamedef. Getting Label. '%.20s'\n",textptr); |
||
1913 | |||
1914 | if (isdigit(*textptr) || (*textptr == '-')) |
||
1915 | { |
||
5 | Plagman | 1916 | getlabel(); |
337 | terminx | 1917 | error++; |
1918 | ReportError(ERROR_SYNTAXERROR); |
||
1919 | transnum(LABEL_DEFINE); |
||
1920 | transnum(LABEL_DEFINE); |
||
1921 | scriptptr -= 3; // we complete the process anyways just to skip past the fucked up section |
||
1922 | return 0; |
||
1923 | } |
||
5 | Plagman | 1924 | |
337 | terminx | 1925 | getlabel(); |
1926 | //printf("Got Label '%.20s'\n",textptr); |
||
1927 | // Check to see it's already defined |
||
1928 | |||
1929 | for (i=0;i<NUMKEYWORDS;i++) |
||
1930 | if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0) |
||
5 | Plagman | 1931 | { |
1932 | error++; |
||
337 | terminx | 1933 | ReportError(ERROR_ISAKEYWORD); |
5 | Plagman | 1934 | return 0; |
1935 | } |
||
337 | terminx | 1936 | #if 0 |
1937 | for (i=0;i<iGameVarCount;i++) |
||
1938 | { |
||
1939 | if (aGameVars[i].szLabel != NULL) |
||
5 | Plagman | 1940 | { |
337 | terminx | 1941 | if (Bstrcmp(label+(labelcnt<<6),aGameVars[i].szLabel) == 0) |
1942 | { |
||
1943 | warning++; |
||
584 | terminx | 1944 | initprintf(" * WARNING.(L%d) duplicate Game definition `%s' ignored.\n",line_number,label+(labelcnt<<6)); |
102 | terminx | 1945 | break; |
337 | terminx | 1946 | } |
5 | Plagman | 1947 | } |
1948 | } |
||
337 | terminx | 1949 | #endif |
5 | Plagman | 1950 | |
337 | terminx | 1951 | //printf("Translating number '%.20s'\n",textptr); |
1952 | transnum(LABEL_DEFINE); // get initial value |
||
1953 | //printf("Done Translating number. '%.20s'\n",textptr); |
||
5 | Plagman | 1954 | |
337 | terminx | 1955 | transnum(LABEL_DEFINE); // get flags |
1956 | //Bsprintf(g_szBuf,"Adding GameVar='%s', val=%l, flags=%lX",label+(labelcnt<<6), |
||
1957 | // *(scriptptr-2), *(scriptptr-1)); |
||
1958 | //AddLog(g_szBuf); |
||
587 | terminx | 1959 | if ((*(scriptptr-1)&GAMEVAR_FLAG_USER_MASK)==3) |
1960 | { |
||
1961 | warning++; |
||
1962 | *(scriptptr-1)^=GAMEVAR_FLAG_PERPLAYER; |
||
1963 | ReportError(WARNING_BADGAMEVAR); |
||
1964 | } |
||
337 | terminx | 1965 | AddGameVar(label+(labelcnt<<6),*(scriptptr-2), |
1966 | (*(scriptptr-1)) |
||
1967 | // can't define default or secret |
||
1968 | & (~(GAMEVAR_FLAG_DEFAULT | GAMEVAR_FLAG_SECRET)) |
||
1969 | ); |
||
1970 | //AddLog("Added gamevar"); |
||
1971 | scriptptr -= 3; // no need to save in script... |
||
1972 | return 0; |
||
1973 | |||
676 | terminx | 1974 | case CON_GAMEARRAY: |
1975 | if (isdigit(*textptr) || (*textptr == '-')) |
||
1976 | { |
||
1977 | getlabel(); |
||
1978 | error++; |
||
1979 | ReportError(ERROR_SYNTAXERROR); |
||
1980 | transnum(LABEL_DEFINE); |
||
1981 | transnum(LABEL_DEFINE); |
||
1982 | scriptptr -= 3; // we complete the process anyways just to skip past the fucked up section |
||
1983 | return 0; |
||
1984 | } |
||
1985 | getlabel(); |
||
1986 | //printf("Got Label '%.20s'\n",textptr); |
||
1987 | // Check to see it's already defined |
||
1988 | |||
1989 | for (i=0;i<NUMKEYWORDS;i++) |
||
1990 | if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0) |
||
1991 | { |
||
1992 | error++; |
||
1993 | ReportError(ERROR_ISAKEYWORD); |
||
1994 | return 0; |
||
1995 | } |
||
1996 | transnum(LABEL_DEFINE); |
||
1997 | AddGameArray(label+(labelcnt<<6),*(scriptptr-1)); |
||
1998 | |||
1999 | scriptptr -= 2; // no need to save in script... |
||
2000 | return 0; |
||
2001 | |||
2002 | |||
337 | terminx | 2003 | case CON_DEFINE: |
2004 | { |
||
2005 | //printf("Got definition. Getting Label. '%.20s'\n",textptr); |
||
2006 | getlabel(); |
||
2007 | //printf("Got label. '%.20s'\n",textptr); |
||
2008 | // Check to see it's already defined |
||
2009 | |||
2010 | for (i=0;i<NUMKEYWORDS;i++) |
||
2011 | if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0) |
||
331 | terminx | 2012 | { |
2013 | error++; |
||
337 | terminx | 2014 | ReportError(ERROR_ISAKEYWORD); |
331 | terminx | 2015 | return 0; |
2016 | } |
||
5 | Plagman | 2017 | |
337 | terminx | 2018 | for (i=0;i<labelcnt;i++) |
2019 | { |
||
546 | terminx | 2020 | if (Bstrcmp(label+(labelcnt<<6),label+(i<<6)) == 0 /* && (labeltype[i] & LABEL_DEFINE) */) |
5 | Plagman | 2021 | { |
337 | terminx | 2022 | if (i >= defaultlabelcnt) |
5 | Plagman | 2023 | { |
337 | terminx | 2024 | warning++; |
2025 | ReportError(WARNING_DUPLICATEDEFINITION); |
||
5 | Plagman | 2026 | } |
337 | terminx | 2027 | break; |
5 | Plagman | 2028 | } |
337 | terminx | 2029 | } |
2030 | //printf("Translating. '%.20s'\n",textptr); |
||
2031 | transnum(LABEL_DEFINE); |
||
2032 | //printf("Translated. '%.20s'\n",textptr); |
||
2033 | if (i == labelcnt) |
||
2034 | { |
||
2035 | // printf("Defining Definition '%s' to be '%d'\n",label+(labelcnt<<6),*(scriptptr-1)); |
||
2036 | labeltype[labelcnt] = LABEL_DEFINE; |
||
2037 | labelcode[labelcnt++] = *(scriptptr-1); |
||
2038 | if (*(scriptptr-1) >= 0 && *(scriptptr-1) < MAXTILES && dynamicremap) |
||
2039 | processnames(label+(i<<6),*(scriptptr-1)); |
||
2040 | } |
||
2041 | scriptptr -= 2; |
||
2042 | return 0; |
||
2043 | } |
||
5 | Plagman | 2044 | |
337 | terminx | 2045 | case CON_PALFROM: |
2046 | for (j=0;j<4;j++) |
||
2047 | { |
||
2048 | if (keyword() == -1) |
||
2049 | transnum(LABEL_DEFINE); |
||
2050 | else break; |
||
2051 | } |
||
5 | Plagman | 2052 | |
337 | terminx | 2053 | while (j<4) |
2054 | { |
||
2055 | *scriptptr = 0; |
||
2056 | scriptptr++; |
||
2057 | j++; |
||
2058 | } |
||
2059 | return 0; |
||
5 | Plagman | 2060 | |
337 | terminx | 2061 | case CON_MOVE: |
2062 | if (parsing_actor || parsing_state) |
||
2063 | { |
||
2064 | if (!CheckEventSync(current_event)) |
||
2065 | ReportError(WARNING_EVENTSYNC); |
||
5 | Plagman | 2066 | |
337 | terminx | 2067 | if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) |
2068 | { |
||
2069 | ReportError(-1); |
||
2070 | *(scriptptr-1) = 0; |
||
584 | terminx | 2071 | initprintf("%s:%d: warning: expected a move, found a constant.\n",compilefile,line_number); |
337 | terminx | 2072 | } |
2073 | |||
2074 | j = 0; |
||
2075 | while (keyword() == -1) |
||
2076 | { |
||
2077 | transnum(LABEL_DEFINE); |
||
2078 | scriptptr--; |
||
2079 | j |= *scriptptr; |
||
2080 | } |
||
2081 | *scriptptr = j; |
||
2082 | |||
2083 | scriptptr++; |
||
2084 | } |
||
2085 | else |
||
5 | Plagman | 2086 | { |
337 | terminx | 2087 | scriptptr--; |
5 | Plagman | 2088 | getlabel(); |
2089 | // Check to see it's already defined |
||
2090 | |||
331 | terminx | 2091 | for (i=0;i<NUMKEYWORDS;i++) |
333 | terminx | 2092 | if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0) |
5 | Plagman | 2093 | { |
2094 | error++; |
||
2095 | ReportError(ERROR_ISAKEYWORD); |
||
2096 | return 0; |
||
2097 | } |
||
2098 | |||
331 | terminx | 2099 | for (i=0;i<labelcnt;i++) |
546 | terminx | 2100 | if (Bstrcmp(label+(labelcnt<<6),label+(i<<6)) == 0 /* && (labeltype[i] & LABEL_MOVE) */) |
5 | Plagman | 2101 | { |
337 | terminx | 2102 | warning++; |
584 | terminx | 2103 | initprintf("%s:%d: warning: duplicate move `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); |
5 | Plagman | 2104 | break; |
2105 | } |
||
331 | terminx | 2106 | if (i == labelcnt) |
5 | Plagman | 2107 | { |
337 | terminx | 2108 | labeltype[labelcnt] = LABEL_MOVE; |
619 | terminx | 2109 | labelcode[labelcnt++] = (intptr_t) scriptptr; |
5 | Plagman | 2110 | } |
337 | terminx | 2111 | for (j=0;j<2;j++) |
5 | Plagman | 2112 | { |
337 | terminx | 2113 | if (keyword() >= 0) break; |
2114 | transnum(LABEL_DEFINE); |
||
5 | Plagman | 2115 | } |
337 | terminx | 2116 | for (k=j;k<2;k++) |
5 | Plagman | 2117 | { |
2118 | *scriptptr = 0; |
||
2119 | scriptptr++; |
||
2120 | } |
||
337 | terminx | 2121 | } |
2122 | return 0; |
||
5 | Plagman | 2123 | |
337 | terminx | 2124 | case CON_MUSIC: |
2125 | { |
||
2126 | // NOTE: this doesn't get stored in the PCode... |
||
2127 | |||
2128 | // music 1 stalker.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid |
||
2129 | // thecall.mid ahgeez.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid |
||
2130 | scriptptr--; |
||
2131 | transnum(LABEL_DEFINE); // Volume Number (0/4) |
||
2132 | scriptptr--; |
||
2133 | |||
2134 | k = *scriptptr-1; |
||
2135 | |||
2136 | if (k >= 0) // if it's background music |
||
2137 | { |
||
2138 | i = 0; |
||
2139 | // get the file name... |
||
2140 | while (keyword() == -1) |
||
335 | terminx | 2141 | { |
337 | terminx | 2142 | while (isaltok(*textptr) == 0) |
5 | Plagman | 2143 | { |
337 | terminx | 2144 | if (*textptr == 0x0a) line_number++; |
2145 | textptr++; |
||
2146 | if (*textptr == 0) break; |
||
5 | Plagman | 2147 | } |
331 | terminx | 2148 | j = 0; |
412 | terminx | 2149 | tempbuf[j] = '/'; |
337 | terminx | 2150 | while (isaltok(*(textptr+j))) |
331 | terminx | 2151 | { |
412 | terminx | 2152 | tempbuf[j+1] = textptr[j]; |
337 | terminx | 2153 | j++; |
331 | terminx | 2154 | } |
412 | terminx | 2155 | tempbuf[j+1] = '\0'; |
385 | terminx | 2156 | |
562 | terminx | 2157 | if (map[(k*MAXLEVELS)+i].musicfn == NULL) |
2158 | map[(k*MAXLEVELS)+i].musicfn = Bcalloc(Bstrlen(tempbuf)+1,sizeof(char)); |
||
2159 | else if ((Bstrlen(tempbuf)+1) > sizeof(map[(k*MAXLEVELS)+i].musicfn)) |
||
2160 | map[(k*MAXLEVELS)+i].musicfn = Brealloc(map[(k*MAXLEVELS)+i].musicfn,(Bstrlen(tempbuf)+1)); |
||
385 | terminx | 2161 | |
562 | terminx | 2162 | Bstrcpy(map[(k*MAXLEVELS)+i].musicfn,tempbuf); |
385 | terminx | 2163 | |
337 | terminx | 2164 | textptr += j; |
381 | terminx | 2165 | if (i > MAXLEVELS-1) break; |
337 | terminx | 2166 | i++; |
5 | Plagman | 2167 | } |
337 | terminx | 2168 | } |
2169 | else |
||
2170 | { |
||
2171 | i = 0; |
||
2172 | while (keyword() == -1) |
||
5 | Plagman | 2173 | { |
337 | terminx | 2174 | while (isaltok(*textptr) == 0) |
5 | Plagman | 2175 | { |
337 | terminx | 2176 | if (*textptr == 0x0a) line_number++; |
2177 | textptr++; |
||
2178 | if (*textptr == 0) break; |
||
331 | terminx | 2179 | } |
337 | terminx | 2180 | j = 0; |
381 | terminx | 2181 | |
337 | terminx | 2182 | while (isaltok(*(textptr+j))) |
331 | terminx | 2183 | { |
337 | terminx | 2184 | env_music_fn[i][j] = textptr[j]; |
2185 | j++; |
||
331 | terminx | 2186 | } |
337 | terminx | 2187 | env_music_fn[i][j] = '\0'; |
2188 | |||
2189 | textptr += j; |
||
381 | terminx | 2190 | if (i > MAXVOLUMES-1) break; |
337 | terminx | 2191 | i++; |
5 | Plagman | 2192 | } |
337 | terminx | 2193 | } |
2194 | } |
||
2195 | return 0; |
||
5 | Plagman | 2196 | |
337 | terminx | 2197 | case CON_INCLUDE: |
2198 | scriptptr--; |
||
2199 | while (isaltok(*textptr) == 0) |
||
5 | Plagman | 2200 | { |
337 | terminx | 2201 | if (*textptr == 0x0a) line_number++; |
2202 | textptr++; |
||
2203 | if (*textptr == 0) break; |
||
2204 | } |
||
2205 | j = 0; |
||
2206 | while (isaltok(*textptr)) |
||
2207 | { |
||
2208 | tempbuf[j] = *(textptr++); |
||
2209 | j++; |
||
2210 | } |
||
2211 | tempbuf[j] = '\0'; |
||
5 | Plagman | 2212 | |
337 | terminx | 2213 | { |
437 | terminx | 2214 | int temp_line_number; |
2215 | int temp_ifelse_check; |
||
337 | terminx | 2216 | char *origtptr, *mptr; |
2217 | char parentcompilefile[255]; |
||
2218 | int fp; |
||
5 | Plagman | 2219 | |
337 | terminx | 2220 | fp = kopen4load(tempbuf,loadfromgrouponly); |
2221 | if (fp < 0) |
||
2222 | { |
||
2223 | error++; |
||
584 | terminx | 2224 | initprintf("%s:%d: error: could not find file `%s'.\n",compilefile,line_number,tempbuf); |
337 | terminx | 2225 | return 0; |
2226 | } |
||
335 | terminx | 2227 | |
337 | terminx | 2228 | j = kfilelength(fp); |
2229 | |||
2230 | mptr = (char *)Bmalloc(j+1); |
||
2231 | if (!mptr) |
||
5 | Plagman | 2232 | { |
337 | terminx | 2233 | kclose(fp); |
2234 | error++; |
||
584 | terminx | 2235 | initprintf("%s:%d: error: could not allocate %d bytes to include `%s'.\n", |
337 | terminx | 2236 | line_number,compilefile,j,tempbuf); |
2237 | return 0; |
||
5 | Plagman | 2238 | } |
2239 | |||
584 | terminx | 2240 | initprintf("Including: %s (%d bytes)\n",tempbuf, j); |
337 | terminx | 2241 | kread(fp, mptr, j); |
2242 | kclose(fp); |
||
2243 | mptr[j] = 0; |
||
2244 | |||
2245 | if (*textptr == '"') // skip past the closing quote if it's there so we don't screw up the next line |
||
2246 | textptr++; |
||
2247 | origtptr = textptr; |
||
2248 | |||
2249 | Bstrcpy(parentcompilefile, compilefile); |
||
2250 | Bstrcpy(compilefile, tempbuf); |
||
2251 | temp_line_number = line_number; |
||
2252 | line_number = 1; |
||
2253 | temp_ifelse_check = checking_ifelse; |
||
2254 | checking_ifelse = 0; |
||
2255 | |||
2256 | textptr = mptr; |
||
2257 | do done = parsecommand(); |
||
2258 | while (!done); |
||
2259 | |||
2260 | Bstrcpy(compilefile, parentcompilefile); |
||
2261 | total_lines += line_number; |
||
2262 | line_number = temp_line_number; |
||
2263 | checking_ifelse = temp_ifelse_check; |
||
2264 | |||
2265 | textptr = origtptr; |
||
2266 | |||
2267 | Bfree(mptr); |
||
5 | Plagman | 2268 | } |
2269 | return 0; |
||
2270 | |||
337 | terminx | 2271 | case CON_AI: |
2272 | if (parsing_actor || parsing_state) |
||
2273 | { |
||
2274 | if (!CheckEventSync(current_event)) |
||
2275 | ReportError(WARNING_EVENTSYNC); |
||
2276 | transnum(LABEL_AI); |
||
2277 | } |
||
2278 | else |
||
2279 | { |
||
5 | Plagman | 2280 | scriptptr--; |
337 | terminx | 2281 | getlabel(); |
5 | Plagman | 2282 | |
337 | terminx | 2283 | for (i=0;i<NUMKEYWORDS;i++) |
2284 | if (Bstrcmp(label+(labelcnt<<6),keyw[i]) == 0) |
||
5 | Plagman | 2285 | { |
2286 | error++; |
||
337 | terminx | 2287 | ReportError(ERROR_ISAKEYWORD); |
5 | Plagman | 2288 | return 0; |
2289 | } |
||
2290 | |||
337 | terminx | 2291 | for (i=0;i<labelcnt;i++) |
546 | terminx | 2292 | if (Bstrcmp(label+(labelcnt<<6),label+(i<<6)) == 0 /* && (labeltype[i] & LABEL_AI) */) |
5 | Plagman | 2293 | { |
337 | terminx | 2294 | warning++; |
584 | terminx | 2295 | initprintf("%s:%d: warning: duplicate ai `%s' ignored.\n",compilefile,line_number,label+(labelcnt<<6)); |
337 | terminx | 2296 | break; |
5 | Plagman | 2297 | } |
2298 | |||
337 | terminx | 2299 | if (i == labelcnt) |
2300 | { |
||
2301 | labeltype[labelcnt] = LABEL_AI; |
||
619 | terminx | 2302 | labelcode[labelcnt++] = (intptr_t) scriptptr; |
335 | terminx | 2303 | } |
2304 | |||
337 | terminx | 2305 | for (j=0;j<3;j++) |
5 | Plagman | 2306 | { |
337 | terminx | 2307 | if (keyword() >= 0) break; |
2308 | if (j == 1) |
||
2309 | transnum(LABEL_ACTION); |
||
2310 | else if (j == 2) |
||
2311 | { |
||
2312 | if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) |
||
254 | terminx | 2313 | { |
337 | terminx | 2314 | ReportError(-1); |
2315 | *(scriptptr-1) = 0; |
||
584 | terminx | 2316 | initprintf("%s:%d: warning: expected a move, found a constant.\n",compilefile,line_number); |
254 | terminx | 2317 | } |
337 | terminx | 2318 | k = 0; |
2319 | while (keyword() == -1) |
||
5 | Plagman | 2320 | { |
337 | terminx | 2321 | transnum(LABEL_DEFINE); |
2322 | scriptptr--; |
||
2323 | k |= *scriptptr; |
||
5 | Plagman | 2324 | } |
337 | terminx | 2325 | *scriptptr = k; |
5 | Plagman | 2326 | scriptptr++; |
337 | terminx | 2327 | return 0; |
5 | Plagman | 2328 | } |
2329 | } |
||
337 | terminx | 2330 | for < |