Skip to content

Commit d06ef9d

Browse files
committed
rem: Removed functions moved to respective modules and utils
1 parent 9424f37 commit d06ef9d

File tree

4 files changed

+3
-197
lines changed

4 files changed

+3
-197
lines changed

src/commands.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "utils/loggingsystem.hpp"
1212
#include "utils/memory.hpp"
13+
#include "utils/scanner.hpp"
1314

1415
//---------------------------------------------------------------------------------
1516
// Debug P2:SM++ ConVars | Self-explanatory.

src/commands.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ extern ConVar p2sm_developer;
1818
//---------------------------------------------------------------------------------
1919
// UTIL P2:SM++ ConVars | ConVars the host can change.
2020
//---------------------------------------------------------------------------------
21-
extern ConVar p2sm_instantrespawn;
21+
extern ConVar p2sm_multiplayer_instantrespawn;
2222

2323
#endif

src/sdk.cpp

Lines changed: 0 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -71,161 +71,5 @@ void (__fastcall* CUGCFileRequestManager__Update_orig)(CUGCFileRequestManager* t
7171
void __fastcall CUGCFileRequestManager__Update_hook(CUGCFileRequestManager* thisPtr) { }
7272

7373
}
74-
75-
/// Interfaced UTIL Functions \\\
76-
77-
//---------------------------------------------------------------------------------
78-
// Purpose: Get the player's base class with its entity index. Thanks to Nanoman2525 for this.
79-
//---------------------------------------------------------------------------------
80-
CBasePlayer* UTIL_PlayerByIndex(const int playerIndex)
81-
{
82-
#ifdef _WIN32
83-
static auto PlayerByIndex_ = reinterpret_cast<CBasePlayer* (__cdecl*)(int)>(Memory::Scan<void*>(SERVER, "55 8B EC 8B 4D 08 33 C0 85 C9 7E 30"));
84-
return PlayerByIndex_(playerIndex);
85-
#else // Linux support TODO
86-
return nullptr;
87-
#endif
88-
}
89-
90-
//---------------------------------------------------------------------------------
91-
// Purpose: Show on screen message to players. msg_dest are definSed macros in globals.hpp.
92-
//---------------------------------------------------------------------------------
93-
void UTIL_ClientPrint(CBasePlayer* player, const int msg_dest, const char* msg_name, const char* param1, const char* param2, const char* param3, const char* param4)
94-
{
95-
static auto ClientPrint_ = reinterpret_cast<void (__cdecl*)(CBasePlayer*, int, const char*, const char*, const char*, const char*, const char*)>(Memory::Scan<void*>(SERVER, "55 8B EC 83 EC 20 56 8B 75 08 85 F6 74 4C"));
96-
ClientPrint_(player, msg_dest, msg_name, param1, param2, param3, param4);
97-
}
98-
99-
//---------------------------------------------------------------------------------
100-
// Purpose: Show on text on screen just like game_text does.
101-
//---------------------------------------------------------------------------------
102-
void UTIL_HudMessage(CBasePlayer* pPlayer, const HudMessageParams& textparms, const char* pMessage)
103-
{
104-
static auto HudMessage_ = reinterpret_cast<void (__cdecl*)(CBasePlayer*, const HudMessageParams&, const char*)>(Memory::Scan(SERVER, "55 8B EC 83 EC 20 8D 4D ? E8 ? ? ? ? 8B 45 ? 8D 4D ? 85 C0 74 ? 50 E8 ? ? ? ? EB ? E8 ? ? ? ? 56"));
105-
HudMessage_(pPlayer, textparms, pMessage);
106-
}
107-
108-
//---------------------------------------------------------------------------------
109-
// Purpose: Get the CBasePlayer of the player who executed the ConVar or ConCommand.
110-
//---------------------------------------------------------------------------------
111-
CBasePlayer* UTIL_GetCommandClient()
11274
{
113-
static auto GetCommandClient_ = reinterpret_cast<CBasePlayer* (__cdecl*)()>(Memory::Scan(SERVER, "A1 ? ? ? ? 40 85 C0"));
114-
return GetCommandClient_();
115-
}
116-
117-
//---------------------------------------------------------------------------------
118-
// Purpose: Get the client index of the player who executed the ConVar or ConCommand. This is not the player's entity index which is 1 more.
119-
//---------------------------------------------------------------------------------
120-
int UTIL_GetCommandClientIndex()
121-
{
122-
static auto GetCommandClientIndex_ = reinterpret_cast<int (__cdecl*)()>(Memory::Scan(SERVER, "A1 ? ? ? ? 40 C3"));
123-
return GetCommandClientIndex_();
124-
}
125-
126-
/// CBaseEntity Class Functions \\\
127-
128-
//---------------------------------------------------------------------------------
129-
// Purpose: Self-explanatory. Thanks to Nanoman2525 for this.
130-
//---------------------------------------------------------------------------------
131-
void CBaseEntity__RemoveEntity(CBaseEntity* pEntity)
132-
{
133-
static auto RemoveEntity_ = reinterpret_cast<void (__cdecl*)(void*)>(Memory::Scan<void*>(SERVER, "55 8B EC 57 8B 7D 08 85 FF 74 72"));
134-
RemoveEntity_((reinterpret_cast<IServerEntity*>(pEntity)->GetNetworkable()));
135-
}
136-
137-
//---------------------------------------------------------------------------------
138-
// Purpose: Get team number for the supplied CBasePlayer.
139-
//---------------------------------------------------------------------------------
140-
int CBaseEntity__GetTeamNumber(CBasePlayer* pPlayer)
141-
{
142-
static auto GetTeamNumber_ = reinterpret_cast<int(__thiscall*)(CBaseEntity*)>(Memory::Scan<void*>(SERVER, "8B 81 F4 02 00 00 C3"));
143-
return GetTeamNumber_(reinterpret_cast<CBaseEntity*>(pPlayer));
144-
}
145-
146-
//---------------------------------------------------------------------------------
147-
// Purpose: Get the script scope of a entity. Thanks to Nullderef/Vista for this.
148-
//---------------------------------------------------------------------------------
149-
HSCRIPT CBaseEntity__GetScriptScope(CBaseEntity* entity)
150-
{
151-
if (!entity)
152-
return nullptr;
153-
154-
return *reinterpret_cast<HSCRIPT*>(reinterpret_cast<uintptr_t>(entity) + 0x33c);
155-
}
156-
157-
//---------------------------------------------------------------------------------
158-
// Purpose: Get the script instance of a entity. Thanks to Nullderef/Vista for this.
159-
//---------------------------------------------------------------------------------
160-
HSCRIPT CBaseEntity__GetScriptInstance(CBaseEntity* entity)
161-
{
162-
static auto GetScriptInstance_ = reinterpret_cast<HSCRIPT(__thiscall*)(CBaseEntity*)>(Memory::Scan<void*>(SERVER, "55 8B EC 51 56 8B F1 83 BE 50"));
163-
if (!GetScriptInstance_)
164-
{
165-
Log(WARNING, false, "Could not get script instance for entity!");
166-
return nullptr;
167-
}
168-
169-
return GetScriptInstance_(entity);
170-
}
171-
172-
// TODO: Implement EmitSound
173-
// int CBaseEntity__EmitSound(CBaseEntity* entity, IRecipientFilter* filter, int iEntIndex, const char* soundName, const Vector* pOrigin, float soundTime)
174-
// {
175-
// static auto
176-
// //55 8B EC 83 EC 4C 8B 0D
177-
// }
178-
179-
/// CBasePlayer Class Functions \\\
180-
181-
void CBasePlayer__ShowViewPortPanel(const int playerIndex, const char* name, const bool bShow, KeyValues* data)
182-
{
183-
CBasePlayer* pPlayer = UTIL_PlayerByIndex(playerIndex);
184-
if (!pPlayer)
185-
{
186-
Log(WARNING, false, "Couldn't get player to display view port panel to! playerIndex: %i", playerIndex);
187-
return;
188-
}
189-
static auto ShowViewPortPanel_ = reinterpret_cast<void(__thiscall*)(CBasePlayer*, const char*, bool, KeyValues*)>(Memory::Scan<void*>(SERVER, "55 8B EC 83 EC 20 53 56 8B F1 57 8D 4D ? E8 ? ? ? ? 56"));
190-
ShowViewPortPanel_(pPlayer, name, bShow, data);
191-
}
192-
193-
194-
/// CPortal_Player Class Functions \\\
195-
196-
//---------------------------------------------------------------------------------
197-
// Purpose: Respawn the a player by their entity index.
198-
//---------------------------------------------------------------------------------
199-
void CPortal_Player__RespawnPlayer(const int playerIndex)
200-
{
201-
CBasePlayer* pPlayer = UTIL_PlayerByIndex(playerIndex);
202-
if (!pPlayer)
203-
{
204-
Log(WARNING, false, "Couldn't get player to respawn! playerIndex: %i", playerIndex);
205-
return;
206-
}
207-
208-
static auto RespawnPlayer_ = reinterpret_cast<void(__thiscall*)(CPortal_Player*)>(Memory::Scan<void*>(SERVER, "0F 57 C0 56 8B F1 57 8D 8E"));
209-
RespawnPlayer_(reinterpret_cast<CPortal_Player*>(pPlayer));
210-
}
211-
212-
//---------------------------------------------------------------------------------
213-
// Purpose: Set the flashlight for a player on or off. Thanks to Nanoman2525 for this.
214-
// Not a function in the CPortal_Player class, just more grouping it with the
215-
// class. This does the same thing as the FlashlightTurnOn and FlashlightTurnOff
216-
// functions in CPortal_Player but done in one function.
217-
//---------------------------------------------------------------------------------
218-
void CPortal_Player__SetFlashlightState(const int playerIndex, const bool enable)
219-
{
220-
CBasePlayer* pPlayer = UTIL_PlayerByIndex(playerIndex);
221-
if (!pPlayer)
222-
{
223-
Log(WARNING, true, "Couldn't get player to set flashlight state! playerIndex: %i enable: %i", playerIndex, !!enable);
224-
return;
225-
}
226-
227-
if (enable)
228-
reinterpret_cast<void(__thiscall*)(CBaseEntity*, int)>(Memory::Scan<void*>(SERVER, "55 8B EC 53 8B D9 8B 83 A8"))(reinterpret_cast<CBaseEntity*>(pPlayer), EF_DIMLIGHT);
229-
else
230-
reinterpret_cast<void(__thiscall*)(CBaseEntity*, int)>(Memory::Scan<void*>(SERVER, "55 8B EC 53 56 8B 75 08 8B D9 8B 83"))(reinterpret_cast<CBaseEntity*>(pPlayer), EF_DIMLIGHT);
23175
}

