mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Lunatic/LT: provide the predefined labels in con_lang, add "strict" from luajit.
The latter is only for development, since the embedded version already has a undeclared-var-reference handling similar to that. Also fix parm2memberpat. git-svn-id: https://svn.eduke32.com/eduke32@2762 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b30ac41147
commit
5bdbd2eda5
7 changed files with 281 additions and 156 deletions
|
@ -133,6 +133,7 @@ extern int32_t g_errorLineNum;
|
||||||
extern int32_t g_tw;
|
extern int32_t g_tw;
|
||||||
extern const char *keyw[];
|
extern const char *keyw[];
|
||||||
|
|
||||||
|
// KEEPINSYNC lunatic/con_lang.lua
|
||||||
enum SystemString_t {
|
enum SystemString_t {
|
||||||
STR_MAPNAME,
|
STR_MAPNAME,
|
||||||
STR_MAPFILENAME,
|
STR_MAPFILENAME,
|
||||||
|
@ -542,37 +543,38 @@ enum InputLabel_t
|
||||||
INPUT_END
|
INPUT_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// KEEPINSYNC lunatic/con_lang.lua
|
||||||
enum ProjectileLabel_t
|
enum ProjectileLabel_t
|
||||||
{
|
{
|
||||||
PROJ_WORKSLIKE,
|
PROJ_WORKSLIKE, // 0
|
||||||
PROJ_SPAWNS,
|
PROJ_SPAWNS,
|
||||||
PROJ_SXREPEAT,
|
PROJ_SXREPEAT,
|
||||||
PROJ_SYREPEAT,
|
PROJ_SYREPEAT,
|
||||||
PROJ_SOUND,
|
PROJ_SOUND,
|
||||||
PROJ_ISOUND,
|
PROJ_ISOUND, // 5
|
||||||
PROJ_VEL,
|
PROJ_VEL,
|
||||||
PROJ_EXTRA,
|
PROJ_EXTRA,
|
||||||
PROJ_DECAL,
|
PROJ_DECAL,
|
||||||
PROJ_TRAIL,
|
PROJ_TRAIL,
|
||||||
PROJ_TXREPEAT,
|
PROJ_TXREPEAT, // 10
|
||||||
PROJ_TYREPEAT,
|
PROJ_TYREPEAT,
|
||||||
PROJ_TOFFSET,
|
PROJ_TOFFSET,
|
||||||
PROJ_TNUM,
|
PROJ_TNUM,
|
||||||
PROJ_DROP,
|
PROJ_DROP,
|
||||||
PROJ_CSTAT,
|
PROJ_CSTAT, // 15
|
||||||
PROJ_CLIPDIST,
|
PROJ_CLIPDIST,
|
||||||
PROJ_SHADE,
|
PROJ_SHADE,
|
||||||
PROJ_XREPEAT,
|
PROJ_XREPEAT,
|
||||||
PROJ_YREPEAT,
|
PROJ_YREPEAT,
|
||||||
PROJ_PAL,
|
PROJ_PAL, // 20
|
||||||
PROJ_EXTRA_RAND,
|
PROJ_EXTRA_RAND,
|
||||||
PROJ_HITRADIUS,
|
PROJ_HITRADIUS,
|
||||||
PROJ_VEL_MULT,
|
PROJ_VEL_MULT,
|
||||||
PROJ_OFFSET,
|
PROJ_OFFSET,
|
||||||
PROJ_BOUNCES,
|
PROJ_BOUNCES, // 25
|
||||||
PROJ_BSOUND,
|
PROJ_BSOUND,
|
||||||
PROJ_RANGE,
|
PROJ_RANGE,
|
||||||
PROJ_FLASH_COLOR, // 29
|
PROJ_FLASH_COLOR,
|
||||||
PROJ_END
|
PROJ_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,99 +28,99 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "gamedef.h" // vmstate_t
|
#include "gamedef.h" // vmstate_t
|
||||||
|
|
||||||
// the order of these can't be changed or else compatibility with EDuke 2.0 mods will break
|
// the order of these can't be changed or else compatibility with EDuke 2.0 mods will break
|
||||||
// KEEPINSYNC2 with EventNames[] and same enum in defs.ilua
|
// KEEPINSYNC2 with EventNames[] and lunatic/con_lang.lua
|
||||||
enum GameEvent_t {
|
enum GameEvent_t {
|
||||||
EVENT_INIT,
|
EVENT_INIT, // 0
|
||||||
EVENT_ENTERLEVEL,
|
EVENT_ENTERLEVEL,
|
||||||
EVENT_RESETWEAPONS,
|
EVENT_RESETWEAPONS,
|
||||||
EVENT_RESETINVENTORY,
|
EVENT_RESETINVENTORY,
|
||||||
EVENT_HOLSTER,
|
EVENT_HOLSTER,
|
||||||
EVENT_LOOKLEFT,
|
EVENT_LOOKLEFT, // 5
|
||||||
EVENT_LOOKRIGHT,
|
EVENT_LOOKRIGHT,
|
||||||
EVENT_SOARUP,
|
EVENT_SOARUP,
|
||||||
EVENT_SOARDOWN,
|
EVENT_SOARDOWN,
|
||||||
EVENT_CROUCH,
|
EVENT_CROUCH,
|
||||||
EVENT_JUMP,
|
EVENT_JUMP, // 10
|
||||||
EVENT_RETURNTOCENTER,
|
EVENT_RETURNTOCENTER,
|
||||||
EVENT_LOOKUP,
|
EVENT_LOOKUP,
|
||||||
EVENT_LOOKDOWN,
|
EVENT_LOOKDOWN,
|
||||||
EVENT_AIMUP,
|
EVENT_AIMUP,
|
||||||
EVENT_FIRE,
|
EVENT_FIRE, // 15
|
||||||
EVENT_CHANGEWEAPON,
|
EVENT_CHANGEWEAPON,
|
||||||
EVENT_GETSHOTRANGE,
|
EVENT_GETSHOTRANGE,
|
||||||
EVENT_GETAUTOAIMANGLE,
|
EVENT_GETAUTOAIMANGLE,
|
||||||
EVENT_GETLOADTILE,
|
EVENT_GETLOADTILE,
|
||||||
EVENT_CHEATGETSTEROIDS,
|
EVENT_CHEATGETSTEROIDS, // 20
|
||||||
EVENT_CHEATGETHEAT,
|
EVENT_CHEATGETHEAT,
|
||||||
EVENT_CHEATGETBOOT,
|
EVENT_CHEATGETBOOT,
|
||||||
EVENT_CHEATGETSHIELD,
|
EVENT_CHEATGETSHIELD,
|
||||||
EVENT_CHEATGETSCUBA,
|
EVENT_CHEATGETSCUBA,
|
||||||
EVENT_CHEATGETHOLODUKE,
|
EVENT_CHEATGETHOLODUKE, // 25
|
||||||
EVENT_CHEATGETJETPACK,
|
EVENT_CHEATGETJETPACK,
|
||||||
EVENT_CHEATGETFIRSTAID,
|
EVENT_CHEATGETFIRSTAID,
|
||||||
EVENT_QUICKKICK,
|
EVENT_QUICKKICK,
|
||||||
EVENT_INVENTORY,
|
EVENT_INVENTORY,
|
||||||
EVENT_USENIGHTVISION,
|
EVENT_USENIGHTVISION, // 30
|
||||||
EVENT_USESTEROIDS,
|
EVENT_USESTEROIDS,
|
||||||
EVENT_INVENTORYLEFT,
|
EVENT_INVENTORYLEFT,
|
||||||
EVENT_INVENTORYRIGHT,
|
EVENT_INVENTORYRIGHT,
|
||||||
EVENT_HOLODUKEON,
|
EVENT_HOLODUKEON,
|
||||||
EVENT_HOLODUKEOFF,
|
EVENT_HOLODUKEOFF, // 35
|
||||||
EVENT_USEMEDKIT,
|
EVENT_USEMEDKIT,
|
||||||
EVENT_USEJETPACK,
|
EVENT_USEJETPACK,
|
||||||
EVENT_TURNAROUND,
|
EVENT_TURNAROUND,
|
||||||
EVENT_DISPLAYWEAPON,
|
EVENT_DISPLAYWEAPON,
|
||||||
EVENT_FIREWEAPON,
|
EVENT_FIREWEAPON, // 40
|
||||||
EVENT_SELECTWEAPON,
|
EVENT_SELECTWEAPON,
|
||||||
EVENT_MOVEFORWARD,
|
EVENT_MOVEFORWARD,
|
||||||
EVENT_MOVEBACKWARD,
|
EVENT_MOVEBACKWARD,
|
||||||
EVENT_TURNLEFT,
|
EVENT_TURNLEFT,
|
||||||
EVENT_TURNRIGHT,
|
EVENT_TURNRIGHT, // 45
|
||||||
EVENT_STRAFELEFT,
|
EVENT_STRAFELEFT,
|
||||||
EVENT_STRAFERIGHT,
|
EVENT_STRAFERIGHT,
|
||||||
EVENT_WEAPKEY1,
|
EVENT_WEAPKEY1,
|
||||||
EVENT_WEAPKEY2,
|
EVENT_WEAPKEY2,
|
||||||
EVENT_WEAPKEY3,
|
EVENT_WEAPKEY3, // 50
|
||||||
EVENT_WEAPKEY4,
|
EVENT_WEAPKEY4,
|
||||||
EVENT_WEAPKEY5,
|
EVENT_WEAPKEY5,
|
||||||
EVENT_WEAPKEY6,
|
EVENT_WEAPKEY6,
|
||||||
EVENT_WEAPKEY7,
|
EVENT_WEAPKEY7,
|
||||||
EVENT_WEAPKEY8,
|
EVENT_WEAPKEY8, // 55
|
||||||
EVENT_WEAPKEY9,
|
EVENT_WEAPKEY9,
|
||||||
EVENT_WEAPKEY10,
|
EVENT_WEAPKEY10,
|
||||||
EVENT_DRAWWEAPON,
|
EVENT_DRAWWEAPON,
|
||||||
EVENT_DISPLAYCROSSHAIR,
|
EVENT_DISPLAYCROSSHAIR,
|
||||||
EVENT_DISPLAYREST,
|
EVENT_DISPLAYREST, // 60
|
||||||
EVENT_DISPLAYSBAR,
|
EVENT_DISPLAYSBAR,
|
||||||
EVENT_RESETPLAYER,
|
EVENT_RESETPLAYER,
|
||||||
EVENT_INCURDAMAGE,
|
EVENT_INCURDAMAGE,
|
||||||
EVENT_AIMDOWN,
|
EVENT_AIMDOWN,
|
||||||
EVENT_GAME,
|
EVENT_GAME, // 65
|
||||||
EVENT_PREVIOUSWEAPON,
|
EVENT_PREVIOUSWEAPON,
|
||||||
EVENT_NEXTWEAPON,
|
EVENT_NEXTWEAPON,
|
||||||
EVENT_SWIMUP,
|
EVENT_SWIMUP,
|
||||||
EVENT_SWIMDOWN,
|
EVENT_SWIMDOWN,
|
||||||
EVENT_GETMENUTILE,
|
EVENT_GETMENUTILE, // 70
|
||||||
EVENT_SPAWN,
|
EVENT_SPAWN,
|
||||||
EVENT_LOGO,
|
EVENT_LOGO,
|
||||||
EVENT_EGS,
|
EVENT_EGS,
|
||||||
EVENT_DOFIRE,
|
EVENT_DOFIRE,
|
||||||
EVENT_PRESSEDFIRE,
|
EVENT_PRESSEDFIRE, // 75
|
||||||
EVENT_USE,
|
EVENT_USE,
|
||||||
EVENT_PROCESSINPUT,
|
EVENT_PROCESSINPUT,
|
||||||
EVENT_FAKEDOMOVETHINGS,
|
EVENT_FAKEDOMOVETHINGS,
|
||||||
EVENT_DISPLAYROOMS,
|
EVENT_DISPLAYROOMS,
|
||||||
EVENT_KILLIT,
|
EVENT_KILLIT, // 80
|
||||||
EVENT_LOADACTOR,
|
EVENT_LOADACTOR,
|
||||||
EVENT_DISPLAYBONUSSCREEN,
|
EVENT_DISPLAYBONUSSCREEN,
|
||||||
EVENT_DISPLAYMENU,
|
EVENT_DISPLAYMENU,
|
||||||
EVENT_DISPLAYMENUREST,
|
EVENT_DISPLAYMENUREST,
|
||||||
EVENT_DISPLAYLOADINGSCREEN,
|
EVENT_DISPLAYLOADINGSCREEN, // 85
|
||||||
EVENT_ANIMATESPRITES,
|
EVENT_ANIMATESPRITES,
|
||||||
EVENT_NEWGAME,
|
EVENT_NEWGAME,
|
||||||
EVENT_SOUND,
|
EVENT_SOUND,
|
||||||
EVENT_CHECKTOUCHDAMAGE,
|
EVENT_CHECKTOUCHDAMAGE,
|
||||||
EVENT_CHECKFLOORDAMAGE,
|
EVENT_CHECKFLOORDAMAGE, // 90
|
||||||
EVENT_LOADGAME,
|
EVENT_LOADGAME,
|
||||||
EVENT_SAVEGAME,
|
EVENT_SAVEGAME,
|
||||||
MAXEVENTS
|
MAXEVENTS
|
||||||
|
|
|
@ -1,6 +1,156 @@
|
||||||
-- Use this file like
|
-- Use this file like
|
||||||
-- require("lpeg")
|
-- require("lpeg")
|
||||||
-- con_keyword = dofile("con_lang.lua")
|
-- con = require("con_lang")
|
||||||
|
--
|
||||||
|
-- Contains:
|
||||||
|
-- * con.labels
|
||||||
|
-- * con.keyword
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
-- KEEPINSYNC gamedef.h
|
||||||
|
labels =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
STR_MAPNAME = 0,
|
||||||
|
STR_MAPFILENAME = 1,
|
||||||
|
STR_PLAYERNAME = 2,
|
||||||
|
STR_VERSION = 3,
|
||||||
|
STR_GAMETYPE = 4,
|
||||||
|
STR_VOLUMENAME = 5,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
PROJ_WORKSLIKE = 0,
|
||||||
|
PROJ_SPAWNS = 1,
|
||||||
|
PROJ_SXREPEAT = 2,
|
||||||
|
PROJ_SYREPEAT = 3,
|
||||||
|
PROJ_SOUND = 4,
|
||||||
|
PROJ_ISOUND = 5,
|
||||||
|
PROJ_VEL = 6,
|
||||||
|
PROJ_EXTRA = 7,
|
||||||
|
PROJ_DECAL = 8,
|
||||||
|
PROJ_TRAIL = 9,
|
||||||
|
PROJ_TXREPEAT = 10,
|
||||||
|
PROJ_TYREPEAT = 11,
|
||||||
|
PROJ_TOFFSET = 12,
|
||||||
|
PROJ_TNUM = 13,
|
||||||
|
PROJ_DROP = 14,
|
||||||
|
PROJ_CSTAT = 15,
|
||||||
|
PROJ_CLIPDIST = 16,
|
||||||
|
PROJ_SHADE = 17,
|
||||||
|
PROJ_XREPEAT = 18,
|
||||||
|
PROJ_YREPEAT = 19,
|
||||||
|
PROJ_PAL = 20,
|
||||||
|
PROJ_EXTRA_RAND = 21,
|
||||||
|
PROJ_HITRADIUS = 22,
|
||||||
|
PROJ_VEL_MULT = 23,
|
||||||
|
PROJ_OFFSET = 24,
|
||||||
|
PROJ_BOUNCES = 25,
|
||||||
|
PROJ_BSOUND = 26,
|
||||||
|
PROJ_RANGE = 27,
|
||||||
|
PROJ_FLASH_COLOR = 28,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
EVENT_INIT = 0,
|
||||||
|
EVENT_ENTERLEVEL = 1,
|
||||||
|
EVENT_RESETWEAPONS = 2,
|
||||||
|
EVENT_RESETINVENTORY = 3,
|
||||||
|
EVENT_HOLSTER = 4,
|
||||||
|
EVENT_LOOKLEFT = 5,
|
||||||
|
EVENT_LOOKRIGHT = 6,
|
||||||
|
EVENT_SOARUP = 7,
|
||||||
|
EVENT_SOARDOWN = 8,
|
||||||
|
EVENT_CROUCH = 9,
|
||||||
|
EVENT_JUMP = 10,
|
||||||
|
EVENT_RETURNTOCENTER = 11,
|
||||||
|
EVENT_LOOKUP = 12,
|
||||||
|
EVENT_LOOKDOWN = 13,
|
||||||
|
EVENT_AIMUP = 14,
|
||||||
|
EVENT_FIRE = 15,
|
||||||
|
EVENT_CHANGEWEAPON = 16,
|
||||||
|
EVENT_GETSHOTRANGE = 17,
|
||||||
|
EVENT_GETAUTOAIMANGLE = 18,
|
||||||
|
EVENT_GETLOADTILE = 19,
|
||||||
|
EVENT_CHEATGETSTEROIDS = 20,
|
||||||
|
EVENT_CHEATGETHEAT = 21,
|
||||||
|
EVENT_CHEATGETBOOT = 22,
|
||||||
|
EVENT_CHEATGETSHIELD = 23,
|
||||||
|
EVENT_CHEATGETSCUBA = 24,
|
||||||
|
EVENT_CHEATGETHOLODUKE = 25,
|
||||||
|
EVENT_CHEATGETJETPACK = 26,
|
||||||
|
EVENT_CHEATGETFIRSTAID = 27,
|
||||||
|
EVENT_QUICKKICK = 28,
|
||||||
|
EVENT_INVENTORY = 29,
|
||||||
|
EVENT_USENIGHTVISION = 30,
|
||||||
|
EVENT_USESTEROIDS = 31,
|
||||||
|
EVENT_INVENTORYLEFT = 32,
|
||||||
|
EVENT_INVENTORYRIGHT = 33,
|
||||||
|
EVENT_HOLODUKEON = 34,
|
||||||
|
EVENT_HOLODUKEOFF = 35,
|
||||||
|
EVENT_USEMEDKIT = 36,
|
||||||
|
EVENT_USEJETPACK = 37,
|
||||||
|
EVENT_TURNAROUND = 38,
|
||||||
|
EVENT_DISPLAYWEAPON = 39,
|
||||||
|
EVENT_FIREWEAPON = 40,
|
||||||
|
EVENT_SELECTWEAPON = 41,
|
||||||
|
EVENT_MOVEFORWARD = 42,
|
||||||
|
EVENT_MOVEBACKWARD = 43,
|
||||||
|
EVENT_TURNLEFT = 44,
|
||||||
|
EVENT_TURNRIGHT = 45,
|
||||||
|
EVENT_STRAFELEFT = 46,
|
||||||
|
EVENT_STRAFERIGHT = 47,
|
||||||
|
EVENT_WEAPKEY1 = 48,
|
||||||
|
EVENT_WEAPKEY2 = 49,
|
||||||
|
EVENT_WEAPKEY3 = 50,
|
||||||
|
EVENT_WEAPKEY4 = 51,
|
||||||
|
EVENT_WEAPKEY5 = 52,
|
||||||
|
EVENT_WEAPKEY6 = 53,
|
||||||
|
EVENT_WEAPKEY7 = 54,
|
||||||
|
EVENT_WEAPKEY8 = 55,
|
||||||
|
EVENT_WEAPKEY9 = 56,
|
||||||
|
EVENT_WEAPKEY10 = 57,
|
||||||
|
EVENT_DRAWWEAPON = 58,
|
||||||
|
EVENT_DISPLAYCROSSHAIR = 59,
|
||||||
|
EVENT_DISPLAYREST = 60,
|
||||||
|
EVENT_DISPLAYSBAR = 61,
|
||||||
|
EVENT_RESETPLAYER = 62,
|
||||||
|
EVENT_INCURDAMAGE = 63,
|
||||||
|
EVENT_AIMDOWN = 64,
|
||||||
|
EVENT_GAME = 65,
|
||||||
|
EVENT_PREVIOUSWEAPON = 66,
|
||||||
|
EVENT_NEXTWEAPON = 67,
|
||||||
|
EVENT_SWIMUP = 68,
|
||||||
|
EVENT_SWIMDOWN = 69,
|
||||||
|
EVENT_GETMENUTILE = 70,
|
||||||
|
EVENT_SPAWN = 71,
|
||||||
|
EVENT_LOGO = 72,
|
||||||
|
EVENT_EGS = 73,
|
||||||
|
EVENT_DOFIRE = 74,
|
||||||
|
EVENT_PRESSEDFIRE = 75,
|
||||||
|
EVENT_USE = 76,
|
||||||
|
EVENT_PROCESSINPUT = 77,
|
||||||
|
EVENT_FAKEDOMOVETHINGS = 78,
|
||||||
|
EVENT_DISPLAYROOMS = 79,
|
||||||
|
EVENT_KILLIT = 80,
|
||||||
|
EVENT_LOADACTOR = 81,
|
||||||
|
EVENT_DISPLAYBONUSSCREEN = 82,
|
||||||
|
EVENT_DISPLAYMENU = 83,
|
||||||
|
EVENT_DISPLAYMENUREST = 84,
|
||||||
|
EVENT_DISPLAYLOADINGSCREEN = 85,
|
||||||
|
EVENT_ANIMATESPRITES = 86,
|
||||||
|
EVENT_NEWGAME = 87,
|
||||||
|
EVENT_SOUND = 88,
|
||||||
|
EVENT_CHECKTOUCHDAMAGE = 89,
|
||||||
|
EVENT_CHECKFLOORDAMAGE = 90,
|
||||||
|
EVENT_LOADGAME = 91,
|
||||||
|
EVENT_SAVEGAME = 92,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
-- NOTE: These MUST be in reverse lexicographical order!
|
-- NOTE: These MUST be in reverse lexicographical order!
|
||||||
-- Per CON syntax, valid identifiers names are disjunct from keywords,
|
-- Per CON syntax, valid identifiers names are disjunct from keywords,
|
||||||
|
@ -9,7 +159,7 @@
|
||||||
-- (from the final grammar in lunacon.lua) must match the longest
|
-- (from the final grammar in lunacon.lua) must match the longest
|
||||||
-- possible keyword name, else the negation might wrongly not fail.
|
-- possible keyword name, else the negation might wrongly not fail.
|
||||||
|
|
||||||
return
|
keyword =
|
||||||
|
|
||||||
lpeg.P(false) +
|
lpeg.P(false) +
|
||||||
"}" +
|
"}" +
|
||||||
|
@ -375,3 +525,5 @@ lpeg.P(false) +
|
||||||
"activatebysector" +
|
"activatebysector" +
|
||||||
"action" +
|
"action" +
|
||||||
lpeg.P(false)
|
lpeg.P(false)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -270,104 +270,6 @@ typedef struct {
|
||||||
char display_bonus_screen;
|
char display_bonus_screen;
|
||||||
char show_level_text;
|
char show_level_text;
|
||||||
} user_defs;
|
} user_defs;
|
||||||
|
|
||||||
// KEEPINSYNC2
|
|
||||||
enum GameEvent_t {
|
|
||||||
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,
|
|
||||||
MAXEVENTS
|
|
||||||
};
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
ffi.cdef[[
|
ffi.cdef[[
|
||||||
|
@ -375,6 +277,20 @@ actor_t actor[MAXSPRITES];
|
||||||
user_defs ud;
|
user_defs ud;
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
--- default defines
|
||||||
|
local con = require("con_lang")
|
||||||
|
|
||||||
|
for i=1,#con.labels do
|
||||||
|
local strbuf = {"enum {"}
|
||||||
|
|
||||||
|
for label, val in pairs(con.labels[i]) do
|
||||||
|
strbuf[#strbuf+1] = string.format("%s = %d,", label, val)
|
||||||
|
end
|
||||||
|
strbuf[#strbuf+1] = "};"
|
||||||
|
|
||||||
|
ffi.cdef(table.concat(strbuf))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---=== Set up restricted global environment ===---
|
---=== Set up restricted global environment ===---
|
||||||
|
|
||||||
|
@ -728,6 +644,13 @@ local function serializeGamevars()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function loadGamevarsString(string)
|
local function loadGamevarsString(string)
|
||||||
|
--[=[
|
||||||
|
for gvname,_ in pairs(gamevarNames) do
|
||||||
|
G_[gvname] = nil;
|
||||||
|
end
|
||||||
|
gamevarNames = {}; -- clear gamevars
|
||||||
|
--]=]
|
||||||
|
|
||||||
assert(oG.loadstring(string))()
|
assert(oG.loadstring(string))()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
|
|
||||||
local lpeg = require("lpeg")
|
local lpeg = require("lpeg")
|
||||||
|
|
||||||
local EDUKE32_LUNATIC = _EDUKE32_LUNATIC
|
if (not _EDUKE32_LUNATIC) then
|
||||||
|
require("strict")
|
||||||
|
end
|
||||||
|
|
||||||
-- If/else nesting is problematic in CON: because a dangling 'else' is attached
|
|
||||||
-- to the outermost 'if', I think there's no way of linearizing its (recursive)
|
-- I think that the "too many pending calls/choices" is unavoidable in general.
|
||||||
-- pattern, so the "too many pending calls/choices" is unavoidable in general.
|
-- This limit is of course still arbitrary, but writing long if/else cascades
|
||||||
-- This limit is of course still arbitrary, but writing if/else cascades
|
|
||||||
-- in CON isn't pretty either (though sometimes necessary because nested switches
|
-- in CON isn't pretty either (though sometimes necessary because nested switches
|
||||||
-- don't work?)
|
-- don't work?)
|
||||||
-- See also: http://lua-users.org/lists/lua-l/2010-03/msg00086.html
|
-- See also: http://lua-users.org/lists/lua-l/2010-03/msg00086.html
|
||||||
|
@ -19,7 +20,7 @@ local Pat, Set, Range, Var = lpeg.P, lpeg.S, lpeg.R, lpeg.V
|
||||||
|
|
||||||
|
|
||||||
---- All keywords pattern -- needed for CON syntax
|
---- All keywords pattern -- needed for CON syntax
|
||||||
local con_keyword = require("con_lang")
|
local con = require("con_lang")
|
||||||
|
|
||||||
|
|
||||||
local function match_until(matchsp, untilsp) -- (!untilsp matchsp)* in PEG
|
local function match_until(matchsp, untilsp) -- (!untilsp matchsp)* in PEG
|
||||||
|
@ -35,6 +36,7 @@ end
|
||||||
---=== semantic action functions ===---
|
---=== semantic action functions ===---
|
||||||
|
|
||||||
local inf = 1/0
|
local inf = 1/0
|
||||||
|
local NaN = 0/0
|
||||||
|
|
||||||
-- Last keyword position, for error diagnosis.
|
-- Last keyword position, for error diagnosis.
|
||||||
local g_lastkwpos = nil
|
local g_lastkwpos = nil
|
||||||
|
@ -79,7 +81,7 @@ local function parse_number(numstr)
|
||||||
-- TODO: print line number
|
-- TODO: print line number
|
||||||
if (num < -0x80000000 or num > 0xffffffff) then
|
if (num < -0x80000000 or num > 0xffffffff) then
|
||||||
errprintf("number %s out of the range of a 32-bit integer", numstr)
|
errprintf("number %s out of the range of a 32-bit integer", numstr)
|
||||||
num = 0/0
|
num = NaN
|
||||||
elseif (num >= 0x80000000 and numstr:sub(1,2):lower()~="0x") then
|
elseif (num >= 0x80000000 and numstr:sub(1,2):lower()~="0x") then
|
||||||
warnprintf("number %s converted to a negative one", numstr)
|
warnprintf("number %s converted to a negative one", numstr)
|
||||||
num = num-0x100000000
|
num = num-0x100000000
|
||||||
|
@ -99,21 +101,24 @@ local LABEL_MOVE = 32
|
||||||
local g_labeldef = {}
|
local g_labeldef = {}
|
||||||
local g_labeltype = {}
|
local g_labeltype = {}
|
||||||
|
|
||||||
|
local function reset_labels()
|
||||||
|
g_labeldef = { NO=0 }
|
||||||
|
g_labeltype = { NO=LABEL_DEFINE+LABEL_ACTION+LABEL_AI+LABEL_MOVE }
|
||||||
|
|
||||||
|
for i=1,#con.labels do
|
||||||
|
for label, val in pairs(con.labels[i]) do
|
||||||
|
g_labeldef[label] = val
|
||||||
|
g_labeltype[label] = LABEL_DEFINE
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function lookup_defined_label(identifier)
|
local function lookup_defined_label(identifier)
|
||||||
local num = g_labeldef[identifier]
|
local num = g_labeldef[identifier]
|
||||||
|
|
||||||
if (num == nil) then
|
if (num == nil) then
|
||||||
if (EDUKE32_LUNATIC == nil) then
|
|
||||||
-- HACK: try a couple of hardcoded def prefixes
|
|
||||||
if (identifier:sub(1, 6)=="EVENT_"
|
|
||||||
or identifier:sub(1,4)=="STR_"
|
|
||||||
or identifier:sub(1,5)=="PROJ_")
|
|
||||||
then return 0 -- TEMP
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
errprintf("label \"%s\" is not defined", identifier)
|
errprintf("label \"%s\" is not defined", identifier)
|
||||||
return -1/0
|
return -inf
|
||||||
end
|
end
|
||||||
|
|
||||||
return num
|
return num
|
||||||
|
@ -135,7 +140,8 @@ local function do_define_label(identifier, idornum)
|
||||||
|
|
||||||
local oldnum = g_labeldef[identifier]
|
local oldnum = g_labeldef[identifier]
|
||||||
if (oldnum) then
|
if (oldnum) then
|
||||||
if (oldnum ~= num) then
|
-- con.labels[...]: don't warn for wrong PROJ_ redefinitions
|
||||||
|
if (oldnum ~= num and con.labels[2][identifier]==nil) then
|
||||||
warnprintf("label \"%s\" not redefined with new value %d (old: %d)",
|
warnprintf("label \"%s\" not redefined with new value %d (old: %d)",
|
||||||
identifier, num, oldnum)
|
identifier, num, oldnum)
|
||||||
end
|
end
|
||||||
|
@ -321,7 +327,7 @@ local Co = {
|
||||||
definesound = sp1 * t_define * sp1 * maybe_quoted_filename * n_defines(5), -- XXX: TS
|
definesound = sp1 * t_define * sp1 * maybe_quoted_filename * n_defines(5), -- XXX: TS
|
||||||
|
|
||||||
-- NOTE: gamevar.ogg is OK, too
|
-- NOTE: gamevar.ogg is OK, too
|
||||||
music = sp1 * t_define * match_until(sp1 * t_filename, sp1 * con_keyword * sp1),
|
music = sp1 * t_define * match_until(sp1 * t_filename, sp1 * con.keyword * sp1),
|
||||||
|
|
||||||
--- 3. Game Settings
|
--- 3. Game Settings
|
||||||
-- gamestartup has 25/29 fixed defines, depending on 1.3D/1.5 version:
|
-- gamestartup has 25/29 fixed defines, depending on 1.3D/1.5 version:
|
||||||
|
@ -365,7 +371,7 @@ local arraypat = sp0 * "[" * sp0 * t_rvar * sp0 * "]"
|
||||||
-- will be wrongly accepted at the parsing stage because we don't discriminate between
|
-- will be wrongly accepted at the parsing stage because we don't discriminate between
|
||||||
-- actor and player (but it will be rejected later).
|
-- actor and player (but it will be rejected later).
|
||||||
local parm2memberpat = (Pat("htg_t") + "loogiex" + "loogiey" + "ammo_amount" +
|
local parm2memberpat = (Pat("htg_t") + "loogiex" + "loogiey" + "ammo_amount" +
|
||||||
"weaprecs" + "gotweapon" + "pals" + "max_ammo_amount") * sp0 * t_rvar
|
"weaprecs" + "gotweapon" + "pals" + "max_ammo_amount") * sp1 * t_rvar
|
||||||
-- The member name must match keywords, too (_all), because e.g. cstat is a member
|
-- The member name must match keywords, too (_all), because e.g. cstat is a member
|
||||||
-- of sprite[].
|
-- of sprite[].
|
||||||
local memberpat = sp0 * "." * sp0 * (parm2memberpat + t_identifier_all)
|
local memberpat = sp0 * "." * sp0 * (parm2memberpat + t_identifier_all)
|
||||||
|
@ -907,9 +913,8 @@ local function all_alt_pattern(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- actor ORGANTIC is greeting!
|
-- actor ORGANTIC is greeting!
|
||||||
local function warn_on_lonely_else(subj, pos)
|
local function warn_on_lonely_else()
|
||||||
warnprintf("found `else' with no `if'")
|
warnprintf("found `else' with no `if'")
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- NOTE: The indented text is not true, e.g. addlog vs. addlogvar:
|
-- NOTE: The indented text is not true, e.g. addlog vs. addlogvar:
|
||||||
|
@ -927,7 +932,7 @@ local con_outer_command = all_alt_pattern(Co)
|
||||||
local con_inner_command = all_alt_pattern(Ci) + "addlog" + "operate"
|
local con_inner_command = all_alt_pattern(Ci) + "addlog" + "operate"
|
||||||
local con_if_begs = all_alt_pattern(Cif) + "ifcansee"
|
local con_if_begs = all_alt_pattern(Cif) + "ifcansee"
|
||||||
|
|
||||||
local lone_else = lpeg.Cmt("else" * sp1, warn_on_lonely_else)
|
local lone_else = ("else" * sp1)/warn_on_lonely_else
|
||||||
|
|
||||||
local stmt_list = Var("stmt_list")
|
local stmt_list = Var("stmt_list")
|
||||||
-- possibly empty statement list:
|
-- possibly empty statement list:
|
||||||
|
@ -994,7 +999,7 @@ local Grammar = Pat{
|
||||||
whitespace = Set(" \t\r\26") + newline + Set("(),;") + comment + linecomment,
|
whitespace = Set(" \t\r\26") + newline + Set("(),;") + comment + linecomment,
|
||||||
|
|
||||||
t_identifier_all = t_broken_identifier + t_good_identifier,
|
t_identifier_all = t_broken_identifier + t_good_identifier,
|
||||||
-- NOTE: -con_keyword alone would be wrong, e.g. "state breakobject":
|
-- NOTE: -con.keyword alone would be wrong, e.g. "state breakobject":
|
||||||
-- NOTE 2: The + "[" is so that stuff like
|
-- NOTE 2: The + "[" is so that stuff like
|
||||||
-- getactor[THISACTOR].x x
|
-- getactor[THISACTOR].x x
|
||||||
-- getactor[THISACTOR].y y
|
-- getactor[THISACTOR].y y
|
||||||
|
@ -1002,7 +1007,7 @@ local Grammar = Pat{
|
||||||
-- getactor[THISACTOR].x x
|
-- getactor[THISACTOR].x x
|
||||||
-- getactor [THISACTOR].y y
|
-- getactor [THISACTOR].y y
|
||||||
-- This is in need of cleanup!
|
-- This is in need of cleanup!
|
||||||
t_identifier = -NotKeyw(con_keyword * (sp1 + "[")) * lpeg.C(t_identifier_all),
|
t_identifier = -NotKeyw(con.keyword * (sp1 + "[")) * lpeg.C(t_identifier_all),
|
||||||
t_define = (t_maybe_minus * t_identifier/lookup_defined_label) + t_number, -- TODO: minus
|
t_define = (t_maybe_minus * t_identifier/lookup_defined_label) + t_number, -- TODO: minus
|
||||||
|
|
||||||
t_arrayexp = t_identifier * arraypat * memberpat^-1,
|
t_arrayexp = t_identifier * arraypat * memberpat^-1,
|
||||||
|
@ -1125,12 +1130,11 @@ if (not _EDUKE32_LUNATIC) then
|
||||||
|
|
||||||
g_recurslevel = -1
|
g_recurslevel = -1
|
||||||
g_badids = {}
|
g_badids = {}
|
||||||
g_labeldef = {}
|
reset_labels()
|
||||||
g_labeltype = {}
|
|
||||||
|
|
||||||
g_numerrors = 0
|
g_numerrors = 0
|
||||||
|
|
||||||
g_directory = string.match(filename, "(.*/)") or ""
|
g_directory = filename:match("(.*/)") or ""
|
||||||
filename = filename:sub(#g_directory+1, -1)
|
filename = filename:sub(#g_directory+1, -1)
|
||||||
|
|
||||||
local ok, msg = pcall(do_include_file, g_directory, filename)
|
local ok, msg = pcall(do_include_file, g_directory, filename)
|
||||||
|
|
43
polymer/eduke32/source/lunatic/strict.lua
Normal file
43
polymer/eduke32/source/lunatic/strict.lua
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
--
|
||||||
|
-- strict.lua
|
||||||
|
-- checks uses of undeclared global variables
|
||||||
|
-- All global variables must be 'declared' through a regular assignment
|
||||||
|
-- (even assigning nil will do) in a main chunk before being used
|
||||||
|
-- anywhere or assigned to inside a function.
|
||||||
|
--
|
||||||
|
|
||||||
|
local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget
|
||||||
|
|
||||||
|
local mt = getmetatable(_G)
|
||||||
|
if mt == nil then
|
||||||
|
mt = {}
|
||||||
|
setmetatable(_G, mt)
|
||||||
|
end
|
||||||
|
|
||||||
|
mt.__declared = {}
|
||||||
|
|
||||||
|
local function what ()
|
||||||
|
local d = getinfo(3, "S")
|
||||||
|
return d and d.what or "C"
|
||||||
|
end
|
||||||
|
|
||||||
|
mt.__newindex = function (t, n, v)
|
||||||
|
if not mt.__declared[n] then
|
||||||
|
local w = what()
|
||||||
|
if w ~= "main" and w ~= "C" then
|
||||||
|
error("assign to undeclared variable '"..n.."'", 2)
|
||||||
|
end
|
||||||
|
mt.__declared[n] = true
|
||||||
|
end
|
||||||
|
rawset(t, n, v)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- PK: change from original:
|
||||||
|
--[[
|
||||||
|
mt.__index = function (t, n)
|
||||||
|
if not mt.__declared[n] and what() ~= "C" then
|
||||||
|
error("variable '"..n.."' is not declared", 2)
|
||||||
|
end
|
||||||
|
return rawget(t, n)
|
||||||
|
end
|
||||||
|
--]]
|
|
@ -34,6 +34,7 @@ print("========== attempting to load string: ==========")
|
||||||
print(gvstr)
|
print(gvstr)
|
||||||
print("---------- (end string to load) ----------")
|
print("---------- (end string to load) ----------")
|
||||||
|
|
||||||
|
-- XXX: need to think about fully restoring state
|
||||||
DBG_.loadGamevarsString(gvstr)
|
DBG_.loadGamevarsString(gvstr)
|
||||||
print("ourvar[4]="..ourvar[4])
|
print("ourvar[4]="..ourvar[4])
|
||||||
|
|
||||||
|
@ -125,6 +126,6 @@ gameactor(1680, -- LIZTROOP
|
||||||
)
|
)
|
||||||
|
|
||||||
checkfail('gameactor(1680, 0)') -- lua function expected, number passed
|
checkfail('gameactor(1680, 0)') -- lua function expected, number passed
|
||||||
|
printf("EVENT_INIT = %d", gv.EVENT_INIT) -- tests default defines
|
||||||
|
|
||||||
print('---=== END TEST SCRIPT ===---')
|
print('---=== END TEST SCRIPT ===---')
|
||||||
|
|
Loading…
Reference in a new issue