mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 07:22:28 +00:00
Merge branch 'lightfade-ticbased' into le-fadefof
This commit is contained in:
commit
703764d769
3 changed files with 14 additions and 14 deletions
|
@ -356,16 +356,16 @@ void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean
|
|||
|
||||
if (ticbased)
|
||||
{
|
||||
ll->duration = abs(speed);
|
||||
ll->speed = FixedFloor(FixedDiv(destvalue - sector->lightlevel, ll->duration))/FRACUNIT;
|
||||
ll->ticbased = ticbased;
|
||||
ll->timer = abs(speed);
|
||||
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->duration, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1);
|
||||
ll->firsttic = gametic;
|
||||
ll->interval = max(FixedFloor(FixedDiv(ll->timer, abs(destvalue - sector->lightlevel)))/FRACUNIT, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ll->duration = -1;
|
||||
ll->timer = -1;
|
||||
ll->speed = abs(speed);
|
||||
}
|
||||
}
|
||||
|
@ -385,14 +385,14 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed, boolean ticbased)
|
|||
*/
|
||||
void T_LightFade(lightlevel_t *ll)
|
||||
{
|
||||
if (ll->duration >= 0) // tic-based
|
||||
if (ll->ticbased)
|
||||
{
|
||||
if (gametic - ll->firsttic >= ll->duration)
|
||||
if (--ll->timer <= 0)
|
||||
{
|
||||
ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel
|
||||
P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker
|
||||
}
|
||||
else if (!((gametic - ll->firsttic) % ll->interval))
|
||||
else if (!(ll->timer % ll->interval))
|
||||
{
|
||||
if (ll->speed < 0)
|
||||
ll->sector->lightlevel = max(ll->sector->lightlevel + (INT16)ll->speed, (INT16)ll->destlevel);
|
||||
|
|
|
@ -1540,9 +1540,9 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type)
|
|||
WRITEUINT32(save_p, SaveSector(ht->sector));
|
||||
WRITEINT32(save_p, ht->destlevel);
|
||||
WRITEINT32(save_p, ht->speed);
|
||||
WRITEINT32(save_p, ht->duration);
|
||||
WRITEUINT8(save_p, (UINT8)ht->ticbased);
|
||||
WRITEINT32(save_p, ht->timer);
|
||||
WRITEUINT32(save_p, ht->interval);
|
||||
WRITEUINT32(save_p, (UINT32)ht->firsttic);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -2547,9 +2547,9 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker)
|
|||
ht->sector = LoadSector(READUINT32(save_p));
|
||||
ht->destlevel = READINT32(save_p);
|
||||
ht->speed = READINT32(save_p);
|
||||
ht->duration = READINT32(save_p);
|
||||
ht->ticbased = (boolean)READUINT8(save_p);
|
||||
ht->timer = READINT32(save_p);
|
||||
ht->interval = READUINT32(save_p);
|
||||
ht->firsttic = (tic_t)READUINT32(save_p);
|
||||
if (ht->sector)
|
||||
ht->sector->lightingdata = ht;
|
||||
P_AddThinker(&ht->thinker);
|
||||
|
|
|
@ -140,9 +140,9 @@ typedef struct
|
|||
INT32 speed; ///< Speed at which to change light level.
|
||||
|
||||
// Tic-based behavior
|
||||
INT32 duration; ///< If <0, do not use tic-based behavior. If 0, set instantly. If >0, fade lasts this duration.
|
||||
boolean ticbased; ///< Tic-based logic
|
||||
INT32 timer; ///< Tic-based timer
|
||||
UINT32 interval; ///< Interval to deduct light level
|
||||
tic_t firsttic; ///< First gametic to count from
|
||||
} lightlevel_t;
|
||||
|
||||
#define GLOWSPEED 8
|
||||
|
|
Loading…
Reference in a new issue