Mercurial > mm7
annotate Timer.cpp @ 2439:daf7807d0a86
Merge
author | a.parshin |
---|---|
date | Thu, 24 Jul 2014 00:32:18 +0300 |
parents | d922225a6081 |
children | 1e1b2728b3d3 |
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 { | |
2425 | 52 pKeyActionMap->ResetKeys();//Unhandled application exception |
53 | |
2044 | 54 bPaused = 0; |
55 uStartTime = Time(); | |
56 } | |
57 } | |
58 | |
59 //----- (00426386) -------------------------------------------------------- | |
60 void Timer::TrackGameTime() | |
61 { | |
62 if (!bTackGameTime) | |
63 { | |
64 uGameTimeStart = Time(); | |
65 bTackGameTime = true; | |
66 } | |
67 } | |
68 | |
69 | |
70 | |
71 //----- (004263A0) -------------------------------------------------------- | |
72 void Timer::StopGameTime() | |
73 { | |
74 if (bTackGameTime) | |
75 { | |
76 bTackGameTime = 0; | |
77 uStartTime = Time(); | |
78 } | |
79 } | |
80 | |
81 //----- (004263B7) -------------------------------------------------------- | |
82 void Timer::Update() | |
83 { | |
84 //Timer *v1; // esi@1 | |
85 //unsigned int v2; // eax@2 | |
86 //signed int v3; // eax@3 | |
87 //char v4; // zf@5 | |
88 | |
89 | |
90 unsigned __int64 new_time = Time(); | |
91 while (new_time <= uStartTime) | |
92 new_time = Time(); | |
93 | |
94 uTimeElapsed = new_time - uStartTime; | |
95 uStartTime = new_time; | |
96 | |
97 if (uTimeElapsed > 32) | |
98 uTimeElapsed = 32; | |
99 | |
100 if (!bPaused && !bTackGameTime) | |
101 uTotalGameTimeElapsed += uTimeElapsed; | |
102 dt_in_some_format = (uTimeElapsed << 16) / 128; | |
103 } | |
104 | |
105 //----- (00426402) -------------------------------------------------------- | |
106 void Timer::Initialize() | |
107 { | |
108 uTotalGameTimeElapsed = 0; | |
109 bReady = true; | |
110 } |