From c27027f937143ab0459ca049ffce825ddbf29c6b Mon Sep 17 00:00:00 2001 From: Unnamed Date: Sun, 17 Feb 2019 20:25:45 +0000 Subject: [PATCH] Init parts of several hacks in their respective init functions Also don't push console commands but issue their init functions directly --- src/hack.cpp | 2 -- src/hacks/KillSay.cpp | 1 + src/hacks/Spam.cpp | 13 +++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hack.cpp b/src/hack.cpp index 1d66c832..da0a09b0 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -348,8 +348,6 @@ free(logname);*/ auto extra_exec = std::getenv("CH_EXEC"); if (extra_exec) hack::command_stack().push(extra_exec); - hack::command_stack().push("cat_killsay_reload"); - hack::command_stack().push("cat_spam_reload"); hack::initialized = true; for (int i = 0; i < 12; i++) diff --git a/src/hacks/KillSay.cpp b/src/hacks/KillSay.cpp index 506fc5f8..cc6d1001 100644 --- a/src/hacks/KillSay.cpp +++ b/src/hacks/KillSay.cpp @@ -167,6 +167,7 @@ static CatCommand reload_command("killsay_reload", "Reload killsays", []() { rel void init() { + reload(); g_IEventManager2->AddListener(&listener, (const char *) "player_death", false); } diff --git a/src/hacks/Spam.cpp b/src/hacks/Spam.cpp index fc8ee2ce..8dc255de 100644 --- a/src/hacks/Spam.cpp +++ b/src/hacks/Spam.cpp @@ -234,12 +234,6 @@ bool FormatSpamMessage(std::string &message) return SubstituteQueries(message); } -void init() -{ - spam_source.installChangeCallback([](settings::VariableBase &var, int after) { file.Load(*filename); }); - filename.installChangeCallback([](settings::VariableBase &var, std::string after) { file.TryLoad(after); }); -} - void createMove() { IF_GAME(IsTF2()) @@ -377,6 +371,13 @@ bool isActive() return bool(spam_source); } +void init() +{ + spam_source.installChangeCallback([](settings::VariableBase &var, int after) { file.Load(*filename); }); + filename.installChangeCallback([](settings::VariableBase &var, std::string after) { file.TryLoad(after); }); + reloadSpamFile(); +} + const std::vector builtin_default = { "Cathook - more fun than a ball of yarn!", "GNU/Linux is the best OS!", "Visit https://github.com/nullworks/cathook for more information!", "Cathook - Free and Open-Source tf2 cheat!", "Cathook - ca(n)t stop me meow!" }; const std::vector builtin_lennyfaces = { "( ͡° ͜ʖ ͡°)", "( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°) ͡°)", "ʕ•ᴥ•ʔ", "(▀̿Ĺ̯▀̿ ̿)", "( ͡°╭͜ʖ╮͡° )", "(ง'̀-'́)ง", "(◕‿◕✿)", "༼ つ ͡° ͜ʖ ͡° ༽つ" }; const std::vector builtin_blanks = { ". \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n " };