Clean up arguments for the lighting effect functions

This commit is contained in:
MascaraSnake 2021-09-19 15:52:54 +02:00
parent fe708db398
commit 18c2cfcace
3 changed files with 42 additions and 64 deletions

View file

@ -63,34 +63,27 @@ void T_FireFlicker(fireflicker_t *flick)
/** Spawns an adjustable fire flicker effect in a sector.
*
* \param minsector Sector whose light level is used as the darkest.
* \param maxsector Sector whose light level is used as the brightest,
* and also the target sector for the effect.
* \param sector Target sector for the effect.
* \param lighta One of the two light levels to move between.
* \param lightb The other light level.
* \param length Four times the number of tics between flickers.
* \sa T_FireFlicker
*/
fireflicker_t *P_SpawnAdjustableFireFlicker(sector_t *minsector, sector_t *maxsector, INT32 length)
fireflicker_t *P_SpawnAdjustableFireFlicker(sector_t *sector, INT16 lighta, INT16 lightb, INT32 length)
{
fireflicker_t *flick;
P_RemoveLighting(maxsector); // out with the old, in with the new
P_RemoveLighting(sector); // out with the old, in with the new
flick = Z_Calloc(sizeof (*flick), PU_LEVSPEC, NULL);
P_AddThinker(THINK_MAIN, &flick->thinker);
flick->thinker.function.acp1 = (actionf_p1)T_FireFlicker;
flick->sector = maxsector;
flick->maxlight = maxsector->lightlevel;
flick->minlight = minsector->lightlevel;
if (flick->minlight > flick->maxlight)
{
// You mixed them up, you dummy.
INT32 oops = flick->minlight;
flick->minlight = flick->maxlight;
flick->maxlight = oops;
}
flick->sector = sector;
flick->maxlight = max(lighta, lightb);
flick->minlight = min(lighta, lightb);
flick->count = flick->resetcount = length/4;
maxsector->lightingdata = flick;
sector->lightingdata = flick;
// input bounds checking and stuff
if (!flick->resetcount)
@ -194,9 +187,9 @@ void T_StrobeFlash(strobe_t *flash)
/** Spawns an adjustable strobe light effect in a sector.
*
* \param minsector Sector whose light level is used as the darkest.
* \param maxsector Sector whose light level is used as the brightest,
* and also the target sector for the effect.
* \param sector Target sector for the effect.
* \param lighta One of the two light levels to move between.
* \param lightb The other light level.
* \param darktime Time in tics for the light to be dark.
* \param brighttime Time in tics for the light to be bright.
* \param inSync If true, the effect will be kept in sync
@ -207,29 +200,21 @@ void T_StrobeFlash(strobe_t *flash)
* the strobe flash is random.
* \sa T_StrobeFlash
*/
strobe_t *P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector, INT32 darktime, INT32 brighttime, boolean inSync)
strobe_t *P_SpawnAdjustableStrobeFlash(sector_t *sector, INT16 lighta, INT16 lightb, INT32 darktime, INT32 brighttime, boolean inSync)
{
strobe_t *flash;
P_RemoveLighting(maxsector); // out with the old, in with the new
P_RemoveLighting(sector); // out with the old, in with the new
flash = Z_Calloc(sizeof (*flash), PU_LEVSPEC, NULL);
P_AddThinker(THINK_MAIN, &flash->thinker);
flash->sector = maxsector;
flash->sector = sector;
flash->darktime = darktime;
flash->brighttime = brighttime;
flash->thinker.function.acp1 = (actionf_p1)T_StrobeFlash;
flash->maxlight = maxsector->lightlevel;
flash->minlight = minsector->lightlevel;
if (flash->minlight > flash->maxlight)
{
// You mixed them up, you dummy.
INT32 oops = flash->minlight;
flash->minlight = flash->maxlight;
flash->maxlight = oops;
}
flash->maxlight = max(lighta, lightb);
flash->minlight = min(lighta, lightb);
if (flash->minlight == flash->maxlight)
flash->minlight = 0;
@ -239,7 +224,7 @@ strobe_t *P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector,
else
flash->count = 1;
maxsector->lightingdata = flash;
sector->lightingdata = flash;
return flash;
}
@ -276,31 +261,24 @@ void T_Glow(glow_t *g)
/** Spawns an adjustable glowing light effect in a sector.
*
* \param minsector Sector whose light level is used as the darkest.
* \param maxsector Sector whose light level is used as the brightest,
* and also the target sector for the effect.
* \param sector Target sector for the effect.
* \param lighta One of the two light levels to move between.
* \param lightb The other light level.
* \param length The speed of the effect.
* \sa T_Glow
*/
glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length)
glow_t *P_SpawnAdjustableGlowingLight(sector_t *sector, INT16 lighta, INT16 lightb, INT32 length)
{
glow_t *g;
P_RemoveLighting(maxsector); // out with the old, in with the new
P_RemoveLighting(sector); // out with the old, in with the new
g = Z_Calloc(sizeof (*g), PU_LEVSPEC, NULL);
P_AddThinker(THINK_MAIN, &g->thinker);
g->sector = maxsector;
g->minlight = minsector->lightlevel;
g->maxlight = maxsector->lightlevel;
if (g->minlight > g->maxlight)
{
// You mixed them up, you dummy.
INT32 oops = g->minlight;
g->minlight = g->maxlight;
g->maxlight = oops;
}
g->sector = sector;
g->minlight = min(lighta, lightb);
g->maxlight = max(lighta, lightb);
g->thinker.function.acp1 = (actionf_p1)T_Glow;
g->direction = 1;
g->speed = length/4;
@ -317,7 +295,7 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector,
g->speed = (g->maxlight - g->minlight)/2;
}
maxsector->lightingdata = g;
sector->lightingdata = g;
return g;
}

