From 8fb2d03e8eeb5539752abe0aa14e6b60c6a22f00 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Wed, 3 May 2017 22:26:06 +0300 Subject: [PATCH] update readme + add glow check --- README.md | 2 +- src/hack.cpp | 20 ++++------ src/hooks/others.cpp | 95 +++++++++++++++++++++++--------------------- 3 files changed, 57 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 7f0c43c7..9634f3e3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Ubuntu (and probably Debian) users can run this script: ``` -sudo apt update && sudo apt install build-essential software-properties-common -y && sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt update && sudo apt install gcc-snapshot -y && sudo apt update && sudo apt install libc6-dev gcc-6 g++-6 g++-6-multilib gdb -y && git clone --recursive https://github.com/nullifiedcat/cathook && cd cathook && make -j4 +sudo apt update && sudo apt install build-essential software-properties-common -y && sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt update && sudo apt install gcc-snapshot -y && sudo apt update && sudo apt install git libc6-dev gcc-6 g++-6 libc6-dev:i386 g++-6-multilib gdb -y && git clone --recursive https://github.com/nullifiedcat/cathook && cd cathook && make -j4 ``` **Errors while installing?** diff --git a/src/hack.cpp b/src/hack.cpp index a737ab69..1432a221 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -67,17 +67,11 @@ void hack::ExecuteCommand(const std::string command) { ConCommand* hack::c_Cat = 0; void hack::CC_Cat(const CCommand& args) { - g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&colors::blu), "cathook"); - g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&colors::white), " by "); - g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&colors::blu), "d4rkc4t\n"); - g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&colors::white), "build: " CATHOOK_BUILD_NUMBER " \"" CATHOOK_BUILD_NAME "\"\n"); -#if _DEVELOPER - g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&colors::red), "[DEVELOPER BUILD]\n"); -#else - g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&colors::red), "Build for user " __DRM_NAME " (Early Access)\n"); -#endif -#ifdef __DRM_NOTES - g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&colors::red), "Build notes: " __DRM_NOTES "\n"); + g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&colors::white), "cathook"); + g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&colors::blu), " by "); + g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&colors::red), "nullifiedcat\n"); +#if defined(GIT_COMMIT_HASH) && defined(GIT_COMMIT_DATE) + g_ICvar->ConsoleColorPrintf(*reinterpret_cast(&colors::white), "commit: #" GIT_COMMIT_HASH " " GIT_COMMIT_DATE "\n"); #endif } @@ -167,7 +161,7 @@ void hack::Initialize() { hooks::hkInput->Init((void*)g_IInput, 0); hooks::hkInput->HookMethod((void*)GetUserCmd_hook, hooks::offGetUserCmd); hooks::hkInput->Apply(); - logging::Info("Before hacking: %s", g_ISteamFriends->GetPersonaName()); + //logging::Info("Before hacking: %s", g_ISteamFriends->GetPersonaName()); hooks::hkIVModelRender = new hooks::VMTHook(); hooks::hkIVModelRender->Init(g_IVModelRender, 0); hooks::hkIVModelRender->HookMethod((void*)DrawModelExecute_hook, hooks::offDrawModelExecute); @@ -176,7 +170,7 @@ void hack::Initialize() { hooks::hkSteamFriends->Init(g_ISteamFriends, 0); hooks::hkSteamFriends->HookMethod((void*)GetFriendPersonaName_hook, hooks::offGetFriendPersonaName); hooks::hkSteamFriends->Apply(); - logging::Info("After hacking: %s", g_ISteamFriends->GetPersonaName()); + //logging::Info("After hacking: %s", g_ISteamFriends->GetPersonaName()); // Sadly, it doesn't work as expected :( /*hooks::hkBaseClientState = new hooks::VMTHook(); hooks::hkBaseClientState->Init((void*)g_IBaseClientState, 0); diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index da3e17bb..603d6a9a 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -190,54 +190,57 @@ void FrameStageNotify_hook(void* thisptr, int stage) { } } } + static ConVar* glow_outline_effect = g_ICvar->FindVar("glow_outline_effect_enable"); if (TF && cathook && !g_Settings.bInvalid && stage == FRAME_RENDER_START) { - if (glow_enabled) { - for (int i = 0; i < g_GlowObjectManager->m_GlowObjectDefinitions.m_Size; i++) { - GlowObjectDefinition_t& glowobject = g_GlowObjectManager->m_GlowObjectDefinitions[i]; - if (glowobject.m_nNextFreeSlot != ENTRY_IN_USE) - continue; - int color = GetEntityGlowColor(glowobject.m_hEntity.m_Index & 0xFFF); - if (color == 0) { - glowobject.m_flGlowAlpha = 0.0f; - } else { - glowobject.m_flGlowAlpha = (float)glow_alpha; - } - unsigned char _b = (color >> 16) & 0xFF; - unsigned char _g = (color >> 8) & 0xFF; - unsigned char _r = (color) & 0xFF; - glowobject.m_vGlowColor.x = (float)_r / 255.0f; - glowobject.m_vGlowColor.y = (float)_g / 255.0f; - glowobject.m_vGlowColor.z = (float)_b / 255.0f; - } - } - // Remove glow from dead entities - for (int i = 0; i < g_GlowObjectManager->m_GlowObjectDefinitions.Count(); i++) { - if (g_GlowObjectManager->m_GlowObjectDefinitions[i].m_nNextFreeSlot != ENTRY_IN_USE) continue; - IClientEntity* ent = (IClientEntity*)g_IEntityList->GetClientEntityFromHandle(g_GlowObjectManager->m_GlowObjectDefinitions[i].m_hEntity); - if (ent && ent->IsDormant()) { - g_GlowObjectManager->DisableGlow(i); - } else if (ent && ent->GetClientClass()->m_ClassID == g_pClassID->C_Player) { - if (NET_BYTE(ent, netvar.iLifeState) != LIFE_ALIVE) { - g_GlowObjectManager->DisableGlow(i); - } - } - } - if (glow_enabled) { - for (int i = 1; i < g_IEntityList->GetHighestEntityIndex(); i++) { - IClientEntity* entity = g_IEntityList->GetClientEntity(i); - if (!entity || i == g_IEngine->GetLocalPlayer() || entity->IsDormant()) - continue; - if (!CanEntityEvenGlow(i)) continue; - int clazz = entity->GetClientClass()->m_ClassID; - int current_handle = g_GlowObjectManager->GlowHandle(entity); - bool shouldglow = ShouldEntityGlow(i); - if (current_handle != -1) { - if (!shouldglow) { - g_GlowObjectManager->DisableGlow(current_handle); + if (glow_outline_effect->GetBool()) { + if (glow_enabled) { + for (int i = 0; i < g_GlowObjectManager->m_GlowObjectDefinitions.m_Size; i++) { + GlowObjectDefinition_t& glowobject = g_GlowObjectManager->m_GlowObjectDefinitions[i]; + if (glowobject.m_nNextFreeSlot != ENTRY_IN_USE) + continue; + int color = GetEntityGlowColor(glowobject.m_hEntity.m_Index & 0xFFF); + if (color == 0) { + glowobject.m_flGlowAlpha = 0.0f; + } else { + glowobject.m_flGlowAlpha = (float)glow_alpha; } - } else { - if (shouldglow) { - g_GlowObjectManager->EnableGlow(entity, colors::white); + unsigned char _b = (color >> 16) & 0xFF; + unsigned char _g = (color >> 8) & 0xFF; + unsigned char _r = (color) & 0xFF; + glowobject.m_vGlowColor.x = (float)_r / 255.0f; + glowobject.m_vGlowColor.y = (float)_g / 255.0f; + glowobject.m_vGlowColor.z = (float)_b / 255.0f; + } + } + // Remove glow from dead entities + for (int i = 0; i < g_GlowObjectManager->m_GlowObjectDefinitions.Count(); i++) { + if (g_GlowObjectManager->m_GlowObjectDefinitions[i].m_nNextFreeSlot != ENTRY_IN_USE) continue; + IClientEntity* ent = (IClientEntity*)g_IEntityList->GetClientEntityFromHandle(g_GlowObjectManager->m_GlowObjectDefinitions[i].m_hEntity); + if (ent && ent->IsDormant()) { + g_GlowObjectManager->DisableGlow(i); + } else if (ent && ent->GetClientClass()->m_ClassID == g_pClassID->C_Player) { + if (NET_BYTE(ent, netvar.iLifeState) != LIFE_ALIVE) { + g_GlowObjectManager->DisableGlow(i); + } + } + } + if (glow_enabled) { + for (int i = 1; i < g_IEntityList->GetHighestEntityIndex(); i++) { + IClientEntity* entity = g_IEntityList->GetClientEntity(i); + if (!entity || i == g_IEngine->GetLocalPlayer() || entity->IsDormant()) + continue; + if (!CanEntityEvenGlow(i)) continue; + int clazz = entity->GetClientClass()->m_ClassID; + int current_handle = g_GlowObjectManager->GlowHandle(entity); + bool shouldglow = ShouldEntityGlow(i); + if (current_handle != -1) { + if (!shouldglow) { + g_GlowObjectManager->DisableGlow(current_handle); + } + } else { + if (shouldglow) { + g_GlowObjectManager->EnableGlow(entity, colors::white); + } } } }