Subversion Repositories eduke32

Rev

Rev 5553 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 Plagman 1
//-------------------------------------------------------------------------
2
/*
1652 terminx 3
Copyright (C) 2010 EDuke32 developers and contributors
5 Plagman 4
 
1652 terminx 5
This file is part of EDuke32.
5 Plagman 6
 
7
EDuke32 is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License version 2
9
as published by the Free Software Foundation.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 
15
See the GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
4541 hendricks2 19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
5 Plagman 20
*/
21
//-------------------------------------------------------------------------
22
 
23
#include "duke3d.h"
2296 helixhorne 24
#include "namesdyn.h"
5 Plagman 25
#include "gamedef.h"
1677 terminx 26
#include "gameexec.h"
1950 helixhorne 27
#include "savegame.h"
2561 helixhorne 28
#include "common.h"
2726 hendricks2 29
#include "common_game.h"
5 Plagman 30
 
31
#include "osd.h"
32
 
1492 terminx 33
#ifdef _WIN32
34
#define WIN32_LEAN_AND_MEAN
35
#include <windows.h>
36
#include <shellapi.h>
37
#endif
38
 
4385 terminx 39
#define NUMKEYWORDS (int32_t)ARRAY_SIZE(keyw)
5499 terminx 40
#define NUMALTKEYWORDS (int32_t)ARRAY_SIZE(altkeyw)
1708 helixhorne 41
 
1205 terminx 42
int32_t g_scriptVersion = 13; // 13 = 1.3D-style CON files, 14 = 1.4/1.5 style CON files
5 Plagman 43
 
1143 terminx 44
char g_szScriptFileName[BMAX_PATH] = "(none)";  // file we're currently compiling
45
 
1205 terminx 46
int32_t g_totalLines,g_lineNumber;
5 Plagman 47
char g_szBuf[1024];
48
 
3410 helixhorne 49
#if !defined LUNATIC
3826 helixhorne 50
static char g_szCurrentBlockName[256] = "(none)", g_szLastBlockName[256] = "NULL";
51
static int32_t g_checkingIfElse, g_processingState, g_lastKeyword = -1;
52
 
3373 helixhorne 53
// The pointer to the start of the case table in a switch statement.
54
// First entry is 'default' code.
5521 hendricks2 55
static intptr_t *g_caseScriptPtr;
56
static intptr_t previous_event;
1205 terminx 57
static int32_t g_numCases = 0;
58
static int32_t g_checkingSwitch = 0, g_currentEvent = -1;
3834 hendricks2 59
static int32_t g_labelsOnly = 0, g_skipKeywordCheck = 0, g_dynamicTileMapping = 0, g_dynamicSoundMapping = 0;
1205 terminx 60
static int32_t g_numBraces = 0;
5 Plagman 61
 
1857 terminx 62
static int32_t C_ParseCommand(int32_t loop);
1361 terminx 63
static int32_t C_SetScriptSize(int32_t size);
3373 helixhorne 64
#endif
874 terminx 65
 
1205 terminx 66
int32_t g_numQuoteRedefinitions = 0;
5 Plagman 67
 
3328 helixhorne 68
#ifdef LUNATIC
69
weapondata_t g_playerWeapon[MAXPLAYERS][MAX_WEAPONS];
70
#endif
5 Plagman 71
 
3826 helixhorne 72
#if !defined LUNATIC
5521 hendricks2 73
static intptr_t g_parsingActorPtr;
74
static intptr_t g_parsingEventPtr;
75
static intptr_t g_parsingEventBreakPtr;
76
static intptr_t apScriptGameEventEnd[MAXGAMEEVENTS];
3826 helixhorne 77
static char *textptr;
3415 helixhorne 78
#endif
5 Plagman 79
 
1205 terminx 80
int32_t g_numCompilerErrors,g_numCompilerWarnings;
432 terminx 81
 
1465 terminx 82
extern int32_t g_maxSoundPos;
83
 
1857 terminx 84
enum
335 terminx 85
{
255 terminx 86
    LABEL_ANY    = -1,
87
    LABEL_DEFINE = 1,
88
    LABEL_STATE  = 2,
89
    LABEL_ACTOR  = 4,
90
    LABEL_ACTION = 8,
91
    LABEL_AI     = 16,
92
    LABEL_MOVE   = 32,
5 Plagman 93
};
94
 
3410 helixhorne 95
#if !defined LUNATIC
5540 terminx 96
static char *C_GetLabelType(int32_t type)
5 Plagman 97
{
1205 terminx 98
    int32_t i;
5 Plagman 99
    char x[64];
100
 
1857 terminx 101
    const char *LabelTypeText[] =
102
    {
103
        "define",
104
        "state",
105
        "actor",
106
        "action",
107
        "ai",
108
        "move"
109
    };
110
 
5 Plagman 111
    x[0] = 0;
1229 terminx 112
    for (i=0; i<6; i++)
335 terminx 113
    {
5 Plagman 114
        if (!(type & (1<<i))) continue;
115
        if (x[0]) Bstrcat(x, " or ");
1143 terminx 116
        Bstrcat(x, LabelTypeText[i]);
5 Plagman 117
    }
4491 helixhorne 118
 
119
    return Xstrdup(x);
5 Plagman 120
}
121
 
5499 terminx 122
typedef struct {
123
    const char* token;
124
    int32_t val;
125
} tokenmap_t;
5 Plagman 126
 
5499 terminx 127
const tokenmap_t altkeyw [] =
128
{
129
    { "#define", CON_DEFINE },
5531 hendricks2 130
    { "#include", CON_INCLUDE },
5499 terminx 131
    { "al", CON_ADDLOGVAR },
132
    { "var", CON_GAMEVAR },
133
    { "array", CON_GAMEARRAY },
134
    { "shiftl", CON_SHIFTVARVARL },
135
    { "shiftr", CON_SHIFTVARVARR },
136
    { "rand", CON_RANDVARVAR },
137
    { "set", CON_SETVARVAR },
138
    { "add", CON_ADDVARVAR },
139
    { "sub", CON_SUBVARVAR },
140
    { "mul", CON_MULVARVAR },
141
    { "div", CON_DIVVARVAR },
142
    { "mod", CON_MODVARVAR },
143
    { "and", CON_ANDVARVAR },
144
    { "or", CON_ORVARVAR },
145
    { "xor", CON_XORVARVAR },
146
    { "ifl", CON_IFVARVARL },
147
    { "ifle", CON_IFVARVARLE },
148
    { "ifg", CON_IFVARVARG },
149
    { "ifge", CON_IFVARVARGE },
150
    { "ife", CON_IFVARVARE },
151
    { "ifn", CON_IFVARVARN },
152
    { "ifand", CON_IFVARVARAND },
153
    { "ifor", CON_IFVARVAROR },
154
    { "ifxor", CON_IFVARVARXOR },
155
    { "ifeither", CON_IFVARVAREITHER },
156
    { "ifboth", CON_IFVARVARBOTH },
157
    { "whilen", CON_WHILEVARVARN },
158
    { "whilel", CON_WHILEVARVARL },
5501 terminx 159
    { "abs", CON_KLABS },
5505 terminx 160
 
161
    { "getp", CON_GETPLAYER },
5531 hendricks2 162
    { "getpv", CON_GETPLAYERVAR },
5505 terminx 163
    { "gets", CON_GETSECTOR },
164
    { "geta", CON_GETACTOR },
165
    { "getav", CON_GETACTORVAR },
166
    { "getw", CON_GETWALL },
167
    { "getu", CON_GETUSERDEF },
168
    { "geti", CON_GETINPUT },
169
 
170
    { "setp", CON_SETPLAYER },
5531 hendricks2 171
    { "setpv", CON_SETPLAYERVAR },
5505 terminx 172
    { "sets", CON_SETSECTOR },
173
    { "seta", CON_SETACTOR },
174
    { "setav", CON_SETACTORVAR },
175
    { "setw", CON_SETWALL },
176
    { "setu", CON_SETUSERDEF },
177
    { "seti", CON_SETINPUT },
5499 terminx 178
};
179
 
