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