Add unique function to retrieve game informations

This commit is contained in:
2025-09-29 11:58:57 +02:00
parent 3216bf016d
commit 3ed6f16964

View File

@@ -3,6 +3,7 @@
#include <spdlog/sinks/rotating_file_sink.h> #include <spdlog/sinks/rotating_file_sink.h>
#include <filesystem> #include <filesystem>
#include <safetyhook.hpp> #include <safetyhook.hpp>
#include "GameInformations.h"
#include "ObfuscateString.h" #include "ObfuscateString.h"
#include "Memory.hpp"; #include "Memory.hpp";
#include "Maths.hpp"; #include "Maths.hpp";
@@ -21,11 +22,6 @@ const float BASE_ASPECT = 1.777777791;
// Logger // Logger
std::shared_ptr<spdlog::logger> logger; std::shared_ptr<spdlog::logger> logger;
// Screen informations
static int screenWidth = GetSystemMetrics(SM_CXSCREEN);
static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
static float aspectRatio = (float)screenWidth / screenHeight;
// Plugin states // Plugin states
static bool AOBScanDone = false; static bool AOBScanDone = false;
static bool g_fix_enabled = false; static bool g_fix_enabled = false;
@@ -39,9 +35,10 @@ static int g_AdditionalFOVValue = 0;
static float g_CameraDistance = 1.f; static float g_CameraDistance = 1.f;
// Shared values // Shared values
static float g_reference_FOV = 65.f; static float g_FOV_In = 65.f;
static float g_FOV_In = 0.f; static float g_FOV_Out = 65.f;
static float g_FOV_Out = 0.f; static float g_Camera_In = 230.f;
static float g_Camera_Out = 230.f;
static bool g_Console_Enabled = false; static bool g_Console_Enabled = false;
// AOB Unreal Engine offsets addresses // AOB Unreal Engine offsets addresses
@@ -175,7 +172,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
} }
} }
if (FOVaddress && DOFaddress && CAaddress && Vignettingaddress && VolumetricFogaddress) { if (FOVaddress && Cameraaddress && DOFaddress && CAaddress && Vignettingaddress && VolumetricFogaddress) {
logger->info("All AOB signatures found. Ready to patch..."); logger->info("All AOB signatures found. Ready to patch...");
AOBScanDone = true; AOBScanDone = true;
} }
@@ -290,16 +287,14 @@ extern "C" __declspec(dllexport) void SetCameraDistance(float multiplier) {
} }
// Getters for Reshade addon call // Getters for Reshade addon call
extern "C" __declspec(dllexport) float GetFOVIn() { extern "C" __declspec(dllexport) void GetGameInfos(GameInfos* infos) {
return g_FOV_In; if (!infos) return;
}
extern "C" __declspec(dllexport) float GetFOVOut() { infos->FOVIn = g_FOV_In;
return g_FOV_Out; infos->FOVOut = g_FOV_Out;
} infos->cameraIn = g_Camera_In;
infos->cameraOut = g_Camera_Out;
extern "C" __declspec(dllexport) bool GetConsoleEnabled() { infos->consoleEnabled = g_Console_Enabled;
return g_Console_Enabled;
} }
// Code injection functions // Code injection functions
@@ -328,7 +323,9 @@ static void CameraFixEnabled() {
if (!CameraHook) { if (!CameraHook) {
CameraHook = safetyhook::create_mid(Cameraaddress, CameraHook = safetyhook::create_mid(Cameraaddress,
[](SafetyHookContext& ctx) { [](SafetyHookContext& ctx) {
g_Camera_In = ctx.xmm0.f32[0];
ctx.xmm0.f32[0] *= g_CameraDistance; ctx.xmm0.f32[0] *= g_CameraDistance;
g_Camera_Out = ctx.xmm0.f32[0];
}); });
} }
else CameraHook.enable(); else CameraHook.enable();