diff --git a/src/client/component/renderer.cpp b/src/client/component/renderer.cpp new file mode 100644 index 00000000..adf50b0a --- /dev/null +++ b/src/client/component/renderer.cpp @@ -0,0 +1,75 @@ +#include +#include "loader/component_loader.hpp" +#include "game/game.hpp" +#include "game/dvars.hpp" + +#include + +namespace renderer +{ + namespace + { + utils::hook::detour r_init_draw_method_hook; + utils::hook::detour r_update_front_end_dvar_options_hook; + + int get_fullbright_technique() + { + return game::TECHNIQUE_UNLIT; + } + + void gfxdrawmethod() + { + game::gfxDrawMethod->drawScene = game::GFX_DRAW_SCENE_STANDARD; + + game::gfxDrawMethod->baseTechType = dvars::r_fullbright->current.enabled ? get_fullbright_technique() : game::TECHNIQUE_LIT; + game::gfxDrawMethod->emissiveTechType = dvars::r_fullbright->current.enabled ? get_fullbright_technique() : game::TECHNIQUE_EMISSIVE; + game::gfxDrawMethod->forceTechType = dvars::r_fullbright->current.enabled ? get_fullbright_technique() : 242; + } + + void r_init_draw_method_stub() + { + gfxdrawmethod(); + } + + bool r_update_front_end_dvar_options_stub() + { + if (dvars::r_fullbright->modified) + { + game::Dvar_ClearModified(dvars::r_fullbright); + game::R_SyncRenderThread(); + + gfxdrawmethod(); + } + + return r_update_front_end_dvar_options_hook.invoke(); + } + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + if (game::environment::is_dedi()) + { + return; + } + + dvars::r_fullbright = dvars::register_int("r_fullbright", 0, 0, 3, game::DVAR_FLAG_SAVED); + + r_init_draw_method_hook.create(SELECT_VALUE(0x1404BD140, 0x1405C46E0), &r_init_draw_method_stub); + r_update_front_end_dvar_options_hook.create(SELECT_VALUE(0x1404F8870, 0x1405FF9E0), &r_update_front_end_dvar_options_stub); + + // use "saved" flags for "r_normalMap" + utils::hook::set(SELECT_VALUE(0x0, 0x1405D460E), game::DVAR_FLAG_SAVED); + + // use "saved" flags for "r_specularMap" + utils::hook::set(SELECT_VALUE(0x0, 0x1405D4639), game::DVAR_FLAG_SAVED); + + // use "saved" flags for "r_specOccMap" + utils::hook::set(SELECT_VALUE(0x0, 0x1405D4664), game::DVAR_FLAG_SAVED); + } + }; +} + +REGISTER_COMPONENT(renderer::component) \ No newline at end of file diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 0312bd57..6606fea6 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -38,6 +38,7 @@ namespace game WEAK symbol Dvar_SetCommand{0x1403C72B0, 0x1404FD0A0}; WEAK symbol Dvar_FindVar{0x1403C5D50, 0x1404FBB00}; + WEAK symbol Dvar_ClearModified{0x0, 0x1404FB930}; WEAK symbol Dvar_GetCombinedString{0x140354DF0, 0x14041D830}; WEAK symbol Dvar_ValueToString{0x1403C8560, 0x1404FE660}; WEAK symbol Dvar_RegisterBool{0x1403C47E0, 0x1404FA540}; @@ -85,7 +86,7 @@ namespace game WEAK symbol R_TextWidth{0x1404D43B0, 0x1405D94A0}; WEAK symbol R_GetFontHeight{0x1405EA360, 0x1405D92C0}; WEAK symbol R_DrawSomething{0x1404D37B0, 0x1405D8890}; - WEAK symbol R_SyncRenderThread{0, 0x14076E7D0}; + WEAK symbol R_SyncRenderThread{0,0x1405FF3A0}; WEAK symbol R_AddDObjToScene{0, 0x140775C40}; WEAK symbol g_assetNames{0, 0x140BEF280}; WEAK symbol g_poolSize{0, 0x140FEADF0}; - WEAK symbol gfxDrawMethod{0, 0x14EDF9E00}; + WEAK symbol gfxDrawMethod{0, 0x14FD21180}; WEAK symbol dvarCount{0, 0x14D064CF4}; WEAK symbol sortedDvars{0, 0x14D064D00};