diff --git a/src/component/ban.cpp b/src/component/ban.cpp new file mode 100644 index 0000000..4b20d1b --- /dev/null +++ b/src/component/ban.cpp @@ -0,0 +1,40 @@ +#include + +#include "loader/component_loader.hpp" +#include "utils/hook.hpp" + +namespace ban +{ + namespace + { + const game::dvar_t* sv_discord = nullptr; + const game::dvar_t* sv_clanWebsite = nullptr; + + bool out_of_band_print_hk(game::netsrc_t src, game::netadr_s to, const char* msg) + { + if (msg != "error\nPATCH_BANNED_FROM_SERVER"s) + { + return game::NET_OutOfBandPrint(src, to, msg); + } + + const auto errorMsg = std::format("error\nPermanently banned\nDiscord: {}\nWebsite: {}", + sv_discord->current.string, sv_clanWebsite->current.string); + + return game::NET_OutOfBandPrint(src, to, errorMsg.data()); + } + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + sv_discord = game::Dvar_RegisterString("sv_discord", "https://www.discord.gg/", game::DVAR_FLAG_SAVED, "Discord invitation link"); + sv_clanWebsite = game::Dvar_RegisterString("sv_clanWebsite", "https://www.google.com/", game::DVAR_FLAG_SAVED, "Website link"); + + utils::hook::call(SELECT(0x48B7E2, 0x0), out_of_band_print_hk); + } + }; +} + +REGISTER_COMPONENT(ban::component) \ No newline at end of file diff --git a/src/component/chat.cpp b/src/component/chat.cpp index eb91bbc..5421eeb 100644 --- a/src/component/chat.cpp +++ b/src/component/chat.cpp @@ -9,7 +9,6 @@ namespace chat public: void post_unpack() override { - } }; } diff --git a/src/component/command.cpp b/src/component/command.cpp index fce6af2..35254ff 100644 --- a/src/component/command.cpp +++ b/src/component/command.cpp @@ -127,35 +127,6 @@ namespace command { utils::nt::raise_hard_exception(); }); - - add("dvarDump", [](const params& params) - { - if (params.size() < 2) - { - return; - } - - std::string filename = "dump/"; - filename.append(params.get(1)); - if (!filename.ends_with(".txt")) - { - filename.append(".txt"); - } - - for (auto i = 0; i < *game::dvarCount; i++) - { - const auto dvar = game::sortedDvars[i]; - - if (dvar) - { - const auto line = std::format("{} \"{}\"\r\n", dvar->name, - game::Dvar_DisplayableValue(dvar)); - utils::io::write_file(filename, line, i != 0); - } - } - - game::Com_Printf(game::CON_CHANNEL_SERVER, "%i dvars\n", *game::dvarCount); - }); } }; } diff --git a/src/component/gameplay.cpp b/src/component/gameplay.cpp index bd4c926..83802cf 100644 --- a/src/component/gameplay.cpp +++ b/src/component/gameplay.cpp @@ -1,15 +1,32 @@ #include #include "loader/component_loader.hpp" +#include "utils/hook.hpp" namespace gameplay { + namespace + { + const game::dvar_s* player_meleeRange = nullptr; + utils::hook::detour fire_weapon_melee_hook; + + void fire_weapon_melee_stub(game::gentity_s* ent, int time) + { + if (player_meleeRange->current.value == 0.0f) + return; + + fire_weapon_melee_hook.invoke(ent, time); + } + } + class component final : public component_interface { public: void post_unpack() override { + player_meleeRange = reinterpret_cast(SELECT(0xC51990, 0x0)); + fire_weapon_melee_hook.create(SELECT(0x401E00, 0x0), &fire_weapon_melee_stub); } }; } diff --git a/src/game/game.hpp b/src/game/game.hpp index 6b87e4c..bd5e09a 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -1,6 +1,6 @@ #pragma once -#define SELECT(mp, zm) (game::environment::t6mp() ? mp : zm) +#define SELECT(mp, zm) (game::environment::t5mp() ? mp : zm) namespace game { diff --git a/src/game/symbols.hpp b/src/game/symbols.hpp index 20e589f..655ab15 100644 --- a/src/game/symbols.hpp +++ b/src/game/symbols.hpp @@ -7,16 +7,29 @@ namespace game // Functions WEAK symbol Com_Error{0x627380, 0x0}; WEAK symbol Com_Printf{0x4126C0, 0x0}; + WEAK symbol Com_DPrintf{0x4E3FA0, 0x0}; WEAK symbol Cbuf_AddText{0x56EF70, 0x0}; WEAK symbol Cmd_ExecuteSingleCommand{0x50B470, 0x0}; + WEAK symbol SV_SendServerCommand{0x588B10, 0x0}; + WEAK symbol SV_DelayDropClient{0x4A8DC0, 0x0}; + WEAK symbol SV_GetPlayerByName{0x875180, 0x0}; + WEAK symbol SV_GetPlayerByNum{0x875260, 0x0}; + + WEAK symbol NET_OutOfBandPrint{0x560BB0, 0x0}; + WEAK symbol NET_AdrToString {0x49F970, 0x0}; + WEAK symbol Dvar_FindVar{0x512F70, 0x0}; WEAK symbol Dvar_DisplayableValue{0x681DD0, 0x0}; + WEAK symbol Dvar_RegisterString{0x4E3410, 0x0}; WEAK symbol Cmd_AddCommandInternal{0x6AD580, 0x0}; WEAK symbol Cmd_RemoveCommand{0x527EA0, 0x0}; + WEAK symbol I_CleanStr{0x4B0700, 0x0}; + WEAK symbol ConcatArgs{0x5D5F10, 0x0}; WEAK symbol cmd_args{0x355BD88, 0x0};