Split P_FadeLight into P_FadeLightBySector

This commit is contained in:
mazmazz 2018-09-08 22:14:49 -04:00
parent 1e1b01c157
commit 68e67917f1
2 changed files with 41 additions and 40 deletions

View file

@ -323,33 +323,26 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector,
return g; return g;
} }
/** Fades all the lights in sectors with a particular tag to a new /** Fades all the lights in specified sector to a new
* value. * value.
* *
* \param tag Tag to look for sectors by. * \param sector Target sector
* \param destvalue The final light value in these sectors. * \param destvalue The final light value in these sectors.
* \param speed Speed of the fade; the change to the ligh * \param speed Speed of the fade; the change to the ligh
* level in each sector per tic. * level in each sector per tic.
* \param ticbased Use a specific duration for the fade, defined by speed * \param ticbased Use a specific duration for the fade, defined by speed
* \sa T_LightFade * \sa T_LightFade
*/ */
void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased) void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased)
{ {
INT32 i;
lightlevel_t *ll; lightlevel_t *ll;
sector_t *sector;
// search all sectors for ones with tag
for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;)
{
sector = &sectors[i];
P_RemoveLighting(sector); // remove the old lighting effect first P_RemoveLighting(sector); // remove the old lighting effect first
if ((ticbased && !speed) || sector->lightlevel == destvalue) // set immediately if ((ticbased && !speed) || sector->lightlevel == destvalue) // set immediately
{ {
sector->lightlevel = destvalue; sector->lightlevel = destvalue;
continue; return;
} }
ll = Z_Calloc(sizeof (*ll), PU_LEVSPEC, NULL); ll = Z_Calloc(sizeof (*ll), PU_LEVSPEC, NULL);
@ -376,6 +369,13 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased)
ll->speed = abs(speed); ll->speed = abs(speed);
} }
} }
void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased)
{
INT32 i;
// search all sectors for ones with tag
for (i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0 ;)
P_FadeLightBySector(&sectors[i], destvalue, speed, ticbased);
} }
/** Fades the light level in a sector to a new value. /** Fades the light level in a sector to a new value.

View file

@ -161,6 +161,7 @@ strobe_t * P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector
void T_Glow(glow_t *g); void T_Glow(glow_t *g);
glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length); glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length);
void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased);
void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased); void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased);
void T_LightFade(lightlevel_t *ll); void T_LightFade(lightlevel_t *ll);