Cleaned up some more stuff in P_LoadLevel()

This commit is contained in:
MascaraSnake 2019-12-28 12:48:32 +01:00
parent c059146937
commit e9376a8353
6 changed files with 20 additions and 36 deletions

View file

@ -2152,7 +2152,7 @@ lumpnum_t lastloadedmaplumpnum; // for comparative savegame
//
// Some player initialization for map start.
//
static void P_LevelInitStuff(void)
static void P_InitLevelSettings(void)
{
INT32 i;
boolean canresetlives = true;
@ -2277,7 +2277,7 @@ void P_LoadThingsOnly(void)
P_RemoveMobj((mobj_t *)think);
}
P_LevelInitStuff();
P_InitLevelSettings();
P_SpawnMapThings(true);
@ -2777,19 +2777,16 @@ static void P_InitGametype(void)
/** Loads a level from a lump or external wad.
*
* \param skipprecip If true, don't spawn precipitation.
* \param fromnetsave If true, skip some stuff because we're loading a netgame snapshot.
* \todo Clean up, refactor, split up; get rid of the bloat.
*/
boolean P_LoadLevel(boolean skipprecip)
boolean P_LoadLevel(boolean fromnetsave)
{
// use gamemap to get map number.
// 99% of the things already did, so.
// Map header should always be in place at this point
INT32 i, loadprecip = 1, ranspecialwipe = 0;
boolean spawnemblems = true;
INT32 fromnetsave = 0;
INT32 i, ranspecialwipe = 0;
sector_t *ss;
boolean chase;
levelloading = true;
// This is needed. Don't touch.
@ -2820,19 +2817,18 @@ boolean P_LoadLevel(boolean skipprecip)
if (cv_runscripts.value && mapheaderinfo[gamemap-1]->scriptname[0] != '#')
P_RunLevelScript(mapheaderinfo[gamemap-1]->scriptname);
P_LevelInitStuff();
P_InitLevelSettings();
postimgtype = postimgtype2 = postimg_none;
if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0')
P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter);
// chasecam on in chaos, race, coop
// chasecam off in match, tag, capture the flag
chase = (!(gametyperules & GTR_FIRSTPERSON)) || (maptol & TOL_2D);
if (!dedicated)
{
// chasecam on in first-person gametypes and 2D
boolean chase = (!(gametyperules & GTR_FIRSTPERSON)) || (maptol & TOL_2D);
// Salt: CV_ClearChangedFlags() messes with your settings :(
/*if (!cv_cam_speed.changed)
CV_Set(&cv_cam_speed, cv_cam_speed.defaultvalue);*/
@ -2943,14 +2939,7 @@ boolean P_LoadLevel(boolean skipprecip)
P_InitThinkers();
P_InitCachedActions();
/// \note for not spawning precipitation, etc. when loading netgame snapshots
if (skipprecip)
{
fromnetsave = 1;
loadprecip = 0;
spawnemblems = false;
}
else if (savedata.lives > 0)
if (!fromnetsave && savedata.lives > 0)
{
numgameovers = savedata.numgameovers;
players[consoleplayer].continues = savedata.continues;
@ -2964,9 +2953,7 @@ boolean P_LoadLevel(boolean skipprecip)
// internal game map
maplumpname = G_BuildMapName(gamemap);
//lastloadedmaplumpnum = LUMPERROR;
lastloadedmaplumpnum = W_CheckNumForName(maplumpname);
if (lastloadedmaplumpnum == INT16_MAX)
I_Error("Map %s not found.\n", maplumpname);
@ -2991,7 +2978,7 @@ boolean P_LoadLevel(boolean skipprecip)
P_ResetDynamicSlopes(fromnetsave);
#endif
P_SpawnMapThings(spawnemblems);
P_SpawnMapThings(!fromnetsave);
skyboxmo[0] = skyboxviewpnts[0];
skyboxmo[1] = skyboxcenterpnts[0];
@ -3002,7 +2989,7 @@ boolean P_LoadLevel(boolean skipprecip)
// set up world state
P_SpawnSpecials(fromnetsave);
if (loadprecip) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame)
if (!fromnetsave) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame)
P_SpawnPrecipitation();
#ifdef HWRENDER // not win32 only 19990829 by Kin
@ -3068,7 +3055,7 @@ boolean P_LoadLevel(boolean skipprecip)
lastmaploaded = gamemap; // HAS to be set after saving!!
if (loadprecip) // uglier hack
if (!fromnetsave) // uglier hack
{ // to make a newly loaded level start on the second frame.
INT32 buf = gametic % BACKUPTICS;
for (i = 0; i < MAXPLAYERS; i++)

View file

@ -97,7 +97,7 @@ void P_SetupLevelSky(INT32 skynum, boolean global);
void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum);
#endif
void P_LoadThingsOnly(void);
boolean P_LoadLevel(boolean skipprecip);
boolean P_LoadLevel(boolean fromnetsave);
boolean P_AddWadFile(const char *wadfilename);
boolean P_RunSOC(const char *socfilename);
void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num);

View file

@ -553,11 +553,8 @@ pslope_t *P_SlopeById(UINT16 id)
}
/// Reset slopes and read them from special lines.
void P_ResetDynamicSlopes(const UINT32 fromsave) {
void P_ResetDynamicSlopes(const boolean fromsave) {
size_t i;
boolean spawnthinkers = !(boolean)fromsave;
slopelist = NULL;
slopecount = 0;
@ -574,14 +571,14 @@ void P_ResetDynamicSlopes(const UINT32 fromsave) {
case 711:
case 712:
case 713:
line_SpawnViaLine(i, spawnthinkers);
line_SpawnViaLine(i, !fromsave);
break;
case 704:
case 705:
case 714:
case 715:
line_SpawnViaVertexes(i, spawnthinkers);
line_SpawnViaVertexes(i, !fromsave);
break;
default:

View file

@ -23,7 +23,7 @@ extern UINT16 slopecount;
void P_LinkSlopeThinkers (void);
void P_CalculateSlopeNormal(pslope_t *slope);
void P_ResetDynamicSlopes(const UINT32 fromsave);
void P_ResetDynamicSlopes(const boolean fromsave);
//
// P_CopySectorSlope

View file

@ -6426,7 +6426,7 @@ static void P_ApplyFlatAlignment(line_t *master, sector_t *sector, angle_t flata
* as they'll just be erased by UnArchiveThinkers.
* \sa P_SpawnPrecipitation, P_SpawnFriction, P_SpawnPushers, P_SpawnScrollers
*/
void P_SpawnSpecials(INT32 fromnetsave)
void P_SpawnSpecials(boolean fromnetsave)
{
sector_t *sector;
size_t i;

View file

@ -35,7 +35,7 @@ void P_SetupLevelFlatAnims(void);
// at map load
void P_InitSpecials(void);
void P_SpawnSpecials(INT32 fromnetsave);
void P_SpawnSpecials(boolean fromnetsave);
// every tic
void P_UpdateSpecials(void);