967 terminx 180
const char *keyw[] =
559 terminx 181
{
182
    "definelevelname",          // 0  defines level name
183
    "actor",                    // 1  defines an actor
184
    "addammo",                  // 2  adds ammo to a weapon
185
    "ifrnd",                    // 3  checks against a randomizer
186
    "enda",                     // 4  ends an actor definition
187
    "ifcansee",                 // 5  checks if the player can see an object
188
    "ifhitweapon",              // 6  checks if an object was hit by a weapon
189
    "action",                   // 7  defines an action if used outside a state or actor, otherwise triggers actor to perform action
190
    "ifpdistl",                 // 8  checks if player distance is less than value
191
    "ifpdistg",                 // 9  checks if player distance is more than value
192
    "else",                     // 10 used with if checks
193
    "strength",                 // 11 sets health
194
    "break",                    // 12 stops processing
195
    "shoot",                    // 13 shoots a projectile
1625 terminx 196
    "palfrom",                  // 14 used for player screen shading effect, sets p->pals
559 terminx 197
    "sound",                    // 15 plays a sound that was defined with definesound
198
    "fall",                     // 16 causes actor to fall to sector floor height
199
    "state",                    // 17 begins defining a state if used outside a state or actor, otherwise calls a state
200
    "ends",                     // 18 ends defining a state
201
    "define",                   // 19 defines a value
1203 terminx 202
    "return",                   // 20
559 terminx 203
    "ifai",                     // 21 checks if actor is currently performing a specific ai function
204
    "killit",                   // 22 kills an actor
205
    "addweapon",                // 23 adds a weapon to the closest player
206
    "ai",                       // 24 sets an ai function to be used by an actor
207
    "addphealth",               // 25 adds health to the player
208
    "ifdead",                   // 26 checks if actor is dead
209
    "ifsquished",               // 27 checks if actor has been squished
210
    "sizeto",                   // 28 gradually increases actor size until it matches parameters given
211
    "{",                        // 29 used to indicate segments of code
212
    "}",                        // 30 used to indicate segments of code
213
    "spawn",                    // 31 spawns an actor
214
    "move",                     // 32
215
    "ifwasweapon",              // 33
216
    "ifaction",                 // 34
217
    "ifactioncount",            // 35
218
    "resetactioncount",         // 36
219
    "debris",                   // 37
220
    "pstomp",                   // 38
221
    "<null>",                   // 39 was previously used to define the start of a comment block
222
    "cstat",                    // 40
223
    "ifmove",                   // 41
224
    "resetplayer",              // 42
225
    "ifonwater",                // 43
226
    "ifinwater",                // 44
227
    "ifcanshoottarget",         // 45
228
    "ifcount",                  // 46
229
    "resetcount",               // 47
230
    "addinventory",             // 48
231
    "ifactornotstayput",        // 49
232
    "hitradius",                // 50
233
    "ifp",                      // 51
234
    "count",                    // 52
235
    "ifactor",                  // 53
236
    "music",                    // 54
237
    "include",                  // 55
238
    "ifstrength",               // 56
239
    "definesound",              // 57
240
    "guts",                     // 58
241
    "ifspawnedby",              // 59
242
    "gamestartup",              // 60
243
    "wackplayer",               // 61
244
    "ifgapzl",                  // 62
245
    "ifhitspace",               // 63
246
    "ifoutside",                // 64
247
    "ifmultiplayer",            // 65
248
    "operate",                  // 66
249
    "ifinspace",                // 67
250
    "debug",                    // 68
251
    "endofgame",                // 69
252
    "ifbulletnear",             // 70
253
    "ifrespawn",                // 71
254
    "iffloordistl",             // 72
255
    "ifceilingdistl",           // 73
256
    "spritepal",                // 74
257
    "ifpinventory",             // 75
258
    "betaname",                 // 76
259
    "cactor",                   // 77
260
    "ifphealthl",               // 78
261
    "definequote",              // 79
262
    "quote",                    // 80
263
    "ifinouterspace",           // 81
264
    "ifnotmoving",              // 82
265
    "respawnhitag",             // 83
266
    "tip",                      // 84
267
    "ifspritepal",              // 85
268
    "money",                    // 86
269
    "soundonce",                // 87
270
    "addkills",                 // 88
271
    "stopsound",                // 89
272
    "ifawayfromwall",           // 90
273
    "ifcanseetarget",           // 91
274
    "globalsound",              // 92
275
    "lotsofglass",              // 93
276
    "ifgotweaponce",            // 94
277
    "getlastpal",               // 95
278
    "pkick",                    // 96
279
    "mikesnd",                  // 97
280
    "useractor",                // 98
281
    "sizeat",                   // 99
282
    "addstrength",              // 100  [#]
283
    "cstator",                  // 101
284
    "mail",                     // 102
285
    "paper",                    // 103
286
    "tossweapon",               // 104
287
    "sleeptime",                // 105
288
    "nullop",                   // 106
289
    "definevolumename",         // 107
290
    "defineskillname",          // 108
291
    "ifnosounds",               // 109
292
    "clipdist",                 // 110
2695 helixhorne 293
    "ifangdiffl",               // 111  Last Duke3D 1.5 CON command
559 terminx 294
    "gamevar",                  // 112
295
    "ifvarl",                   // 113
296
    "ifvarg",                   // 114
297
    "setvarvar",                // 115
298
    "setvar",                   // 116
299
    "addvarvar",                // 117
300
    "addvar",                   // 118
301
    "ifvarvarl",                // 119
302
    "ifvarvarg",                // 120
303
    "addlogvar",                // 121
304
    "addlog",                   // 122
305
    "onevent",                  // 123
306
    "endevent",                 // 124
307
    "ifvare",                   // 125
308
    "ifvarvare",                // 126
309
    "spgetlotag",               // 127
310
    "spgethitag",               // 128
311
    "sectgetlotag",             // 129
312
    "sectgethitag",             // 130
313
    "ifsound",                  // 131
314
    "gettexturefloor",          // 132
315
    "gettextureceiling",        // 133
316
    "inittimer",                // 134
317
    "starttrack",               // 135
318
    "randvar",                  // 136
319
    "enhanced",                 // 137
320
    "getangletotarget",         // 138
321
    "getactorangle",            // 139
322
    "setactorangle",            // 140
323
    "mulvar",                   // 141
324
    "mulvarvar",                // 142
325
    "divvar",                   // 143
326
    "divvarvar",                // 144
327
    "modvar",                   // 145
328
    "modvarvar",                // 146
329
    "andvar",                   // 147
330
    "andvarvar",                // 148
331
    "orvar",                    // 149
332
    "orvarvar",                 // 150
333
    "getplayerangle",           // 151
334
    "setplayerangle",           // 152
335
    "lockplayer",               // 153
336
    "setsector",                // 154
337
    "getsector",                // 155
338
    "setactor",                 // 156
339
    "getactor",                 // 157
340
    "setwall",                  // 158
341
    "getwall",                  // 159
342
    "findnearactor",            // 160
343
    "findnearactorvar",         // 161
344
    "setactorvar",              // 162
345
    "getactorvar",              // 163
346
    "espawn",                   // 164
347
    "getplayer",                // 165
348
    "setplayer",                // 166
349
    "sqrt",                     // 167
350
    "eventloadactor",           // 168
351
    "espawnvar",                // 169
352
    "getuserdef",               // 170
353
    "setuserdef",               // 171
354
    "subvarvar",                // 172
355
    "subvar",                   // 173
356
    "ifvarn",                   // 174
357
    "ifvarvarn",                // 175
358
    "ifvarand",                 // 176
359
    "ifvarvarand",              // 177
360
    "myos",                     // 178
361
    "myospal",                  // 179
362
    "displayrand",              // 180
363
    "sin",                      // 181
364
    "xorvarvar",                // 182
365
    "xorvar",                   // 183
366
    "randvarvar",               // 184
367
    "myosx",                    // 185
368
    "myospalx",                 // 186
369
    "gmaxammo",                 // 187
370
    "smaxammo",                 // 188
371
    "startlevel",               // 189
372
    "eshoot",                   // 190
373
    "qspawn",                   // 191
374
    "rotatesprite",             // 192
375
    "defineprojectile",         // 193
376
    "spriteshadow",             // 194
377
    "cos",                      // 195
378
    "eshootvar",                // 196
379
    "findnearactor3d",          // 197
380
    "findnearactor3dvar",       // 198
381
    "flash",                    // 199
382
    "qspawnvar",                // 200
383
    "eqspawn",                  // 201
384
    "eqspawnvar",               // 202
385
    "minitext",                 // 203
386
    "gametext",                 // 204
387
    "digitalnumber",            // 205
388
    "addweaponvar",             // 206
389
    "setprojectile",            // 207
390
    "angoff",                   // 208
391
    "updatesector",             // 209
392
    "insertspriteq",            // 210
393
    "angoffvar",                // 211
394
    "whilevarn",                // 212
395
    "switch",                   // 213
396
    "case",                     // 214
397
    "default",                  // 215
398
    "endswitch",                // 216
399
    "shootvar",                 // 217
400
    "soundvar",                 // 218
401
    "findplayer",               // 219
402
    "findotherplayer",          // 220
403
    "activatebysector",         // 221 sectnum, spriteid
404
    "operatesectors",           // 222 sectnum, spriteid
405
    "operaterespawns",          // 223 lotag
406
    "operateactivators",        // 224 lotag, player index
407
    "operatemasterswitches",    // 225 lotag
408
    "checkactivatormotion",     // 226 lotag
409
    "zshoot",                   // 227 zvar projnum
410
    "dist",                     // 228 sprite1 sprite2
411
    "ldist",                    // 229 sprite1 sprite2
412
    "shiftvarl",                // 230
413
    "shiftvarr",                // 231
414
    "spritenvg",                // 232
415
    "getangle",                 // 233
416
    "whilevarvarn",             // 234
417
    "hitscan",                  // 235
418
    "time",                     // 236
419
    "getplayervar",             // 237
420
    "setplayervar",             // 238
421
    "mulscale",                 // 239
422
    "setaspect",                // 240
423
    "ezshoot",                  // 241
424
    "spritenoshade",            // 242
425
    "movesprite",               // 243
426
    "checkavailweapon",         // 244
427
    "soundoncevar",             // 245
428
    "updatesectorz",            // 246
429
    "stopallsounds",            // 247
430
    "ssp",                      // 248
431
    "stopsoundvar",             // 249
432
    "displayrandvar",           // 250
433
    "displayrandvarvar",        // 251
434
    "checkavailinven",          // 252
435
    "globalsoundvar",           // 253
436
    "guniqhudid",               // 254
437
    "getprojectile",            // 255
438
    "getthisprojectile",        // 256
439
    "setthisprojectile",        // 257
440
    "definecheat",              // 258
441
    "cheatkeys",                // 259
442
    "userquote",                // 260
443
    "precache",                 // 261
444
    "definegamefuncname",       // 262
445
    "redefinequote",            // 263
446
    "qsprintf",                 // 264
447
    "getpname",                 // 265
448
    "qstrcat",                  // 266
449
    "qstrcpy",                  // 267
450
    "setsprite",                // 268
451
    "rotatepoint",              // 269
452
    "dragpoint",                // 270
453
    "getzrange",                // 271
454
    "changespritestat",         // 272
455
    "getceilzofslope",          // 273
456
    "getflorzofslope",          // 274
457
    "neartag",                  // 275
458
    "definegametype",           // 276
459
    "changespritesect",         // 277
460
    "spriteflags",              // 278
461
    "savegamevar",              // 279
462
    "readgamevar",              // 280
463
    "findnearsprite",           // 281
464
    "findnearspritevar",        // 282
465
    "findnearsprite3d",         // 283
466
    "findnearsprite3dvar",      // 284
467
    "dynamicremap",             // 285
468
    "setinput",                 // 286
469
    "getinput",                 // 287
955 hnt_ts 470
    "save",                     // 288
2695 helixhorne 471
    "cansee",                   // 289  Beginning EDuke32 SVN
559 terminx 472
    "canseespr",                // 290
473
    "findnearactorz",           // 291
474
    "findnearactorzvar",        // 292
475
    "findnearspritez",          // 293
476
    "findnearspritezvar",       // 294
955 hnt_ts 477
    "zshootvar",                // 295
478
    "ezshootvar",               // 296
479
    "getcurraddress",           // 297
480
    "jump",                     // 298
481
    "qstrlen",                  // 299
559 terminx 482
    "getincangle",              // 300
483
    "quake",                    // 301
484
    "showview",                 // 302
485
    "headspritestat",           // 303
486
    "prevspritestat",           // 304
487
    "nextspritestat",           // 305
488
    "headspritesect",           // 306
489
    "prevspritesect",           // 307
490
    "nextspritesect",           // 308
587 terminx 491
    "getkeyname",               // 309
492
    "qsubstr",                  // 310
493
    "gametextz",                // 311
494
    "digitalnumberz",           // 312
495
    "spritenopal",              // 313
617 terminx 496
    "hitradiusvar",             // 314
642 terminx 497
    "rotatesprite16",           // 315
676 terminx 498
    "gamearray",                // 316
499
    "setarray",                 // 317
693 terminx 500
    "resizearray",              // 318
501
    "writearraytofile",         // 319
502
    "readarrayfromfile",        // 320
955 hnt_ts 503
    "starttrackvar",            // 321
504
    "qgetsysstr",               // 322
505
    "getticks",                 // 323
856 terminx 506
    "gettspr",                  // 324
507
    "settspr",                  // 325
859 terminx 508
    "savemapstate",             // 326
509
    "loadmapstate",             // 327
510
    "clearmapstate",            // 328
874 terminx 511
    "scriptsize",               // 329
987 terminx 512
    "setgamename",              // 330
903 hnt_ts 513
    "cmenu",                    // 331
958 hnt_ts 514
    "gettimedate",              // 332
964 hnt_ts 515
    "activatecheat",            // 333
980 hnt_ts 516
    "setgamepalette",           // 334
984 terminx 517
    "setdefname",               // 335
986 terminx 518
    "setcfgname",               // 336
1060 hnt_ts 519
    "ifvaror",                  // 337
520
    "ifvarvaror",               // 338
521
    "ifvarxor",                 // 339
522
    "ifvarvarxor",              // 340
523
    "ifvareither",              // 341
524
    "ifvarvareither",           // 342
1068 terminx 525
    "getarraysize",             // 343
526
    "savenn",                   // 344
1228 terminx 527
    "copy",                     // 345
5501 terminx 528
    "inv",                      // 346
1457 terminx 529
    "sectorofwall",             // 347
530
    "qstrncat",                 // 348
1461 terminx 531
    "ifactorsound",             // 349
532
    "stopactorsound",           // 350
1673 terminx 533
    "ifclient",                 // 351
534
    "ifserver",                 // 352
1708 helixhorne 535
    "sectsetinterpolation",     // 353
536
    "sectclearinterpolation",   // 354
1857 terminx 537
    "clipmove",                 // 355
538
    "lineintersect",            // 356
539
    "rayintersect",             // 357
540
    "calchypotenuse",           // 358
541
    "clipmovenoslide",          // 359
1909 terminx 542
    "includedefault",           // 360
2104 helixhorne 543
    "setactorsoundpitch",       // 361
2419 hendricks2 544
    "echo",                     // 362
2573 helixhorne 545
    "showviewunbiased",         // 363
3610 hendricks2 546
    "rotatespritea",            // 364
3803 terminx 547
    "shadeto",                  // 365
548
    "endoflevel",               // 366
549
    "ifplayersl",               // 367
550
    "activate",                 // 368
3833 hendricks2 551
    "qstrdim",                  // 369
552
    "screentext",               // 370
3834 hendricks2 553
    "dynamicsoundremap",        // 371
3912 helixhorne 554
    "screensound",              // 372
4928 hendricks2 555
    "getmusicposition",         // 373
556
    "setmusicposition",         // 374
4977 hendricks2 557
    "undefinevolume",           // 375
558
    "undefineskill",            // 376
559
    "undefinelevel",            // 377
5031 hendricks2 560
    "startcutscene",            // 378
4987 terminx 561
    "ifcutscene",               // 379
5033 hendricks2 562
    "definevolumeflags",        // 380
5039 hendricks2 563
    "resetplayerflags",         // 381
5093 hendricks2 564
    "appendevent",              // 382
5353 hendricks2 565
    "defstate",                 // 383
5499 terminx 566
    "shiftvarvarl",             // 384
567
    "shiftvarvarr",             // 385
568
    "ifvarvarle",               // 386
569
    "ifvarvarge",               // 387
570
    "ifvarvarboth",             // 388
571
    "whilevarl",                // 389
572
    "whilevarvarl",             // 390
5501 terminx 573
    "klabs",                    // 391
5530 hendricks2 574
    "ifvarle",                  // 392
575
    "ifvarge",                  // 393
576
    "ifvarboth",                // 394
559 terminx 577
    "<null>"
578
};
3354 helixhorne 579
#endif
5 Plagman 580
 
3258 helixhorne 581
// KEEPINSYNC with enum GameEvent_t and lunatic/con_lang.lua
582
const char *EventNames[MAXEVENTS] =
2327 helixhorne 583
{
3258 helixhorne 584
    "EVENT_INIT",
585
    "EVENT_ENTERLEVEL",
586
    "EVENT_RESETWEAPONS",
587
    "EVENT_RESETINVENTORY",
588
    "EVENT_HOLSTER",
589
    "EVENT_LOOKLEFT",
590
    "EVENT_LOOKRIGHT",
591
    "EVENT_SOARUP",
592
    "EVENT_SOARDOWN",
593
    "EVENT_CROUCH",
594
    "EVENT_JUMP",
595
    "EVENT_RETURNTOCENTER",
596
    "EVENT_LOOKUP",
597
    "EVENT_LOOKDOWN",
598
    "EVENT_AIMUP",
599
    "EVENT_FIRE",
600
    "EVENT_CHANGEWEAPON",
601
    "EVENT_GETSHOTRANGE",
602
    "EVENT_GETAUTOAIMANGLE",
603
    "EVENT_GETLOADTILE",
604
    "EVENT_CHEATGETSTEROIDS",
605
    "EVENT_CHEATGETHEAT",
606
    "EVENT_CHEATGETBOOT",
607
    "EVENT_CHEATGETSHIELD",
608
    "EVENT_CHEATGETSCUBA",
609
    "EVENT_CHEATGETHOLODUKE",
610
    "EVENT_CHEATGETJETPACK",
611
    "EVENT_CHEATGETFIRSTAID",
612
    "EVENT_QUICKKICK",
613
    "EVENT_INVENTORY",
614
    "EVENT_USENIGHTVISION",
615
    "EVENT_USESTEROIDS",
616
    "EVENT_INVENTORYLEFT",
617
    "EVENT_INVENTORYRIGHT",
618
    "EVENT_HOLODUKEON",
619
    "EVENT_HOLODUKEOFF",
620
    "EVENT_USEMEDKIT",
621
    "EVENT_USEJETPACK",
622
    "EVENT_TURNAROUND",
623
    "EVENT_DISPLAYWEAPON",
624
    "EVENT_FIREWEAPON",
625
    "EVENT_SELECTWEAPON",
626
    "EVENT_MOVEFORWARD",
627
    "EVENT_MOVEBACKWARD",
628
    "EVENT_TURNLEFT",
629
    "EVENT_TURNRIGHT",
630
    "EVENT_STRAFELEFT",
631
    "EVENT_STRAFERIGHT",
632
    "EVENT_WEAPKEY1",
633
    "EVENT_WEAPKEY2",
634
    "EVENT_WEAPKEY3",
635
    "EVENT_WEAPKEY4",
636
    "EVENT_WEAPKEY5",
637
    "EVENT_WEAPKEY6",
638
    "EVENT_WEAPKEY7",
639
    "EVENT_WEAPKEY8",
640
    "EVENT_WEAPKEY9",
641
    "EVENT_WEAPKEY10",
642
    "EVENT_DRAWWEAPON",
643
    "EVENT_DISPLAYCROSSHAIR",
644
    "EVENT_DISPLAYREST",
645
    "EVENT_DISPLAYSBAR",
646
    "EVENT_RESETPLAYER",
647
    "EVENT_INCURDAMAGE",
648
    "EVENT_AIMDOWN",
649
    "EVENT_GAME",
650
    "EVENT_PREVIOUSWEAPON",
651
    "EVENT_NEXTWEAPON",
652
    "EVENT_SWIMUP",
653
    "EVENT_SWIMDOWN",
654
    "EVENT_GETMENUTILE",
655
    "EVENT_SPAWN",
656
    "EVENT_LOGO",
657
    "EVENT_EGS",
658
    "EVENT_DOFIRE",
659
    "EVENT_PRESSEDFIRE",
660
    "EVENT_USE",
661
    "EVENT_PROCESSINPUT",
662
    "EVENT_FAKEDOMOVETHINGS",
663
    "EVENT_DISPLAYROOMS",
664
    "EVENT_KILLIT",
665
    "EVENT_LOADACTOR",
666
    "EVENT_DISPLAYBONUSSCREEN",
667
    "EVENT_DISPLAYMENU",
668
    "EVENT_DISPLAYMENUREST",
669
    "EVENT_DISPLAYLOADINGSCREEN",
670
    "EVENT_ANIMATESPRITES",
671
    "EVENT_NEWGAME",
672
    "EVENT_SOUND",
673
    "EVENT_CHECKTOUCHDAMAGE",
674
    "EVENT_CHECKFLOORDAMAGE",
675
    "EVENT_LOADGAME",
676
    "EVENT_SAVEGAME",
677
    "EVENT_PREGAME",
3937 helixhorne 678
    "EVENT_CHANGEMENU",
4206 helixhorne 679
    "EVENT_DAMAGEHPLANE",
4515 hendricks2 680
    "EVENT_ACTIVATECHEAT",
4945 hendricks2 681
    "EVENT_DISPLAYINACTIVEMENU",
682
    "EVENT_DISPLAYINACTIVEMENUREST",
4987 terminx 683
    "EVENT_CUTSCENE",
5003 hendricks2 684
    "EVENT_DISPLAYCURSOR",
5045 hendricks2 685
    "EVENT_DISPLAYLEVELSTATS",
5046 hendricks2 686
    "EVENT_DISPLAYCAMERAOSD",
5047 hendricks2 687
    "EVENT_DISPLAYROOMSCAMERA",
688
    "EVENT_DISPLAYSTART",
5098 hendricks2 689
    "EVENT_WORLD",
690
    "EVENT_PREWORLD",
691
    "EVENT_PRELEVEL",
5118 hendricks2 692
    "EVENT_DISPLAYSPIT",
693
    "EVENT_DISPLAYFIST",
694
    "EVENT_DISPLAYKNEE",
695
    "EVENT_DISPLAYKNUCKLES",
696
    "EVENT_DISPLAYSCUBA",
697
    "EVENT_DISPLAYTIP",
698
    "EVENT_DISPLAYACCESS",
3937 helixhorne 699
#ifdef LUNATIC
700
    "EVENT_ANIMATEALLSPRITES",
701
#endif
2327 helixhorne 702
};
703
 
