Mercurial > mm7
annotate Timer.cpp @ 2315:58be29479e75
add files
author | Ritor1 |
---|---|
date | Wed, 19 Mar 2014 10:09:42 +0600 |
parents | aff7a7b072b7 |
children | f4af3b203f65 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2044
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
2044 | 2 |
3 #include "Timer.h" | |
4 #include "Keyboard.h" | |
5 #include "Log.h" | |
6 | |
7 #include "OSAPI.h" | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 Timer *pMiscTimer = new Timer; | |
14 Timer *pEventTimer; | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 //----- (00426317) -------------------------------------------------------- | |
22 unsigned __int64 Timer::Time() | |
23 { | |
24 unsigned __int64 v2 = TimeQuant * timeGetTime() / 1000; | |
25 if (v2 < uStartTime) | |
26 uStartTime = 0; | |
27 return v2; | |
28 } | |
29 | |
30 | |
31 | |
32 //----- (00426349) -------------------------------------------------------- | |
33 void Timer::Pause() | |
34 { | |
35 if (!bPaused) | |
36 { | |
37 uStopTime = Time(); | |
38 bPaused = true; | |
39 } | |
40 } | |
41 | |
42 | |
43 //----- (00426363) -------------------------------------------------------- | |
44 void Timer::Resume() | |
45 { | |
46 if (bPaused) | |
47 { | |
48 pKeyActionMap->ResetKeys(); | |
49 bPaused = 0; | |
50 uStartTime = Time(); | |
51 } | |
52 } | |
53 | |
54 //----- (00426386) -------------------------------------------------------- | |
55 void Timer::TrackGameTime() | |
56 { | |
57 if (!bTackGameTime) | |
58 { | |
59 uGameTimeStart = Time(); | |
60 bTackGameTime = true; | |
61 } | |
62 } | |
63 | |
64 | |
65 | |
66 //----- (004263A0) -------------------------------------------------------- | |
67 void Timer::StopGameTime() | |
68 { | |
69 if (bTackGameTime) | |
70 { | |
71 bTackGameTime = 0; | |
72 uStartTime = Time(); | |
73 } | |
74 } | |
75 | |
76 //----- (004263B7) -------------------------------------------------------- | |
77 void Timer::Update() | |
78 { | |
79 //Timer *v1; // esi@1 | |
80 //unsigned int v2; // eax@2 | |
81 //signed int v3; // eax@3 | |
82 //char v4; // zf@5 | |
83 | |
84 | |
85 unsigned __int64 new_time = Time(); | |
86 while (new_time <= uStartTime) | |
87 new_time = Time(); | |
88 | |
89 uTimeElapsed = new_time - uStartTime; | |
90 uStartTime = new_time; | |
91 | |
92 if (uTimeElapsed > 32) | |
93 uTimeElapsed = 32; | |
94 | |
95 if (!bPaused && !bTackGameTime) | |
96 uTotalGameTimeElapsed += uTimeElapsed; | |
97 dt_in_some_format = (uTimeElapsed << 16) / 128; | |
98 } | |
99 | |
100 //----- (00426402) -------------------------------------------------------- | |
101 void Timer::Initialize() | |
102 { | |
103 uTotalGameTimeElapsed = 0; | |
104 bReady = true; | |
105 } |