Split off part of P_SpawnSpecials into a new function called P_InitSpecials

This allows tag lists, gravity, weather, and the "CheckFor" vars to be initialised before running P_LoadThings or P_ResetDynamicSlopes, in case they could affect mobj spawning or cause a netgame desync somehow by carrying over the previous level's values
This commit is contained in:
Monster Iestyn 2017-04-24 20:33:39 +01:00
parent bbeb69c477
commit 4e96f624e7
3 changed files with 44 additions and 25 deletions

View File

@ -2732,6 +2732,10 @@ boolean P_SetupLevel(boolean skipprecip)
P_PrepareThings(lastloadedmaplumpnum + ML_THINGS);
// init gravity, tag lists,
// anything that P_ResetDynamicSlopes/P_LoadThings needs to know
P_InitSpecials();
#ifdef ESLOPE
P_ResetDynamicSlopes();
#endif
@ -2750,8 +2754,6 @@ boolean P_SetupLevel(boolean skipprecip)
if (loadprecip) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame)
P_SpawnPrecipitation();
globalweather = mapheaderinfo[gamemap-1]->weather;
#ifdef HWRENDER // not win32 only 19990829 by Kin
if (rendermode != render_soft && rendermode != render_none)
{

View File

@ -5546,6 +5546,45 @@ static void P_RunLevelLoadExecutors(void)
}
}
/** Before things are loaded, initialises certain stuff in case they're needed
* by P_ResetDynamicSlopes or P_LoadThings. This was split off from
* P_SpawnSpecials, in case you couldn't tell.
*
* \sa P_SpawnSpecials, P_InitTagLists
* \author Monster Iestyn
*/
void P_InitSpecials(void)
{
// Set the default gravity. Custom gravity overrides this setting.
gravity = FRACUNIT/2;
// Defaults in case levels don't have them set.
sstimer = 90*TICRATE + 6;
totalrings = 1;
CheckForBustableBlocks = CheckForBouncySector = CheckForQuicksand = CheckForMarioBlocks = CheckForFloatBob = CheckForReverseGravity = false;
// Set curWeather
switch (mapheaderinfo[gamemap-1]->weather)
{
case PRECIP_SNOW: // snow
case PRECIP_RAIN: // rain
case PRECIP_STORM: // storm
case PRECIP_STORM_NORAIN: // storm w/o rain
case PRECIP_STORM_NOSTRIKES: // storm w/o lightning
curWeather = mapheaderinfo[gamemap-1]->weather;
break;
default: // blank/none
curWeather = PRECIP_NONE:
break;
}
// Set globalweather
globalweather = mapheaderinfo[gamemap-1]->weather;
P_InitTagLists(); // Create xref tables for tags
}
/** After the map has loaded, scans for specials that spawn 3Dfloors and
* thinkers.
*
@ -5567,15 +5606,6 @@ void P_SpawnSpecials(INT32 fromnetsave)
// but currently isn't.
(void)fromnetsave;
// Set the default gravity. Custom gravity overrides this setting.
gravity = FRACUNIT/2;
// Defaults in case levels don't have them set.
sstimer = 90*TICRATE + 6;
totalrings = 1;
CheckForBustableBlocks = CheckForBouncySector = CheckForQuicksand = CheckForMarioBlocks = CheckForFloatBob = CheckForReverseGravity = false;
// Init special SECTORs.
sector = sectors;
for (i = 0; i < numsectors; i++, sector++)
@ -5624,20 +5654,6 @@ void P_SpawnSpecials(INT32 fromnetsave)
}
}
if (mapheaderinfo[gamemap-1]->weather == 2) // snow
curWeather = PRECIP_SNOW;
else if (mapheaderinfo[gamemap-1]->weather == 3) // rain
curWeather = PRECIP_RAIN;
else if (mapheaderinfo[gamemap-1]->weather == 1) // storm
curWeather = PRECIP_STORM;
else if (mapheaderinfo[gamemap-1]->weather == 5) // storm w/o rain
curWeather = PRECIP_STORM_NORAIN;
else if (mapheaderinfo[gamemap-1]->weather == 6) // storm w/o lightning
curWeather = PRECIP_STORM_NOSTRIKES;
else
curWeather = PRECIP_NONE;
P_InitTagLists(); // Create xref tables for tags
P_SearchForDisableLinedefs(); // Disable linedefs are now allowed to disable *any* line
P_SpawnScrollers(); // Add generalized scrollers

View File

@ -32,6 +32,7 @@ void P_InitPicAnims(void);
void P_SetupLevelFlatAnims(void);
// at map load
void P_InitSpecials(void);
void P_SpawnSpecials(INT32 fromnetsave);
// every tic