src/sdk.hpp

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,6 @@
77

88
#pragma once
99

10-
#include "globals.hpp"
11-
12-
// UTIL_HudMessage message parameters struct. Based on the one from util.h.
13-
// See Valve Developer Community for game_text to see which field does what:
14-
// https://developer.valvesoftware.com/wiki/Game_text
15-
typedef struct
16-
{
17-
float x, y;
18-
int effect;
19-
byte r1, g1, b1, a1;
20-
byte r2, g2, b2, a2;
21-
float fadeinTime, fadeoutTime, holdTime;
22-
float fxTime;
23-
int channel;
24-
} HudMessageParams;
25-
2610
//---------------------------------------------------------------------------------
2711
// Hooked game functions.
2812
//---------------------------------------------------------------------------------
@@ -40,27 +24,4 @@ void __fastcall CPortal_Player__FlashlightTurnOff_hook(CPortal_Player* thisPtr,
4024
// Workshop download stopping hooks.
4125
class CUGCFileRequestManager;
4226
extern void (__fastcall* CUGCFileRequestManager__Update_orig)(CUGCFileRequestManager* thisptr);
43-
void __fastcall CUGCFileRequestManager__Update_hook(CUGCFileRequestManager* thisPtr);
44-
45-
//---------------------------------------------------------------------------------
46-
// Interfaced game functions.
47-
//---------------------------------------------------------------------------------
48-
// UTIL functions
49-
CBasePlayer* UTIL_PlayerByIndex(int playerIndex);
50-
void UTIL_ClientPrint(CBasePlayer* player, int msg_dest, const char* msg_name, const char* param1 = nullptr, const char* param2 = nullptr, const char* param3 = nullptr, const char* param4 = nullptr);
51-
void UTIL_HudMessage(CBasePlayer* pPlayer, const HudMessageParams& textparms, const char* pMessage);
52-
CBasePlayer* UTIL_GetCommandClient();
53-
int UTIL_GetCommandClientIndex();
54-
55-
// CBaseEntity functions
56-
void CBaseEntity__RemoveEntity(CBaseEntity* pEntity);
57-
int CBaseEntity__GetTeamNumber(CBasePlayer* pPlayer);
58-
HSCRIPT CBaseEntity__GetScriptScope(CBaseEntity* entity);
59-
HSCRIPT CBaseEntity__GetScriptInstance(CBaseEntity* entity);
60-
61-
// CBasePlayer functions
62-
void CBasePlayer__ShowViewPortPanel(int playerIndex, const char* name, bool bShow = true, KeyValues* data = nullptr);
63-
64-
// CPortal_Player functions
65-
void CPortal_Player__RespawnPlayer(int playerIndex);
66-
void CPortal_Player__SetFlashlightState(int playerIndex, bool enable);
27+
void __fastcall CUGCFileRequestManager__Update_hook(CUGCFileRequestManager* thisPtr);

0 commit comments

Comments
 (0)