mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-22 09:11:21 +00:00
No more unnecessary light level twiddling
This commit is contained in:
parent
18c2cfcace
commit
9180b86e9e
2 changed files with 13 additions and 64 deletions
|
@ -96,6 +96,9 @@ fireflicker_t *P_SpawnAdjustableFireFlicker(sector_t *sector, INT16 lighta, INT1
|
|||
flick->maxlight++;
|
||||
}
|
||||
|
||||
// Make sure the starting light level is in range.
|
||||
sector->lightlevel = max((INT16)flick->minlight, min((INT16)flick->maxlight, sector->lightlevel));
|
||||
|
||||
return flick;
|
||||
}
|
||||
|
||||
|
@ -224,6 +227,9 @@ strobe_t *P_SpawnAdjustableStrobeFlash(sector_t *sector, INT16 lighta, INT16 lig
|
|||
else
|
||||
flash->count = 1;
|
||||
|
||||
// Make sure the starting light level is in range.
|
||||
sector->lightlevel = max((INT16)flash->minlight, min((INT16)flash->maxlight, sector->lightlevel));
|
||||
|
||||
sector->lightingdata = flash;
|
||||
return flash;
|
||||
}
|
||||
|
@ -295,6 +301,9 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *sector, INT16 lighta, INT16 ligh
|
|||
g->speed = (g->maxlight - g->minlight)/2;
|
||||
}
|
||||
|
||||
// Make sure the starting light level is in range.
|
||||
sector->lightlevel = max((INT16)g->minlight, min((INT16)g->maxlight, sector->lightlevel));
|
||||
|
||||
sector->lightingdata = g;
|
||||
|
||||
return g;
|
||||
|
|
68
src/p_spec.c
68
src/p_spec.c
|
@ -2513,23 +2513,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
|||
if (line->flags & ML_NOCLIMB && line->backsector)
|
||||
{
|
||||
// Use front sector for min light level, back sector for max.
|
||||
// This is tricky because P_SpawnAdjustableFireFlicker expects
|
||||
// the maxsector (second argument) to also be the target
|
||||
// sector, so we have to do some light level twiddling.
|
||||
fireflicker_t *flick;
|
||||
INT16 reallightlevel = sectors[secnum].lightlevel;
|
||||
sectors[secnum].lightlevel = line->backsector->lightlevel;
|
||||
|
||||
flick = P_SpawnAdjustableFireFlicker(§ors[secnum], line->frontsector->lightlevel, sectors[secnum].lightlevel,
|
||||
P_SpawnAdjustableFireFlicker(§ors[secnum], line->frontsector->lightlevel, line->backsector->lightlevel,
|
||||
P_AproxDistance(line->dx, line->dy)>>FRACBITS);
|
||||
|
||||
// Make sure the starting light level is in range.
|
||||
if (reallightlevel < flick->minlight)
|
||||
reallightlevel = (INT16)flick->minlight;
|
||||
else if (reallightlevel > flick->maxlight)
|
||||
reallightlevel = (INT16)flick->maxlight;
|
||||
|
||||
sectors[secnum].lightlevel = reallightlevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2547,23 +2532,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
|||
if (line->flags & ML_NOCLIMB && line->backsector)
|
||||
{
|
||||
// Use front sector for min light level, back sector for max.
|
||||
// This is tricky because P_SpawnAdjustableGlowingLight expects
|
||||
// the maxsector (second argument) to also be the target
|
||||
// sector, so we have to do some light level twiddling.
|
||||
glow_t *glow;
|
||||
INT16 reallightlevel = sectors[secnum].lightlevel;
|
||||
sectors[secnum].lightlevel = line->backsector->lightlevel;
|
||||
|
||||
glow = P_SpawnAdjustableGlowingLight(§ors[secnum], line->frontsector->lightlevel, sectors[secnum].lightlevel,
|
||||
P_SpawnAdjustableGlowingLight(§ors[secnum], line->frontsector->lightlevel, line->backsector->lightlevel,
|
||||
P_AproxDistance(line->dx, line->dy)>>FRACBITS);
|
||||
|
||||
// Make sure the starting light level is in range.
|
||||
if (reallightlevel < glow->minlight)
|
||||
reallightlevel = (INT16)glow->minlight;
|
||||
else if (reallightlevel > glow->maxlight)
|
||||
reallightlevel = (INT16)glow->maxlight;
|
||||
|
||||
sectors[secnum].lightlevel = reallightlevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2581,23 +2551,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
|||
if (line->flags & ML_NOCLIMB && line->backsector)
|
||||
{
|
||||
// Use front sector for min light level, back sector for max.
|
||||
// This is tricky because P_SpawnAdjustableGlowingLight expects
|
||||
// the maxsector (second argument) to also be the target
|
||||
// sector, so we have to do some light level twiddling.
|
||||
strobe_t *flash;
|
||||
INT16 reallightlevel = sectors[secnum].lightlevel;
|
||||
sectors[secnum].lightlevel = line->backsector->lightlevel;
|
||||
|
||||
flash = P_SpawnAdjustableStrobeFlash(§ors[secnum], line->frontsector->lightlevel, sectors[secnum].lightlevel,
|
||||
P_SpawnAdjustableStrobeFlash(§ors[secnum], line->frontsector->lightlevel, line->backsector->lightlevel,
|
||||
abs(line->dx)>>FRACBITS, abs(line->dy)>>FRACBITS, false);
|
||||
|
||||
// Make sure the starting light level is in range.
|
||||
if (reallightlevel < flash->minlight)
|
||||
reallightlevel = (INT16)flash->minlight;
|
||||
else if (reallightlevel > flash->maxlight)
|
||||
reallightlevel = (INT16)flash->maxlight;
|
||||
|
||||
sectors[secnum].lightlevel = reallightlevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2615,23 +2570,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
|||
if (line->flags & ML_NOCLIMB && line->backsector)
|
||||
{
|
||||
// Use front sector for min light level, back sector for max.
|
||||
// This is tricky because P_SpawnAdjustableGlowingLight expects
|
||||
// the maxsector (second argument) to also be the target
|
||||
// sector, so we have to do some light level twiddling.
|
||||
strobe_t *flash;
|
||||
INT16 reallightlevel = sectors[secnum].lightlevel;
|
||||
sectors[secnum].lightlevel = line->backsector->lightlevel;
|
||||
|
||||
flash = P_SpawnAdjustableStrobeFlash(§ors[secnum], line->frontsector->lightlevel, sectors[secnum].lightlevel,
|
||||
P_SpawnAdjustableStrobeFlash(§ors[secnum], line->frontsector->lightlevel, line->backsector->lightlevel,
|
||||
abs(line->dx)>>FRACBITS, abs(line->dy)>>FRACBITS, true);
|
||||
|
||||
// Make sure the starting light level is in range.
|
||||
if (reallightlevel < flash->minlight)
|
||||
reallightlevel = (INT16)flash->minlight;
|
||||
else if (reallightlevel > flash->maxlight)
|
||||
reallightlevel = (INT16)flash->maxlight;
|
||||
|
||||
sectors[secnum].lightlevel = reallightlevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue