-
Notifications
You must be signed in to change notification settings - Fork 0
/
EngineClient.h
151 lines (136 loc) · 5.81 KB
/
EngineClient.h
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#pragma once
#include "MiscDefinitions.h"
#include "ClientRecvProps.h"
#include "offsets.h"
#include "Vector.h"
#define FLOW_OUTGOING 0
#define FLOW_INCOMING 1
#define MAX_FLOWS 2
class INetChannelInfo
{
public:
enum {
GENERIC = 0, // must be first and is default group
LOCALPLAYER, // bytes for local player entity update
OTHERPLAYERS, // bytes for other players update
ENTITIES, // all other entity bytes
SOUNDS, // game sounds
EVENTS, // event messages
USERMESSAGES, // user messages
ENTMESSAGES, // entity messages
VOICE, // voice data
STRINGTABLE, // a stringtable update
MOVE, // client move cmds
STRINGCMD, // string command
SIGNON, // various signondata
TOTAL, // must be last and is not a real group
};
virtual const char *GetName(void) const = 0; // get channel name
virtual const char *GetAddress(void) const = 0; // get channel IP address as string
virtual float GetTime(void) const = 0; // current net time
virtual float GetTimeConnected(void) const = 0; // get connection time in seconds
virtual int GetBufferSize(void) const = 0; // netchannel packet history size
virtual int GetDataRate(void) const = 0; // send data rate in byte/sec
virtual bool IsLoopback(void) const = 0; // true if loopback channel
virtual bool IsTimingOut(void) const = 0; // true if timing out
virtual bool IsPlayback(void) const = 0; // true if demo playback
virtual float GetLatency(int flow) const = 0; // current latency (RTT), more accurate but jittering
virtual float GetAvgLatency(int flow) const = 0; // average packet latency in seconds
virtual float GetAvgLoss(int flow) const = 0; // avg packet loss[0..1]
virtual float GetAvgChoke(int flow) const = 0; // avg packet choke[0..1]
virtual float GetAvgData(int flow) const = 0; // data flow in bytes/sec
virtual float GetAvgPackets(int flow) const = 0; // avg packets/sec
virtual int GetTotalData(int flow) const = 0; // total flow in/out in bytes
virtual int GetSequenceNr(int flow) const = 0; // last send seq number
virtual bool IsValidPacket(int flow, int frame_number) const = 0; // true if packet was not lost/dropped/chocked/flushed
virtual float GetPacketTime(int flow, int frame_number) const = 0; // time when packet was send
virtual int GetPacketBytes(int flow, int frame_number, int group) const = 0; // group size of this packet
virtual bool GetStreamProgress(int flow, int *received, int *total) const = 0; // TCP progress if transmitting
virtual float GetTimeSinceLastReceived(void) const = 0; // get time since last recieved packet in seconds
virtual float GetCommandInterpolationAmount(int flow, int frame_number) const = 0;
virtual void GetPacketResponseLatency(int flow, int frame_number, int *pnLatencyMsecs, int *pnChoke) const = 0;
virtual void GetRemoteFramerate(float *pflFrameTime, float *pflFrameTimeStdDeviation) const = 0;
virtual float GetTimeoutSeconds() const = 0;
};
class IVEngineClient
{
public:
int GetPlayerForUserID(int UserID) {
using Original = int(__thiscall*)(PVOID, int);
return call_vfunc<Original>(this, 9)(this, UserID);
}
void ClientCmd(const char *szCmdString)
{
typedef void(__thiscall* oClientCmd)(PVOID, const char*);
return call_vfunc<oClientCmd>(this, 7)(this, szCmdString);
}
void GetScreenSize(int& width, int& height)
{
typedef void(__thiscall* oGetScreenSize)(PVOID, int&, int&);
return call_vfunc< oGetScreenSize >(this, Offsets::VMT::Engine_GetScreenSize)(this, width, height);
}
bool IsTakingScreenshot(void)
{
typedef bool(__thiscall* OriginalFn)(PVOID);
return call_vfunc<OriginalFn>(this, 85)(this);
}
bool GetPlayerInfo(int ent_num, player_info_t *pinfo)
{
typedef bool(__thiscall* oGetPlayerInfo)(PVOID, int, player_info_t*);
return call_vfunc< oGetPlayerInfo >(this, Offsets::VMT::Engine_GetPlayerInfo)(this, ent_num, pinfo);
}
int GetLocalPlayer()
{
typedef int(__thiscall* oLocal)(PVOID);
return call_vfunc< oLocal >(this, Offsets::VMT::Engine_GetLocalPlayer)(this);
}
void ExecuteClientCmd(const char* szCmdString) {
typedef void(__thiscall *OrigFn)(void*, const char *);
call_vfunc<OrigFn>(this, 108)(this, szCmdString);
}
float Time()
{
typedef float(__thiscall* oTime)(PVOID);
return call_vfunc< oTime >(this, Offsets::VMT::Engine_Time)(this);
}
void GetViewAngles(Vector& vAngles)
{
typedef void(__thiscall* oSetViewAngles)(PVOID, Vector&);
return call_vfunc< oSetViewAngles >(this, Offsets::VMT::Engine_GetViewAngles)(this, vAngles);
}
void SetViewAngles(Vector& vAngles)
{
typedef void(__thiscall* oSetViewAngles)(PVOID, Vector&);
return call_vfunc< oSetViewAngles >(this, Offsets::VMT::Engine_SetViewAngles)(this, vAngles);
}
int GetMaxClients()
{
typedef bool(__thiscall* oGetMaxClients)(PVOID);
return call_vfunc< oGetMaxClients >(this, Offsets::VMT::Engine_GetMaxClients)(this);
}
bool IsConnected()
{
typedef bool(__thiscall* oGetScreenSize)(PVOID);
return call_vfunc< oGetScreenSize >(this, Offsets::VMT::Engine_IsConnected)(this);
}
bool IsInGame()
{
typedef bool(__thiscall* oLocal)(PVOID);
return call_vfunc< oLocal >(this, Offsets::VMT::Engine_IsInGame)(this);
}
const matrix3x4& WorldToScreenMatrix()
{
typedef const matrix3x4& (__thiscall* oWorldToScreenMatrix)(PVOID);
return call_vfunc< oWorldToScreenMatrix >(this, Offsets::VMT::Engine_WorldToScreenMatrix)(this);
}
void ClientCmd_Unrestricted(char const* cmd)
{
typedef void(__thiscall* oClientCmdUnres)(PVOID, const char*);
return call_vfunc<oClientCmdUnres>(this, Offsets::VMT::Engine_ClientCmd_Unrestricted)(this, cmd);
}
INetChannelInfo* GetNetChannelInfo()
{
typedef INetChannelInfo*(__thiscall* OriginalFn)(PVOID);
return call_vfunc< OriginalFn >(this, 78)(this);
}
};