forked from mangosR2/scriptdev2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsc_timer.cpp
More file actions
34 lines (29 loc) · 747 Bytes
/
sc_timer.cpp
File metadata and controls
34 lines (29 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Copyright (C) 2013 by boxa for ScriptDev2_R2 <http://github.com/mangosR2/scriptdev2/>
* This program is free software licensed under GPL version 2
* Please see the included DOCS/LICENSE.TXT for more information */
#include "precompiled.h"
bool TTimer::Expired(uint32 const tickDiff)
{
m_counter += tickDiff;
if (m_counter >= m_period)
{
if (m_autoReset)
m_counter = 0;
return true;
}
return false;
}
void TTimer::Reset(uint32 const period)
{
m_period = period;
m_counter = 0;
}
void TTimer::Reset(uint32 const periodMin, uint32 const periodMax)
{
Reset(urand(periodMin, periodMax));
}
void TTimer::ResetAuto(uint32 const period)
{
Reset(period);
m_autoReset = true;
}