WIP Stuff

Fix glow and chams (kind of, todo)
Add detach (todo)
This commit is contained in:
TotallyNotElite 2018-12-19 22:02:11 +01:00
parent dd6650c551
commit e7908e2e90
11 changed files with 38 additions and 44 deletions

View File

@ -25,6 +25,7 @@ extern std::mutex command_stack_mutex;
std::stack<std::string> &command_stack(); std::stack<std::string> &command_stack();
void ExecuteCommand(const std::string command); void ExecuteCommand(const std::string command);
extern bool game_shutdown;
extern bool shutdown; extern bool shutdown;
extern bool initialized; extern bool initialized;

View File

@ -16,5 +16,4 @@ void shutdown();
void reload(); void reload();
extern const std::vector<std::string> builtin_default; extern const std::vector<std::string> builtin_default;
extern const std::vector<std::string> jp_anime;
} // namespace hacks::shared::dominatesay } // namespace hacks::shared::dominatesay

View File

@ -16,8 +16,6 @@ namespace effect_chams
class EffectChams : public IScreenSpaceEffect class EffectChams : public IScreenSpaceEffect
{ {
std::vector<KeyValues *> chams_keyvalues;
public: public:
virtual void Init(); virtual void Init();
virtual void Shutdown() virtual void Shutdown()
@ -28,9 +26,6 @@ public:
mat_unlit_z.Shutdown(); mat_unlit_z.Shutdown();
mat_lit.Shutdown(); mat_lit.Shutdown();
mat_lit_z.Shutdown(); mat_lit_z.Shutdown();
for (auto kv : chams_keyvalues)
if (kv)
kv->deleteThis();
init = false; init = false;
} }
} }

View File

@ -15,8 +15,6 @@ namespace effect_glow
class EffectGlow : public IScreenSpaceEffect class EffectGlow : public IScreenSpaceEffect
{ {
std::vector<KeyValues *> glow_keyvalues;
public: public:
virtual void Init(); virtual void Init();
virtual void Shutdown() virtual void Shutdown()
@ -30,9 +28,6 @@ public:
mat_unlit_z.Shutdown(); mat_unlit_z.Shutdown();
mat_blur_x.Shutdown(); mat_blur_x.Shutdown();
mat_blur_y.Shutdown(); mat_blur_y.Shutdown();
for (auto kv : glow_keyvalues)
if (kv)
kv->deleteThis();
init = false; init = false;
} }
} }

View File

@ -5,7 +5,7 @@
* Author: nullifiedcat * Author: nullifiedcat
*/ */
#include <core/logging.hpp> #include "common.hpp"
#include <pthread.h> #include <pthread.h>
#include "hack.hpp" #include "hack.hpp"
@ -40,7 +40,7 @@ void *MainThread(void *arg)
logging::Info("Shutting down..."); logging::Info("Shutting down...");
hack::Shutdown(); hack::Shutdown();
logging::Shutdown(); logging::Shutdown();
return 0; return nullptr;
} }
void __attribute__((constructor)) attach() void __attribute__((constructor)) attach()
@ -51,9 +51,19 @@ void __attribute__((constructor)) attach()
pthread_create(&thread_main, 0, MainThread, &mutex_quit); pthread_create(&thread_main, 0, MainThread, &mutex_quit);
} }
void __attribute__((destructor)) detach() void detach()
{ {
logging::Info("Detaching"); logging::Info("Detaching");
pthread_mutex_unlock(&mutex_quit); pthread_mutex_unlock(&mutex_quit);
pthread_join(thread_main, 0); pthread_join(thread_main, 0);
} }
void __attribute__((destructor)) deconstruct()
{
detach();
}
CatCommand cat_detach("detach", "Detach cathook from TF2", []() {
hack::game_shutdown = false;
detach();
});

View File

