Only permit Spray Cans to be grabbed on base game levels

I would not be so heavy handed against preventing players from grabbing Spray Cans on custom levels, but designing a system that permits unloaded headers to retain their cans is frankly overkill. There are plenty of other ways the same kind of level-scouring play can be experienced on custom levels.
This commit is contained in:
toaster 2023-08-23 17:16:07 +01:00
parent 53549bfa2d
commit a3640110ae
8 changed files with 19 additions and 10 deletions

View file

@ -1514,7 +1514,8 @@ void D_SRB2Main(void)
//
// search for mainwad maps
//
P_InitMapData(false);
P_InitMapData();
basenummapheaders = nummapheaders;
CON_SetLoadingProgress(LOADED_IWAD);
@ -1525,7 +1526,7 @@ void D_SRB2Main(void)
//
// search for pwad maps
//
P_InitMapData(true);
P_InitMapData();
CON_SetLoadingProgress(LOADED_PWAD);

View file

@ -605,7 +605,10 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile)
} // end while
if (gamedataadded)
{
basenummapheaders = nummapheaders;
G_LoadGameData();
}
if (gamestate == GS_MENU || gamestate == GS_TITLESCREEN)
{

View file

@ -551,7 +551,7 @@ struct mapheader_t
#define LF2_FINISHNEEDED (1<<3) ///< Not available in Time Attack modes until you beat the level
extern mapheader_t** mapheaderinfo;
extern INT32 nummapheaders, mapallocsize;
extern INT32 nummapheaders, basenummapheaders, mapallocsize;
struct unloaded_mapheader_t
{

View file

@ -193,6 +193,7 @@ quake_t *g_quakes = NULL;
// Map Header Information
mapheader_t** mapheaderinfo = {NULL};
INT32 nummapheaders = 0;
INT32 basenummapheaders = 0;
INT32 mapallocsize = 0;
unloaded_mapheader_t *unloadedmapheaders = NULL;

View file

@ -642,6 +642,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
return;
}
// See also P_SprayCanInit
UINT16 can_id = mapheaderinfo[gamemap-1]->cache_spraycan;
if (can_id < gamedata->numspraycans)
@ -649,7 +650,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
// Assigned to this level, has been grabbed
return;
}
//else
// Prevent footguns - these won't persist when custom levels are unloaded
else if (gamemap-1 < basenummapheaders)
{
// Unassigned, get the next grabbable colour
can_id = gamedata->gotspraycans;

View file

@ -12437,6 +12437,7 @@ static boolean P_SetupEmblem(mapthing_t *mthing, mobj_t *mobj)
void P_SprayCanInit(mobj_t* mobj)
{
// See also P_TouchSpecialThing
UINT16 can_id = mapheaderinfo[gamemap-1]->cache_spraycan;
if (can_id < gamedata->numspraycans)
@ -12444,7 +12445,8 @@ void P_SprayCanInit(mobj_t* mobj)
// Assigned to this level, has been grabbed
mobj->renderflags = (tr_trans50 << RF_TRANSSHIFT);
}
else
// Prevent footguns - these won't persist when custom levels are unloaded
else if (gamemap-1 < basenummapheaders)
{
// Unassigned, get the next grabbable colour
can_id = gamedata->gotspraycans;

View file

@ -8564,7 +8564,7 @@ lumpnum_t wadnamelump = LUMPERROR;
INT16 wadnamemap = 0; // gamemap based
// Initialising map data (and catching replacements)...
UINT8 P_InitMapData(boolean existingmapheaders)
UINT8 P_InitMapData(void)
{
UINT8 ret = 0;
INT32 i, j;
@ -8616,7 +8616,7 @@ UINT8 P_InitMapData(boolean existingmapheaders)
if (maplump == LUMPERROR)
{
#ifndef DEVELOP
if (!existingmapheaders)
if (!basenummapheaders)
{
I_Error("P_InitMapData: Base map %s has a header but no level\n", name);
}
@ -8633,7 +8633,7 @@ UINT8 P_InitMapData(boolean existingmapheaders)
ret |= MAPRET_ADDED;
CONS_Printf("%s\n", name);
if (existingmapheaders && mapheaderinfo[i]->lumpnum != LUMPERROR)
if (basenummapheaders && mapheaderinfo[i]->lumpnum != LUMPERROR)
{
G_SetGameModified(multiplayer, true); // oops, double-defined - no record attack privileges for you
@ -8950,7 +8950,7 @@ boolean P_MultiSetupWadFiles(boolean fullsetup)
if (partadd_stage == 2)
{
UINT8 mapsadded = P_InitMapData(true);
UINT8 mapsadded = P_InitMapData();
if (!mapsadded)
CONS_Printf(M_GetText("No maps added\n"));

View file

@ -114,7 +114,7 @@ boolean P_AddWadFile(const char *wadfilename);
#define MAPRET_ADDED (1)
#define MAPRET_CURRENTREPLACED (1<<1)
UINT8 P_InitMapData(boolean existingmapheaders);
UINT8 P_InitMapData(void);
extern lumpnum_t wadnamelump;
extern INT16 wadnamemap;
#define WADNAMECHECK(name) (!strncmp(name, "WADNAME", 7))