3410 helixhorne 704
#if !defined LUNATIC
1143 terminx 705
const memberlabel_t SectorLabels[]=
559 terminx 706
{
707
    { "wallptr", SECTOR_WALLPTR, 0, 0 },
708
    { "wallnum", SECTOR_WALLNUM, 0, 0 },
709
    { "ceilingz", SECTOR_CEILINGZ, 0, 0 },
710
    { "floorz", SECTOR_FLOORZ, 0, 0 },
711
    { "ceilingstat", SECTOR_CEILINGSTAT, 0, 0 },
712
    { "floorstat", SECTOR_FLOORSTAT, 0, 0 },
713
    { "ceilingpicnum", SECTOR_CEILINGPICNUM, 0, 0 },
714
    { "ceilingslope", SECTOR_CEILINGSLOPE, 0, 0 },
715
    { "ceilingshade", SECTOR_CEILINGSHADE, 0, 0 },
716
    { "ceilingpal", SECTOR_CEILINGPAL, 0, 0 },
717
    { "ceilingxpanning", SECTOR_CEILINGXPANNING, 0, 0 },
718
    { "ceilingypanning", SECTOR_CEILINGYPANNING, 0, 0 },
719
    { "floorpicnum", SECTOR_FLOORPICNUM, 0, 0 },
720
    { "floorslope", SECTOR_FLOORSLOPE, 0, 0 },
721
    { "floorshade", SECTOR_FLOORSHADE, 0, 0 },
722
    { "floorpal", SECTOR_FLOORPAL, 0, 0 },
723
    { "floorxpanning", SECTOR_FLOORXPANNING, 0, 0 },
724
    { "floorypanning", SECTOR_FLOORYPANNING, 0, 0 },
725
    { "visibility", SECTOR_VISIBILITY, 0, 0 },
4416 helixhorne 726
    { "fogpal", SECTOR_FOGPAL, 0, 0 }, // formerly filler
727
    { "alignto", SECTOR_FOGPAL, 0, 0 }, // formerly filler
559 terminx 728
    { "lotag", SECTOR_LOTAG, 0, 0 },
729
    { "hitag", SECTOR_HITAG, 0, 0 },
730
    { "extra", SECTOR_EXTRA, 0, 0 },
2050 helixhorne 731
    { "ceilingbunch", SECTOR_CEILINGBUNCH, 0, 0 },
732
    { "floorbunch", SECTOR_FLOORBUNCH, 0, 0 },
3192 terminx 733
    { "ulotag", SECTOR_ULOTAG, 0, 0 },
734
    { "uhitag", SECTOR_UHITAG, 0, 0 },
559 terminx 735
    { "", -1, 0, 0  }     // END OF LIST
736
};
5 Plagman 737
 
1143 terminx 738
const memberlabel_t WallLabels[]=
559 terminx 739
{
740
    { "x", WALL_X, 0, 0 },
741
    { "y", WALL_Y, 0, 0 },
742
    { "point2", WALL_POINT2, 0, 0 },
743
    { "nextwall", WALL_NEXTWALL, 0, 0 },
744
    { "nextsector", WALL_NEXTSECTOR, 0, 0 },
745
    { "cstat", WALL_CSTAT, 0, 0 },
746
    { "picnum", WALL_PICNUM, 0, 0 },
747
    { "overpicnum", WALL_OVERPICNUM, 0, 0 },
748
    { "shade", WALL_SHADE, 0, 0 },
749
    { "pal", WALL_PAL, 0, 0 },
750
    { "xrepeat", WALL_XREPEAT, 0, 0 },
751
    { "yrepeat", WALL_YREPEAT, 0, 0 },
752
    { "xpanning", WALL_XPANNING, 0, 0 },
753
    { "ypanning", WALL_YPANNING, 0, 0 },
754
    { "lotag", WALL_LOTAG, 0, 0 },
755
    { "hitag", WALL_HITAG, 0, 0 },
756
    { "extra", WALL_EXTRA, 0, 0 },
3192 terminx 757
    { "ulotag", WALL_ULOTAG, 0, 0 },
758
    { "uhitag", WALL_UHITAG, 0, 0 },
559 terminx 759
    { "", -1, 0, 0  }     // END OF LIST
760
};
5 Plagman 761
 
1143 terminx 762
const memberlabel_t ActorLabels[]=
559 terminx 763
{
764
    { "x", ACTOR_X, 0, 0 },
765
    { "y", ACTOR_Y, 0, 0 },
766
    { "z", ACTOR_Z, 0, 0 },
767
    { "cstat", ACTOR_CSTAT, 0, 0 },
768
    { "picnum", ACTOR_PICNUM, 0, 0 },
769
    { "shade", ACTOR_SHADE, 0, 0 },
770
    { "pal", ACTOR_PAL, 0, 0 },
771
    { "clipdist", ACTOR_CLIPDIST, 0, 0 },
1011 terminx 772
//    { "filler", ACTOR_DETAIL, 0, 0 },
4313 helixhorne 773
    { "blend", ACTOR_DETAIL, 0, 0 },
559 terminx 774
    { "xrepeat", ACTOR_XREPEAT, 0, 0 },
775
    { "yrepeat", ACTOR_YREPEAT, 0, 0 },
776
    { "xoffset", ACTOR_XOFFSET, 0, 0 },
777
    { "yoffset", ACTOR_YOFFSET, 0, 0 },
778
    { "sectnum", ACTOR_SECTNUM, 0, 0 },
779
    { "statnum", ACTOR_STATNUM, 0, 0 },
780
    { "ang", ACTOR_ANG, 0, 0 },
781
    { "owner", ACTOR_OWNER, 0, 0 },
782
    { "xvel", ACTOR_XVEL, 0, 0 },
783
    { "yvel", ACTOR_YVEL, 0, 0 },
784
    { "zvel", ACTOR_ZVEL, 0, 0 },
785
    { "lotag", ACTOR_LOTAG, 0, 0 },
786
    { "hitag", ACTOR_HITAG, 0, 0 },
787
    { "extra", ACTOR_EXTRA, 0, 0 },
5 Plagman 788
 
1143 terminx 789
    // ActorExtra labels...
559 terminx 790
    { "htcgg", ACTOR_HTCGG, 0, 0 },
791
    { "htpicnum", ACTOR_HTPICNUM, 0, 0 },
792
    { "htang", ACTOR_HTANG, 0, 0 },
793
    { "htextra", ACTOR_HTEXTRA, 0, 0 },
794
    { "htowner", ACTOR_HTOWNER, 0, 0 },
795
    { "htmovflag", ACTOR_HTMOVFLAG, 0, 0 },
796
    { "httempang", ACTOR_HTTEMPANG, 0, 0 },
797
    { "htactorstayput", ACTOR_HTACTORSTAYPUT, 0, 0 },
798
    { "htdispicnum", ACTOR_HTDISPICNUM, 0, 0 },
799
    { "httimetosleep", ACTOR_HTTIMETOSLEEP, 0, 0 },
800
    { "htfloorz", ACTOR_HTFLOORZ, 0, 0 },
801
    { "htceilingz", ACTOR_HTCEILINGZ, 0, 0 },
802
    { "htlastvx", ACTOR_HTLASTVX, 0, 0 },
803
    { "htlastvy", ACTOR_HTLASTVY, 0, 0 },
804
    { "htbposx", ACTOR_HTBPOSX, 0, 0 },
805
    { "htbposy", ACTOR_HTBPOSY, 0, 0 },
806
    { "htbposz", ACTOR_HTBPOSZ, 0, 0 },
870 terminx 807
    { "htg_t", ACTOR_HTG_T, LABEL_HASPARM2, 10 },
5 Plagman 808
 
559 terminx 809
    // model flags
5 Plagman 810
 
559 terminx 811
    { "angoff", ACTOR_ANGOFF, 0, 0 },
812
    { "pitch", ACTOR_PITCH, 0, 0 },
813
    { "roll", ACTOR_ROLL, 0, 0 },
814
    { "mdxoff", ACTOR_MDXOFF, 0, 0 },
815
    { "mdyoff", ACTOR_MDYOFF, 0, 0 },
816
    { "mdzoff", ACTOR_MDZOFF, 0, 0 },
817
    { "mdflags", ACTOR_MDFLAGS, 0, 0 },
590 plagman 818
    { "xpanning", ACTOR_XPANNING, 0, 0 },
819
    { "ypanning", ACTOR_YPANNING, 0, 0 },
853 terminx 820
 
939 terminx 821
    { "htflags", ACTOR_HTFLAGS, 0, 0 },
822
 
1344 terminx 823
    { "alpha", ACTOR_ALPHA, 0, 0 },
1341 terminx 824
 
3192 terminx 825
    { "ulotag", ACTOR_ULOTAG, 0, 0 },
826
    { "uhitag", ACTOR_UHITAG, 0, 0 },
827
 
4146 helixhorne 828
    { "isvalid", ACTOR_ISVALID, 0, 0 },
4313 helixhorne 829
// aliases:
4448 helixhorne 830
    { "movflags", ACTOR_HITAG, 0, 0 },
4313 helixhorne 831
    { "detail", ACTOR_DETAIL, 0, 0 },  // deprecated name for 'blend'
4146 helixhorne 832
 
856 terminx 833
    { "", -1, 0, 0  }     // END OF LIST
834
};
835
 
1143 terminx 836
const memberlabel_t TsprLabels[]=
856 terminx 837
{
853 terminx 838
    // tsprite access
839
 
1007 hnt_ts 840
    { "tsprx", ACTOR_X, 0, 0 },
841
    { "tspry", ACTOR_Y, 0, 0 },
842
    { "tsprz", ACTOR_Z, 0, 0 },
843
    { "tsprcstat", ACTOR_CSTAT, 0, 0 },
844
    { "tsprpicnum", ACTOR_PICNUM, 0, 0 },
845
    { "tsprshade", ACTOR_SHADE, 0, 0 },
846
    { "tsprpal", ACTOR_PAL, 0, 0 },
847
    { "tsprclipdist", ACTOR_CLIPDIST, 0, 0 },
1011 terminx 848
//    { "tsprfiller", ACTOR_DETAIL, 0, 0 },
4313 helixhorne 849
    { "tsprblend", ACTOR_DETAIL, 0, 0 },
1007 hnt_ts 850
    { "tsprxrepeat", ACTOR_XREPEAT, 0, 0 },
851
    { "tspryrepeat", ACTOR_YREPEAT, 0, 0 },
852
    { "tsprxoffset", ACTOR_XOFFSET, 0, 0 },
853
    { "tspryoffset", ACTOR_YOFFSET, 0, 0 },
854
    { "tsprsectnum", ACTOR_SECTNUM, 0, 0 },
855
    { "tsprstatnum", ACTOR_STATNUM, 0, 0 },
856
    { "tsprang", ACTOR_ANG, 0, 0 },
857
    { "tsprowner", ACTOR_OWNER, 0, 0 },
858
#if 1
859
    { "tsprxvel", ACTOR_XVEL, 0, 0 },
860
    { "tspryvel", ACTOR_YVEL, 0, 0 },
861
    { "tsprzvel", ACTOR_ZVEL, 0, 0 },
862
    { "tsprlotag", ACTOR_LOTAG, 0, 0 },
863
    { "tsprhitag", ACTOR_HITAG, 0, 0 },
864
    { "tsprextra", ACTOR_EXTRA, 0, 0 },
865
#endif
4313 helixhorne 866
// aliases:
867
    { "tsprdetail", ACTOR_DETAIL, 0, 0 },  // deprecated name for 'tsprblend'
853 terminx 868
 
559 terminx 869
    { "", -1, 0, 0  }     // END OF LIST
870
};
5 Plagman 871
 
