Subversion Repositories eduke32

Rev

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