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