put precip purge into a function
to reduce code dupe and branching
This commit is contained in:
1 parent
58a9e17500
commit
b6fd7a1e96
5 files changed
+26
-80
No files matched your search
+6
-14
@@ -10174,21 +10174,13 @@ void P_RemoveSavegameMobj(mobj_t *mobj)
|
||||
thinker_t *th = (thinker_t*)mobj;
|
||||
|
||||
// unlink from sector and block lists
|
||||
if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker)
|
||||
{
|
||||
P_UnsetPrecipThingPosition((precipmobj_t *)mobj);
|
||||
}
|
||||
else
|
||||
{
|
||||
// unlink from sector and block lists
|
||||
P_UnsetThingPosition(mobj);
|
||||
P_UnsetThingPosition(mobj);
|
||||
|
||||
// Remove touching_sectorlist from mobj.
|
||||
if (sector_list)
|
||||
{
|
||||
P_DelSeclist(sector_list);
|
||||
sector_list = NULL;
|
||||
}
|
||||
// Remove touching_sectorlist from mobj.
|
||||
if (sector_list)
|
||||
{
|
||||
P_DelSeclist(sector_list);
|
||||
sector_list = NULL;
|
||||
}
|
||||
|
||||
// stop any playing sound
|
||||
|
||||
+1
-18
@@ -2669,8 +2669,6 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save)
|
||||
{
|
||||
thinker_t *currentthinker;
|
||||
thinker_t *next;
|
||||
thinker_t *currentprecipthinker;
|
||||
thinker_t *nextprecip;
|
||||
UINT8 tclass;
|
||||
UINT8 restoreNum = false;
|
||||
UINT32 i;
|
||||
@@ -2696,22 +2694,7 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save)
|
||||
}
|
||||
|
||||
// remove all the current precip thinkers
|
||||
currentprecipthinker = precipcap.next;
|
||||
for (currentprecipthinker = precipcap.next; currentprecipthinker != &precipcap; currentprecipthinker = nextprecip)
|
||||
{
|
||||
nextprecip = currentprecipthinker->next;
|
||||
|
||||
#ifdef PARANOIA
|
||||
if (currentprecipthinker->function.acp1 != (actionf_p1)P_NullPrecipThinker)
|
||||
{
|
||||
(next->prev = currentprecipthinker->prev)->next = nextprecip;
|
||||
R_DestroyLevelInterpolators(currentprecipthinker);
|
||||
Z_Free(currentprecipthinker);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
P_RemoveSavegameMobj((mobj_t *)currentprecipthinker); // item isn't saved, don't remove it
|
||||
}
|
||||
P_PurgePrecipitation();
|
||||
|
||||
// we don't want the removed mobjs to come back
|
||||
iquetail = iquehead = 0;
|
||||
|
||||
+15
-29
@@ -1721,6 +1721,19 @@ static boolean is_rain_type (INT32 weathernum)
|
||||
}
|
||||
}
|
||||
|
||||
void P_PurgePrecipitation(void)
|
||||
{
|
||||
thinker_t *think;
|
||||
thinker_t *next;
|
||||
|
||||
for (think = precipcap.next; think != NULL && think != &precipcap;)
|
||||
{
|
||||
next = think->next;
|
||||
P_FreePrecipMobj((precipmobj_t *)think);
|
||||
think = next;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// P_SwitchWeather
|
||||
//
|
||||
@@ -1729,6 +1742,7 @@ static boolean is_rain_type (INT32 weathernum)
|
||||
void P_SwitchWeather(INT32 weathernum)
|
||||
{
|
||||
boolean purge = true;
|
||||
boolean spawnprecip = false;
|
||||
|
||||
if (weathernum == curWeather)
|
||||
return;
|
||||
@@ -1739,22 +1753,7 @@ void P_SwitchWeather(INT32 weathernum)
|
||||
|
||||
if (purge)
|
||||
{
|
||||
thinker_t *think;
|
||||
thinker_t *next;
|
||||
precipmobj_t *precipmobj;
|
||||
|
||||
for (think = precipcap.next; think != &precipcap; think = next)
|
||||
{
|
||||
next = think->next;
|
||||
|
||||
#ifdef PARANOIA
|
||||
if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker)
|
||||
continue; // not a precipmobj thinker
|
||||
#endif
|
||||
|
||||
precipmobj = (precipmobj_t *)think;
|
||||
P_FreePrecipMobj(precipmobj);
|
||||
}
|
||||
P_PurgePrecipitation();
|
||||
}
|
||||
else // Rather than respawn all that crap, reuse it!
|
||||
{
|
||||
@@ -1764,11 +1763,6 @@ void P_SwitchWeather(INT32 weathernum)
|
||||
|
||||
for (think = precipcap.next; think != &precipcap; think = think->next)
|
||||
{
|
||||
#ifdef PARANOIA
|
||||
if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker)
|
||||
continue; // not a precipmobj thinker
|
||||
#endif
|
||||
|
||||
precipmobj = (precipmobj_t *)think;
|
||||
|
||||
INT32 z = 0;
|
||||
@@ -1813,8 +1807,6 @@ void P_SwitchWeather(INT32 weathernum)
|
||||
}
|
||||
}
|
||||
|
||||
boolean spawnprecip = false;
|
||||
|
||||
switch (weathernum)
|
||||
{
|
||||
case PRECIP_SNOW: // snow
|
||||
@@ -1822,23 +1814,17 @@ void P_SwitchWeather(INT32 weathernum)
|
||||
spawnprecip = true;
|
||||
break;
|
||||
case PRECIP_RAIN: // rain
|
||||
{
|
||||
curWeather = PRECIP_RAIN;
|
||||
spawnprecip = true;
|
||||
break;
|
||||
}
|
||||
case PRECIP_STORM: // storm
|
||||
{
|
||||
curWeather = PRECIP_STORM;
|
||||
spawnprecip = true;
|
||||
break;
|
||||
}
|
||||
case PRECIP_STORM_NOSTRIKES: // storm w/o lightning
|
||||
{
|
||||
curWeather = PRECIP_STORM_NOSTRIKES;
|
||||
spawnprecip = true;
|
||||
break;
|
||||
}
|
||||
case PRECIP_STORM_NORAIN: // storm w/o rain
|
||||
curWeather = PRECIP_STORM_NORAIN;
|
||||
break;
|
||||
|
||||
@@ -74,6 +74,7 @@ INT32 P_FindMinSurroundingLight(sector_t *sector, INT32 max);
|
||||
void P_SetupSignExit(player_t *player);
|
||||
boolean P_IsFlagAtBase(mobjtype_t flag);
|
||||
|
||||
void P_PurgePrecipitation(void);
|
||||
void P_SwitchWeather(INT32 weathernum);
|
||||
|
||||
boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller);
|
||||
|
||||
+3
-19
@@ -295,27 +295,11 @@ static void FlipCam4_OnChange(void)
|
||||
|
||||
static void Precipstuff_OnChange(void)
|
||||
{
|
||||
if (gamestate != GS_LEVEL)
|
||||
return;
|
||||
|
||||
thinker_t *think;
|
||||
thinker_t *next;
|
||||
precipmobj_t *precipmobj;
|
||||
|
||||
for (think = precipcap.next; think != &precipcap; think = next)
|
||||
if (gamestate == GS_LEVEL)
|
||||
{
|
||||
next = think->next;
|
||||
|
||||
#ifdef PARANOIA
|
||||
if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker)
|
||||
continue; // not a precipmobj thinker
|
||||
#endif
|
||||
|
||||
precipmobj = (precipmobj_t *)think;
|
||||
P_FreePrecipMobj(precipmobj);
|
||||
P_PurgePrecipitation();
|
||||
P_SpawnPrecipitation();
|
||||
}
|
||||
|
||||
P_SpawnPrecipitation();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user