From 7adb8d0e6f34db3af9674380cce5a56a49445f95 Mon Sep 17 00:00:00 2001 From: "C.S. Melis" Date: Wed, 13 Dec 2023 22:11:05 +0100 Subject: [PATCH] Scale pbubble and character detail float values --- flplusplus/src/graphics.cpp | 55 ++++++++++++++++++++++++++++++++++--- flplusplus/src/offsets.h | 5 ++++ 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/flplusplus/src/graphics.cpp b/flplusplus/src/graphics.cpp index 36cb21f..1a1bace 100644 --- a/flplusplus/src/graphics.cpp +++ b/flplusplus/src/graphics.cpp @@ -2,13 +2,19 @@ #include "patch.h" #include "offsets.h" #include "config.h" +#include "Common.h" #define WIN32_LEAN_AND_MEAN #include +config::ConfigData& cfg = config::get_config(); + +const float minScale = 1; +const float maxScale = 1000000; + int patch_lodranges(const float* scale) { - if(*scale < 1 || *scale > 1000000) return 0; + if(*scale < minScale || *scale > maxScale) return 0; if(*scale == 1) { //1x lods @@ -41,6 +47,44 @@ int patch_lodranges(const float* scale) return 1; } +float __fastcall multiply_pbubble_float(INI_Reader* reader, PVOID _edx, UINT index) +{ + return reader->get_value_float(index) * cfg.pbubblescale; +} + +float __fastcall multiply_characterdetail_float(INI_Reader* reader, PVOID _edx, UINT index) +{ + return reader->get_value_float(index) * cfg.characterdetailscale; +} + +bool patch_pbubble() +{ + if (cfg.pbubblescale < minScale || cfg.pbubblescale > maxScale) + return false; + + static UINT multiplyPbubblePtr = (UINT) &multiply_pbubble_float; + + patch::patch_uint32(OF_PBUBBLE_GET_VALUE0, (UINT) &multiplyPbubblePtr); + patch::patch_uint32(OF_PBUBBLE_GET_VALUE1, (UINT) &multiplyPbubblePtr); + + return true; +} + +bool patch_characterdetail() +{ + if (cfg.characterdetailscale < minScale || cfg.characterdetailscale > maxScale) + return false; + + auto common = (DWORD) GetModuleHandleA("common.dll"); + + UINT multiplyCharacterDetailPtr = (UINT) &multiply_characterdetail_float; + UINT detailSwitchAddr = common + F_OF_BODYPART_DETAILSWITCH_GET_VALUE; + + patch::patch_uint32(detailSwitchAddr, multiplyCharacterDetailPtr - detailSwitchAddr - 4); + + return true; +} + void graphics::init(bool version11) { patch::patch_uint8(OF_VIDEODIALOG, 0x33); //disable unsupported video dialog @@ -49,9 +93,12 @@ void graphics::init(bool version11) //FL tries to load this font over Agency FB, screws up UI if it finds it //if you have a font named '\b' you have big problems const char *garbageFont = "\b\0"; - HMODULE common = GetModuleHandleA("common.dll"); - unsigned int address = (DWORD) common + (version11 ? F_OF_VIBROCENTRICFONT_V11 : F_OF_VIBROCENTRICFONT_V10); + auto common = (DWORD) GetModuleHandleA("common.dll"); + unsigned int address = common + (version11 ? F_OF_VIBROCENTRICFONT_V11 : F_OF_VIBROCENTRICFONT_V10); patch::patch_bytes(address, (void*)garbageFont, 2); //lod 0 - patch_lodranges(&config::get_config().lodscale); + patch_lodranges(&cfg.lodscale); + + patch_pbubble(); + patch_characterdetail(); } diff --git a/flplusplus/src/offsets.h b/flplusplus/src/offsets.h index 2ccfc06..e3de6c6 100644 --- a/flplusplus/src/offsets.h +++ b/flplusplus/src/offsets.h @@ -22,3 +22,8 @@ #define F_OF_VIBROCENTRICFONT_V11 (0x143DC0) #define F_OF_VIBROCENTRICFONT_V10 (0x143D90) + +#define OF_PBUBBLE_GET_VALUE0 (0x4FD82C) +#define OF_PBUBBLE_GET_VALUE1 (0x4FD839) + +#define F_OF_BODYPART_DETAILSWITCH_GET_VALUE (0x9EFB2)