1143 terminx 872
const memberlabel_t PlayerLabels[]=
559 terminx 873
{
874
    { "zoom", PLAYER_ZOOM, 0, 0 },
875
    { "exitx", PLAYER_EXITX, 0, 0 },
876
    { "exity", PLAYER_EXITY, 0, 0 },
870 terminx 877
    { "loogiex", PLAYER_LOOGIEX, LABEL_HASPARM2, 64 },
878
    { "loogiey", PLAYER_LOOGIEY, LABEL_HASPARM2, 64 },
559 terminx 879
    { "numloogs", PLAYER_NUMLOOGS, 0, 0 },
880
    { "loogcnt", PLAYER_LOOGCNT, 0, 0 },
881
    { "posx", PLAYER_POSX, 0, 0 },
882
    { "posy", PLAYER_POSY, 0, 0 },
883
    { "posz", PLAYER_POSZ, 0, 0 },
884
    { "horiz", PLAYER_HORIZ, 0, 0 },
885
    { "ohoriz", PLAYER_OHORIZ, 0, 0 },
886
    { "ohorizoff", PLAYER_OHORIZOFF, 0, 0 },
887
    { "invdisptime", PLAYER_INVDISPTIME, 0, 0 },
888
    { "bobposx", PLAYER_BOBPOSX, 0, 0 },
889
    { "bobposy", PLAYER_BOBPOSY, 0, 0 },
890
    { "oposx", PLAYER_OPOSX, 0, 0 },
891
    { "oposy", PLAYER_OPOSY, 0, 0 },
892
    { "oposz", PLAYER_OPOSZ, 0, 0 },
893
    { "pyoff", PLAYER_PYOFF, 0, 0 },
894
    { "opyoff", PLAYER_OPYOFF, 0, 0 },
895
    { "posxv", PLAYER_POSXV, 0, 0 },
896
    { "posyv", PLAYER_POSYV, 0, 0 },
897
    { "poszv", PLAYER_POSZV, 0, 0 },
898
    { "last_pissed_time", PLAYER_LAST_PISSED_TIME, 0, 0 },
899
    { "truefz", PLAYER_TRUEFZ, 0, 0 },
900
    { "truecz", PLAYER_TRUECZ, 0, 0 },
901
    { "player_par", PLAYER_PLAYER_PAR, 0, 0 },
902
    { "visibility", PLAYER_VISIBILITY, 0, 0 },
903
    { "bobcounter", PLAYER_BOBCOUNTER, 0, 0 },
904
    { "weapon_sway", PLAYER_WEAPON_SWAY, 0, 0 },
905
    { "pals_time", PLAYER_PALS_TIME, 0, 0 },
906
    { "randomflamex", PLAYER_RANDOMFLAMEX, 0, 0 },
907
    { "crack_time", PLAYER_CRACK_TIME, 0, 0 },
908
    { "aim_mode", PLAYER_AIM_MODE, 0, 0 },
909
    { "ang", PLAYER_ANG, 0, 0 },
910
    { "oang", PLAYER_OANG, 0, 0 },
911
    { "angvel", PLAYER_ANGVEL, 0, 0 },
912
    { "cursectnum", PLAYER_CURSECTNUM, 0, 0 },
913
    { "look_ang", PLAYER_LOOK_ANG, 0, 0 },
914
    { "last_extra", PLAYER_LAST_EXTRA, 0, 0 },
915
    { "subweapon", PLAYER_SUBWEAPON, 0, 0 },
916
    { "ammo_amount", PLAYER_AMMO_AMOUNT, LABEL_HASPARM2, MAX_WEAPONS },
917
    { "wackedbyactor", PLAYER_WACKEDBYACTOR, 0, 0 },
918
    { "frag", PLAYER_FRAG, 0, 0 },
919
    { "fraggedself", PLAYER_FRAGGEDSELF, 0, 0 },
920
    { "curr_weapon", PLAYER_CURR_WEAPON, 0, 0 },
921
    { "last_weapon", PLAYER_LAST_WEAPON, 0, 0 },
922
    { "tipincs", PLAYER_TIPINCS, 0, 0 },
923
    { "horizoff", PLAYER_HORIZOFF, 0, 0 },
924
    { "wantweaponfire", PLAYER_WANTWEAPONFIRE, 0, 0 },
925
    { "holoduke_amount", PLAYER_HOLODUKE_AMOUNT, 0, 0 },
926
    { "newowner", PLAYER_NEWOWNER, 0, 0 },
927
    { "hurt_delay", PLAYER_HURT_DELAY, 0, 0 },
928
    { "hbomb_hold_delay", PLAYER_HBOMB_HOLD_DELAY, 0, 0 },
929
    { "jumping_counter", PLAYER_JUMPING_COUNTER, 0, 0 },
930
    { "airleft", PLAYER_AIRLEFT, 0, 0 },
931
    { "knee_incs", PLAYER_KNEE_INCS, 0, 0 },
932
    { "access_incs", PLAYER_ACCESS_INCS, 0, 0 },
933
    { "fta", PLAYER_FTA, 0, 0 },
934
    { "ftq", PLAYER_FTQ, 0, 0 },
935
    { "access_wallnum", PLAYER_ACCESS_WALLNUM, 0, 0 },
936
    { "access_spritenum", PLAYER_ACCESS_SPRITENUM, 0, 0 },
937
    { "kickback_pic", PLAYER_KICKBACK_PIC, 0, 0 },
938
    { "got_access", PLAYER_GOT_ACCESS, 0, 0 },
939
    { "weapon_ang", PLAYER_WEAPON_ANG, 0, 0 },
940
    { "firstaid_amount", PLAYER_FIRSTAID_AMOUNT, 0, 0 },
941
    { "somethingonplayer", PLAYER_SOMETHINGONPLAYER, 0, 0 },
942
    { "on_crane", PLAYER_ON_CRANE, 0, 0 },
943
    { "i", PLAYER_I, 0, 0 },
944
    { "one_parallax_sectnum", PLAYER_ONE_PARALLAX_SECTNUM, 0, 0 },
945
    { "over_shoulder_on", PLAYER_OVER_SHOULDER_ON, 0, 0 },
946
    { "random_club_frame", PLAYER_RANDOM_CLUB_FRAME, 0, 0 },
947
    { "fist_incs", PLAYER_FIST_INCS, 0, 0 },
948
    { "one_eighty_count", PLAYER_ONE_EIGHTY_COUNT, 0, 0 },
949
    { "cheat_phase", PLAYER_CHEAT_PHASE, 0, 0 },
950
    { "dummyplayersprite", PLAYER_DUMMYPLAYERSPRITE, 0, 0 },
951
    { "extra_extra8", PLAYER_EXTRA_EXTRA8, 0, 0 },
952
    { "quick_kick", PLAYER_QUICK_KICK, 0, 0 },
953
    { "heat_amount", PLAYER_HEAT_AMOUNT, 0, 0 },
954
    { "actorsqu", PLAYER_ACTORSQU, 0, 0 },
955
    { "timebeforeexit", PLAYER_TIMEBEFOREEXIT, 0, 0 },
956
    { "customexitsound", PLAYER_CUSTOMEXITSOUND, 0, 0 },
1625 terminx 957
    { "weaprecs", PLAYER_WEAPRECS, LABEL_HASPARM2, MAX_WEAPONS },
559 terminx 958
    { "weapreccnt", PLAYER_WEAPRECCNT, 0, 0 },
959
    { "interface_toggle_flag", PLAYER_INTERFACE_TOGGLE_FLAG, 0, 0 },
960
    { "rotscrnang", PLAYER_ROTSCRNANG, 0, 0 },
961
    { "dead_flag", PLAYER_DEAD_FLAG, 0, 0 },
962
    { "show_empty_weapon", PLAYER_SHOW_EMPTY_WEAPON, 0, 0 },
963
    { "scuba_amount", PLAYER_SCUBA_AMOUNT, 0, 0 },
964
    { "jetpack_amount", PLAYER_JETPACK_AMOUNT, 0, 0 },
965
    { "steroids_amount", PLAYER_STEROIDS_AMOUNT, 0, 0 },
966
    { "shield_amount", PLAYER_SHIELD_AMOUNT, 0, 0 },
967
    { "holoduke_on", PLAYER_HOLODUKE_ON, 0, 0 },
968
    { "pycount", PLAYER_PYCOUNT, 0, 0 },
969
    { "weapon_pos", PLAYER_WEAPON_POS, 0, 0 },
970
    { "frag_ps", PLAYER_FRAG_PS, 0, 0 },
971
    { "transporter_hold", PLAYER_TRANSPORTER_HOLD, 0, 0 },
972
    { "last_full_weapon", PLAYER_LAST_FULL_WEAPON, 0, 0 },
973
    { "footprintshade", PLAYER_FOOTPRINTSHADE, 0, 0 },
974
    { "boot_amount", PLAYER_BOOT_AMOUNT, 0, 0 },
975
    { "scream_voice", PLAYER_SCREAM_VOICE, 0, 0 },
976
    { "gm", PLAYER_GM, 0, 0 },
977
    { "on_warping_sector", PLAYER_ON_WARPING_SECTOR, 0, 0 },
978
    { "footprintcount", PLAYER_FOOTPRINTCOUNT, 0, 0 },
979
    { "hbomb_on", PLAYER_HBOMB_ON, 0, 0 },
980
    { "jumping_toggle", PLAYER_JUMPING_TOGGLE, 0, 0 },
981
    { "rapid_fire_hold", PLAYER_RAPID_FIRE_HOLD, 0, 0 },
982
    { "on_ground", PLAYER_ON_GROUND, 0, 0 },
983
    { "name", PLAYER_NAME,  LABEL_ISSTRING, 32 },
984
    { "inven_icon", PLAYER_INVEN_ICON, 0, 0 },
985
    { "buttonpalette", PLAYER_BUTTONPALETTE, 0, 0 },
986
    { "jetpack_on", PLAYER_JETPACK_ON, 0, 0 },
987
    { "spritebridge", PLAYER_SPRITEBRIDGE, 0, 0 },
988
    { "lastrandomspot", PLAYER_LASTRANDOMSPOT, 0, 0 },
989
    { "scuba_on", PLAYER_SCUBA_ON, 0, 0 },
990
    { "footprintpal", PLAYER_FOOTPRINTPAL, 0, 0 },
991
    { "heat_on", PLAYER_HEAT_ON, 0, 0 },
992
    { "holster_weapon", PLAYER_HOLSTER_WEAPON, 0, 0 },
993
    { "falling_counter", PLAYER_FALLING_COUNTER, 0, 0 },
994
    { "gotweapon", PLAYER_GOTWEAPON, LABEL_HASPARM2, MAX_WEAPONS },
995
    { "refresh_inventory", PLAYER_REFRESH_INVENTORY, 0, 0 },
996
    { "palette", PLAYER_PALETTE, 0, 0 },
997
    { "toggle_key_flag", PLAYER_TOGGLE_KEY_FLAG, 0, 0 },
998
    { "knuckle_incs", PLAYER_KNUCKLE_INCS, 0, 0 },
999
    { "walking_snd_toggle", PLAYER_WALKING_SND_TOGGLE, 0, 0 },
1000
    { "palookup", PLAYER_PALOOKUP, 0, 0 },
1001
    { "hard_landing", PLAYER_HARD_LANDING, 0, 0 },
1002
    { "max_secret_rooms", PLAYER_MAX_SECRET_ROOMS, 0, 0 },
1003
    { "secret_rooms", PLAYER_SECRET_ROOMS, 0, 0 },
869 terminx 1004
    { "pals", PLAYER_PALS, LABEL_HASPARM2, 3 },
559 terminx 1005
    { "max_actors_killed", PLAYER_MAX_ACTORS_KILLED, 0, 0 },
1006
    { "actors_killed", PLAYER_ACTORS_KILLED, 0, 0 },
1007
    { "return_to_center", PLAYER_RETURN_TO_CENTER, 0, 0 },
1008
    { "runspeed", PLAYER_RUNSPEED, 0, 0 },
1009
    { "sbs", PLAYER_SBS, 0, 0 },
1010
    { "reloading", PLAYER_RELOADING, 0, 0 },
1011
    { "auto_aim", PLAYER_AUTO_AIM, 0, 0 },
1012
    { "movement_lock", PLAYER_MOVEMENT_LOCK, 0, 0 },
1013
    { "sound_pitch", PLAYER_SOUND_PITCH, 0, 0 },
1014
    { "weaponswitch", PLAYER_WEAPONSWITCH, 0, 0 },
1015
    { "team", PLAYER_TEAM, 0, 0 },
566 terminx 1016
    { "max_player_health", PLAYER_MAX_PLAYER_HEALTH, 0, 0 },
1017
    { "max_shield_amount", PLAYER_MAX_SHIELD_AMOUNT, 0, 0 },
1018
    { "max_ammo_amount", PLAYER_MAX_AMMO_AMOUNT, LABEL_HASPARM2, MAX_WEAPONS },
1062 terminx 1019
    { "last_quick_kick", PLAYER_LAST_QUICK_KICK, 0, 0 },
3100 hendricks2 1020
    { "autostep", PLAYER_AUTOSTEP, 0, 0 },
1021
    { "autostep_sbw", PLAYER_AUTOSTEP_SBW, 0, 0 },
5099 hendricks2 1022
    { "hudpal", PLAYER_HUDPAL, 0, 0 },
5165 hendricks2 1023
    { "index", PLAYER_INDEX, 0, 0 },
559 terminx 1024
    { "", -1, 0, 0  }     // END OF LIST
1025
};
5 Plagman 1026
 
1143 terminx 1027
const memberlabel_t ProjectileLabels[]=
559 terminx 1028
{
1029
    { "workslike", PROJ_WORKSLIKE, 0, 0 },
1030
    { "spawns", PROJ_SPAWNS, 0, 0 },
1031
    { "sxrepeat", PROJ_SXREPEAT, 0, 0 },
1032
    { "syrepeat", PROJ_SYREPEAT, 0, 0 },
1033
    { "sound", PROJ_SOUND, 0, 0 },
1034
    { "isound", PROJ_ISOUND, 0, 0 },
1035
    { "vel", PROJ_VEL, 0, 0 },
1036
    { "extra", PROJ_EXTRA, 0, 0 },
1037
    { "decal", PROJ_DECAL, 0, 0 },
1038
    { "trail", PROJ_TRAIL, 0, 0 },
1039
    { "txrepeat", PROJ_TXREPEAT, 0, 0 },
1040
    { "tyrepeat", PROJ_TYREPEAT, 0, 0 },
1041
    { "toffset", PROJ_TOFFSET, 0, 0 },
1042
    { "tnum", PROJ_TNUM, 0, 0 },
1043
    { "drop", PROJ_DROP, 0, 0 },
1044
    { "cstat", PROJ_CSTAT, 0, 0 },
1045
    { "clipdist", PROJ_CLIPDIST, 0, 0 },
1046
    { "shade", PROJ_SHADE, 0, 0 },
1047
    { "xrepeat", PROJ_XREPEAT, 0, 0 },
1048
    { "yrepeat", PROJ_YREPEAT, 0, 0 },
1049
    { "pal", PROJ_PAL, 0, 0 },
1050
    { "extra_rand", PROJ_EXTRA_RAND, 0, 0 },
1051
    { "hitradius", PROJ_HITRADIUS, 0, 0 },
3053 terminx 1052
    { "velmult", PROJ_MOVECNT, 0, 0 },
559 terminx 1053
    { "offset", PROJ_OFFSET, 0, 0 },
1054
    { "bounces", PROJ_BOUNCES, 0, 0 },
1055
    { "bsound", PROJ_BSOUND, 0, 0 },
1056
    { "range", PROJ_RANGE, 0, 0 },
1315 terminx 1057
    { "flashcolor", PROJ_FLASH_COLOR, 0, 0 },
3866 helixhorne 1058
    { "userdata", PROJ_USERDATA, 0, 0 },
559 terminx 1059
    { "", -1, 0, 0  }     // END OF LIST
1060
};
5 Plagman 1061
 
