mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Lunatic translator: dynamic tile remapping.
Also, fix message when tiles get remapped in debugging builds. git-svn-id: https://svn.eduke32.com/eduke32@3568 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
92e85fa0d3
commit
56ea732ccd
7 changed files with 87 additions and 19 deletions
|
@ -4087,15 +4087,17 @@ static int32_t C_ParseCommand(int32_t loop)
|
|||
|
||||
case CON_DYNAMICREMAP:
|
||||
g_scriptPtr--;
|
||||
if (g_dynamicTileMapping++)
|
||||
if (g_dynamicTileMapping)
|
||||
{
|
||||
initprintf("%s:%d: warning: duplicate dynamicremap statement\n",g_szScriptFileName,g_lineNumber);
|
||||
g_numCompilerWarnings++;
|
||||
}
|
||||
#ifdef DYNTILEREMAP_ENABLE
|
||||
else initprintf("Using dynamic tile remapping\n");
|
||||
#else
|
||||
else
|
||||
#ifdef DYNTILEREMAP_ENABLE
|
||||
initprintf("Using dynamic tile remapping\n");
|
||||
|
||||
g_dynamicTileMapping = 1;
|
||||
#else
|
||||
{
|
||||
initprintf("%s:%d: warning: dynamic tile remapping is disabled in this build\n",g_szScriptFileName,g_lineNumber);
|
||||
g_numCompilerWarnings++;
|
||||
|
|
|
@ -535,6 +535,14 @@ tiledata_t g_tile[MAXTILES];
|
|||
projectile_t ProjectileData[MAXTILES];
|
||||
projectile_t SpriteProjectile[MAXSPRITES];
|
||||
|
||||
// Used from lunacon.lua for dynamic tile remapping:
|
||||
struct
|
||||
{
|
||||
const char *str;
|
||||
int32_t *dynvalptr;
|
||||
const int16_t staticval;
|
||||
} g_dynTileList[];
|
||||
|
||||
char *ScriptQuotes[];
|
||||
|
||||
const int32_t playerswhenstarted;
|
||||
|
|
|
@ -108,6 +108,9 @@ g_playerWeapon;
|
|||
g_tile;
|
||||
ProjectileData;
|
||||
SpriteProjectile;
|
||||
|
||||
g_dynTileList;
|
||||
|
||||
ScriptQuotes;
|
||||
|
||||
screenpeek;
|
||||
|
|
|
@ -138,6 +138,11 @@ local g_gamevar = {}
|
|||
-- [identifier] = { name=<mangled name / code>, size=<initial size> }
|
||||
local g_gamearray = {}
|
||||
|
||||
-- * nil if dynamic tile remapping disabled
|
||||
-- * true if enabled but no remappings made
|
||||
-- * else, a table { [name]=<g_dynTileList index> }
|
||||
local g_dyntilei = nil
|
||||
|
||||
local g_have_file = {} -- [filename]=true
|
||||
local g_curcode = nil -- a table of string pieces or other "gencode" tables
|
||||
|
||||
|
@ -299,6 +304,8 @@ local function reset_codegen()
|
|||
tilesizy = { name="g_tile.sizy", size=MAXTILES, sysp=true },
|
||||
}
|
||||
|
||||
g_dyntilei = nil
|
||||
|
||||
g_have_file = {}
|
||||
g_curcode = new_initial_codetab()
|
||||
-- [{actor, event, actor}num]=gencode_table
|
||||
|
@ -578,6 +585,32 @@ local function do_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 (g_dyntilei==true) then
|
||||
-- Init name -> g_dynTileList index mapping
|
||||
g_dyntilei = {}
|
||||
|
||||
for i=0,math.huge do
|
||||
local str = ffiC.g_dynTileList[i].str
|
||||
if (str==nil) then
|
||||
break
|
||||
end
|
||||
|
||||
g_dyntilei[ffi.string(str)] = i
|
||||
end
|
||||
end
|
||||
|
||||
-- Potentially process one dynamic tile remapping
|
||||
if (g_dyntilei[identifier]) then
|
||||
local di = ffiC.g_dynTileList[g_dyntilei[identifier]]
|
||||
|
||||
if (ffiC._DEBUG_LUNATIC~=0 and di.staticval~=num) then
|
||||
printf("REMAP %s (%d) --> %d", ffi.string(di.str), di.staticval, num)
|
||||
end
|
||||
di.dynvalptr[0] = num
|
||||
end
|
||||
end
|
||||
|
||||
-- New definition of a label
|
||||
g_labeldef[identifier] = num
|
||||
g_labeltype[identifier] = LABEL.NUMBER
|
||||
|
@ -1244,7 +1277,7 @@ local Couter = {
|
|||
|
||||
--- 2. Defines and Meta-Settings
|
||||
dynamicremap = cmd()
|
||||
/ Cmd.NYI("dynamic tile remapping"),
|
||||
/ function() print("Using dynamic tile remapping"); g_dyntilei=true; end,
|
||||
setcfgname = sp1 * tok.filename
|
||||
/ Cmd.nyi("`setcfgname'"),
|
||||
setdefname = sp1 * tok.filename
|
||||
|
|
|
@ -1,8 +1,22 @@
|
|||
// Use as root file, not as additional CON module.
|
||||
|
||||
// Test dynamic tile remapping.
|
||||
dynamicremap
|
||||
// Make MASKWALL2 (fence in E1L1 rooftop) execute the C side code of DUKECAR.
|
||||
// This must be before the original DUKECAR definition, because label
|
||||
// redefinitions are ignored in CON.
|
||||
// XXX: Does MASKWALL2's code get executed, too?
|
||||
define DUKECAR 913
|
||||
|
||||
include GAME.CON
|
||||
// NOTE:
|
||||
// DEFS.CON 520:6: warning: label "DUKECAR" not redefined with new value 2491 (old: 913)
|
||||
|
||||
gamevar LOGO_FLAGS 2303 0 // 255+2048, test "no ep4 cutscene" bit
|
||||
|
||||
useractor 4 58 1 NO NO 0
|
||||
// usertype 4 is "rotation-fixed actor"
|
||||
// tile 58 is the space suit
|
||||
|
||||
state killme
|
||||
enda
|
||||
|
||||
gamevar LOGO_FLAGS 2303 0 // 255+2048, test "no ep4 cutscene" bit
|
||||
|
|
|
@ -43,7 +43,8 @@ struct dynitem
|
|||
const int16_t staticval;
|
||||
};
|
||||
|
||||
static struct dynitem list[]=
|
||||
// NOTE: external linkage for Lunatic
|
||||
struct dynitem g_dynTileList[] =
|
||||
{
|
||||
{ "SECTOREFFECTOR", DVPTR(SECTOREFFECTOR), SECTOREFFECTOR__STATIC },
|
||||
{ "ACTIVATOR", DVPTR(ACTIVATOR), ACTIVATOR__STATIC },
|
||||
|
@ -782,13 +783,11 @@ static struct dynitem list[]=
|
|||
{ "RESERVEDSLOT10", DVPTR(RESERVEDSLOT10), RESERVEDSLOT10__STATIC },
|
||||
{ "RESERVEDSLOT11", DVPTR(RESERVEDSLOT11), RESERVEDSLOT11__STATIC },
|
||||
{ "RESERVEDSLOT12", DVPTR(RESERVEDSLOT12), RESERVEDSLOT12__STATIC },
|
||||
{ 0, NULL, 0 },
|
||||
{ NULL, NULL, 0 },
|
||||
};
|
||||
|
||||
#ifdef DYNTILEREMAP_ENABLE
|
||||
|
||||
static hashtable_t h_names = {512, NULL};
|
||||
|
||||
int32_t SECTOREFFECTOR = SECTOREFFECTOR__STATIC;
|
||||
int32_t ACTIVATOR = ACTIVATOR__STATIC;
|
||||
int32_t TOUCHPLATE = TOUCHPLATE__STATIC;
|
||||
|
@ -1528,6 +1527,9 @@ int32_t RESERVEDSLOT10 = RESERVEDSLOT10__STATIC;
|
|||
int32_t RESERVEDSLOT11 = RESERVEDSLOT11__STATIC;
|
||||
int32_t RESERVEDSLOT12 = RESERVEDSLOT12__STATIC;
|
||||
|
||||
#if !defined LUNATIC
|
||||
static hashtable_t h_names = {512, NULL};
|
||||
|
||||
void G_ProcessDynamicTileMapping(const char *szLabel, int32_t lValue)
|
||||
{
|
||||
int32_t i;
|
||||
|
@ -1538,11 +1540,12 @@ void G_ProcessDynamicTileMapping(const char *szLabel, int32_t lValue)
|
|||
i = hash_find(&h_names,szLabel);
|
||||
if (i>=0)
|
||||
{
|
||||
struct dynitem *di = &g_dynTileList[i];
|
||||
#ifdef DEBUGGINGAIDS
|
||||
if (list[i].staticval != *list[i].dynvalptr)
|
||||
OSD_Printf("REMAP %s (%d) --> %d\n", list[i].str, list[i].staticval, *list[i].dynvalptr);
|
||||
if (di->staticval != lValue)
|
||||
OSD_Printf("REMAP %s (%d) --> %d\n", di->str, di->staticval, lValue);
|
||||
#endif
|
||||
*(list[i].dynvalptr) = lValue;
|
||||
*di->dynvalptr = lValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1552,8 +1555,8 @@ void inithashnames(void)
|
|||
|
||||
hash_init(&h_names);
|
||||
|
||||
for (i=0; list[i].staticval; i++)
|
||||
hash_add(&h_names, list[i].str, i, 0);
|
||||
for (i=0; g_dynTileList[i].staticval; i++)
|
||||
hash_add(&h_names, g_dynTileList[i].str, i, 0);
|
||||
}
|
||||
|
||||
void freehashnames(void)
|
||||
|
@ -1561,18 +1564,21 @@ void freehashnames(void)
|
|||
hash_free(&h_names);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// This is run after all CON define's have been processed to set up the
|
||||
// dynamic->static tile mapping.
|
||||
void G_InitDynamicTiles(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
Bmemset(DynamicTileMap, 0, sizeof(DynamicTileMap));
|
||||
|
||||
for (i=0; list[i].staticval; i++)
|
||||
for (i=0; g_dynTileList[i].staticval; i++)
|
||||
#ifdef DYNTILEREMAP_ENABLE
|
||||
DynamicTileMap[*(list[i].dynvalptr)] = list[i].staticval;
|
||||
DynamicTileMap[*(g_dynTileList[i].dynvalptr)] = g_dynTileList[i].staticval;
|
||||
#else
|
||||
DynamicTileMap[list[i].staticval] = list[i].staticval;
|
||||
DynamicTileMap[g_dynTileList[i].staticval] = g_dynTileList[i].staticval;
|
||||
#endif
|
||||
|
||||
BlimpSpawnSprites[0] = RPGSPRITE;
|
||||
|
|
|
@ -769,8 +769,10 @@ void G_InitDynamicTiles(void);
|
|||
|
||||
void G_ProcessDynamicTileMapping(const char *szLabel, int32_t lValue);
|
||||
|
||||
#if !defined LUNATIC
|
||||
void inithashnames(void);
|
||||
void freehashnames(void);
|
||||
#endif
|
||||
|
||||
extern int32_t SECTOREFFECTOR;
|
||||
extern int32_t ACTIVATOR;
|
||||
|
|
Loading…
Reference in a new issue