View file

@ -2520,7 +2520,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
INT16 reallightlevel = sectors[secnum].lightlevel;
sectors[secnum].lightlevel = line->backsector->lightlevel;
flick = P_SpawnAdjustableFireFlicker(line->frontsector, &sectors[secnum],
flick = P_SpawnAdjustableFireFlicker(&sectors[secnum], line->frontsector->lightlevel, sectors[secnum].lightlevel,
P_AproxDistance(line->dx, line->dy)>>FRACBITS);
// Make sure the starting light level is in range.
@ -2535,7 +2535,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
{
// Use front sector for min, target sector for max,
// the same way linetype 61 does it.
P_SpawnAdjustableFireFlicker(line->frontsector, &sectors[secnum],
P_SpawnAdjustableFireFlicker(&sectors[secnum], line->frontsector->lightlevel, sectors[secnum].lightlevel,
P_AproxDistance(line->dx, line->dy)>>FRACBITS);
}
}
@ -2554,7 +2554,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
INT16 reallightlevel = sectors[secnum].lightlevel;
sectors[secnum].lightlevel = line->backsector->lightlevel;
glow = P_SpawnAdjustableGlowingLight(line->frontsector, &sectors[secnum],
glow = P_SpawnAdjustableGlowingLight(&sectors[secnum], line->frontsector->lightlevel, sectors[secnum].lightlevel,
P_AproxDistance(line->dx, line->dy)>>FRACBITS);
// Make sure the starting light level is in range.
@ -2569,7 +2569,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
{
// Use front sector for min, target sector for max,
// the same way linetype 602 does it.
P_SpawnAdjustableGlowingLight(line->frontsector, &sectors[secnum],
P_SpawnAdjustableGlowingLight(&sectors[secnum], line->frontsector->lightlevel, sectors[secnum].lightlevel,
P_AproxDistance(line->dx, line->dy)>>FRACBITS);
}
}
@ -2588,7 +2588,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
INT16 reallightlevel = sectors[secnum].lightlevel;
sectors[secnum].lightlevel = line->backsector->lightlevel;
flash = P_SpawnAdjustableStrobeFlash(line->frontsector, &sectors[secnum],
flash = P_SpawnAdjustableStrobeFlash(&sectors[secnum], line->frontsector->lightlevel, sectors[secnum].lightlevel,
abs(line->dx)>>FRACBITS, abs(line->dy)>>FRACBITS, false);
// Make sure the starting light level is in range.
@ -2603,7 +2603,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
{
// Use front sector for min, target sector for max,
// the same way linetype 602 does it.
P_SpawnAdjustableStrobeFlash(line->frontsector, &sectors[secnum],
P_SpawnAdjustableStrobeFlash(&sectors[secnum], line->frontsector->lightlevel, sectors[secnum].lightlevel,
abs(line->dx)>>FRACBITS, abs(line->dy)>>FRACBITS, false);
}
}
@ -2622,7 +2622,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
INT16 reallightlevel = sectors[secnum].lightlevel;
sectors[secnum].lightlevel = line->backsector->lightlevel;
flash = P_SpawnAdjustableStrobeFlash(line->frontsector, &sectors[secnum],
flash = P_SpawnAdjustableStrobeFlash(&sectors[secnum], line->frontsector->lightlevel, sectors[secnum].lightlevel,
abs(line->dx)>>FRACBITS, abs(line->dy)>>FRACBITS, true);
// Make sure the starting light level is in range.
@ -2637,7 +2637,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
{
// Use front sector for min, target sector for max,
// the same way linetype 602 does it.
P_SpawnAdjustableStrobeFlash(line->frontsector, &sectors[secnum],
P_SpawnAdjustableStrobeFlash(&sectors[secnum], line->frontsector->lightlevel, sectors[secnum].lightlevel,
abs(line->dx)>>FRACBITS, abs(line->dy)>>FRACBITS, true);
}
}
@ -6960,28 +6960,28 @@ void P_SpawnSpecials(boolean fromnetsave)
case 602: // Adjustable pulsating light
sec = sides[*lines[i].sidenum].sector - sectors;
TAG_ITER_SECTORS(tag, s)
P_SpawnAdjustableGlowingLight(&sectors[sec], &sectors[s],
P_SpawnAdjustableGlowingLight(&sectors[s], sectors[sec].lightlevel, sectors[s].lightlevel,
P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS);
break;
case 603: // Adjustable flickering light
sec = sides[*lines[i].sidenum].sector - sectors;
TAG_ITER_SECTORS(tag, s)
P_SpawnAdjustableFireFlicker(&sectors[sec], &sectors[s],
P_SpawnAdjustableFireFlicker(&sectors[s], sectors[sec].lightlevel, sectors[s].lightlevel,
P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS);
break;
case 604: // Adjustable Blinking Light (unsynchronized)
sec = sides[*lines[i].sidenum].sector - sectors;
TAG_ITER_SECTORS(tag, s)
P_SpawnAdjustableStrobeFlash(&sectors[sec], &sectors[s],
P_SpawnAdjustableStrobeFlash(&sectors[s], sectors[sec].lightlevel, sectors[s].lightlevel,
abs(lines[i].dx)>>FRACBITS, abs(lines[i].dy)>>FRACBITS, false);
break;
case 605: // Adjustable Blinking Light (synchronized)
sec = sides[*lines[i].sidenum].sector - sectors;
TAG_ITER_SECTORS(tag, s)
P_SpawnAdjustableStrobeFlash(&sectors[sec], &sectors[s],
P_SpawnAdjustableStrobeFlash(&sectors[s], sectors[sec].lightlevel, sectors[s].lightlevel,
abs(lines[i].dx)>>FRACBITS, abs(lines[i].dy)>>FRACBITS, true);
break;

View file

@ -284,15 +284,15 @@ typedef struct
void P_RemoveLighting(sector_t *sector);
void T_FireFlicker(fireflicker_t *flick);
fireflicker_t *P_SpawnAdjustableFireFlicker(sector_t *minsector, sector_t *maxsector, INT32 length);
fireflicker_t *P_SpawnAdjustableFireFlicker(sector_t *sector, INT16 lighta, INT16 lightb, INT32 length);
void T_LightningFlash(lightflash_t *flash);
void T_StrobeFlash(strobe_t *flash);
void P_SpawnLightningFlash(sector_t *sector);
strobe_t * P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector, INT32 darktime, INT32 brighttime, boolean inSync);
strobe_t * P_SpawnAdjustableStrobeFlash(sector_t *sector, INT16 lighta, INT16 lightb, INT32 darktime, INT32 brighttime, boolean inSync);
void T_Glow(glow_t *g);
glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, INT32 length);
glow_t *P_SpawnAdjustableGlowingLight(sector_t *sector, INT16 lighta, INT16 lightb, 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, boolean force);