1143 terminx 1062
const memberlabel_t UserdefsLabels[]=
559 terminx 1063
{
1064
    //        { "<null>", 1, 0, 0 },
1065
    { "god", USERDEFS_GOD, 0, 0 },
1066
    { "warp_on", USERDEFS_WARP_ON, 0, 0 },
1067
    { "cashman", USERDEFS_CASHMAN, 0, 0 },
1068
    { "eog", USERDEFS_EOG, 0, 0 },
1069
    { "showallmap", USERDEFS_SHOWALLMAP, 0, 0 },
1070
    { "show_help", USERDEFS_SHOW_HELP, 0, 0 },
1071
    { "scrollmode", USERDEFS_SCROLLMODE, 0, 0 },
1072
    { "clipping", USERDEFS_CLIPPING, 0, 0 },
1073
    { "user_name", USERDEFS_USER_NAME, LABEL_HASPARM2, MAXPLAYERS },
1074
    { "ridecule", USERDEFS_RIDECULE, LABEL_HASPARM2 | LABEL_ISSTRING, 10 },
1075
    { "savegame", USERDEFS_SAVEGAME, LABEL_HASPARM2 | LABEL_ISSTRING, 10 },
1076
    { "pwlockout", USERDEFS_PWLOCKOUT, LABEL_ISSTRING, 128 },
1077
    { "rtsname;", USERDEFS_RTSNAME,  LABEL_ISSTRING, 128 },
1078
    { "overhead_on", USERDEFS_OVERHEAD_ON, 0, 0 },
1079
    { "last_overhead", USERDEFS_LAST_OVERHEAD, 0, 0 },
1080
    { "showweapons", USERDEFS_SHOWWEAPONS, 0, 0 },
5 Plagman 1081
 
559 terminx 1082
    { "pause_on", USERDEFS_PAUSE_ON, 0, 0 },
1083
    { "from_bonus", USERDEFS_FROM_BONUS, 0, 0 },
1084
    { "camerasprite", USERDEFS_CAMERASPRITE, 0, 0 },
1085
    { "last_camsprite", USERDEFS_LAST_CAMSPRITE, 0, 0 },
1086
    { "last_level", USERDEFS_LAST_LEVEL, 0, 0 },
1087
    { "secretlevel", USERDEFS_SECRETLEVEL, 0, 0 },
4968 hendricks2 1088
    { "playerbest", USERDEFS_PLAYERBEST, 0, 0 },
5 Plagman 1089
 
559 terminx 1090
    { "const_visibility", USERDEFS_CONST_VISIBILITY, 0, 0 },
1091
    { "uw_framerate", USERDEFS_UW_FRAMERATE, 0, 0 },
1092
    { "camera_time", USERDEFS_CAMERA_TIME, 0, 0 },
1093
    { "folfvel", USERDEFS_FOLFVEL, 0, 0 },
1094
    { "folavel", USERDEFS_FOLAVEL, 0, 0 },
1095
    { "folx", USERDEFS_FOLX, 0, 0 },
1096
    { "foly", USERDEFS_FOLY, 0, 0 },
1097
    { "fola", USERDEFS_FOLA, 0, 0 },
1098
    { "reccnt", USERDEFS_RECCNT, 0, 0 },
5 Plagman 1099
 
4945 hendricks2 1100
    { "m_origin_x", USERDEFS_M_ORIGIN_X, 0, 0 },
1101
    { "m_origin_y", USERDEFS_M_ORIGIN_Y, 0, 0 },
1102
 
5043 hendricks2 1103
    { "usevoxels", USERDEFS_USEVOXELS, 0, 0 },
1104
    { "usehightile", USERDEFS_USEHIGHTILE, 0, 0 },
1105
    { "usemodels", USERDEFS_USEMODELS, 0, 0 },
1106
 
559 terminx 1107
    { "entered_name", USERDEFS_ENTERED_NAME, 0, 0 },
1108
    { "screen_tilting", USERDEFS_SCREEN_TILTING, 0, 0 },
1109
    { "shadows", USERDEFS_SHADOWS, 0, 0 },
1110
    { "fta_on", USERDEFS_FTA_ON, 0, 0 },
1111
    { "executions", USERDEFS_EXECUTIONS, 0, 0 },
1112
    { "auto_run", USERDEFS_AUTO_RUN, 0, 0 },
1113
    { "coords", USERDEFS_COORDS, 0, 0 },
1114
    { "tickrate", USERDEFS_TICKRATE, 0, 0 },
1115
    { "m_coop", USERDEFS_M_COOP, 0, 0 },
1116
    { "coop", USERDEFS_COOP, 0, 0 },
1117
    { "screen_size", USERDEFS_SCREEN_SIZE, 0, 0 },
1118
    { "lockout", USERDEFS_LOCKOUT, 0, 0 },
1119
    { "crosshair", USERDEFS_CROSSHAIR, 0, 0 },
4215 helixhorne 1120
//    { "wchoice[MAXPLAYERS][MAX_WEAPONS]", USERDEFS_WCHOICE, 0, 0 },
559 terminx 1121
    { "playerai", USERDEFS_PLAYERAI, 0, 0 },
1122
    { "respawn_monsters", USERDEFS_RESPAWN_MONSTERS, 0, 0 },
1123
    { "respawn_items", USERDEFS_RESPAWN_ITEMS, 0, 0 },
1124
    { "respawn_inventory", USERDEFS_RESPAWN_INVENTORY, 0, 0 },
1125
    { "recstat", USERDEFS_RECSTAT, 0, 0 },
1126
    { "monsters_off", USERDEFS_MONSTERS_OFF, 0, 0 },
1127
    { "brightness", USERDEFS_BRIGHTNESS, 0, 0 },
1128
    { "m_respawn_items", USERDEFS_M_RESPAWN_ITEMS, 0, 0 },
1129
    { "m_respawn_monsters", USERDEFS_M_RESPAWN_MONSTERS, 0, 0 },
1130
    { "m_respawn_inventory", USERDEFS_M_RESPAWN_INVENTORY, 0, 0 },
1131
    { "m_recstat", USERDEFS_M_RECSTAT, 0, 0 },
1132
    { "m_monsters_off", USERDEFS_M_MONSTERS_OFF, 0, 0 },
1133
    { "detail", USERDEFS_DETAIL, 0, 0 },
1134
    { "m_ffire", USERDEFS_M_FFIRE, 0, 0 },
1135
    { "ffire", USERDEFS_FFIRE, 0, 0 },
1136
    { "m_player_skill", USERDEFS_M_PLAYER_SKILL, 0, 0 },
1137
    { "m_level_number", USERDEFS_M_LEVEL_NUMBER, 0, 0 },
1138
    { "m_volume_number", USERDEFS_M_VOLUME_NUMBER, 0, 0 },
1139
    { "multimode", USERDEFS_MULTIMODE, 0, 0 },
1140
    { "player_skill", USERDEFS_PLAYER_SKILL, 0, 0 },
1141
    { "level_number", USERDEFS_LEVEL_NUMBER, 0, 0 },
1142
    { "volume_number", USERDEFS_VOLUME_NUMBER, 0, 0 },
1143
    { "m_marker", USERDEFS_M_MARKER, 0, 0 },
1144
    { "marker", USERDEFS_MARKER, 0, 0 },
1145
    { "mouseflip", USERDEFS_MOUSEFLIP, 0, 0 },
1146
    { "statusbarscale", USERDEFS_STATUSBARSCALE, 0, 0 },
1147
    { "drawweapon", USERDEFS_DRAWWEAPON, 0, 0 },
1148
    { "mouseaiming", USERDEFS_MOUSEAIMING, 0, 0 },
1149
    { "weaponswitch", USERDEFS_WEAPONSWITCH, 0, 0 },
1150
    { "democams", USERDEFS_DEMOCAMS, 0, 0 },
1151
    { "color", USERDEFS_COLOR, 0, 0 },
1152
    { "msgdisptime", USERDEFS_MSGDISPTIME, 0, 0 },
1153
    { "statusbarmode", USERDEFS_STATUSBARMODE, 0, 0 },
1154
    { "m_noexits", USERDEFS_M_NOEXITS, 0, 0 },
1155
    { "noexits", USERDEFS_NOEXITS, 0, 0 },
1156
    { "autovote", USERDEFS_AUTOVOTE, 0, 0 },
1157
    { "automsg", USERDEFS_AUTOMSG, 0, 0 },
1158
    { "idplayers", USERDEFS_IDPLAYERS, 0, 0 },
1159
    { "team", USERDEFS_TEAM, 0, 0 },
1160
    { "viewbob", USERDEFS_VIEWBOB, 0, 0 },
1161
    { "weaponsway", USERDEFS_WEAPONSWAY, 0, 0 },
1162
    { "angleinterpolation", USERDEFS_ANGLEINTERPOLATION, 0, 0 },
926 terminx 1163
    { "obituaries", USERDEFS_OBITUARIES, 0, 0 },
674 terminx 1164
    { "levelstats", USERDEFS_LEVELSTATS, 0, 0 },
881 terminx 1165
    { "crosshairscale", USERDEFS_CROSSHAIRSCALE, 0, 0 },
934 terminx 1166
    { "althud", USERDEFS_ALTHUD, 0, 0 },
990 terminx 1167
    { "display_bonus_screen", USERDEFS_DISPLAY_BONUS_SCREEN, 0, 0 },
1082 terminx 1168
    { "show_level_text", USERDEFS_SHOW_LEVEL_TEXT, 0, 0 },
1090 terminx 1169
    { "weaponscale", USERDEFS_WEAPONSCALE, 0, 0 },
1095 terminx 1170
    { "textscale", USERDEFS_TEXTSCALE, 0, 0 },
3071 terminx 1171
    { "runkey_mode", USERDEFS_RUNKEY_MODE, 0, 0 },
4970 hendricks2 1172
    { "musictoggle", USERDEFS_MUSICTOGGLE, 0, 0 },
5044 hendricks2 1173
    { "gametypeflags", USERDEFS_GAMETYPEFLAGS, 0, 0 },
1174
    { "m_gametypeflags", USERDEFS_M_GAMETYPEFLAGS, 0, 0 },
5248 hendricks2 1175
    { "globalflags", USERDEFS_GLOBALFLAGS, 0, 0 },
1176
    { "globalgameflags", USERDEFS_GLOBALGAMEFLAGS, 0, 0 },
5489 terminx 1177
    { "vm_player", USERDEFS_VM_PLAYER, 0, 0 },
1178
    { "vm_sprite", USERDEFS_VM_SPRITE, 0, 0 },
1179
    { "vm_distance", USERDEFS_VM_DISTANCE, 0, 0 },
5553 hendricks2 1180
    { "soundtoggle", USERDEFS_SOUNDTOGGLE, 0, 0 },
559 terminx 1181
    { "", -1, 0, 0  }     // END OF LIST
1182
};
5 Plagman 1183
 
1143 terminx 1184
const memberlabel_t InputLabels[]=
559 terminx 1185
{
1186
    { "avel", INPUT_AVEL, 0, 0 },
1187
    { "horz", INPUT_HORZ, 0, 0 },
1188
    { "fvel", INPUT_FVEL, 0, 0 },
1189
    { "svel", INPUT_SVEL, 0, 0 },
1190
    { "bits", INPUT_BITS, 0, 0 },
1191
    { "extbits", INPUT_EXTBITS, 0, 0 },
1192
    { "", -1, 0, 0  }     // END OF LIST
1193
};
5 Plagman 1194
 
5115 hendricks2 1195
const memberlabel_t TileDataLabels[]=
1196
{
1197
    // tilesiz[]
1198
    { "xsize", TILEDATA_XSIZE, 0, 0 },
1199
    { "ysize", TILEDATA_YSIZE, 0, 0 },
1200
 
1201
    // picanm[]
1202
    { "animframes", TILEDATA_ANIMFRAMES, 0, 0 },
1203
    { "xoffset", TILEDATA_XOFFSET, 0, 0 },
1204
    { "yoffset", TILEDATA_YOFFSET, 0, 0 },
1205
    { "animspeed", TILEDATA_ANIMSPEED, 0, 0 },
1206
    { "animtype", TILEDATA_ANIMTYPE, 0, 0 },
1207
 
1208
    // g_tile[]
1209
    { "gameflags", TILEDATA_GAMEFLAGS, 0, 0 },
1210
 
1211
    { "", -1, 0, 0  }     // END OF LIST
1212
};
1213
 
1214
const memberlabel_t PalDataLabels[]=
1215
{
1216
    // g_noFloorPal[]
1217
    { "nofloorpal", PALDATA_NOFLOORPAL, 0, 0 },
1218
 
1219
    { "", -1, 0, 0  }     // END OF LIST
1220
};
1221
 
3354 helixhorne 1222
#endif
1223
 
1064 terminx 1224
char *bitptr; // pointer to bitmap of which bytecode positions contain pointers
5533 terminx 1225
#define BITPTR_SET(x) (bitptr[(x)>>3] |= (1<<((x)&7)))
1226
#define BITPTR_CLEAR(x) (bitptr[(x)>>3] &= ~(1<<((x)&7)))
1227
#define BITPTR_IS_POINTER(x) (bitptr[(x)>>3] & (1<<((x) &7)))
978 terminx 1228
 
3415 helixhorne 1229
#if !defined LUNATIC
1625 terminx 1230
hashtable_t h_gamevars    = { MAXGAMEVARS>>1, NULL };
1231
hashtable_t h_arrays      = { MAXGAMEARRAYS>>1, NULL };
1232
hashtable_t h_labels      = { 11264>>1, NULL };
3354 helixhorne 1233
 
5502 terminx 1234
static hashtable_t h_keywords   = { CON_END>>1, NULL };
1024 terminx 1235
 
5502 terminx 1236
static hashtable_t h_sector     = { SECTOR_END>>1, NULL };
1237
static hashtable_t h_wall       = { WALL_END>>1, NULL };
1238
static hashtable_t h_userdef    = { USERDEFS_END>>1, NULL };
1024 terminx 1239
 
5502 terminx 1240
static hashtable_t h_projectile = { PROJ_END>>1, NULL };
1241
static hashtable_t h_player     = { PLAYER_END>>1, NULL };
1242
static hashtable_t h_input      = { INPUT_END>>1, NULL };
1243
static hashtable_t h_actor      = { ACTOR_END>>1, NULL };
1244
static hashtable_t h_tsprite    = { ACTOR_END>>1, NULL };
1024 terminx 1245
 
5502 terminx 1246
static hashtable_t h_tiledata   = { TILEDATA_END>>1, NULL };
1247
static hashtable_t h_paldata    = { PALDATA_END>>1, NULL };
5115 hendricks2 1248
 
1201 terminx 1249
void C_InitHashes()
1024 terminx 1250
{
1205 terminx 1251
    int32_t i;
1024 terminx 1252
 
1625 terminx 1253
    hash_init(&h_gamevars);
1254
    hash_init(&h_arrays);
1255
    hash_init(&h_labels);
1031 hnt_ts 1256
    inithashnames();
3834 hendricks2 1257
    initsoundhashnames();
1024 terminx 1258
 
1625 terminx 1259
    hash_init(&h_keywords);
5502 terminx 1260
    hash_init(&h_sector);
1261
    hash_init(&h_wall);
1262
    hash_init(&h_userdef);
1263
    hash_init(&h_projectile);
1264
    hash_init(&h_player);
1265
    hash_init(&h_input);
1266
    hash_init(&h_actor);
1267
    hash_init(&h_tsprite);
1268
    hash_init(&h_tiledata);
1269
    hash_init(&h_paldata);
1544 terminx 1270
 
5519 hendricks2 1271
    for (i=0; i<NUMKEYWORDS; i++) hash_add(&h_keywords,keyw[i],i,0);
5499 terminx 1272
    for (i=0; i<NUMALTKEYWORDS; i++) hash_add(&h_keywords, altkeyw[i].token, altkeyw[i].val, 0);
5502 terminx 1273
    for (i=0; SectorLabels[i].lId >= 0; i++) hash_add(&h_sector,SectorLabels[i].name,i,0);
1274
    for (i=0; WallLabels[i].lId >= 0; i++) hash_add(&h_wall,WallLabels[i].name,i,0);
1275
    for (i=0; UserdefsLabels[i].lId >= 0; i++) hash_add(&h_userdef,UserdefsLabels[i].name,i,0);
1276
    for (i=0; ProjectileLabels[i].lId >= 0; i++) hash_add(&h_projectile,ProjectileLabels[i].name,i,0);
1277
    for (i=0; PlayerLabels[i].lId >= 0; i++) hash_add(&h_player,PlayerLabels[i].name,i,0);
1278
    for (i=0; InputLabels[i].lId >= 0; i++) hash_add(&h_input,InputLabels[i].name,i,0);
1279
    for (i=0; ActorLabels[i].lId >= 0; i++) hash_add(&h_actor,ActorLabels[i].name,i,0);
1280
    for (i=0; TsprLabels[i].lId >= 0; i++) hash_add(&h_tsprite,TsprLabels[i].name,i,0);
1281
    for (i=0; TileDataLabels[i].lId >= 0; i++) hash_add(&h_tiledata,TileDataLabels[i].name,i,0);
1282
    for (i=0; PalDataLabels[i].lId >= 0; i++) hash_add(&h_paldata,PalDataLabels[i].name,i,0);
1024 terminx 1283
}
1025 terminx 1284
 
1390 terminx 1285
// "magic" number for { and }, overrides line number in compiled code for later detection
1201 terminx 1286
#define IFELSE_MAGIC 31337
1205 terminx 1287
static int32_t g_ifElseAborted;
1200 terminx 1288
 
1820 terminx 1289
static int32_t C_SetScriptSize(int32_t newsize)
874 terminx 1290
{
5521 hendricks2 1291
    intptr_t const oscript = (intptr_t)script;
874 terminx 1292
    intptr_t *newscript;
1293
    intptr_t i, j;
1205 terminx 1294
    int32_t osize = g_scriptSize;
1820 terminx 1295
    char *scriptptrs;
1064 terminx 1296
    char *newbitptr;
2262 helixhorne 1297
 
4491 helixhorne 1298
    scriptptrs = (char *)Xcalloc(1, g_scriptSize * sizeof(uint8_t));
1820 terminx 1299
 
1229 terminx 1300
    for (i=g_scriptSize-1; i>=0; i--)
874 terminx 1301
    {
5533 terminx 1302
        if (BITPTR_IS_POINTER(i))
874 terminx 1303
        {
4680 terminx 1304
            if (EDUKE32_PREDICT_FALSE((intptr_t)script[i] < (intptr_t)&script[0] || (intptr_t)script[i] >= (intptr_t)&script[g_scriptSize]))
1820 terminx 1305
            {
1306
                g_numCompilerErrors++;
1909 terminx 1307
                initprintf("Internal compiler error at %" PRIdPTR " (0x%" PRIxPTR ")\n",i,i);
5513 terminx 1308
                VM_ScriptInfo(&script[i], 16);
1820 terminx 1309
            }
1310
 
874 terminx 1311
            scriptptrs[i] = 1;
976 terminx 1312
            script[i] -= (intptr_t)&script[0];
874 terminx 1313
        }
1314
        else scriptptrs[i] = 0;
1315
    }
1316
 
3102 terminx 1317
    G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), script, P2I_FWD_NON0);
