Skip to content

Commit

Permalink
refactor: don't need hook
Browse files Browse the repository at this point in the history
tanger gonna be mad
  • Loading branch information
ThisAMJ committed Mar 7, 2024
1 parent fbc23ad commit 5f56d3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 4 additions & 13 deletions src/Modules/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ REDECL(Client::OverrideView);
REDECL(Client::ProcessMovement);
REDECL(Client::DrawTranslucentRenderables);
REDECL(Client::DrawOpaqueRenderables);
REDECL(Client::MsgPreSkipToNextLevel);
REDECL(Client::CalcViewModelLag);
REDECL(Client::AddShadowToReceiver);

Expand Down Expand Up @@ -529,13 +528,7 @@ DETOUR_T(void, Client::AddShadowToReceiver, unsigned short handle, void *pRender
}
Hook g_AddShadowToReceiverHook(&Client::AddShadowToReceiver_Hook);

extern Hook g_MsgPreSkipToNextLevelHook;
DETOUR_T(void, Client::MsgPreSkipToNextLevel) {
g_MsgPreSkipToNextLevelHook.Disable();
Client::MsgPreSkipToNextLevel(thisptr);
g_MsgPreSkipToNextLevelHook.Enable();
}
Hook (g_MsgPreSkipToNextLevelHook)(&Client::MsgPreSkipToNextLevel_Hook);
static void (*MsgPreSkipToNextLevel)();

CON_COMMAND(sar_workshop_skip, "sar_workshop_skip - Skips to the next level in workshop\n") {
if (!sv_cheats.GetBool()) {
Expand All @@ -547,7 +540,7 @@ CON_COMMAND(sar_workshop_skip, "sar_workshop_skip - Skips to the next level in w
// open the console so that it works on binds lmao (the menu has to be visible probably)
// debug with -vguimessages launch option
engine->ExecuteCommand("showconsole");
Client::MsgPreSkipToNextLevel(nullptr);
MsgPreSkipToNextLevel();
}

bool Client::Init() {
Expand Down Expand Up @@ -668,13 +661,11 @@ bool Client::Init() {
g_DrawOpaqueRenderablesHook.SetFunc(Client::DrawOpaqueRenderables);

#ifdef _WIN32
Client::MsgPreSkipToNextLevel = (decltype(Client::MsgPreSkipToNextLevel))Memory::Scan(client->Name(), "57 8B F9 E8 ? ? ? ? 8B C8 E8 ? ? ? ? 0B C2");
MsgPreSkipToNextLevel = (decltype(MsgPreSkipToNextLevel))Memory::Scan(client->Name(), "57 8B F9 E8 ? ? ? ? 8B C8 E8 ? ? ? ? 0B C2");
#else
Client::MsgPreSkipToNextLevel = (decltype(Client::MsgPreSkipToNextLevel))Memory::Scan(client->Name(), "53 83 EC 08 E8 ? ? ? ? 83 EC 0C 50 E8 ? ? ? ? 83 C4 10 09 C2");
MsgPreSkipToNextLevel = (decltype(MsgPreSkipToNextLevel))Memory::Scan(client->Name(), "53 83 EC 08 E8 ? ? ? ? 83 EC 0C 50 E8 ? ? ? ? 83 C4 10 09 C2");
#endif

g_MsgPreSkipToNextLevelHook.SetFunc(Client::MsgPreSkipToNextLevel);

if (sar.game->Is(SourceGame_Portal2)) {
#ifdef _WIN32
Client::CalcViewModelLag = (decltype(Client::CalcViewModelLag))Memory::Scan(client->Name(), "53 8B DC 83 EC 08 83 E4 F0 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 83 EC 1C 56 6A 00 6A 00 8D 45 F4 8B F1 8B 4B 0C 50 51 E8 ? ? ? ?");
Expand Down
2 changes: 0 additions & 2 deletions src/Modules/Client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ class Client : public Module {
// CRendering3dView::DrawTranslucentRenderables
DECL_DETOUR(DrawTranslucentRenderables, bool inSkybox, bool shadowDepth);

DECL_DETOUR_T(void, MsgPreSkipToNextLevel);

// CHLClient::LevelInitPreEntity
DECL_DETOUR(LevelInitPreEntity, const char *levelName);

Expand Down

0 comments on commit 5f56d3c

Please sign in to comment.