forked from derandark/PhatAC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobals.cpp
133 lines (104 loc) · 2.08 KB
/
Globals.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "StdAfx.h"
#include "Globals.h"
bool g_bDebugToggle = false;
CGlobals *g_pGlobals = NULL;
CGlobals::CGlobals()
{
m_hWnd = NULL;
m_hConsoleWnd = NULL;
QueryPerformanceFrequency((LARGE_INTEGER *)&m_CounterFreq);
QueryPerformanceCounter((LARGE_INTEGER *)&m_CounterStart);
QueryPerformanceCounter((LARGE_INTEGER *)&m_CounterTime);
int GameDirLen = GetCurrentDirectory(MAX_PATH, m_GameDir);
if (GameDirLen > 0)
{
if (m_GameDir[GameDirLen - 1] == '\\')
{
m_GameDir[GameDirLen - 1] = 0;
}
}
ResetPackets();
Update();
}
CGlobals::~CGlobals()
{
}
const char *CGlobals::GetGameDirectory()
{
return (char *)m_GameDir;
}
std::string CGlobals::GetGameFile(const char *filename)
{
std::string filepath = GetGameDirectory();
filepath += "\\";
filepath += filename;
return filepath;
}
void CGlobals::SetWindowHandle(HWND hWnd)
{
m_hWnd = hWnd;
}
HWND CGlobals::GetWindowHandle()
{
return (HWND)m_hWnd;
}
void CGlobals::SetConsoleWindowHandle(HWND hConsoleWnd)
{
m_hConsoleWnd = hConsoleWnd;
}
HWND CGlobals::GetConsoleWindowHandle()
{
return (HWND)m_hConsoleWnd;
}
void CGlobals::SetClientCount(WORD wCount)
{
m_wClientCount = wCount;
}
WORD CGlobals::GetClientCount()
{
return (WORD)m_wClientCount;
}
void CGlobals::PacketSent(DWORD dwLength)
{
m_cPacketSendCount++;
m_cPacketSendSize += dwLength;
}
void CGlobals::PacketRecv(DWORD dwLength)
{
m_cPacketRecvCount++;
m_cPacketRecvSize += dwLength;
}
UINT64 CGlobals::GetPacketSendCount()
{
return m_cPacketSendCount;
}
UINT64 CGlobals::GetPacketRecvCount()
{
return m_cPacketRecvCount;
}
UINT64 CGlobals::GetPacketSendSize()
{
return m_cPacketSendSize;
}
UINT64 CGlobals::GetPacketRecvSize()
{
return m_cPacketRecvSize;
}
void CGlobals::ResetPackets()
{
m_cPacketSendCount = 0;
m_cPacketRecvCount = 0;
m_cPacketSendSize = 0;
m_cPacketRecvSize = 0;
}
double CGlobals::Time()
{
return m_fTime;
}
double g_TimeAdjustment = 0;
void CGlobals::Update()
{
QueryPerformanceCounter((LARGE_INTEGER *)&m_CounterTime);
m_fTime = (m_CounterTime - m_CounterStart) / (double)m_CounterFreq;
m_fTime += 24000.0 + g_TimeAdjustment;
}