mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-31 05:30:48 +00:00
Merge branch 'lightfade-ticbased' into le-fadefof
This commit is contained in:
commit
c468451a63
4 changed files with 27 additions and 27 deletions
|
@ -352,19 +352,17 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean
|
||||||
P_AddThinker(&ll->thinker); // add thinker
|
P_AddThinker(&ll->thinker); // add thinker
|
||||||
|
|
||||||
ll->sector = sector;
|
ll->sector = sector;
|
||||||
|
ll->sourcelevel = sector->lightlevel;
|
||||||
ll->destlevel = destvalue;
|
ll->destlevel = destvalue;
|
||||||
|
|
||||||
if (ticbased)
|
if (ticbased)
|
||||||
{
|
{
|
||||||
ll->ticbased = ticbased;
|
ll->ticbased = true;
|
||||||
ll->timer = abs(speed);
|
ll->timer = ll->speed = abs(speed); // use ll->speed for total duration
|
||||||
ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->timer))/FRACUNIT;
|
|
||||||
if (!ll->speed)
|
|
||||||
ll->speed = (destvalue < sector->lightlevel) ? -1 : 1;
|
|
||||||
ll->interval = max(FixedFloor(FixedDiv(ll->timer, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ll->ticbased = false;
|
||||||
ll->timer = -1;
|
ll->timer = -1;
|
||||||
ll->speed = abs(speed);
|
ll->speed = abs(speed);
|
||||||
}
|
}
|
||||||
|
@ -389,15 +387,17 @@ void T_LightFade(lightlevel_t *ll)
|
||||||
{
|
{
|
||||||
if (--ll->timer <= 0)
|
if (--ll->timer <= 0)
|
||||||
{
|
{
|
||||||
ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel
|
ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel
|
||||||
P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker
|
P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker
|
||||||
}
|
}
|
||||||
else if (!(ll->timer % ll->interval))
|
|
||||||
{
|
|
||||||
if (ll->speed < 0)
|
|
||||||
ll->sector->lightlevel = max(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel);
|
|
||||||
else
|
else
|
||||||
ll->sector->lightlevel = min(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel);
|
{
|
||||||
|
INT16 delta = abs(ll->destlevel - ll->sourcelevel);
|
||||||
|
fixed_t factor = min(FixedDiv(ll->speed - ll->timer, ll->speed), 1*FRACUNIT);
|
||||||
|
if (ll->destlevel < ll->sourcelevel)
|
||||||
|
ll->sector->lightlevel = max(min(ll->sector->lightlevel, ll->sourcelevel - (INT16)FixedMul(delta, factor)), ll->destlevel);
|
||||||
|
else if (ll->destlevel > ll->sourcelevel)
|
||||||
|
ll->sector->lightlevel = min(max(ll->sector->lightlevel, ll->sourcelevel + (INT16)FixedMul(delta, factor)), ll->destlevel);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -408,12 +408,12 @@ void T_LightFade(lightlevel_t *ll)
|
||||||
if (ll->sector->lightlevel + ll->speed >= ll->destlevel)
|
if (ll->sector->lightlevel + ll->speed >= ll->destlevel)
|
||||||
{
|
{
|
||||||
// stop changing light level
|
// stop changing light level
|
||||||
ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel
|
ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel
|
||||||
|
|
||||||
P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker
|
P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ll->sector->lightlevel = (INT16)(ll->sector->lightlevel + (INT16)ll->speed); // move lightlevel
|
ll->sector->lightlevel += ll->speed; // move lightlevel
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -421,11 +421,11 @@ void T_LightFade(lightlevel_t *ll)
|
||||||
if (ll->sector->lightlevel - ll->speed <= ll->destlevel)
|
if (ll->sector->lightlevel - ll->speed <= ll->destlevel)
|
||||||
{
|
{
|
||||||
// stop changing light level
|
// stop changing light level
|
||||||
ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel
|
ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel
|
||||||
|
|
||||||
P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker
|
P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ll->sector->lightlevel = (INT16)(ll->sector->lightlevel - (INT16)ll->speed); // move lightlevel
|
ll->sector->lightlevel -= ll->speed; // move lightlevel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1538,11 +1538,11 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type)
|
||||||
const lightlevel_t *ht = (const void *)th;
|
const lightlevel_t *ht = (const void *)th;
|
||||||
WRITEUINT8(save_p, type);
|
WRITEUINT8(save_p, type);
|
||||||
WRITEUINT32(save_p, SaveSector(ht->sector));
|
WRITEUINT32(save_p, SaveSector(ht->sector));
|
||||||
WRITEINT32(save_p, ht->destlevel);
|
WRITEINT16(save_p, ht->sourcelevel);
|
||||||
WRITEINT32(save_p, ht->speed);
|
WRITEINT16(save_p, ht->destlevel);
|
||||||
|
WRITEINT16(save_p, ht->speed);
|
||||||
WRITEUINT8(save_p, (UINT8)ht->ticbased);
|
WRITEUINT8(save_p, (UINT8)ht->ticbased);
|
||||||
WRITEINT32(save_p, ht->timer);
|
WRITEINT32(save_p, ht->timer);
|
||||||
WRITEUINT32(save_p, ht->interval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -2545,11 +2545,11 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker)
|
||||||
lightlevel_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL);
|
lightlevel_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL);
|
||||||
ht->thinker.function.acp1 = thinker;
|
ht->thinker.function.acp1 = thinker;
|
||||||
ht->sector = LoadSector(READUINT32(save_p));
|
ht->sector = LoadSector(READUINT32(save_p));
|
||||||
ht->destlevel = READINT32(save_p);
|
ht->sourcelevel = READINT16(save_p);
|
||||||
ht->speed = READINT32(save_p);
|
ht->destlevel = READINT16(save_p);
|
||||||
|
ht->speed = READINT16(save_p);
|
||||||
ht->ticbased = (boolean)READUINT8(save_p);
|
ht->ticbased = (boolean)READUINT8(save_p);
|
||||||
ht->timer = READINT32(save_p);
|
ht->timer = READINT32(save_p);
|
||||||
ht->interval = READUINT32(save_p);
|
|
||||||
if (ht->sector)
|
if (ht->sector)
|
||||||
ht->sector->lightingdata = ht;
|
ht->sector->lightingdata = ht;
|
||||||
P_AddThinker(&ht->thinker);
|
P_AddThinker(&ht->thinker);
|
||||||
|
|
|
@ -2788,7 +2788,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
||||||
P_FadeLight(line->tag,
|
P_FadeLight(line->tag,
|
||||||
(line->flags & ML_DONTPEGBOTTOM) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel,
|
(line->flags & ML_DONTPEGBOTTOM) ? max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 255), 0) : line->frontsector->lightlevel,
|
||||||
(line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS,
|
(line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].rowoffset>>FRACBITS, 0) : P_AproxDistance(line->dx, line->dy)>>FRACBITS,
|
||||||
(line->flags & ML_EFFECT5));
|
(line->flags & ML_EFFECT4));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 421: // Stop lighting effect in tagged sectors
|
case 421: // Stop lighting effect in tagged sectors
|
||||||
|
|
|
@ -136,13 +136,13 @@ typedef struct
|
||||||
{
|
{
|
||||||
thinker_t thinker; ///< Thinker in use for the effect.
|
thinker_t thinker; ///< Thinker in use for the effect.
|
||||||
sector_t *sector; ///< Sector where action is taking place.
|
sector_t *sector; ///< Sector where action is taking place.
|
||||||
INT32 destlevel; ///< Light level we're fading to.
|
INT16 sourcelevel; ///< Light level we're fading from.
|
||||||
INT32 speed; ///< Speed at which to change light level.
|
INT16 destlevel; ///< Light level we're fading to.
|
||||||
|
INT16 speed; ///< Speed at which to change light level. OR: Tic-based duration
|
||||||
|
|
||||||
// Tic-based behavior
|
// Tic-based behavior
|
||||||
boolean ticbased; ///< Tic-based logic
|
boolean ticbased; ///< Tic-based logic
|
||||||
INT32 timer; ///< Tic-based timer
|
INT32 timer; ///< Tic-based timer
|
||||||
UINT32 interval; ///< Interval to deduct light level
|
|
||||||
} lightlevel_t;
|
} lightlevel_t;
|
||||||
|
|
||||||
#define GLOWSPEED 8
|
#define GLOWSPEED 8
|
||||||
|
|
Loading…
Reference in a new issue