fix Killstreak

This commit is contained in:
LightCat 2019-01-12 17:40:16 +01:00
parent 968d635bd8
commit 57698d3c26
3 changed files with 27 additions and 2 deletions

View File

@ -544,8 +544,23 @@ static CatCommand dump_vars("debug_dump_netvars", "Dump netvars of entity", [](c
DumpRecvTable(ent, clz->m_pRecvTable, 0, ft, 0);
});
void Shutdown()
{
if (CE_BAD(LOCAL_E))
return;
// unpatching local player
void **vtable = *(void ***) (g_pLocalPlayer->entity->InternalEntity());
if (vtable[offsets::ShouldDraw()] == C_TFPlayer__ShouldDraw_hook)
{
void *page = (void *) ((uintptr_t) vtable & ~0xFFF);
mprotect(page, 0xFFF, PROT_READ | PROT_WRITE | PROT_EXEC);
vtable[offsets::ShouldDraw()] = (void *) C_TFPlayer__ShouldDraw_original;
mprotect(page, 0xFFF, PROT_READ | PROT_EXEC);
}
}
InitRoutine init([]() {
teammatesPushaway = g_ICvar->FindVar("tf_avoidteammates_pushaway");
EC::Register(EC::Shutdown, Shutdown, "draw_local_player", EC::average);
EC::Register(EC::CreateMove, CreateMove, "cm_misc_hacks", EC::average);
#if ENABLE_VISUALS
EC::Register(EC::Draw, DrawText, "draw_misc_hacks", EC::average);

View File

@ -5,11 +5,16 @@
#include "HookedMethods.hpp"
namespace hacks::tf2::killstreak
{
extern void fire_event(IGameEvent *event);
}
namespace hooked_methods
{
DEFINE_HOOKED_METHOD(FireEvent, bool, IGameEventManager2 *this_, IGameEvent *event, bool no_broadcast)
{
hacks::tf2::killstreak::fire_event(event);
return original::FireEvent(this_, event, no_broadcast);
}
} // namespace hooked_methods
} // namespace hooked_methods

View File

@ -5,11 +5,16 @@
#include "HookedMethods.hpp"
namespace hacks::tf2::killstreak
{
extern void fire_event(IGameEvent *event);
}
namespace hooked_methods
{
DEFINE_HOOKED_METHOD(FireEventClientSide, bool, IGameEventManager2 *this_, IGameEvent *event)
{
hacks::tf2::killstreak::fire_event(event);
return original::FireEventClientSide(this_, event);
}
} // namespace hooked_methods
} // namespace hooked_methods