From 07e8ef6627b8f85c46d49de5162599c6ddda7460 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 24 Apr 2017 20:33:39 +0100 Subject: [PATCH 1/4] 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 # Conflicts: # src/p_spec.c --- src/p_setup.c | 6 +++-- src/p_spec.c | 62 ++++++++++++++++++++++++++++++++------------------- src/p_spec.h | 1 + 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index ba4554e68..aab686d57 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3041,6 +3041,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 @@ -3059,8 +3063,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) { diff --git a/src/p_spec.c b/src/p_spec.c index 67bb74720..1909e34d8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5621,6 +5621,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*8)/10; + + // 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. * @@ -5642,15 +5681,6 @@ void P_SpawnSpecials(INT32 fromnetsave) // but currently isn't. (void)fromnetsave; - // Set the default gravity. Custom gravity overrides this setting. - gravity = (FRACUNIT*8)/10; - - // 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++) @@ -5699,20 +5729,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 diff --git a/src/p_spec.h b/src/p_spec.h index 1231aeda8..b604ac951 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -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 From 11b5b624bb7d16597f678bd89f38b8f16323db03 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 24 Apr 2017 20:43:58 +0100 Subject: [PATCH 2/4] Whoops forgot this --- src/p_spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 1909e34d8..9254c389e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5650,7 +5650,7 @@ void P_InitSpecials(void) curWeather = mapheaderinfo[gamemap-1]->weather; break; default: // blank/none - curWeather = PRECIP_NONE: + curWeather = PRECIP_NONE; break; } From 453f673219b11d3320cabc3ae639b21892def99e Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 24 Apr 2017 21:05:28 +0100 Subject: [PATCH 3/4] Spinning/swinging maces/chains can now use P_FindSpecialLineFromTag! # Conflicts: # src/p_mobj.c --- src/p_mobj.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index e1ac3f2db..3d309f0d1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11531,20 +11531,16 @@ void P_SpawnMapThing(mapthing_t *mthing) mobjtype_t macetype = MT_SMALLMACE; boolean firsttime; mobj_t *spawnee; - size_t line; + INT32 line; const size_t mthingi = (size_t)(mthing - mapthings); - // Why does P_FindSpecialLineFromTag not work here?!? - // Monster Iestyn: tag lists haven't been initialised yet for the map, that's why - for (line = 0; line < numlines; line++) - { - if (lines[line].special == 9 && lines[line].tag == mthing->angle) - break; - } + // Find the corresponding linedef special, using angle as tag + // P_FindSpecialLineFromTag works here now =D + line = P_FindSpecialLineFromTag(9, mthing->angle, -1); - if (line == numlines) + if (line == -1) { - CONS_Debug(DBG_GAMELOGIC, "Mace chain (mapthing #%s) needs tagged to a #9 parameter line (trying to find tag %d).\n", sizeu1(mthingi), mthing->angle); + CONS_Debug(DBG_GAMELOGIC, "Mace chain (mapthing #%s) needs to be tagged to a #9 parameter line (trying to find tag %d).\n", sizeu1(mthingi), mthing->angle); return; } /* From 3b3a37daad13eef69013f4c515109ed65fbd3a85 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 25 Apr 2017 20:39:32 +0100 Subject: [PATCH 4/4] level header's "forcecharacter" parameter doesn't take skin numbers anymore, so this isn't needed! --- src/p_setup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index aab686d57..e283254db 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2791,8 +2791,7 @@ boolean P_SetupLevel(boolean skipprecip) postimgtype = postimgtype2 = postimgtype3 = postimgtype4 = postimg_none; - if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0' - && atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255) + if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0') P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter); // chasecam on in chaos, race, coop