@ -12,6 +12,7 @@
#include <settings/Bool.hpp> #include <settings/Bool.hpp>
#include "common.hpp" #include "common.hpp"
#include "hack.hpp"
settings::Bool log_to_console{ "hack.log-console", "false" }; settings::Bool log_to_console{ "hack.log-console", "false" };
@ -45,7 +46,7 @@ void logging::Info(const char *fmt, ...)
fprintf(logging::handle, "%s", result); fprintf(logging::handle, "%s", result);
fflush(logging::handle); fflush(logging::handle);
#if ENABLE_VISUALS #if ENABLE_VISUALS
if (g_ICvar) if (!hack::game_shutdown && g_ICvar)
{ {
if (*log_to_console) if (*log_to_console)
g_ICvar->ConsolePrintf("%s", result); g_ICvar->ConsolePrintf("%s", result);

View File

@ -32,6 +32,8 @@
* Linux * Linux
*/ */
// game_shutdown = Is full game shutdown or just detach
bool hack::game_shutdown = true;
bool hack::shutdown = false; bool hack::shutdown = false;
bool hack::initialized = false; bool hack::initialized = false;
@ -367,6 +369,8 @@ void hack::Shutdown()
if (hack::shutdown) if (hack::shutdown)
return; return;
hack::shutdown = true; hack::shutdown = true;
// Stop cathook stuff
settings::RVarLock.store(true);
playerlist::Save(); playerlist::Save();
#if ENABLE_VISUALS #if ENABLE_VISUALS
sdl_hooks::cleanSdlHooks(); sdl_hooks::cleanSdlHooks();
@ -374,8 +378,15 @@ void hack::Shutdown()
logging::Info("Unregistering convars.."); logging::Info("Unregistering convars..");
ConVar_Unregister(); ConVar_Unregister();
logging::Info("Shutting down killsay..."); logging::Info("Shutting down killsay...");
hacks::shared::killsay::shutdown(); if (!hack::game_shutdown)
hacks::shared::dominatesay::shutdown(); {
hacks::shared::announcer::shutdown(); hacks::shared::killsay::shutdown();
hacks::shared::dominatesay::shutdown();
hacks::shared::announcer::shutdown();
#if ENABLE_VISUALS
g_pScreenSpaceEffects->DisableScreenSpaceEffect("_cathook_glow");
g_pScreenSpaceEffects->DisableScreenSpaceEffect("_cathook_chams");
#endif
}
logging::Info("Success.."); logging::Info("Success..");
} }

View File

@ -35,9 +35,6 @@ std::string ComposeDominateSay(IGameEvent *event)
case 2: case 2:
source = &builtin_default; source = &builtin_default;
break; break;
case 3:
source = &jp_anime;
break;
default: default:
break; break;
} }
@ -115,17 +112,4 @@ const std::vector<std::string> builtin_default = {
"%killer% is dominating the server with %dominum% dominations!", "%killer% is dominating the server with %dominum% dominations!",
}; };
// same goes to this one
const std::vector<std::string> jp_anime = {
"Get d-dominated %name%-senpai >:3",
"g- gomenasai! %name%-san!",
"Wow! hey hey hey H~ ey !!! I found you again~~!",
"%name%-san please don't get mad at me.. ><",
// https://youtu.be/sW3RT0tF020?t=207
"kore kara mo douzo yoroshiku ne.",
"konna watashi dakedo waratte yurushite ne.",
"zutto taisetsu ni shite ne.",
"eikyuu hoshou no watashi dakara.",
};
} // namespace hacks::shared::dominatesay } // namespace hacks::shared::dominatesay

View File

