Addressed an issue where prompt icons would disappear. Fixed an issue where HUD scaling would not perform properly.
This commit is contained in:
@@ -24,6 +24,7 @@ static std::atomic<bool> g_camera_fix_enabled = false;
|
||||
static std::atomic<bool> g_DOF_fix_enabled = false;
|
||||
static std::atomic<bool> g_vignetting_fix_enabled = false;
|
||||
static std::atomic<bool> g_sharpening_fix_enabled = false;
|
||||
std::atomic<bool> bForceHUDRedraw = false; // Used to force HUD drawing once
|
||||
static int g_AdditionalFOVValue = 0;
|
||||
static float g_cameraDistanceMultiplier = 1.f;
|
||||
static float g_sharpeningValue = 1.f;
|
||||
@@ -51,7 +52,8 @@ static uint8_t* PSNCheckaddress = nullptr;
|
||||
static SafetyHookMid FOVHook{};
|
||||
static SafetyHookMid CameraHook{};
|
||||
static SafetyHookMid UWHook{};
|
||||
static SafetyHookMid HUDHook{};
|
||||
static SafetyHookMid HUD1Hook{};
|
||||
static SafetyHookMid HUD2Hook{};
|
||||
static SafetyHookMid VignetteHook{};
|
||||
static SafetyHookMid SharpeningHook{};
|
||||
|
||||
@@ -83,7 +85,6 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
constexpr auto PSNCheckStringObfuscated = make_obfuscated<0x8A>("E8 ?? ?? ?? ?? 48 89 ?? ?? ?? ?? ?? ?? 48 81 ?? ?? ?? ?? ?? E9 ?? ?? ?? ?? 0F 8A ?? ?? ?? ?? EB");
|
||||
|
||||
using AOBScan::Make;
|
||||
using OffsetScan::Make;
|
||||
// Prepare all data for scanning
|
||||
std::vector<AOBScanEntry> signatures = {
|
||||
Make(&FOVaddress, FOVStringObfuscated, "FOV"),
|
||||
@@ -117,6 +118,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
DOFFixEnabled();
|
||||
VignetteFixEnabled();
|
||||
SharpeningFixEnabled();
|
||||
bForceHUDRedraw = true;
|
||||
}
|
||||
|
||||
// Setters for Reshade addon call
|
||||
@@ -129,12 +131,16 @@ extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enable
|
||||
if (fix == GameFixes::Vignetting) { g_vignetting_fix_enabled = enabled; VignetteFixEnabled(); }
|
||||
if (fix == GameFixes::Sharpening) { g_sharpening_fix_enabled = enabled; SharpeningFixEnabled(); }
|
||||
if (fix == GameFixes::None) logger->info("------------------ User inputs ------------------");
|
||||
bForceHUDRedraw = true;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetValues(GameSetting setting, float value) {
|
||||
if (setting == GameSetting::FOV) g_AdditionalFOVValue = (int)(value);
|
||||
if (setting == GameSetting::CameraDistance) g_cameraDistanceMultiplier = value;
|
||||
if (setting == GameSetting::HUD) g_HUDOffset = (value * screenWidth) / (float)100;
|
||||
if (setting == GameSetting::HUD) {
|
||||
g_HUDOffset = (value * screenWidth) / (float)100;
|
||||
bForceHUDRedraw = true; // Force HUD to be redrawn with the new offset
|
||||
}
|
||||
if (setting == GameSetting::Sharpening) g_sharpeningValue = 1.f - value / 1.5f;
|
||||
}
|
||||
|
||||
@@ -190,24 +196,23 @@ static void UltraWideFixEnabled() {
|
||||
logger->info("Ultrawide fix {}", g_fix_enabled && g_ultrawide_fix_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
float aspect = (g_AspectRatio > 16.f / 9.f) ? 2.370370388f : 16.f / 9.f;
|
||||
static float initialHUDOffset = (1920.f - (screenHeight * aspect)) / 2.f;
|
||||
static std::vector<uint8_t> memoryOffset = {};
|
||||
static int32_t offset = 0;
|
||||
static void HUDFixEnabled() {
|
||||
if (!HUD1address || !HUD2address) return;
|
||||
if (!HUDHook) { // Hook only once
|
||||
if (memoryOffset.empty()) {
|
||||
memoryOffset = Memory::ReadBytes(HUD1address + 4, 4); // Retrieve the offset used to access the HUD
|
||||
offset = *reinterpret_cast<uint32_t*>(memoryOffset.data()); // Convert it to a usable int32 offset
|
||||
}
|
||||
HUDHook = safetyhook::create_mid(HUD1address,
|
||||
if (!HUD1Hook) { // Hook only once
|
||||
HUD1Hook = safetyhook::create_mid(HUD1address,
|
||||
[](SafetyHookContext& ctx) {
|
||||
*reinterpret_cast<float*>(ctx.rax + offset) = g_fix_enabled && g_HUD_fix_enabled ? initialHUDOffset + g_HUDOffset : initialHUDOffset;
|
||||
float desiredOffset = ctx.xmm2.f32[0];
|
||||
if (desiredOffset < 0) // Compute right and left offsets with user's selection
|
||||
ctx.xmm2.f32[0] += g_fix_enabled && g_HUD_fix_enabled ? g_HUDOffset : 0.f;
|
||||
else ctx.xmm2.f32[0] -= g_fix_enabled && g_HUD_fix_enabled ? g_HUDOffset : 0.f;
|
||||
});
|
||||
}
|
||||
if (!HUD2Hook) { // Hook only once
|
||||
HUD2Hook = safetyhook::create_mid(HUD2address,
|
||||
[](SafetyHookContext& ctx) { // Force PF flag to 1 to redraw the HUD with the new offset only once per user input
|
||||
if (bForceHUDRedraw.exchange(false)) ctx.rflags |= (1 << 2);
|
||||
});
|
||||
}
|
||||
Memory::PatchBytes(HUD1address + 0x19, "\x90\x90\x90\x90\x90\x90\x90\x90", 8); // Prevent rax+0xD0 from being overridden
|
||||
Memory::PatchBytes(HUD2address, "\xEB", 1); // Force the engine to reapply the new HUD position every frame
|
||||
|
||||
logger->info("HUD fix {}", g_fix_enabled && g_HUD_fix_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
@@ -268,7 +273,7 @@ static void DOFFixEnabled() {
|
||||
logger->info("Depth of field fix {}", g_fix_enabled && g_DOF_fix_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
static void PSNCheckRemoval() {
|
||||
static void PSNCheckRemoval() { // Only for internal use
|
||||
if (!PSNCheckaddress) return;
|
||||
Memory::PatchBytes(PSNCheckaddress, "\x31\xC0\x90\x90\x90", 5); //
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user