1318
    G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), script, P2I_FWD_NON0);
1820 terminx 1319
 
4491 helixhorne 1320
    newscript = (intptr_t *)Xrealloc(script, newsize * sizeof(intptr_t));
1321
    newbitptr = (char *)Xcalloc(1,(((newsize+7)>>3)+1) * sizeof(uint8_t));
874 terminx 1322
 
1820 terminx 1323
    if (newsize >= osize)
1029 terminx 1324
    {
1820 terminx 1325
        Bmemset(&newscript[0]+osize,0,(newsize-osize) * sizeof(uint8_t));
1229 terminx 1326
        Bmemcpy(newbitptr,bitptr,sizeof(uint8_t) *((osize+7)>>3));
1029 terminx 1327
    }
1390 terminx 1328
    else
1820 terminx 1329
        Bmemcpy(newbitptr,bitptr,sizeof(uint8_t) *((newsize+7)>>3));
1029 terminx 1330
 
1064 terminx 1331
    Bfree(bitptr);
1332
    bitptr = newbitptr;
1390 terminx 1333
    if (script != newscript)
1334
    {
3278 hendricks2 1335
        initprintf("Relocating compiled code from to 0x%" PRIxPTR " to 0x%" PRIxPTR "\n", (intptr_t)script, (intptr_t)newscript);
1390 terminx 1336
        script = newscript;
1337
    }
1338
 
1820 terminx 1339
    g_scriptSize = newsize;
5521 hendricks2 1340
    g_scriptPtr = script + (intptr_t)g_scriptPtr - oscript;
976 terminx 1341
 
1544 terminx 1342
    if (g_caseScriptPtr)
5521 hendricks2 1343
        g_caseScriptPtr = script + (intptr_t)g_caseScriptPtr - oscript;
1544 terminx 1344
 
1820 terminx 1345
    for (i=(((newsize>=osize)?osize:newsize))-1; i>=0; i--)
1346
        if (scriptptrs[i])
1347
        {
1950 helixhorne 1348
            j = (intptr_t)script[i]+(intptr_t)&script[0];
1820 terminx 1349
            script[i] = j;
1350
        }
874 terminx 1351
 
3102 terminx 1352
    G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), script, P2I_BACK_NON0);
1353
    G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), script, P2I_BACK_NON0);
874 terminx 1354
 
1355
    Bfree(scriptptrs);
1356
    return 0;
1357
}
1358
 
2640 helixhorne 1359
static int32_t ispecial(const char c)
1593 terminx 1360
{
1361
    if (c == ' ' || c == 0x0d || c == '(' || c == ')' ||
1616 helixhorne 1362
            c == ',' || c == ';' || (c == 0x0a /*&& ++g_lineNumber*/))
1593 terminx 1363
        return 1;
1545 terminx 1364
 
1593 terminx 1365
    return 0;
1366
}
1367
 
5505 terminx 1368
static inline void C_NextLine(void)
5089 hendricks2 1369
{
1370
    while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0)
1371
        textptr++;
1372
}
1545 terminx 1373
 
5505 terminx 1374
static inline void C_SkipSpace(void)
5089 hendricks2 1375
{
1376
    while (*textptr == ' ' || *textptr == '\t')
1377
        textptr++;
1378
}
1379
 
1205 terminx 1380
static int32_t C_SkipComments(void)
5 Plagman 1381
{
1040 terminx 1382
    do
5 Plagman 1383
    {
1544 terminx 1384
        switch (*textptr)
335 terminx 1385
        {
1544 terminx 1386
        case '\n':
1143 terminx 1387
            g_lineNumber++;
1544 terminx 1388
        case ' ':
1389
        case '\t':
1390
        case '\r':
1665 terminx 1391
        case 0x1a:
5 Plagman 1392
            textptr++;
1544 terminx 1393
            break;
1394
        case '/':
1395
            switch (textptr[1])
5 Plagman 1396
            {
1544 terminx 1397
            case '/': // C++ style comment
1398
                if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1)
1399
                    initprintf("%s:%d: debug: got comment.\n",g_szScriptFileName,g_lineNumber);
1545 terminx 1400
                C_NextLine();
1665 terminx 1401
                continue;
1544 terminx 1402
            case '*': // beginning of a C style comment
1403
                if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1)
1404
                    initprintf("%s:%d: debug: got start of comment block.\n",g_szScriptFileName,g_lineNumber);
1405
                do
1406
                {
1407
                    if (*textptr == '\n')
1408
                        g_lineNumber++;
1409
                    textptr++;
1410
                }
1411
                while (*textptr && (textptr[0] != '*' || textptr[1] != '/'));
1412
 
4680 terminx 1413
                if (EDUKE32_PREDICT_FALSE(!*textptr))
1544 terminx 1414
                {
1415
                    if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug)
1416
                        initprintf("%s:%d: debug: EOF in comment!\n",g_szScriptFileName,g_lineNumber);
1417
                    C_ReportError(-1);
1418
                    initprintf("%s:%d: error: found `/*' with no `*/'.\n",g_szScriptFileName,g_lineNumber);
5521 hendricks2 1419
                    g_parsingActorPtr = g_processingState = g_numBraces = 0;
1544 terminx 1420
                    g_numCompilerErrors++;
1665 terminx 1421
                    continue;
1544 terminx 1422
                }
1423
 
1424
                if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1)
1425
                    initprintf("%s:%d: debug: got end of comment block.\n",g_szScriptFileName,g_lineNumber);
1426
 
1427
                textptr+=2;
1665 terminx 1428
                continue;
5 Plagman 1429
            }
1665 terminx 1430
            continue;
1544 terminx 1431
 
1545 terminx 1432
        default:
1433
            if (ispecial(*textptr))
1434
            {
1435
                textptr++;
1665 terminx 1436
                continue;
1545 terminx 1437
            }
1544 terminx 1438
        case 0: // EOF
1439
            return ((g_scriptPtr-script) > (g_scriptSize-32)) ? C_SetScriptSize(g_scriptSize<<1) : 0;
5 Plagman 1440
        }
1046 terminx 1441
    }
1544 terminx 1442
    while (1);
5 Plagman 1443
}
1444
 
1625 terminx 1445
#define GetDefID(szGameLabel) hash_find(&h_gamevars,szGameLabel)
1446
#define GetADefID(szGameLabel) hash_find(&h_arrays,szGameLabel)
1189 terminx 1447
 
2640 helixhorne 1448
static int32_t isaltok(const char c)
5 Plagman 1449
{
1213 terminx 1450
    return (isalnum(c) || c == '{' || c == '}' || c == '/' || c == '\\' ||
1215 terminx 1451
            c == '*' || c == '-' || c == '_' || c == '.');
5 Plagman 1452
}
1453
 
4474 helixhorne 1454
static int32_t C_IsLabelChar(const char c, int32_t i)
1455
{
1456
    return (isalnum(c) || c=='_' || c=='*' || c=='?' ||
1457
            (i > 0 && (c=='+' || c=='-' || c=='.')));
1458
}
1459
 
1206 terminx 1460
static inline int32_t C_GetLabelNameID(const memberlabel_t *pLabel, hashtable_t *tH, const char *psz)
5 Plagman 1461
{
1462
    // find the label psz in the table pLabel.
1463
    // returns the ID for the label, or -1
1464
 
1857 terminx 1465
    int32_t l = hash_findcase(tH,psz);
1466
    return (l >= 0) ? pLabel[l].lId : -1;
5 Plagman 1467
}
1468
 
1206 terminx 1469
static inline int32_t C_GetLabelNameOffset(hashtable_t *tH, const char *psz)
5 Plagman 1470
{
1471
    // find the label psz in the table pLabel.
1472
    // returns the offset in the array for the label, or -1
1473
 
1206 terminx 1474
    return hash_findcase(tH,psz);
5 Plagman 1475
}
1476
 
1143 terminx 1477
static void C_GetNextLabelName(void)
5 Plagman 1478
{
1857 terminx 1479
    int32_t i = 0;
5 Plagman 1480
 
1143 terminx 1481
    C_SkipComments();
5 Plagman 1482
 
4474 helixhorne 1483
//    while (ispecial(*textptr) == 0 && *textptr!='['&& *textptr!=']' && *textptr!='\t' && *textptr!='\n' && *textptr!='\r')
1484
    while (C_IsLabelChar(*textptr, i))
1143 terminx 1485
        label[(g_numLabels<<6)+(i++)] = *(textptr++);
1857 terminx 1486
    label[(g_numLabels<<6)+i] = 0;
5 Plagman 1487
 
1857 terminx 1488
    if (!(g_numCompilerErrors|g_numCompilerWarnings) && g_scriptDebug > 1)
5537 terminx 1489
        initprintf("%s:%d: debug: label `%s'.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6));
5 Plagman 1490
}
1491
 
1205 terminx 1492
static int32_t C_GetKeyword(void)
5 Plagman 1493
{
1205 terminx 1494
    int32_t i;
5 Plagman 1495
    char *temptextptr;
1496
 
1143 terminx 1497
    C_SkipComments();
5 Plagman 1498
 
1499
    temptextptr = textptr;
1500
 
1857 terminx 1501
    if (*temptextptr == 0) // EOF
1502
        return -2;
1503
 
333 terminx 1504
    while (isaltok(*temptextptr) == 0)
5 Plagman 1505
    {
1506
        temptextptr++;
333 terminx 1507
        if (*temptextptr == 0)
5 Plagman 1508
            return 0;
1509
    }
1510
 
1511
    i = 0;
333 terminx 1512
    while (isaltok(*temptextptr))
1034 terminx 1513
        tempbuf[i++] = *(temptextptr++);
5 Plagman 1514
    tempbuf[i] = 0;
1857 terminx 1515
 
1625 terminx 1516
    return hash_find(&h_keywords,tempbuf);
5 Plagman 1517
}
1518
 
1205 terminx 1519
static int32_t C_GetNextKeyword(void) //Returns its code #
5 Plagman 1520
{
1205 terminx 1521
    int32_t i, l;
5 Plagman 1522
 
1143 terminx 1523
    C_SkipComments();
5 Plagman 1524
 
1544 terminx 1525
    if (*textptr == 0) // EOF
1857 terminx 1526
        return -2;
5 Plagman 1527
 
1528
    l = 0;
333 terminx 1529
    while (isaltok(*(textptr+l)))
5 Plagman 1530
    {
1531
        tempbuf[l] = textptr[l];
1532
        l++;
1533
    }
1534
    tempbuf[l] = 0;
1535
 
4680 terminx 1536
    if (EDUKE32_PREDICT_TRUE((i = hash_find(&h_keywords,tempbuf)) >= 0))
5 Plagman 1537
    {
1200 terminx 1538
        if (i == CON_LEFTBRACE || i == CON_RIGHTBRACE || i == CON_NULLOP)
1201 terminx 1539
            *g_scriptPtr = i + (IFELSE_MAGIC<<12);
1200 terminx 1540
        else *g_scriptPtr = i + (g_lineNumber<<12);
1393 terminx 1541
 
5533 terminx 1542
        BITPTR_CLEAR(g_scriptPtr-script);
1024 terminx 1543
        textptr += l;
1143 terminx 1544
        g_scriptPtr++;
1393 terminx 1545
 
1143 terminx 1546
        if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug)
5537 terminx 1547
            initprintf("%s:%d: debug: keyword `%s'.\n",g_szScriptFileName,g_lineNumber,keyw[i]);
1024 terminx 1548
        return i;
5 Plagman 1549
    }
1550
 
1551
    textptr += l;
1857 terminx 1552
    g_numCompilerErrors++;
5 Plagman 1553
 
4680 terminx 1554
    if (EDUKE32_PREDICT_FALSE((tempbuf[0] == '{' || tempbuf[0] == '}') && tempbuf[1] != 0))
5 Plagman 1555
    {
1143 terminx 1556
        C_ReportError(-1);
1857 terminx 1557
        initprintf("%s:%d: error: expected whitespace between `%c' and `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf[0],tempbuf+1);
5 Plagman 1558
    }
1143 terminx 1559
    else C_ReportError(ERROR_EXPECTEDKEYWORD);
1857 terminx 1560
 
5 Plagman 1561
    return -1;
1562
}
1563
 
2392 helixhorne 1564
static int32_t parse_decimal_number(void)  // (textptr)
1565
{
1566
    // decimal constants -- this is finicky business
1567
    int64_t num = strtoll(textptr, NULL, 10);  // assume long long to be int64_t
1568
 
4680 terminx 1569
    if (EDUKE32_PREDICT_TRUE(num >= INT32_MIN && num <= INT32_MAX))
2392 helixhorne 1570
    {
1571
        // all OK
1572
    }
4680 terminx 1573
    else if (EDUKE32_PREDICT_FALSE(num > INT32_MAX && num <= UINT32_MAX))
2392 helixhorne 1574
    {
1575
        // Number interpreted as uint32, but packed as int32 (on 32-bit archs)
1576
        // (CON code in the wild exists that does this).  Note that such conversion
1577
        // is implementation-defined (C99 6.3.1.3) but GCC does the 'expected' thing.
2742 helixhorne 1578
#if 0
2392 helixhorne 1579
        initprintf("%s:%d: warning: number greater than INT32_MAX converted to a negative one.\n",
1580
                   g_szScriptFileName,g_lineNumber);
1581
        g_numCompilerWarnings++;
2742 helixhorne 1582
#endif
2392 helixhorne 1583
    }
1584
    else
1585
    {
1586
        // out of range, this is arguably worse
1587
 
1588
        initprintf("%s:%d: warning: number out of the range of a 32-bit integer encountered.\n",
1589
                   g_szScriptFileName,g_lineNumber);
1590
        g_numCompilerWarnings++;
1591
    }
1592
 
1593
    return (int32_t)num;
1594
}
1595
 
2751 helixhorne 1596
static int32_t parse_hex_constant(const char *hexnum)
1597
{
1598
    int64_t x;
1599
    sscanf(hexnum, "%" PRIx64 "", &x);
1600
 
4680 terminx 1601
    if (EDUKE32_PREDICT_FALSE(x > UINT32_MAX))
2751 helixhorne 1602
    {
1603
        initprintf("%s:%d: warning: number 0x%" PRIx64 " truncated to 32 bits.\n",
1604
                   g_szScriptFileName,g_lineNumber, x);
1605
        g_numCompilerWarnings++;
1606
    }
1607
 
1608
    return x;
1609
}
1610
 
1205 terminx 1611
static void C_GetNextVarType(int32_t type)
5 Plagman 1612
{
1205 terminx 1613
    int32_t i=0,f=0;
5 Plagman 1614
 
1143 terminx 1615
    C_SkipComments();
1605 terminx 1616
 
1143 terminx 1617
    if (!type && !g_labelsOnly && (isdigit(*textptr) || ((*textptr == '-') && (isdigit(*(textptr+1))))))
5 Plagman 1618
    {
5533 terminx 1619
        BITPTR_CLEAR(g_scriptPtr-script);
2392 helixhorne 1620
 
1621
        *g_scriptPtr++ = MAXGAMEVARS;
1622
 
1623
        if (tolower(textptr[1])=='x')  // hex constants
2751 helixhorne 1624
            *g_scriptPtr = parse_hex_constant(textptr+2);
622 terminx 1625
        else
2392 helixhorne 1626
            *g_scriptPtr = parse_decimal_number();
1627
 
1628
        if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug)
5537 terminx 1629
            initprintf("%s:%d: debug: constant %ld in place of gamevar.\n",
2392 helixhorne 1630
                       g_szScriptFileName,g_lineNumber,(long)*g_scriptPtr);
1631
 
5533 terminx 1632
        BITPTR_CLEAR(g_scriptPtr-script);
1143 terminx 1633
        g_scriptPtr++;
1213 terminx 1634
#if 1
1635
        while (!ispecial(*textptr) && *textptr != ']') textptr++;
1636
#else
1143 terminx 1637
        C_GetNextLabelName();
1213 terminx 1638
#endif
5 Plagman 1639
        return;
1640
    }
1034 terminx 1641
    else if ((*textptr == '-')/* && !isdigit(*(textptr+1))*/)
5 Plagman 1642
    {
4680 terminx 1643
        if (EDUKE32_PREDICT_FALSE(type))
5 Plagman 1644
        {
1143 terminx 1645
            g_numCompilerErrors++;
1646
            C_ReportError(ERROR_SYNTAXERROR);
1647
            C_GetNextLabelName();
5 Plagman 1648
            return;
1649
        }
1605 terminx 1650
 
4680 terminx 1651
        if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug)
1652
            initprintf("%s:%d: debug: flagging gamevar as negative.\n", g_szScriptFileName, g_lineNumber); //,Batol(textptr));
1653
        f = (MAXGAMEVARS<<1);
1654
 
1605 terminx 1655
        textptr++;
5 Plagman 1656
    }
