2006-04-13 20:47:06 +00:00
//-------------------------------------------------------------------------
/*
2010-05-25 10:56:00 +00:00
Copyright ( C ) 2010 EDuke32 developers and contributors
2006-04-13 20:47:06 +00:00
2010-05-25 10:56:00 +00:00
This file is part of EDuke32 .
2006-04-13 20:47:06 +00:00
EDuke32 is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
2014-07-20 08:55:56 +00:00
Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2006-04-13 20:47:06 +00:00
*/
//-------------------------------------------------------------------------
# include "duke3d.h"
2012-01-28 14:37:56 +00:00
# include "namesdyn.h"
2006-04-13 20:47:06 +00:00
# include "gamedef.h"
2010-08-02 08:13:51 +00:00
# include "gameexec.h"
2011-07-29 22:07:49 +00:00
# include "savegame.h"
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
# include "common.h"
2012-06-03 16:09:33 +00:00
# include "common_game.h"
2006-04-13 20:47:06 +00:00
# include "osd.h"
2009-09-09 07:19:14 +00:00
# ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include <shellapi.h>
# endif
2014-03-22 09:25:15 +00:00
# define NUMKEYWORDS (int32_t)ARRAY_SIZE(keyw)
2010-09-27 21:52:04 +00:00
2009-01-09 09:29:17 +00:00
int32_t g_scriptVersion = 13 ; // 13 = 1.3D-style CON files, 14 = 1.4/1.5 style CON files
2010-09-27 21:52:04 +00:00
uint32_t g_scriptDateVersion = 99999999 ; // YYYYMMDD
2013-01-20 21:17:06 +00:00
# if !defined LUNATIC
2010-09-27 21:52:04 +00:00
static uint32_t g_scriptLastKeyword ; // = NUMKEYWORDS-1;
2014-03-22 09:25:15 +00:00
# define NUMKEYWDATES (int32_t)ARRAY_SIZE(g_keywdate)
2010-09-27 21:52:04 +00:00
// { keyw, date } means that at the date, all keywords up to keyw inclusive are available
static struct { uint32_t keyw ; uint32_t date ; } g_keywdate [ ] =
{
// beginning of eduke32 svn
{ CON_CANSEE , 20060423 } ,
{ CON_CANSEESPR , 20060424 } ,
// some stuff here not representable this way
{ CON_FINDNEARSPRITEZVAR , 20060516 } ,
{ CON_EZSHOOT , 20060701 } ,
{ CON_EZSHOOTVAR , 20060822 } ,
{ CON_JUMP , 20060828 } ,
{ CON_QSTRLEN , 20060930 } ,
{ CON_QUAKE , 20070105 } ,
{ CON_SHOWVIEW , 20070208 } ,
{ CON_NEXTSPRITESECT , 20070819 } ,
{ CON_GETKEYNAME , 20071024 } , // keyw numbers have been
{ CON_SPRITENOPAL , 20071220 } , // shuffled around here
{ CON_HITRADIUSVAR , 20080216 } ,
{ CON_ROTATESPRITE16 , 20080314 } ,
{ CON_SETARRAY , 20080401 } ,
{ CON_READARRAYFROMFILE , 20080405 } ,
{ CON_STARTTRACKVAR , 20080510 } ,
{ CON_QGETSYSSTR , 20080709 } ,
{ CON_GETTICKS , 20080711 } ,
{ CON_SETTSPR , 20080713 } ,
{ CON_CLEARMAPSTATE , 20080716 } ,
{ CON_SCRIPTSIZE , 20080720 } ,
{ CON_SETGAMENAME , 20080722 } ,
{ CON_CMENU , 20080725 } ,
{ CON_GETTIMEDATE , 20080809 } ,
{ CON_ACTIVATECHEAT , 20080810 } ,
{ CON_SETGAMEPALETTE , 20080816 } ,
{ CON_SETCFGNAME , 20080817 } ,
{ CON_IFVARVAREITHER , 20080907 } ,
{ CON_SAVENN , 20080915 } ,
{ CON_COPY , 20090219 } ,
// { CON_INV, 20090619 },
{ CON_QSTRNCAT , 20090712 } ,
{ CON_STOPACTORSOUND , 20090715 } ,
{ CON_IFSERVER , 20100722 } ,
{ CON_CALCHYPOTENUSE , 20100927 } ,
2010-10-17 14:49:39 +00:00
{ CON_CLIPMOVENOSLIDE , 20101009 } ,
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
{ CON_INCLUDEDEFAULT , 20110615 } ,
2011-11-03 23:08:54 +00:00
{ CON_SETACTORSOUNDPITCH , 20111102 } ,
2012-03-05 07:24:04 +00:00
{ CON_ECHO , 20120304 } ,
2012-03-31 11:22:00 +00:00
{ CON_SHOWVIEWUNBIASED , 20120331 } ,
2013-03-25 04:33:03 +00:00
{ CON_ROTATESPRITEA , 20130324 } ,
2013-05-23 18:28:04 +00:00
{ CON_ACTIVATE , 20130522 } ,
2013-06-01 06:55:00 +00:00
{ CON_SCREENTEXT , 20130529 } ,
2013-06-01 06:55:30 +00:00
{ CON_DYNAMICSOUNDREMAP , 20130530 } ,
2013-06-28 14:07:46 +00:00
{ CON_SCREENSOUND , 20130628 } ,
2015-02-20 22:10:28 +00:00
{ CON_SETMUSICPOSITION , 20150116 } ,
{ CON_UNDEFINELEVEL , 20150208 } ,
{ CON_IFCUTSCENE , 20150210 } ,
2015-02-22 22:15:20 +00:00
{ CON_DEFINEVOLUMEFLAGS , 20150222 } ,
2015-03-04 02:15:15 +00:00
{ CON_RESETPLAYERFLAGS , 20150303 } ,
2015-03-25 21:31:11 +00:00
{ CON_APPENDEVENT , 20150325 } ,
2010-09-27 21:52:04 +00:00
} ;
2013-01-20 21:17:06 +00:00
# endif
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
char g_szScriptFileName [ BMAX_PATH ] = " (none) " ; // file we're currently compiling
2009-01-09 09:29:17 +00:00
int32_t g_totalLines , g_lineNumber ;
2006-04-13 20:47:06 +00:00
char g_szBuf [ 1024 ] ;
2013-01-19 18:29:00 +00:00
# if !defined LUNATIC
2013-05-30 18:10:49 +00:00
static char g_szCurrentBlockName [ 256 ] = " (none) " , g_szLastBlockName [ 256 ] = " NULL " ;
static int32_t g_checkingIfElse , g_processingState , g_lastKeyword = - 1 ;
2013-01-05 13:09:19 +00:00
// The pointer to the start of the case table in a switch statement.
// First entry is 'default' code.
static intptr_t * g_caseScriptPtr = NULL ;
2009-02-19 09:39:19 +00:00
static intptr_t * previous_event = NULL ;
2009-01-09 09:29:17 +00:00
static int32_t g_numCases = 0 ;
static int32_t g_checkingSwitch = 0 , g_currentEvent = - 1 ;
2013-06-01 06:55:30 +00:00
static int32_t g_labelsOnly = 0 , g_skipKeywordCheck = 0 , g_dynamicTileMapping = 0 , g_dynamicSoundMapping = 0 ;
2009-01-09 09:29:17 +00:00
static int32_t g_numBraces = 0 ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
static int32_t C_ParseCommand ( int32_t loop ) ;
2009-05-05 16:21:33 +00:00
static int32_t C_SetScriptSize ( int32_t size ) ;
2013-01-05 13:09:19 +00:00
# endif
2008-07-20 03:29:00 +00:00
2009-01-09 09:29:17 +00:00
int32_t g_numQuoteRedefinitions = 0 ;
2006-04-13 20:47:06 +00:00
2012-12-28 17:18:16 +00:00
# ifdef LUNATIC
weapondata_t g_playerWeapon [ MAXPLAYERS ] [ MAX_WEAPONS ] ;
# endif
2006-04-13 20:47:06 +00:00
2013-01-20 21:17:06 +00:00
# if !defined LUNATIC
2013-05-30 18:10:49 +00:00
static intptr_t * g_parsingEventPtr = NULL ;
2015-03-27 12:28:45 +00:00
static intptr_t * g_parsingEventBreakPtr = NULL ;
2013-01-05 13:09:19 +00:00
static char * textptr ;
2013-05-30 18:10:49 +00:00
# endif
2009-01-09 09:29:17 +00:00
int32_t g_numCompilerErrors , g_numCompilerWarnings ;
2006-12-20 03:27:25 +00:00
2009-07-24 02:31:34 +00:00
extern int32_t g_maxSoundPos ;
2011-04-07 01:16:29 +00:00
enum
2006-11-15 01:16:55 +00:00
{
2006-08-04 00:57:27 +00:00
LABEL_ANY = - 1 ,
LABEL_DEFINE = 1 ,
LABEL_STATE = 2 ,
LABEL_ACTOR = 4 ,
LABEL_ACTION = 8 ,
LABEL_AI = 16 ,
LABEL_MOVE = 32 ,
2006-04-13 20:47:06 +00:00
} ;
2013-01-19 18:29:00 +00:00
# if !defined LUNATIC
2009-01-09 09:29:17 +00:00
static const char * C_GetLabelType ( int32_t type )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2006-04-13 20:47:06 +00:00
char x [ 64 ] ;
2011-04-07 01:16:29 +00:00
const char * LabelTypeText [ ] =
{
" define " ,
" state " ,
" actor " ,
" action " ,
" ai " ,
" move "
} ;
2006-04-13 20:47:06 +00:00
x [ 0 ] = 0 ;
2009-02-19 16:47:54 +00:00
for ( i = 0 ; i < 6 ; i + + )
2006-11-15 01:16:55 +00:00
{
2006-04-13 20:47:06 +00:00
if ( ! ( type & ( 1 < < i ) ) ) continue ;
if ( x [ 0 ] ) Bstrcat ( x , " or " ) ;
2008-11-20 14:06:36 +00:00
Bstrcat ( x , LabelTypeText [ i ] ) ;
2006-04-13 20:47:06 +00:00
}
2014-05-30 00:02:19 +00:00
return Xstrdup ( x ) ;
2006-04-13 20:47:06 +00:00
}
2008-08-11 10:17:18 +00:00
const char * keyw [ ] =
2007-08-25 01:05:00 +00:00
{
" definelevelname " , // 0 defines level name
" actor " , // 1 defines an actor
" addammo " , // 2 adds ammo to a weapon
" ifrnd " , // 3 checks against a randomizer
" enda " , // 4 ends an actor definition
" ifcansee " , // 5 checks if the player can see an object
" ifhitweapon " , // 6 checks if an object was hit by a weapon
" action " , // 7 defines an action if used outside a state or actor, otherwise triggers actor to perform action
" ifpdistl " , // 8 checks if player distance is less than value
" ifpdistg " , // 9 checks if player distance is more than value
" else " , // 10 used with if checks
" strength " , // 11 sets health
" break " , // 12 stops processing
" shoot " , // 13 shoots a projectile
2010-05-02 23:27:30 +00:00
" palfrom " , // 14 used for player screen shading effect, sets p->pals
2007-08-25 01:05:00 +00:00
" sound " , // 15 plays a sound that was defined with definesound
" fall " , // 16 causes actor to fall to sector floor height
" state " , // 17 begins defining a state if used outside a state or actor, otherwise calls a state
" ends " , // 18 ends defining a state
" define " , // 19 defines a value
2009-01-06 06:59:18 +00:00
" return " , // 20
2007-08-25 01:05:00 +00:00
" ifai " , // 21 checks if actor is currently performing a specific ai function
" killit " , // 22 kills an actor
" addweapon " , // 23 adds a weapon to the closest player
" ai " , // 24 sets an ai function to be used by an actor
" addphealth " , // 25 adds health to the player
" ifdead " , // 26 checks if actor is dead
" ifsquished " , // 27 checks if actor has been squished
" sizeto " , // 28 gradually increases actor size until it matches parameters given
" { " , // 29 used to indicate segments of code
" } " , // 30 used to indicate segments of code
" spawn " , // 31 spawns an actor
" move " , // 32
" ifwasweapon " , // 33
" ifaction " , // 34
" ifactioncount " , // 35
" resetactioncount " , // 36
" debris " , // 37
" pstomp " , // 38
" <null> " , // 39 was previously used to define the start of a comment block
" cstat " , // 40
" ifmove " , // 41
" resetplayer " , // 42
" ifonwater " , // 43
" ifinwater " , // 44
" ifcanshoottarget " , // 45
" ifcount " , // 46
" resetcount " , // 47
" addinventory " , // 48
" ifactornotstayput " , // 49
" hitradius " , // 50
" ifp " , // 51
" count " , // 52
" ifactor " , // 53
" music " , // 54
" include " , // 55
" ifstrength " , // 56
" definesound " , // 57
" guts " , // 58
" ifspawnedby " , // 59
" gamestartup " , // 60
" wackplayer " , // 61
" ifgapzl " , // 62
" ifhitspace " , // 63
" ifoutside " , // 64
" ifmultiplayer " , // 65
" operate " , // 66
" ifinspace " , // 67
" debug " , // 68
" endofgame " , // 69
" ifbulletnear " , // 70
" ifrespawn " , // 71
" iffloordistl " , // 72
" ifceilingdistl " , // 73
" spritepal " , // 74
" ifpinventory " , // 75
" betaname " , // 76
" cactor " , // 77
" ifphealthl " , // 78
" definequote " , // 79
" quote " , // 80
" ifinouterspace " , // 81
" ifnotmoving " , // 82
" respawnhitag " , // 83
" tip " , // 84
" ifspritepal " , // 85
" money " , // 86
" soundonce " , // 87
" addkills " , // 88
" stopsound " , // 89
" ifawayfromwall " , // 90
" ifcanseetarget " , // 91
" globalsound " , // 92
" lotsofglass " , // 93
" ifgotweaponce " , // 94
" getlastpal " , // 95
" pkick " , // 96
" mikesnd " , // 97
" useractor " , // 98
" sizeat " , // 99
" addstrength " , // 100 [#]
" cstator " , // 101
" mail " , // 102
" paper " , // 103
" tossweapon " , // 104
" sleeptime " , // 105
" nullop " , // 106
" definevolumename " , // 107
" defineskillname " , // 108
" ifnosounds " , // 109
" clipdist " , // 110
2012-05-25 18:39:22 +00:00
" ifangdiffl " , // 111 Last Duke3D 1.5 CON command
2007-08-25 01:05:00 +00:00
" gamevar " , // 112
" ifvarl " , // 113
" ifvarg " , // 114
" setvarvar " , // 115
" setvar " , // 116
" addvarvar " , // 117
" addvar " , // 118
" ifvarvarl " , // 119
" ifvarvarg " , // 120
" addlogvar " , // 121
" addlog " , // 122
" onevent " , // 123
" endevent " , // 124
" ifvare " , // 125
" ifvarvare " , // 126
" spgetlotag " , // 127
" spgethitag " , // 128
" sectgetlotag " , // 129
" sectgethitag " , // 130
" ifsound " , // 131
" gettexturefloor " , // 132
" gettextureceiling " , // 133
" inittimer " , // 134
" starttrack " , // 135
" randvar " , // 136
" enhanced " , // 137
" getangletotarget " , // 138
" getactorangle " , // 139
" setactorangle " , // 140
" mulvar " , // 141
" mulvarvar " , // 142
" divvar " , // 143
" divvarvar " , // 144
" modvar " , // 145
" modvarvar " , // 146
" andvar " , // 147
" andvarvar " , // 148
" orvar " , // 149
" orvarvar " , // 150
" getplayerangle " , // 151
" setplayerangle " , // 152
" lockplayer " , // 153
" setsector " , // 154
" getsector " , // 155
" setactor " , // 156
" getactor " , // 157
" setwall " , // 158
" getwall " , // 159
" findnearactor " , // 160
" findnearactorvar " , // 161
" setactorvar " , // 162
" getactorvar " , // 163
" espawn " , // 164
" getplayer " , // 165
" setplayer " , // 166
" sqrt " , // 167
" eventloadactor " , // 168
" espawnvar " , // 169
" getuserdef " , // 170
" setuserdef " , // 171
" subvarvar " , // 172
" subvar " , // 173
" ifvarn " , // 174
" ifvarvarn " , // 175
" ifvarand " , // 176
" ifvarvarand " , // 177
" myos " , // 178
" myospal " , // 179
" displayrand " , // 180
" sin " , // 181
" xorvarvar " , // 182
" xorvar " , // 183
" randvarvar " , // 184
" myosx " , // 185
" myospalx " , // 186
" gmaxammo " , // 187
" smaxammo " , // 188
" startlevel " , // 189
" eshoot " , // 190
" qspawn " , // 191
" rotatesprite " , // 192
" defineprojectile " , // 193
" spriteshadow " , // 194
" cos " , // 195
" eshootvar " , // 196
" findnearactor3d " , // 197
" findnearactor3dvar " , // 198
" flash " , // 199
" qspawnvar " , // 200
" eqspawn " , // 201
" eqspawnvar " , // 202
" minitext " , // 203
" gametext " , // 204
" digitalnumber " , // 205
" addweaponvar " , // 206
" setprojectile " , // 207
" angoff " , // 208
" updatesector " , // 209
" insertspriteq " , // 210
" angoffvar " , // 211
" whilevarn " , // 212
" switch " , // 213
" case " , // 214
" default " , // 215
" endswitch " , // 216
" shootvar " , // 217
" soundvar " , // 218
" findplayer " , // 219
" findotherplayer " , // 220
" activatebysector " , // 221 sectnum, spriteid
" operatesectors " , // 222 sectnum, spriteid
" operaterespawns " , // 223 lotag
" operateactivators " , // 224 lotag, player index
" operatemasterswitches " , // 225 lotag
" checkactivatormotion " , // 226 lotag
" zshoot " , // 227 zvar projnum
" dist " , // 228 sprite1 sprite2
" ldist " , // 229 sprite1 sprite2
" shiftvarl " , // 230
" shiftvarr " , // 231
" spritenvg " , // 232
" getangle " , // 233
" whilevarvarn " , // 234
" hitscan " , // 235
" time " , // 236
" getplayervar " , // 237
" setplayervar " , // 238
" mulscale " , // 239
" setaspect " , // 240
" ezshoot " , // 241
" spritenoshade " , // 242
" movesprite " , // 243
" checkavailweapon " , // 244
" soundoncevar " , // 245
" updatesectorz " , // 246
" stopallsounds " , // 247
" ssp " , // 248
" stopsoundvar " , // 249
" displayrandvar " , // 250
" displayrandvarvar " , // 251
" checkavailinven " , // 252
" globalsoundvar " , // 253
" guniqhudid " , // 254
" getprojectile " , // 255
" getthisprojectile " , // 256
" setthisprojectile " , // 257
" definecheat " , // 258
" cheatkeys " , // 259
" userquote " , // 260
" precache " , // 261
" definegamefuncname " , // 262
" redefinequote " , // 263
" qsprintf " , // 264
" getpname " , // 265
" qstrcat " , // 266
" qstrcpy " , // 267
" setsprite " , // 268
" rotatepoint " , // 269
" dragpoint " , // 270
" getzrange " , // 271
" changespritestat " , // 272
" getceilzofslope " , // 273
" getflorzofslope " , // 274
" neartag " , // 275
" definegametype " , // 276
" changespritesect " , // 277
" spriteflags " , // 278
" savegamevar " , // 279
" readgamevar " , // 280
" findnearsprite " , // 281
" findnearspritevar " , // 282
" findnearsprite3d " , // 283
" findnearsprite3dvar " , // 284
" dynamicremap " , // 285
" setinput " , // 286
" getinput " , // 287
2008-08-09 19:59:41 +00:00
" save " , // 288
2012-05-25 18:39:22 +00:00
" cansee " , // 289 Beginning EDuke32 SVN
2007-08-25 01:05:00 +00:00
" canseespr " , // 290
" findnearactorz " , // 291
" findnearactorzvar " , // 292
" findnearspritez " , // 293
" findnearspritezvar " , // 294
2008-08-09 19:59:41 +00:00
" zshootvar " , // 295
" ezshootvar " , // 296
" getcurraddress " , // 297
" jump " , // 298
" qstrlen " , // 299
2007-08-25 01:05:00 +00:00
" getincangle " , // 300
" quake " , // 301
" showview " , // 302
" headspritestat " , // 303
" prevspritestat " , // 304
" nextspritestat " , // 305
" headspritesect " , // 306
" prevspritesect " , // 307
" nextspritesect " , // 308
2007-12-20 19:14:38 +00:00
" getkeyname " , // 309
" qsubstr " , // 310
" gametextz " , // 311
" digitalnumberz " , // 312
" spritenopal " , // 313
2008-02-16 22:18:48 +00:00
" hitradiusvar " , // 314
2008-03-14 21:04:28 +00:00
" rotatesprite16 " , // 315
2008-04-01 02:50:44 +00:00
" gamearray " , // 316
" setarray " , // 317
2008-04-05 04:18:48 +00:00
" resizearray " , // 318
" writearraytofile " , // 319
" readarrayfromfile " , // 320
2008-08-09 19:59:41 +00:00
" starttrackvar " , // 321
" qgetsysstr " , // 322
" getticks " , // 323
2008-07-13 07:10:47 +00:00
" gettspr " , // 324
" settspr " , // 325
2008-07-16 09:27:08 +00:00
" savemapstate " , // 326
" loadmapstate " , // 327
" clearmapstate " , // 328
2008-07-20 03:29:00 +00:00
" scriptsize " , // 329
2008-08-17 11:07:28 +00:00
" setgamename " , // 330
2008-07-25 18:10:33 +00:00
" cmenu " , // 331
2008-08-10 08:58:34 +00:00
" gettimedate " , // 332
2008-08-10 16:28:25 +00:00
" activatecheat " , // 333
2008-08-16 11:20:08 +00:00
" setgamepalette " , // 334
2008-08-17 09:01:31 +00:00
" setdefname " , // 335
2008-08-17 09:57:36 +00:00
" setcfgname " , // 336
2008-09-07 12:36:20 +00:00
" ifvaror " , // 337
" ifvarvaror " , // 338
" ifvarxor " , // 339
" ifvarvarxor " , // 340
" ifvareither " , // 341
" ifvarvareither " , // 342
2008-09-15 02:47:02 +00:00
" getarraysize " , // 343
" savenn " , // 344
2009-02-19 09:39:19 +00:00
" copy " , // 345
2009-06-19 01:10:10 +00:00
" <null> " , // 346 internal inversion function
2009-07-12 01:55:34 +00:00
" sectorofwall " , // 347
" qstrncat " , // 348
2009-07-15 01:26:38 +00:00
" ifactorsound " , // 349
" stopactorsound " , // 350
2010-07-22 20:29:09 +00:00
" ifclient " , // 351
" ifserver " , // 352
2010-09-27 21:52:04 +00:00
" sectsetinterpolation " , // 353
" sectclearinterpolation " , // 354
2011-04-07 01:16:29 +00:00
" clipmove " , // 355
" lineintersect " , // 356
" rayintersect " , // 357
" calchypotenuse " , // 358
" clipmovenoslide " , // 359
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
" includedefault " , // 360
2011-11-03 23:08:54 +00:00
" setactorsoundpitch " , // 361
2012-03-05 07:24:04 +00:00
" echo " , // 362
2012-03-31 11:22:00 +00:00
" showviewunbiased " , // 363
2013-03-25 04:33:03 +00:00
" rotatespritea " , // 364
2013-05-23 18:28:04 +00:00
" shadeto " , // 365
" endoflevel " , // 366
" ifplayersl " , // 367
" activate " , // 368
2013-06-01 06:55:00 +00:00
" qstrdim " , // 369
" screentext " , // 370
2013-06-01 06:55:30 +00:00
" dynamicsoundremap " , // 371
2013-06-28 14:07:46 +00:00
" screensound " , // 372
2015-01-17 00:28:49 +00:00
" getmusicposition " , // 373
" setmusicposition " , // 374
2015-02-09 05:50:33 +00:00
" undefinevolume " , // 375
" undefineskill " , // 376
" undefinelevel " , // 377
2015-02-22 22:14:39 +00:00
" startcutscene " , // 378
2015-02-11 05:22:07 +00:00
" ifcutscene " , // 379
2015-02-22 22:15:20 +00:00
" definevolumeflags " , // 380
2015-03-04 02:15:15 +00:00
" resetplayerflags " , // 381
2015-03-25 21:31:11 +00:00
" appendevent " , // 382
2007-08-25 01:05:00 +00:00
" <null> "
} ;
2013-01-01 15:24:18 +00:00
# endif
2007-02-08 04:19:39 +00:00
2012-12-09 13:24:36 +00:00
// KEEPINSYNC with enum GameEvent_t and lunatic/con_lang.lua
const char * EventNames [ MAXEVENTS ] =
2012-02-09 22:44:26 +00:00
{
2012-12-09 13:24:36 +00:00
" EVENT_INIT " ,
" EVENT_ENTERLEVEL " ,
" EVENT_RESETWEAPONS " ,
" EVENT_RESETINVENTORY " ,
" EVENT_HOLSTER " ,
" EVENT_LOOKLEFT " ,
" EVENT_LOOKRIGHT " ,
" EVENT_SOARUP " ,
" EVENT_SOARDOWN " ,
" EVENT_CROUCH " ,
" EVENT_JUMP " ,
" EVENT_RETURNTOCENTER " ,
" EVENT_LOOKUP " ,
" EVENT_LOOKDOWN " ,
" EVENT_AIMUP " ,
" EVENT_FIRE " ,
" EVENT_CHANGEWEAPON " ,
" EVENT_GETSHOTRANGE " ,
" EVENT_GETAUTOAIMANGLE " ,
" EVENT_GETLOADTILE " ,
" EVENT_CHEATGETSTEROIDS " ,
" EVENT_CHEATGETHEAT " ,
" EVENT_CHEATGETBOOT " ,
" EVENT_CHEATGETSHIELD " ,
" EVENT_CHEATGETSCUBA " ,
" EVENT_CHEATGETHOLODUKE " ,
" EVENT_CHEATGETJETPACK " ,
" EVENT_CHEATGETFIRSTAID " ,
" EVENT_QUICKKICK " ,
" EVENT_INVENTORY " ,
" EVENT_USENIGHTVISION " ,
" EVENT_USESTEROIDS " ,
" EVENT_INVENTORYLEFT " ,
" EVENT_INVENTORYRIGHT " ,
" EVENT_HOLODUKEON " ,
" EVENT_HOLODUKEOFF " ,
" EVENT_USEMEDKIT " ,
" EVENT_USEJETPACK " ,
" EVENT_TURNAROUND " ,
" EVENT_DISPLAYWEAPON " ,
" EVENT_FIREWEAPON " ,
" EVENT_SELECTWEAPON " ,
" EVENT_MOVEFORWARD " ,
" EVENT_MOVEBACKWARD " ,
" EVENT_TURNLEFT " ,
" EVENT_TURNRIGHT " ,
" EVENT_STRAFELEFT " ,
" EVENT_STRAFERIGHT " ,
" EVENT_WEAPKEY1 " ,
" EVENT_WEAPKEY2 " ,
" EVENT_WEAPKEY3 " ,
" EVENT_WEAPKEY4 " ,
" EVENT_WEAPKEY5 " ,
" EVENT_WEAPKEY6 " ,
" EVENT_WEAPKEY7 " ,
" EVENT_WEAPKEY8 " ,
" EVENT_WEAPKEY9 " ,
" EVENT_WEAPKEY10 " ,
" EVENT_DRAWWEAPON " ,
" EVENT_DISPLAYCROSSHAIR " ,
" EVENT_DISPLAYREST " ,
" EVENT_DISPLAYSBAR " ,
" EVENT_RESETPLAYER " ,
" EVENT_INCURDAMAGE " ,
" EVENT_AIMDOWN " ,
" EVENT_GAME " ,
" EVENT_PREVIOUSWEAPON " ,
" EVENT_NEXTWEAPON " ,
" EVENT_SWIMUP " ,
" EVENT_SWIMDOWN " ,
" EVENT_GETMENUTILE " ,
" EVENT_SPAWN " ,
" EVENT_LOGO " ,
" EVENT_EGS " ,
" EVENT_DOFIRE " ,
" EVENT_PRESSEDFIRE " ,
" EVENT_USE " ,
" EVENT_PROCESSINPUT " ,
" EVENT_FAKEDOMOVETHINGS " ,
" EVENT_DISPLAYROOMS " ,
" EVENT_KILLIT " ,
" EVENT_LOADACTOR " ,
" EVENT_DISPLAYBONUSSCREEN " ,
" EVENT_DISPLAYMENU " ,
" EVENT_DISPLAYMENUREST " ,
" EVENT_DISPLAYLOADINGSCREEN " ,
" EVENT_ANIMATESPRITES " ,
" EVENT_NEWGAME " ,
" EVENT_SOUND " ,
" EVENT_CHECKTOUCHDAMAGE " ,
" EVENT_CHECKFLOORDAMAGE " ,
" EVENT_LOADGAME " ,
" EVENT_SAVEGAME " ,
" EVENT_PREGAME " ,
2013-07-07 20:59:10 +00:00
" EVENT_CHANGEMENU " ,
2013-12-20 18:31:33 +00:00
" EVENT_DAMAGEHPLANE " ,
2014-06-16 23:16:55 +00:00
" EVENT_ACTIVATECHEAT " ,
2015-01-25 12:16:58 +00:00
" EVENT_DISPLAYINACTIVEMENU " ,
" EVENT_DISPLAYINACTIVEMENUREST " ,
2015-02-11 05:22:07 +00:00
" EVENT_CUTSCENE " ,
2015-02-11 07:08:27 +00:00
" EVENT_DISPLAYCURSOR " ,
2015-03-08 07:57:47 +00:00
" EVENT_DISPLAYLEVELSTATS " ,
2015-03-08 07:58:06 +00:00
" EVENT_DISPLAYCAMERAOSD " ,
2015-03-08 07:58:24 +00:00
" EVENT_DISPLAYROOMSCAMERA " ,
" EVENT_DISPLAYSTART " ,
2015-03-27 12:29:05 +00:00
" EVENT_WORLD " ,
" EVENT_PREWORLD " ,
" EVENT_PRELEVEL " ,
2015-03-30 05:57:30 +00:00
" EVENT_DISPLAYSPIT " ,
" EVENT_DISPLAYFIST " ,
" EVENT_DISPLAYKNEE " ,
" EVENT_DISPLAYKNUCKLES " ,
" EVENT_DISPLAYSCUBA " ,
" EVENT_DISPLAYTIP " ,
" EVENT_DISPLAYACCESS " ,
2013-07-07 20:59:10 +00:00
# ifdef LUNATIC
" EVENT_ANIMATEALLSPRITES " ,
# endif
2012-02-09 22:44:26 +00:00
} ;
2013-01-19 18:29:00 +00:00
# if !defined LUNATIC
2008-11-20 14:06:36 +00:00
const memberlabel_t SectorLabels [ ] =
2007-08-25 01:05:00 +00:00
{
{ " wallptr " , SECTOR_WALLPTR , 0 , 0 } ,
{ " wallnum " , SECTOR_WALLNUM , 0 , 0 } ,
{ " ceilingz " , SECTOR_CEILINGZ , 0 , 0 } ,
{ " floorz " , SECTOR_FLOORZ , 0 , 0 } ,
{ " ceilingstat " , SECTOR_CEILINGSTAT , 0 , 0 } ,
{ " floorstat " , SECTOR_FLOORSTAT , 0 , 0 } ,
{ " ceilingpicnum " , SECTOR_CEILINGPICNUM , 0 , 0 } ,
{ " ceilingslope " , SECTOR_CEILINGSLOPE , 0 , 0 } ,
{ " ceilingshade " , SECTOR_CEILINGSHADE , 0 , 0 } ,
{ " ceilingpal " , SECTOR_CEILINGPAL , 0 , 0 } ,
{ " ceilingxpanning " , SECTOR_CEILINGXPANNING , 0 , 0 } ,
{ " ceilingypanning " , SECTOR_CEILINGYPANNING , 0 , 0 } ,
{ " floorpicnum " , SECTOR_FLOORPICNUM , 0 , 0 } ,
{ " floorslope " , SECTOR_FLOORSLOPE , 0 , 0 } ,
{ " floorshade " , SECTOR_FLOORSHADE , 0 , 0 } ,
{ " floorpal " , SECTOR_FLOORPAL , 0 , 0 } ,
{ " floorxpanning " , SECTOR_FLOORXPANNING , 0 , 0 } ,
{ " floorypanning " , SECTOR_FLOORYPANNING , 0 , 0 } ,
{ " visibility " , SECTOR_VISIBILITY , 0 , 0 } ,
2014-04-05 11:28:10 +00:00
{ " fogpal " , SECTOR_FOGPAL , 0 , 0 } , // formerly filler
{ " alignto " , SECTOR_FOGPAL , 0 , 0 } , // formerly filler
2007-08-25 01:05:00 +00:00
{ " lotag " , SECTOR_LOTAG , 0 , 0 } ,
{ " hitag " , SECTOR_HITAG , 0 , 0 } ,
{ " extra " , SECTOR_EXTRA , 0 , 0 } ,
2011-09-30 14:30:33 +00:00
{ " ceilingbunch " , SECTOR_CEILINGBUNCH , 0 , 0 } ,
{ " floorbunch " , SECTOR_FLOORBUNCH , 0 , 0 } ,
2012-11-16 00:54:04 +00:00
{ " ulotag " , SECTOR_ULOTAG , 0 , 0 } ,
{ " uhitag " , SECTOR_UHITAG , 0 , 0 } ,
2007-08-25 01:05:00 +00:00
{ " " , - 1 , 0 , 0 } // END OF LIST
} ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
const memberlabel_t WallLabels [ ] =
2007-08-25 01:05:00 +00:00
{
{ " x " , WALL_X , 0 , 0 } ,
{ " y " , WALL_Y , 0 , 0 } ,
{ " point2 " , WALL_POINT2 , 0 , 0 } ,
{ " nextwall " , WALL_NEXTWALL , 0 , 0 } ,
{ " nextsector " , WALL_NEXTSECTOR , 0 , 0 } ,
{ " cstat " , WALL_CSTAT , 0 , 0 } ,
{ " picnum " , WALL_PICNUM , 0 , 0 } ,
{ " overpicnum " , WALL_OVERPICNUM , 0 , 0 } ,
{ " shade " , WALL_SHADE , 0 , 0 } ,
{ " pal " , WALL_PAL , 0 , 0 } ,
{ " xrepeat " , WALL_XREPEAT , 0 , 0 } ,
{ " yrepeat " , WALL_YREPEAT , 0 , 0 } ,
{ " xpanning " , WALL_XPANNING , 0 , 0 } ,
{ " ypanning " , WALL_YPANNING , 0 , 0 } ,
{ " lotag " , WALL_LOTAG , 0 , 0 } ,
{ " hitag " , WALL_HITAG , 0 , 0 } ,
{ " extra " , WALL_EXTRA , 0 , 0 } ,
2012-11-16 00:54:04 +00:00
{ " ulotag " , WALL_ULOTAG , 0 , 0 } ,
{ " uhitag " , WALL_UHITAG , 0 , 0 } ,
2007-08-25 01:05:00 +00:00
{ " " , - 1 , 0 , 0 } // END OF LIST
} ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
const memberlabel_t ActorLabels [ ] =
2007-08-25 01:05:00 +00:00
{
{ " x " , ACTOR_X , 0 , 0 } ,
{ " y " , ACTOR_Y , 0 , 0 } ,
{ " z " , ACTOR_Z , 0 , 0 } ,
{ " cstat " , ACTOR_CSTAT , 0 , 0 } ,
{ " picnum " , ACTOR_PICNUM , 0 , 0 } ,
{ " shade " , ACTOR_SHADE , 0 , 0 } ,
{ " pal " , ACTOR_PAL , 0 , 0 } ,
{ " clipdist " , ACTOR_CLIPDIST , 0 , 0 } ,
2008-08-24 00:22:36 +00:00
// { "filler", ACTOR_DETAIL, 0, 0 },
2014-02-09 19:22:36 +00:00
{ " blend " , ACTOR_DETAIL , 0 , 0 } ,
2007-08-25 01:05:00 +00:00
{ " xrepeat " , ACTOR_XREPEAT , 0 , 0 } ,
{ " yrepeat " , ACTOR_YREPEAT , 0 , 0 } ,
{ " xoffset " , ACTOR_XOFFSET , 0 , 0 } ,
{ " yoffset " , ACTOR_YOFFSET , 0 , 0 } ,
{ " sectnum " , ACTOR_SECTNUM , 0 , 0 } ,
{ " statnum " , ACTOR_STATNUM , 0 , 0 } ,
{ " ang " , ACTOR_ANG , 0 , 0 } ,
{ " owner " , ACTOR_OWNER , 0 , 0 } ,
{ " xvel " , ACTOR_XVEL , 0 , 0 } ,
{ " yvel " , ACTOR_YVEL , 0 , 0 } ,
{ " zvel " , ACTOR_ZVEL , 0 , 0 } ,
{ " lotag " , ACTOR_LOTAG , 0 , 0 } ,
{ " hitag " , ACTOR_HITAG , 0 , 0 } ,
{ " extra " , ACTOR_EXTRA , 0 , 0 } ,
2008-11-20 14:06:36 +00:00
// ActorExtra labels...
2007-08-25 01:05:00 +00:00
{ " htcgg " , ACTOR_HTCGG , 0 , 0 } ,
{ " htpicnum " , ACTOR_HTPICNUM , 0 , 0 } ,
{ " htang " , ACTOR_HTANG , 0 , 0 } ,
{ " htextra " , ACTOR_HTEXTRA , 0 , 0 } ,
{ " htowner " , ACTOR_HTOWNER , 0 , 0 } ,
{ " htmovflag " , ACTOR_HTMOVFLAG , 0 , 0 } ,
{ " httempang " , ACTOR_HTTEMPANG , 0 , 0 } ,
{ " htactorstayput " , ACTOR_HTACTORSTAYPUT , 0 , 0 } ,
{ " htdispicnum " , ACTOR_HTDISPICNUM , 0 , 0 } ,
{ " httimetosleep " , ACTOR_HTTIMETOSLEEP , 0 , 0 } ,
{ " htfloorz " , ACTOR_HTFLOORZ , 0 , 0 } ,
{ " htceilingz " , ACTOR_HTCEILINGZ , 0 , 0 } ,
{ " htlastvx " , ACTOR_HTLASTVX , 0 , 0 } ,
{ " htlastvy " , ACTOR_HTLASTVY , 0 , 0 } ,
{ " htbposx " , ACTOR_HTBPOSX , 0 , 0 } ,
{ " htbposy " , ACTOR_HTBPOSY , 0 , 0 } ,
{ " htbposz " , ACTOR_HTBPOSZ , 0 , 0 } ,
2008-07-19 13:12:20 +00:00
{ " htg_t " , ACTOR_HTG_T , LABEL_HASPARM2 , 10 } ,
2007-08-25 01:05:00 +00:00
// model flags
{ " angoff " , ACTOR_ANGOFF , 0 , 0 } ,
{ " pitch " , ACTOR_PITCH , 0 , 0 } ,
{ " roll " , ACTOR_ROLL , 0 , 0 } ,
{ " mdxoff " , ACTOR_MDXOFF , 0 , 0 } ,
{ " mdyoff " , ACTOR_MDYOFF , 0 , 0 } ,
{ " mdzoff " , ACTOR_MDZOFF , 0 , 0 } ,
{ " mdflags " , ACTOR_MDFLAGS , 0 , 0 } ,
2008-01-03 21:54:58 +00:00
{ " xpanning " , ACTOR_XPANNING , 0 , 0 } ,
{ " ypanning " , ACTOR_YPANNING , 0 , 0 } ,
2008-07-12 10:57:52 +00:00
2008-08-07 23:32:18 +00:00
{ " htflags " , ACTOR_HTFLAGS , 0 , 0 } ,
2009-04-24 06:04:13 +00:00
{ " alpha " , ACTOR_ALPHA , 0 , 0 } ,
2009-04-24 02:53:50 +00:00
2012-11-16 00:54:04 +00:00
{ " ulotag " , ACTOR_ULOTAG , 0 , 0 } ,
{ " uhitag " , ACTOR_UHITAG , 0 , 0 } ,
2013-11-11 16:48:17 +00:00
{ " isvalid " , ACTOR_ISVALID , 0 , 0 } ,
2014-02-09 19:22:36 +00:00
// aliases:
2014-04-19 22:42:18 +00:00
{ " movflags " , ACTOR_HITAG , 0 , 0 } ,
2014-02-09 19:22:36 +00:00
{ " detail " , ACTOR_DETAIL , 0 , 0 } , // deprecated name for 'blend'
2013-11-11 16:48:17 +00:00
2008-07-13 07:10:47 +00:00
{ " " , - 1 , 0 , 0 } // END OF LIST
} ;
2008-11-20 14:06:36 +00:00
const memberlabel_t TsprLabels [ ] =
2008-07-13 07:10:47 +00:00
{
2008-07-12 10:57:52 +00:00
// tsprite access
2008-08-23 15:37:30 +00:00
{ " tsprx " , ACTOR_X , 0 , 0 } ,
{ " tspry " , ACTOR_Y , 0 , 0 } ,
{ " tsprz " , ACTOR_Z , 0 , 0 } ,
{ " tsprcstat " , ACTOR_CSTAT , 0 , 0 } ,
{ " tsprpicnum " , ACTOR_PICNUM , 0 , 0 } ,
{ " tsprshade " , ACTOR_SHADE , 0 , 0 } ,
{ " tsprpal " , ACTOR_PAL , 0 , 0 } ,
{ " tsprclipdist " , ACTOR_CLIPDIST , 0 , 0 } ,
2008-08-24 00:22:36 +00:00
// { "tsprfiller", ACTOR_DETAIL, 0, 0 },
2014-02-09 19:22:36 +00:00
{ " tsprblend " , ACTOR_DETAIL , 0 , 0 } ,
2008-08-23 15:37:30 +00:00
{ " tsprxrepeat " , ACTOR_XREPEAT , 0 , 0 } ,
{ " tspryrepeat " , ACTOR_YREPEAT , 0 , 0 } ,
{ " tsprxoffset " , ACTOR_XOFFSET , 0 , 0 } ,
{ " tspryoffset " , ACTOR_YOFFSET , 0 , 0 } ,
{ " tsprsectnum " , ACTOR_SECTNUM , 0 , 0 } ,
{ " tsprstatnum " , ACTOR_STATNUM , 0 , 0 } ,
{ " tsprang " , ACTOR_ANG , 0 , 0 } ,
{ " tsprowner " , ACTOR_OWNER , 0 , 0 } ,
# if 1
{ " tsprxvel " , ACTOR_XVEL , 0 , 0 } ,
{ " tspryvel " , ACTOR_YVEL , 0 , 0 } ,
{ " tsprzvel " , ACTOR_ZVEL , 0 , 0 } ,
{ " tsprlotag " , ACTOR_LOTAG , 0 , 0 } ,
{ " tsprhitag " , ACTOR_HITAG , 0 , 0 } ,
{ " tsprextra " , ACTOR_EXTRA , 0 , 0 } ,
# endif
2014-02-09 19:22:36 +00:00
// aliases:
{ " tsprdetail " , ACTOR_DETAIL , 0 , 0 } , // deprecated name for 'tsprblend'
2008-07-12 10:57:52 +00:00
2007-08-25 01:05:00 +00:00
{ " " , - 1 , 0 , 0 } // END OF LIST
} ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
const memberlabel_t PlayerLabels [ ] =
2007-08-25 01:05:00 +00:00
{
{ " zoom " , PLAYER_ZOOM , 0 , 0 } ,
{ " exitx " , PLAYER_EXITX , 0 , 0 } ,
{ " exity " , PLAYER_EXITY , 0 , 0 } ,
2008-07-19 13:12:20 +00:00
{ " loogiex " , PLAYER_LOOGIEX , LABEL_HASPARM2 , 64 } ,
{ " loogiey " , PLAYER_LOOGIEY , LABEL_HASPARM2 , 64 } ,
2007-08-25 01:05:00 +00:00
{ " numloogs " , PLAYER_NUMLOOGS , 0 , 0 } ,
{ " loogcnt " , PLAYER_LOOGCNT , 0 , 0 } ,
{ " posx " , PLAYER_POSX , 0 , 0 } ,
{ " posy " , PLAYER_POSY , 0 , 0 } ,
{ " posz " , PLAYER_POSZ , 0 , 0 } ,
{ " horiz " , PLAYER_HORIZ , 0 , 0 } ,
{ " ohoriz " , PLAYER_OHORIZ , 0 , 0 } ,
{ " ohorizoff " , PLAYER_OHORIZOFF , 0 , 0 } ,
{ " invdisptime " , PLAYER_INVDISPTIME , 0 , 0 } ,
{ " bobposx " , PLAYER_BOBPOSX , 0 , 0 } ,
{ " bobposy " , PLAYER_BOBPOSY , 0 , 0 } ,
{ " oposx " , PLAYER_OPOSX , 0 , 0 } ,
{ " oposy " , PLAYER_OPOSY , 0 , 0 } ,
{ " oposz " , PLAYER_OPOSZ , 0 , 0 } ,
{ " pyoff " , PLAYER_PYOFF , 0 , 0 } ,
{ " opyoff " , PLAYER_OPYOFF , 0 , 0 } ,
{ " posxv " , PLAYER_POSXV , 0 , 0 } ,
{ " posyv " , PLAYER_POSYV , 0 , 0 } ,
{ " poszv " , PLAYER_POSZV , 0 , 0 } ,
{ " last_pissed_time " , PLAYER_LAST_PISSED_TIME , 0 , 0 } ,
{ " truefz " , PLAYER_TRUEFZ , 0 , 0 } ,
{ " truecz " , PLAYER_TRUECZ , 0 , 0 } ,
{ " player_par " , PLAYER_PLAYER_PAR , 0 , 0 } ,
{ " visibility " , PLAYER_VISIBILITY , 0 , 0 } ,
{ " bobcounter " , PLAYER_BOBCOUNTER , 0 , 0 } ,
{ " weapon_sway " , PLAYER_WEAPON_SWAY , 0 , 0 } ,
{ " pals_time " , PLAYER_PALS_TIME , 0 , 0 } ,
{ " randomflamex " , PLAYER_RANDOMFLAMEX , 0 , 0 } ,
{ " crack_time " , PLAYER_CRACK_TIME , 0 , 0 } ,
{ " aim_mode " , PLAYER_AIM_MODE , 0 , 0 } ,
{ " ang " , PLAYER_ANG , 0 , 0 } ,
{ " oang " , PLAYER_OANG , 0 , 0 } ,
{ " angvel " , PLAYER_ANGVEL , 0 , 0 } ,
{ " cursectnum " , PLAYER_CURSECTNUM , 0 , 0 } ,
{ " look_ang " , PLAYER_LOOK_ANG , 0 , 0 } ,
{ " last_extra " , PLAYER_LAST_EXTRA , 0 , 0 } ,
{ " subweapon " , PLAYER_SUBWEAPON , 0 , 0 } ,
{ " ammo_amount " , PLAYER_AMMO_AMOUNT , LABEL_HASPARM2 , MAX_WEAPONS } ,
{ " wackedbyactor " , PLAYER_WACKEDBYACTOR , 0 , 0 } ,
{ " frag " , PLAYER_FRAG , 0 , 0 } ,
{ " fraggedself " , PLAYER_FRAGGEDSELF , 0 , 0 } ,
{ " curr_weapon " , PLAYER_CURR_WEAPON , 0 , 0 } ,
{ " last_weapon " , PLAYER_LAST_WEAPON , 0 , 0 } ,
{ " tipincs " , PLAYER_TIPINCS , 0 , 0 } ,
{ " horizoff " , PLAYER_HORIZOFF , 0 , 0 } ,
{ " wantweaponfire " , PLAYER_WANTWEAPONFIRE , 0 , 0 } ,
{ " holoduke_amount " , PLAYER_HOLODUKE_AMOUNT , 0 , 0 } ,
{ " newowner " , PLAYER_NEWOWNER , 0 , 0 } ,
{ " hurt_delay " , PLAYER_HURT_DELAY , 0 , 0 } ,
{ " hbomb_hold_delay " , PLAYER_HBOMB_HOLD_DELAY , 0 , 0 } ,
{ " jumping_counter " , PLAYER_JUMPING_COUNTER , 0 , 0 } ,
{ " airleft " , PLAYER_AIRLEFT , 0 , 0 } ,
{ " knee_incs " , PLAYER_KNEE_INCS , 0 , 0 } ,
{ " access_incs " , PLAYER_ACCESS_INCS , 0 , 0 } ,
{ " fta " , PLAYER_FTA , 0 , 0 } ,
{ " ftq " , PLAYER_FTQ , 0 , 0 } ,
{ " access_wallnum " , PLAYER_ACCESS_WALLNUM , 0 , 0 } ,
{ " access_spritenum " , PLAYER_ACCESS_SPRITENUM , 0 , 0 } ,
{ " kickback_pic " , PLAYER_KICKBACK_PIC , 0 , 0 } ,
{ " got_access " , PLAYER_GOT_ACCESS , 0 , 0 } ,
{ " weapon_ang " , PLAYER_WEAPON_ANG , 0 , 0 } ,
{ " firstaid_amount " , PLAYER_FIRSTAID_AMOUNT , 0 , 0 } ,
{ " somethingonplayer " , PLAYER_SOMETHINGONPLAYER , 0 , 0 } ,
{ " on_crane " , PLAYER_ON_CRANE , 0 , 0 } ,
{ " i " , PLAYER_I , 0 , 0 } ,
{ " one_parallax_sectnum " , PLAYER_ONE_PARALLAX_SECTNUM , 0 , 0 } ,
{ " over_shoulder_on " , PLAYER_OVER_SHOULDER_ON , 0 , 0 } ,
{ " random_club_frame " , PLAYER_RANDOM_CLUB_FRAME , 0 , 0 } ,
{ " fist_incs " , PLAYER_FIST_INCS , 0 , 0 } ,
{ " one_eighty_count " , PLAYER_ONE_EIGHTY_COUNT , 0 , 0 } ,
{ " cheat_phase " , PLAYER_CHEAT_PHASE , 0 , 0 } ,
{ " dummyplayersprite " , PLAYER_DUMMYPLAYERSPRITE , 0 , 0 } ,
{ " extra_extra8 " , PLAYER_EXTRA_EXTRA8 , 0 , 0 } ,
{ " quick_kick " , PLAYER_QUICK_KICK , 0 , 0 } ,
{ " heat_amount " , PLAYER_HEAT_AMOUNT , 0 , 0 } ,
{ " actorsqu " , PLAYER_ACTORSQU , 0 , 0 } ,
{ " timebeforeexit " , PLAYER_TIMEBEFOREEXIT , 0 , 0 } ,
{ " customexitsound " , PLAYER_CUSTOMEXITSOUND , 0 , 0 } ,
2010-05-02 23:27:30 +00:00
{ " weaprecs " , PLAYER_WEAPRECS , LABEL_HASPARM2 , MAX_WEAPONS } ,
2007-08-25 01:05:00 +00:00
{ " weapreccnt " , PLAYER_WEAPRECCNT , 0 , 0 } ,
{ " interface_toggle_flag " , PLAYER_INTERFACE_TOGGLE_FLAG , 0 , 0 } ,
{ " rotscrnang " , PLAYER_ROTSCRNANG , 0 , 0 } ,
{ " dead_flag " , PLAYER_DEAD_FLAG , 0 , 0 } ,
{ " show_empty_weapon " , PLAYER_SHOW_EMPTY_WEAPON , 0 , 0 } ,
{ " scuba_amount " , PLAYER_SCUBA_AMOUNT , 0 , 0 } ,
{ " jetpack_amount " , PLAYER_JETPACK_AMOUNT , 0 , 0 } ,
{ " steroids_amount " , PLAYER_STEROIDS_AMOUNT , 0 , 0 } ,
{ " shield_amount " , PLAYER_SHIELD_AMOUNT , 0 , 0 } ,
{ " holoduke_on " , PLAYER_HOLODUKE_ON , 0 , 0 } ,
{ " pycount " , PLAYER_PYCOUNT , 0 , 0 } ,
{ " weapon_pos " , PLAYER_WEAPON_POS , 0 , 0 } ,
{ " frag_ps " , PLAYER_FRAG_PS , 0 , 0 } ,
{ " transporter_hold " , PLAYER_TRANSPORTER_HOLD , 0 , 0 } ,
{ " last_full_weapon " , PLAYER_LAST_FULL_WEAPON , 0 , 0 } ,
{ " footprintshade " , PLAYER_FOOTPRINTSHADE , 0 , 0 } ,
{ " boot_amount " , PLAYER_BOOT_AMOUNT , 0 , 0 } ,
{ " scream_voice " , PLAYER_SCREAM_VOICE , 0 , 0 } ,
{ " gm " , PLAYER_GM , 0 , 0 } ,
{ " on_warping_sector " , PLAYER_ON_WARPING_SECTOR , 0 , 0 } ,
{ " footprintcount " , PLAYER_FOOTPRINTCOUNT , 0 , 0 } ,
{ " hbomb_on " , PLAYER_HBOMB_ON , 0 , 0 } ,
{ " jumping_toggle " , PLAYER_JUMPING_TOGGLE , 0 , 0 } ,
{ " rapid_fire_hold " , PLAYER_RAPID_FIRE_HOLD , 0 , 0 } ,
{ " on_ground " , PLAYER_ON_GROUND , 0 , 0 } ,
{ " name " , PLAYER_NAME , LABEL_ISSTRING , 32 } ,
{ " inven_icon " , PLAYER_INVEN_ICON , 0 , 0 } ,
{ " buttonpalette " , PLAYER_BUTTONPALETTE , 0 , 0 } ,
{ " jetpack_on " , PLAYER_JETPACK_ON , 0 , 0 } ,
{ " spritebridge " , PLAYER_SPRITEBRIDGE , 0 , 0 } ,
{ " lastrandomspot " , PLAYER_LASTRANDOMSPOT , 0 , 0 } ,
{ " scuba_on " , PLAYER_SCUBA_ON , 0 , 0 } ,
{ " footprintpal " , PLAYER_FOOTPRINTPAL , 0 , 0 } ,
{ " heat_on " , PLAYER_HEAT_ON , 0 , 0 } ,
{ " holster_weapon " , PLAYER_HOLSTER_WEAPON , 0 , 0 } ,
{ " falling_counter " , PLAYER_FALLING_COUNTER , 0 , 0 } ,
{ " gotweapon " , PLAYER_GOTWEAPON , LABEL_HASPARM2 , MAX_WEAPONS } ,
{ " refresh_inventory " , PLAYER_REFRESH_INVENTORY , 0 , 0 } ,
{ " palette " , PLAYER_PALETTE , 0 , 0 } ,
{ " toggle_key_flag " , PLAYER_TOGGLE_KEY_FLAG , 0 , 0 } ,
{ " knuckle_incs " , PLAYER_KNUCKLE_INCS , 0 , 0 } ,
{ " walking_snd_toggle " , PLAYER_WALKING_SND_TOGGLE , 0 , 0 } ,
{ " palookup " , PLAYER_PALOOKUP , 0 , 0 } ,
{ " hard_landing " , PLAYER_HARD_LANDING , 0 , 0 } ,
{ " max_secret_rooms " , PLAYER_MAX_SECRET_ROOMS , 0 , 0 } ,
{ " secret_rooms " , PLAYER_SECRET_ROOMS , 0 , 0 } ,
2008-07-19 07:39:51 +00:00
{ " pals " , PLAYER_PALS , LABEL_HASPARM2 , 3 } ,
2007-08-25 01:05:00 +00:00
{ " max_actors_killed " , PLAYER_MAX_ACTORS_KILLED , 0 , 0 } ,
{ " actors_killed " , PLAYER_ACTORS_KILLED , 0 , 0 } ,
{ " return_to_center " , PLAYER_RETURN_TO_CENTER , 0 , 0 } ,
{ " runspeed " , PLAYER_RUNSPEED , 0 , 0 } ,
{ " sbs " , PLAYER_SBS , 0 , 0 } ,
{ " reloading " , PLAYER_RELOADING , 0 , 0 } ,
{ " auto_aim " , PLAYER_AUTO_AIM , 0 , 0 } ,
{ " movement_lock " , PLAYER_MOVEMENT_LOCK , 0 , 0 } ,
{ " sound_pitch " , PLAYER_SOUND_PITCH , 0 , 0 } ,
{ " weaponswitch " , PLAYER_WEAPONSWITCH , 0 , 0 } ,
{ " team " , PLAYER_TEAM , 0 , 0 } ,
2007-08-27 23:11:49 +00:00
{ " max_player_health " , PLAYER_MAX_PLAYER_HEALTH , 0 , 0 } ,
{ " max_shield_amount " , PLAYER_MAX_SHIELD_AMOUNT , 0 , 0 } ,
{ " max_ammo_amount " , PLAYER_MAX_AMMO_AMOUNT , LABEL_HASPARM2 , MAX_WEAPONS } ,
2008-09-11 09:24:45 +00:00
{ " last_quick_kick " , PLAYER_LAST_QUICK_KICK , 0 , 0 } ,
2012-10-29 04:29:17 +00:00
{ " autostep " , PLAYER_AUTOSTEP , 0 , 0 } ,
{ " autostep_sbw " , PLAYER_AUTOSTEP_SBW , 0 , 0 } ,
2015-03-27 12:29:24 +00:00
{ " hudpal " , PLAYER_HUDPAL , 0 , 0 } ,
2015-04-26 00:07:57 +00:00
{ " index " , PLAYER_INDEX , 0 , 0 } ,
2007-08-25 01:05:00 +00:00
{ " " , - 1 , 0 , 0 } // END OF LIST
} ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
const memberlabel_t ProjectileLabels [ ] =
2007-08-25 01:05:00 +00:00
{
{ " workslike " , PROJ_WORKSLIKE , 0 , 0 } ,
{ " spawns " , PROJ_SPAWNS , 0 , 0 } ,
{ " sxrepeat " , PROJ_SXREPEAT , 0 , 0 } ,
{ " syrepeat " , PROJ_SYREPEAT , 0 , 0 } ,
{ " sound " , PROJ_SOUND , 0 , 0 } ,
{ " isound " , PROJ_ISOUND , 0 , 0 } ,
{ " vel " , PROJ_VEL , 0 , 0 } ,
{ " extra " , PROJ_EXTRA , 0 , 0 } ,
{ " decal " , PROJ_DECAL , 0 , 0 } ,
{ " trail " , PROJ_TRAIL , 0 , 0 } ,
{ " txrepeat " , PROJ_TXREPEAT , 0 , 0 } ,
{ " tyrepeat " , PROJ_TYREPEAT , 0 , 0 } ,
{ " toffset " , PROJ_TOFFSET , 0 , 0 } ,
{ " tnum " , PROJ_TNUM , 0 , 0 } ,
{ " drop " , PROJ_DROP , 0 , 0 } ,
{ " cstat " , PROJ_CSTAT , 0 , 0 } ,
{ " clipdist " , PROJ_CLIPDIST , 0 , 0 } ,
{ " shade " , PROJ_SHADE , 0 , 0 } ,
{ " xrepeat " , PROJ_XREPEAT , 0 , 0 } ,
{ " yrepeat " , PROJ_YREPEAT , 0 , 0 } ,
{ " pal " , PROJ_PAL , 0 , 0 } ,
{ " extra_rand " , PROJ_EXTRA_RAND , 0 , 0 } ,
{ " hitradius " , PROJ_HITRADIUS , 0 , 0 } ,
2012-10-05 20:48:10 +00:00
{ " velmult " , PROJ_MOVECNT , 0 , 0 } ,
2007-08-25 01:05:00 +00:00
{ " offset " , PROJ_OFFSET , 0 , 0 } ,
{ " bounces " , PROJ_BOUNCES , 0 , 0 } ,
{ " bsound " , PROJ_BSOUND , 0 , 0 } ,
{ " range " , PROJ_RANGE , 0 , 0 } ,
2009-04-13 06:01:50 +00:00
{ " flashcolor " , PROJ_FLASH_COLOR , 0 , 0 } ,
2013-06-09 16:37:18 +00:00
{ " userdata " , PROJ_USERDATA , 0 , 0 } ,
2007-08-25 01:05:00 +00:00
{ " " , - 1 , 0 , 0 } // END OF LIST
} ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
const memberlabel_t UserdefsLabels [ ] =
2007-08-25 01:05:00 +00:00
{
// { "<null>", 1, 0, 0 },
{ " god " , USERDEFS_GOD , 0 , 0 } ,
{ " warp_on " , USERDEFS_WARP_ON , 0 , 0 } ,
{ " cashman " , USERDEFS_CASHMAN , 0 , 0 } ,
{ " eog " , USERDEFS_EOG , 0 , 0 } ,
{ " showallmap " , USERDEFS_SHOWALLMAP , 0 , 0 } ,
{ " show_help " , USERDEFS_SHOW_HELP , 0 , 0 } ,
{ " scrollmode " , USERDEFS_SCROLLMODE , 0 , 0 } ,
{ " clipping " , USERDEFS_CLIPPING , 0 , 0 } ,
{ " user_name " , USERDEFS_USER_NAME , LABEL_HASPARM2 , MAXPLAYERS } ,
{ " ridecule " , USERDEFS_RIDECULE , LABEL_HASPARM2 | LABEL_ISSTRING , 10 } ,
{ " savegame " , USERDEFS_SAVEGAME , LABEL_HASPARM2 | LABEL_ISSTRING , 10 } ,
{ " pwlockout " , USERDEFS_PWLOCKOUT , LABEL_ISSTRING , 128 } ,
{ " rtsname; " , USERDEFS_RTSNAME , LABEL_ISSTRING , 128 } ,
{ " overhead_on " , USERDEFS_OVERHEAD_ON , 0 , 0 } ,
{ " last_overhead " , USERDEFS_LAST_OVERHEAD , 0 , 0 } ,
{ " showweapons " , USERDEFS_SHOWWEAPONS , 0 , 0 } ,
{ " pause_on " , USERDEFS_PAUSE_ON , 0 , 0 } ,
{ " from_bonus " , USERDEFS_FROM_BONUS , 0 , 0 } ,
{ " camerasprite " , USERDEFS_CAMERASPRITE , 0 , 0 } ,
{ " last_camsprite " , USERDEFS_LAST_CAMSPRITE , 0 , 0 } ,
{ " last_level " , USERDEFS_LAST_LEVEL , 0 , 0 } ,
{ " secretlevel " , USERDEFS_SECRETLEVEL , 0 , 0 } ,
2015-02-08 08:03:30 +00:00
{ " playerbest " , USERDEFS_PLAYERBEST , 0 , 0 } ,
2007-08-25 01:05:00 +00:00
{ " const_visibility " , USERDEFS_CONST_VISIBILITY , 0 , 0 } ,
{ " uw_framerate " , USERDEFS_UW_FRAMERATE , 0 , 0 } ,
{ " camera_time " , USERDEFS_CAMERA_TIME , 0 , 0 } ,
{ " folfvel " , USERDEFS_FOLFVEL , 0 , 0 } ,
{ " folavel " , USERDEFS_FOLAVEL , 0 , 0 } ,
{ " folx " , USERDEFS_FOLX , 0 , 0 } ,
{ " foly " , USERDEFS_FOLY , 0 , 0 } ,
{ " fola " , USERDEFS_FOLA , 0 , 0 } ,
{ " reccnt " , USERDEFS_RECCNT , 0 , 0 } ,
2015-01-25 12:16:58 +00:00
{ " m_origin_x " , USERDEFS_M_ORIGIN_X , 0 , 0 } ,
{ " m_origin_y " , USERDEFS_M_ORIGIN_Y , 0 , 0 } ,
2015-03-08 07:57:13 +00:00
{ " usevoxels " , USERDEFS_USEVOXELS , 0 , 0 } ,
{ " usehightile " , USERDEFS_USEHIGHTILE , 0 , 0 } ,
{ " usemodels " , USERDEFS_USEMODELS , 0 , 0 } ,
2007-08-25 01:05:00 +00:00
{ " entered_name " , USERDEFS_ENTERED_NAME , 0 , 0 } ,
{ " screen_tilting " , USERDEFS_SCREEN_TILTING , 0 , 0 } ,
{ " shadows " , USERDEFS_SHADOWS , 0 , 0 } ,
{ " fta_on " , USERDEFS_FTA_ON , 0 , 0 } ,
{ " executions " , USERDEFS_EXECUTIONS , 0 , 0 } ,
{ " auto_run " , USERDEFS_AUTO_RUN , 0 , 0 } ,
{ " coords " , USERDEFS_COORDS , 0 , 0 } ,
{ " tickrate " , USERDEFS_TICKRATE , 0 , 0 } ,
{ " m_coop " , USERDEFS_M_COOP , 0 , 0 } ,
{ " coop " , USERDEFS_COOP , 0 , 0 } ,
{ " screen_size " , USERDEFS_SCREEN_SIZE , 0 , 0 } ,
{ " lockout " , USERDEFS_LOCKOUT , 0 , 0 } ,
{ " crosshair " , USERDEFS_CROSSHAIR , 0 , 0 } ,
2013-12-26 19:44:56 +00:00
// { "wchoice[MAXPLAYERS][MAX_WEAPONS]", USERDEFS_WCHOICE, 0, 0 },
2007-08-25 01:05:00 +00:00
{ " playerai " , USERDEFS_PLAYERAI , 0 , 0 } ,
{ " respawn_monsters " , USERDEFS_RESPAWN_MONSTERS , 0 , 0 } ,
{ " respawn_items " , USERDEFS_RESPAWN_ITEMS , 0 , 0 } ,
{ " respawn_inventory " , USERDEFS_RESPAWN_INVENTORY , 0 , 0 } ,
{ " recstat " , USERDEFS_RECSTAT , 0 , 0 } ,
{ " monsters_off " , USERDEFS_MONSTERS_OFF , 0 , 0 } ,
{ " brightness " , USERDEFS_BRIGHTNESS , 0 , 0 } ,
{ " m_respawn_items " , USERDEFS_M_RESPAWN_ITEMS , 0 , 0 } ,
{ " m_respawn_monsters " , USERDEFS_M_RESPAWN_MONSTERS , 0 , 0 } ,
{ " m_respawn_inventory " , USERDEFS_M_RESPAWN_INVENTORY , 0 , 0 } ,
{ " m_recstat " , USERDEFS_M_RECSTAT , 0 , 0 } ,
{ " m_monsters_off " , USERDEFS_M_MONSTERS_OFF , 0 , 0 } ,
{ " detail " , USERDEFS_DETAIL , 0 , 0 } ,
{ " m_ffire " , USERDEFS_M_FFIRE , 0 , 0 } ,
{ " ffire " , USERDEFS_FFIRE , 0 , 0 } ,
{ " m_player_skill " , USERDEFS_M_PLAYER_SKILL , 0 , 0 } ,
{ " m_level_number " , USERDEFS_M_LEVEL_NUMBER , 0 , 0 } ,
{ " m_volume_number " , USERDEFS_M_VOLUME_NUMBER , 0 , 0 } ,
{ " multimode " , USERDEFS_MULTIMODE , 0 , 0 } ,
{ " player_skill " , USERDEFS_PLAYER_SKILL , 0 , 0 } ,
{ " level_number " , USERDEFS_LEVEL_NUMBER , 0 , 0 } ,
{ " volume_number " , USERDEFS_VOLUME_NUMBER , 0 , 0 } ,
{ " m_marker " , USERDEFS_M_MARKER , 0 , 0 } ,
{ " marker " , USERDEFS_MARKER , 0 , 0 } ,
{ " mouseflip " , USERDEFS_MOUSEFLIP , 0 , 0 } ,
{ " statusbarscale " , USERDEFS_STATUSBARSCALE , 0 , 0 } ,
{ " drawweapon " , USERDEFS_DRAWWEAPON , 0 , 0 } ,
{ " mouseaiming " , USERDEFS_MOUSEAIMING , 0 , 0 } ,
{ " weaponswitch " , USERDEFS_WEAPONSWITCH , 0 , 0 } ,
{ " democams " , USERDEFS_DEMOCAMS , 0 , 0 } ,
{ " color " , USERDEFS_COLOR , 0 , 0 } ,
{ " msgdisptime " , USERDEFS_MSGDISPTIME , 0 , 0 } ,
{ " statusbarmode " , USERDEFS_STATUSBARMODE , 0 , 0 } ,
{ " m_noexits " , USERDEFS_M_NOEXITS , 0 , 0 } ,
{ " noexits " , USERDEFS_NOEXITS , 0 , 0 } ,
{ " autovote " , USERDEFS_AUTOVOTE , 0 , 0 } ,
{ " automsg " , USERDEFS_AUTOMSG , 0 , 0 } ,
{ " idplayers " , USERDEFS_IDPLAYERS , 0 , 0 } ,
{ " team " , USERDEFS_TEAM , 0 , 0 } ,
{ " viewbob " , USERDEFS_VIEWBOB , 0 , 0 } ,
{ " weaponsway " , USERDEFS_WEAPONSWAY , 0 , 0 } ,
{ " angleinterpolation " , USERDEFS_ANGLEINTERPOLATION , 0 , 0 } ,
2008-07-31 10:35:23 +00:00
{ " obituaries " , USERDEFS_OBITUARIES , 0 , 0 } ,
2008-03-31 02:55:50 +00:00
{ " levelstats " , USERDEFS_LEVELSTATS , 0 , 0 } ,
2008-07-21 09:05:53 +00:00
{ " crosshairscale " , USERDEFS_CROSSHAIRSCALE , 0 , 0 } ,
2008-08-07 07:52:36 +00:00
{ " althud " , USERDEFS_ALTHUD , 0 , 0 } ,
2008-08-19 11:05:21 +00:00
{ " display_bonus_screen " , USERDEFS_DISPLAY_BONUS_SCREEN , 0 , 0 } ,
2008-09-29 02:12:53 +00:00
{ " show_level_text " , USERDEFS_SHOW_LEVEL_TEXT , 0 , 0 } ,
2008-10-05 11:51:59 +00:00
{ " weaponscale " , USERDEFS_WEAPONSCALE , 0 , 0 } ,
2008-10-11 09:20:04 +00:00
{ " textscale " , USERDEFS_TEXTSCALE , 0 , 0 } ,
2012-10-14 18:18:30 +00:00
{ " runkey_mode " , USERDEFS_RUNKEY_MODE , 0 , 0 } ,
2015-02-08 08:04:09 +00:00
{ " musictoggle " , USERDEFS_MUSICTOGGLE , 0 , 0 } ,
2015-03-08 07:57:28 +00:00
{ " gametypeflags " , USERDEFS_GAMETYPEFLAGS , 0 , 0 } ,
{ " m_gametypeflags " , USERDEFS_M_GAMETYPEFLAGS , 0 , 0 } ,
2007-08-25 01:05:00 +00:00
{ " " , - 1 , 0 , 0 } // END OF LIST
} ;
2007-02-08 04:19:39 +00:00
2008-11-20 14:06:36 +00:00
const memberlabel_t InputLabels [ ] =
2007-08-25 01:05:00 +00:00
{
{ " avel " , INPUT_AVEL , 0 , 0 } ,
{ " horz " , INPUT_HORZ , 0 , 0 } ,
{ " fvel " , INPUT_FVEL , 0 , 0 } ,
{ " svel " , INPUT_SVEL , 0 , 0 } ,
{ " bits " , INPUT_BITS , 0 , 0 } ,
{ " extbits " , INPUT_EXTBITS , 0 , 0 } ,
{ " " , - 1 , 0 , 0 } // END OF LIST
} ;
2006-04-13 20:47:06 +00:00
2015-03-30 05:56:37 +00:00
const memberlabel_t TileDataLabels [ ] =
{
// tilesiz[]
{ " xsize " , TILEDATA_XSIZE , 0 , 0 } ,
{ " ysize " , TILEDATA_YSIZE , 0 , 0 } ,
// picanm[]
{ " animframes " , TILEDATA_ANIMFRAMES , 0 , 0 } ,
{ " xoffset " , TILEDATA_XOFFSET , 0 , 0 } ,
{ " yoffset " , TILEDATA_YOFFSET , 0 , 0 } ,
{ " animspeed " , TILEDATA_ANIMSPEED , 0 , 0 } ,
{ " animtype " , TILEDATA_ANIMTYPE , 0 , 0 } ,
// g_tile[]
{ " gameflags " , TILEDATA_GAMEFLAGS , 0 , 0 } ,
{ " " , - 1 , 0 , 0 } // END OF LIST
} ;
const memberlabel_t PalDataLabels [ ] =
{
// g_noFloorPal[]
{ " nofloorpal " , PALDATA_NOFLOORPAL , 0 , 0 } ,
{ " " , - 1 , 0 , 0 } // END OF LIST
} ;
2013-01-01 15:24:18 +00:00
# endif
2008-09-12 02:07:44 +00:00
char * bitptr ; // pointer to bitmap of which bytecode positions contain pointers
2008-08-16 10:54:10 +00:00
# define BITPTR_POINTER 1
2013-01-20 21:17:06 +00:00
# if !defined LUNATIC
2010-05-02 23:27:30 +00:00
hashtable_t h_gamevars = { MAXGAMEVARS > > 1 , NULL } ;
hashtable_t h_arrays = { MAXGAMEARRAYS > > 1 , NULL } ;
hashtable_t h_labels = { 11264 > > 1 , NULL } ;
2013-01-01 15:24:18 +00:00
2012-01-15 22:40:16 +00:00
static hashtable_t h_keywords = { CON_END > > 1 , NULL } ;
2008-08-25 00:49:12 +00:00
2012-01-15 22:40:16 +00:00
static hashtable_t sectorH = { SECTOR_END > > 1 , NULL } ;
static hashtable_t wallH = { WALL_END > > 1 , NULL } ;
static hashtable_t userdefH = { USERDEFS_END > > 1 , NULL } ;
2008-08-25 00:49:12 +00:00
2012-01-15 22:40:16 +00:00
static hashtable_t projectileH = { PROJ_END > > 1 , NULL } ;
static hashtable_t playerH = { PLAYER_END > > 1 , NULL } ;
static hashtable_t inputH = { INPUT_END > > 1 , NULL } ;
static hashtable_t actorH = { ACTOR_END > > 1 , NULL } ;
static hashtable_t tspriteH = { ACTOR_END > > 1 , NULL } ;
2008-08-25 00:49:12 +00:00
2015-03-30 05:56:37 +00:00
static hashtable_t tiledataH = { TILEDATA_END > > 1 , NULL } ;
static hashtable_t paldataH = { PALDATA_END > > 1 , NULL } ;
2009-01-05 14:43:12 +00:00
void C_InitHashes ( )
2008-08-25 00:49:12 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2008-08-25 00:49:12 +00:00
2010-05-02 23:27:30 +00:00
hash_init ( & h_gamevars ) ;
hash_init ( & h_arrays ) ;
hash_init ( & h_labels ) ;
2008-08-25 20:25:49 +00:00
inithashnames ( ) ;
2013-06-01 06:55:30 +00:00
initsoundhashnames ( ) ;
2008-08-25 00:49:12 +00:00
2010-05-02 23:27:30 +00:00
hash_init ( & h_keywords ) ;
2009-01-10 07:38:50 +00:00
hash_init ( & sectorH ) ;
hash_init ( & wallH ) ;
hash_init ( & userdefH ) ;
hash_init ( & projectileH ) ;
hash_init ( & playerH ) ;
hash_init ( & inputH ) ;
hash_init ( & actorH ) ;
hash_init ( & tspriteH ) ;
2015-03-30 05:56:37 +00:00
hash_init ( & tiledataH ) ;
hash_init ( & paldataH ) ;
2009-11-18 01:17:56 +00:00
2010-09-27 21:52:04 +00:00
g_scriptLastKeyword = NUMKEYWORDS - 1 ;
// determine last CON keyword for backward compatibility with older mods
if ( g_scriptDateVersion < g_keywdate [ NUMKEYWDATES - 1 ] . date )
{
for ( i = NUMKEYWDATES - 1 ; i > = 0 ; i - - )
{
if ( g_scriptDateVersion > = g_keywdate [ i ] . date )
{
g_scriptLastKeyword = g_keywdate [ i ] . keyw ;
break ;
}
}
if ( i < 0 )
g_scriptLastKeyword = g_keywdate [ 0 ] . keyw - 1 ; // may be slightly imprecise
}
for ( i = g_scriptLastKeyword ; i > = 0 ; i - - ) hash_add ( & h_keywords , keyw [ i ] , i , 0 ) ;
2010-08-02 08:13:51 +00:00
for ( i = 0 ; SectorLabels [ i ] . lId > = 0 ; i + + ) hash_add ( & sectorH , SectorLabels [ i ] . name , i , 0 ) ;
for ( i = 0 ; WallLabels [ i ] . lId > = 0 ; i + + ) hash_add ( & wallH , WallLabels [ i ] . name , i , 0 ) ;
for ( i = 0 ; UserdefsLabels [ i ] . lId > = 0 ; i + + ) hash_add ( & userdefH , UserdefsLabels [ i ] . name , i , 0 ) ;
for ( i = 0 ; ProjectileLabels [ i ] . lId > = 0 ; i + + ) hash_add ( & projectileH , ProjectileLabels [ i ] . name , i , 0 ) ;
for ( i = 0 ; PlayerLabels [ i ] . lId > = 0 ; i + + ) hash_add ( & playerH , PlayerLabels [ i ] . name , i , 0 ) ;
for ( i = 0 ; InputLabels [ i ] . lId > = 0 ; i + + ) hash_add ( & inputH , InputLabels [ i ] . name , i , 0 ) ;
for ( i = 0 ; ActorLabels [ i ] . lId > = 0 ; i + + ) hash_add ( & actorH , ActorLabels [ i ] . name , i , 0 ) ;
for ( i = 0 ; TsprLabels [ i ] . lId > = 0 ; i + + ) hash_add ( & tspriteH , TsprLabels [ i ] . name , i , 0 ) ;
2015-03-30 05:56:37 +00:00
for ( i = 0 ; TileDataLabels [ i ] . lId > = 0 ; i + + ) hash_add ( & tiledataH , TileDataLabels [ i ] . name , i , 0 ) ;
for ( i = 0 ; PalDataLabels [ i ] . lId > = 0 ; i + + ) hash_add ( & paldataH , PalDataLabels [ i ] . name , i , 0 ) ;
2008-08-25 00:49:12 +00:00
}
2008-08-25 02:12:02 +00:00
2009-05-22 23:49:25 +00:00
// "magic" number for { and }, overrides line number in compiled code for later detection
2009-01-05 14:43:12 +00:00
# define IFELSE_MAGIC 31337
2009-01-09 09:29:17 +00:00
static int32_t g_ifElseAborted ;
2009-01-04 22:22:33 +00:00
2011-03-04 08:50:58 +00:00
static int32_t C_SetScriptSize ( int32_t newsize )
2008-07-20 03:29:00 +00:00
{
2008-11-20 14:06:36 +00:00
intptr_t oscriptPtr = ( unsigned ) ( g_scriptPtr - script ) ;
intptr_t ocaseScriptPtr = ( unsigned ) ( g_caseScriptPtr - script ) ;
intptr_t oparsingEventPtr = ( unsigned ) ( g_parsingEventPtr - script ) ;
intptr_t oparsingActorPtr = ( unsigned ) ( g_parsingActorPtr - script ) ;
2008-07-20 03:29:00 +00:00
intptr_t * newscript ;
intptr_t i , j ;
2009-01-09 09:29:17 +00:00
int32_t osize = g_scriptSize ;
2011-03-04 08:50:58 +00:00
char * scriptptrs ;
2008-09-12 02:07:44 +00:00
char * newbitptr ;
2012-01-15 22:40:16 +00:00
2014-05-30 00:02:19 +00:00
scriptptrs = ( char * ) Xcalloc ( 1 , g_scriptSize * sizeof ( uint8_t ) ) ;
2011-03-04 08:50:58 +00:00
2009-02-19 16:47:54 +00:00
for ( i = g_scriptSize - 1 ; i > = 0 ; i - - )
2008-07-20 03:29:00 +00:00
{
2009-01-10 07:38:50 +00:00
if ( bitptr [ i > > 3 ] & ( BITPTR_POINTER < < ( i & 7 ) ) )
2008-07-20 03:29:00 +00:00
{
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( intptr_t ) script [ i ] < ( intptr_t ) & script [ 0 ] | | ( intptr_t ) script [ i ] > = ( intptr_t ) & script [ g_scriptSize ] ) )
2011-03-04 08:50:58 +00:00
{
g_numCompilerErrors + + ;
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
initprintf ( " Internal compiler error at % " PRIdPTR " (0x% " PRIxPTR " ) \n " , i , i ) ;
2011-03-04 08:50:58 +00:00
}
2008-07-20 03:29:00 +00:00
scriptptrs [ i ] = 1 ;
2008-08-16 07:53:29 +00:00
script [ i ] - = ( intptr_t ) & script [ 0 ] ;
2008-07-20 03:29:00 +00:00
}
else scriptptrs [ i ] = 0 ;
}
2012-10-30 15:54:35 +00:00
G_Util_PtrToIdx2 ( & g_tile [ 0 ] . execPtr , MAXTILES , sizeof ( tiledata_t ) , script , P2I_FWD_NON0 ) ;
G_Util_PtrToIdx2 ( & g_tile [ 0 ] . loadPtr , MAXTILES , sizeof ( tiledata_t ) , script , P2I_FWD_NON0 ) ;
2011-07-29 22:07:49 +00:00
G_Util_PtrToIdx ( apScriptGameEvent , MAXGAMEEVENTS , script , P2I_FWD_NON0 ) ;
2008-07-20 03:29:00 +00:00
2011-03-04 08:50:58 +00:00
initprintf ( " Resizing code buffer to %d*%d bytes \n " , newsize , ( int32_t ) sizeof ( intptr_t ) ) ;
2008-08-25 10:27:18 +00:00
2014-05-30 00:02:19 +00:00
newscript = ( intptr_t * ) Xrealloc ( script , newsize * sizeof ( intptr_t ) ) ;
newbitptr = ( char * ) Xcalloc ( 1 , ( ( ( newsize + 7 ) > > 3 ) + 1 ) * sizeof ( uint8_t ) ) ;
2008-08-25 10:27:18 +00:00
2011-03-04 08:50:58 +00:00
if ( newsize > = osize )
2008-08-25 10:27:18 +00:00
{
2011-03-04 08:50:58 +00:00
Bmemset ( & newscript [ 0 ] + osize , 0 , ( newsize - osize ) * sizeof ( uint8_t ) ) ;
2009-02-19 16:47:54 +00:00
Bmemcpy ( newbitptr , bitptr , sizeof ( uint8_t ) * ( ( osize + 7 ) > > 3 ) ) ;
2008-09-12 02:07:44 +00:00
}
2009-05-22 23:49:25 +00:00
else
2011-03-04 08:50:58 +00:00
Bmemcpy ( newbitptr , bitptr , sizeof ( uint8_t ) * ( ( newsize + 7 ) > > 3 ) ) ;
2008-08-25 10:27:18 +00:00
2008-09-12 02:07:44 +00:00
Bfree ( bitptr ) ;
bitptr = newbitptr ;
2009-05-22 23:49:25 +00:00
if ( script ! = newscript )
{
Win64 support! (Meaning it works, not that we recommend it for everyday use.)
This includes a complete Windows header and library refresh, including the addition of 64-bit compiled libs:
*libogg 1.3.0
*libvorbis 1.3.3
*zlib 1.2.7
*libpng 1.5.13
*libvpx 9a3de881c0e681ba1a79a166a86308bbc84b4acd
*SDL_mixer 1.2.12 (for RENDERTYPE=SDL)
*DirectX import libraries: dsound and dxguid (now included)
To build in 64-bit, you essentially need MinGW's MSYS (but not MinGW itself) and MinGW-w64 at the top of your PATH. The target is automatically detected using `$(CC) -dumpmachine`. The EDukeWiki will get detailed instrucitons.
All compiler and linker warnings when building in 64-bit mode have been fixed.
Remaining 64-bit to-do:
- The ebacktrace dll does not build under 64-bit. It uses code specific to the format of 32-bit executables and will have to be ported to work with 64-bit executables. A future 64-bit version will be named ebacktrace1-64.dll.
- RENDERTYPE=SDL crashes in SDL_mixer's Mix_Linked_Version().
- DirectInput gives an error and does not function. This only affects joysticks, and the error never happens without any plugged in.
- Port the classic renderer ASM to 64-bit. (Just kidding, this is way out of my league.)
This commit includes a fair bit of Makefile development spanning all platforms, including simplifying the SDLCONFIG code, fixing build on Mac OS X (thanks rhoenie!), globally factoring Apple brew/port inclusion, enforcing that all -L come before all -l, and ensuring that $(shell ) is always :='d.
In addition, I have resurrected the old GCC_MAJOR and GCC_MINOR detection using `$(CC) -dumpversion`, but I have made it failsafe in case the command fails or the version is manually specified. I have applied this new fine-grained detection where applicable, including allowing LTO, and restraining -W's to versions that support them.
git-svn-id: https://svn.eduke32.com/eduke32@3278 1a8010ca-5511-0410-912e-c29ae57300e0
2012-12-13 02:37:20 +00:00
initprintf ( " Relocating compiled code from to 0x% " PRIxPTR " to 0x% " PRIxPTR " \n " , ( intptr_t ) script , ( intptr_t ) newscript ) ;
2009-05-22 23:49:25 +00:00
script = newscript ;
}
2011-03-04 08:50:58 +00:00
g_scriptSize = newsize ;
2008-11-20 14:06:36 +00:00
g_scriptPtr = ( intptr_t * ) ( script + oscriptPtr ) ;
2009-11-18 01:17:56 +00:00
if ( g_caseScriptPtr )
2008-11-20 14:06:36 +00:00
g_caseScriptPtr = ( intptr_t * ) ( script + ocaseScriptPtr ) ;
2009-11-18 01:17:56 +00:00
if ( g_parsingEventPtr )
2008-11-20 14:06:36 +00:00
g_parsingEventPtr = ( intptr_t * ) ( script + oparsingEventPtr ) ;
2009-11-18 01:17:56 +00:00
if ( g_parsingActorPtr )
2008-11-20 14:06:36 +00:00
g_parsingActorPtr = ( intptr_t * ) ( script + oparsingActorPtr ) ;
2012-01-15 22:40:16 +00:00
2011-03-04 08:50:58 +00:00
for ( i = ( ( ( newsize > = osize ) ? osize : newsize ) ) - 1 ; i > = 0 ; i - - )
if ( scriptptrs [ i ] )
{
2011-07-29 22:07:49 +00:00
j = ( intptr_t ) script [ i ] + ( intptr_t ) & script [ 0 ] ;
2011-03-04 08:50:58 +00:00
script [ i ] = j ;
}
2008-07-20 03:29:00 +00:00
2012-10-30 15:54:35 +00:00
G_Util_PtrToIdx2 ( & g_tile [ 0 ] . execPtr , MAXTILES , sizeof ( tiledata_t ) , script , P2I_BACK_NON0 ) ;
G_Util_PtrToIdx2 ( & g_tile [ 0 ] . loadPtr , MAXTILES , sizeof ( tiledata_t ) , script , P2I_BACK_NON0 ) ;
2011-07-29 22:07:49 +00:00
G_Util_PtrToIdx ( apScriptGameEvent , MAXGAMEEVENTS , script , P2I_BACK_NON0 ) ;
2009-01-04 22:22:33 +00:00
2008-07-20 03:29:00 +00:00
Bfree ( scriptptrs ) ;
return 0 ;
}
2012-05-05 22:24:02 +00:00
static int32_t ispecial ( const char c )
2010-01-23 22:12:02 +00:00
{
if ( c = = ' ' | | c = = 0x0d | | c = = ' ( ' | | c = = ' ) ' | |
2010-03-14 15:49:03 +00:00
c = = ' , ' | | c = = ' ; ' | | ( c = = 0x0a /*&& ++g_lineNumber*/ ) )
2010-01-23 22:12:02 +00:00
return 1 ;
return 0 ;
}
2009-11-20 03:54:40 +00:00
2015-03-25 06:28:09 +00:00
static void C_NextLine ( void )
{
while ( * textptr ! = 0x0a & & * textptr ! = 0x0d & & * textptr ! = 0 )
textptr + + ;
}
static void C_SkipSpace ( void )
{
while ( * textptr = = ' ' | | * textptr = = ' \t ' )
textptr + + ;
}
2009-11-20 03:54:40 +00:00
2009-01-09 09:29:17 +00:00
static int32_t C_SkipComments ( void )
2006-04-13 20:47:06 +00:00
{
2008-08-28 11:35:35 +00:00
do
2006-04-13 20:47:06 +00:00
{
2009-11-18 01:17:56 +00:00
switch ( * textptr )
2006-11-15 01:16:55 +00:00
{
2009-11-18 01:17:56 +00:00
case ' \n ' :
2008-11-20 14:06:36 +00:00
g_lineNumber + + ;
2009-11-18 01:17:56 +00:00
case ' ' :
case ' \t ' :
case ' \r ' :
2010-07-03 08:53:57 +00:00
case 0x1a :
2006-04-13 20:47:06 +00:00
textptr + + ;
2009-11-18 01:17:56 +00:00
break ;
case ' / ' :
switch ( textptr [ 1 ] )
2006-04-13 20:47:06 +00:00
{
2009-11-18 01:17:56 +00:00
case ' / ' : // C++ style comment
if ( ! ( g_numCompilerErrors | | g_numCompilerWarnings ) & & g_scriptDebug > 1 )
initprintf ( " %s:%d: debug: got comment. \n " , g_szScriptFileName , g_lineNumber ) ;
2009-11-20 03:54:40 +00:00
C_NextLine ( ) ;
2010-07-03 08:53:57 +00:00
continue ;
2009-11-18 01:17:56 +00:00
case ' * ' : // beginning of a C style comment
if ( ! ( g_numCompilerErrors | | g_numCompilerWarnings ) & & g_scriptDebug > 1 )
initprintf ( " %s:%d: debug: got start of comment block. \n " , g_szScriptFileName , g_lineNumber ) ;
do
{
if ( * textptr = = ' \n ' )
g_lineNumber + + ;
textptr + + ;
}
while ( * textptr & & ( textptr [ 0 ] ! = ' * ' | | textptr [ 1 ] ! = ' / ' ) ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ! * textptr ) )
2009-11-18 01:17:56 +00:00
{
if ( ! ( g_numCompilerErrors | | g_numCompilerWarnings ) & & g_scriptDebug )
initprintf ( " %s:%d: debug: EOF in comment! \n " , g_szScriptFileName , g_lineNumber ) ;
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: error: found `/*' with no `*/'. \n " , g_szScriptFileName , g_lineNumber ) ;
2011-04-07 01:16:29 +00:00
g_parsingActorPtr = NULL ; g_processingState = g_numBraces = 0 ;
2009-11-18 01:17:56 +00:00
g_numCompilerErrors + + ;
2010-07-03 08:53:57 +00:00
continue ;
2009-11-18 01:17:56 +00:00
}
if ( ! ( g_numCompilerErrors | | g_numCompilerWarnings ) & & g_scriptDebug > 1 )
initprintf ( " %s:%d: debug: got end of comment block. \n " , g_szScriptFileName , g_lineNumber ) ;
textptr + = 2 ;
2010-07-03 08:53:57 +00:00
continue ;
2006-04-13 20:47:06 +00:00
}
2010-07-03 08:53:57 +00:00
continue ;
2009-11-18 01:17:56 +00:00
default :
2009-11-20 03:54:40 +00:00
if ( ispecial ( * textptr ) )
{
textptr + + ;
2010-07-03 08:53:57 +00:00
continue ;
2009-11-20 03:54:40 +00:00
}
case 0 : // EOF
2009-11-18 01:17:56 +00:00
return ( ( g_scriptPtr - script ) > ( g_scriptSize - 32 ) ) ? C_SetScriptSize ( g_scriptSize < < 1 ) : 0 ;
2006-04-13 20:47:06 +00:00
}
2008-09-01 21:59:53 +00:00
}
2009-11-18 01:17:56 +00:00
while ( 1 ) ;
2006-04-13 20:47:06 +00:00
}
2010-05-02 23:27:30 +00:00
# define GetDefID(szGameLabel) hash_find(&h_gamevars,szGameLabel)
# define GetADefID(szGameLabel) hash_find(&h_arrays,szGameLabel)
2008-12-21 22:46:55 +00:00
2012-05-05 22:24:02 +00:00
static int32_t isaltok ( const char c )
2006-04-13 20:47:06 +00:00
{
2009-01-16 06:11:25 +00:00
return ( isalnum ( c ) | | c = = ' { ' | | c = = ' } ' | | c = = ' / ' | | c = = ' \\ ' | |
2009-01-18 07:32:35 +00:00
c = = ' * ' | | c = = ' - ' | | c = = ' _ ' | | c = = ' . ' ) ;
2006-04-13 20:47:06 +00:00
}
2014-05-18 09:55:41 +00:00
static int32_t C_IsLabelChar ( const char c , int32_t i )
{
return ( isalnum ( c ) | | c = = ' _ ' | | c = = ' * ' | | c = = ' ? ' | |
( i > 0 & & ( c = = ' + ' | | c = = ' - ' | | c = = ' . ' ) ) ) ;
}
2009-01-10 07:38:50 +00:00
static inline int32_t C_GetLabelNameID ( const memberlabel_t * pLabel , hashtable_t * tH , const char * psz )
2006-04-13 20:47:06 +00:00
{
// find the label psz in the table pLabel.
// returns the ID for the label, or -1
2011-04-07 01:16:29 +00:00
int32_t l = hash_findcase ( tH , psz ) ;
return ( l > = 0 ) ? pLabel [ l ] . lId : - 1 ;
2006-04-13 20:47:06 +00:00
}
2009-01-10 07:38:50 +00:00
static inline int32_t C_GetLabelNameOffset ( hashtable_t * tH , const char * psz )
2006-04-13 20:47:06 +00:00
{
// find the label psz in the table pLabel.
// returns the offset in the array for the label, or -1
2009-01-10 07:38:50 +00:00
return hash_findcase ( tH , psz ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
static void C_GetNextLabelName ( void )
2006-04-13 20:47:06 +00:00
{
2011-04-07 01:16:29 +00:00
int32_t i = 0 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
C_SkipComments ( ) ;
2006-04-13 20:47:06 +00:00
2014-05-18 09:55:41 +00:00
// while (ispecial(*textptr) == 0 && *textptr!='['&& *textptr!=']' && *textptr!='\t' && *textptr!='\n' && *textptr!='\r')
while ( C_IsLabelChar ( * textptr , i ) )
2008-11-20 14:06:36 +00:00
label [ ( g_numLabels < < 6 ) + ( i + + ) ] = * ( textptr + + ) ;
label [ ( g_numLabels < < 6 ) + i ] = 0 ;
2011-04-07 01:16:29 +00:00
if ( ! ( g_numCompilerErrors | g_numCompilerWarnings ) & & g_scriptDebug > 1 )
2008-11-20 14:06:36 +00:00
initprintf ( " %s:%d: debug: got label `%s'. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
2006-04-13 20:47:06 +00:00
}
2009-01-09 09:29:17 +00:00
static int32_t C_GetKeyword ( void )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2006-04-13 20:47:06 +00:00
char * temptextptr ;
2008-11-20 14:06:36 +00:00
C_SkipComments ( ) ;
2006-04-13 20:47:06 +00:00
temptextptr = textptr ;
2011-04-07 01:16:29 +00:00
if ( * temptextptr = = 0 ) // EOF
return - 2 ;
2006-11-14 21:35:50 +00:00
while ( isaltok ( * temptextptr ) = = 0 )
2006-04-13 20:47:06 +00:00
{
temptextptr + + ;
2006-11-14 21:35:50 +00:00
if ( * temptextptr = = 0 )
2006-04-13 20:47:06 +00:00
return 0 ;
}
i = 0 ;
2006-11-14 21:35:50 +00:00
while ( isaltok ( * temptextptr ) )
2008-08-26 08:39:45 +00:00
tempbuf [ i + + ] = * ( temptextptr + + ) ;
2006-04-13 20:47:06 +00:00
tempbuf [ i ] = 0 ;
2011-04-07 01:16:29 +00:00
2010-05-02 23:27:30 +00:00
return hash_find ( & h_keywords , tempbuf ) ;
2006-04-13 20:47:06 +00:00
}
2009-01-09 09:29:17 +00:00
static int32_t C_GetNextKeyword ( void ) //Returns its code #
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i , l ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
C_SkipComments ( ) ;
2006-04-13 20:47:06 +00:00
2009-11-18 01:17:56 +00:00
if ( * textptr = = 0 ) // EOF
2011-04-07 01:16:29 +00:00
return - 2 ;
2006-04-13 20:47:06 +00:00
l = 0 ;
2006-11-14 21:35:50 +00:00
while ( isaltok ( * ( textptr + l ) ) )
2006-04-13 20:47:06 +00:00
{
tempbuf [ l ] = textptr [ l ] ;
l + + ;
}
tempbuf [ l ] = 0 ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_TRUE ( ( i = hash_find ( & h_keywords , tempbuf ) ) > = 0 ) )
2006-04-13 20:47:06 +00:00
{
2009-01-04 22:22:33 +00:00
if ( i = = CON_LEFTBRACE | | i = = CON_RIGHTBRACE | | i = = CON_NULLOP )
2009-01-05 14:43:12 +00:00
* g_scriptPtr = i + ( IFELSE_MAGIC < < 12 ) ;
2009-01-04 22:22:33 +00:00
else * g_scriptPtr = i + ( g_lineNumber < < 12 ) ;
2009-05-28 02:55:46 +00:00
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2008-08-25 00:49:12 +00:00
textptr + = l ;
2008-11-20 14:06:36 +00:00
g_scriptPtr + + ;
2009-05-28 02:55:46 +00:00
2008-11-20 14:06:36 +00:00
if ( ! ( g_numCompilerErrors | | g_numCompilerWarnings ) & & g_scriptDebug )
initprintf ( " %s:%d: debug: translating keyword `%s'. \n " , g_szScriptFileName , g_lineNumber , keyw [ i ] ) ;
2008-08-25 00:49:12 +00:00
return i ;
2006-04-13 20:47:06 +00:00
}
textptr + = l ;
2011-04-07 01:16:29 +00:00
g_numCompilerErrors + + ;
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( tempbuf [ 0 ] = = ' { ' | | tempbuf [ 0 ] = = ' } ' ) & & tempbuf [ 1 ] ! = 0 ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
C_ReportError ( - 1 ) ;
2011-04-07 01:16:29 +00:00
initprintf ( " %s:%d: error: expected whitespace between `%c' and `%s'. \n " , g_szScriptFileName , g_lineNumber , tempbuf [ 0 ] , tempbuf + 1 ) ;
2006-04-13 20:47:06 +00:00
}
2008-11-20 14:06:36 +00:00
else C_ReportError ( ERROR_EXPECTEDKEYWORD ) ;
2011-04-07 01:16:29 +00:00
2006-04-13 20:47:06 +00:00
return - 1 ;
}
2012-02-29 15:27:40 +00:00
static int32_t parse_decimal_number ( void ) // (textptr)
{
// decimal constants -- this is finicky business
int64_t num = strtoll ( textptr , NULL , 10 ) ; // assume long long to be int64_t
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_TRUE ( num > = INT32_MIN & & num < = INT32_MAX ) )
2012-02-29 15:27:40 +00:00
{
// all OK
}
2014-10-25 03:36:34 +00:00
else if ( EDUKE32_PREDICT_FALSE ( num > INT32_MAX & & num < = UINT32_MAX ) )
2012-02-29 15:27:40 +00:00
{
// Number interpreted as uint32, but packed as int32 (on 32-bit archs)
// (CON code in the wild exists that does this). Note that such conversion
// is implementation-defined (C99 6.3.1.3) but GCC does the 'expected' thing.
2012-06-06 22:03:35 +00:00
#if 0
2012-02-29 15:27:40 +00:00
initprintf ( " %s:%d: warning: number greater than INT32_MAX converted to a negative one. \n " ,
g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
2012-06-06 22:03:35 +00:00
# endif
2012-02-29 15:27:40 +00:00
}
else
{
// out of range, this is arguably worse
initprintf ( " %s:%d: warning: number out of the range of a 32-bit integer encountered. \n " ,
g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
}
return ( int32_t ) num ;
}
2012-06-10 18:56:27 +00:00
static int32_t parse_hex_constant ( const char * hexnum )
{
int64_t x ;
sscanf ( hexnum , " % " PRIx64 " " , & x ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( x > UINT32_MAX ) )
2012-06-10 18:56:27 +00:00
{
initprintf ( " %s:%d: warning: number 0x% " PRIx64 " truncated to 32 bits. \n " ,
g_szScriptFileName , g_lineNumber , x ) ;
g_numCompilerWarnings + + ;
}
return x ;
}
2009-01-09 09:29:17 +00:00
static void C_GetNextVarType ( int32_t type )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i = 0 , f = 0 ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
C_SkipComments ( ) ;
2010-03-03 01:37:27 +00:00
2008-11-20 14:06:36 +00:00
if ( ! type & & ! g_labelsOnly & & ( isdigit ( * textptr ) | | ( ( * textptr = = ' - ' ) & & ( isdigit ( * ( textptr + 1 ) ) ) ) ) )
2006-04-13 20:47:06 +00:00
{
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2012-02-29 15:27:40 +00:00
* g_scriptPtr + + = MAXGAMEVARS ;
if ( tolower ( textptr [ 1 ] ) = = ' x ' ) // hex constants
2012-06-10 18:56:27 +00:00
* g_scriptPtr = parse_hex_constant ( textptr + 2 ) ;
2008-02-18 08:10:54 +00:00
else
2012-02-29 15:27:40 +00:00
* g_scriptPtr = parse_decimal_number ( ) ;
if ( ! ( g_numCompilerErrors | | g_numCompilerWarnings ) & & g_scriptDebug )
initprintf ( " %s:%d: debug: accepted constant %ld in place of gamevar. \n " ,
g_szScriptFileName , g_lineNumber , ( long ) * g_scriptPtr ) ;
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2008-11-20 14:06:36 +00:00
g_scriptPtr + + ;
2009-01-16 06:11:25 +00:00
# if 1
while ( ! ispecial ( * textptr ) & & * textptr ! = ' ] ' ) textptr + + ;
# else
2008-11-20 14:06:36 +00:00
C_GetNextLabelName ( ) ;
2009-01-16 06:11:25 +00:00
# endif
2006-04-13 20:47:06 +00:00
return ;
}
2008-08-26 08:39:45 +00:00
else if ( ( * textptr = = ' - ' ) /* && !isdigit(*(textptr+1))*/ )
2006-04-13 20:47:06 +00:00
{
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( type ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
C_GetNextLabelName ( ) ;
2006-04-13 20:47:06 +00:00
return ;
}
2010-03-03 01:37:27 +00:00
2014-10-25 03:36:34 +00:00
if ( ! ( g_numCompilerErrors | | g_numCompilerWarnings ) & & g_scriptDebug )
initprintf ( " %s:%d: debug: flagging gamevar as negative. \n " , g_szScriptFileName , g_lineNumber ) ; //,Batol(textptr));
f = ( MAXGAMEVARS < < 1 ) ;
2010-03-03 01:37:27 +00:00
textptr + + ;
2006-04-13 20:47:06 +00:00
}
2012-02-29 15:27:40 +00:00
2008-11-20 14:06:36 +00:00
C_GetNextLabelName ( ) ;
2008-04-01 02:50:44 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ! g_skipKeywordCheck & & hash_find ( & h_keywords , label + ( g_numLabels < < 6 ) ) > = 0 ) )
2008-08-25 00:49:12 +00:00
{
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_ISAKEYWORD ) ;
2008-08-25 00:49:12 +00:00
return ;
}
2008-04-01 02:50:44 +00:00
2008-11-20 14:06:36 +00:00
C_SkipComments ( ) ; //skip comments and whitespace
2008-04-01 02:50:44 +00:00
if ( ( * textptr = = ' [ ' ) ) //read of array as a gamevar
{
2009-01-09 09:29:17 +00:00
int32_t lLabelID = - 1 ;
2009-01-07 14:05:13 +00:00
2008-04-27 06:54:28 +00:00
f | = ( MAXGAMEVARS < < 2 ) ;
2008-04-01 02:50:44 +00:00
textptr + + ;
2008-11-20 14:06:36 +00:00
i = GetADefID ( label + ( g_numLabels < < 6 ) ) ;
2008-04-27 06:54:28 +00:00
if ( i < 0 )
2008-04-01 02:50:44 +00:00
{
2009-01-07 14:05:13 +00:00
i = GetDefID ( label + ( g_numLabels < < 6 ) ) ;
2015-03-25 06:27:42 +00:00
if ( ( unsigned ) ( i - g_iStructVarIDs ) > = NUMQUICKSTRUCTS )
2009-01-07 14:05:13 +00:00
i = - 1 ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i < 0 ) )
2009-01-07 14:05:13 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_NOTAGAMEARRAY ) ;
return ;
}
f & = ~ ( MAXGAMEVARS < < 2 ) ; // not an array
f | = ( MAXGAMEVARS < < 3 ) ;
2008-04-01 02:50:44 +00:00
}
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2008-11-20 14:06:36 +00:00
* g_scriptPtr + + = ( i | f ) ;
2015-03-25 06:27:57 +00:00
if ( ( f & ( MAXGAMEVARS < < 3 ) ) & & i - g_iStructVarIDs = = STRUCT_USERDEF )
{
// userdef doesn't really have an array index
while ( * textptr ! = ' ] ' )
{
if ( * textptr = = 0xa )
break ;
if ( ! * textptr )
break ;
textptr + + ;
}
* g_scriptPtr + + = g_iThisActorID ; // help out the VM by inserting a dummy index
}
else
{
C_GetNextVarType ( 0 ) ;
C_SkipComments ( ) ;
}
2008-04-27 06:54:28 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' ] ' ) )
2008-04-01 02:50:44 +00:00
{
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_GAMEARRAYBNC ) ;
2008-04-01 02:50:44 +00:00
return ;
}
textptr + + ;
2009-01-16 06:11:25 +00:00
//writing arrays in this way is not supported because it would require too many changes to other code
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( type ) )
2008-04-01 02:50:44 +00:00
{
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_INVALIDARRAYWRITE ) ;
2008-04-01 02:50:44 +00:00
return ;
}
2009-01-07 14:05:13 +00:00
if ( f & ( MAXGAMEVARS < < 3 ) )
{
while ( * textptr ! = ' . ' )
{
if ( * textptr = = 0xa )
break ;
if ( ! * textptr )
break ;
textptr + + ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' . ' ) )
2009-01-07 14:05:13 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
return ;
}
textptr + + ;
/// now pointing at 'xxx'
C_GetNextLabelName ( ) ;
2012-03-26 05:05:57 +00:00
/*initprintf("found xxx label of \"%s\"\n", label+(g_numLabels<<6));*/
2009-01-07 14:05:13 +00:00
2015-03-25 06:27:42 +00:00
switch ( i - g_iStructVarIDs )
{
case STRUCT_SPRITE :
2010-05-16 22:53:08 +00:00
lLabelID = C_GetLabelNameOffset ( & actorH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
2015-03-25 06:27:42 +00:00
break ;
case STRUCT_SECTOR :
2010-05-16 22:53:08 +00:00
lLabelID = C_GetLabelNameOffset ( & sectorH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
2015-03-25 06:27:42 +00:00
break ;
case STRUCT_WALL :
2010-05-16 22:53:08 +00:00
lLabelID = C_GetLabelNameOffset ( & wallH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
2015-03-25 06:27:42 +00:00
break ;
case STRUCT_PLAYER :
2010-05-16 22:53:08 +00:00
lLabelID = C_GetLabelNameOffset ( & playerH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
2015-03-25 06:27:42 +00:00
break ;
case STRUCT_ACTORVAR :
2015-03-25 06:27:57 +00:00
case STRUCT_PLAYERVAR :
2009-01-16 06:11:25 +00:00
lLabelID = GetDefID ( label + ( g_numLabels < < 6 ) ) ;
2015-03-25 06:27:42 +00:00
break ;
2015-03-25 06:27:57 +00:00
case STRUCT_TSPR :
lLabelID = C_GetLabelNameOffset ( & tspriteH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
break ;
case STRUCT_PROJECTILE :
case STRUCT_THISPROJECTILE :
lLabelID = C_GetLabelNameOffset ( & projectileH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
break ;
case STRUCT_USERDEF :
lLabelID = C_GetLabelNameOffset ( & userdefH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
break ;
case STRUCT_INPUT :
lLabelID = C_GetLabelNameOffset ( & inputH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
break ;
2015-03-30 05:56:37 +00:00
case STRUCT_TILEDATA :
lLabelID = C_GetLabelNameOffset ( & tiledataH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
break ;
case STRUCT_PALDATA :
lLabelID = C_GetLabelNameOffset ( & paldataH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
break ;
2015-03-25 06:27:42 +00:00
}
2009-01-13 04:40:56 +00:00
2009-01-07 14:05:13 +00:00
//printf("LabelID is %d\n",lLabelID);
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( lLabelID = = - 1 ) )
2009-01-07 14:05:13 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYMBOLNOTRECOGNIZED ) ;
return ;
}
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2009-01-07 14:05:13 +00:00
2015-03-25 06:27:42 +00:00
switch ( i - g_iStructVarIDs )
2009-01-07 14:05:13 +00:00
{
2015-03-25 06:27:42 +00:00
case STRUCT_SPRITE :
2009-01-07 14:05:13 +00:00
* g_scriptPtr + + = ActorLabels [ lLabelID ] . lId ;
//printf("member's flags are: %02Xh\n",ActorLabels[lLabelID].flags);
if ( ActorLabels [ lLabelID ] . flags & LABEL_HASPARM2 )
{
//printf("Member has PARM2\n");
// get parm2
// get the ID of the DEF
C_GetNextVarType ( 0 ) ;
}
2015-03-25 06:27:42 +00:00
break ;
case STRUCT_SECTOR :
2009-01-16 06:11:25 +00:00
* g_scriptPtr + + = SectorLabels [ lLabelID ] . lId ;
2015-03-25 06:27:42 +00:00
break ;
case STRUCT_WALL :
* g_scriptPtr + + = WallLabels [ lLabelID ] . lId ;
break ;
case STRUCT_PLAYER :
2009-01-07 14:05:13 +00:00
* g_scriptPtr + + = PlayerLabels [ lLabelID ] . lId ;
//printf("member's flags are: %02Xh\n",ActorLabels[lLabelID].flags);
if ( PlayerLabels [ lLabelID ] . flags & LABEL_HASPARM2 )
{
//printf("Member has PARM2\n");
// get parm2
// get the ID of the DEF
C_GetNextVarType ( 0 ) ;
}
2015-03-25 06:27:42 +00:00
break ;
case STRUCT_ACTORVAR :
2015-03-25 06:27:57 +00:00
case STRUCT_PLAYERVAR :
2009-01-16 06:11:25 +00:00
* g_scriptPtr + + = lLabelID ;
2015-03-25 06:27:42 +00:00
break ;
2015-03-25 06:27:57 +00:00
case STRUCT_TSPR :
* g_scriptPtr + + = TsprLabels [ lLabelID ] . lId ;
break ;
case STRUCT_PROJECTILE :
case STRUCT_THISPROJECTILE :
* g_scriptPtr + + = ProjectileLabels [ lLabelID ] . lId ;
break ;
case STRUCT_USERDEF :
* g_scriptPtr + + = UserdefsLabels [ lLabelID ] . lId ;
break ;
case STRUCT_INPUT :
* g_scriptPtr + + = InputLabels [ lLabelID ] . lId ;
break ;
2015-03-30 05:56:37 +00:00
case STRUCT_TILEDATA :
* g_scriptPtr + + = TileDataLabels [ lLabelID ] . lId ;
break ;
case STRUCT_PALDATA :
* g_scriptPtr + + = PalDataLabels [ lLabelID ] . lId ;
break ;
2015-03-25 06:27:42 +00:00
}
2009-01-07 14:05:13 +00:00
}
2008-04-01 02:50:44 +00:00
return ;
}
// initprintf("not an array");
2008-11-20 14:06:36 +00:00
i = GetDefID ( label + ( g_numLabels < < 6 ) ) ;
2008-04-01 02:50:44 +00:00
if ( i < 0 ) //gamevar not found
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( ! type & & ! g_labelsOnly )
2006-04-13 20:47:06 +00:00
{
2008-04-01 02:50:44 +00:00
//try looking for a define instead
2008-11-20 14:06:36 +00:00
Bstrcpy ( tempbuf , label + ( g_numLabels < < 6 ) ) ;
2010-05-02 23:27:30 +00:00
i = hash_find ( & h_labels , tempbuf ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_TRUE ( i > = 0 ) )
2006-04-13 20:47:06 +00:00
{
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_TRUE ( labeltype [ i ] & LABEL_DEFINE ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( ! ( g_numCompilerErrors | | g_numCompilerWarnings ) & & g_scriptDebug )
initprintf ( " %s:%d: debug: accepted defined label `%s' instead of gamevar. \n " , g_szScriptFileName , g_lineNumber , label + ( i < < 6 ) ) ;
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2011-12-21 18:40:47 +00:00
* g_scriptPtr + + = MAXGAMEVARS ;
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2011-12-21 18:40:47 +00:00
* g_scriptPtr + + = labelcode [ i ] ;
2006-04-13 20:47:06 +00:00
return ;
}
}
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_NOTAGAMEVAR ) ;
2006-04-13 20:47:06 +00:00
return ;
}
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_NOTAGAMEVAR ) ;
2006-12-23 02:38:47 +00:00
textptr + + ;
return ;
2008-04-01 02:50:44 +00:00
2006-04-13 20:47:06 +00:00
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( type = = GAMEVAR_READONLY & & aGameVars [ i ] . dwFlags & GAMEVAR_READONLY ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_VARREADONLY ) ;
2006-04-13 20:47:06 +00:00
return ;
}
2014-10-25 03:36:34 +00:00
else if ( EDUKE32_PREDICT_FALSE ( aGameVars [ i ] . dwFlags & type ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_VARTYPEMISMATCH ) ;
2006-04-13 20:47:06 +00:00
return ;
}
2011-04-07 01:16:29 +00:00
2008-11-20 14:06:36 +00:00
if ( ! ( g_numCompilerErrors | | g_numCompilerWarnings ) & & g_scriptDebug > 1 )
initprintf ( " %s:%d: debug: accepted gamevar `%s'. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
2008-04-27 06:54:28 +00:00
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2008-11-20 14:06:36 +00:00
* g_scriptPtr + + = ( i | f ) ;
2006-04-13 20:47:06 +00:00
}
2009-01-10 07:38:50 +00:00
# define C_GetNextVar() C_GetNextVarType(0)
2006-04-13 20:47:06 +00:00
2009-01-09 09:29:17 +00:00
static inline void C_GetManyVarsType ( int32_t type , int32_t num )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i ;
2009-02-19 16:47:54 +00:00
for ( i = num - 1 ; i > = 0 ; i - - )
2008-11-20 14:06:36 +00:00
C_GetNextVarType ( type ) ;
2006-04-13 20:47:06 +00:00
}
2009-01-10 07:38:50 +00:00
# define C_GetManyVars(num) C_GetManyVarsType(0,num)
2006-04-13 20:47:06 +00:00
2012-06-17 19:45:46 +00:00
// returns:
// -1 on EOF or wrong type or error
// 0 if literal value
// LABEL_* (>0) if that type and matched
//
// *g_scriptPtr will contain the value OR 0 if wrong type or error
2009-01-09 09:29:17 +00:00
static int32_t C_GetNextValue ( int32_t type )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t i , l ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
C_SkipComments ( ) ;
2006-04-13 20:47:06 +00:00
2009-11-18 01:17:56 +00:00
if ( * textptr = = 0 ) // EOF
return - 1 ;
2006-04-13 20:47:06 +00:00
l = 0 ;
2006-11-14 21:35:50 +00:00
while ( isaltok ( * ( textptr + l ) ) )
2006-04-13 20:47:06 +00:00
{
tempbuf [ l ] = textptr [ l ] ;
l + + ;
}
tempbuf [ l ] = 0 ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ! g_skipKeywordCheck & & hash_find ( & h_keywords , tempbuf /*label+(g_numLabels<<6)*/ ) > = 0 ) )
2008-08-25 00:49:12 +00:00
{
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_ISAKEYWORD ) ;
2008-08-25 00:49:12 +00:00
textptr + = l ;
}
2006-04-28 04:14:45 +00:00
2010-05-02 23:27:30 +00:00
i = hash_find ( & h_labels , tempbuf ) ;
2008-08-25 00:49:12 +00:00
if ( i > = 0 )
2006-04-13 20:47:06 +00:00
{
2008-08-25 00:49:12 +00:00
char * el , * gl ;
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_TRUE ( labeltype [ i ] & type ) )
2008-08-25 00:49:12 +00:00
{
2008-11-20 14:06:36 +00:00
if ( ! ( g_numCompilerErrors | | g_numCompilerWarnings ) & & g_scriptDebug > 1 )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
gl = ( char * ) C_GetLabelType ( labeltype [ i ] ) ;
initprintf ( " %s:%d: debug: accepted %s label `%s'. \n " , g_szScriptFileName , g_lineNumber , gl , label + ( i < < 6 ) ) ;
2008-08-25 00:49:12 +00:00
Bfree ( gl ) ;
2006-04-13 20:47:06 +00:00
}
2012-03-11 17:37:50 +00:00
2011-12-21 18:40:47 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* ( g_scriptPtr + + ) = labelcode [ i ] ;
2012-03-11 17:37:50 +00:00
2006-04-13 20:47:06 +00:00
textptr + = l ;
2008-08-25 00:49:12 +00:00
return labeltype [ i ] ;
2006-04-13 20:47:06 +00:00
}
2014-10-25 03:36:34 +00:00
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2008-11-20 14:06:36 +00:00
* ( g_scriptPtr + + ) = 0 ;
2008-08-25 00:49:12 +00:00
textptr + = l ;
2008-11-20 14:06:36 +00:00
el = ( char * ) C_GetLabelType ( type ) ;
gl = ( char * ) C_GetLabelType ( labeltype [ i ] ) ;
C_ReportError ( - 1 ) ;
2009-01-10 07:38:50 +00:00
initprintf ( " %s:%d: warning: expected %s, found %s. \n " , g_szScriptFileName , g_lineNumber , el , gl ) ;
2008-11-20 14:06:36 +00:00
g_numCompilerWarnings + + ;
2008-08-25 00:49:12 +00:00
Bfree ( el ) ;
Bfree ( gl ) ;
return - 1 ; // valid label name, but wrong type
2006-04-13 20:47:06 +00:00
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( isdigit ( * textptr ) = = 0 & & * textptr ! = ' - ' ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
C_ReportError ( ERROR_PARAMUNDEFINED ) ;
g_numCompilerErrors + + ;
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2008-11-20 14:06:36 +00:00
* g_scriptPtr = 0 ;
g_scriptPtr + + ;
2006-04-13 20:47:06 +00:00
textptr + = l ;
return - 1 ; // error!
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( isdigit ( * textptr ) & & g_labelsOnly ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
C_ReportError ( WARNING_LABELSONLY ) ;
g_numCompilerWarnings + + ;
2006-04-13 20:47:06 +00:00
}
2008-12-21 22:46:55 +00:00
i = l - 1 ;
do
{
2009-01-13 04:40:56 +00:00
// FIXME: check for 0-9 A-F for hex
2009-01-02 01:03:41 +00:00
if ( textptr [ 0 ] = = ' 0 ' & & textptr [ 1 ] = = ' x ' ) break ; // kill the warning for hex
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ! isdigit ( textptr [ i - - ] ) ) )
2008-12-21 22:46:55 +00:00
{
C_ReportError ( - 1 ) ;
2009-01-10 07:38:50 +00:00
initprintf ( " %s:%d: warning: invalid character `%c' in definition! \n " , g_szScriptFileName , g_lineNumber , textptr [ i + 1 ] ) ;
2008-12-21 22:46:55 +00:00
g_numCompilerWarnings + + ;
break ;
}
}
while ( i > 0 ) ;
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2008-12-21 22:46:55 +00:00
if ( tolower ( textptr [ 1 ] ) = = ' x ' )
2012-06-10 18:56:27 +00:00
* g_scriptPtr = parse_hex_constant ( textptr + 2 ) ;
2008-02-18 08:10:54 +00:00
else
2012-02-29 15:27:40 +00:00
* g_scriptPtr = parse_decimal_number ( ) ;
if ( ! ( g_numCompilerErrors | | g_numCompilerWarnings ) & & g_scriptDebug > 1 )
initprintf ( " %s:%d: debug: accepted constant %ld. \n " ,
g_szScriptFileName , g_lineNumber , ( long ) * g_scriptPtr ) ;
2008-12-21 22:46:55 +00:00
2008-11-20 14:06:36 +00:00
g_scriptPtr + + ;
2006-04-13 20:47:06 +00:00
textptr + = l ;
return 0 ; // literal value
}
2009-06-19 01:10:10 +00:00
static inline int32_t C_IntPow2 ( int32_t v )
{
2009-06-24 08:20:10 +00:00
return ( ( v ! = 0 ) & & ( v & ( v - 1 ) ) = = 0 ) ;
2009-06-19 01:10:10 +00:00
}
static inline uint32_t C_Pow2IntLogBase2 ( int32_t v )
{
2009-06-24 08:20:10 +00:00
static const uint32_t b [ ] = { 0xAAAAAAAA , 0xCCCCCCCC , 0xF0F0F0F0 ,
0xFF00FF00 , 0xFFFF0000
} ;
register uint32_t r = ( v & b [ 0 ] ) ! = 0 ;
int32_t i = 4 ;
for ( ; i > 0 ; i - - )
r | = ( ( v & b [ i ] ) ! = 0 ) < < i ;
return r ;
2009-06-19 01:10:10 +00:00
}
2009-06-18 05:57:10 +00:00
static int32_t C_CheckMalformedBranch ( intptr_t lastScriptPtr )
{
switch ( C_GetKeyword ( ) )
{
case CON_RIGHTBRACE :
case CON_ENDA :
case CON_ENDEVENT :
case CON_ENDS :
2009-06-19 01:10:10 +00:00
case CON_ELSE :
2009-06-18 05:57:10 +00:00
g_scriptPtr = lastScriptPtr + & script [ 0 ] ;
g_ifElseAborted = 1 ;
C_ReportError ( - 1 ) ;
g_numCompilerWarnings + + ;
initprintf ( " %s:%d: warning: malformed `%s' branch \n " , g_szScriptFileName , g_lineNumber ,
2009-06-24 08:20:10 +00:00
keyw [ * ( g_scriptPtr ) & 0xFFF ] ) ;
2009-06-18 05:57:10 +00:00
return 1 ;
}
return 0 ;
}
2009-01-09 09:29:17 +00:00
static int32_t C_CheckEmptyBranch ( int32_t tw , intptr_t lastScriptPtr )
2009-01-04 22:22:33 +00:00
{
2011-12-04 18:10:06 +00:00
// ifrnd and the others actually do something when the condition is executed
2009-01-06 00:00:11 +00:00
if ( ( Bstrncmp ( keyw [ tw ] , " if " , 2 ) & & tw ! = CON_ELSE ) | |
2011-12-04 18:10:06 +00:00
tw = = CON_IFRND | | tw = = CON_IFHITWEAPON | | tw = = CON_IFCANSEE | | tw = = CON_IFCANSEETARGET | |
tw = = CON_IFPDISTL | | tw = = CON_IFPDISTG | | tw = = CON_IFGOTWEAPONCE )
2009-01-04 22:22:33 +00:00
{
g_ifElseAborted = 0 ;
return 0 ;
}
2009-01-05 14:43:12 +00:00
if ( ( * ( g_scriptPtr ) & 0xFFF ) ! = CON_NULLOP | | * ( g_scriptPtr ) > > 12 ! = IFELSE_MAGIC )
2009-01-04 22:22:33 +00:00
g_ifElseAborted = 0 ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_ifElseAborted ) )
2009-01-04 22:22:33 +00:00
{
2009-01-05 14:43:12 +00:00
C_ReportError ( - 1 ) ;
g_numCompilerWarnings + + ;
2009-01-04 22:22:33 +00:00
g_scriptPtr = lastScriptPtr + & script [ 0 ] ;
2009-01-05 14:43:12 +00:00
initprintf ( " %s:%d: warning: empty `%s' branch \n " , g_szScriptFileName , g_lineNumber ,
2009-01-04 22:22:33 +00:00
keyw [ * ( g_scriptPtr ) & 0xFFF ] ) ;
2009-06-18 05:57:10 +00:00
* ( g_scriptPtr ) = ( CON_NULLOP + ( IFELSE_MAGIC < < 12 ) ) ;
2009-01-04 22:22:33 +00:00
return 1 ;
}
return 0 ;
}
2009-01-09 09:29:17 +00:00
static int32_t C_CountCaseStatements ( )
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
int32_t lCount ;
2006-12-23 02:38:47 +00:00
char * temptextptr = textptr ;
2009-01-09 09:29:17 +00:00
int32_t temp_ScriptLineNumber = g_lineNumber ;
2008-11-20 14:06:36 +00:00
intptr_t scriptoffset = ( unsigned ) ( g_scriptPtr - script ) ;
intptr_t caseoffset = ( unsigned ) ( g_caseScriptPtr - script ) ;
2009-01-09 09:29:17 +00:00
// int32_t i;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
g_numCases = 0 ;
g_caseScriptPtr = NULL ;
2006-04-13 20:47:06 +00:00
//Bsprintf(g_szBuf,"CSS: %.12s",textptr);
//AddLog(g_szBuf);
2011-05-20 02:34:41 +00:00
C_ParseCommand ( 1 ) ;
2008-11-20 14:06:36 +00:00
// since we processed the endswitch, we need to re-increment g_checkingSwitch
g_checkingSwitch + + ;
2006-04-13 20:47:06 +00:00
textptr = temptextptr ;
2008-11-20 14:06:36 +00:00
g_scriptPtr = ( intptr_t * ) ( script + scriptoffset ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
g_lineNumber = temp_ScriptLineNumber ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
lCount = g_numCases ;
g_numCases = 0 ;
g_caseScriptPtr = ( intptr_t * ) ( script + caseoffset ) ;
g_numCases = 0 ;
2006-04-13 20:47:06 +00:00
return lCount ;
}
2011-07-21 22:39:29 +00:00
static void C_Include ( const char * confile )
{
int32_t temp_ScriptLineNumber ;
int32_t temp_ifelse_check ;
int32_t j ;
char * origtptr , * mptr ;
char parentScriptFileName [ 255 ] ;
int32_t fp ;
fp = kopen4loadfrommod ( confile , g_loadFromGroupOnly ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( fp < 0 ) )
2011-07-21 22:39:29 +00:00
{
g_numCompilerErrors + + ;
initprintf ( " %s:%d: error: could not find file `%s'. \n " , g_szScriptFileName , g_lineNumber , confile ) ;
return ;
}
j = kfilelength ( fp ) ;
2014-05-30 00:02:19 +00:00
mptr = ( char * ) Xmalloc ( j + 1 ) ;
2011-07-21 22:39:29 +00:00
initprintf ( " Including: %s (%d bytes) \n " , confile , j ) ;
kread ( fp , mptr , j ) ;
kclose ( fp ) ;
mptr [ j ] = 0 ;
if ( * textptr = = ' " ' ) // skip past the closing quote if it's there so we don't screw up the next line
textptr + + ;
origtptr = textptr ;
Bstrcpy ( parentScriptFileName , g_szScriptFileName ) ;
Bstrcpy ( g_szScriptFileName , confile ) ;
temp_ScriptLineNumber = g_lineNumber ;
g_lineNumber = 1 ;
temp_ifelse_check = g_checkingIfElse ;
g_checkingIfElse = 0 ;
textptr = mptr ;
C_SkipComments ( ) ;
C_ParseCommand ( 1 ) ;
Bstrcpy ( g_szScriptFileName , parentScriptFileName ) ;
g_totalLines + = g_lineNumber ;
g_lineNumber = temp_ScriptLineNumber ;
g_checkingIfElse = temp_ifelse_check ;
textptr = origtptr ;
Bfree ( mptr ) ;
}
2013-01-19 18:29:00 +00:00
# endif // !defined LUNATIC
2011-07-21 22:39:29 +00:00
2012-05-28 18:15:26 +00:00
# ifdef _WIN32
static void check_filename_case ( const char * fn )
{
int32_t fp ;
if ( ( fp = kopen4loadfrommod ( fn , g_loadFromGroupOnly ) ) > = 0 )
kclose ( fp ) ;
}
# else
static void check_filename_case ( const char * fn ) { UNREFERENCED_PARAMETER ( fn ) ; }
# endif
2012-12-29 15:21:24 +00:00
void G_DoGameStartup ( const int32_t * params )
{
int32_t j = 0 ;
ud . const_visibility = params [ j + + ] ;
g_impactDamage = params [ j + + ] ;
g_maxPlayerHealth = g_player [ 0 ] . ps - > max_player_health = g_player [ 0 ] . ps - > max_shield_amount = params [ j + + ] ;
g_startArmorAmount = params [ j + + ] ;
g_actorRespawnTime = params [ j + + ] ;
2013-05-23 18:28:04 +00:00
if ( g_scriptVersion > = 11 )
g_itemRespawnTime = params [ j + + ] ;
else
g_itemRespawnTime = g_actorRespawnTime ;
if ( g_scriptVersion > = 11 )
g_playerFriction = params [ j + + ] ;
if ( g_scriptVersion = = 14 )
g_spriteGravity = params [ j + + ] ;
if ( g_scriptVersion > = 11 )
{
g_rpgBlastRadius = params [ j + + ] ;
g_pipebombBlastRadius = params [ j + + ] ;
g_shrinkerBlastRadius = params [ j + + ] ;
g_tripbombBlastRadius = params [ j + + ] ;
g_morterBlastRadius = params [ j + + ] ;
g_bouncemineBlastRadius = params [ j + + ] ;
g_seenineBlastRadius = params [ j + + ] ;
}
2012-12-29 15:21:24 +00:00
g_player [ 0 ] . ps - > max_ammo_amount [ PISTOL_WEAPON ] = params [ j + + ] ;
g_player [ 0 ] . ps - > max_ammo_amount [ SHOTGUN_WEAPON ] = params [ j + + ] ;
g_player [ 0 ] . ps - > max_ammo_amount [ CHAINGUN_WEAPON ] = params [ j + + ] ;
g_player [ 0 ] . ps - > max_ammo_amount [ RPG_WEAPON ] = params [ j + + ] ;
g_player [ 0 ] . ps - > max_ammo_amount [ HANDBOMB_WEAPON ] = params [ j + + ] ;
g_player [ 0 ] . ps - > max_ammo_amount [ SHRINKER_WEAPON ] = params [ j + + ] ;
g_player [ 0 ] . ps - > max_ammo_amount [ DEVISTATOR_WEAPON ] = params [ j + + ] ;
g_player [ 0 ] . ps - > max_ammo_amount [ TRIPBOMB_WEAPON ] = params [ j + + ] ;
2013-05-23 18:28:04 +00:00
if ( g_scriptVersion > = 13 )
2012-12-29 15:21:24 +00:00
{
2013-05-23 18:28:04 +00:00
g_player [ 0 ] . ps - > max_ammo_amount [ FREEZE_WEAPON ] = params [ j + + ] ;
if ( g_scriptVersion = = 14 )
g_player [ 0 ] . ps - > max_ammo_amount [ GROW_WEAPON ] = params [ j + + ] ;
g_damageCameras = params [ j + + ] ;
g_numFreezeBounces = params [ j + + ] ;
g_freezerSelfDamage = params [ j + + ] ;
if ( g_scriptVersion = = 14 )
{
g_spriteDeleteQueueSize = params [ j + + ] ;
g_spriteDeleteQueueSize = clamp ( g_spriteDeleteQueueSize , 0 , 1024 ) ;
2012-12-29 15:21:24 +00:00
2013-05-23 18:28:04 +00:00
g_tripbombLaserMode = params [ j + + ] ;
}
2012-12-29 15:21:24 +00:00
}
}
2014-09-07 18:10:12 +00:00
void C_DefineMusic ( int32_t vol , int32_t lev , const char * fn )
{
2014-09-07 18:10:14 +00:00
Bassert ( ( unsigned ) vol < MAXVOLUMES + 1 ) ;
Bassert ( ( unsigned ) lev < MAXLEVELS ) ;
2014-09-07 18:10:12 +00:00
{
2014-09-07 18:10:14 +00:00
map_t * const map = & MapInfo [ ( MAXLEVELS * vol ) + lev ] ;
2014-09-07 18:10:12 +00:00
2014-09-07 18:10:14 +00:00
Bfree ( map - > musicfn ) ;
map - > musicfn = dup_filename ( fn ) ;
check_filename_case ( map - > musicfn ) ;
2014-09-07 18:10:12 +00:00
}
}
2013-01-01 15:24:22 +00:00
# ifdef LUNATIC
void C_DefineSound ( int32_t sndidx , const char * fn , int32_t args [ 5 ] )
{
Bassert ( ( unsigned ) sndidx < MAXSOUNDS ) ;
{
sound_t * const snd = & g_sounds [ sndidx ] ;
Bfree ( snd - > filename ) ;
snd - > filename = dup_filename ( fn ) ;
check_filename_case ( snd - > filename ) ;
snd - > ps = args [ 0 ] ;
snd - > pe = args [ 1 ] ;
snd - > pr = args [ 2 ] ;
2013-09-21 13:38:07 +00:00
snd - > m = args [ 3 ] & ~ SF_ONEINST_INTERNAL ;
if ( args [ 3 ] & SF_LOOP )
snd - > m | = SF_ONEINST_INTERNAL ;
2013-01-01 15:24:22 +00:00
snd - > vo = args [ 4 ] ;
if ( sndidx > g_maxSoundPos )
g_maxSoundPos = sndidx ;
}
}
2013-01-01 15:24:28 +00:00
void C_DefineQuote ( int32_t qnum , const char * qstr )
{
C_AllocQuote ( qnum ) ;
Bstrncpyz ( ScriptQuotes [ qnum ] , qstr , MAXQUOTELEN ) ;
}
2013-01-05 13:09:19 +00:00
void C_DefineVolumeName ( int32_t vol , const char * name )
{
Bassert ( ( unsigned ) vol < MAXVOLUMES ) ;
Bstrncpyz ( EpisodeNames [ vol ] , name , sizeof ( EpisodeNames [ vol ] ) ) ;
g_numVolumes = max ( g_numVolumes , vol + 1 ) ;
}
2013-01-05 13:09:31 +00:00
void C_DefineSkillName ( int32_t skill , const char * name )
{
Bassert ( ( unsigned ) skill < MAXSKILLS ) ;
Bstrncpyz ( SkillNames [ skill ] , name , sizeof ( SkillNames [ skill ] ) ) ;
g_numSkills = max ( g_numSkills , skill + 1 ) ;
}
2013-01-05 13:09:19 +00:00
void C_DefineLevelName ( int32_t vol , int32_t lev , const char * fn ,
int32_t partime , int32_t designertime ,
const char * levelname )
{
Bassert ( ( unsigned ) vol < MAXVOLUMES ) ;
Bassert ( ( unsigned ) lev < MAXLEVELS ) ;
{
map_t * const map = & MapInfo [ ( MAXLEVELS * vol ) + lev ] ;
Bfree ( map - > filename ) ;
map - > filename = dup_filename ( fn ) ;
// TODO: truncate to 32 chars?
Bfree ( map - > name ) ;
2014-05-30 00:02:19 +00:00
map - > name = Xstrdup ( levelname ) ;
2013-01-05 13:09:19 +00:00
map - > partime = REALGAMETICSPERSEC * partime ;
map - > designertime = REALGAMETICSPERSEC * designertime ;
}
}
2013-02-24 16:05:22 +00:00
void C_DefineGameFuncName ( int32_t idx , const char * name )
{
2013-05-30 18:10:49 +00:00
assert ( ( unsigned ) idx < NUMGAMEFUNCTIONS ) ;
2013-02-24 16:05:22 +00:00
Bstrncpyz ( gamefunctions [ idx ] , name , MAXGAMEFUNCLEN ) ;
Bstrncpyz ( keydefaults [ 3 * idx ] , name , MAXGAMEFUNCLEN ) ;
2013-02-28 17:30:04 +00:00
hash_add ( & h_gamefuncs , gamefunctions [ idx ] , idx , 0 ) ;
2013-02-24 16:05:22 +00:00
}
2013-05-30 18:10:49 +00:00
void C_DefineGameType ( int32_t idx , int32_t flags , const char * name )
{
Bassert ( ( unsigned ) idx < MAXGAMETYPES ) ;
GametypeFlags [ idx ] = flags ;
Bstrncpyz ( GametypeNames [ idx ] , name , sizeof ( GametypeNames [ idx ] ) ) ;
g_numGametypes = idx + 1 ;
}
2013-01-01 15:24:22 +00:00
# endif
2015-02-22 22:15:20 +00:00
void C_DefineVolumeFlags ( int32_t vol , int32_t flags )
{
Bassert ( ( unsigned ) vol < MAXVOLUMES ) ;
EpisodeFlags [ vol ] = flags ;
}
2015-02-09 05:50:33 +00:00
void C_UndefineVolume ( int32_t vol )
{
Bassert ( ( unsigned ) vol < MAXVOLUMES ) ;
2015-02-22 22:14:54 +00:00
for ( int32_t i = 0 ; i < MAXLEVELS ; i + + )
C_UndefineLevel ( vol , i ) ;
2015-02-09 05:50:33 +00:00
EpisodeNames [ vol ] [ 0 ] = ' \0 ' ;
g_numVolumes = 0 ;
for ( int32_t i = MAXVOLUMES - 1 ; i > = 0 ; i - - )
{
if ( EpisodeNames [ i ] [ 0 ] )
{
g_numVolumes = i + 1 ;
break ;
}
}
}
void C_UndefineSkill ( int32_t skill )
{
Bassert ( ( unsigned ) skill < MAXSKILLS ) ;
SkillNames [ skill ] [ 0 ] = ' \0 ' ;
g_numSkills = 0 ;
for ( int32_t i = MAXSKILLS - 1 ; i > = 0 ; i - - )
{
if ( SkillNames [ i ] [ 0 ] )
{
g_numSkills = i + 1 ;
break ;
}
}
}
void C_UndefineLevel ( int32_t vol , int32_t lev )
{
Bassert ( ( unsigned ) vol < MAXVOLUMES ) ;
Bassert ( ( unsigned ) lev < MAXLEVELS ) ;
{
map_t * const map = & MapInfo [ ( MAXLEVELS * vol ) + lev ] ;
2015-02-22 22:14:54 +00:00
if ( map - > filename )
Bfree ( map - > filename ) ;
2015-02-09 05:50:33 +00:00
map - > filename = NULL ;
2015-02-22 22:14:54 +00:00
if ( map - > name )
Bfree ( map - > name ) ;
2015-02-09 05:50:33 +00:00
map - > name = NULL ;
map - > partime = 0 ;
map - > designertime = 0 ;
}
}
2013-04-05 17:53:18 +00:00
LUNATIC_EXTERN int32_t C_SetDefName ( const char * name )
2013-02-24 16:05:22 +00:00
{
clearDefNamePtr ( ) ;
g_defNamePtr = dup_filename ( name ) ;
if ( g_defNamePtr )
initprintf ( " Using DEF file: %s. \n " , g_defNamePtr ) ;
return ( g_defNamePtr = = NULL ) ;
}
2015-03-24 00:40:55 +00:00
defaultprojectile_t DefaultProjectile ;
int32_t g_numProjectiles = 0 ;
EDUKE32_STATIC_ASSERT ( sizeof ( projectile_t ) = = sizeof ( DefaultProjectile ) ) ;
2015-05-16 11:56:49 +00:00
void C_AllocProjectile ( int32_t j )
{
g_tile [ j ] . proj = ( projectile_t * ) Xmalloc ( 2 * sizeof ( projectile_t ) ) ;
g_tile [ j ] . defproj = g_tile [ j ] . proj + 1 ;
}
void C_FreeProjectile ( int32_t j )
{
Bfree ( g_tile [ j ] . proj ) ;
g_tile [ j ] . proj = g_tile [ j ] . defproj = NULL ;
}
2013-04-05 17:53:18 +00:00
LUNATIC_EXTERN void C_DefineProjectile ( int32_t j , int32_t what , int32_t val )
2013-02-07 21:01:03 +00:00
{
2015-03-24 00:40:55 +00:00
if ( g_tile [ j ] . proj = = NULL )
{
2015-05-16 11:56:49 +00:00
C_AllocProjectile ( j ) ;
* g_tile [ j ] . proj = DefaultProjectile ;
2015-03-24 00:40:55 +00:00
g_numProjectiles + = 2 ;
}
projectile_t * const proj = g_tile [ j ] . proj ;
2013-02-07 21:01:03 +00:00
switch ( what )
{
case PROJ_WORKSLIKE :
2015-03-24 00:40:55 +00:00
proj - > workslike = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_SPAWNS :
2015-03-24 00:40:55 +00:00
proj - > spawns = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_SXREPEAT :
2015-03-24 00:40:55 +00:00
proj - > sxrepeat = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_SYREPEAT :
2015-03-24 00:40:55 +00:00
proj - > syrepeat = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_SOUND :
2015-03-24 00:40:55 +00:00
proj - > sound = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_ISOUND :
2015-03-24 00:40:55 +00:00
proj - > isound = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_VEL :
2015-03-24 00:40:55 +00:00
proj - > vel = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_EXTRA :
2015-03-24 00:40:55 +00:00
proj - > extra = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_DECAL :
2015-03-24 00:40:55 +00:00
proj - > decal = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_TRAIL :
2015-03-24 00:40:55 +00:00
proj - > trail = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_TXREPEAT :
2015-03-24 00:40:55 +00:00
proj - > txrepeat = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_TYREPEAT :
2015-03-24 00:40:55 +00:00
proj - > tyrepeat = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_TOFFSET :
2015-03-24 00:40:55 +00:00
proj - > toffset = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_TNUM :
2015-03-24 00:40:55 +00:00
proj - > tnum = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_DROP :
2015-03-24 00:40:55 +00:00
proj - > drop = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_CSTAT :
2015-03-24 00:40:55 +00:00
proj - > cstat = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_CLIPDIST :
2015-03-24 00:40:55 +00:00
proj - > clipdist = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_SHADE :
2015-03-24 00:40:55 +00:00
proj - > shade = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_XREPEAT :
2015-03-24 00:40:55 +00:00
proj - > xrepeat = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_YREPEAT :
2015-03-24 00:40:55 +00:00
proj - > yrepeat = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_PAL :
2015-03-24 00:40:55 +00:00
proj - > pal = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_EXTRA_RAND :
2015-03-24 00:40:55 +00:00
proj - > extra_rand = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_HITRADIUS :
2015-03-24 00:40:55 +00:00
proj - > hitradius = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_MOVECNT :
2015-03-24 00:40:55 +00:00
proj - > movecnt = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_OFFSET :
2015-03-24 00:40:55 +00:00
proj - > offset = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_BOUNCES :
2015-03-24 00:40:55 +00:00
proj - > bounces = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_BSOUND :
2015-03-24 00:40:55 +00:00
proj - > bsound = val ; break ;
2013-02-07 21:01:03 +00:00
case PROJ_RANGE :
2015-03-24 00:40:55 +00:00
proj - > range = val ; break ;
2014-07-06 22:36:34 +00:00
case PROJ_FLASH_COLOR :
2015-03-24 00:40:55 +00:00
proj - > flashcolor = val ; break ;
2013-06-09 16:37:18 +00:00
case PROJ_USERDATA :
2015-03-24 00:40:55 +00:00
proj - > userdata = val ; break ;
2013-02-07 21:01:03 +00:00
default : break ;
}
2015-03-24 00:40:55 +00:00
* g_tile [ j ] . defproj = * proj ;
2014-02-22 19:38:52 +00:00
g_tile [ j ] . flags | = SFLAG_PROJECTILE ;
2013-02-07 21:01:03 +00:00
}
2013-01-01 15:24:25 +00:00
int32_t C_AllocQuote ( int32_t qnum )
{
2014-03-22 17:02:21 +00:00
Bassert ( ( unsigned ) qnum < MAXQUOTES ) ;
2013-01-01 15:24:25 +00:00
if ( ScriptQuotes [ qnum ] = = NULL )
{
2014-05-30 00:02:19 +00:00
ScriptQuotes [ qnum ] = ( char * ) Xcalloc ( MAXQUOTELEN , sizeof ( uint8_t ) ) ;
2013-01-01 15:24:25 +00:00
return 1 ;
}
return 0 ;
}
2015-03-23 06:28:40 +00:00
static void C_ReplaceQuoteSubstring ( const size_t q , char const * const query , char const * const replacement )
{
size_t querylength = Bstrlen ( query ) ;
for ( int i = MAXQUOTELEN - querylength - 2 ; i > = 0 ; i - - )
if ( Bstrncmp ( & ScriptQuotes [ q ] [ i ] , query , querylength ) = = 0 )
{
Bmemset ( tempbuf , 0 , sizeof ( tempbuf ) ) ;
Bstrncpy ( tempbuf , ScriptQuotes [ q ] , i ) ;
Bstrcat ( tempbuf , replacement ) ;
Bstrcat ( tempbuf , & ScriptQuotes [ q ] [ i + querylength ] ) ;
Bstrncpy ( ScriptQuotes [ q ] , tempbuf , MAXQUOTELEN - 1 ) ;
i = MAXQUOTELEN - querylength - 2 ;
}
}
2013-01-01 15:24:25 +00:00
void C_InitQuotes ( void )
{
2015-01-11 04:56:10 +00:00
for ( int i = 0 ; i < 128 ; i + + ) C_AllocQuote ( i ) ;
2013-01-01 15:24:25 +00:00
2015-02-11 05:22:41 +00:00
# ifdef EDUKE32_TOUCH_DEVICES
ScriptQuotes [ QUOTE_DEAD ] = 0 ;
2015-01-11 04:56:10 +00:00
# else
2015-03-23 06:28:40 +00:00
char const * const replacement_USE = " USE " ;
if ( ! Bstrstr ( ScriptQuotes [ QUOTE_DEAD ] , replacement_USE ) )
{
C_ReplaceQuoteSubstring ( QUOTE_DEAD , " SPACE " , replacement_USE ) ;
C_ReplaceQuoteSubstring ( QUOTE_DEAD , " OPEN " , replacement_USE ) ;
C_ReplaceQuoteSubstring ( QUOTE_DEAD , " ANY BUTTON " , replacement_USE ) ;
}
2015-01-11 04:56:10 +00:00
# endif
2013-01-01 15:24:25 +00:00
// most of these are based on Blood, obviously
2015-01-11 04:56:10 +00:00
const char * PlayerObituaries [ ] =
2013-01-01 15:24:25 +00:00
{
2015-01-11 04:56:10 +00:00
" ^02%s^02 beat %s^02 like a cur " ,
" ^02%s^02 broke %s " ,
" ^02%s^02 body bagged %s " ,
" ^02%s^02 boned %s^02 like a fish " ,
" ^02%s^02 castrated %s " ,
" ^02%s^02 creamed %s " ,
" ^02%s^02 crushed %s " ,
" ^02%s^02 destroyed %s " ,
" ^02%s^02 diced %s " ,
" ^02%s^02 disemboweled %s " ,
" ^02%s^02 erased %s " ,
" ^02%s^02 eviscerated %s " ,
" ^02%s^02 flailed %s " ,
" ^02%s^02 flattened %s " ,
" ^02%s^02 gave AnAl MaDnEsS to %s " ,
" ^02%s^02 gave %s^02 Anal Justice " ,
" ^02%s^02 hosed %s " ,
" ^02%s^02 hurt %s^02 real bad " ,
" ^02%s^02 killed %s " ,
" ^02%s^02 made dog meat out of %s " ,
" ^02%s^02 made mincemeat out of %s " ,
" ^02%s^02 manhandled %s " ,
" ^02%s^02 massacred %s " ,
" ^02%s^02 mutilated %s " ,
" ^02%s^02 murdered %s " ,
" ^02%s^02 neutered %s " ,
" ^02%s^02 punted %s " ,
" ^02%s^02 reamed %s " ,
" ^02%s^02 ripped %s^02 a new orifice " ,
" ^02%s^02 rocked %s " ,
" ^02%s^02 sent %s^02 to hell " ,
" ^02%s^02 shredded %s " ,
" ^02%s^02 slashed %s " ,
" ^02%s^02 slaughtered %s " ,
" ^02%s^02 sliced %s " ,
" ^02%s^02 smacked %s around " ,
" ^02%s^02 smashed %s " ,
" ^02%s^02 snuffed %s " ,
" ^02%s^02 sodomized %s " ,
" ^02%s^02 splattered %s " ,
" ^02%s^02 sprayed %s " ,
" ^02%s^02 squashed %s " ,
" ^02%s^02 throttled %s " ,
" ^02%s^02 toasted %s " ,
" ^02%s^02 vented %s " ,
" ^02%s^02 ventilated %s " ,
" ^02%s^02 wasted %s " ,
" ^02%s^02 wrecked %s " ,
} ;
2013-01-01 15:24:25 +00:00
2015-01-11 04:56:10 +00:00
const char * PlayerSelfObituaries [ ] =
{
" ^02%s^02 is excrement " ,
" ^02%s^02 is hamburger " ,
" ^02%s^02 suffered scrotum separation " ,
" ^02%s^02 volunteered for population control " ,
" ^02%s^02 has suicided " ,
" ^02%s^02 bled out " ,
} ;
EDUKE32_STATIC_ASSERT ( OBITQUOTEINDEX + ARRAY_SIZE ( PlayerObituaries ) - 1 < MAXQUOTES ) ;
EDUKE32_STATIC_ASSERT ( SUICIDEQUOTEINDEX + ARRAY_SIZE ( PlayerSelfObituaries ) - 1 < MAXQUOTES ) ;
g_numObituaries = ARRAY_SIZE ( PlayerObituaries ) ;
for ( int i = g_numObituaries - 1 ; i > = 0 ; i - - )
{
if ( C_AllocQuote ( i + OBITQUOTEINDEX ) )
Bstrcpy ( ScriptQuotes [ i + OBITQUOTEINDEX ] , PlayerObituaries [ i ] ) ;
}
g_numSelfObituaries = ARRAY_SIZE ( PlayerSelfObituaries ) ;
for ( int i = g_numSelfObituaries - 1 ; i > = 0 ; i - - )
{
if ( C_AllocQuote ( i + SUICIDEQUOTEINDEX ) )
Bstrcpy ( ScriptQuotes [ i + SUICIDEQUOTEINDEX ] , PlayerSelfObituaries [ i ] ) ;
2013-01-01 15:24:25 +00:00
}
}
2013-11-08 18:08:45 +00:00
LUNATIC_EXTERN void C_SetCfgName ( const char * cfgname )
{
char temp [ BMAX_PATH ] ;
struct Bstat st ;
2013-11-08 18:08:47 +00:00
2013-11-08 18:08:45 +00:00
int32_t fullscreen = ud . config . ScreenMode ;
int32_t xdim = ud . config . ScreenWidth , ydim = ud . config . ScreenHeight , bpp = ud . config . ScreenBPP ;
int32_t usemouse = ud . config . UseMouse , usejoy = ud . config . UseJoystick ;
# ifdef USE_OPENGL
int32_t glrm = glrendmode ;
# endif
if ( Bstrcmp ( setupfilename , SETUPFILENAME ) ! = 0 ) // set to something else via -cfg
return ;
if ( Bstat ( g_modDir , & st ) < 0 )
{
if ( errno = = ENOENT ) // path doesn't exist
{
if ( Bmkdir ( g_modDir , S_IRWXU ) < 0 )
{
OSD_Printf ( " Failed to create configuration file directory %s \n " , g_modDir ) ;
return ;
}
else OSD_Printf ( " Created configuration file directory %s \n " , g_modDir ) ;
}
else
{
// another type of failure
return ;
}
}
else if ( ( st . st_mode & S_IFDIR ) ! = S_IFDIR )
{
// directory isn't a directory
return ;
}
2013-11-08 18:08:47 +00:00
// XXX: Back up 'cfgname' as it may be the global 'tempbuf'.
Bstrncpyz ( temp , cfgname , sizeof ( temp ) ) ;
2013-11-08 18:08:45 +00:00
CONFIG_WriteSetup ( 1 ) ;
2013-11-08 18:08:47 +00:00
2013-11-08 18:08:45 +00:00
if ( g_modDir [ 0 ] ! = ' / ' )
2013-11-08 18:08:47 +00:00
Bsnprintf ( setupfilename , sizeof ( setupfilename ) , " %s/%s " , g_modDir , temp ) ;
else
Bstrncpyz ( setupfilename , temp , sizeof ( setupfilename ) ) ;
2013-11-08 18:08:45 +00:00
2013-11-08 18:08:47 +00:00
initprintf ( " Using config file \" %s \" . \n " , setupfilename ) ;
2013-11-08 18:08:45 +00:00
CONFIG_ReadSetup ( ) ;
ud . config . ScreenMode = fullscreen ;
ud . config . ScreenWidth = xdim ;
ud . config . ScreenHeight = ydim ;
ud . config . ScreenBPP = bpp ;
ud . config . UseMouse = usemouse ;
ud . config . UseJoystick = usejoy ;
# ifdef USE_OPENGL
glrendmode = glrm ;
# endif
}
2013-01-19 18:29:00 +00:00
# if !defined LUNATIC
2014-12-26 17:29:57 +00:00
static void C_BitOrNextValue ( int32_t * valptr )
{
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
* valptr | = * g_scriptPtr ;
}
static void C_FinishBitOr ( int32_t value )
{
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr = value ;
g_scriptPtr + + ;
}
2015-03-27 12:28:45 +00:00
static void C_FillEventBreakStackWithJump ( intptr_t * breakPtr , intptr_t destination )
{
while ( breakPtr )
{
intptr_t const tempPtr = * breakPtr ;
* breakPtr = destination ;
breakPtr = ( intptr_t * ) tempPtr ;
}
}
2011-04-07 01:16:29 +00:00
static int32_t C_ParseCommand ( int32_t loop )
2006-04-13 20:47:06 +00:00
{
2011-05-22 21:52:22 +00:00
int32_t i , j = 0 , k = 0 , tw , otw ;
2011-10-17 18:42:10 +00:00
// char *temptextptr;
2008-11-05 11:49:13 +00:00
intptr_t * tempscrptr = NULL ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
do
2007-08-29 05:29:37 +00:00
{
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( quitevent ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " Aborted. \n " ) ;
G_Shutdown ( ) ;
2014-06-13 09:02:37 +00:00
Bexit ( 0 ) ;
2011-04-07 01:16:29 +00:00
}
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_numCompilerErrors > 63 | | ( * textptr = = ' \0 ' ) | | ( * ( textptr + 1 ) = = ' \0 ' ) | | C_SkipComments ( ) ) )
2011-04-07 01:16:29 +00:00
return 1 ;
2006-09-19 23:02:33 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_scriptDebug ) )
2011-04-07 01:16:29 +00:00
C_ReportError ( - 1 ) ;
2006-04-13 20:47:06 +00:00
2011-10-17 18:42:10 +00:00
tempscrptr = NULL ; // temptextptr = NULL;
2011-04-07 01:16:29 +00:00
otw = g_lastKeyword ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
switch ( ( g_lastKeyword = tw = C_GetNextKeyword ( ) ) )
2006-11-16 03:02:42 +00:00
{
2011-04-07 01:16:29 +00:00
default :
case - 1 :
case - 2 :
return 1 ; //End
case CON_STATE :
if ( g_parsingActorPtr = = NULL & & g_processingState = = 0 )
{
C_GetNextLabelName ( ) ;
g_scriptPtr - - ;
2011-12-04 21:20:17 +00:00
labelcode [ g_numLabels ] = g_scriptPtr - script ;
2011-04-07 01:16:29 +00:00
labeltype [ g_numLabels ] = LABEL_STATE ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
g_processingState = 1 ;
Bsprintf ( g_szCurrentBlockName , " %s " , label + ( g_numLabels < < 6 ) ) ;
2006-11-15 01:16:55 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( hash_find ( & h_keywords , label + ( g_numLabels < < 6 ) ) > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_ISAKEYWORD ) ;
continue ;
}
2006-11-15 01:16:55 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( hash_find ( & h_gamevars , label + ( g_numLabels < < 6 ) ) > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerWarnings + + ;
C_ReportError ( WARNING_NAMEMATCHESVAR ) ;
}
2008-08-23 07:32:15 +00:00
2011-04-07 01:16:29 +00:00
hash_add ( & h_labels , label + ( g_numLabels < < 6 ) , g_numLabels , 0 ) ;
g_numLabels + + ;
continue ;
}
2008-08-23 07:32:15 +00:00
2011-04-07 01:16:29 +00:00
C_GetNextLabelName ( ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( j = hash_find ( & h_labels , label + ( g_numLabels < < 6 ) ) ) < 0 ) )
2008-08-25 00:49:12 +00:00
{
2008-11-20 14:06:36 +00:00
C_ReportError ( - 1 ) ;
2011-04-07 01:16:29 +00:00
initprintf ( " %s:%d: error: state `%s' not found. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
2014-10-25 03:36:34 +00:00
g_scriptPtr + + ;
continue ;
}
if ( EDUKE32_PREDICT_FALSE ( ( labeltype [ j ] & LABEL_STATE ) ! = LABEL_STATE ) )
{
char * gl = ( char * ) C_GetLabelType ( labeltype [ j ] ) ;
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: warning: expected state, found %s. \n " , g_szScriptFileName , g_lineNumber , gl ) ;
g_numCompilerWarnings + + ;
Bfree ( gl ) ;
* ( g_scriptPtr - 1 ) = CON_NULLOP ; // get rid of the state, leaving a nullop to satisfy if conditions
bitptr [ ( g_scriptPtr - script - 1 ) > > 3 ] & = ~ ( 1 < < ( ( g_scriptPtr - script - 1 ) & 7 ) ) ;
continue ; // valid label name, but wrong type
2006-04-13 20:47:06 +00:00
}
2014-10-25 03:36:34 +00:00
if ( ! ( g_numCompilerErrors | | g_numCompilerWarnings ) & & g_scriptDebug > 1 )
initprintf ( " %s:%d: debug: accepted state label `%s'. \n " , g_szScriptFileName , g_lineNumber , label + ( j < < 6 ) ) ;
* g_scriptPtr = ( intptr_t ) ( script + labelcode [ j ] ) ;
// 'state' type labels are always script addresses, as far as I can see
bitptr [ ( g_scriptPtr - script ) > > 3 ] | = ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2011-04-07 01:16:29 +00:00
g_scriptPtr + + ;
continue ;
case CON_ENDS :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_processingState = = 0 ) )
2006-04-13 20:47:06 +00:00
{
2011-04-07 01:16:29 +00:00
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: error: found `ends' without open `state'. \n " , g_szScriptFileName , g_lineNumber ) ;
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
2006-04-13 20:47:06 +00:00
}
2011-04-07 01:16:29 +00:00
// else
2006-04-13 20:47:06 +00:00
{
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_numBraces > 0 ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_OPENBRACKET ) ;
g_numCompilerErrors + + ;
}
2014-10-25 03:36:34 +00:00
else if ( EDUKE32_PREDICT_FALSE ( g_numBraces < 0 ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_CLOSEBRACKET ) ;
g_numCompilerErrors + + ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_checkingSwitch > 0 ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_NOENDSWITCH ) ;
g_numCompilerErrors + + ;
g_checkingSwitch = 0 ; // can't be checking anymore...
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
g_processingState = 0 ;
Bsprintf ( g_szCurrentBlockName , " (none) " ) ;
2006-11-15 01:16:55 +00:00
}
2011-04-07 01:16:29 +00:00
continue ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
case CON_SETTHISPROJECTILE :
case CON_SETPROJECTILE :
case CON_GETTHISPROJECTILE :
case CON_GETPROJECTILE :
{
int32_t lLabelID ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
// syntax getwall[<var>].x <VAR>
// gets the value of wall[<var>].xxx into <VAR>
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
// now get name of .xxx
while ( ( * textptr ! = ' [ ' ) )
{
textptr + + ;
}
if ( * textptr = = ' [ ' )
textptr + + ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
if ( tw = = CON_SETTHISPROJECTILE )
g_labelsOnly = 1 ;
C_GetNextVar ( ) ;
g_labelsOnly = 0 ;
// now get name of .xxx
while ( * textptr ! = ' . ' )
{
if ( * textptr = = 0xa )
break ;
if ( ! * textptr )
break ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
textptr + + ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' . ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
continue ;
}
textptr + + ;
/// now pointing at 'xxx'
C_GetNextLabelName ( ) ;
2012-03-26 05:05:57 +00:00
//printf("found xxx label of \"%s\"\n", label+(g_numLabels<<6));
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
lLabelID = C_GetLabelNameOffset ( & projectileH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
//printf("LabelID is %d\n",lLabelID);
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( lLabelID = = - 1 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYMBOLNOTRECOGNIZED ) ;
continue ;
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = ProjectileLabels [ lLabelID ] . lId ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
//printf("member's flags are: %02Xh\n",PlayerLabels[lLabelID].flags);
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// now at target VAR...
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
switch ( tw )
{
case CON_SETPROJECTILE :
case CON_SETTHISPROJECTILE :
C_GetNextVar ( ) ;
break ;
default :
C_GetNextVarType ( GAMEVAR_READONLY ) ;
break ;
}
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
case CON_GAMEVAR :
// syntax: gamevar <var1> <initial value> <flags>
// defines var1 and sets initial value.
// flags are used to define usage
// (see top of this files for flags)
//printf("Got gamedef. Getting Label. '%.20s'\n",textptr);
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( isdigit ( * textptr ) | | ( * textptr = = ' - ' ) ) )
2011-04-07 01:16:29 +00:00
{
C_GetNextLabelName ( ) ;
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
C_GetNextValue ( LABEL_DEFINE ) ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - = 3 ; // we complete the process anyways just to skip past the fucked up section
continue ;
}
2006-11-16 03:02:42 +00:00
2008-11-20 14:06:36 +00:00
C_GetNextLabelName ( ) ;
2011-04-07 01:16:29 +00:00
//printf("Got Label '%.20s'\n",textptr);
// Check to see it's already defined
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( hash_find ( & h_keywords , label + ( g_numLabels < < 6 ) ) > = 0 ) )
2008-09-01 07:15:16 +00:00
{
2011-04-07 01:16:29 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_ISAKEYWORD ) ;
continue ;
2008-09-01 07:15:16 +00:00
}
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
//printf("Translating number '%.20s'\n",textptr);
C_GetNextValue ( LABEL_DEFINE ) ; // get initial value
//printf("Done Translating number. '%.20s'\n",textptr);
C_GetNextValue ( LABEL_DEFINE ) ; // get flags
2012-03-26 05:05:57 +00:00
//Bsprintf(g_szBuf,"Adding GameVar=\"%s\", val=%l, flags=%lX",label+(g_numLabels<<6),
2011-04-07 01:16:29 +00:00
// *(g_scriptPtr-2), *(g_scriptPtr-1));
//AddLog(g_szBuf);
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( * ( g_scriptPtr - 1 ) & GAMEVAR_USER_MASK ) = = 3 ) )
2006-11-16 03:02:42 +00:00
{
2008-11-20 14:06:36 +00:00
g_numCompilerWarnings + + ;
2011-04-07 01:16:29 +00:00
* ( g_scriptPtr - 1 ) ^ = GAMEVAR_PERPLAYER ;
C_ReportError ( WARNING_BADGAMEVAR ) ;
2006-11-16 03:02:42 +00:00
}
2011-04-07 01:16:29 +00:00
Gv_NewVar ( label + ( g_numLabels < < 6 ) , * ( g_scriptPtr - 2 ) ,
( * ( g_scriptPtr - 1 ) )
// can't define default or secret
& ( ~ ( GAMEVAR_DEFAULT | GAMEVAR_SECRET ) )
) ;
//AddLog("Added gamevar");
g_scriptPtr - = 3 ; // no need to save in script...
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_GAMEARRAY :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( isdigit ( * textptr ) | | ( * textptr = = ' - ' ) ) )
2006-11-16 03:02:42 +00:00
{
2011-04-07 01:16:29 +00:00
C_GetNextLabelName ( ) ;
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
2008-11-20 14:06:36 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - = 2 ; // we complete the process anyways just to skip past the fucked up section
continue ;
2006-11-16 03:02:42 +00:00
}
2008-11-20 14:06:36 +00:00
C_GetNextLabelName ( ) ;
2011-04-07 01:16:29 +00:00
//printf("Got Label '%.20s'\n",textptr);
2006-11-15 01:16:55 +00:00
// Check to see it's already defined
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( hash_find ( & h_keywords , label + ( g_numLabels < < 6 ) ) > = 0 ) )
2008-08-25 00:49:12 +00:00
{
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_ISAKEYWORD ) ;
2011-04-07 01:16:29 +00:00
continue ;
2008-08-25 00:49:12 +00:00
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
i = hash_find ( & h_gamevars , label + ( g_numLabels < < 6 ) ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = 0 ) )
2008-08-23 07:32:15 +00:00
{
2008-11-20 14:06:36 +00:00
g_numCompilerWarnings + + ;
C_ReportError ( WARNING_NAMEMATCHESVAR ) ;
2008-08-23 07:32:15 +00:00
}
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
2012-12-13 02:33:53 +00:00
Gv_NewArray ( label + ( g_numLabels < < 6 ) , NULL , * ( g_scriptPtr - 1 ) , GAMEARRAY_NORMAL ) ;
2011-04-07 01:16:29 +00:00
g_scriptPtr - = 2 ; // no need to save in script...
continue ;
case CON_DEFINE :
2006-04-13 20:47:06 +00:00
{
2011-04-07 01:16:29 +00:00
//printf("Got definition. Getting Label. '%.20s'\n",textptr);
C_GetNextLabelName ( ) ;
//printf("Got label. '%.20s'\n",textptr);
// Check to see it's already defined
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( hash_find ( & h_keywords , label + ( g_numLabels < < 6 ) ) > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_ISAKEYWORD ) ;
continue ;
}
i = hash_find ( & h_gamevars , label + ( g_numLabels < < 6 ) ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerWarnings + + ;
C_ReportError ( WARNING_NAMEMATCHESVAR ) ;
}
2012-06-10 18:56:27 +00:00
//printf("Translating. '%.20s'\n",textptr);
C_GetNextValue ( LABEL_DEFINE ) ;
//printf("Translated. '%.20s'\n",textptr);
2011-04-07 01:16:29 +00:00
i = hash_find ( & h_labels , label + ( g_numLabels < < 6 ) ) ;
if ( i > = 0 )
{
2012-06-10 18:56:27 +00:00
// if (i >= g_numDefaultLabels)
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( labelcode [ i ] ! = * ( g_scriptPtr - 1 ) ) )
2011-04-07 01:16:29 +00:00
{
2012-06-10 18:56:27 +00:00
g_numCompilerWarnings + + ;
initprintf ( " %s:%d: warning: ignored redefinition of `%s' to %d (old: %d). \n " , g_szScriptFileName ,
g_lineNumber , label + ( g_numLabels < < 6 ) , ( int32_t ) ( * ( g_scriptPtr - 1 ) ) , labelcode [ i ] ) ;
//C_ReportError(WARNING_DUPLICATEDEFINITION);
}
2011-04-07 01:16:29 +00:00
}
2012-06-10 18:56:27 +00:00
else
2011-04-07 01:16:29 +00:00
{
2012-03-26 05:05:57 +00:00
// printf("Defining Definition \"%s\" to be '%d'\n",label+(g_numLabels<<6),*(g_scriptPtr-1));
2011-04-07 01:16:29 +00:00
hash_add ( & h_labels , label + ( g_numLabels < < 6 ) , g_numLabels , 0 ) ;
labeltype [ g_numLabels ] = LABEL_DEFINE ;
labelcode [ g_numLabels + + ] = * ( g_scriptPtr - 1 ) ;
if ( * ( g_scriptPtr - 1 ) > = 0 & & * ( g_scriptPtr - 1 ) < MAXTILES & & g_dynamicTileMapping )
G_ProcessDynamicTileMapping ( label + ( ( g_numLabels - 1 ) < < 6 ) , * ( g_scriptPtr - 1 ) ) ;
}
g_scriptPtr - = 2 ;
continue ;
2006-04-13 20:47:06 +00:00
}
2009-05-28 02:55:46 +00:00
2011-04-07 01:16:29 +00:00
case CON_PALFROM :
for ( j = 3 ; j > = 0 ; j - - )
2006-04-13 20:47:06 +00:00
{
2011-04-07 01:16:29 +00:00
if ( C_GetKeyword ( ) = = - 1 )
C_GetNextValue ( LABEL_DEFINE ) ;
else break ;
2006-04-13 20:47:06 +00:00
}
2009-05-28 02:55:46 +00:00
2011-04-07 01:16:29 +00:00
while ( j > - 1 )
2006-04-13 20:47:06 +00:00
{
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2013-05-23 18:28:04 +00:00
* g_scriptPtr + + = 0 ;
2011-04-07 01:16:29 +00:00
j - - ;
2006-04-13 20:47:06 +00:00
}
2011-04-07 01:16:29 +00:00
continue ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
case CON_MOVE :
if ( g_parsingActorPtr | | g_processingState )
2006-11-16 03:02:42 +00:00
{
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( C_GetNextValue ( LABEL_MOVE | LABEL_DEFINE ) = = 0 ) & & ( * ( g_scriptPtr - 1 ) ! = 0 ) & & ( * ( g_scriptPtr - 1 ) ! = 1 ) ) )
2006-04-13 20:47:06 +00:00
{
2011-04-07 01:16:29 +00:00
C_ReportError ( - 1 ) ;
bitptr [ ( g_scriptPtr - script - 1 ) > > 3 ] & = ~ ( 1 < < ( ( g_scriptPtr - script - 1 ) & 7 ) ) ;
* ( g_scriptPtr - 1 ) = 0 ;
initprintf ( " %s:%d: warning: expected a move, found a constant. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
2006-04-13 20:47:06 +00:00
}
2006-12-12 07:25:01 +00:00
2011-04-07 01:16:29 +00:00
j = 0 ;
while ( C_GetKeyword ( ) = = - 1 )
2014-12-26 17:29:57 +00:00
C_BitOrNextValue ( & j ) ;
2006-12-05 21:22:19 +00:00
2014-12-26 17:29:57 +00:00
C_FinishBitOr ( j ) ;
2006-04-13 20:47:06 +00:00
}
2011-04-07 01:16:29 +00:00
else
2006-04-13 20:47:06 +00:00
{
2011-04-07 01:16:29 +00:00
g_scriptPtr - - ;
C_GetNextLabelName ( ) ;
// Check to see it's already defined
2006-12-04 22:05:30 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( hash_find ( & h_keywords , label + ( g_numLabels < < 6 ) ) > = 0 ) )
2006-11-15 01:16:55 +00:00
{
2011-04-07 01:16:29 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_ISAKEYWORD ) ;
continue ;
2006-04-13 20:47:06 +00:00
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( hash_find ( & h_gamevars , label + ( g_numLabels < < 6 ) ) > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerWarnings + + ;
C_ReportError ( WARNING_NAMEMATCHESVAR ) ;
}
2009-11-18 01:17:56 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( i = hash_find ( & h_labels , label + ( g_numLabels < < 6 ) ) ) > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerWarnings + + ;
initprintf ( " %s:%d: warning: duplicate move `%s' ignored. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
}
2012-05-25 18:39:22 +00:00
else
2011-04-07 01:16:29 +00:00
{
hash_add ( & h_labels , label + ( g_numLabels < < 6 ) , g_numLabels , 0 ) ;
labeltype [ g_numLabels ] = LABEL_MOVE ;
2011-12-04 21:20:17 +00:00
labelcode [ g_numLabels + + ] = g_scriptPtr - script ;
2011-04-07 01:16:29 +00:00
}
2006-08-17 23:07:43 +00:00
2011-04-07 01:16:29 +00:00
for ( j = 1 ; j > = 0 ; j - - )
{
if ( C_GetKeyword ( ) ! = - 1 ) break ;
C_GetNextValue ( LABEL_DEFINE ) ;
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
for ( k = j ; k > = 0 ; k - - )
{
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr = 0 ;
g_scriptPtr + + ;
}
2006-04-13 20:47:06 +00:00
}
2011-04-07 01:16:29 +00:00
continue ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
case CON_MUSIC :
2006-04-13 20:47:06 +00:00
{
2011-04-07 01:16:29 +00:00
// NOTE: this doesn't get stored in the PCode...
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// music 1 stalker.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid
// thecall.mid ahgeez.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid
g_scriptPtr - - ;
C_GetNextValue ( LABEL_DEFINE ) ; // Volume Number (0/4)
g_scriptPtr - - ;
2006-04-13 20:47:06 +00:00
2014-09-07 18:10:14 +00:00
k = * g_scriptPtr - 1 ; // 0-based volume number. -1 or MAXVOLUMES: "special"
if ( k = = - 1 )
k = MAXVOLUMES ;
2009-11-18 01:17:56 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) k > = MAXVOLUMES + 1 ) ) // if it's not background or special music
2011-04-07 01:16:29 +00:00
{
2014-09-07 18:10:14 +00:00
g_numCompilerErrors + + ;
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: error: volume number must be between 0 and MAXVOLUMES+1=%d. \n " ,
g_szScriptFileName , g_lineNumber , MAXVOLUMES + 1 ) ;
2014-10-25 03:36:34 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2014-09-07 18:10:14 +00:00
2014-10-25 03:36:34 +00:00
i = 0 ;
// get the file name...
while ( C_GetKeyword ( ) = = - 1 )
{
C_SkipComments ( ) ;
j = 0 ;
tempbuf [ j ] = ' / ' ;
while ( isaltok ( * ( textptr + j ) ) )
{
tempbuf [ j + 1 ] = textptr [ j ] ;
j + + ;
}
tempbuf [ j + 1 ] = ' \0 ' ;
C_DefineMusic ( k , i , tempbuf ) ;
textptr + = j ;
if ( i > = MAXLEVELS )
break ;
i + + ;
}
2008-09-01 07:15:16 +00:00
}
2011-04-07 01:16:29 +00:00
continue ;
case CON_INCLUDE :
2008-11-20 14:06:36 +00:00
g_scriptPtr - - ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
C_SkipComments ( ) ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
j = 0 ;
while ( isaltok ( * textptr ) )
2008-08-23 07:32:15 +00:00
{
2011-04-07 01:16:29 +00:00
tempbuf [ j ] = * ( textptr + + ) ;
j + + ;
2008-08-23 07:32:15 +00:00
}
2011-04-07 01:16:29 +00:00
tempbuf [ j ] = ' \0 ' ;
2008-08-23 07:32:15 +00:00
2011-07-21 22:39:29 +00:00
C_Include ( tempbuf ) ;
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
continue ;
case CON_INCLUDEDEFAULT :
C_SkipComments ( ) ;
2012-06-03 16:09:33 +00:00
C_Include ( G_DefaultConFile ( ) ) ;
2011-04-07 01:16:29 +00:00
continue ;
case CON_AI :
if ( g_parsingActorPtr | | g_processingState )
{
C_GetNextValue ( LABEL_AI ) ;
}
else
{
g_scriptPtr - - ;
C_GetNextLabelName ( ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( hash_find ( & h_keywords , label + ( g_numLabels < < 6 ) ) > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_ISAKEYWORD ) ;
continue ;
}
i = hash_find ( & h_gamevars , label + ( g_numLabels < < 6 ) ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerWarnings + + ;
C_ReportError ( WARNING_NAMEMATCHESVAR ) ;
}
i = hash_find ( & h_labels , label + ( g_numLabels < < 6 ) ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerWarnings + + ;
initprintf ( " %s:%d: warning: duplicate ai `%s' ignored. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
}
2012-05-25 18:39:22 +00:00
else
2011-04-07 01:16:29 +00:00
{
labeltype [ g_numLabels ] = LABEL_AI ;
hash_add ( & h_labels , label + ( g_numLabels < < 6 ) , g_numLabels , 0 ) ;
2011-12-04 21:20:17 +00:00
labelcode [ g_numLabels + + ] = g_scriptPtr - script ;
2011-04-07 01:16:29 +00:00
}
for ( j = 0 ; j < 3 ; j + + )
{
if ( C_GetKeyword ( ) ! = - 1 ) break ;
if ( j = = 1 )
C_GetNextValue ( LABEL_ACTION ) ;
else if ( j = = 2 )
2006-11-15 01:16:55 +00:00
{
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( C_GetNextValue ( LABEL_MOVE | LABEL_DEFINE ) = = 0 ) & &
( * ( g_scriptPtr - 1 ) ! = 0 ) & & ( * ( g_scriptPtr - 1 ) ! = 1 ) ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( - 1 ) ;
bitptr [ ( g_scriptPtr - script - 1 ) > > 3 ] & = ~ ( 1 < < ( ( g_scriptPtr - script - 1 ) & 7 ) ) ;
* ( g_scriptPtr - 1 ) = 0 ;
initprintf ( " %s:%d: warning: expected a move, found a constant. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
}
2014-12-26 17:29:57 +00:00
2011-04-07 01:16:29 +00:00
k = 0 ;
while ( C_GetKeyword ( ) = = - 1 )
2014-12-26 17:29:57 +00:00
C_BitOrNextValue ( & k ) ;
C_FinishBitOr ( k ) ;
2011-05-20 02:34:41 +00:00
j = 666 ;
break ;
2006-11-15 01:16:55 +00:00
}
2011-04-07 01:16:29 +00:00
}
2011-05-20 02:34:41 +00:00
if ( j = = 666 )
continue ;
2011-04-07 01:16:29 +00:00
for ( k = j ; k < 3 ; k + + )
{
2009-07-04 09:28:21 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
2011-04-07 01:16:29 +00:00
* g_scriptPtr = 0 ;
2008-11-20 14:06:36 +00:00
g_scriptPtr + + ;
2006-11-15 01:16:55 +00:00
}
}
2011-04-07 01:16:29 +00:00
continue ;
case CON_ACTION :
if ( g_parsingActorPtr | | g_processingState )
2006-11-15 01:16:55 +00:00
{
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_ACTION ) ;
2006-11-15 01:16:55 +00:00
}
2011-04-07 01:16:29 +00:00
else
2008-09-01 07:15:16 +00:00
{
2011-04-07 01:16:29 +00:00
g_scriptPtr - - ;
C_GetNextLabelName ( ) ;
// Check to see it's already defined
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( hash_find ( & h_keywords , label + ( g_numLabels < < 6 ) ) > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_ISAKEYWORD ) ;
continue ;
}
i = hash_find ( & h_gamevars , label + ( g_numLabels < < 6 ) ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerWarnings + + ;
C_ReportError ( WARNING_NAMEMATCHESVAR ) ;
}
i = hash_find ( & h_labels , label + ( g_numLabels < < 6 ) ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerWarnings + + ;
initprintf ( " %s:%d: warning: duplicate action `%s' ignored. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
}
2012-05-25 18:39:22 +00:00
else
2011-04-07 01:16:29 +00:00
{
labeltype [ g_numLabels ] = LABEL_ACTION ;
2011-12-04 21:20:17 +00:00
labelcode [ g_numLabels ] = g_scriptPtr - script ;
2011-04-07 01:16:29 +00:00
hash_add ( & h_labels , label + ( g_numLabels < < 6 ) , g_numLabels , 0 ) ;
g_numLabels + + ;
}
for ( j = 4 ; j > = 0 ; j - - )
{
if ( C_GetKeyword ( ) ! = - 1 ) break ;
C_GetNextValue ( LABEL_DEFINE ) ;
}
for ( k = j ; k > = 0 ; k - - )
{
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* ( g_scriptPtr + + ) = 0 ;
}
2008-09-01 07:15:16 +00:00
}
2011-04-07 01:16:29 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_ACTOR :
case CON_USERACTOR :
case CON_EVENTLOADACTOR :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_processingState | | g_parsingActorPtr ) )
2008-08-25 00:49:12 +00:00
{
2011-04-07 01:16:29 +00:00
C_ReportError ( ERROR_FOUNDWITHIN ) ;
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
2008-08-25 00:49:12 +00:00
}
2008-08-23 07:32:15 +00:00
2011-04-07 01:16:29 +00:00
g_numBraces = 0 ;
g_scriptPtr - - ;
g_parsingActorPtr = g_scriptPtr ;
2008-08-23 07:32:15 +00:00
2011-04-07 01:16:29 +00:00
if ( tw = = CON_USERACTOR )
2008-08-25 00:49:12 +00:00
{
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
2008-08-25 00:49:12 +00:00
}
2006-11-16 03:02:42 +00:00
2012-04-07 20:09:44 +00:00
// save the actor name w/o consuming it
2011-04-07 01:16:29 +00:00
C_SkipComments ( ) ;
j = 0 ;
while ( isaltok ( * ( textptr + j ) ) )
2006-11-16 03:02:42 +00:00
{
2011-04-07 01:16:29 +00:00
g_szCurrentBlockName [ j ] = textptr [ j ] ;
j + + ;
2006-11-15 01:16:55 +00:00
}
2011-04-07 01:16:29 +00:00
g_szCurrentBlockName [ j ] = 0 ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
if ( tw = = CON_USERACTOR )
2006-11-15 01:16:55 +00:00
{
2011-07-20 22:08:05 +00:00
j = * g_scriptPtr ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( j > 6 | | ( j & 3 ) = = 3 ) )
2011-07-20 22:08:05 +00:00
{
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: warning: invalid useractor type. Must be 0, 1, 2 "
2012-04-07 20:09:44 +00:00
" (notenemy, enemy, enemystayput) or have 4 added ( \" doesn't move \" ). \n " ,
2011-07-20 22:08:05 +00:00
g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
j = 0 ;
}
2006-11-15 01:16:55 +00:00
}
2006-11-16 03:02:42 +00:00
2011-03-04 08:50:58 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) * g_scriptPtr > = MAXTILES ) )
2012-05-13 16:05:34 +00:00
{
C_ReportError ( ERROR_EXCEEDSMAXTILES ) ;
g_numCompilerErrors + + ;
continue ;
}
2011-04-07 01:16:29 +00:00
if ( tw = = CON_EVENTLOADACTOR )
{
2012-10-30 15:54:35 +00:00
g_tile [ * g_scriptPtr ] . loadPtr = g_parsingActorPtr ;
2011-07-20 22:08:05 +00:00
g_checkingIfElse = 0 ;
continue ;
2011-04-07 01:16:29 +00:00
}
2011-03-04 08:50:58 +00:00
2012-10-30 15:54:35 +00:00
g_tile [ * g_scriptPtr ] . execPtr = g_parsingActorPtr ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
if ( tw = = CON_USERACTOR )
2012-10-30 15:54:35 +00:00
{
if ( j & 1 )
2014-02-22 19:38:52 +00:00
g_tile [ * g_scriptPtr ] . flags | = SFLAG_BADGUY ;
2012-10-30 15:54:35 +00:00
if ( j & 2 )
2014-02-22 19:38:52 +00:00
g_tile [ * g_scriptPtr ] . flags | = ( SFLAG_BADGUY | SFLAG_BADGUYSTAYPUT ) ;
2012-12-23 19:24:21 +00:00
if ( j & 4 )
2014-02-22 19:38:52 +00:00
g_tile [ * g_scriptPtr ] . flags | = SFLAG_ROTFIXED ;
2012-10-30 15:54:35 +00:00
}
2011-03-04 08:50:58 +00:00
2011-04-07 01:16:29 +00:00
for ( j = 0 ; j < 4 ; j + + )
2006-11-15 01:16:55 +00:00
{
2011-04-07 01:16:29 +00:00
bitptr [ ( g_parsingActorPtr + j - script ) > > 3 ] & = ~ ( 1 < < ( ( g_parsingActorPtr + j - script ) & 7 ) ) ;
* ( g_parsingActorPtr + j ) = 0 ;
if ( j = = 3 )
2006-11-15 01:16:55 +00:00
{
2011-04-07 01:16:29 +00:00
j = 0 ;
while ( C_GetKeyword ( ) = = - 1 )
2014-12-26 17:29:57 +00:00
C_BitOrNextValue ( & j ) ;
C_FinishBitOr ( j ) ;
2006-11-15 01:16:55 +00:00
break ;
}
2011-04-07 01:16:29 +00:00
else
2006-11-15 01:16:55 +00:00
{
2011-04-07 01:16:29 +00:00
if ( C_GetKeyword ( ) ! = - 1 )
2006-11-15 01:16:55 +00:00
{
2011-04-07 01:16:29 +00:00
for ( i = 4 - j ; i ; i - - )
{
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* ( g_scriptPtr + + ) = 0 ;
}
break ;
2006-11-15 01:16:55 +00:00
}
2011-04-07 01:16:29 +00:00
switch ( j )
{
case 0 :
C_GetNextValue ( LABEL_DEFINE ) ;
break ;
case 1 :
C_GetNextValue ( LABEL_ACTION ) ;
break ;
case 2 :
2011-12-21 18:41:55 +00:00
// XXX: LABEL_MOVE|LABEL_DEFINE, what is this shit? compatibility?
2014-10-25 03:36:34 +00:00
// yep, it sure is :(
if ( EDUKE32_PREDICT_FALSE ( ( C_GetNextValue ( LABEL_MOVE | LABEL_DEFINE ) = = 0 ) & & ( * ( g_scriptPtr - 1 ) ! = 0 ) & & ( * ( g_scriptPtr - 1 ) ! = 1 ) ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( - 1 ) ;
bitptr [ ( g_scriptPtr - script - 1 ) > > 3 ] & = ~ ( 1 < < ( ( g_scriptPtr - script - 1 ) & 7 ) ) ;
* ( g_scriptPtr - 1 ) = 0 ;
initprintf ( " %s:%d: warning: expected a move, found a constant. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
}
break ;
}
if ( * ( g_scriptPtr - 1 ) > = ( intptr_t ) & script [ 0 ] & & * ( g_scriptPtr - 1 ) < ( intptr_t ) & script [ g_scriptSize ] )
bitptr [ ( g_parsingActorPtr + j - script ) > > 3 ] | = ( BITPTR_POINTER < < ( ( g_parsingActorPtr + j - script ) & 7 ) ) ;
else bitptr [ ( g_parsingActorPtr + j - script ) > > 3 ] & = ~ ( 1 < < ( ( g_parsingActorPtr + j - script ) & 7 ) ) ;
* ( g_parsingActorPtr + j ) = * ( g_scriptPtr - 1 ) ;
2006-11-15 01:16:55 +00:00
}
}
2011-04-07 01:16:29 +00:00
g_checkingIfElse = 0 ;
continue ;
2006-11-13 23:12:47 +00:00
2011-04-07 01:16:29 +00:00
case CON_ONEVENT :
2015-03-25 21:31:11 +00:00
case CON_APPENDEVENT :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_processingState | | g_parsingActorPtr ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_FOUNDWITHIN ) ;
g_numCompilerErrors + + ;
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
g_numBraces = 0 ;
g_scriptPtr - - ;
g_parsingEventPtr = g_scriptPtr ;
g_parsingActorPtr = g_scriptPtr ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
C_SkipComments ( ) ;
j = 0 ;
while ( isaltok ( * ( textptr + j ) ) )
{
g_szCurrentBlockName [ j ] = textptr [ j ] ;
j + + ;
}
g_szCurrentBlockName [ j ] = 0 ;
// g_labelsOnly = 1;
C_GetNextValue ( LABEL_DEFINE ) ;
g_labelsOnly = 0 ;
g_scriptPtr - - ;
j = * g_scriptPtr ; // type of event
g_currentEvent = j ;
//Bsprintf(g_szBuf,"Adding Event for %d at %lX",j, g_parsingEventPtr);
//AddLog(g_szBuf);
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > MAXGAMEEVENTS - 1 ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: error: invalid event ID. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
continue ;
}
// if event has already been declared then store previous script location
2015-03-25 21:31:11 +00:00
if ( ! apScriptGameEvent [ j ] )
2011-04-07 01:16:29 +00:00
{
2015-03-25 21:31:11 +00:00
apScriptGameEvent [ j ] = g_parsingEventPtr ;
}
else if ( tw = = CON_ONEVENT )
{
previous_event = apScriptGameEvent [ j ] ;
apScriptGameEvent [ j ] = g_parsingEventPtr ;
}
else // if (tw == CON_APPENDEVENT)
{
2015-03-27 12:28:45 +00:00
intptr_t const destination = g_parsingEventPtr - script ;
2015-03-25 21:31:11 +00:00
intptr_t * previous_event_end = apScriptGameEventEnd [ j ] ;
* ( previous_event_end + + ) = CON_JUMP ;
* ( previous_event_end + + ) = MAXGAMEVARS ;
2015-03-27 12:28:45 +00:00
C_FillEventBreakStackWithJump ( ( intptr_t * ) * previous_event_end , destination ) ;
* ( previous_event_end + + ) = destination ;
2011-04-07 01:16:29 +00:00
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
g_checkingIfElse = 0 ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_QSPRINTF :
C_GetManyVars ( 2 ) ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
j = 0 ;
2009-07-12 01:55:34 +00:00
2011-04-07 01:16:29 +00:00
while ( C_GetKeyword ( ) = = - 1 & & j < 32 )
C_GetNextVar ( ) , j + + ;
2009-07-12 01:55:34 +00:00
2011-04-07 01:16:29 +00:00
* g_scriptPtr + + = CON_NULLOP + ( g_lineNumber < < 12 ) ;
continue ;
2006-04-13 20:47:06 +00:00
2015-01-17 00:27:19 +00:00
case CON_CSTAT :
C_GetNextValue ( LABEL_DEFINE ) ;
if ( EDUKE32_PREDICT_FALSE ( * ( g_scriptPtr - 1 ) = = 32767 ) )
{
* ( g_scriptPtr - 1 ) = 32768 ;
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: warning: tried to set cstat 32767, using 32768 instead. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
}
else if ( EDUKE32_PREDICT_FALSE ( ( * ( g_scriptPtr - 1 ) & 32 ) & & ( * ( g_scriptPtr - 1 ) & 16 ) ) )
{
i = * ( g_scriptPtr - 1 ) ;
* ( g_scriptPtr - 1 ) ^ = 48 ;
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: warning: tried to set cstat %d, using %d instead. \n " , g_szScriptFileName , g_lineNumber , i , ( int32_t ) ( * ( g_scriptPtr - 1 ) ) ) ;
g_numCompilerWarnings + + ;
}
continue ;
case CON_HITRADIUSVAR :
C_GetManyVars ( 5 ) ;
continue ;
case CON_HITRADIUS :
C_GetNextValue ( LABEL_DEFINE ) ;
C_GetNextValue ( LABEL_DEFINE ) ;
C_GetNextValue ( LABEL_DEFINE ) ;
case CON_ADDAMMO :
case CON_ADDWEAPON :
case CON_SIZETO :
case CON_SIZEAT :
case CON_DEBRIS :
case CON_ADDINVENTORY :
case CON_GUTS :
C_GetNextValue ( LABEL_DEFINE ) ;
2011-04-07 01:16:29 +00:00
case CON_ESPAWN :
case CON_ESHOOT :
case CON_QSPAWN :
case CON_EQSPAWN :
case CON_STRENGTH :
case CON_SHOOT :
case CON_ADDPHEALTH :
case CON_SPAWN :
case CON_COUNT :
case CON_ENDOFGAME :
2013-05-23 18:28:04 +00:00
case CON_ENDOFLEVEL :
2011-04-07 01:16:29 +00:00
case CON_SPRITEPAL :
case CON_CACTOR :
case CON_MONEY :
case CON_ADDKILLS :
case CON_DEBUG :
case CON_ADDSTRENGTH :
case CON_CSTATOR :
case CON_MAIL :
case CON_PAPER :
case CON_SLEEPTIME :
case CON_CLIPDIST :
case CON_LOTSOFGLASS :
case CON_SAVENN :
case CON_SAVE :
case CON_ANGOFF :
case CON_QUOTE :
case CON_SOUND :
case CON_GLOBALSOUND :
case CON_SOUNDONCE :
case CON_STOPSOUND :
C_GetNextValue ( LABEL_DEFINE ) ;
2011-05-20 02:34:41 +00:00
continue ;
2009-06-18 05:57:10 +00:00
2011-04-07 01:16:29 +00:00
case CON_ELSE :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ! g_checkingIfElse ) )
{
g_scriptPtr - - ;
tempscrptr = g_scriptPtr ;
g_numCompilerWarnings + + ;
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: warning: found `else' with no `if'. \n " , g_szScriptFileName , g_lineNumber ) ;
if ( C_GetKeyword ( ) = = CON_LEFTBRACE )
{
C_GetNextKeyword ( ) ;
g_numBraces + + ;
C_ParseCommand ( 1 ) ;
}
else C_ParseCommand ( 0 ) ;
g_scriptPtr = tempscrptr ;
continue ;
}
2011-04-07 01:16:29 +00:00
{
intptr_t offset ;
intptr_t lastScriptPtr = g_scriptPtr - & script [ 0 ] - 1 ;
2009-06-18 05:57:10 +00:00
2011-04-07 01:16:29 +00:00
g_ifElseAborted = 0 ;
g_checkingIfElse - - ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
if ( C_CheckMalformedBranch ( lastScriptPtr ) )
continue ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
tempscrptr = g_scriptPtr ;
offset = ( unsigned ) ( tempscrptr - script ) ;
g_scriptPtr + + ; //Leave a spot for the fail location
C_ParseCommand ( 0 ) ;
2009-01-05 14:43:12 +00:00
2011-04-07 01:16:29 +00:00
if ( C_CheckEmptyBranch ( tw , lastScriptPtr ) )
continue ;
2009-01-05 14:43:12 +00:00
2011-04-07 01:16:29 +00:00
tempscrptr = ( intptr_t * ) script + offset ;
* tempscrptr = ( intptr_t ) g_scriptPtr ;
bitptr [ ( tempscrptr - script ) > > 3 ] | = ( BITPTR_POINTER < < ( ( tempscrptr - script ) & 7 ) ) ;
}
2014-10-25 03:36:34 +00:00
2011-04-07 01:16:29 +00:00
continue ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
case CON_SETSECTOR :
case CON_GETSECTOR :
{
int32_t lLabelID ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
// syntax getsector[<var>].x <VAR>
// gets the value of sector[<var>].xxx into <VAR>
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
// now get name of .xxx
while ( ( * textptr ! = ' [ ' ) )
{
textptr + + ;
}
if ( * textptr = = ' [ ' )
textptr + + ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
g_labelsOnly = 1 ;
C_GetNextVar ( ) ;
g_labelsOnly = 0 ;
// now get name of .xxx
while ( * textptr ! = ' . ' )
{
if ( * textptr = = 0xa )
break ;
if ( ! * textptr )
break ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
textptr + + ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' . ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
continue ;
}
textptr + + ;
/// now pointing at 'xxx'
C_GetNextLabelName ( ) ;
2012-03-26 05:05:57 +00:00
//printf("found xxx label of \"%s\"\n", label+(g_numLabels<<6));
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
lLabelID = C_GetLabelNameID ( SectorLabels , & sectorH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
2006-11-15 01:16:55 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( lLabelID = = - 1 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYMBOLNOTRECOGNIZED ) ;
continue ;
}
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = lLabelID ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
// now at target VAR...
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
if ( tw = = CON_GETSECTOR )
C_GetNextVarType ( GAMEVAR_READONLY ) ;
else
C_GetNextVar ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
case CON_FINDNEARACTOR :
case CON_FINDNEARACTOR3D :
case CON_FINDNEARSPRITE :
case CON_FINDNEARSPRITE3D :
2006-11-16 03:02:42 +00:00
case CON_FINDNEARACTORZ :
case CON_FINDNEARSPRITEZ :
2011-04-07 01:16:29 +00:00
{
// syntax findnearactor <type> <maxdist> <getvar>
// gets the sprite ID of the nearest actor within max dist
// that is of <type> into <getvar>
// -1 for none found
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ; // get <type>
C_GetNextValue ( LABEL_DEFINE ) ; // get maxdist
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
switch ( tw )
{
case CON_FINDNEARACTORZ :
case CON_FINDNEARSPRITEZ :
C_GetNextValue ( LABEL_DEFINE ) ;
default :
break ;
}
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
// target var
// get the ID of the DEF
C_GetNextVarType ( GAMEVAR_READONLY ) ;
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
case CON_FINDNEARACTORVAR :
case CON_FINDNEARACTOR3DVAR :
case CON_FINDNEARSPRITEVAR :
case CON_FINDNEARSPRITE3DVAR :
2006-11-15 01:16:55 +00:00
case CON_FINDNEARACTORZVAR :
case CON_FINDNEARSPRITEZVAR :
2011-04-07 01:16:29 +00:00
{
C_GetNextValue ( LABEL_DEFINE ) ; // get <type>
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
C_GetNextVar ( ) ;
switch ( tw )
{
case CON_FINDNEARACTORZVAR :
case CON_FINDNEARSPRITEZVAR :
C_GetNextVar ( ) ;
default :
break ;
}
// target var
// get the ID of the DEF
C_GetNextVarType ( GAMEVAR_READONLY ) ;
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
case CON_SETWALL :
case CON_GETWALL :
{
int32_t lLabelID ;
2006-11-13 23:12:47 +00:00
2011-04-07 01:16:29 +00:00
// syntax getwall[<var>].x <VAR>
// gets the value of wall[<var>].xxx into <VAR>
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
// now get name of .xxx
while ( ( * textptr ! = ' [ ' ) )
{
textptr + + ;
}
if ( * textptr = = ' [ ' )
textptr + + ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
g_labelsOnly = 1 ;
C_GetNextVar ( ) ;
g_labelsOnly = 0 ;
// now get name of .xxx
while ( * textptr ! = ' . ' )
{
if ( * textptr = = 0xa )
break ;
if ( ! * textptr )
break ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
textptr + + ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' . ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
continue ;
}
textptr + + ;
/// now pointing at 'xxx'
C_GetNextLabelName ( ) ;
2012-03-26 05:05:57 +00:00
//printf("found xxx label of \"%s\"\n", label+(g_numLabels<<6));
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
lLabelID = C_GetLabelNameID ( WallLabels , & wallH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( lLabelID = = - 1 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYMBOLNOTRECOGNIZED ) ;
continue ;
}
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = lLabelID ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// now at target VAR...
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
if ( tw = = CON_GETWALL )
C_GetNextVarType ( GAMEVAR_READONLY ) ;
else
C_GetNextVar ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_SETPLAYER :
case CON_GETPLAYER :
{
int32_t lLabelID ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
// syntax getwall[<var>].x <VAR>
// gets the value of wall[<var>].xxx into <VAR>
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// now get name of .xxx
while ( ( * textptr ! = ' [ ' ) )
{
textptr + + ;
}
if ( * textptr = = ' [ ' )
textptr + + ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
g_labelsOnly = 1 ;
C_GetNextVar ( ) ;
g_labelsOnly = 0 ;
// now get name of .xxx
while ( * textptr ! = ' . ' )
{
if ( * textptr = = 0xa )
break ;
if ( ! * textptr )
break ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
textptr + + ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' . ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
continue ;
}
textptr + + ;
/// now pointing at 'xxx'
C_GetNextLabelName ( ) ;
2012-03-26 05:05:57 +00:00
//printf("found xxx label of \"%s\"\n", label+(g_numLabels<<6));
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
lLabelID = C_GetLabelNameOffset ( & playerH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
//printf("LabelID is %d\n",lLabelID);
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( lLabelID = = - 1 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYMBOLNOTRECOGNIZED ) ;
continue ;
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = PlayerLabels [ lLabelID ] . lId ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
//printf("member's flags are: %02Xh\n",PlayerLabels[lLabelID].flags);
if ( PlayerLabels [ lLabelID ] . flags & LABEL_HASPARM2 )
{
//printf("Member has PARM2\n");
// get parm2
// get the ID of the DEF
C_GetNextVar ( ) ;
}
else
{
//printf("Member does not have Parm2\n");
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// now at target VAR...
// get the ID of the DEF
if ( tw = = CON_GETPLAYER )
C_GetNextVarType ( GAMEVAR_READONLY ) ;
else
C_GetNextVar ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
case CON_SETINPUT :
case CON_GETINPUT :
{
int32_t lLabelID ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// syntax getwall[<var>].x <VAR>
// gets the value of wall[<var>].xxx into <VAR>
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// now get name of .xxx
while ( ( * textptr ! = ' [ ' ) )
{
textptr + + ;
}
if ( * textptr = = ' [ ' )
textptr + + ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
g_labelsOnly = 1 ;
C_GetNextVar ( ) ;
g_labelsOnly = 0 ;
// now get name of .xxx
while ( * textptr ! = ' . ' )
{
if ( * textptr = = 0xa )
break ;
if ( ! * textptr )
break ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
textptr + + ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' . ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
continue ;
}
textptr + + ;
/// now pointing at 'xxx'
C_GetNextLabelName ( ) ;
2012-03-26 05:05:57 +00:00
//printf("found xxx label of \"%s\"\n", label+(g_numLabels<<6));
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
lLabelID = C_GetLabelNameOffset ( & inputH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
//printf("LabelID is %d\n",lLabelID);
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( lLabelID = = - 1 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYMBOLNOTRECOGNIZED ) ;
continue ;
}
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = InputLabels [ lLabelID ] . lId ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
// now at target VAR...
// get the ID of the DEF
if ( tw = = CON_GETINPUT )
C_GetNextVarType ( GAMEVAR_READONLY ) ;
else
C_GetNextVar ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
case CON_SETUSERDEF :
case CON_GETUSERDEF :
{
int32_t lLabelID ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
// syntax [gs]etuserdef.x <VAR>
// gets the value of ud.xxx into <VAR>
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// now get name of .xxx
while ( * textptr ! = ' . ' )
{
if ( * textptr = = 0xa )
break ;
if ( ! * textptr )
break ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
textptr + + ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' . ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
continue ;
}
textptr + + ;
/// now pointing at 'xxx'
C_GetNextLabelName ( ) ;
2012-03-26 05:05:57 +00:00
//printf("found xxx label of \"%s\"\n", label+(g_numLabels<<6));
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
lLabelID = C_GetLabelNameID ( UserdefsLabels , & userdefH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
2006-11-13 23:12:47 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( lLabelID = = - 1 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYMBOLNOTRECOGNIZED ) ;
continue ;
}
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = lLabelID ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
// now at target VAR...
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
if ( tw = = CON_GETUSERDEF )
C_GetNextVarType ( GAMEVAR_READONLY ) ;
else
C_GetNextVar ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2008-06-05 02:29:18 +00:00
}
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
case CON_SETACTORVAR :
2006-11-16 03:02:42 +00:00
case CON_SETPLAYERVAR :
case CON_GETACTORVAR :
case CON_GETPLAYERVAR :
2011-04-07 01:16:29 +00:00
{
// syntax [gs]etactorvar[<var>].<varx> <VAR>
// gets the value of the per-actor variable varx into VAR
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// now get name of <var>
while ( ( * textptr ! = ' [ ' ) )
{
textptr + + ;
}
if ( * textptr = = ' [ ' )
textptr + + ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
g_labelsOnly = 1 ;
C_GetNextVar ( ) ;
g_labelsOnly = 0 ;
// now get name of .<varx>
while ( * textptr ! = ' . ' )
{
if ( * textptr = = 0xa )
break ;
if ( ! * textptr )
break ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
textptr + + ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' . ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
continue ;
}
textptr + + ;
2010-05-02 23:27:30 +00:00
2011-04-07 01:16:29 +00:00
if ( g_scriptPtr [ - 1 ] = = g_iThisActorID ) // convert to "setvarvar"
{
g_scriptPtr - - ;
g_scriptPtr [ - 1 ] = CON_SETVARVAR ;
if ( tw = = CON_SETACTORVAR | | tw = = CON_SETPLAYERVAR )
{
C_GetNextVarType ( GAMEVAR_READONLY ) ;
C_GetNextVar ( ) ;
}
else
{
g_scriptPtr + + ;
C_GetNextVar ( ) ;
g_scriptPtr - = 2 ;
C_GetNextVarType ( GAMEVAR_READONLY ) ;
g_scriptPtr + + ;
}
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
/// now pointing at 'xxx'
2010-05-02 23:27:30 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
C_GetNextLabelName ( ) ;
2012-03-26 05:05:57 +00:00
//printf("found label of \"%s\"\n", label+(g_numLabels<<6));
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
// Check to see if it's a keyword
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( hash_find ( & h_keywords , label + ( g_numLabels < < 6 ) ) > = 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_ISAKEYWORD ) ;
continue ;
}
2010-05-02 23:27:30 +00:00
2011-04-07 01:16:29 +00:00
i = GetDefID ( label + ( g_numLabels < < 6 ) ) ;
2012-03-26 05:05:57 +00:00
//printf("Label \"%s\" ID is %d\n",label+(g_numLabels<<6), i);
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i < 0 ) )
2011-04-07 01:16:29 +00:00
{
// not a defined DEF
g_numCompilerErrors + + ;
C_ReportError ( ERROR_NOTAGAMEVAR ) ;
continue ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( aGameVars [ i ] . dwFlags & GAMEVAR_READONLY ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_VARREADONLY ) ;
continue ;
}
2010-05-02 23:27:30 +00:00
2011-04-07 01:16:29 +00:00
switch ( tw )
{
case CON_SETACTORVAR :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ! ( aGameVars [ i ] . dwFlags & GAMEVAR_PERACTOR ) ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: error: variable `%s' is not per-actor. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
continue ;
}
break ;
case CON_SETPLAYERVAR :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ! ( aGameVars [ i ] . dwFlags & GAMEVAR_PERPLAYER ) ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: error: variable `%s' is not per-player. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
continue ;
}
break ;
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = i ; // the ID of the DEF (offset into array...)
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
switch ( tw )
{
case CON_GETACTORVAR :
case CON_GETPLAYERVAR :
C_GetNextVarType ( GAMEVAR_READONLY ) ;
break ;
default :
C_GetNextVar ( ) ;
break ;
}
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_SETACTOR :
case CON_GETACTOR :
{
int32_t lLabelID ;
2006-11-13 23:12:47 +00:00
2011-04-07 01:16:29 +00:00
// syntax getwall[<var>].x <VAR>
// gets the value of wall[<var>].xxx into <VAR>
2006-11-13 23:12:47 +00:00
2011-04-07 01:16:29 +00:00
// now get name of .xxx
while ( ( * textptr ! = ' [ ' ) )
textptr + + ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
if ( * textptr = = ' [ ' )
textptr + + ;
2008-07-13 07:10:47 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
g_labelsOnly = 1 ;
C_GetNextVar ( ) ;
g_labelsOnly = 0 ;
// now get name of .xxx
2008-07-13 07:10:47 +00:00
2011-04-07 01:16:29 +00:00
while ( * textptr ! = ' . ' )
{
if ( * textptr = = 0xa )
break ;
if ( ! * textptr )
break ;
2008-07-13 07:10:47 +00:00
2011-04-07 01:16:29 +00:00
textptr + + ;
}
2008-07-13 07:10:47 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' . ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
continue ;
}
textptr + + ;
/// now pointing at 'xxx'
C_GetNextLabelName ( ) ;
2012-03-26 05:05:57 +00:00
//printf("found xxx label of \"%s\"\n", label+(g_numLabels<<6));
2011-04-07 01:16:29 +00:00
lLabelID = C_GetLabelNameOffset ( & actorH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
//printf("LabelID is %d\n",lLabelID);
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( lLabelID = = - 1 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYMBOLNOTRECOGNIZED ) ;
continue ;
}
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = ActorLabels [ lLabelID ] . lId ;
//printf("member's flags are: %02Xh\n",ActorLabels[lLabelID].flags);
if ( ActorLabels [ lLabelID ] . flags & LABEL_HASPARM2 )
{
//printf("Member has PARM2\n");
// get parm2
// get the ID of the DEF
C_GetNextVar ( ) ;
}
// now at target VAR...
// get the ID of the DEF
if ( tw = = CON_GETACTOR )
C_GetNextVarType ( GAMEVAR_READONLY ) ;
else
C_GetNextVar ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2008-07-13 07:10:47 +00:00
2011-04-07 01:16:29 +00:00
case CON_GETTSPR :
case CON_SETTSPR :
{
int32_t lLabelID ;
2013-05-28 19:52:45 +00:00
#if 0
2014-10-25 03:36:34 +00:00
if ( unlikely ( g_currentEvent ! = EVENT_ANIMATESPRITES ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: warning: found `%s' outside of EVENT_ANIMATESPRITES \n " , g_szScriptFileName , g_lineNumber , tempbuf ) ;
g_numCompilerWarnings + + ;
}
2013-05-28 19:52:45 +00:00
# endif
2011-04-07 01:16:29 +00:00
// syntax getwall[<var>].x <VAR>
// gets the value of wall[<var>].xxx into <VAR>
2008-07-13 07:10:47 +00:00
2011-04-07 01:16:29 +00:00
// now get name of .xxx
while ( ( * textptr ! = ' [ ' ) )
{
textptr + + ;
}
if ( * textptr = = ' [ ' )
textptr + + ;
2008-07-13 07:10:47 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
g_labelsOnly = 1 ;
C_GetNextVar ( ) ;
g_labelsOnly = 0 ;
// now get name of .xxx
while ( * textptr ! = ' . ' )
{
if ( * textptr = = 0xa )
break ;
if ( ! * textptr )
break ;
2008-07-13 07:10:47 +00:00
2011-04-07 01:16:29 +00:00
textptr + + ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' . ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
continue ;
}
textptr + + ;
/// now pointing at 'xxx'
C_GetNextLabelName ( ) ;
2012-03-26 05:05:57 +00:00
//printf("found xxx label of \"%s\"\n", label+(g_numLabels<<6));
2008-07-13 07:10:47 +00:00
2011-04-07 01:16:29 +00:00
lLabelID = C_GetLabelNameOffset ( & tspriteH , Bstrtolower ( label + ( g_numLabels < < 6 ) ) ) ;
//printf("LabelID is %d\n",lLabelID);
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( lLabelID = = - 1 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYMBOLNOTRECOGNIZED ) ;
continue ;
}
2009-07-15 01:26:38 +00:00
2011-04-07 01:16:29 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = TsprLabels [ lLabelID ] . lId ;
2009-07-12 01:55:34 +00:00
2011-04-07 01:16:29 +00:00
//printf("member's flags are: %02Xh\n",ActorLabels[lLabelID].flags);
2006-08-28 19:18:05 +00:00
2011-04-07 01:16:29 +00:00
// now at target VAR...
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
if ( tw = = CON_GETTSPR )
C_GetNextVarType ( GAMEVAR_READONLY ) ;
else
C_GetNextVar ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2006-04-13 20:47:06 +00:00
2015-01-17 00:27:19 +00:00
case CON_RANDVARVAR :
case CON_SETVARVAR :
case CON_ADDVARVAR :
case CON_SUBVARVAR :
case CON_MULVARVAR :
case CON_DIVVARVAR :
case CON_MODVARVAR :
case CON_ANDVARVAR :
case CON_ORVARVAR :
case CON_XORVARVAR :
case CON_DISPLAYRANDVARVAR :
case CON_SIN :
case CON_COS :
case CON_QSTRLEN :
case CON_HEADSPRITESTAT :
case CON_PREVSPRITESTAT :
case CON_NEXTSPRITESTAT :
case CON_HEADSPRITESECT :
case CON_PREVSPRITESECT :
case CON_NEXTSPRITESECT :
2011-04-07 01:16:29 +00:00
case CON_SECTOROFWALL :
C_GetNextVarType ( GAMEVAR_READONLY ) ;
2015-01-17 00:27:19 +00:00
case CON_ADDLOGVAR :
2011-04-07 01:16:29 +00:00
case CON_ESHOOTVAR :
case CON_ESPAWNVAR :
case CON_QSPAWNVAR :
case CON_EQSPAWNVAR :
case CON_OPERATERESPAWNS :
case CON_OPERATEMASTERSWITCHES :
case CON_CHECKACTIVATORMOTION :
case CON_TIME :
case CON_INITTIMER :
case CON_LOCKPLAYER :
case CON_SHOOTVAR :
case CON_QUAKE :
case CON_JUMP :
case CON_CMENU :
case CON_SOUNDVAR :
case CON_GLOBALSOUNDVAR :
case CON_STOPSOUNDVAR :
2013-06-28 14:07:46 +00:00
case CON_SCREENSOUND :
2011-04-07 01:16:29 +00:00
case CON_SOUNDONCEVAR :
case CON_ANGOFFVAR :
case CON_CHECKAVAILWEAPON :
case CON_CHECKAVAILINVEN :
case CON_GUNIQHUDID :
case CON_SAVEGAMEVAR :
case CON_USERQUOTE :
2012-03-05 07:24:04 +00:00
case CON_ECHO :
2011-04-07 01:16:29 +00:00
case CON_STARTTRACKVAR :
case CON_CLEARMAPSTATE :
case CON_ACTIVATECHEAT :
case CON_SETGAMEPALETTE :
2015-01-17 00:27:19 +00:00
case CON_SECTSETINTERPOLATION :
case CON_SECTCLEARINTERPOLATION :
case CON_SETACTORANGLE :
case CON_SETPLAYERANGLE :
2015-01-17 00:28:49 +00:00
case CON_SETMUSICPOSITION :
2015-02-22 22:14:39 +00:00
case CON_STARTCUTSCENE :
2015-03-04 02:15:15 +00:00
case CON_RESETPLAYERFLAGS :
2011-04-07 01:16:29 +00:00
C_GetNextVar ( ) ;
continue ;
2015-01-17 00:27:19 +00:00
case CON_SQRT :
C_GetNextVar ( ) ;
case CON_FINDPLAYER :
case CON_FINDOTHERPLAYER :
case CON_DISPLAYRAND :
2013-02-25 15:31:05 +00:00
case CON_READGAMEVAR :
2015-01-17 00:27:19 +00:00
case CON_GETANGLETOTARGET :
case CON_GETACTORANGLE :
case CON_GETPLAYERANGLE :
case CON_GETTICKS :
case CON_GETCURRADDRESS :
2015-01-17 00:28:49 +00:00
case CON_GETMUSICPOSITION :
2013-02-25 15:31:05 +00:00
C_GetNextVarType ( GAMEVAR_READONLY ) ;
continue ;
2009-06-19 01:10:10 +00:00
2011-04-07 01:16:29 +00:00
case CON_ENHANCED :
// don't store in pCode...
2009-06-24 08:20:10 +00:00
g_scriptPtr - - ;
2011-04-07 01:16:29 +00:00
//printf("We are enhanced, baby...\n");
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * g_scriptPtr > BYTEVERSION_JF ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerWarnings + + ;
initprintf ( " %s:%d: warning: need build %d, found build %d \n " , g_szScriptFileName , g_lineNumber , k , BYTEVERSION_JF ) ;
}
2011-05-20 02:34:41 +00:00
continue ;
2009-06-19 01:10:10 +00:00
2011-04-07 01:16:29 +00:00
case CON_DYNAMICREMAP :
g_scriptPtr - - ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_dynamicTileMapping ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: warning: duplicate dynamicremap statement \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
}
2013-03-17 18:11:38 +00:00
else
2012-01-28 14:38:54 +00:00
# ifdef DYNTILEREMAP_ENABLE
2013-03-17 18:11:38 +00:00
initprintf ( " Using dynamic tile remapping \n " ) ;
g_dynamicTileMapping = 1 ;
2012-01-28 14:38:54 +00:00
# else
2012-01-28 15:16:14 +00:00
{
initprintf ( " %s:%d: warning: dynamic tile remapping is disabled in this build \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
}
2012-01-28 14:38:54 +00:00
# endif
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
2013-06-01 06:55:30 +00:00
case CON_DYNAMICSOUNDREMAP :
g_scriptPtr - - ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_dynamicSoundMapping ) )
2013-06-01 06:55:30 +00:00
{
initprintf ( " %s:%d: warning: duplicate dynamicsoundremap statement \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
}
else
# ifdef DYNSOUNDREMAP_ENABLE
initprintf ( " Using dynamic sound remapping \n " ) ;
g_dynamicSoundMapping = 1 ;
# else
{
initprintf ( " %s:%d: warning: dynamic sound remapping is disabled in this build \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
}
# endif
continue ;
2011-04-07 01:16:29 +00:00
case CON_RANDVAR :
case CON_ZSHOOT :
case CON_EZSHOOT :
case CON_SETVAR :
case CON_ADDVAR :
case CON_SUBVAR :
case CON_DISPLAYRANDVAR :
case CON_MULVAR :
case CON_DIVVAR :
case CON_MODVAR :
case CON_ANDVAR :
case CON_ORVAR :
case CON_XORVAR :
case CON_SHIFTVARL :
case CON_SHIFTVARR :
2009-06-24 08:20:10 +00:00
{
2011-04-07 01:16:29 +00:00
intptr_t * inst = g_scriptPtr - 1 ;
char * tptr = textptr ;
// syntax: [rand|add|set]var <var1> <const1>
// sets var1 to const1
// adds const1 to var1 (const1 can be negative...)
//printf("Found [add|set]var at line= %d\n",g_lineNumber);
2009-06-19 01:10:10 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
if ( tw ! = CON_ZSHOOT & & tw ! = CON_EZSHOOT )
C_GetNextVarType ( GAMEVAR_READONLY ) ;
else C_GetNextVar ( ) ;
2009-06-19 01:10:10 +00:00
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ; // the number to check against...
2009-08-28 23:08:00 +00:00
2011-04-07 01:16:29 +00:00
if ( tw = = CON_DIVVAR | | tw = = CON_MULVAR )
{
int32_t i = * ( g_scriptPtr - 1 ) ;
j = klabs ( i ) ;
2010-01-23 22:12:02 +00:00
2011-04-07 01:16:29 +00:00
if ( i = = - 1 )
{
* inst = CON_INV + ( g_lineNumber < < 12 ) ;
g_scriptPtr - - ;
continue ;
}
2010-05-02 23:27:30 +00:00
2011-04-07 01:16:29 +00:00
if ( C_IntPow2 ( j ) )
{
* inst = ( ( tw = = CON_DIVVAR ) ? CON_SHIFTVARR : CON_SHIFTVARL ) + ( g_lineNumber < < 12 ) ;
* ( g_scriptPtr - 1 ) = C_Pow2IntLogBase2 ( j ) ;
// initprintf("%s:%d: replacing multiply/divide with shift\n",g_szScriptFileName,g_lineNumber);
2010-05-02 23:27:30 +00:00
2011-04-07 01:16:29 +00:00
if ( i = = j )
continue ;
2009-02-19 09:39:19 +00:00
2011-04-07 01:16:29 +00:00
* g_scriptPtr + + = CON_INV + ( g_lineNumber < < 12 ) ;
textptr = tptr ;
C_GetNextVarType ( GAMEVAR_READONLY ) ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
// initprintf("%s:%d: adding inversion\n",g_szScriptFileName,g_lineNumber);
}
}
}
continue ;
2015-01-17 00:27:19 +00:00
2011-04-07 01:16:29 +00:00
case CON_WRITEARRAYTOFILE :
case CON_READARRAYFROMFILE :
C_GetNextLabelName ( ) ;
i = GetADefID ( label + ( g_numLabels < < 6 ) ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i < 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_NOTAGAMEARRAY ) ;
return 1 ;
}
2014-10-25 03:36:34 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = i ;
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
continue ;
2015-01-17 00:27:19 +00:00
2011-04-07 01:16:29 +00:00
case CON_COPY :
C_GetNextLabelName ( ) ;
i = GetADefID ( label + ( g_numLabels < < 6 ) ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i < 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_NOTAGAMEARRAY ) ;
return 1 ;
}
2014-10-25 03:36:34 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = i ;
2011-04-07 01:16:29 +00:00
C_SkipComments ( ) ; // skip comments and whitespace
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' [ ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_GAMEARRAYBNO ) ;
return 1 ;
}
textptr + + ;
2008-11-20 14:06:36 +00:00
C_GetNextVar ( ) ;
2011-04-07 01:16:29 +00:00
C_SkipComments ( ) ; // skip comments and whitespace
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' ] ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_GAMEARRAYBNC ) ;
return 1 ;
}
textptr + + ;
case CON_SETARRAY :
C_GetNextLabelName ( ) ;
i = GetADefID ( label + ( g_numLabels < < 6 ) ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i < 0 ) )
2011-04-07 01:16:29 +00:00
{
2014-10-25 03:36:34 +00:00
g_numCompilerErrors + + ;
C_ReportError ( ERROR_NOTAGAMEARRAY ) ;
return 1 ;
2011-04-07 01:16:29 +00:00
}
2014-10-25 03:36:34 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = i ;
if ( EDUKE32_PREDICT_FALSE ( aGameArrays [ i ] . dwFlags & GAMEARRAY_READONLY ) )
2011-04-07 01:16:29 +00:00
{
2014-10-25 03:36:34 +00:00
C_ReportError ( ERROR_ARRAYREADONLY ) ;
2011-04-07 01:16:29 +00:00
g_numCompilerErrors + + ;
return 1 ;
}
C_SkipComments ( ) ; // skip comments and whitespace
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' [ ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_GAMEARRAYBNO ) ;
return 1 ;
}
textptr + + ;
C_GetNextVar ( ) ;
C_SkipComments ( ) ; // skip comments and whitespace
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = ' ] ' ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_GAMEARRAYBNC ) ;
return 1 ;
}
textptr + + ;
C_GetNextVar ( ) ;
continue ;
2015-01-17 00:27:19 +00:00
2011-04-07 01:16:29 +00:00
case CON_GETARRAYSIZE :
case CON_RESIZEARRAY :
C_GetNextLabelName ( ) ;
i = GetADefID ( label + ( g_numLabels < < 6 ) ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i < 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_NOTAGAMEARRAY ) ;
return 1 ;
}
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = i ;
if ( tw = = CON_RESIZEARRAY & & ( aGameArrays [ i ] . dwFlags & GAMEARRAY_TYPE_MASK ) )
{
C_ReportError ( - 1 ) ;
initprintf ( " can't resize system array `%s'. " , label + ( g_numLabels < < 6 ) ) ;
return 1 ;
}
2011-04-07 01:16:29 +00:00
C_SkipComments ( ) ;
2012-04-07 20:09:44 +00:00
C_GetNextVarType ( tw = = CON_GETARRAYSIZE ? GAMEVAR_READONLY : 0 ) ;
2011-04-07 01:16:29 +00:00
continue ;
case CON_SMAXAMMO :
case CON_ADDWEAPONVAR :
case CON_ACTIVATEBYSECTOR :
case CON_OPERATESECTORS :
case CON_OPERATEACTIVATORS :
case CON_SSP :
case CON_GMAXAMMO :
2006-04-16 03:42:36 +00:00
case CON_DIST :
case CON_LDIST :
2006-11-16 03:02:42 +00:00
case CON_GETINCANGLE :
2011-04-07 01:16:29 +00:00
case CON_GETANGLE :
2006-04-16 03:42:36 +00:00
case CON_MULSCALE :
2011-04-07 01:16:29 +00:00
case CON_SETASPECT :
// get the ID of the DEF
switch ( tw )
{
case CON_DIST :
case CON_LDIST :
case CON_GETANGLE :
case CON_GETINCANGLE :
2012-04-22 19:11:01 +00:00
case CON_MULSCALE :
2011-04-07 01:16:29 +00:00
C_GetNextVarType ( GAMEVAR_READONLY ) ;
break ;
default :
C_GetNextVar ( ) ;
break ;
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
if ( tw = = CON_GMAXAMMO )
C_GetNextVarType ( GAMEVAR_READONLY ) ;
else C_GetNextVar ( ) ;
2006-11-13 23:12:47 +00:00
2011-04-07 01:16:29 +00:00
switch ( tw )
{
case CON_DIST :
case CON_LDIST :
case CON_GETANGLE :
case CON_GETINCANGLE :
C_GetNextVar ( ) ;
break ;
case CON_MULSCALE :
C_GetManyVars ( 2 ) ;
break ;
}
continue ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
case CON_FLASH :
case CON_SAVEMAPSTATE :
case CON_LOADMAPSTATE :
2011-08-03 17:22:46 +00:00
if ( tw ! = CON_FLASH )
{
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_currentEvent = = EVENT_ANIMATESPRITES ) )
2011-08-03 17:22:46 +00:00
{
initprintf ( " %s:%d: warning: found `%s' inside EVENT_ANIMATESPRITES \n " ,
g_szScriptFileName , g_lineNumber , tempbuf ) ;
g_numCompilerWarnings + + ;
}
}
2011-04-07 01:16:29 +00:00
continue ;
2006-11-16 03:02:42 +00:00
2013-05-23 18:28:04 +00:00
case CON_ACTIVATE :
2013-05-25 20:25:39 +00:00
* ( g_scriptPtr - 1 ) = CON_OPERATEACTIVATORS ;
2013-05-23 18:28:04 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
2013-05-25 20:25:39 +00:00
* g_scriptPtr + + = 0 ;
2013-05-23 18:28:04 +00:00
continue ;
2011-04-07 01:16:29 +00:00
case CON_GETFLORZOFSLOPE :
case CON_GETCEILZOFSLOPE :
C_GetManyVars ( 3 ) ;
C_GetNextVarType ( GAMEVAR_READONLY ) ;
continue ;
2006-11-13 23:12:47 +00:00
2011-04-07 01:16:29 +00:00
case CON_DEFINEPROJECTILE :
{
int32_t y , z ;
2006-11-13 23:12:47 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_processingState | | g_parsingActorPtr ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_FOUNDWITHIN ) ;
g_numCompilerErrors + + ;
}
2006-11-13 23:12:47 +00:00
2011-04-07 01:16:29 +00:00
g_scriptPtr - - ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
j = * ( g_scriptPtr - 1 ) ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
y = * ( g_scriptPtr - 1 ) ;
C_GetNextValue ( LABEL_DEFINE ) ;
z = * ( g_scriptPtr - 1 ) ;
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > = MAXTILES ) )
2012-05-13 16:05:34 +00:00
{
C_ReportError ( ERROR_EXCEEDSMAXTILES ) ;
g_numCompilerErrors + + ;
continue ;
}
2013-02-07 21:01:03 +00:00
C_DefineProjectile ( j , y , z ) ;
2011-04-07 01:16:29 +00:00
continue ;
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_SPRITEFLAGS :
if ( g_parsingActorPtr = = NULL & & g_processingState = = 0 )
{
g_scriptPtr - - ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
j = * g_scriptPtr ;
2006-11-13 23:12:47 +00:00
2014-12-26 17:29:58 +00:00
int32_t flags = 0 ;
do
C_BitOrNextValue ( & flags ) ;
while ( C_GetKeyword ( ) = = - 1 ) ;
2012-05-13 16:05:34 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > = MAXTILES ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_EXCEEDSMAXTILES ) ;
g_numCompilerErrors + + ;
2012-05-13 16:05:34 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2006-11-13 23:12:47 +00:00
2014-12-26 17:29:58 +00:00
g_tile [ j ] . flags = flags ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
continue ;
}
C_GetNextVar ( ) ;
continue ;
2006-04-13 20:47:06 +00:00
2006-11-13 23:12:47 +00:00
case CON_SPRITESHADOW :
case CON_SPRITENVG :
case CON_SPRITENOSHADE :
2007-10-24 07:12:50 +00:00
case CON_SPRITENOPAL :
2006-11-13 23:12:47 +00:00
case CON_PRECACHE :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_processingState | | g_parsingActorPtr ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_FOUNDWITHIN ) ;
g_numCompilerErrors + + ;
}
g_scriptPtr - - ;
2008-11-20 14:06:36 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
2011-04-07 01:16:29 +00:00
j = * g_scriptPtr ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > = MAXTILES ) )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
C_ReportError ( ERROR_EXCEEDSMAXTILES ) ;
g_numCompilerErrors + + ;
2012-05-13 16:05:34 +00:00
continue ;
2006-04-13 20:47:06 +00:00
}
2011-04-07 01:16:29 +00:00
switch ( tw )
{
case CON_SPRITESHADOW :
2014-02-22 19:38:52 +00:00
g_tile [ * g_scriptPtr ] . flags | = SFLAG_SHADOW ;
2011-04-07 01:16:29 +00:00
break ;
case CON_SPRITENVG :
2014-02-22 19:38:52 +00:00
g_tile [ * g_scriptPtr ] . flags | = SFLAG_NVG ;
2011-04-07 01:16:29 +00:00
break ;
case CON_SPRITENOSHADE :
2014-02-22 19:38:52 +00:00
g_tile [ * g_scriptPtr ] . flags | = SFLAG_NOSHADE ;
2011-04-07 01:16:29 +00:00
break ;
case CON_SPRITENOPAL :
2014-02-22 19:38:52 +00:00
g_tile [ * g_scriptPtr ] . flags | = SFLAG_NOPAL ;
2011-04-07 01:16:29 +00:00
break ;
case CON_PRECACHE :
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
i = * g_scriptPtr ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) i > = MAXTILES ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_EXCEEDSMAXTILES ) ;
g_numCompilerErrors + + ;
}
2012-11-15 14:28:00 +00:00
g_tile [ j ] . cacherange = i ;
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
2012-11-15 14:28:00 +00:00
if ( * g_scriptPtr )
2014-02-22 19:38:52 +00:00
g_tile [ j ] . flags | = SFLAG_CACHE ;
2012-11-15 14:28:00 +00:00
2011-04-07 01:16:29 +00:00
break ;
}
continue ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
case CON_IFACTORSOUND :
case CON_IFVARVARG :
case CON_IFVARVARL :
case CON_IFVARVARE :
case CON_IFVARVARN :
case CON_IFVARVARAND :
case CON_IFVARVAROR :
case CON_IFVARVARXOR :
case CON_IFVARVAREITHER :
case CON_WHILEVARVARN :
{
intptr_t offset ;
intptr_t lastScriptPtr = g_scriptPtr - & script [ 0 ] - 1 ;
2007-08-29 04:01:21 +00:00
2011-04-07 01:16:29 +00:00
g_ifElseAborted = 0 ;
2009-06-18 05:57:10 +00:00
2011-04-07 01:16:29 +00:00
C_GetManyVars ( 2 ) ;
2009-06-18 05:57:10 +00:00
2011-04-07 01:16:29 +00:00
if ( C_CheckMalformedBranch ( lastScriptPtr ) )
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
tempscrptr = g_scriptPtr ;
offset = ( unsigned ) ( g_scriptPtr - script ) ;
g_scriptPtr + + ; // Leave a spot for the fail location
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
C_ParseCommand ( 0 ) ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
if ( C_CheckEmptyBranch ( tw , lastScriptPtr ) )
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
tempscrptr = ( intptr_t * ) script + offset ;
* tempscrptr = ( intptr_t ) g_scriptPtr ;
bitptr [ ( tempscrptr - script ) > > 3 ] | = ( BITPTR_POINTER < < ( ( tempscrptr - script ) & 7 ) ) ;
2009-01-05 14:43:12 +00:00
2011-04-07 01:16:29 +00:00
if ( tw ! = CON_WHILEVARVARN )
{
j = C_GetKeyword ( ) ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
if ( j = = CON_ELSE | | j = = CON_LEFTBRACE )
g_checkingIfElse + + ;
}
continue ;
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_STARTTRACK :
// one parameter (track#)
C_GetNextValue ( LABEL_DEFINE ) ;
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_IFVARL :
case CON_IFVARG :
case CON_IFVARE :
case CON_IFVARN :
case CON_IFVARAND :
case CON_IFVAROR :
case CON_IFVARXOR :
case CON_IFVAREITHER :
case CON_WHILEVARN :
{
intptr_t offset ;
intptr_t lastScriptPtr = ( g_scriptPtr - script - 1 ) ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
g_ifElseAborted = 0 ;
// get the ID of the DEF
C_GetNextVar ( ) ;
C_GetNextValue ( LABEL_DEFINE ) ; // the number to check against...
2009-06-18 05:57:10 +00:00
2011-04-07 01:16:29 +00:00
if ( C_CheckMalformedBranch ( lastScriptPtr ) )
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
tempscrptr = g_scriptPtr ;
offset = ( unsigned ) ( tempscrptr - script ) ;
g_scriptPtr + + ; //Leave a spot for the fail location
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
C_ParseCommand ( 0 ) ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
if ( C_CheckEmptyBranch ( tw , lastScriptPtr ) )
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
tempscrptr = ( intptr_t * ) script + offset ;
* tempscrptr = ( intptr_t ) g_scriptPtr ;
bitptr [ ( tempscrptr - script ) > > 3 ] | = ( BITPTR_POINTER < < ( ( tempscrptr - script ) & 7 ) ) ;
2009-01-05 14:43:12 +00:00
2011-04-07 01:16:29 +00:00
if ( tw ! = CON_WHILEVARN )
{
j = C_GetKeyword ( ) ;
2009-01-05 14:43:12 +00:00
2011-04-07 01:16:29 +00:00
if ( j = = CON_ELSE | | j = = CON_LEFTBRACE )
g_checkingIfElse + + ;
}
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
continue ;
}
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
case CON_ROTATESPRITE16 :
case CON_ROTATESPRITE :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_parsingEventPtr = = NULL & & g_processingState = = 0 ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_EVENTONLY ) ;
g_numCompilerErrors + + ;
}
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
// syntax:
// int32_t x, int32_t y, int32_t z, short a, short tilenum, int8_t shade, char orientation, x1, y1, x2, y2
// myospal adds char pal
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEFs
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
C_GetManyVars ( 12 ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-11-16 03:02:42 +00:00
2013-03-25 04:33:03 +00:00
case CON_ROTATESPRITEA :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_parsingEventPtr = = NULL & & g_processingState = = 0 ) )
2013-03-25 04:33:03 +00:00
{
C_ReportError ( ERROR_EVENTONLY ) ;
g_numCompilerErrors + + ;
}
C_GetManyVars ( 13 ) ;
continue ;
2011-04-07 01:16:29 +00:00
case CON_SHOWVIEW :
2012-03-31 11:22:00 +00:00
case CON_SHOWVIEWUNBIASED :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_parsingEventPtr = = NULL & & g_processingState = = 0 ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_EVENTONLY ) ;
g_numCompilerErrors + + ;
}
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
C_GetManyVars ( 10 ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
case CON_GETZRANGE :
C_GetManyVars ( 4 ) ;
C_GetManyVarsType ( GAMEVAR_READONLY , 4 ) ;
C_GetManyVars ( 2 ) ;
2011-05-20 02:34:41 +00:00
continue ;
2007-02-08 04:19:39 +00:00
2011-04-07 01:16:29 +00:00
case CON_CLIPMOVE :
case CON_CLIPMOVENOSLIDE :
// <retvar>,<x>,<y>,z,<sectnum>, xvect,yvect,walldist,floordist,ceildist,clipmask
C_GetManyVarsType ( GAMEVAR_READONLY , 3 ) ;
2008-11-20 14:06:36 +00:00
C_GetNextVar ( ) ;
2011-04-07 01:16:29 +00:00
C_GetNextVarType ( GAMEVAR_READONLY ) ;
C_GetManyVars ( 6 ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_CALCHYPOTENUSE :
C_GetNextVarType ( GAMEVAR_READONLY ) ;
C_GetManyVars ( 2 ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_LINEINTERSECT :
case CON_RAYINTERSECT :
// lineintersect x y z x y z x y x y <intx> <inty> <intz> <ret>
// rayintersect x y z vx vy vz x y x y <intx> <inty> <intz> <ret>
C_GetManyVars ( 10 ) ;
C_GetManyVarsType ( GAMEVAR_READONLY , 4 ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_HITSCAN :
case CON_CANSEE :
2006-11-16 03:02:42 +00:00
// get the ID of the DEF
2011-04-07 01:16:29 +00:00
C_GetManyVars ( tw = = CON_CANSEE ? 8 : 7 ) ;
C_GetManyVarsType ( GAMEVAR_READONLY , tw = = CON_CANSEE ? 1 : 6 ) ;
if ( tw = = CON_HITSCAN ) C_GetNextVar ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_CANSEESPR :
C_GetManyVars ( 2 ) ;
C_GetNextVarType ( GAMEVAR_READONLY ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_NEARTAG :
C_GetManyVars ( 5 ) ;
C_GetManyVarsType ( GAMEVAR_READONLY , 4 ) ;
C_GetManyVars ( 2 ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_ROTATEPOINT :
C_GetManyVars ( 5 ) ;
C_GetManyVarsType ( GAMEVAR_READONLY , 2 ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
case CON_GETTIMEDATE :
C_GetManyVarsType ( GAMEVAR_READONLY , 8 ) ;
2011-05-20 02:34:41 +00:00
continue ;
2007-08-29 04:01:21 +00:00
2011-04-07 01:16:29 +00:00
case CON_MOVESPRITE :
case CON_SETSPRITE :
C_GetManyVars ( 4 ) ;
if ( tw = = CON_MOVESPRITE )
{
C_GetNextVar ( ) ;
C_GetNextVarType ( GAMEVAR_READONLY ) ;
}
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_MINITEXT :
case CON_GAMETEXT :
case CON_GAMETEXTZ :
case CON_DIGITALNUMBER :
case CON_DIGITALNUMBERZ :
2013-06-01 06:55:00 +00:00
case CON_SCREENTEXT :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_parsingEventPtr = = NULL & & g_processingState = = 0 ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_EVENTONLY ) ;
g_numCompilerErrors + + ;
}
switch ( tw )
{
2013-06-01 06:55:00 +00:00
case CON_SCREENTEXT :
C_GetManyVars ( 8 ) ;
2011-04-07 01:16:29 +00:00
case CON_GAMETEXTZ :
case CON_DIGITALNUMBERZ :
C_GetManyVars ( 1 ) ;
case CON_GAMETEXT :
case CON_DIGITALNUMBER :
C_GetManyVars ( 6 ) ;
default :
C_GetManyVars ( 5 ) ;
break ;
}
2011-05-20 02:34:41 +00:00
continue ;
2008-11-20 14:06:36 +00:00
2011-04-07 01:16:29 +00:00
case CON_UPDATESECTOR :
case CON_UPDATESECTORZ :
C_GetManyVars ( 2 ) ;
if ( tw = = CON_UPDATESECTORZ )
C_GetNextVar ( ) ;
C_GetNextVarType ( GAMEVAR_READONLY ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_MYOS :
case CON_MYOSPAL :
case CON_MYOSX :
case CON_MYOSPALX :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_parsingEventPtr = = NULL & & g_processingState = = 0 ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_EVENTONLY ) ;
g_numCompilerErrors + + ;
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// syntax:
// int32_t x, int32_t y, short tilenum, int8_t shade, char orientation
// myospal adds char pal
2007-08-31 06:18:56 +00:00
2011-04-07 01:16:29 +00:00
C_GetManyVars ( 5 ) ;
if ( tw = = CON_MYOSPAL | | tw = = CON_MYOSPALX )
{
// Parse: pal
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
// get the ID of the DEF
C_GetNextVar ( ) ;
}
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_SWITCH :
2008-01-26 03:59:34 +00:00
{
2011-04-07 01:16:29 +00:00
intptr_t tempoffset ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
g_checkingSwitch + + ; // allow nesting (if other things work)
C_GetNextVar ( ) ;
tempscrptr = g_scriptPtr ;
tempoffset = ( unsigned ) ( tempscrptr - script ) ;
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = 0 ; // leave spot for end location (for after processing)
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = 0 ; // count of case statements
g_caseScriptPtr = g_scriptPtr ; // the first case's pointer.
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = 0 ; // leave spot for 'default' location (null if none)
2011-10-17 18:42:10 +00:00
// temptextptr=textptr;
2011-04-07 01:16:29 +00:00
// probably does not allow nesting...
j = C_CountCaseStatements ( ) ;
// initprintf("Done Counting Case Statements for switch %d: found %d.\n", g_checkingSwitch,j);
g_scriptPtr + = j * 2 ;
C_SkipComments ( ) ;
g_scriptPtr - = j * 2 ; // allocate buffer for the table
tempscrptr = ( intptr_t * ) ( script + tempoffset ) ;
2010-03-02 22:49:26 +00:00
2011-04-07 01:16:29 +00:00
//AddLog(g_szBuf);
2010-03-02 22:49:26 +00:00
2011-04-07 01:16:29 +00:00
if ( j < 0 )
{
return 1 ;
}
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
if ( tempscrptr )
2007-12-20 19:14:38 +00:00
{
2011-04-07 01:16:29 +00:00
tempscrptr [ 1 ] = ( intptr_t ) j ; // save count of cases
}
else
{
//Bsprintf(g_szBuf,"ERROR::%s %d",__FILE__,__LINE__);
//AddLog(g_szBuf);
2007-12-20 19:14:38 +00:00
}
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
while ( j - - )
{
// leave room for statements
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = 0 ; // value check
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = 0 ; // code offset
C_SkipComments ( ) ;
}
2010-03-02 22:49:26 +00:00
2011-04-07 01:16:29 +00:00
g_numCases = 0 ;
2011-05-20 02:34:41 +00:00
C_ParseCommand ( 1 ) ;
2008-02-17 05:08:18 +00:00
tempscrptr = ( intptr_t * ) ( script + tempoffset ) ;
2010-03-03 01:37:27 +00:00
2011-04-07 01:16:29 +00:00
//Bsprintf(g_szBuf,"SWITCHXX: '%.22s'",textptr);
//AddLog(g_szBuf);
// done processing switch. clean up.
if ( g_checkingSwitch < 1 )
{
// Bsprintf(g_szBuf,"ERROR::%s %d: g_checkingSwitch=%d",__FILE__,__LINE__, g_checkingSwitch);
// AddLog(g_szBuf);
}
g_numCases = 0 ;
if ( tempscrptr )
{
intptr_t t , n ;
for ( i = 3 ; i < 3 + tempscrptr [ 1 ] * 2 - 2 ; i + = 2 ) // sort them
{
t = tempscrptr [ i ] ; n = i ;
for ( j = i + 2 ; j < 3 + tempscrptr [ 1 ] * 2 ; j + = 2 )
if ( tempscrptr [ j ] < t ) { t = tempscrptr [ j ] ; n = j ; }
if ( n ! = i )
{
t = tempscrptr [ i ] ; tempscrptr [ i ] = tempscrptr [ n ] ; tempscrptr [ n ] = t ;
t = tempscrptr [ i + 1 ] ; tempscrptr [ i + 1 ] = tempscrptr [ n + 1 ] ; tempscrptr [ n + 1 ] = t ;
}
}
// for (j=3;j<3+tempscrptr[1]*2;j+=2)initprintf("%5d %8x\n",tempscrptr[j],tempscrptr[j+1]);
tempscrptr [ 0 ] = ( intptr_t ) g_scriptPtr - ( intptr_t ) & script [ 0 ] ; // save 'end' location
// bitptr[(tempscrptr-script)>>3] |= (BITPTR_POINTER<<((tempscrptr-script)&7));
}
else
{
//Bsprintf(g_szBuf,"ERROR::%s %d",__FILE__,__LINE__);
//AddLog(g_szBuf);
}
g_caseScriptPtr = NULL ;
// decremented in endswitch. Don't decrement here...
// g_checkingSwitch--; // allow nesting (maybe if other things work)
tempscrptr = NULL ;
if ( g_checkingSwitch )
{
//Bsprintf(g_szBuf,"ERROR::%s %d: g_checkingSwitch=%d",__FILE__,__LINE__, g_checkingSwitch);
//AddLog(g_szBuf);
}
//AddLog("End of Switch statement");
}
2011-05-20 02:34:41 +00:00
continue ;
2010-03-03 01:37:27 +00:00
2011-04-07 01:16:29 +00:00
case CON_CASE :
{
intptr_t tempoffset = 0 ;
//AddLog("Found Case");
2006-11-16 03:02:42 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_checkingSwitch < 1 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: error: found `case' statement when not in switch \n " , g_szScriptFileName , g_lineNumber ) ;
g_scriptPtr - - ;
return 1 ;
}
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
repeatcase :
g_scriptPtr - - ; // don't save in code
g_numCases + + ;
//Bsprintf(g_szBuf,"case1: %.12s",textptr);
//AddLog(g_szBuf);
C_GetNextValue ( LABEL_DEFINE ) ;
if ( * textptr = = ' : ' )
textptr + + ;
//Bsprintf(g_szBuf,"case2: %.12s",textptr);
//AddLog(g_szBuf);
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
j = * ( - - g_scriptPtr ) ; // get value
//Bsprintf(g_szBuf,"case: Value of case %d is %d",(int32_t)g_numCases,(int32_t)j);
//AddLog(g_szBuf);
if ( g_caseScriptPtr )
{
for ( i = ( g_numCases / 2 ) - 1 ; i > = 0 ; i - - )
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_caseScriptPtr [ i * 2 + 1 ] = = j ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerWarnings + + ;
C_ReportError ( WARNING_DUPLICATECASE ) ;
break ;
}
//AddLog("Adding value to script");
g_caseScriptPtr [ g_numCases + + ] = j ; // save value
g_caseScriptPtr [ g_numCases ] = ( intptr_t ) ( ( intptr_t * ) g_scriptPtr - & script [ 0 ] ) ; // save offset
}
// j = C_GetKeyword();
//Bsprintf(g_szBuf,"case3: %.12s",textptr);
//AddLog(g_szBuf);
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
if ( C_GetKeyword ( ) = = CON_CASE )
{
//AddLog("Found Repeat Case");
C_GetNextKeyword ( ) ; // eat 'case'
goto repeatcase ;
}
//Bsprintf(g_szBuf,"case4: '%.12s'",textptr);
//AddLog(g_szBuf);
tempoffset = ( unsigned ) ( tempscrptr - script ) ;
2006-04-13 20:47:06 +00:00
2011-05-20 02:34:41 +00:00
while ( C_ParseCommand ( 0 ) = = 0 )
2011-04-07 01:16:29 +00:00
{
//Bsprintf(g_szBuf,"case5 '%.25s'",textptr);
//AddLog(g_szBuf);
if ( C_GetKeyword ( ) = = CON_CASE )
{
//AddLog("Found Repeat Case");
C_GetNextKeyword ( ) ; // eat 'case'
tempscrptr = ( intptr_t * ) ( script + tempoffset ) ;
goto repeatcase ;
}
}
tempscrptr = ( intptr_t * ) ( script + tempoffset ) ;
//AddLog("End Case");
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
// break;
}
case CON_DEFAULT :
g_scriptPtr - - ; // don't save
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
C_SkipComments ( ) ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
if ( * textptr = = ' : ' )
textptr + + ;
2009-01-04 22:22:33 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_checkingSwitch < 1 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: error: found `default' statement when not in switch \n " , g_szScriptFileName , g_lineNumber ) ;
return 1 ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_caseScriptPtr & & g_caseScriptPtr [ 0 ] ! = 0 ) )
2006-08-03 03:14:43 +00:00
{
2011-04-07 01:16:29 +00:00
// duplicate default statement
g_numCompilerErrors + + ;
2008-11-20 14:06:36 +00:00
C_ReportError ( - 1 ) ;
2011-04-07 01:16:29 +00:00
initprintf ( " %s:%d: error: multiple `default' statements found in switch \n " , g_szScriptFileName , g_lineNumber ) ;
2006-08-03 03:14:43 +00:00
}
2011-04-07 01:16:29 +00:00
if ( g_caseScriptPtr )
2009-01-04 22:22:33 +00:00
{
2011-04-07 01:16:29 +00:00
g_caseScriptPtr [ 0 ] = ( intptr_t ) ( g_scriptPtr - & script [ 0 ] ) ; // save offset
// bitptr[(g_caseScriptPtr-script)>>3] |= (BITPTR_POINTER<<((g_caseScriptPtr-script)&7));
2009-01-04 22:22:33 +00:00
}
2011-04-07 01:16:29 +00:00
//Bsprintf(g_szBuf,"default: '%.22s'",textptr);
//AddLog(g_szBuf);
2011-05-20 02:34:41 +00:00
C_ParseCommand ( 1 ) ;
continue ;
2009-06-18 05:57:10 +00:00
2011-04-07 01:16:29 +00:00
case CON_ENDSWITCH :
//AddLog("End Switch");
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( - - g_checkingSwitch < 0 ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: error: found `endswitch' without matching `switch' \n " , g_szScriptFileName , g_lineNumber ) ;
}
return 1 ; // end of block
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
case CON_QSTRNCAT :
2015-01-17 00:27:19 +00:00
case CON_DRAGPOINT :
case CON_GETKEYNAME :
case CON_SETACTORSOUNDPITCH :
2011-04-07 01:16:29 +00:00
C_GetManyVars ( 3 ) ;
continue ;
2015-01-17 00:27:19 +00:00
2011-04-07 01:16:29 +00:00
case CON_CHANGESPRITESTAT :
case CON_CHANGESPRITESECT :
case CON_ZSHOOTVAR :
case CON_EZSHOOTVAR :
case CON_GETPNAME :
case CON_STARTLEVEL :
case CON_QSTRCAT :
case CON_QSTRCPY :
case CON_QGETSYSSTR :
2015-01-17 00:27:19 +00:00
case CON_STOPACTORSOUND :
2013-01-24 20:02:52 +00:00
C_GetManyVars ( 2 ) ;
continue ;
2015-01-17 00:27:19 +00:00
2013-06-01 06:55:00 +00:00
case CON_QSTRDIM :
C_GetNextVarType ( GAMEVAR_READONLY ) ;
C_GetNextVarType ( GAMEVAR_READONLY ) ;
C_GetManyVars ( 16 ) ;
continue ;
2015-01-17 00:27:19 +00:00
2011-04-07 01:16:29 +00:00
case CON_QSUBSTR :
C_GetManyVars ( 4 ) ;
continue ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
case CON_IFRND :
case CON_IFPDISTL :
case CON_IFPDISTG :
case CON_IFWASWEAPON :
case CON_IFACTIONCOUNT :
case CON_IFCOUNT :
case CON_IFACTOR :
case CON_IFSTRENGTH :
case CON_IFSPAWNEDBY :
case CON_IFGAPZL :
case CON_IFFLOORDISTL :
case CON_IFCEILINGDISTL :
// case 74:
case CON_IFPHEALTHL :
case CON_IFSPRITEPAL :
case CON_IFGOTWEAPONCE :
case CON_IFANGDIFFL :
case CON_IFSOUND :
case CON_IFAI :
case CON_IFACTION :
case CON_IFMOVE :
case CON_IFP :
case CON_IFPINVENTORY :
2013-05-23 18:28:04 +00:00
case CON_IFPLAYERSL :
2015-02-11 05:22:07 +00:00
case CON_IFCUTSCENE :
2011-04-07 01:16:29 +00:00
{
intptr_t offset ;
intptr_t lastScriptPtr = ( g_scriptPtr - & script [ 0 ] - 1 ) ;
2009-01-05 14:43:12 +00:00
2011-04-07 01:16:29 +00:00
g_ifElseAborted = 0 ;
2009-01-05 14:43:12 +00:00
2011-04-07 01:16:29 +00:00
switch ( tw )
{
2015-02-11 05:22:07 +00:00
case CON_IFCUTSCENE :
C_GetNextVar ( ) ;
break ;
2011-04-07 01:16:29 +00:00
case CON_IFAI :
C_GetNextValue ( LABEL_AI ) ;
break ;
case CON_IFACTION :
C_GetNextValue ( LABEL_ACTION ) ;
break ;
case CON_IFMOVE :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( C_GetNextValue ( LABEL_MOVE | LABEL_DEFINE ) = = 0 ) & & ( * ( g_scriptPtr - 1 ) ! = 0 ) & & ( * ( g_scriptPtr - 1 ) ! = 1 ) ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( - 1 ) ;
* ( g_scriptPtr - 1 ) = 0 ;
initprintf ( " %s:%d: warning: expected a move, found a constant. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
}
break ;
case CON_IFPINVENTORY :
C_GetNextValue ( LABEL_DEFINE ) ;
C_GetNextValue ( LABEL_DEFINE ) ;
break ;
case CON_IFP :
j = 0 ;
do
2014-12-26 17:29:57 +00:00
C_BitOrNextValue ( & j ) ;
2011-04-07 01:16:29 +00:00
while ( C_GetKeyword ( ) = = - 1 ) ;
2014-12-26 17:29:57 +00:00
C_FinishBitOr ( j ) ;
2011-04-07 01:16:29 +00:00
break ;
case CON_IFSOUND :
case CON_IFACTORSOUND :
default :
C_GetNextValue ( LABEL_DEFINE ) ;
break ;
}
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
if ( C_CheckMalformedBranch ( lastScriptPtr ) )
continue ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
tempscrptr = g_scriptPtr ;
offset = ( unsigned ) ( tempscrptr - script ) ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
g_scriptPtr + + ; //Leave a spot for the fail location
2009-06-18 05:57:10 +00:00
2011-04-07 01:16:29 +00:00
C_ParseCommand ( 0 ) ;
2007-08-29 04:01:21 +00:00
2011-04-07 01:16:29 +00:00
if ( C_CheckEmptyBranch ( tw , lastScriptPtr ) )
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
tempscrptr = ( intptr_t * ) script + offset ;
* tempscrptr = ( intptr_t ) g_scriptPtr ;
bitptr [ ( tempscrptr - script ) > > 3 ] | = ( BITPTR_POINTER < < ( ( tempscrptr - script ) & 7 ) ) ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
j = C_GetKeyword ( ) ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
if ( j = = CON_ELSE | | j = = CON_LEFTBRACE )
g_checkingIfElse + + ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
continue ;
}
2009-01-05 14:43:12 +00:00
2011-04-07 01:16:29 +00:00
case CON_IFCLIENT :
case CON_IFSERVER :
case CON_IFONWATER :
case CON_IFINWATER :
case CON_IFACTORNOTSTAYPUT :
case CON_IFCANSEE :
case CON_IFHITWEAPON :
case CON_IFSQUISHED :
case CON_IFDEAD :
case CON_IFCANSHOOTTARGET :
case CON_IFHITSPACE :
case CON_IFOUTSIDE :
case CON_IFMULTIPLAYER :
case CON_IFINSPACE :
case CON_IFBULLETNEAR :
case CON_IFRESPAWN :
case CON_IFINOUTERSPACE :
case CON_IFNOTMOVING :
case CON_IFAWAYFROMWALL :
case CON_IFCANSEETARGET :
case CON_IFNOSOUNDS :
{
intptr_t offset ;
intptr_t lastScriptPtr = ( g_scriptPtr - & script [ 0 ] - 1 ) ;
2009-01-05 14:43:12 +00:00
2011-04-07 01:16:29 +00:00
g_ifElseAborted = 0 ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
if ( C_CheckMalformedBranch ( lastScriptPtr ) )
continue ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
tempscrptr = g_scriptPtr ;
offset = ( unsigned ) ( tempscrptr - script ) ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
g_scriptPtr + + ; //Leave a spot for the fail location
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
C_ParseCommand ( 0 ) ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
if ( C_CheckEmptyBranch ( tw , lastScriptPtr ) )
continue ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
tempscrptr = ( intptr_t * ) script + offset ;
* tempscrptr = ( intptr_t ) g_scriptPtr ;
bitptr [ ( tempscrptr - script ) > > 3 ] | = ( BITPTR_POINTER < < ( ( tempscrptr - script ) & 7 ) ) ;
2009-01-05 14:43:12 +00:00
2011-04-07 01:16:29 +00:00
j = C_GetKeyword ( ) ;
2009-01-05 14:43:12 +00:00
2011-04-07 01:16:29 +00:00
if ( j = = CON_ELSE | | j = = CON_LEFTBRACE )
g_checkingIfElse + + ;
2009-01-04 22:22:33 +00:00
2011-04-07 01:16:29 +00:00
continue ;
}
case CON_LEFTBRACE :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ! ( g_processingState | | g_parsingActorPtr | | g_parsingEventPtr ) ) )
2011-04-07 01:16:29 +00:00
{
g_numCompilerErrors + + ;
C_ReportError ( ERROR_SYNTAXERROR ) ;
}
g_numBraces + + ;
2006-04-13 20:47:06 +00:00
2011-05-20 02:34:41 +00:00
C_ParseCommand ( 1 ) ;
2011-04-07 01:16:29 +00:00
continue ;
2009-01-05 14:43:12 +00:00
2011-04-07 01:16:29 +00:00
case CON_RIGHTBRACE :
g_numBraces - - ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
if ( ( * ( g_scriptPtr - 2 ) > > 12 ) = = ( IFELSE_MAGIC ) & &
( ( * ( g_scriptPtr - 2 ) & 0xFFF ) = = CON_LEFTBRACE ) ) // rewrite "{ }" into "nullop"
{
// initprintf("%s:%d: rewriting empty braces '{ }' as 'nullop' from right\n",g_szScriptFileName,g_lineNumber);
* ( g_scriptPtr - 2 ) = CON_NULLOP + ( IFELSE_MAGIC < < 12 ) ;
g_scriptPtr - = 2 ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
if ( C_GetKeyword ( ) ! = CON_ELSE & & ( * ( g_scriptPtr - 2 ) & 0xFFF ) ! = CON_ELSE )
g_ifElseAborted = 1 ;
else g_ifElseAborted = 0 ;
2008-08-16 07:53:29 +00:00
2011-04-07 01:16:29 +00:00
j = C_GetKeyword ( ) ;
2006-04-25 01:56:24 +00:00
2011-04-07 01:16:29 +00:00
if ( g_checkingIfElse & & j ! = CON_ELSE )
g_checkingIfElse - - ;
2006-04-25 01:56:24 +00:00
2011-04-07 01:16:29 +00:00
return 1 ;
}
2006-04-25 01:56:24 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_numBraces < 0 ) )
2006-04-25 01:56:24 +00:00
{
2011-04-07 01:16:29 +00:00
if ( g_checkingSwitch )
{
C_ReportError ( ERROR_NOENDSWITCH ) ;
}
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: error: found more `}' than `{'. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
2006-04-25 01:56:24 +00:00
}
2011-05-20 02:34:41 +00:00
2011-04-07 01:16:29 +00:00
if ( g_checkingIfElse & & j ! = CON_ELSE )
g_checkingIfElse - - ;
2006-04-25 01:56:24 +00:00
2011-04-07 01:16:29 +00:00
return 1 ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_BETANAME :
g_scriptPtr - - ;
j = 0 ;
2009-11-20 03:54:40 +00:00
C_NextLine ( ) ;
2011-04-07 01:16:29 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2015-02-09 05:50:33 +00:00
case CON_UNDEFINELEVEL :
g_scriptPtr - - ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
j = * g_scriptPtr ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
k = * g_scriptPtr ;
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > MAXVOLUMES - 1 ) )
{
initprintf ( " %s:%d: error: volume number exceeds maximum volume count. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
C_NextLine ( ) ;
continue ;
}
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) k > MAXLEVELS - 1 ) )
{
initprintf ( " %s:%d: error: level number exceeds maximum number of levels per episode. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
C_NextLine ( ) ;
continue ;
}
C_UndefineLevel ( j , k ) ;
continue ;
case CON_UNDEFINESKILL :
g_scriptPtr - - ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
j = * g_scriptPtr ;
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > = MAXSKILLS ) )
{
initprintf ( " %s:%d: error: skill number exceeds maximum skill count %d. \n " ,
g_szScriptFileName , g_lineNumber , MAXSKILLS ) ;
g_numCompilerErrors + + ;
C_NextLine ( ) ;
continue ;
}
C_UndefineSkill ( j ) ;
continue ;
case CON_UNDEFINEVOLUME :
g_scriptPtr - - ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
j = * g_scriptPtr ;
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > MAXVOLUMES - 1 ) )
{
initprintf ( " %s:%d: error: volume number exceeds maximum volume count. \n " ,
g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
C_NextLine ( ) ;
continue ;
}
C_UndefineVolume ( j ) ;
continue ;
2011-04-07 01:16:29 +00:00
case CON_DEFINEVOLUMENAME :
g_scriptPtr - - ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
j = * g_scriptPtr ;
2015-03-25 06:28:09 +00:00
C_SkipSpace ( ) ;
2011-04-07 01:16:29 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > MAXVOLUMES - 1 ) )
2008-06-30 09:25:06 +00:00
{
2011-04-07 01:16:29 +00:00
initprintf ( " %s:%d: error: volume number exceeds maximum volume count. \n " ,
g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
2009-11-20 03:54:40 +00:00
C_NextLine ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2008-06-30 09:25:06 +00:00
}
2011-04-07 01:16:29 +00:00
i = 0 ;
while ( * textptr ! = 0x0a & & * textptr ! = 0x0d & & * textptr ! = 0 )
2006-04-13 20:47:06 +00:00
{
2013-03-25 04:31:09 +00:00
EpisodeNames [ j ] [ i ] = * textptr ;
2011-04-07 01:16:29 +00:00
textptr + + , i + + ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = ( signed ) sizeof ( EpisodeNames [ j ] ) - 1 ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: warning: truncating volume name to %d characters. \n " ,
g_szScriptFileName , g_lineNumber , ( int32_t ) sizeof ( EpisodeNames [ j ] ) - 1 ) ;
g_numCompilerWarnings + + ;
C_NextLine ( ) ;
break ;
}
}
g_numVolumes = j + 1 ;
EpisodeNames [ j ] [ i ] = ' \0 ' ;
continue ;
2015-02-22 22:15:20 +00:00
case CON_DEFINEVOLUMEFLAGS :
g_scriptPtr - - ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
j = * g_scriptPtr ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
k = * g_scriptPtr ;
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > MAXVOLUMES - 1 ) )
{
initprintf ( " %s:%d: error: volume number exceeds maximum volume count. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
C_NextLine ( ) ;
continue ;
}
C_DefineVolumeFlags ( j , k ) ;
continue ;
2011-04-07 01:16:29 +00:00
case CON_DEFINEGAMEFUNCNAME :
g_scriptPtr - - ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
j = * g_scriptPtr ;
2015-03-25 06:28:09 +00:00
C_SkipSpace ( ) ;
2011-04-07 01:16:29 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > NUMGAMEFUNCTIONS - 1 ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: error: function number exceeds number of game functions. \n " ,
g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
2009-11-20 03:54:40 +00:00
C_NextLine ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
}
2008-12-31 09:07:49 +00:00
2011-04-07 01:16:29 +00:00
i = 0 ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
while ( * textptr ! = 0x0a & & * textptr ! = 0x0d & & * textptr ! = 0 )
{
gamefunctions [ j ] [ i ] = * textptr ;
keydefaults [ j * 3 ] [ i ] = * textptr ;
textptr + + , i + + ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( * textptr ! = 0x0a & & * textptr ! = 0x0d & & ispecial ( * textptr ) ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: warning: invalid character in function name. \n " ,
g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
C_NextLine ( ) ;
break ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = MAXGAMEFUNCLEN - 1 ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: warning: truncating function name to %d characters. \n " ,
g_szScriptFileName , g_lineNumber , MAXGAMEFUNCLEN ) ;
g_numCompilerWarnings + + ;
C_NextLine ( ) ;
break ;
}
}
gamefunctions [ j ] [ i ] = ' \0 ' ;
keydefaults [ j * 3 ] [ i ] = ' \0 ' ;
hash_add ( & h_gamefuncs , gamefunctions [ j ] , j , 0 ) ;
{
2014-05-30 00:02:19 +00:00
char * str = Bstrtolower ( Xstrdup ( gamefunctions [ j ] ) ) ;
2011-04-07 01:16:29 +00:00
hash_add ( & h_gamefuncs , str , j , 0 ) ;
Bfree ( str ) ;
}
2008-08-16 07:53:29 +00:00
2011-04-07 01:16:29 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_DEFINESKILLNAME :
g_scriptPtr - - ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
j = * g_scriptPtr ;
2015-03-25 06:28:09 +00:00
C_SkipSpace ( ) ;
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > = MAXSKILLS ) )
2006-11-15 01:16:55 +00:00
{
2012-03-25 22:00:27 +00:00
initprintf ( " %s:%d: error: skill number exceeds maximum skill count %d. \n " ,
g_szScriptFileName , g_lineNumber , MAXSKILLS ) ;
2011-04-07 01:16:29 +00:00
g_numCompilerErrors + + ;
2009-11-20 03:54:40 +00:00
C_NextLine ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-11-15 01:16:55 +00:00
}
2008-07-22 09:05:34 +00:00
2011-04-07 01:16:29 +00:00
i = 0 ;
2008-07-22 09:05:34 +00:00
2011-04-07 01:16:29 +00:00
while ( * textptr ! = 0x0a & & * textptr ! = 0x0d & & * textptr ! = 0 )
2008-07-22 09:05:34 +00:00
{
2013-03-25 04:31:09 +00:00
SkillNames [ j ] [ i ] = * textptr ;
2011-04-07 01:16:29 +00:00
textptr + + , i + + ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = ( signed ) sizeof ( SkillNames [ j ] ) - 1 ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: warning: truncating skill name to %d characters. \n " ,
g_szScriptFileName , g_lineNumber , ( int32_t ) sizeof ( SkillNames [ j ] ) - 1 ) ;
g_numCompilerWarnings + + ;
C_NextLine ( ) ;
break ;
}
2008-07-22 09:05:34 +00:00
}
2012-03-25 22:00:27 +00:00
2011-04-07 01:16:29 +00:00
SkillNames [ j ] [ i ] = ' \0 ' ;
2012-03-25 22:00:27 +00:00
for ( i = 0 ; i < MAXSKILLS ; i + + )
if ( SkillNames [ i ] [ 0 ] = = 0 )
break ;
g_numSkills = i ;
2011-04-07 01:16:29 +00:00
continue ;
2009-11-18 01:17:56 +00:00
2011-04-07 01:16:29 +00:00
case CON_SETGAMENAME :
{
char gamename [ 32 ] ;
g_scriptPtr - - ;
2008-08-17 09:01:31 +00:00
2011-04-07 01:16:29 +00:00
C_SkipComments ( ) ;
2009-11-18 01:17:56 +00:00
2011-04-07 01:16:29 +00:00
i = 0 ;
2009-02-02 01:49:14 +00:00
2011-04-07 01:16:29 +00:00
while ( * textptr ! = 0x0a & & * textptr ! = 0x0d & & * textptr ! = 0 )
2008-08-23 23:37:01 +00:00
{
2011-04-07 01:16:29 +00:00
gamename [ i ] = * textptr ;
textptr + + , i + + ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = ( signed ) sizeof ( gamename ) - 1 ) )
2008-08-23 23:37:01 +00:00
{
2011-04-07 01:16:29 +00:00
initprintf ( " %s:%d: warning: truncating game name to %d characters. \n " ,
g_szScriptFileName , g_lineNumber , ( int32_t ) sizeof ( gamename ) - 1 ) ;
g_numCompilerWarnings + + ;
C_NextLine ( ) ;
break ;
2008-08-23 23:37:01 +00:00
}
}
2011-04-07 01:16:29 +00:00
gamename [ i ] = ' \0 ' ;
2014-05-30 00:02:19 +00:00
g_gameNamePtr = Xstrdup ( gamename ) ;
2014-06-16 23:17:11 +00:00
G_UpdateAppTitle ( ) ;
2011-04-07 01:16:29 +00:00
}
continue ;
case CON_SETDEFNAME :
{
g_scriptPtr - - ;
C_SkipComments ( ) ;
j = 0 ;
while ( isaltok ( * textptr ) )
2008-08-23 23:37:01 +00:00
{
2011-04-07 01:16:29 +00:00
tempbuf [ j ] = * ( textptr + + ) ;
j + + ;
2008-08-23 23:37:01 +00:00
}
2011-04-07 01:16:29 +00:00
tempbuf [ j ] = ' \0 ' ;
Clear up handling of g_*NamePtr in the game.
The primary change is that things have been made memory-clean. Some of these
pointers may point to wildly different places during the course of the program
such as statically or dynamically allocated storage, the buffer returned by
getenv() (which must not be modified according to the docs), or an element of
argv[]. Consequently, we need to strdup, or better, dup_filename them if they
are ever to be passed to a function that modifies their pointed-to data.
Specifically:
- added statics or consts according to usage
- 3 new functions clear{Grp,Def,Script}NamePtr, only 'Def' one extern for now
- in G_CheckCommandLine, don't strip 'const'; use Bstrncpyz where appropriate
- remove multiple declarations
Also, warn if an application parameter has been ignored (not matched).
git-svn-id: https://svn.eduke32.com/eduke32@2561 1a8010ca-5511-0410-912e-c29ae57300e0
2012-03-28 19:44:00 +00:00
2013-02-24 16:05:22 +00:00
C_SetDefName ( tempbuf ) ;
2008-08-23 23:37:01 +00:00
}
2011-04-07 01:16:29 +00:00
continue ;
case CON_SETCFGNAME :
2008-08-23 23:37:01 +00:00
{
2011-04-07 01:16:29 +00:00
g_scriptPtr - - ;
C_SkipComments ( ) ;
j = 0 ;
while ( isaltok ( * textptr ) )
{
tempbuf [ j ] = * ( textptr + + ) ;
j + + ;
}
tempbuf [ j ] = ' \0 ' ;
2013-11-08 18:08:45 +00:00
C_SetCfgName ( tempbuf ) ;
2011-04-07 01:16:29 +00:00
}
continue ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
case CON_DEFINEGAMETYPE :
g_scriptPtr - - ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
j = * g_scriptPtr ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
GametypeFlags [ j ] = * g_scriptPtr ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
C_SkipComments ( ) ;
2006-11-15 01:16:55 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > MAXGAMETYPES - 1 ) )
2006-04-13 20:47:06 +00:00
{
2011-04-07 01:16:29 +00:00
initprintf ( " %s:%d: error: gametype number exceeds maximum gametype count. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
2009-11-20 03:54:40 +00:00
C_NextLine ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
}
2011-04-07 01:16:29 +00:00
g_numGametypes = j + 1 ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
i = 0 ;
2006-11-16 03:02:42 +00:00
2011-04-07 01:16:29 +00:00
while ( * textptr ! = 0x0a & & * textptr ! = 0x0d & & * textptr ! = 0 )
{
2013-03-25 04:31:09 +00:00
GametypeNames [ j ] [ i ] = * textptr ;
2011-04-07 01:16:29 +00:00
textptr + + , i + + ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = ( signed ) sizeof ( GametypeNames [ j ] ) - 1 ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: warning: truncating gametype name to %d characters. \n " ,
g_szScriptFileName , g_lineNumber , ( int32_t ) sizeof ( GametypeNames [ j ] ) - 1 ) ;
g_numCompilerWarnings + + ;
C_NextLine ( ) ;
break ;
}
}
GametypeNames [ j ] [ i ] = ' \0 ' ;
continue ;
2006-12-04 22:05:30 +00:00
2011-04-07 01:16:29 +00:00
case CON_DEFINELEVELNAME :
g_scriptPtr - - ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
j = * g_scriptPtr ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
k = * g_scriptPtr ;
C_SkipComments ( ) ;
2006-12-12 07:25:01 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) j > MAXVOLUMES - 1 ) )
2006-04-13 20:47:06 +00:00
{
2011-04-07 01:16:29 +00:00
initprintf ( " %s:%d: error: volume number exceeds maximum volume count. \n " , g_szScriptFileName , g_lineNumber ) ;
2008-11-20 14:06:36 +00:00
g_numCompilerErrors + + ;
2011-04-07 01:16:29 +00:00
C_NextLine ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) k > MAXLEVELS - 1 ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: error: level number exceeds maximum number of levels per episode. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
C_NextLine ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
}
2006-12-05 21:22:19 +00:00
2011-04-07 01:16:29 +00:00
i = 0 ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
tempbuf [ i ] = ' / ' ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
while ( * textptr ! = ' ' & & * textptr ! = ' \t ' & & * textptr ! = 0x0a )
{
tempbuf [ i + 1 ] = * textptr ;
textptr + + , i + + ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = BMAX_PATH ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: error: level file name exceeds limit of %d characters. \n " , g_szScriptFileName , g_lineNumber , BMAX_PATH ) ;
g_numCompilerErrors + + ;
2015-03-25 06:28:09 +00:00
C_SkipSpace ( ) ;
2011-04-07 01:16:29 +00:00
break ;
}
}
tempbuf [ i + 1 ] = ' \0 ' ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
Bcorrectfilename ( tempbuf , 0 ) ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
if ( MapInfo [ j * MAXLEVELS + k ] . filename = = NULL )
2014-05-30 00:02:19 +00:00
MapInfo [ j * MAXLEVELS + k ] . filename = ( char * ) Xcalloc ( Bstrlen ( tempbuf ) + 1 , sizeof ( uint8_t ) ) ;
2011-04-07 01:16:29 +00:00
else if ( ( Bstrlen ( tempbuf ) + 1 ) > sizeof ( MapInfo [ j * MAXLEVELS + k ] . filename ) )
2014-05-30 00:02:19 +00:00
MapInfo [ j * MAXLEVELS + k ] . filename = ( char * ) Xrealloc ( MapInfo [ j * MAXLEVELS + k ] . filename , ( Bstrlen ( tempbuf ) + 1 ) ) ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
Bstrcpy ( MapInfo [ j * MAXLEVELS + k ] . filename , tempbuf ) ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
C_SkipComments ( ) ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
MapInfo [ j * MAXLEVELS + k ] . partime =
( ( ( * ( textptr + 0 ) - ' 0 ' ) * 10 + ( * ( textptr + 1 ) - ' 0 ' ) ) * REALGAMETICSPERSEC * 60 ) +
( ( ( * ( textptr + 3 ) - ' 0 ' ) * 10 + ( * ( textptr + 4 ) - ' 0 ' ) ) * REALGAMETICSPERSEC ) ;
2006-12-05 21:22:19 +00:00
2011-04-07 01:16:29 +00:00
textptr + = 5 ;
2015-03-25 06:28:09 +00:00
C_SkipSpace ( ) ;
2006-12-05 21:22:19 +00:00
2013-05-23 18:28:04 +00:00
// cheap hack, 0.99 doesn't have the 3D Realms time
2013-05-25 22:50:46 +00:00
if ( * ( textptr + 2 ) = = ' : ' )
2013-05-23 18:28:04 +00:00
{
MapInfo [ j * MAXLEVELS + k ] . designertime =
( ( ( * ( textptr + 0 ) - ' 0 ' ) * 10 + ( * ( textptr + 1 ) - ' 0 ' ) ) * REALGAMETICSPERSEC * 60 ) +
( ( ( * ( textptr + 3 ) - ' 0 ' ) * 10 + ( * ( textptr + 4 ) - ' 0 ' ) ) * REALGAMETICSPERSEC ) ;
2006-12-05 21:22:19 +00:00
2013-05-23 18:28:04 +00:00
textptr + = 5 ;
2015-03-25 06:28:09 +00:00
C_SkipSpace ( ) ;
2013-05-23 18:28:04 +00:00
}
2013-05-25 22:50:46 +00:00
else if ( g_scriptVersion = = 10 ) g_scriptVersion = 9 ;
2006-12-05 21:22:19 +00:00
2011-04-07 01:16:29 +00:00
i = 0 ;
2006-12-05 21:22:19 +00:00
2011-04-07 01:16:29 +00:00
while ( * textptr ! = 0x0a & & * textptr ! = 0x0d & & * textptr ! = 0 )
{
2013-03-25 04:31:09 +00:00
tempbuf [ i ] = * textptr ;
2011-04-07 01:16:29 +00:00
textptr + + , i + + ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = 32 ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: warning: truncating level name to %d characters. \n " ,
g_szScriptFileName , g_lineNumber , 32 ) ;
g_numCompilerWarnings + + ;
C_NextLine ( ) ;
break ;
}
}
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
tempbuf [ i ] = ' \0 ' ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
if ( MapInfo [ j * MAXLEVELS + k ] . name = = NULL )
2014-05-30 00:02:19 +00:00
MapInfo [ j * MAXLEVELS + k ] . name = ( char * ) Xcalloc ( Bstrlen ( tempbuf ) + 1 , sizeof ( uint8_t ) ) ;
2011-04-07 01:16:29 +00:00
else if ( ( Bstrlen ( tempbuf ) + 1 ) > sizeof ( MapInfo [ j * MAXLEVELS + k ] . name ) )
2014-05-30 00:02:19 +00:00
MapInfo [ j * MAXLEVELS + k ] . name = ( char * ) Xrealloc ( MapInfo [ j * MAXLEVELS + k ] . name , ( Bstrlen ( tempbuf ) + 1 ) ) ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
/* initprintf("level name string len: %d\n",Bstrlen(tempbuf)); */
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
Bstrcpy ( MapInfo [ j * MAXLEVELS + k ] . name , tempbuf ) ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
continue ;
2011-02-25 21:50:19 +00:00
2011-04-07 01:16:29 +00:00
case CON_DEFINEQUOTE :
case CON_REDEFINEQUOTE :
if ( tw = = CON_DEFINEQUOTE )
{
g_scriptPtr - - ;
}
2006-04-24 01:54:58 +00:00
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
k = * ( g_scriptPtr - 1 ) ;
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) k > = MAXQUOTES ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: error: quote number exceeds limit of %d. \n " , g_szScriptFileName , g_lineNumber , MAXQUOTES ) ;
g_numCompilerErrors + + ;
}
2012-12-09 13:42:38 +00:00
else
2006-04-23 03:14:44 +00:00
{
2013-01-01 15:24:25 +00:00
C_AllocQuote ( k ) ;
2006-04-24 02:58:15 +00:00
}
2006-04-13 20:47:06 +00:00
if ( tw = = CON_DEFINEQUOTE )
2011-04-07 01:16:29 +00:00
g_scriptPtr - - ;
i = 0 ;
2015-03-25 06:28:09 +00:00
C_SkipSpace ( ) ;
2011-04-07 01:16:29 +00:00
if ( tw = = CON_REDEFINEQUOTE )
2006-04-13 20:47:06 +00:00
{
2011-04-07 01:16:29 +00:00
if ( ScriptQuoteRedefinitions [ g_numQuoteRedefinitions ] = = NULL )
2014-05-30 00:02:19 +00:00
ScriptQuoteRedefinitions [ g_numQuoteRedefinitions ] = ( char * ) Xcalloc ( MAXQUOTELEN , sizeof ( uint8_t ) ) ;
2011-04-07 01:16:29 +00:00
}
while ( * textptr ! = 0x0a & & * textptr ! = 0x0d & & * textptr ! = 0 )
{
/*
if ( * textptr = = ' % ' & & * ( textptr + 1 ) = = ' s ' )
{
initprintf ( " %s:%d: error: quote text contains string identifier. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
while ( * textptr ! = 0x0a & & * textptr ! = 0x0d & & * textptr ! = 0 ) textptr + + ;
2006-11-16 03:02:42 +00:00
break ;
2011-04-07 01:16:29 +00:00
}
*/
if ( tw = = CON_DEFINEQUOTE )
* ( ScriptQuotes [ k ] + i ) = * textptr ;
else
* ( ScriptQuoteRedefinitions [ g_numQuoteRedefinitions ] + i ) = * textptr ;
textptr + + , i + + ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = MAXQUOTELEN - 1 ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: warning: truncating quote text to %d characters. \n " , g_szScriptFileName , g_lineNumber , MAXQUOTELEN - 1 ) ;
g_numCompilerWarnings + + ;
C_NextLine ( ) ;
break ;
}
2006-04-13 20:47:06 +00:00
}
2012-12-09 13:42:38 +00:00
2011-04-07 01:16:29 +00:00
if ( tw = = CON_DEFINEQUOTE )
2012-12-09 13:42:38 +00:00
{
if ( ( unsigned ) k < MAXQUOTES )
* ( ScriptQuotes [ k ] + i ) = ' \0 ' ;
}
2011-04-07 01:16:29 +00:00
else
{
* ( ScriptQuoteRedefinitions [ g_numQuoteRedefinitions ] + i ) = ' \0 ' ;
bitptr [ ( g_scriptPtr - script ) > > 3 ] & = ~ ( BITPTR_POINTER < < ( ( g_scriptPtr - script ) & 7 ) ) ;
* g_scriptPtr + + = g_numQuoteRedefinitions ;
g_numQuoteRedefinitions + + ;
}
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_CHEATKEYS :
g_scriptPtr - - ;
C_GetNextValue ( LABEL_DEFINE ) ;
CheatKeys [ 0 ] = * ( g_scriptPtr - 1 ) ;
C_GetNextValue ( LABEL_DEFINE ) ;
CheatKeys [ 1 ] = * ( g_scriptPtr - 1 ) ;
g_scriptPtr - = 2 ;
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_DEFINECHEAT :
g_scriptPtr - - ;
C_GetNextValue ( LABEL_DEFINE ) ;
k = * ( g_scriptPtr - 1 ) ;
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( k > 25 ) )
2006-04-13 20:47:06 +00:00
{
2011-04-07 01:16:29 +00:00
initprintf ( " %s:%d: error: cheat redefinition attempts to redefine nonexistent cheat. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
2009-11-20 03:54:40 +00:00
C_NextLine ( ) ;
2011-05-20 02:34:41 +00:00
continue ;
2006-04-13 20:47:06 +00:00
}
2011-04-07 01:16:29 +00:00
g_scriptPtr - - ;
i = 0 ;
2015-03-25 06:28:09 +00:00
C_SkipSpace ( ) ;
2011-04-07 01:16:29 +00:00
while ( * textptr ! = 0x0a & & * textptr ! = 0x0d & & * textptr ! = 0 & & * textptr ! = ' ' )
{
2015-03-24 10:49:03 +00:00
CheatStrings [ k ] [ i ] = Btolower ( * textptr ) ;
2011-04-07 01:16:29 +00:00
textptr + + , i + + ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = ( signed ) sizeof ( CheatStrings [ k ] ) - 1 ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: warning: truncating cheat string to %d characters. \n " ,
2013-08-12 15:18:20 +00:00
g_szScriptFileName , g_lineNumber , ( signed ) sizeof ( CheatStrings [ k ] ) - 1 ) ;
2011-04-07 01:16:29 +00:00
g_numCompilerWarnings + + ;
C_NextLine ( ) ;
break ;
}
}
CheatStrings [ k ] [ i ] = ' \0 ' ;
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_DEFINESOUND :
g_scriptPtr - - ;
C_GetNextValue ( LABEL_DEFINE ) ;
2013-06-01 06:55:30 +00:00
// Ideally we could keep the value of i from C_GetNextValue() instead of having to hash_find() again.
// This depends on tempbuf remaining in place after C_GetNextValue():
j = hash_find ( & h_labels , tempbuf ) ;
2011-04-07 01:16:29 +00:00
k = * ( g_scriptPtr - 1 ) ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( unsigned ) k > = MAXSOUNDS ) )
2011-04-07 01:16:29 +00:00
{
initprintf ( " %s:%d: error: exceeded sound limit of %d. \n " , g_szScriptFileName , g_lineNumber , MAXSOUNDS ) ;
g_numCompilerErrors + + ;
}
g_scriptPtr - - ;
i = 0 ;
C_SkipComments ( ) ;
2006-11-15 01:16:55 +00:00
2011-04-07 01:16:29 +00:00
if ( g_sounds [ k ] . filename = = NULL )
2014-05-30 00:02:19 +00:00
g_sounds [ k ] . filename = ( char * ) Xcalloc ( BMAX_PATH , sizeof ( uint8_t ) ) ;
2007-09-11 05:26:38 +00:00
2011-04-07 01:16:29 +00:00
if ( * textptr = = ' \" ' )
2009-11-20 03:54:40 +00:00
{
2011-04-07 01:16:29 +00:00
textptr + + ;
while ( * textptr & & * textptr ! = ' \" ' )
2009-11-20 03:54:40 +00:00
{
2011-04-07 01:16:29 +00:00
g_sounds [ k ] . filename [ i + + ] = * textptr + + ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = BMAX_PATH - 1 ) )
2011-04-07 01:16:29 +00:00
{
2012-06-17 19:45:46 +00:00
initprintf ( " %s:%d: error: sound filename exceeds limit of %d characters. \n " , g_szScriptFileName , g_lineNumber , BMAX_PATH - 1 ) ;
2011-04-07 01:16:29 +00:00
g_numCompilerErrors + + ;
C_SkipComments ( ) ;
break ;
}
2009-11-20 03:54:40 +00:00
}
2011-04-07 01:16:29 +00:00
textptr + + ;
2009-11-20 03:54:40 +00:00
}
2011-04-07 01:16:29 +00:00
else while ( * textptr ! = ' ' & & * textptr ! = ' \t ' & & * textptr ! = ' \r ' & & * textptr ! = ' \n ' )
2006-11-15 01:16:55 +00:00
{
2010-01-23 22:12:02 +00:00
g_sounds [ k ] . filename [ i + + ] = * textptr + + ;
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( i > = BMAX_PATH - 1 ) )
2010-01-23 22:12:02 +00:00
{
2012-06-17 19:45:46 +00:00
initprintf ( " %s:%d: error: sound filename exceeds limit of %d characters. \n " , g_szScriptFileName , g_lineNumber , BMAX_PATH - 1 ) ;
2010-01-23 22:12:02 +00:00
g_numCompilerErrors + + ;
C_SkipComments ( ) ;
break ;
}
2006-11-15 01:16:55 +00:00
}
2011-04-07 01:16:29 +00:00
g_sounds [ k ] . filename [ i ] = ' \0 ' ;
2006-04-13 20:47:06 +00:00
2012-05-28 18:15:26 +00:00
check_filename_case ( g_sounds [ k ] . filename ) ;
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
g_sounds [ k ] . ps = * ( g_scriptPtr - 1 ) ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_sounds [ k ] . pe = * ( g_scriptPtr - 1 ) ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_sounds [ k ] . pr = * ( g_scriptPtr - 1 ) ;
2013-01-13 16:40:36 +00:00
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
2013-09-08 20:18:56 +00:00
g_sounds [ k ] . m = * ( g_scriptPtr - 1 ) & ~ SF_ONEINST_INTERNAL ;
2013-01-13 16:40:36 +00:00
if ( * ( g_scriptPtr - 1 ) & 1 )
2013-09-08 20:18:56 +00:00
g_sounds [ k ] . m | = SF_ONEINST_INTERNAL ;
2013-01-13 16:40:36 +00:00
2011-04-07 01:16:29 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
g_sounds [ k ] . vo = * ( g_scriptPtr - 1 ) ;
g_scriptPtr - = 5 ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
if ( k > g_maxSoundPos )
g_maxSoundPos = k ;
2013-06-01 06:55:30 +00:00
if ( k > = 0 & & k < MAXSOUNDS & & g_dynamicSoundMapping & & j > = 0 & & ( labeltype [ j ] & LABEL_DEFINE ) )
G_ProcessDynamicSoundMapping ( label + ( j < < 6 ) , k ) ;
2011-04-07 01:16:29 +00:00
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_ENDEVENT :
2006-04-13 20:47:06 +00:00
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_parsingEventPtr = = NULL ) )
2010-02-23 18:13:46 +00:00
{
C_ReportError ( - 1 ) ;
2011-04-07 01:16:29 +00:00
initprintf ( " %s:%d: error: found `endevent' without open `onevent'. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_numBraces > 0 ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_OPENBRACKET ) ;
g_numCompilerErrors + + ;
}
2014-10-25 03:36:34 +00:00
else if ( EDUKE32_PREDICT_FALSE ( g_numBraces < 0 ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( ERROR_CLOSEBRACKET ) ;
g_numCompilerErrors + + ;
}
// if event has already been declared then put a jump in instead
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( ( intptr_t ) previous_event ) )
2011-04-07 01:16:29 +00:00
{
2015-03-27 12:28:45 +00:00
intptr_t const destination = previous_event - script ;
2010-05-03 01:03:06 +00:00
g_scriptPtr - - ;
2011-04-07 01:16:29 +00:00
* ( g_scriptPtr + + ) = CON_JUMP ;
* ( g_scriptPtr + + ) = MAXGAMEVARS ;
2015-03-27 12:28:45 +00:00
* ( g_scriptPtr + + ) = destination ;
2011-04-07 01:16:29 +00:00
* ( g_scriptPtr + + ) = CON_ENDEVENT ;
previous_event = NULL ;
2015-03-27 12:28:45 +00:00
C_FillEventBreakStackWithJump ( g_parsingEventBreakPtr , destination ) ;
2010-02-23 18:13:46 +00:00
}
2015-03-25 21:31:11 +00:00
else
{
// pad space for the next potential appendevent
apScriptGameEventEnd [ g_currentEvent ] = g_scriptPtr - 1 ;
2015-03-27 12:28:45 +00:00
g_parsingEventPtr = ( intptr_t * ) ( g_scriptPtr - script - 1 ) ;
2015-03-25 21:31:11 +00:00
* ( g_scriptPtr + + ) = CON_ENDEVENT ;
2015-03-27 12:28:45 +00:00
* ( g_scriptPtr + + ) = ( intptr_t ) g_parsingEventBreakPtr ;
2015-03-25 21:31:11 +00:00
* ( g_scriptPtr + + ) = CON_ENDEVENT ;
}
2015-03-27 12:28:45 +00:00
g_parsingEventBreakPtr = g_parsingEventPtr = g_parsingActorPtr = NULL ;
2011-04-07 01:16:29 +00:00
g_currentEvent = - 1 ;
Bsprintf ( g_szCurrentBlockName , " (none) " ) ;
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_ENDA :
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_parsingActorPtr = = NULL ) )
2009-01-04 22:22:33 +00:00
{
C_ReportError ( - 1 ) ;
2011-04-07 01:16:29 +00:00
initprintf ( " %s:%d: error: found `enda' without open `actor'. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerErrors + + ;
2009-01-04 22:22:33 +00:00
}
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( g_numBraces ! = 0 ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( g_numBraces > 0 ? ERROR_OPENBRACKET : ERROR_CLOSEBRACKET ) ;
g_numCompilerErrors + + ;
}
g_parsingActorPtr = NULL ;
Bsprintf ( g_szCurrentBlockName , " (none) " ) ;
continue ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
case CON_RETURN :
case CON_BREAK :
if ( g_checkingSwitch )
{
2014-10-25 03:36:34 +00:00
if ( EDUKE32_PREDICT_FALSE ( otw = = CON_BREAK ) )
2011-04-07 01:16:29 +00:00
{
C_ReportError ( - 1 ) ;
initprintf ( " %s:%d: warning: duplicate `break'. \n " , g_szScriptFileName , g_lineNumber ) ;
g_numCompilerWarnings + + ;
g_scriptPtr - - ;
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
}
return 1 ;
}
2015-03-27 12:28:45 +00:00
else if ( g_parsingEventPtr )
{
g_scriptPtr - - ;
* ( g_scriptPtr + + ) = CON_JUMP ;
* ( g_scriptPtr + + ) = MAXGAMEVARS ;
* g_scriptPtr = ( intptr_t ) g_parsingEventBreakPtr ;
g_parsingEventBreakPtr = g_scriptPtr + + ;
}
2011-05-20 02:34:41 +00:00
continue ;
2011-04-07 01:16:29 +00:00
case CON_SCRIPTSIZE :
g_scriptPtr - - ;
2008-11-20 14:06:36 +00:00
C_GetNextValue ( LABEL_DEFINE ) ;
2011-04-07 01:16:29 +00:00
j = * ( g_scriptPtr - 1 ) ;
2008-11-20 14:06:36 +00:00
g_scriptPtr - - ;
2011-04-07 01:16:29 +00:00
C_SkipComments ( ) ;
2011-05-27 21:24:01 +00:00
if ( C_SetScriptSize ( j ) ) return 1 ;
continue ;
2011-04-07 01:16:29 +00:00
2013-05-23 18:28:04 +00:00
case CON_SHADETO :
g_scriptPtr - - ;
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
continue ;
2015-01-17 00:27:19 +00:00
case CON_ADDLOG :
2011-04-07 01:16:29 +00:00
case CON_FALL :
case CON_TIP :
// case 21:
case CON_KILLIT :
case CON_RESETACTIONCOUNT :
case CON_PSTOMP :
case CON_RESETPLAYER :
case CON_RESETCOUNT :
case CON_WACKPLAYER :
case CON_OPERATE :
case CON_RESPAWNHITAG :
case CON_GETLASTPAL :
case CON_PKICK :
case CON_MIKESND :
case CON_TOSSWEAPON :
2015-01-17 00:27:19 +00:00
case CON_SPGETLOTAG :
case CON_SPGETHITAG :
case CON_SECTGETLOTAG :
case CON_SECTGETHITAG :
case CON_GETTEXTUREFLOOR :
case CON_GETTEXTURECEILING :
case CON_INSERTSPRITEQ :
case CON_STOPALLSOUNDS :
continue ;
2011-04-07 01:16:29 +00:00
case CON_NULLOP :
2015-01-17 00:27:19 +00:00
if ( EDUKE32_PREDICT_FALSE ( C_GetKeyword ( ) ! = CON_ELSE ) )
2006-11-16 03:02:42 +00:00
{
2015-01-17 00:27:19 +00:00
C_ReportError ( - 1 ) ;
g_numCompilerWarnings + + ;
initprintf ( " %s:%d: warning: `nullop' found without `else' \n " , g_szScriptFileName , g_lineNumber ) ;
g_scriptPtr - - ;
g_ifElseAborted = 1 ;
2006-11-16 03:02:42 +00:00
}
2011-04-07 01:16:29 +00:00
continue ;
2015-01-17 00:27:19 +00:00
2011-04-07 01:16:29 +00:00
case CON_GAMESTARTUP :
2006-11-16 03:02:42 +00:00
{
2011-04-07 01:16:29 +00:00
int32_t params [ 30 ] ;
2006-04-13 20:47:06 +00:00
2011-04-07 01:16:29 +00:00
g_scriptPtr - - ;
for ( j = 0 ; j < 30 ; j + + )
{
C_GetNextValue ( LABEL_DEFINE ) ;
g_scriptPtr - - ;
params [ j ] = * g_scriptPtr ;
2006-11-15 01:16:55 +00:00
2013-05-23 18:28:04 +00:00
if ( j ! = 12 & & j ! = 21 & & j ! = 25 ) continue ;
2011-04-07 01:16:29 +00:00
if ( C_GetKeyword ( ) ! = - 1 )
{
2013-05-23 18:28:04 +00:00
if ( j = = 12 )
g_scriptVersion = 10 ;
else if ( j = = 21 )
g_scriptVersion = 11 ;
2013-06-13 21:17:17 +00:00
else if ( j = = 25 )
g_scriptVersion = 13 ;
2011-04-07 01:16:29 +00:00
break ;
}
else
g_scriptVersion = 14 ;
}
/*
v1 .3 d v1 .5
DEFAULTVISIBILITY DEFAULTVISIBILITY
GENERICIMPACTDAMAGE GENERICIMPACTDAMAGE
MAXPLAYERHEALTH MAXPLAYERHEALTH
STARTARMORHEALTH STARTARMORHEALTH
RESPAWNACTORTIME RESPAWNACTORTIME
RESPAWNITEMTIME RESPAWNITEMTIME
RUNNINGSPEED RUNNINGSPEED
RPGBLASTRADIUS GRAVITATIONALCONSTANT
PIPEBOMBRADIUS RPGBLASTRADIUS
SHRINKERBLASTRADIUS PIPEBOMBRADIUS
TRIPBOMBBLASTRADIUS SHRINKERBLASTRADIUS
MORTERBLASTRADIUS TRIPBOMBBLASTRADIUS
BOUNCEMINEBLASTRADIUS MORTERBLASTRADIUS
SEENINEBLASTRADIUS BOUNCEMINEBLASTRADIUS
MAXPISTOLAMMO SEENINEBLASTRADIUS
MAXSHOTGUNAMMO MAXPISTOLAMMO
MAXCHAINGUNAMMO MAXSHOTGUNAMMO
MAXRPGAMMO MAXCHAINGUNAMMO
MAXHANDBOMBAMMO MAXRPGAMMO
MAXSHRINKERAMMO MAXHANDBOMBAMMO
MAXDEVISTATORAMMO MAXSHRINKERAMMO
MAXTRIPBOMBAMMO MAXDEVISTATORAMMO
MAXFREEZEAMMO MAXTRIPBOMBAMMO
CAMERASDESTRUCTABLE MAXFREEZEAMMO
NUMFREEZEBOUNCES MAXGROWAMMO
FREEZERHURTOWNER CAMERASDESTRUCTABLE
NUMFREEZEBOUNCES
FREEZERHURTOWNER
QSIZE
TRIPBOMBLASERMODE
*/
2012-12-29 15:21:24 +00:00
G_DoGameStartup ( params ) ;
2011-04-07 01:16:29 +00:00
}
continue ;
2006-04-13 20:47:06 +00:00
}
2006-11-16 03:02:42 +00:00
}
2011-04-07 01:16:29 +00:00
while ( loop ) ;
2006-04-13 20:47:06 +00:00
return 0 ;
}
2009-01-10 07:38:50 +00:00
/* Anything added with C_AddDefinition() cannot be overwritten in the CONs */
static void C_AddDefinition ( const char * lLabel , int32_t lValue , int32_t lType )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
Bstrcpy ( label + ( g_numLabels < < 6 ) , lLabel ) ;
labeltype [ g_numLabels ] = lType ;
2010-08-02 08:13:51 +00:00
hash_add ( & h_labels , label + ( g_numLabels < < 6 ) , g_numLabels , 0 ) ;
2008-11-20 14:06:36 +00:00
labelcode [ g_numLabels + + ] = lValue ;
g_numDefaultLabels + + ;
2006-04-13 20:47:06 +00:00
}
2012-11-25 13:18:41 +00:00
// KEEPINSYNC lunatic/con_lang.lua
2008-11-20 14:06:36 +00:00
static void C_AddDefaultDefinitions ( void )
2006-04-13 20:47:06 +00:00
{
2012-02-09 22:44:26 +00:00
int32_t i ;
for ( i = 0 ; i < MAXEVENTS ; i + + )
2012-12-09 13:24:36 +00:00
C_AddDefinition ( EventNames [ i ] , i , LABEL_DEFINE ) ;
2009-01-10 07:38:50 +00:00
2012-10-16 17:05:14 +00:00
for ( i = 0 ; i < NUMGAMEFUNCTIONS ; i + + )
{
int32_t j ;
if ( ! Bstrcmp ( gamefunctions [ i ] , " Show_Console " ) ) continue ;
Bsprintf ( tempbuf , " GAMEFUNC_%s " , gamefunctions [ i ] ) ;
for ( j = Bstrlen ( tempbuf ) ; j > = 0 ; j - - )
tempbuf [ j ] = Btoupper ( tempbuf [ j ] ) ;
C_AddDefinition ( tempbuf , i , LABEL_DEFINE ) ;
}
2012-10-31 15:03:33 +00:00
C_AddDefinition ( " STAT_DEFAULT " , STAT_DEFAULT , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_ACTOR " , STAT_ACTOR , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_ZOMBIEACTOR " , STAT_ZOMBIEACTOR , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_EFFECTOR " , STAT_EFFECTOR , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_PROJECTILE " , STAT_PROJECTILE , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_MISC " , STAT_MISC , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_STANDABLE " , STAT_STANDABLE , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_LOCATOR " , STAT_LOCATOR , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_ACTIVATOR " , STAT_ACTIVATOR , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_TRANSPORT " , STAT_TRANSPORT , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_PLAYER " , STAT_PLAYER , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_FX " , STAT_FX , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_FALLER " , STAT_FALLER , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_DUMMYPLAYER " , STAT_DUMMYPLAYER , LABEL_DEFINE ) ;
C_AddDefinition ( " STAT_LIGHT " , STAT_LIGHT , LABEL_DEFINE ) ;
2014-02-22 19:38:52 +00:00
C_AddDefinition ( " SFLAG_SHADOW " , SFLAG_SHADOW , LABEL_DEFINE ) ;
C_AddDefinition ( " SFLAG_NVG " , SFLAG_NVG , LABEL_DEFINE ) ;
C_AddDefinition ( " SFLAG_NOSHADE " , SFLAG_NOSHADE , LABEL_DEFINE ) ;
C_AddDefinition ( " SFLAG_BADGUY " , SFLAG_BADGUY , LABEL_DEFINE ) ;
C_AddDefinition ( " SFLAG_NOPAL " , SFLAG_NOPAL , LABEL_DEFINE ) ;
C_AddDefinition ( " SFLAG_NOEVENTS " , SFLAG_NOEVENTCODE , LABEL_DEFINE ) ;
C_AddDefinition ( " SFLAG_NOLIGHT " , SFLAG_NOLIGHT , LABEL_DEFINE ) ;
C_AddDefinition ( " SFLAG_USEACTIVATOR " , SFLAG_USEACTIVATOR , LABEL_DEFINE ) ;
C_AddDefinition ( " SFLAG_NOCLIP " , SFLAG_NOCLIP , LABEL_DEFINE ) ;
C_AddDefinition ( " SFLAG_SMOOTHMOVE " , SFLAG_SMOOTHMOVE , LABEL_DEFINE ) ;
C_AddDefinition ( " SFLAG_NOTELEPORT " , SFLAG_NOTELEPORT , LABEL_DEFINE ) ;
2014-03-15 14:10:47 +00:00
C_AddDefinition ( " SFLAG_NODAMAGEPUSH " , SFLAG_NODAMAGEPUSH , LABEL_DEFINE ) ;
2015-02-05 16:30:14 +00:00
C_AddDefinition ( " SFLAG_NOWATERDIP " , SFLAG_NOWATERDIP , LABEL_DEFINE ) ;
2012-10-30 15:54:35 +00:00
2009-01-10 07:38:50 +00:00
C_AddDefinition ( " STR_MAPNAME " , STR_MAPNAME , LABEL_DEFINE ) ;
C_AddDefinition ( " STR_MAPFILENAME " , STR_MAPFILENAME , LABEL_DEFINE ) ;
C_AddDefinition ( " STR_PLAYERNAME " , STR_PLAYERNAME , LABEL_DEFINE ) ;
C_AddDefinition ( " STR_VERSION " , STR_VERSION , LABEL_DEFINE ) ;
C_AddDefinition ( " STR_GAMETYPE " , STR_GAMETYPE , LABEL_DEFINE ) ;
2009-01-13 04:40:56 +00:00
C_AddDefinition ( " STR_VOLUMENAME " , STR_VOLUMENAME , LABEL_DEFINE ) ;
2015-02-08 08:03:50 +00:00
C_AddDefinition ( " STR_YOURTIME " , STR_YOURTIME , LABEL_DEFINE ) ;
C_AddDefinition ( " STR_PARTIME " , STR_PARTIME , LABEL_DEFINE ) ;
C_AddDefinition ( " STR_DESIGNERTIME " , STR_DESIGNERTIME , LABEL_DEFINE ) ;
C_AddDefinition ( " STR_BESTTIME " , STR_BESTTIME , LABEL_DEFINE ) ;
2009-01-10 07:38:50 +00:00
C_AddDefinition ( " NO " , 0 , LABEL_DEFINE | LABEL_ACTION | LABEL_AI | LABEL_MOVE ) ;
2013-07-13 21:04:41 +00:00
C_AddDefinition ( " MAXSTATUS " , MAXSTATUS , LABEL_DEFINE ) ;
C_AddDefinition ( " MAXSPRITES " , MAXSPRITES , LABEL_DEFINE ) ;
C_AddDefinition ( " MAX_WEAPONS " , MAX_WEAPONS , LABEL_DEFINE ) ;
2009-01-10 07:38:50 +00:00
C_AddDefinition ( " PROJ_BOUNCES " , PROJ_BOUNCES , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_BSOUND " , PROJ_BSOUND , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_CLIPDIST " , PROJ_CLIPDIST , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_CSTAT " , PROJ_CSTAT , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_DECAL " , PROJ_DECAL , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_DROP " , PROJ_DROP , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_EXTRA " , PROJ_EXTRA , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_EXTRA_RAND " , PROJ_EXTRA_RAND , LABEL_DEFINE ) ;
2009-05-05 16:21:33 +00:00
C_AddDefinition ( " PROJ_FLASH_COLOR " , PROJ_FLASH_COLOR , LABEL_DEFINE ) ;
2009-01-10 07:38:50 +00:00
C_AddDefinition ( " PROJ_HITRADIUS " , PROJ_HITRADIUS , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_ISOUND " , PROJ_ISOUND , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_OFFSET " , PROJ_OFFSET , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_PAL " , PROJ_PAL , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_RANGE " , PROJ_RANGE , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_SHADE " , PROJ_SHADE , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_SOUND " , PROJ_SOUND , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_SPAWNS " , PROJ_SPAWNS , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_SXREPEAT " , PROJ_SXREPEAT , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_SYREPEAT " , PROJ_SYREPEAT , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_TNUM " , PROJ_TNUM , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_TOFFSET " , PROJ_TOFFSET , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_TRAIL " , PROJ_TRAIL , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_TXREPEAT " , PROJ_TXREPEAT , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_TYREPEAT " , PROJ_TYREPEAT , LABEL_DEFINE ) ;
2013-06-09 16:37:18 +00:00
C_AddDefinition ( " PROJ_USERDATA " , PROJ_USERDATA , LABEL_DEFINE ) ;
2012-10-05 20:48:10 +00:00
C_AddDefinition ( " PROJ_VEL_MULT " , PROJ_MOVECNT , LABEL_DEFINE ) ;
2009-01-10 07:38:50 +00:00
C_AddDefinition ( " PROJ_VEL " , PROJ_VEL , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_WORKSLIKE " , PROJ_WORKSLIKE , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_XREPEAT " , PROJ_XREPEAT , LABEL_DEFINE ) ;
C_AddDefinition ( " PROJ_YREPEAT " , PROJ_YREPEAT , LABEL_DEFINE ) ;
2006-04-13 20:47:06 +00:00
}
2013-02-07 21:00:48 +00:00
# endif
2006-04-13 20:47:06 +00:00
2013-02-07 21:00:48 +00:00
void C_InitProjectiles ( void )
2006-04-13 20:47:06 +00:00
{
2015-03-24 00:40:55 +00:00
defaultprojectile_t const Projectile =
2008-09-29 07:38:12 +00:00
{
2015-04-18 21:59:21 +00:00
// workslike, cstat, hitradius, range, flashcolor;
// spawns, sound, isound, vel, decal, trail, tnum, drop;
// offset, bounces, bsound, toffset, extra, extra_rand;
// sxrepeat, syrepeat, txrepeat, tyrepeat;
// shade, xrepeat, yrepeat, pal;
// movecnt, clipdist, filler[2], userdata;
// XXX: The default projectie seems to mimic a union of hard-coded ones.
1 , - 1 , 2048 , 0 , 0 ,
( int16_t ) SMALLSMOKE , - 1 , - 1 , 600 , ( int16_t ) BULLETHOLE , - 1 , 0 , 0 ,
448 , ( int16_t ) g_numFreezeBounces , ( int16_t ) PIPEBOMB_BOUNCE , 1 , 100 , - 1 ,
- 1 , - 1 , - 1 , - 1 ,
- 96 , 18 , 18 , 0 ,
1 , 32 , { 0 , 0 } , 0 ,
2008-09-29 07:38:12 +00:00
} ;
2015-03-24 00:40:55 +00:00
DefaultProjectile = Projectile ;
2008-09-29 07:38:12 +00:00
2015-03-24 00:40:55 +00:00
for ( int i = MAXTILES - 1 ; i > = 0 ; i - - )
2012-10-30 15:54:35 +00:00
{
2015-03-24 00:40:55 +00:00
if ( g_tile [ i ] . proj )
2015-04-18 21:59:21 +00:00
* g_tile [ i ] . proj = DefaultProjectile ;
2015-03-24 00:40:55 +00:00
if ( g_tile [ i ] . defproj )
2015-04-18 21:59:21 +00:00
* g_tile [ i ] . defproj = DefaultProjectile ;
2012-10-30 15:54:35 +00:00
}
2006-04-13 20:47:06 +00:00
}
2013-02-07 21:00:48 +00:00
# if !defined LUNATIC
2009-01-09 09:29:17 +00:00
extern int32_t g_numObituaries ;
extern int32_t g_numSelfObituaries ;
2008-09-28 11:00:59 +00:00
2013-05-23 18:28:04 +00:00
static char * C_ScriptVersionString ( int32_t version )
{
switch ( version )
{
case 9 :
return " 0.99 " ;
case 10 :
return " 1.0 " ;
case 11 :
return " 1.1 " ;
case 13 :
return " 1.3D " ;
default :
return " 1.4+ " ;
}
}
2008-11-20 14:06:36 +00:00
void C_Compile ( const char * filenam )
2006-04-13 20:47:06 +00:00
{
char * mptr ;
2009-01-09 09:29:17 +00:00
int32_t i ;
int32_t fs , fp ;
2011-12-21 18:42:32 +00:00
uint32_t startcompiletime ;
2006-04-13 20:47:06 +00:00
2011-12-21 18:42:32 +00:00
Bmemset ( apScriptGameEvent , 0 , sizeof ( apScriptGameEvent ) ) ;
2006-04-13 20:47:06 +00:00
2012-10-31 15:03:33 +00:00
for ( i = MAXTILES - 1 ; i > = 0 ; i - - )
Bmemset ( & g_tile [ i ] , 0 , sizeof ( tiledata_t ) ) ;
2009-01-05 14:43:12 +00:00
C_InitHashes ( ) ;
2013-01-01 15:24:18 +00:00
2008-11-20 14:06:36 +00:00
Gv_Init ( ) ;
2013-01-01 15:24:18 +00:00
2008-11-20 14:06:36 +00:00
C_InitProjectiles ( ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
fp = kopen4loadfrommod ( ( char * ) filenam , g_loadFromGroupOnly ) ;
2006-11-14 21:35:50 +00:00
if ( fp = = - 1 ) // JBF: was 0
2006-04-13 20:47:06 +00:00
{
2009-01-09 09:29:17 +00:00
extern int32_t numgroupfiles ;
2008-10-01 04:38:14 +00:00
2009-09-09 07:19:14 +00:00
if ( g_loadFromGroupOnly = = 1 | | numgroupfiles = = 0 )
2006-11-15 01:16:55 +00:00
{
2013-06-01 06:57:00 +00:00
# ifdef _WIN32
2012-03-26 05:05:57 +00:00
Bsprintf ( tempbuf , " Duke Nukem 3D game data was not found. A valid copy of \" %s \" or other compatible data is needed to run EDuke32. \n \n "
2012-06-27 17:45:52 +00:00
" You can find \" %s \" in the \" DN3DINST \" or \" ATOMINST \" directory on your Duke Nukem 3D installation CD-ROM. \n \n "
2010-01-23 22:12:02 +00:00
" If you don't already own a copy of Duke or haven't seen your disc in years, don't worry -- you can download the full, registered "
" version of Duke Nukem 3D: Atomic Edition immediately for only $5.99 through our partnership with GOG.com. \n \n "
" Not a typo; it's less than 6 bucks. Get Duke now? \n \n "
" (Clicking yes will bring you to our web store) " ,
2012-06-03 16:09:33 +00:00
G_GrpFile ( ) , G_GrpFile ( ) ) ;
2009-09-09 07:19:14 +00:00
2012-03-05 07:25:24 +00:00
if ( wm_ynbox ( " Important - Duke Nukem 3D not found - EDuke32 " , " %s " , tempbuf ) )
2009-09-09 07:19:14 +00:00
{
SHELLEXECUTEINFOA sinfo ;
2011-07-05 04:56:51 +00:00
char * p = " http://www.gog.com/en/gamecard/duke_nukem_3d_atomic_edition/?pp=6c1e671f9af5b46d9c1a52067bdf0e53685674f7 " ;
2009-09-09 07:19:14 +00:00
Bmemset ( & sinfo , 0 , sizeof ( sinfo ) ) ;
sinfo . cbSize = sizeof ( sinfo ) ;
sinfo . fMask = SEE_MASK_CLASSNAME ;
sinfo . lpVerb = " open " ;
sinfo . lpFile = p ;
sinfo . nShow = SW_SHOWNORMAL ;
sinfo . lpClass = " http " ;
if ( ! ShellExecuteExA ( & sinfo ) )
2009-09-28 00:01:06 +00:00
G_GameExit ( " Error launching default system browser! " ) ;
2009-09-09 07:19:14 +00:00
}
G_GameExit ( " " ) ;
2012-12-29 15:21:24 +00:00
# else
2012-03-26 05:05:57 +00:00
Bsprintf ( tempbuf , " Duke Nukem 3D game data was not found. A valid copy of \" %s \" or other compatible data is needed to run EDuke32. \n "
2012-06-27 17:45:52 +00:00
" You can find \" %s \" in the \" DN3DINST \" or \" ATOMINST \" directory on your Duke Nukem 3D installation CD-ROM. \n \n "
2008-10-05 09:23:55 +00:00
" EDuke32 will now close. " ,
2012-06-03 16:09:33 +00:00
G_GrpFile ( ) , G_GrpFile ( ) ) ;
2009-09-09 07:19:14 +00:00
G_GameExit ( tempbuf ) ;
2012-12-29 15:21:24 +00:00
# endif
2009-09-09 07:19:14 +00:00
}
else
{
Bsprintf ( tempbuf , " CON file `%s' missing. " , filenam ) ;
G_GameExit ( tempbuf ) ;
2008-10-01 04:38:14 +00:00
}
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
//g_loadFromGroupOnly = 1;
2006-04-13 20:47:06 +00:00
return ; //Not there
}
fs = kfilelength ( fp ) ;
2007-12-12 17:42:14 +00:00
initprintf ( " Compiling: %s (%d bytes) \n " , filenam , fs ) ;
2006-04-13 20:47:06 +00:00
2009-06-13 21:06:45 +00:00
flushlogwindow = 0 ;
2008-08-26 08:39:45 +00:00
startcompiletime = getticks ( ) ;
2014-05-30 00:02:19 +00:00
mptr = ( char * ) Xmalloc ( fs + 1 ) ;
2006-04-13 20:47:06 +00:00
mptr [ fs ] = 0 ;
textptr = ( char * ) mptr ;
kread ( fp , ( char * ) textptr , fs ) ;
kclose ( fp ) ;
2007-08-29 04:01:21 +00:00
if ( script ! = NULL )
Bfree ( script ) ;
2008-08-16 07:53:29 +00:00
2014-05-30 00:02:19 +00:00
script = ( intptr_t * ) Xcalloc ( 1 , g_scriptSize * sizeof ( intptr_t ) ) ;
bitptr = ( char * ) Xcalloc ( 1 , ( ( ( g_scriptSize + 7 ) > > 3 ) + 1 ) * sizeof ( uint8_t ) ) ;
2008-08-16 11:30:43 +00:00
// initprintf("script: %d, bitptr: %d\n",script,bitptr);
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
g_numLabels = g_numDefaultLabels = 0 ;
2011-12-25 15:35:06 +00:00
g_scriptPtr = script + 3 ; // move permits constants 0 and 1; moveptr[1] would be script[2] (reachable?)
2008-11-20 14:06:36 +00:00
g_numCompilerWarnings = 0 ;
g_numCompilerErrors = 0 ;
g_lineNumber = 1 ;
g_totalLines = 0 ;
C_AddDefaultDefinitions ( ) ;
Bstrcpy ( g_szScriptFileName , filenam ) ; // JBF 20031130: Store currently compiling file name
2011-05-20 02:34:41 +00:00
C_ParseCommand ( 1 ) ;
2006-04-13 20:47:06 +00:00
2011-07-21 22:39:29 +00:00
for ( i = 0 ; i < g_scriptModulesNum ; + + i )
{
C_Include ( g_scriptModules [ i ] ) ;
Bfree ( g_scriptModules [ i ] ) ;
}
Bfree ( g_scriptModules ) ;
2012-01-05 20:48:05 +00:00
g_scriptModules = NULL ;
2014-08-31 11:15:21 +00:00
g_scriptModulesNum = 0 ;
2011-07-21 22:39:29 +00:00
2009-01-06 06:59:18 +00:00
flushlogwindow = 1 ;
2008-11-20 14:06:36 +00:00
if ( g_numCompilerErrors > 63 )
initprintf ( " fatal error: too many errors: Aborted \n " ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
//*script = (intptr_t) g_scriptPtr;
2006-04-13 20:47:06 +00:00
Bfree ( mptr ) ;
2006-04-23 04:50:08 +00:00
mptr = NULL ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( g_numCompilerWarnings | g_numCompilerErrors )
initprintf ( " Found %d warning(s), %d error(s). \n " , g_numCompilerWarnings , g_numCompilerErrors ) ;
2006-04-13 20:47:06 +00:00
2008-11-20 14:06:36 +00:00
if ( g_numCompilerErrors )
2006-04-13 20:47:06 +00:00
{
2008-11-20 14:06:36 +00:00
if ( g_loadFromGroupOnly )
2006-04-13 20:47:06 +00:00
{
2009-02-02 01:49:14 +00:00
Bsprintf ( buf , " Error compiling CON files. " ) ;
2008-11-20 14:06:36 +00:00
G_GameExit ( buf ) ;
2006-04-13 20:47:06 +00:00
}
else
{
2008-11-20 14:06:36 +00:00
if ( g_groupFileHandle ! = - 1 & & g_loadFromGroupOnly = = 0 )
2006-04-13 20:47:06 +00:00
{
2008-07-10 05:37:36 +00:00
// initprintf("Error(s) found in file `%s'. Do you want to use the INTERNAL DEFAULTS (y/N)?\n",filenam);
2006-04-13 20:47:06 +00:00
i = wm_ynbox ( " CON File Compilation Error " , " Error(s) found in file `%s'. Do you want to use the "
" INTERNAL DEFAULTS? " , filenam ) ;
if ( i ) i = ' y ' ;
2006-11-14 21:35:50 +00:00
if ( i = = ' y ' | | i = = ' Y ' )
2006-04-13 20:47:06 +00:00
{
initprintf ( " Yes \n " ) ;
2008-11-20 14:06:36 +00:00
g_loadFromGroupOnly = 1 ;
2006-04-13 20:47:06 +00:00
return ;
}
2008-07-13 07:10:47 +00:00
else
2008-07-10 05:37:36 +00:00
{
2012-12-29 15:21:24 +00:00
# if (defined _WIN32 || (defined RENDERTYPESDL && ((defined __APPLE__ && defined OSX_STARTUPWINDOW) || defined HAVE_GTK2)))
2008-07-13 07:10:47 +00:00
while ( ! quitevent ) // keep the window open so people can copy CON errors out of it
2008-07-10 05:37:36 +00:00
handleevents ( ) ;
2012-12-29 15:21:24 +00:00
# endif
2008-11-20 14:06:36 +00:00
G_GameExit ( " " ) ;
2008-07-10 05:37:36 +00:00
}
2006-04-13 20:47:06 +00:00
}
}
}
else
{
2010-05-19 10:02:35 +00:00
int32_t j = 0 , k = 0 , l = 0 ;
2006-04-13 20:47:06 +00:00
2015-03-27 12:28:45 +00:00
for ( i = 0 ; i < MAXEVENTS ; + + i )
{
intptr_t * eventEnd = apScriptGameEventEnd [ i ] ;
if ( eventEnd )
{
// C_FillEventBreakStackWithEndEvent
intptr_t * breakPtr = ( intptr_t * ) * ( eventEnd + 2 ) ;
while ( breakPtr )
{
* ( breakPtr - 2 ) = CON_ENDEVENT ;
breakPtr = ( intptr_t * ) * breakPtr ;
}
}
}
2014-09-30 04:15:41 +00:00
hash_free ( & h_labels ) ;
2010-05-02 23:27:30 +00:00
hash_free ( & h_keywords ) ;
2008-08-26 08:39:45 +00:00
freehashnames ( ) ;
2013-06-01 06:55:30 +00:00
freesoundhashnames ( ) ;
2008-08-26 08:39:45 +00:00
2009-01-10 07:38:50 +00:00
hash_free ( & sectorH ) ;
hash_free ( & wallH ) ;
hash_free ( & userdefH ) ;
2008-08-26 08:39:45 +00:00
2009-01-10 07:38:50 +00:00
hash_free ( & projectileH ) ;
hash_free ( & playerH ) ;
hash_free ( & inputH ) ;
hash_free ( & actorH ) ;
hash_free ( & tspriteH ) ;
2008-08-26 08:39:45 +00:00
2008-11-20 14:06:36 +00:00
g_totalLines + = g_lineNumber ;
2008-08-25 10:27:18 +00:00
2009-05-05 16:21:33 +00:00
C_SetScriptSize ( g_scriptPtr - script + 8 ) ;
2008-08-25 10:27:18 +00:00
2013-05-23 18:28:04 +00:00
initprintf ( " Script compiled in %dms, %ld*%db, language version %s \n " , getticks ( ) - startcompiletime ,
( unsigned long ) ( g_scriptPtr - script ) , ( int32_t ) sizeof ( intptr_t ) , C_ScriptVersionString ( g_scriptVersion ) ) ;
2009-01-10 07:38:50 +00:00
2012-12-13 02:33:53 +00:00
initprintf ( " %d/%d labels, %d/%d variables, %d/%d arrays \n " , g_numLabels ,
2011-02-12 13:25:24 +00:00
( int32_t ) min ( ( MAXSECTORS * sizeof ( sectortype ) / sizeof ( int32_t ) ) ,
MAXSPRITES * sizeof ( spritetype ) / ( 1 < < 6 ) ) ,
2012-12-13 02:33:53 +00:00
g_gameVarCount , MAXGAMEVARS , g_gameArrayCount , MAXGAMEARRAYS ) ;
2008-08-25 10:27:18 +00:00
2009-02-19 16:47:54 +00:00
for ( i = MAXQUOTES - 1 ; i > = 0 ; i - - )
2008-11-20 14:06:36 +00:00
if ( ScriptQuotes [ i ] )
2008-08-25 10:27:18 +00:00
j + + ;
2009-02-19 16:47:54 +00:00
for ( i = MAXGAMEEVENTS - 1 ; i > = 0 ; i - - )
2006-11-13 23:12:47 +00:00
if ( apScriptGameEvent [ i ] )
2010-05-19 10:02:35 +00:00
k + + ;
2009-02-19 16:47:54 +00:00
for ( i = MAXTILES - 1 ; i > = 0 ; i - - )
2012-10-30 15:54:35 +00:00
if ( g_tile [ i ] . execPtr )
2010-05-19 10:02:35 +00:00
l + + ;
2010-12-19 22:47:10 +00:00
if ( j ) initprintf ( " %d quotes, " , j ) ;
2010-05-19 10:02:35 +00:00
if ( g_numQuoteRedefinitions ) initprintf ( " %d strings, " , g_numQuoteRedefinitions ) ;
2010-12-19 22:47:10 +00:00
if ( k ) initprintf ( " %d events, " , k ) ;
if ( l ) initprintf ( " %d actors " , l ) ;
2006-04-24 02:58:15 +00:00
2010-05-19 10:02:35 +00:00
initprintf ( " \n " ) ;
2006-04-24 02:58:15 +00:00
2013-01-01 15:24:25 +00:00
C_InitQuotes ( ) ;
2006-04-13 20:47:06 +00:00
}
}
2009-01-09 09:29:17 +00:00
void C_ReportError ( int32_t iError )
2006-04-13 20:47:06 +00:00
{
2009-01-13 04:40:56 +00:00
if ( Bstrcmp ( g_szCurrentBlockName , g_szLastBlockName ) )
{
if ( g_parsingEventPtr | | g_processingState | | g_parsingActorPtr )
initprintf ( " %s: In %s `%s': \n " , g_szScriptFileName , g_parsingEventPtr ? " event " : g_parsingActorPtr ? " actor " : " state " , g_szCurrentBlockName ) ;
else initprintf ( " %s: At top level: \n " , g_szScriptFileName ) ;
Bstrcpy ( g_szLastBlockName , g_szCurrentBlockName ) ;
}
switch ( iError )
{
case ERROR_CLOSEBRACKET :
initprintf ( " %s:%d: error: found more `}' than `{' before `%s'. \n " , g_szScriptFileName , g_lineNumber , tempbuf ) ;
break ;
case ERROR_EVENTONLY :
initprintf ( " %s:%d: error: `%s' only valid during events. \n " , g_szScriptFileName , g_lineNumber , tempbuf ) ;
break ;
case ERROR_EXCEEDSMAXTILES :
initprintf ( " %s:%d: error: `%s' value exceeds MAXTILES. Maximum is %d. \n " , g_szScriptFileName , g_lineNumber , tempbuf , MAXTILES - 1 ) ;
break ;
case ERROR_EXPECTEDKEYWORD :
initprintf ( " %s:%d: error: expected a keyword but found `%s'. \n " , g_szScriptFileName , g_lineNumber , tempbuf ) ;
break ;
case ERROR_FOUNDWITHIN :
initprintf ( " %s:%d: error: found `%s' within %s. \n " , g_szScriptFileName , g_lineNumber , tempbuf , g_parsingEventPtr ? " an event " : g_parsingActorPtr ? " an actor " : " a state " ) ;
break ;
case ERROR_ISAKEYWORD :
initprintf ( " %s:%d: error: symbol `%s' is a keyword. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
break ;
case ERROR_NOENDSWITCH :
initprintf ( " %s:%d: error: did not find `endswitch' before `%s'. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
break ;
case ERROR_NOTAGAMEDEF :
initprintf ( " %s:%d: error: symbol `%s' is not a game definition. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
break ;
case ERROR_NOTAGAMEVAR :
initprintf ( " %s:%d: error: symbol `%s' is not a game variable. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
break ;
case ERROR_NOTAGAMEARRAY :
initprintf ( " %s:%d: error: symbol `%s' is not a game array. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
break ;
case ERROR_GAMEARRAYBNC :
initprintf ( " %s:%d: error: square brackets for index of game array not closed, expected ] found %c \n " , g_szScriptFileName , g_lineNumber , * textptr ) ;
break ;
case ERROR_GAMEARRAYBNO :
initprintf ( " %s:%d: error: square brackets for index of game array not opened, expected [ found %c \n " , g_szScriptFileName , g_lineNumber , * textptr ) ;
break ;
case ERROR_INVALIDARRAYWRITE :
2014-02-09 19:22:36 +00:00
initprintf ( " %s:%d: error: arrays can only be written to using `setarray'. \n " , g_szScriptFileName , g_lineNumber ) ;
2009-01-13 04:40:56 +00:00
break ;
case ERROR_OPENBRACKET :
initprintf ( " %s:%d: error: found more `{' than `}' before `%s'. \n " , g_szScriptFileName , g_lineNumber , tempbuf ) ;
break ;
case ERROR_PARAMUNDEFINED :
initprintf ( " %s:%d: error: parameter `%s' is undefined. \n " , g_szScriptFileName , g_lineNumber , tempbuf ) ;
break ;
case ERROR_SYMBOLNOTRECOGNIZED :
initprintf ( " %s:%d: error: symbol `%s' is not recognized. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
break ;
case ERROR_SYNTAXERROR :
initprintf ( " %s:%d: error: syntax error. \n " , g_szScriptFileName , g_lineNumber ) ;
break ;
case ERROR_VARREADONLY :
initprintf ( " %s:%d: error: variable `%s' is read-only. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
break ;
2012-12-13 02:33:53 +00:00
case ERROR_ARRAYREADONLY :
initprintf ( " %s:%d: error: array `%s' is read-only. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
break ;
2009-01-13 04:40:56 +00:00
case ERROR_VARTYPEMISMATCH :
initprintf ( " %s:%d: error: variable `%s' is of the wrong type. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
break ;
case WARNING_BADGAMEVAR :
2010-12-19 22:47:10 +00:00
initprintf ( " %s:%d: warning: variable `%s' should be either per-player OR per-actor, not both. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
2009-01-13 04:40:56 +00:00
break ;
case WARNING_DUPLICATECASE :
2010-12-19 22:47:10 +00:00
initprintf ( " %s:%d: warning: duplicate case ignored. \n " , g_szScriptFileName , g_lineNumber ) ;
2009-01-13 04:40:56 +00:00
break ;
case WARNING_DUPLICATEDEFINITION :
initprintf ( " %s:%d: warning: duplicate game definition `%s' ignored. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
break ;
case WARNING_EVENTSYNC :
initprintf ( " %s:%d: warning: found `%s' within a local event. \n " , g_szScriptFileName , g_lineNumber , tempbuf ) ;
break ;
case WARNING_LABELSONLY :
initprintf ( " %s:%d: warning: expected a label, found a constant. \n " , g_szScriptFileName , g_lineNumber ) ;
break ;
case WARNING_NAMEMATCHESVAR :
initprintf ( " %s:%d: warning: symbol `%s' already used for game variable. \n " , g_szScriptFileName , g_lineNumber , label + ( g_numLabels < < 6 ) ) ;
break ;
}
2006-04-13 20:47:06 +00:00
}
2013-01-20 21:17:06 +00:00
# endif