AzeorthCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
PeriodicTimer Struct Reference

#include "Timer.h"

Public Member Functions

 PeriodicTimer (int32 period, int32 start_time)
 
bool Update (const uint32 diff)
 
void SetPeriodic (int32 period, int32 start_time)
 
void TUpdate (int32 diff)
 
bool TPassed () const
 
void TReset (int32 diff, int32 period)
 

Private Attributes

int32 i_period
 
int32 i_expireTime
 

Detailed Description

Constructor & Destructor Documentation

◆ PeriodicTimer()

PeriodicTimer::PeriodicTimer ( int32  period,
int32  start_time 
)
inline
267 : i_period(period), i_expireTime(start_time)
268 {
269 }
int32 i_period
Definition: Timer.h:294
int32 i_expireTime
Definition: Timer.h:295

Member Function Documentation

◆ SetPeriodic()

void PeriodicTimer::SetPeriodic ( int32  period,
int32  start_time 
)
inline
283 {
284 i_expireTime = start_time;
285 i_period = period;
286 }

References i_expireTime, and i_period.

◆ TPassed()

bool PeriodicTimer::TPassed ( ) const
inline
290{ return i_expireTime <= 0; }

References i_expireTime.

◆ TReset()

void PeriodicTimer::TReset ( int32  diff,
int32  period 
)
inline
291{ i_expireTime += period > diff ? period : diff; }

References i_expireTime.

◆ TUpdate()

void PeriodicTimer::TUpdate ( int32  diff)
inline
289{ i_expireTime -= diff; }

References i_expireTime.

◆ Update()

bool PeriodicTimer::Update ( const uint32  diff)
inline
272 {
273 if ((i_expireTime -= diff) > 0)
274 {
275 return false;
276 }
277
278 i_expireTime += i_period > int32(diff) ? i_period : diff;
279 return true;
280 }
std::int32_t int32
Definition: Define.h:104

References i_expireTime, and i_period.

Member Data Documentation

◆ i_expireTime

int32 PeriodicTimer::i_expireTime
private

◆ i_period

int32 PeriodicTimer::i_period
private

Referenced by SetPeriodic(), and Update().