2392 helixhorne 1657
 
1143 terminx 1658
    C_GetNextLabelName();
676 terminx 1659
 
4680 terminx 1660
    if (EDUKE32_PREDICT_FALSE(!g_skipKeywordCheck && hash_find(&h_keywords,label+(g_numLabels<<6))>=0))
1024 terminx 1661
    {
1143 terminx 1662
        g_numCompilerErrors++;
1663
        C_ReportError(ERROR_ISAKEYWORD);
1024 terminx 1664
        return;
1665
    }
676 terminx 1666
 
1143 terminx 1667
    C_SkipComments(); //skip comments and whitespace
676 terminx 1668
    if ((*textptr == '['))     //read of array as a gamevar
1669
    {
1205 terminx 1670
        int32_t lLabelID = -1;
1204 terminx 1671
 
715 terminx 1672
        f |= (MAXGAMEVARS<<2);
676 terminx 1673
        textptr++;
1143 terminx 1674
        i=GetADefID(label+(g_numLabels<<6));
715 terminx 1675
        if (i < 0)
676 terminx 1676
        {
1204 terminx 1677
            i=GetDefID(label+(g_numLabels<<6));
5087 hendricks2 1678
            if ((unsigned) (i - g_iStructVarIDs) >= NUMQUICKSTRUCTS)
1204 terminx 1679
                i = -1;
1680
 
4680 terminx 1681
            if (EDUKE32_PREDICT_FALSE(i < 0))
1204 terminx 1682
            {
1683
                g_numCompilerErrors++;
1684
                C_ReportError(ERROR_NOTAGAMEARRAY);
1685
                return;
1686
            }
1687
            f &= ~(MAXGAMEVARS<<2); // not an array
1688
            f |= (MAXGAMEVARS<<3);
676 terminx 1689
        }
1690
 
5533 terminx 1691
        BITPTR_CLEAR(g_scriptPtr-script);
1143 terminx 1692
        *g_scriptPtr++=(i|f);
715 terminx 1693
 
5088 hendricks2 1694
        if ((f & (MAXGAMEVARS<<3)) && i - g_iStructVarIDs == STRUCT_USERDEF)
1695
        {
1696
            // userdef doesn't really have an array index
1697
            while (*textptr != ']')
1698
            {
1699
                if (*textptr == 0xa)
1700
                    break;
1701
                if (!*textptr)
1702
                    break;
1703
 
1704
                textptr++;
1705
            }
5354 hendricks2 1706
 
5533 terminx 1707
            BITPTR_CLEAR(g_scriptPtr-script);
5354 hendricks2 1708
            *g_scriptPtr++ = 0; // help out the VM by inserting a dummy index
5088 hendricks2 1709
        }
1710
        else
1711
        {
5502 terminx 1712
            if (*textptr == ']')
5511 terminx 1713
            {
5533 terminx 1714
                BITPTR_CLEAR(g_scriptPtr-script);
5502 terminx 1715
                *g_scriptPtr++ = g_iThisActorID;
5511 terminx 1716
            }
5502 terminx 1717
            else
1718
                C_GetNextVarType(0);
1719
 
5088 hendricks2 1720
            C_SkipComments();
1721
        }
1722
 
4680 terminx 1723
        if (EDUKE32_PREDICT_FALSE(*textptr != ']'))
676 terminx 1724
        {
1143 terminx 1725
            g_numCompilerErrors++;
1726
            C_ReportError(ERROR_GAMEARRAYBNC);
676 terminx 1727
            return;
1728
        }
1729
        textptr++;
1213 terminx 1730
 
1731
        //writing arrays in this way is not supported because it would require too many changes to other code
1732
 
4680 terminx 1733
        if (EDUKE32_PREDICT_FALSE(type))
676 terminx 1734
        {
1143 terminx 1735
            g_numCompilerErrors++;
1736
            C_ReportError(ERROR_INVALIDARRAYWRITE);
676 terminx 1737
            return;
1738
        }
1204 terminx 1739
 
1740
        if (f & (MAXGAMEVARS<<3))
1741
        {
1742
            while (*textptr != '.')
1743
            {
1744
                if (*textptr == 0xa)
1745
                    break;
1746
                if (!*textptr)
1747
                    break;
1748
 
1749
                textptr++;
1750
            }
1751
 
4680 terminx 1752
            if (EDUKE32_PREDICT_FALSE(*textptr != '.'))
1204 terminx 1753
            {
1754
                g_numCompilerErrors++;
1755
                C_ReportError(ERROR_SYNTAXERROR);
1756
                return;
1757
            }
1758
            textptr++;
1759
            /// now pointing at 'xxx'
1760
            C_GetNextLabelName();
2538 hendricks2 1761
            /*initprintf("found xxx label of \"%s\"\n",   label+(g_numLabels<<6));*/
1204 terminx 1762
 
5087 hendricks2 1763
            switch (i - g_iStructVarIDs)
1764
            {
1765
            case STRUCT_SPRITE:
5502 terminx 1766
                lLabelID=C_GetLabelNameOffset(&h_actor,Bstrtolower(label+(g_numLabels<<6)));
5087 hendricks2 1767
                break;
1768
            case STRUCT_SECTOR:
5502 terminx 1769
                lLabelID=C_GetLabelNameOffset(&h_sector,Bstrtolower(label+(g_numLabels<<6)));
5087 hendricks2 1770
                break;
1771
            case STRUCT_WALL:
5502 terminx 1772
                lLabelID=C_GetLabelNameOffset(&h_wall,Bstrtolower(label+(g_numLabels<<6)));
5087 hendricks2 1773
                break;
1774
            case STRUCT_PLAYER:
5502 terminx 1775
                lLabelID=C_GetLabelNameOffset(&h_player,Bstrtolower(label+(g_numLabels<<6)));
5087 hendricks2 1776
                break;
1777
            case STRUCT_ACTORVAR:
5088 hendricks2 1778
            case STRUCT_PLAYERVAR:
1213 terminx 1779
                lLabelID=GetDefID(label+(g_numLabels<<6));
5087 hendricks2 1780
                break;
5088 hendricks2 1781
            case STRUCT_TSPR:
5502 terminx 1782
                lLabelID=C_GetLabelNameOffset(&h_tsprite,Bstrtolower(label+(g_numLabels<<6)));
5088 hendricks2 1783
                break;
1784
            case STRUCT_PROJECTILE:
1785
            case STRUCT_THISPROJECTILE:
5502 terminx 1786
                lLabelID=C_GetLabelNameOffset(&h_projectile,Bstrtolower(label+(g_numLabels<<6)));
5088 hendricks2 1787
                break;
1788
            case STRUCT_USERDEF:
5502 terminx 1789
                lLabelID=C_GetLabelNameOffset(&h_userdef,Bstrtolower(label+(g_numLabels<<6)));
5088 hendricks2 1790
                break;
1791
            case STRUCT_INPUT:
5502 terminx 1792
                lLabelID=C_GetLabelNameOffset(&h_input,Bstrtolower(label+(g_numLabels<<6)));
5088 hendricks2 1793
                break;
5115 hendricks2 1794
            case STRUCT_TILEDATA:
5502 terminx 1795
                lLabelID=C_GetLabelNameOffset(&h_tiledata,Bstrtolower(label+(g_numLabels<<6)));
5115 hendricks2 1796
                break;
1797
            case STRUCT_PALDATA:
5502 terminx 1798
                lLabelID=C_GetLabelNameOffset(&h_paldata,Bstrtolower(label+(g_numLabels<<6)));
5115 hendricks2 1799
                break;
5087 hendricks2 1800
            }
1207 terminx 1801
 
4680 terminx 1802
            if (EDUKE32_PREDICT_FALSE(lLabelID == -1))
1204 terminx 1803
            {
1804
                g_numCompilerErrors++;
5500 terminx 1805
                C_ReportError(ERROR_NOTAMEMBER);
1204 terminx 1806
                return;
1807
            }
1808
 
5533 terminx 1809
            BITPTR_CLEAR(g_scriptPtr-script);
1204 terminx 1810
 
5087 hendricks2 1811
            switch (i - g_iStructVarIDs)
1204 terminx 1812
            {
5087 hendricks2 1813
            case STRUCT_SPRITE:
1204 terminx 1814
                *g_scriptPtr++=ActorLabels[lLabelID].lId;
1815
 
1816
                if (ActorLabels[lLabelID].flags & LABEL_HASPARM2)
1817
                    C_GetNextVarType(0);
5087 hendricks2 1818
                break;
1819
            case STRUCT_SECTOR:
1213 terminx 1820
                *g_scriptPtr++=SectorLabels[lLabelID].lId;
5087 hendricks2 1821
                break;
1822
            case STRUCT_WALL:
1823
                *g_scriptPtr++=WallLabels[lLabelID].lId;
1824
                break;
1825
            case STRUCT_PLAYER:
1204 terminx 1826
                *g_scriptPtr++=PlayerLabels[lLabelID].lId;
1827
 
1828
                if (PlayerLabels[lLabelID].flags & LABEL_HASPARM2)
1829
                    C_GetNextVarType(0);
5087 hendricks2 1830
                break;
1831
            case STRUCT_ACTORVAR:
5088 hendricks2 1832
            case STRUCT_PLAYERVAR:
5087 hendricks2 1833
                *g_scriptPtr++=lLabelID;
1834
                break;
5088 hendricks2 1835
            case STRUCT_TSPR:
1836
                *g_scriptPtr++=TsprLabels[lLabelID].lId;
1837
                break;
1838
            case STRUCT_PROJECTILE:
1839
            case STRUCT_THISPROJECTILE:
1840
                *g_scriptPtr++=ProjectileLabels[lLabelID].lId;
1841
                break;
1842
            case STRUCT_USERDEF:
1843
                *g_scriptPtr++=UserdefsLabels[lLabelID].lId;
1844
                break;
1845
            case STRUCT_INPUT:
1846
                *g_scriptPtr++=InputLabels[lLabelID].lId;
1847
                break;
5115 hendricks2 1848
            case STRUCT_TILEDATA:
1849
                *g_scriptPtr++=TileDataLabels[lLabelID].lId;
1850
                break;
1851
            case STRUCT_PALDATA:
1852
                *g_scriptPtr++=PalDataLabels[lLabelID].lId;
1853
                break;
1204 terminx 1854
            }
1855
        }
676 terminx 1856
        return;
1857
    }
1858
//    initprintf("not an array");
1143 terminx 1859
    i=GetDefID(label+(g_numLabels<<6));
676 terminx 1860
    if (i<0)   //gamevar not found
5 Plagman 1861
    {
1143 terminx 1862
        if (!type && !g_labelsOnly)
5 Plagman 1863
        {
676 terminx 1864
            //try looking for a define instead
1143 terminx 1865
            Bstrcpy(tempbuf,label+(g_numLabels<<6));
1625 terminx 1866
            i = hash_find(&h_labels,tempbuf);
4680 terminx 1867
            if (EDUKE32_PREDICT_TRUE(i>=0))
5 Plagman 1868
            {
4680 terminx 1869
                if (EDUKE32_PREDICT_TRUE(labeltype[i] & LABEL_DEFINE))
5 Plagman 1870
                {
1143 terminx 1871
                    if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug)
5537 terminx 1872
                        initprintf("%s:%d: debug: label `%s' in place of gamevar.\n",g_szScriptFileName,g_lineNumber,label+(i<<6));
5533 terminx 1873
                    BITPTR_CLEAR(g_scriptPtr-script);
2185 helixhorne 1874
                    *g_scriptPtr++ = MAXGAMEVARS;
5533 terminx 1875
                    BITPTR_CLEAR(g_scriptPtr-script);
2185 helixhorne 1876
                    *g_scriptPtr++ = labelcode[i];
5 Plagman 1877
                    return;
1878
                }
1879
            }
1143 terminx 1880
            g_numCompilerErrors++;
1881
            C_ReportError(ERROR_NOTAGAMEVAR);
5 Plagman 1882
            return;
1883
        }
1143 terminx 1884
        g_numCompilerErrors++;
1885
        C_ReportError(ERROR_NOTAGAMEVAR);
437 terminx 1886
        textptr++;
1887
        return;
676 terminx 1888
 
5 Plagman 1889
    }
4680 terminx 1890
    if (EDUKE32_PREDICT_FALSE(type == GAMEVAR_READONLY && aGameVars[i].dwFlags & GAMEVAR_READONLY))
5 Plagman 1891
    {
1143 terminx 1892
        g_numCompilerErrors++;
1893
        C_ReportError(ERROR_VARREADONLY);
5 Plagman 1894
        return;
1895
    }
4680 terminx 1896
    else if (EDUKE32_PREDICT_FALSE(aGameVars[i].dwFlags & type))
5 Plagman 1897
    {
1143 terminx 1898
        g_numCompilerErrors++;
1899
        C_ReportError(ERROR_VARTYPEMISMATCH);
5 Plagman 1900
        return;
1901
    }
1857 terminx 1902
 
1143 terminx 1903
    if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1)
5537 terminx 1904
        initprintf("%s:%d: debug: gamevar `%s'.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6));
715 terminx 1905
 
5533 terminx 1906
    BITPTR_CLEAR(g_scriptPtr-script);
1143 terminx 1907
    *g_scriptPtr++=(i|f);
5 Plagman 1908
}
1909
 
1206 terminx 1910
#define C_GetNextVar() C_GetNextVarType(0)
5 Plagman 1911
 
