add unlit fullbright + add/update addresses

This commit is contained in:
m 2022-02-26 15:24:03 -06:00
parent 6e21164a6c
commit 58259baf15
2 changed files with 78 additions and 2 deletions

View File

@ -0,0 +1,75 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "game/dvars.hpp"
#include <utils/hook.hpp>
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<bool>();
}
}
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<uint8_t>(SELECT_VALUE(0x0, 0x1405D460E), game::DVAR_FLAG_SAVED);
// use "saved" flags for "r_specularMap"
utils::hook::set<uint8_t>(SELECT_VALUE(0x0, 0x1405D4639), game::DVAR_FLAG_SAVED);
// use "saved" flags for "r_specOccMap"
utils::hook::set<uint8_t>(SELECT_VALUE(0x0, 0x1405D4664), game::DVAR_FLAG_SAVED);
}
};
}
REGISTER_COMPONENT(renderer::component)

View File

@ -38,6 +38,7 @@ namespace game
WEAK symbol<void(int hash, const char* name, const char* buffer)> Dvar_SetCommand{0x1403C72B0, 0x1404FD0A0};
WEAK symbol<dvar_t*(const char* name)> Dvar_FindVar{0x1403C5D50, 0x1404FBB00};
WEAK symbol<void(const dvar_t* dvar)> Dvar_ClearModified{0x0, 0x1404FB930};
WEAK symbol<void(char* buffer, int index)> Dvar_GetCombinedString{0x140354DF0, 0x14041D830};
WEAK symbol<const char*(dvar_t* dvar, dvar_value value)> Dvar_ValueToString{0x1403C8560, 0x1404FE660};
WEAK symbol<dvar_t*(int hash, const char* name, bool value, unsigned int flags)> Dvar_RegisterBool{0x1403C47E0, 0x1404FA540};
@ -85,7 +86,7 @@ namespace game
WEAK symbol<int(const char* text, int maxChars, Font_s* font)> R_TextWidth{0x1404D43B0, 0x1405D94A0};
WEAK symbol<int(void* font)> R_GetFontHeight{0x1405EA360, 0x1405D92C0};
WEAK symbol<void* (int a1)> R_DrawSomething{0x1404D37B0, 0x1405D8890};
WEAK symbol<void()> R_SyncRenderThread{0, 0x14076E7D0};
WEAK symbol<void()> R_SyncRenderThread{0,0x1405FF3A0};
WEAK symbol<void(const void* obj, void* pose, unsigned int entnum, unsigned int renderFxFlags, float* lightingOrigin,
float materialTime, __int64 a7, __int64 a8)> R_AddDObjToScene{0, 0x140775C40};
WEAK symbol<void* (const char* text, int maxChars, void* font, int fontHeight, float x, float y, float xScale, float yScale,
@ -176,7 +177,7 @@ namespace game
WEAK symbol<const char*> g_assetNames{0, 0x140BEF280};
WEAK symbol<int> g_poolSize{0, 0x140FEADF0};
WEAK symbol<GfxDrawMethod_s> gfxDrawMethod{0, 0x14EDF9E00};
WEAK symbol<GfxDrawMethod_s> gfxDrawMethod{0, 0x14FD21180};
WEAK symbol<int> dvarCount{0, 0x14D064CF4};
WEAK symbol<dvar_t*> sortedDvars{0, 0x14D064D00};