@ -38,20 +38,20 @@ CatCommand fix_black_chams("fix_black_chams", "Fix Black Chams", []() {
void EffectChams::Init() void EffectChams::Init()
{ {
if (init)
return;
logging::Info("Init EffectChams..."); logging::Info("Init EffectChams...");
{ {
KeyValues *kv = new KeyValues("UnlitGeneric"); KeyValues *kv = new KeyValues("UnlitGeneric");
kv->SetString("$basetexture", "vgui/white_additive"); kv->SetString("$basetexture", "vgui/white_additive");
kv->SetInt("$ignorez", 0); kv->SetInt("$ignorez", 0);
mat_unlit.Init("__cathook_echams_unlit", kv); mat_unlit.Init("__cathook_echams_unlit", kv);
chams_keyvalues.push_back(kv);
} }
{ {
KeyValues *kv = new KeyValues("UnlitGeneric"); KeyValues *kv = new KeyValues("UnlitGeneric");
kv->SetString("$basetexture", "vgui/white_additive"); kv->SetString("$basetexture", "vgui/white_additive");
kv->SetInt("$ignorez", 1); kv->SetInt("$ignorez", 1);
mat_unlit_z.Init("__cathook_echams_unlit_z", kv); mat_unlit_z.Init("__cathook_echams_unlit_z", kv);
chams_keyvalues.push_back(kv);
} }
{ {
KeyValues *kv = new KeyValues("VertexLitGeneric"); KeyValues *kv = new KeyValues("VertexLitGeneric");
@ -59,7 +59,6 @@ void EffectChams::Init()
kv->SetInt("$ignorez", 0); kv->SetInt("$ignorez", 0);
kv->SetInt("$halflambert", 1); kv->SetInt("$halflambert", 1);
mat_lit.Init("__cathook_echams_lit", kv); mat_lit.Init("__cathook_echams_lit", kv);
chams_keyvalues.push_back(kv);
} }
{ {
KeyValues *kv = new KeyValues("VertexLitGeneric"); KeyValues *kv = new KeyValues("VertexLitGeneric");
@ -67,7 +66,6 @@ void EffectChams::Init()
kv->SetInt("$ignorez", 1); kv->SetInt("$ignorez", 1);
kv->SetInt("$halflambert", 1); kv->SetInt("$halflambert", 1);
mat_lit_z.Init("__cathook_echams_lit_z", kv); mat_lit_z.Init("__cathook_echams_lit_z", kv);
chams_keyvalues.push_back(kv);
} }
logging::Info("Init done!"); logging::Info("Init done!");
init = true; init = true;
@ -335,6 +333,8 @@ void EffectChams::Render(int x, int y, int w, int h)
return; return;
if (!enable) if (!enable)
return; return;
if (g_Settings.bInvalid)
return;
if (!init) if (!init)
Init(); Init();
if (!isHackActive() || (g_IEngine->IsTakingScreenshot() && clean_screenshots)) if (!isHackActive() || (g_IEngine->IsTakingScreenshot() && clean_screenshots))

View File

@ -129,20 +129,20 @@ CatCommand fix_black_glow("fix_black_glow", "Fix Black Glow", []() {
void EffectGlow::Init() void EffectGlow::Init()
{ {
if (init)
return;
logging::Info("Init Glow..."); logging::Info("Init Glow...");
{ {
KeyValues *kv = new KeyValues("UnlitGeneric"); KeyValues *kv = new KeyValues("UnlitGeneric");
kv->SetString("$basetexture", "vgui/white_additive"); kv->SetString("$basetexture", "vgui/white_additive");
kv->SetInt("$ignorez", 0); kv->SetInt("$ignorez", 0);
mat_unlit.Init("__cathook_glow_unlit", kv); mat_unlit.Init("__cathook_glow_unlit", kv);
glow_keyvalues.push_back(kv);
} }
{ {
KeyValues *kv = new KeyValues("UnlitGeneric"); KeyValues *kv = new KeyValues("UnlitGeneric");
kv->SetString("$basetexture", "vgui/white_additive"); kv->SetString("$basetexture", "vgui/white_additive");
kv->SetInt("$ignorez", 1); kv->SetInt("$ignorez", 1);
mat_unlit_z.Init("__cathook_glow_unlit_z", kv); mat_unlit_z.Init("__cathook_glow_unlit_z", kv);
glow_keyvalues.push_back(kv);
} }
// Initialize 2 buffers // Initialize 2 buffers
GetBuffer(1); GetBuffer(1);
@ -153,7 +153,6 @@ void EffectGlow::Init()
kv->SetInt("$additive", 1); kv->SetInt("$additive", 1);
mat_blit.Init("__cathook_glow_blit", TEXTURE_GROUP_CLIENT_EFFECTS, kv); mat_blit.Init("__cathook_glow_blit", TEXTURE_GROUP_CLIENT_EFFECTS, kv);
mat_blit->Refresh(); mat_blit->Refresh();
glow_keyvalues.push_back(kv);
} }
{ {
KeyValues *kv = new KeyValues("BlurFilterX"); KeyValues *kv = new KeyValues("BlurFilterX");
@ -163,7 +162,6 @@ void EffectGlow::Init()
kv->SetInt("$alphatest", 1); kv->SetInt("$alphatest", 1);
mat_blur_x.Init("_cathook_blurx", kv); mat_blur_x.Init("_cathook_blurx", kv);
mat_blur_x->Refresh(); mat_blur_x->Refresh();
glow_keyvalues.push_back(kv);
} }
{ {
KeyValues *kv = new KeyValues("BlurFilterY"); KeyValues *kv = new KeyValues("BlurFilterY");
@ -174,7 +172,6 @@ void EffectGlow::Init()
kv->SetInt("$alphatest", 1); kv->SetInt("$alphatest", 1);
mat_blur_y.Init("_cathook_blury", kv); mat_blur_y.Init("_cathook_blury", kv);
mat_blur_y->Refresh(); mat_blur_y->Refresh();
glow_keyvalues.push_back(kv);
} }
{ {
SS_NeverSolid.m_bEnable = true; SS_NeverSolid.m_bEnable = true;

View File

@ -33,5 +33,6 @@ void applySdlHooks()
void cleanSdlHooks() void cleanSdlHooks()
{ {
*pointers::SDL_GL_SwapWindow = hooked_methods::original::SDL_GL_SwapWindow; *pointers::SDL_GL_SwapWindow = hooked_methods::original::SDL_GL_SwapWindow;
*pointers::SDL_PollEvent = hooked_methods::original::SDL_PollEvent;
} }
} // namespace sdl_hooks } // namespace sdl_hooks