Subversion Repositories eduke32

Rev

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