From 25221421c8f917eba3fcb80754da9dc4589a0534 Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 4 Oct 2024 22:52:37 +0200 Subject: [PATCH] VC: Scale blip outlines to resolution --- SilentPatchVC/SilentPatchVC.cpp | 97 +++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index 0b69b96..d1ba14a 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -328,6 +328,61 @@ namespace OnscreenCounterBarFixes HOOK_EACH_INIT(YPos, orgYPos, YPos_Recalculated); } +// ============= Fix the radar trace blip outline not scaling to resolution ============= +namespace RadarTraceOutlineFixes +{ + template + static const float* orgXPos; + + template + static float XPos_Recalculated; + + template + static const float* orgYPos; + + template + static float YPos_Recalculated; + + template + static void RecalculateXPositions(std::index_sequence) + { + const float multiplier = GetWidthMult() * RsGlobal->MaximumWidth; + ((XPos_Recalculated = *orgXPos * multiplier), ...); + } + + template + static void RecalculateYPositions(std::index_sequence) + { + const float multiplier = GetHeightMult() * RsGlobal->MaximumHeight; + ((YPos_Recalculated = *orgYPos * multiplier), ...); + } + + template + struct PositionRecalculator + { + static void RecalculatePositions() + { + RecalculateXPositions(std::make_index_sequence{}); + RecalculateYPositions(std::make_index_sequence{}); + } + + template + static void (*orgShowRadarTraceWithHeight)(float, float, unsigned int, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char); + + template + static void ShowRadarTraceWithHeight_RecalculatePositions(float a1, float a2, unsigned int a3, unsigned char a4, unsigned char a5, unsigned char a6, unsigned char a7, unsigned char a8) + { + RecalculatePositions(); + orgShowRadarTraceWithHeight(a1, a2, a3, a4, a5, a6, a7, a8); + } + + HOOK_EACH_INIT(ShowRadarTraceWithHeight, orgShowRadarTraceWithHeight, ShowRadarTraceWithHeight_RecalculatePositions); + }; + + HOOK_EACH_INIT(XPos, orgXPos, XPos_Recalculated); + HOOK_EACH_INIT(YPos, orgYPos, YPos_Recalculated); +} + float FixedRefValue() { return 1.0f; @@ -1386,6 +1441,48 @@ void InjectDelayedPatches_VC_Common( bool bHasDebugMenu, const wchar_t* wcModule TXN_CATCH(); + // Fix the radar trace blip shadow not scaling to resolution + try + { + using namespace RadarTraceOutlineFixes; + + auto triangle1 = pattern("D8 05 ? ? ? ? DD D9 D9 44 24 68").count(2); + auto triangle2 = pattern("D8 05 ? ? ? ? DD DA D9 44 24 58").count(2); + + auto showRadarTraceWithHeight = pattern("E8 ? ? ? ? 83 C4 20 80 3D ? ? ? ? ? 0F 84 ? ? ? ? 30 D2").count(2); + + std::array XPositions = { + triangle1.get(0).get(2), + triangle1.get(1).get(2), + + triangle2.get(0).get(2), + triangle2.get(1).get(2), + + get_pattern("D8 05 ? ? ? ? DD D9 D9 44 24 50", 2), + }; + + std::array YPositions = { + get_pattern("D9 05 ? ? ? ? D8 C1 D8 6C 24 58 DD DA", 2), + get_pattern("D9 05 ? ? ? ? D8 C1 D8 44 24 60", 2), + get_pattern("D8 05 ? ? ? ? DD D9 D9 44 24 58", 2), + + get_pattern("D9 05 ? ? ? ? D8 C1 D8 6C 24 58 89 D0", 2), + get_pattern("D9 05 ? ? ? ? D8 C1 D8 44 24 64", 2), + get_pattern("D8 05 ? ? ? ? 89 D8", 2), + }; + + std::array showRadarTraceWithHeight_Patches = { + showRadarTraceWithHeight.get(0).get(), + showRadarTraceWithHeight.get(1).get(), + }; + + HookEach_XPos(XPositions, PatchFloat); + HookEach_YPos(YPositions, PatchFloat); + PositionRecalculator::HookEach_ShowRadarTraceWithHeight(showRadarTraceWithHeight_Patches, InterceptCall); + } + TXN_CATCH(); + + FLAUtils::Init(moduleList); }