From b70779ba6f57e2c47ddbbb14dced96bcba5c31b9 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 13 Jul 2013 21:04:41 +0000 Subject: [PATCH] CON: Add predefined labels MAXSPRITES, MAXSTATUS and MAX_WEAPONS. git-svn-id: https://svn.eduke32.com/eduke32@3944 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/gamedef.c | 3 ++ polymer/eduke32/source/gameexec.c | 3 +- polymer/eduke32/source/lunatic/lunacon.lua | 29 ++++++++++++++----- .../source/lunatic/test/nlcf_break.con | 15 +++++++++- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index ffd72a11e..58db13253 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -6165,6 +6165,9 @@ static void C_AddDefaultDefinitions(void) C_AddDefinition("STR_VOLUMENAME",STR_VOLUMENAME,LABEL_DEFINE); C_AddDefinition("NO",0,LABEL_DEFINE|LABEL_ACTION|LABEL_AI|LABEL_MOVE); + C_AddDefinition("MAXSTATUS", MAXSTATUS, LABEL_DEFINE); + C_AddDefinition("MAXSPRITES", MAXSPRITES, LABEL_DEFINE); + C_AddDefinition("MAX_WEAPONS", MAX_WEAPONS, LABEL_DEFINE); C_AddDefinition("PROJ_BOUNCES",PROJ_BOUNCES,LABEL_DEFINE); C_AddDefinition("PROJ_BSOUND",PROJ_BSOUND,LABEL_DEFINE); diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index acac127bb..8c9218d9f 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -5480,8 +5480,9 @@ void G_SaveMapState(void) if (save != NULL) { +#if !defined LUNATIC int32_t i; - +#endif Bmemcpy(&save->numwalls,&numwalls,sizeof(numwalls)); Bmemcpy(&save->wall[0],&wall[0],sizeof(walltype)*MAXWALLS); Bmemcpy(&save->numsectors,&numsectors,sizeof(numsectors)); diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index adebf6c62..fb3e2fc28 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -83,12 +83,22 @@ local function printf(fmt, ...) print(format(fmt, ...)) end +--- some constants + +local C = { + -- These two are not used except for predefined labels. + -- NOTE: in-game, MAXSPRITES may be 4096 for a V7 build! + MAXSTATUS = ffiC and ffiC.MAXSTATUS or 1024, + MAXSPRITES = ffiC and ffiC.MAXSPRITES or 16384, + + MAXTILES = ffiC and ffiC.MAXTILES or 30720, + MAX_WEAPONS = ffiC and ffiC.MAX_WEAPONS or 12, +} ---=== semantic action functions ===--- local inf = 1/0 local NaN = 0/0 -local MAXTILES = (ffiC and ffiC.MAXTILES or 30720) -- Last keyword position, for error diagnosis. local g_lastkwpos = nil @@ -220,7 +230,6 @@ local function CSV(var) return "_gv._csv"..var end -- KEEPINSYNC gamevars.c: Gv_AddSystemVars() local function new_initial_gvartab() local wmembers = conl.wdata_members - local MAX_WEAPONS = ffiC and ffiC.MAX_WEAPONS or 12 local function GamevarCreationFunc(addflags) return function(varname) @@ -320,7 +329,7 @@ local function new_initial_gvartab() -- Reserved bits gamevar.LOGO_FLAGS.rbits = bit.bnot(4095) - for w=0,MAX_WEAPONS-1 do + for w=0,C.MAX_WEAPONS-1 do for i=1,#wmembers do local member = wmembers[i]:gsub(".*_t ","") -- strip e.g. "const int32_t " :gsub("^_","") -- strip potentially leading underscore @@ -343,8 +352,8 @@ local function reset_codegen() g_gamevar = new_initial_gvartab() g_gamearray = { -- SYSTEM_GAMEARRAY - tilesizx = { name="g_tile.sizx", size=MAXTILES, sysp=true }, - tilesizy = { name="g_tile.sizy", size=MAXTILES, sysp=true }, + tilesizx = { name="g_tile.sizx", size=C.MAXTILES, sysp=true }, + tilesizy = { name="g_tile.sizy", size=C.MAXTILES, sysp=true }, } g_dyntilei = nil @@ -588,7 +597,7 @@ end local check = {} function check.tile_idx(tilenum) - if (not (tilenum >= 0 and tilenum < MAXTILES)) then + if (not (tilenum >= 0 and tilenum < C.MAXTILES)) then errprintf("invalid tile number %d", tilenum) return false end @@ -632,6 +641,10 @@ local function reset_labels() MULTIMODE = 1, numplayers = 1, myconnectindex = 0, + -- Predefined constants + MAXSTATUS = C.MAXSTATUS, + MAXSPRITES = C.MAXSPRITES, + MAX_WEAPONS = C.MAX_WEAPONS, } for varname,_ in pairs(g_labeldef) do @@ -737,7 +750,7 @@ function Define.label(identifier, num) warnprintf("symbol `%s' already used for game variable", identifier) end - if (ffi and g_dyntilei and (num>=0 and num=0 and num