annotate Time.cpp @ 1069:e32e2287d491

minor fixes
author zipi
date Fri, 24 May 2013 19:55:34 +0100
parents f93d17337113
children 9baf16113199
rev   line source
0
Ritor1
parents:
diff changeset
1 #include "OSAPI.h"
Ritor1
parents:
diff changeset
2
Ritor1
parents:
diff changeset
3 #include "Time.h"
Ritor1
parents:
diff changeset
4 #include "Keyboard.h"
816
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
5 #include "Log.h"
0
Ritor1
parents:
diff changeset
6
Ritor1
parents:
diff changeset
7 #include "mm7_data.h"
Ritor1
parents:
diff changeset
8
Ritor1
parents:
diff changeset
9
Ritor1
parents:
diff changeset
10
Ritor1
parents:
diff changeset
11
Ritor1
parents:
diff changeset
12
Ritor1
parents:
diff changeset
13 Timer *pMiscTimer = new Timer;
Ritor1
parents:
diff changeset
14 Timer *pEventTimer;
Ritor1
parents:
diff changeset
15
Ritor1
parents:
diff changeset
16
Ritor1
parents:
diff changeset
17
Ritor1
parents:
diff changeset
18
Ritor1
parents:
diff changeset
19
Ritor1
parents:
diff changeset
20
Ritor1
parents:
diff changeset
21 //----- (00426317) --------------------------------------------------------
Ritor1
parents:
diff changeset
22 unsigned __int64 Timer::Time()
Ritor1
parents:
diff changeset
23 {
1031
f93d17337113 UI stuff.
Nomad
parents: 816
diff changeset
24 uint v2 = TimeQuant * timeGetTime() / 1000;
0
Ritor1
parents:
diff changeset
25 if (v2 < uStartTime)
Ritor1
parents:
diff changeset
26 uStartTime = 0;
Ritor1
parents:
diff changeset
27 return v2;
Ritor1
parents:
diff changeset
28 }
Ritor1
parents:
diff changeset
29
Ritor1
parents:
diff changeset
30
Ritor1
parents:
diff changeset
31
Ritor1
parents:
diff changeset
32 //----- (00426349) --------------------------------------------------------
Ritor1
parents:
diff changeset
33 void Timer::Pause()
Ritor1
parents:
diff changeset
34 {
Ritor1
parents:
diff changeset
35 if (!bPaused)
Ritor1
parents:
diff changeset
36 {
Ritor1
parents:
diff changeset
37 uStopTime = Time();
Ritor1
parents:
diff changeset
38 bPaused = true;
Ritor1
parents:
diff changeset
39 }
Ritor1
parents:
diff changeset
40 }
Ritor1
parents:
diff changeset
41
Ritor1
parents:
diff changeset
42
Ritor1
parents:
diff changeset
43 //----- (00426363) --------------------------------------------------------
Ritor1
parents:
diff changeset
44 void Timer::Resume()
Ritor1
parents:
diff changeset
45 {
Ritor1
parents:
diff changeset
46 if (bPaused)
Ritor1
parents:
diff changeset
47 {
Ritor1
parents:
diff changeset
48 pKeyActionMap->ResetKeys();
Ritor1
parents:
diff changeset
49 bPaused = 0;
Ritor1
parents:
diff changeset
50 uStartTime = Time();
Ritor1
parents:
diff changeset
51 }
Ritor1
parents:
diff changeset
52 }
Ritor1
parents:
diff changeset
53
Ritor1
parents:
diff changeset
54 //----- (00426386) --------------------------------------------------------
Ritor1
parents:
diff changeset
55 void Timer::TrackGameTime()
Ritor1
parents:
diff changeset
56 {
Ritor1
parents:
diff changeset
57 if (!bTackGameTime)
Ritor1
parents:
diff changeset
58 {
Ritor1
parents:
diff changeset
59 uGameTimeStart = Time();
Ritor1
parents:
diff changeset
60 bTackGameTime = true;
Ritor1
parents:
diff changeset
61 }
Ritor1
parents:
diff changeset
62 }
Ritor1
parents:
diff changeset
63
Ritor1
parents:
diff changeset
64
Ritor1
parents:
diff changeset
65
Ritor1
parents:
diff changeset
66 //----- (004263A0) --------------------------------------------------------
Ritor1
parents:
diff changeset
67 void Timer::StopGameTime()
Ritor1
parents:
diff changeset
68 {
Ritor1
parents:
diff changeset
69 if (bTackGameTime)
Ritor1
parents:
diff changeset
70 {
Ritor1
parents:
diff changeset
71 bTackGameTime = 0;
Ritor1
parents:
diff changeset
72 uStartTime = Time();
Ritor1
parents:
diff changeset
73 }
Ritor1
parents:
diff changeset
74 }
Ritor1
parents:
diff changeset
75
Ritor1
parents:
diff changeset
76 //----- (004263B7) --------------------------------------------------------
783
b27dd658ea77 Taveling by foot fixed.
Nomad
parents: 0
diff changeset
77 void Timer::Update()
0
Ritor1
parents:
diff changeset
78 {
816
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
79 //Timer *v1; // esi@1
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
80 //unsigned int v2; // eax@2
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
81 //signed int v3; // eax@3
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
82 //char v4; // zf@5
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
83
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
84
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
85 unsigned __int64 new_time = Time();
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
86 while (new_time <= uStartTime)
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
87 new_time = Time();
0
Ritor1
parents:
diff changeset
88
816
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
89 uTimeElapsed = new_time - uStartTime;
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
90 uStartTime = new_time;
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
91
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
92 if (uTimeElapsed > 32)
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
93 uTimeElapsed = 32;
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
94
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
95 if (!bPaused && !bTackGameTime)
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
96 uTotalGameTimeElapsed += uTimeElapsed;
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
97 dt_in_some_format = (uTimeElapsed << 16) / 128;
0
Ritor1
parents:
diff changeset
98 }
Ritor1
parents:
diff changeset
99
Ritor1
parents:
diff changeset
100 //----- (00426402) --------------------------------------------------------
Ritor1
parents:
diff changeset
101 void Timer::Initialize()
Ritor1
parents:
diff changeset
102 {
Ritor1
parents:
diff changeset
103 uTotalGameTimeElapsed = 0;
Ritor1
parents:
diff changeset
104 bReady = true;
Ritor1
parents:
diff changeset
105 }