annotate Time.cpp @ 1329:27a699abee51

Слияние
author Ritor1
date Tue, 02 Jul 2013 14:08:40 +0600
parents 0aeac0b9ca30
children
rev   line source
0
Ritor1
parents:
diff changeset
1
Ritor1
parents:
diff changeset
2 #include "Time.h"
Ritor1
parents:
diff changeset
3 #include "Keyboard.h"
816
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
4 #include "Log.h"
0
Ritor1
parents:
diff changeset
5
1262
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1194
diff changeset
6 #include "OSAPI.h"
0
Ritor1
parents:
diff changeset
7
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 Timer *pMiscTimer = new Timer;
Ritor1
parents:
diff changeset
13 Timer *pEventTimer;
Ritor1
parents:
diff changeset
14
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 //----- (00426317) --------------------------------------------------------
Ritor1
parents:
diff changeset
21 unsigned __int64 Timer::Time()
Ritor1
parents:
diff changeset
22 {
1194
9baf16113199 arcomage ui partialy drawn
Gloval
parents: 1031
diff changeset
23 unsigned __int64 v2 = TimeQuant * timeGetTime() / 1000;
0
Ritor1
parents:
diff changeset
24 if (v2 < uStartTime)
Ritor1
parents:
diff changeset
25 uStartTime = 0;
Ritor1
parents:
diff changeset
26 return v2;
Ritor1
parents:
diff changeset
27 }
Ritor1
parents:
diff changeset
28
Ritor1
parents:
diff changeset
29
Ritor1
parents:
diff changeset
30
Ritor1
parents:
diff changeset
31 //----- (00426349) --------------------------------------------------------
Ritor1
parents:
diff changeset
32 void Timer::Pause()
Ritor1
parents:
diff changeset
33 {
Ritor1
parents:
diff changeset
34 if (!bPaused)
Ritor1
parents:
diff changeset
35 {
Ritor1
parents:
diff changeset
36 uStopTime = Time();
Ritor1
parents:
diff changeset
37 bPaused = true;
Ritor1
parents:
diff changeset
38 }
Ritor1
parents:
diff changeset
39 }
Ritor1
parents:
diff changeset
40
Ritor1
parents:
diff changeset
41
Ritor1
parents:
diff changeset
42 //----- (00426363) --------------------------------------------------------
Ritor1
parents:
diff changeset
43 void Timer::Resume()
Ritor1
parents:
diff changeset
44 {
Ritor1
parents:
diff changeset
45 if (bPaused)
Ritor1
parents:
diff changeset
46 {
Ritor1
parents:
diff changeset
47 pKeyActionMap->ResetKeys();
Ritor1
parents:
diff changeset
48 bPaused = 0;
Ritor1
parents:
diff changeset
49 uStartTime = Time();
Ritor1
parents:
diff changeset
50 }
Ritor1
parents:
diff changeset
51 }
Ritor1
parents:
diff changeset
52
Ritor1
parents:
diff changeset
53 //----- (00426386) --------------------------------------------------------
Ritor1
parents:
diff changeset
54 void Timer::TrackGameTime()
Ritor1
parents:
diff changeset
55 {
Ritor1
parents:
diff changeset
56 if (!bTackGameTime)
Ritor1
parents:
diff changeset
57 {
Ritor1
parents:
diff changeset
58 uGameTimeStart = Time();
Ritor1
parents:
diff changeset
59 bTackGameTime = true;
Ritor1
parents:
diff changeset
60 }
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 //----- (004263A0) --------------------------------------------------------
Ritor1
parents:
diff changeset
66 void Timer::StopGameTime()
Ritor1
parents:
diff changeset
67 {
Ritor1
parents:
diff changeset
68 if (bTackGameTime)
Ritor1
parents:
diff changeset
69 {
Ritor1
parents:
diff changeset
70 bTackGameTime = 0;
Ritor1
parents:
diff changeset
71 uStartTime = Time();
Ritor1
parents:
diff changeset
72 }
Ritor1
parents:
diff changeset
73 }
Ritor1
parents:
diff changeset
74
Ritor1
parents:
diff changeset
75 //----- (004263B7) --------------------------------------------------------
783
b27dd658ea77 Taveling by foot fixed.
Nomad
parents: 0
diff changeset
76 void Timer::Update()
0
Ritor1
parents:
diff changeset
77 {
816
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
78 //Timer *v1; // esi@1
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
79 //unsigned int v2; // eax@2
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
80 //signed int v3; // eax@3
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
81 //char v4; // zf@5
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
82
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
83
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
84 unsigned __int64 new_time = Time();
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
85 while (new_time <= uStartTime)
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
86 new_time = Time();
0
Ritor1
parents:
diff changeset
87
816
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
88 uTimeElapsed = new_time - uStartTime;
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
89 uStartTime = new_time;
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
90
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
91 if (uTimeElapsed > 32)
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
92 uTimeElapsed = 32;
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
93
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
94 if (!bPaused && !bTackGameTime)
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
95 uTotalGameTimeElapsed += uTimeElapsed;
cfc65feef029 * Player Recovery Times
Nomad
parents: 783
diff changeset
96 dt_in_some_format = (uTimeElapsed << 16) / 128;
0
Ritor1
parents:
diff changeset
97 }
Ritor1
parents:
diff changeset
98
Ritor1
parents:
diff changeset
99 //----- (00426402) --------------------------------------------------------
Ritor1
parents:
diff changeset
100 void Timer::Initialize()
Ritor1
parents:
diff changeset
101 {
Ritor1
parents:
diff changeset
102 uTotalGameTimeElapsed = 0;
Ritor1
parents:
diff changeset
103 bReady = true;
Ritor1
parents:
diff changeset
104 }