Add camera distance fix
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include "CommonHeaders.h"
|
||||
#include "inicpp.h"
|
||||
#include "UEngine.hpp"
|
||||
#include "Logger.hpp"
|
||||
|
||||
@@ -21,25 +20,31 @@ static bool AOBScanDone = false;
|
||||
static std::atomic<bool> g_fix_enabled = false;
|
||||
static std::atomic<bool> g_fov_fix_enabled = false;
|
||||
static std::atomic<bool> g_ultrawide_fix_enabled = false;
|
||||
static std::atomic<bool> g_camera_fix_enabled = false;
|
||||
static int g_AdditionalFOVValue = 0;
|
||||
static float g_cameraDistanceMultiplier = 1.f;
|
||||
|
||||
// Shared values
|
||||
static float g_FOV_In = 80.f;
|
||||
static float g_CompensatedFOV = 80.f;
|
||||
static float g_FOV_Out = 80.f;
|
||||
static float g_Camera_In = 3.f;
|
||||
static float g_Camera_Out = 3.f;
|
||||
|
||||
// AOB Scan pointers
|
||||
static uint8_t* FOVaddress = nullptr;
|
||||
static uint8_t* Ultrawideaddress = nullptr;
|
||||
static uint8_t* Cutscenesaddress = nullptr;
|
||||
static uint8_t* Cameraaddress = nullptr;
|
||||
|
||||
// Hooking
|
||||
static SafetyHookMid FOVHook{};
|
||||
static SafetyHookMid CameraHook{};
|
||||
static SafetyHookMid UWHook{};
|
||||
|
||||
// Prototypes
|
||||
static void FOVFixEnabled();
|
||||
static void UltraWideFixEnabled();
|
||||
static void CameraFixEnabled();
|
||||
|
||||
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
//return;
|
||||
@@ -49,6 +54,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
constexpr auto FOVStringObfuscated = make_obfuscated<0xFA>("C5 F8 ?? ?? ?? ?? C5 F8 ?? ?? ?? ?? C5 78 ?? ?? ?? ?? C5 FA ?? ?? C5 F2 59 ?? ?? ?? ?? ?? 48 83 ?? ?? C3"); // +0x1e
|
||||
constexpr auto AspectStringObfuscated = make_obfuscated<0x8B>("C5 FA 10 ?? ?? C5 F2 ?? ?? C5 CA ?? ?? E9 ?? ?? ?? ?? C5 FA 10 ?? ?? ?? ?? ?? C5");
|
||||
constexpr auto AspectCutscenesStringObfuscated = make_obfuscated<0x9D>("0F 84 ?? ?? ?? ?? 49 8B 9D ?? ?? ?? ?? 49 63 85 ?? ?? ?? ?? 48 6B ?? ?? 48 ?? ?? 48 ?? ?? 0F 84");
|
||||
constexpr auto CameraStringObfuscated = make_obfuscated<0x84>("C5 FA 10 ?? ?? ?? ?? ?? 40 38 ?? ?? ?? ?? ?? 0F 84 ?? ?? ?? ?? C5 FA 10");
|
||||
|
||||
using AOBScan::Make;
|
||||
using OffsetScan::Make;
|
||||
@@ -57,28 +63,32 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
Make(&FOVaddress, FOVStringObfuscated, "FOV"),
|
||||
Make(&Ultrawideaddress, AspectStringObfuscated, "Ultrawide"),
|
||||
Make(&Cutscenesaddress, AspectCutscenesStringObfuscated, "Cutscenes"),
|
||||
Make(&Cameraaddress, CameraStringObfuscated, "Camera"),
|
||||
};
|
||||
// Scan all signature in a batch
|
||||
Memory::AOBScanBatch(signatures, logger);
|
||||
if (FOVaddress && Ultrawideaddress && Cutscenesaddress)
|
||||
if (FOVaddress && Ultrawideaddress && Cutscenesaddress && Cameraaddress)
|
||||
logger->info("All AOB signatures found. Ready to patch...");
|
||||
|
||||
logger->info("-------------- Fixes initialisation -------------");
|
||||
AOBScanDone = true;
|
||||
}
|
||||
|
||||
if (!init && Ultrawideaddress) FOVFixEnabled();
|
||||
if (!init && FOVaddress) FOVFixEnabled();
|
||||
if (!init && Ultrawideaddress) UltraWideFixEnabled();
|
||||
if (!init && Cameraaddress) CameraFixEnabled();
|
||||
}
|
||||
|
||||
// Setters for Reshade addon call
|
||||
extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enabled) { // Set each fix individually
|
||||
if (fix == GameFixes::FOV) { g_fov_fix_enabled = enabled; FOVFixEnabled(); }
|
||||
if (fix == GameFixes::UltraWide) { g_ultrawide_fix_enabled = enabled; UltraWideFixEnabled(); }
|
||||
if (fix == GameFixes::Camera) { g_camera_fix_enabled = enabled; CameraFixEnabled(); }
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
// Getters for Reshade addon call
|
||||
extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) {
|
||||
@@ -86,6 +96,8 @@ extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) {
|
||||
|
||||
infos->FOVIn = g_FOV_In;
|
||||
infos->FOVOut = g_FOV_Out;
|
||||
infos->cameraIn = g_Camera_In;
|
||||
infos->cameraOut = g_Camera_Out;
|
||||
infos->screenWidth = screenWidth;
|
||||
infos->screenHeight = screenHeight;
|
||||
infos->aspectRatio = (float)screenWidth / screenHeight;
|
||||
@@ -133,6 +145,24 @@ static void UltraWideFixEnabled() {
|
||||
logger->info("Ultrawide fix {}", g_fix_enabled && g_ultrawide_fix_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
static void CameraFixEnabled() {
|
||||
if (!Cameraaddress) return;
|
||||
if (g_fix_enabled && g_camera_fix_enabled) {
|
||||
if (!CameraHook) {
|
||||
CameraHook = safetyhook::create_mid(Cameraaddress + 0x8,
|
||||
[](SafetyHookContext& ctx) {
|
||||
g_Camera_In = ctx.xmm0.f32[0];
|
||||
ctx.xmm0.f32[0] *= g_cameraDistanceMultiplier;;
|
||||
g_Camera_Out = ctx.xmm0.f32[0];
|
||||
});
|
||||
}
|
||||
else CameraHook.enable();
|
||||
}
|
||||
else if (CameraHook) CameraHook.disable();
|
||||
|
||||
logger->info("Camera fix {}", g_fix_enabled && g_camera_fix_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
// Standard dll entry
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID) {
|
||||
if (reason == DLL_PROCESS_ATTACH) {
|
||||
|
||||
Reference in New Issue
Block a user