mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
C-CON: Add two new structs, tiledata and paldata, accessible only through quick-access.
git-svn-id: https://svn.eduke32.com/eduke32@5115 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
f68829c08a
commit
0bc349fde2
4 changed files with 183 additions and 1 deletions
|
@ -1170,6 +1170,33 @@ const memberlabel_t InputLabels[]=
|
|||
{ "", -1, 0, 0 } // END OF LIST
|
||||
};
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
char *bitptr; // pointer to bitmap of which bytecode positions contain pointers
|
||||
|
@ -1192,6 +1219,9 @@ static hashtable_t inputH = { INPUT_END>>1, NULL };
|
|||
static hashtable_t actorH = { ACTOR_END>>1, NULL };
|
||||
static hashtable_t tspriteH = { ACTOR_END>>1, NULL };
|
||||
|
||||
static hashtable_t tiledataH = { TILEDATA_END>>1, NULL };
|
||||
static hashtable_t paldataH = { PALDATA_END>>1, NULL };
|
||||
|
||||
void C_InitHashes()
|
||||
{
|
||||
int32_t i;
|
||||
|
@ -1211,6 +1241,8 @@ void C_InitHashes()
|
|||
hash_init(&inputH);
|
||||
hash_init(&actorH);
|
||||
hash_init(&tspriteH);
|
||||
hash_init(&tiledataH);
|
||||
hash_init(&paldataH);
|
||||
|
||||
g_scriptLastKeyword = NUMKEYWORDS-1;
|
||||
// determine last CON keyword for backward compatibility with older mods
|
||||
|
@ -1238,6 +1270,8 @@ void C_InitHashes()
|
|||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
// "magic" number for { and }, overrides line number in compiled code for later detection
|
||||
|
@ -1752,6 +1786,12 @@ static void C_GetNextVarType(int32_t type)
|
|||
case STRUCT_INPUT:
|
||||
lLabelID=C_GetLabelNameOffset(&inputH,Bstrtolower(label+(g_numLabels<<6)));
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
//printf("LabelID is %d\n",lLabelID);
|
||||
|
@ -1813,6 +1853,12 @@ static void C_GetNextVarType(int32_t type)
|
|||
case STRUCT_INPUT:
|
||||
*g_scriptPtr++=InputLabels[lLabelID].lId;
|
||||
break;
|
||||
case STRUCT_TILEDATA:
|
||||
*g_scriptPtr++=TileDataLabels[lLabelID].lId;
|
||||
break;
|
||||
case STRUCT_PALDATA:
|
||||
*g_scriptPtr++=PalDataLabels[lLabelID].lId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -69,6 +69,8 @@ enum QuickStructureAccess_t {
|
|||
STRUCT_THISPROJECTILE,
|
||||
STRUCT_USERDEF,
|
||||
STRUCT_INPUT,
|
||||
STRUCT_TILEDATA,
|
||||
STRUCT_PALDATA,
|
||||
NUMQUICKSTRUCTS,
|
||||
};
|
||||
|
||||
|
@ -105,9 +107,11 @@ extern const memberlabel_t WallLabels[];
|
|||
extern const memberlabel_t ActorLabels[];
|
||||
extern const memberlabel_t PlayerLabels[];
|
||||
extern const memberlabel_t ProjectileLabels[];
|
||||
extern const memberlabel_t userdeflabels[];
|
||||
extern const memberlabel_t UserdefsLabels[];
|
||||
extern const memberlabel_t InputLabels[];
|
||||
extern const memberlabel_t TsprLabels[];
|
||||
extern const memberlabel_t TileDataLabels[];
|
||||
extern const memberlabel_t PalDataLabels[];
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
|
@ -607,6 +611,26 @@ enum InputLabel_t
|
|||
INPUT_END
|
||||
};
|
||||
|
||||
enum TileDataLabel_t
|
||||
{
|
||||
TILEDATA_XSIZE,
|
||||
TILEDATA_YSIZE,
|
||||
TILEDATA_ANIMFRAMES,
|
||||
TILEDATA_XOFFSET,
|
||||
TILEDATA_YOFFSET,
|
||||
TILEDATA_ANIMSPEED,
|
||||
TILEDATA_ANIMTYPE,
|
||||
TILEDATA_GAMEFLAGS,
|
||||
TILEDATA_END
|
||||
};
|
||||
|
||||
enum PalDataLabel_t
|
||||
{
|
||||
PALDATA_NOFLOORPAL,
|
||||
PALDATA_DUMMY, // so the hash table is size 1. remove when another member is added.
|
||||
PALDATA_END
|
||||
};
|
||||
|
||||
#endif
|
||||
// KEEPINSYNC lunatic/con_lang.lua
|
||||
enum ProjectileLabel_t
|
||||
|
|
|
@ -47,6 +47,8 @@ int32_t __fastcall VM_GetTsprite(register int32_t const iActor, register int32_t
|
|||
void __fastcall VM_SetTsprite(register int32_t const iActor, register int32_t const lLabelID, register int32_t const iSet);
|
||||
int32_t __fastcall VM_GetProjectile(register int32_t const iTile, register int32_t lLabelID);
|
||||
void __fastcall VM_SetProjectile(register int32_t const iTile, register int32_t const lLabelID, register int32_t const iSet);
|
||||
int32_t __fastcall VM_GetTileData(register int32_t const iTile, register int32_t lLabelID);
|
||||
int32_t __fastcall VM_GetPalData(register int32_t const iPal, register int32_t lLabelID);
|
||||
#else
|
||||
int32_t __fastcall VM_GetUserdef(register int32_t lLabelID)
|
||||
{
|
||||
|
@ -1312,4 +1314,50 @@ void __fastcall VM_SetProjectile(register int32_t const iTile, register int32_t
|
|||
case PROJ_USERDATA: proj->userdata = iSet; break;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t __fastcall VM_GetTileData(register int32_t const iTile, register int32_t lLabelID)
|
||||
{
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)iTile >= MAXTILES))
|
||||
{
|
||||
CON_ERRPRINTF("VM_GetTileData: invalid tile (%d)\n", iTile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (lLabelID)
|
||||
{
|
||||
case TILEDATA_XSIZE: lLabelID = tilesiz[iTile].x; break;
|
||||
case TILEDATA_YSIZE: lLabelID = tilesiz[iTile].y; break;
|
||||
|
||||
case TILEDATA_ANIMFRAMES: lLabelID = picanm[iTile].num; break;
|
||||
case TILEDATA_XOFFSET: lLabelID = picanm[iTile].xofs; break;
|
||||
case TILEDATA_YOFFSET: lLabelID = picanm[iTile].yofs; break;
|
||||
case TILEDATA_ANIMSPEED: lLabelID = picanm[iTile].sf & PICANM_ANIMSPEED_MASK; break;
|
||||
case TILEDATA_ANIMTYPE: lLabelID = (picanm[iTile].sf & PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT; break;
|
||||
|
||||
case TILEDATA_GAMEFLAGS: lLabelID = g_tile[iTile].flags; break;
|
||||
|
||||
default: lLabelID = -1; break;
|
||||
}
|
||||
|
||||
return lLabelID;
|
||||
}
|
||||
|
||||
int32_t __fastcall VM_GetPalData(register int32_t const iPal, register int32_t lLabelID)
|
||||
{
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)iPal >= MAXPALOOKUPS))
|
||||
{
|
||||
CON_ERRPRINTF("VM_GetPalData: invalid pal (%d)\n", iPal);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (lLabelID)
|
||||
{
|
||||
case PALDATA_NOFLOORPAL: lLabelID = g_noFloorPal[iPal]; break;
|
||||
|
||||
default: lLabelID = -1; break;
|
||||
}
|
||||
|
||||
return lLabelID;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -729,6 +729,33 @@ nastyhacks:
|
|||
rv = VM_GetProjectile(index, label);
|
||||
break;
|
||||
}
|
||||
case STRUCT_TILEDATA:
|
||||
{
|
||||
int const label = *insptr++;
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXTILES))
|
||||
{
|
||||
iActor = index;
|
||||
goto badtile;
|
||||
}
|
||||
|
||||
rv = VM_GetTileData(index, label);
|
||||
break;
|
||||
}
|
||||
|
||||
case STRUCT_PALDATA:
|
||||
{
|
||||
int const label = *insptr++;
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXPALOOKUPS))
|
||||
{
|
||||
iActor = index;
|
||||
goto badpal;
|
||||
}
|
||||
|
||||
rv = VM_GetPalData(index, label);
|
||||
break;
|
||||
}
|
||||
|
||||
case STRUCT_PLAYER:
|
||||
{
|
||||
|
@ -829,6 +856,10 @@ badwall:
|
|||
badtile:
|
||||
CON_ERRPRINTF("Gv_GetVar(): invalid tile ID %d\n", iActor);
|
||||
return -1;
|
||||
|
||||
badpal:
|
||||
CON_ERRPRINTF("Gv_GetVar(): invalid pal ID %d\n", iActor);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void __fastcall Gv_SetVar(int32_t const id, int32_t const lValue, int32_t const iActor, int32_t const iPlayer)
|
||||
|
@ -879,6 +910,7 @@ enum {
|
|||
GVX_BADWALL,
|
||||
GVX_BADINDEX,
|
||||
GVX_BADTILE,
|
||||
GVX_BADPAL,
|
||||
};
|
||||
|
||||
static const char *gvxerrs[] = {
|
||||
|
@ -889,6 +921,7 @@ static const char *gvxerrs[] = {
|
|||
"Gv_GetVarX(): invalid wall ID",
|
||||
"Gv_GetVarX(): invalid array index",
|
||||
"Gv_GetVarX(): invalid tile ID",
|
||||
"Gv_GetVarX(): invalid pal ID",
|
||||
};
|
||||
|
||||
int32_t __fastcall Gv_GetSpecialVarX(int32_t id)
|
||||
|
@ -979,6 +1012,35 @@ int32_t __fastcall Gv_GetSpecialVarX(int32_t id)
|
|||
rv = VM_GetProjectile(index, label);
|
||||
break;
|
||||
}
|
||||
case STRUCT_TILEDATA:
|
||||
{
|
||||
int const label = *insptr++;
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXTILES))
|
||||
{
|
||||
id = index;
|
||||
CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADTILE], id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = VM_GetTileData(index, label);
|
||||
break;
|
||||
}
|
||||
|
||||
case STRUCT_PALDATA:
|
||||
{
|
||||
int const label = *insptr++;
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned) index >= MAXPALOOKUPS))
|
||||
{
|
||||
id = index;
|
||||
CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPAL], id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = VM_GetPalData(index, label);
|
||||
break;
|
||||
}
|
||||
|
||||
case STRUCT_PLAYER:
|
||||
{
|
||||
|
@ -1599,6 +1661,8 @@ static void Gv_AddSystemVars(void)
|
|||
Gv_NewVar("thisprojectile", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("userdef", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("input", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("tiledata", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("paldata", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
|
||||
Gv_NewVar("myconnectindex", (intptr_t)&myconnectindex, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("screenpeek", (intptr_t)&screenpeek, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
|
|
Loading…
Reference in a new issue