1205 terminx 1912
static inline void C_GetManyVarsType(int32_t type, int32_t num)
5 Plagman 1913
{
1205 terminx 1914
    int32_t i;
1229 terminx 1915
    for (i=num-1; i>=0; i--)
1143 terminx 1916
        C_GetNextVarType(type);
5 Plagman 1917
}
1918
 
1206 terminx 1919
#define C_GetManyVars(num) C_GetManyVarsType(0,num)
5 Plagman 1920
 
2766 helixhorne 1921
// returns:
1922
//  -1 on EOF or wrong type or error
1923
//   0 if literal value
1924
//   LABEL_* (>0) if that type and matched
1925
//
1926
// *g_scriptPtr will contain the value OR 0 if wrong type or error
1205 terminx 1927
static int32_t C_GetNextValue(int32_t type)
5 Plagman 1928
{
1143 terminx 1929
    C_SkipComments();
5 Plagman 1930
 
1544 terminx 1931
    if (*textptr == 0) // EOF
1932
        return -1;
5 Plagman 1933
 
5505 terminx 1934
    int32_t l = 0;
1935
 
333 terminx 1936
    while (isaltok(*(textptr+l)))
5 Plagman 1937
    {
1938
        tempbuf[l] = textptr[l];
1939
        l++;
1940
    }
1941
    tempbuf[l] = 0;
1942
 
4680 terminx 1943
    if (EDUKE32_PREDICT_FALSE(!g_skipKeywordCheck && hash_find(&h_keywords,tempbuf /*label+(g_numLabels<<6)*/)>=0))
1024 terminx 1944
    {
1143 terminx 1945
        g_numCompilerErrors++;
1946
        C_ReportError(ERROR_ISAKEYWORD);
1024 terminx 1947
        textptr+=l;
1948
    }
121 terminx 1949
 
5505 terminx 1950
    int32_t i = hash_find(&h_labels,tempbuf);
1951
 
1024 terminx 1952
    if (i>=0)
5 Plagman 1953
    {
4680 terminx 1954
        if (EDUKE32_PREDICT_TRUE(labeltype[i] & type))
5 Plagman 1955
        {
1143 terminx 1956
            if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1)
5 Plagman 1957
            {
5540 terminx 1958
                char *gl = C_GetLabelType(labeltype[i]);
5537 terminx 1959
                initprintf("%s:%d: debug: %s label `%s'.\n",g_szScriptFileName,g_lineNumber,gl,label+(i<<6));
1024 terminx 1960
                Bfree(gl);
5 Plagman 1961
            }
2150 helixhorne 1962
 
5533 terminx 1963
            BITPTR_CLEAR(g_scriptPtr-script);
2185 helixhorne 1964
            *(g_scriptPtr++) = labelcode[i];
2451 helixhorne 1965
 
5 Plagman 1966
            textptr += l;
1024 terminx 1967
            return labeltype[i];
5 Plagman 1968
        }
4680 terminx 1969
 
5533 terminx 1970
        BITPTR_CLEAR(g_scriptPtr-script);
1143 terminx 1971
        *(g_scriptPtr++) = 0;
1024 terminx 1972
        textptr += l;
5540 terminx 1973
        char *el = C_GetLabelType(type);
1974
        char *gl = C_GetLabelType(labeltype[i]);
1143 terminx 1975
        C_ReportError(-1);
1206 terminx 1976
        initprintf("%s:%d: warning: expected %s, found %s.\n",g_szScriptFileName,g_lineNumber,el,gl);
1143 terminx 1977
        g_numCompilerWarnings++;
1024 terminx 1978
        Bfree(el);
1979
        Bfree(gl);
1980
        return -1;  // valid label name, but wrong type
5 Plagman 1981
    }
1982
 
4680 terminx 1983
    if (EDUKE32_PREDICT_FALSE(isdigit(*textptr) == 0 && *textptr != '-'))
5 Plagman 1984
    {
1143 terminx 1985
        C_ReportError(ERROR_PARAMUNDEFINED);
1986
        g_numCompilerErrors++;
5533 terminx 1987
        BITPTR_CLEAR(g_scriptPtr-script);
1143 terminx 1988
        *g_scriptPtr = 0;
1989
        g_scriptPtr++;
5 Plagman 1990
        textptr+=l;
1991
        return -1; // error!
1992
    }
1993
 
4680 terminx 1994
    if (EDUKE32_PREDICT_FALSE(isdigit(*textptr) && g_labelsOnly))
5 Plagman 1995
    {
1143 terminx 1996
        C_ReportError(WARNING_LABELSONLY);
1997
        g_numCompilerWarnings++;
5 Plagman 1998
    }
1189 terminx 1999
 
2000
    i = l-1;
2001
    do
2002
    {
1207 terminx 2003
        // FIXME: check for 0-9 A-F for hex
1198 terminx 2004
        if (textptr[0] == '0' && textptr[1] == 'x') break; // kill the warning for hex
4680 terminx 2005
        if (EDUKE32_PREDICT_FALSE(!isdigit(textptr[i--])))
1189 terminx 2006
        {
2007
            C_ReportError(-1);
1206 terminx 2008
            initprintf("%s:%d: warning: invalid character `%c' in definition!\n",g_szScriptFileName,g_lineNumber,textptr[i+1]);
1189 terminx 2009
            g_numCompilerWarnings++;
2010
            break;
2011
        }
2012
    }
2013
    while (i > 0);
2014
 
5533 terminx 2015
    BITPTR_CLEAR(g_scriptPtr-script);
1189 terminx 2016
 
2017
    if (tolower(textptr[1])=='x')
2751 helixhorne 2018
        *g_scriptPtr = parse_hex_constant(textptr+2);
622 terminx 2019
    else
2392 helixhorne 2020
        *g_scriptPtr = parse_decimal_number();
1189 terminx 2021
 
2392 helixhorne 2022
    if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1)
5537 terminx 2023
        initprintf("%s:%d: debug: constant %ld.\n",
2392 helixhorne 2024
                   g_szScriptFileName,g_lineNumber,(long)*g_scriptPtr);
2025
 
1143 terminx 2026
    g_scriptPtr++;
5 Plagman 2027
 
2028
    textptr += l;
2029
 
2030
    return 0;   // literal value
2031
}
2032
 
5502 terminx 2033
static int32_t C_GetStructureIndexes(int32_t labelsonly, hashtable_t *table)
2034
{
2035
    while ((*textptr != '['))
2036
        textptr++;
2037
 
2038
    if (*textptr == '[')
2039
        textptr++;
2040
 
2041
    C_SkipComments();
2042
 
2043
    if (*textptr == ']')
5511 terminx 2044
    {
5533 terminx 2045
        BITPTR_CLEAR(g_scriptPtr-script);
5502 terminx 2046
        *g_scriptPtr++ = g_iThisActorID;
5511 terminx 2047
    }
5502 terminx 2048
    else
2049
    {
2050
        g_labelsOnly = labelsonly;
2051
        C_GetNextVar();
2052
        g_labelsOnly = 0;
2053
    }
2054
 
2055
    // now get name of .xxx
2056
    while (*textptr != '.')
2057
    {
2058
        if (*textptr == 0xa || !*textptr)
2059
            break;
2060
 
2061
        textptr++;
2062
    }
2063
 
2064
    if (EDUKE32_PREDICT_FALSE(*textptr != '.'))
2065
    {
2066
        g_numCompilerErrors++;
2067
        C_ReportError(ERROR_SYNTAXERROR);
2068
        return -1;
2069
    }
2070
 
2071
    textptr++;
2072
 
2073
    if (!table)
2074
        return 0;
2075
 
2076
    // .xxx
2077
 
2078
    C_GetNextLabelName();
2079
 
5508 terminx 2080
    int32_t const lLabelID = C_GetLabelNameOffset(table, Bstrtolower(label + (g_numLabels << 6)));
5502 terminx 2081
 
2082
    if (EDUKE32_PREDICT_FALSE(lLabelID == -1))
2083
    {
2084
        g_numCompilerErrors++;
2085
        C_ReportError(ERROR_NOTAMEMBER);
2086
        return -1;
2087
    }
2088
 
2089
    return lLabelID;
2090
}
2091
 
5505 terminx 2092
static inline int32_t C_IntPow2(int32_t const v)
1436 terminx 2093
{
1440 terminx 2094
    return ((v!=0) && (v&(v-1))==0);
1436 terminx 2095
}
2096
 
5505 terminx 2097
static inline uint32_t C_Pow2IntLogBase2(int32_t const v)
1436 terminx 2098
{
1440 terminx 2099
    static const uint32_t b[] = {0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0,
2100
                                 0xFF00FF00, 0xFFFF0000
2101
                                };
5505 terminx 2102
 
1440 terminx 2103
    register uint32_t r = (v & b[0]) != 0;
2104
 
5505 terminx 2105
    for (int i = 4; i > 0; i--)
1440 terminx 2106
        r |= ((v & b[i]) != 0) << i;
2107
 
2108
    return r;
1436 terminx 2109
}
2110
 
1435 terminx 2111
static int32_t C_CheckMalformedBranch(intptr_t lastScriptPtr)
2112
{
2113
    switch (C_GetKeyword())
2114
    {
2115
    case CON_RIGHTBRACE:
2116
    case CON_ENDA:
2117
    case CON_ENDEVENT:
2118
    case CON_ENDS:
1436 terminx 2119
    case CON_ELSE:
1435 terminx 2120
        g_scriptPtr = lastScriptPtr + &script[0];
2121
        g_ifElseAborted = 1;
2122
        C_ReportError(-1);
2123
        g_numCompilerWarnings++;
2124
        initprintf("%s:%d: warning: malformed `%s' branch\n",g_szScriptFileName,g_lineNumber,
5534 terminx 2125
                   keyw[*(g_scriptPtr) & VM_INSTMASK]);
1435 terminx 2126
        return 1;
2127
    }
2128
    return 0;
2129
}
2130
 
1205 terminx 2131
static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr)
1200 terminx 2132
{
2149 helixhorne 2133
    // ifrnd and the others actually do something when the condition is executed
1202 terminx 2134
    if ((Bstrncmp(keyw[tw], "if", 2) && tw != CON_ELSE) ||
2149 helixhorne 2135
            tw == CON_IFRND || tw == CON_IFHITWEAPON || tw == CON_IFCANSEE || tw == CON_IFCANSEETARGET ||
2136
            tw == CON_IFPDISTL || tw == CON_IFPDISTG || tw == CON_IFGOTWEAPONCE)
1200 terminx 2137
    {
2138
        g_ifElseAborted = 0;
2139
        return 0;
2140
    }
2141
 
5534 terminx 2142
    if ((*(g_scriptPtr) & VM_INSTMASK) != CON_NULLOP || *(g_scriptPtr)>>12 != IFELSE_MAGIC)
1200 terminx 2143
        g_ifElseAborted = 0;
2144
 
4680 terminx 2145
    if (EDUKE32_PREDICT_FALSE(g_ifElseAborted))
1200 terminx 2146
    {
1201 terminx 2147
        C_ReportError(-1);
2148
        g_numCompilerWarnings++;
1200 terminx 2149
        g_scriptPtr = lastScriptPtr + &script[0];
1201 terminx 2150
        initprintf("%s:%d: warning: empty `%s' branch\n",g_szScriptFileName,g_lineNumber,
5534 terminx 2151
                   keyw[*(g_scriptPtr) & VM_INSTMASK]);
1435 terminx 2152
        *(g_scriptPtr) = (CON_NULLOP + (IFELSE_MAGIC<<12));
1200 terminx 2153
        return 1;
2154
    }
2155
    return 0;
2156
}
2157
 
1205 terminx 2158
static int32_t C_CountCaseStatements()
5 Plagman 2159
{
437 terminx 2160
    char *temptextptr = textptr;
1205 terminx 2161
    int32_t temp_ScriptLineNumber = g_lineNumber;
1143 terminx 2162
    intptr_t scriptoffset = (unsigned)(g_scriptPtr-script);
2163
    intptr_t caseoffset = (unsigned)(g_caseScriptPtr-script);
1205 terminx 2164
//    int32_t i;
5 Plagman 2165
 
1143 terminx 2166
    g_numCases=0;
2167
    g_caseScriptPtr=NULL;
5 Plagman 2168
    //Bsprintf(g_szBuf,"CSS: %.12s",textptr);
2169
    //AddLog(g_szBuf);
1891 terminx 2170
    C_ParseCommand(1);
1143 terminx 2171
    // since we processed the endswitch, we need to re-increment g_checkingSwitch
2172
    g_checkingSwitch++;
5 Plagman 2173
 
2174
    textptr=temptextptr;
1143 terminx 2175
    g_scriptPtr = (intptr_t *)(script+scriptoffset);
5 Plagman 2176
 
1143 terminx 2177
    g_lineNumber = temp_ScriptLineNumber;
5 Plagman 2178
 
5508 terminx 2179
    int32_t const lCount=g_numCases;
1143 terminx 2180
    g_numCases=0;
2181
    g_caseScriptPtr = (intptr_t *)(script+caseoffset);
2182
    g_numCases = 0;
5 Plagman 2183
    return lCount;
2184
}
2185
 
1937 hendricks2 2186
static void C_Include(const char *confile)
2187
{
5505 terminx 2188
    int32_t fp = kopen4loadfrommod(confile,g_loadFromGroupOnly);
1937 hendricks2 2189
 
4680 terminx 2190
    if (EDUKE32_PREDICT_FALSE(fp < 0))
1937 hendricks2 2191
    {
2192
        g_numCompilerErrors++;
2193
        initprintf("%s:%d: error: could not find file `%s'.\n",g_szScriptFileName,g_lineNumber,confile);
2194
        return;
2195
    }
2196
 
5505 terminx 2197
    int32_t j = kfilelength(fp);
1937 hendricks2 2198
 
5505 terminx 2199
    char *mptr = (char *)Xmalloc(j+1);
1937 hendricks2 2200
 
2201
    initprintf("Including: %s (%d bytes)\n",confile, j);
5505 terminx 2202
 
1937 hendricks2 2203
    kread(fp, mptr, j);
2204
    kclose(fp);
2205
    mptr[j] = 0;
2206
 
2207
    if (*textptr == '"') // skip past the closing quote if it's there so we don't screw up the next line
2208
        textptr++;
2209
 
5505 terminx 2210
    char *origtptr = textptr;
2211
    char parentScriptFileName[255];
2212
 
1937 hendricks2 2213
    Bstrcpy(parentScriptFileName, g_szScriptFileName);
2214
    Bstrcpy(g_szScriptFileName, confile);
5505 terminx 2215
 
2216
    int32_t temp_ScriptLineNumber = g_lineNumber;
1937 hendricks2 2217
    g_lineNumber = 1;
5505 terminx 2218
 
2219
    int32_t temp_ifelse_check = g_checkingIfElse;
1937 hendricks2 2220
    g_checkingIfElse = 0;
2221
 
2222
    textptr = mptr;
2223
 
2224
    C_SkipComments();
2225
    C_ParseCommand(1);
2226
 
2227
    Bstrcpy(g_szScriptFileName, parentScriptFileName);
5505 terminx 2228
 
1937 hendricks2 2229
    g_totalLines += g_lineNumber;
2230
    g_lineNumber = temp_ScriptLineNumber;
2231
    g_checkingIfElse = temp_ifelse_check;
2232
 
2233
    textptr = origtptr;
2234
 
2235
    Bfree(mptr);
2236
}
3410 helixhorne 2237
#endif  // !defined LUNATIC
1937 hendricks2 2238
 
2704 helixhorne 2239
#ifdef _WIN32
2240
static void check_filename_case(const char *fn)
2241