EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
timer.h
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Zhur
24  Updates: Allan
25 */
26 
27 #ifndef TIMER_H
28 #define TIMER_H
29 
30 class Timer
31 {
32 public:
33  Timer(uint32 time=0, bool useAcurateTiming = false);
34  Timer(uint32 startAt, uint32 time, bool useAcurateTiming = false);
35 
36  ~Timer() { /* do nothing here */ }
37 
38  inline void Enable() { m_enabled = true; }
39  inline void Disable() { m_enabled = false; }
40  inline const uint32& GetSetAtTrigger() { return m_setAtTrigger; }
41  inline bool Enabled() const { return m_enabled; }
42  inline uint32 GetStartTime() const { return m_startTime; }
43  inline uint32 GetDuration() const { return m_duration; }
44 
45  void Trigger();
46  void SetTimer(uint32 setTimerTime = 0);
47  void Start(uint32 setTimerTime = 0, bool changeResetTimer = true);
48  void SetAtTrigger(uint32 setAtTrigger, bool enableIfDisabled = false);
49 
50  bool TimerFinished();
51  bool Check(bool reset = true);
52 
53  static const void SetCurrentTime();
54  // return remaining time in ms
55  uint32 GetRemainingTime() const;
57 
58 
59 private:
60  bool m_enabled;
61  /* useAcurateTiming resets timer (on check()) to start_time += timer_time to eliminate discrepencies in calling time */
63 
67 
68 };
69 
70 #endif
void Trigger()
Definition: timer.cpp:128
uint32 m_setAtTrigger
Definition: timer.h:66
void Disable()
Definition: timer.h:39
static const void SetCurrentTime()
Definition: timer.cpp:138
void SetTimer(uint32 setTimerTime=0)
Definition: timer.cpp:102
~Timer()
Definition: timer.h:36
bool m_useAcurateTiming
Definition: timer.h:62
uint32 GetRemainingTime() const
Definition: timer.cpp:114
uint32 GetDuration() const
Definition: timer.h:43
bool Enabled() const
Definition: timer.h:41
bool m_enabled
Definition: timer.h:60
uint32 m_startTime
Definition: timer.h:65
uint32 GetCurrentTime()
Definition: timer.cpp:134
bool Check(bool reset=true)
Definition: timer.cpp:62
uint32 m_duration
Definition: timer.h:64
void Enable()
Definition: timer.h:38
unsigned __int32 uint32
Definition: eve-compat.h:50
Timer(uint32 time=0, bool useAcurateTiming=false)
Definition: timer.cpp:37
bool TimerFinished()
void SetAtTrigger(uint32 setAtTrigger, bool enableIfDisabled=false)
Definition: timer.cpp:122
Definition: timer.h:30
uint32 GetStartTime() const
Definition: timer.h:42
const uint32 & GetSetAtTrigger()
Definition: timer.h:40
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)
Definition: timer.cpp:81