CON: Add predefined labels MAXSPRITES, MAXSTATUS and MAX_WEAPONS.

git-svn-id: https://svn.eduke32.com/eduke32@3944 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-07-13 21:04:41 +00:00
parent e4849af91f
commit b70779ba6f
4 changed files with 40 additions and 10 deletions

View file

@ -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);

View file

@ -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));

View file

@ -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<MAXTILES)) then
if (ffi and g_dyntilei and (num>=0 and num<C.MAXTILES)) then
dynmap.maybe_init(g_dyntilei, ffiC.g_dynTileList)
dynmap.maybe_process(g_dyntilei, ffiC.g_dynTileList, identifier, num)
end
@ -2376,7 +2389,7 @@ local Cinner = {
/ function(...) return handle.arraycmd("%s:resize(%s)", 1, ...) end,
getarraysize = cmd(GARI,W)
/ function(ar, dst)
return format("%s=%s", dst, issysgar(ar) and tostring(MAXTILES) or ar.."._size")
return format("%s=%s", dst, issysgar(ar) and tostring(C.MAXTILES) or ar.."._size")
end,
readarrayfromfile = cmd(GARI,D)
/ function(...) -- false: error on no file, nil: don't.

View file

@ -16,11 +16,24 @@ state teststate_break
echo 114
ends
onevent EVENT_INIT
definequote 499 ===
definequote 500 MAXSPRITES: %d
definequote 501 MAXSTATUS: %d
definequote 502 MAX_WEAPONS: %d
// XXX: EVENT_INIT not reached with LunaCON
onevent EVENT_ENTERLEVEL
state teststate_break
redefinequote 114 STILL LIVE OUTER
echo 114
qsprintf 499 /*<-*/ 500 MAXSPRITES
echo 499
qsprintf 499 /*<-*/ 501 MAXSTATUS
echo 499
qsprintf 499 /*<-*/ 502 MAX_WEAPONS
echo 499
endevent
// Test number parsing