Code refactoring
This commit is contained in:
@@ -7,11 +7,13 @@
|
|||||||
#include "Memory.hpp"
|
#include "Memory.hpp"
|
||||||
#include "Maths.hpp"
|
#include "Maths.hpp"
|
||||||
#include "UEngine.hpp"
|
#include "UEngine.hpp"
|
||||||
|
#include "UEMath.hpp"
|
||||||
#include "SDK/Basic.hpp"
|
#include "SDK/Basic.hpp"
|
||||||
#include "SDK/Engine_classes.hpp"
|
#include "SDK/Engine_classes.hpp"
|
||||||
#include "SDK/Phoenix_classes.hpp"
|
#include "SDK/Phoenix_classes.hpp"
|
||||||
|
|
||||||
using namespace SDK;
|
using namespace SDK;
|
||||||
|
using namespace UEMath;
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const std::string PLUGIN_NAME = "TheCallistoProtocol";
|
const std::string PLUGIN_NAME = "TheCallistoProtocol";
|
||||||
@@ -119,88 +121,33 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
|||||||
{
|
{
|
||||||
g_fix_enabled = enabled;
|
g_fix_enabled = enabled;
|
||||||
if (g_fix_enabled && !AOBScanDone) { // Unreal Engine 4.27.2
|
if (g_fix_enabled && !AOBScanDone) { // Unreal Engine 4.27.2
|
||||||
|
uint8_t* baseModule = reinterpret_cast<uint8_t*>(GetModuleHandleA(nullptr)); // Get game base address
|
||||||
logger->info("--------------- AOB scan started ---------------");
|
logger->info("--------------- AOB scan started ---------------");
|
||||||
if (!FOVaddress) {
|
|
||||||
constexpr auto FOVStringObfuscated = make_obfuscated<0x4A>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B");
|
|
||||||
FOVaddress = Memory::AOBScan("", FOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ, logger);
|
|
||||||
|
|
||||||
if (!FOVaddress)
|
using AOBScan::Make;
|
||||||
logger->warn("FOV signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
using OffsetScan::Make;
|
||||||
else {
|
|
||||||
logger->info("FOV signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(FOVaddress));
|
|
||||||
ConstrainAspectaddress = FOVaddress + 0x25;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Cameraaddress) {
|
constexpr auto FOVStringObfuscated = make_obfuscated<0x4A>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B");
|
||||||
constexpr auto CameraStringObfuscated = make_obfuscated<0x4A>("49 8B ?? ?? ?? ?? ?? 48 ?? ?? 74 ?? 48 8D ?? ?? ?? E8 ?? ?? ?? ?? 49 8B ?? ?? ?? ?? ?? EB");
|
constexpr auto CameraStringObfuscated = make_obfuscated<0x2F>("49 8B ?? ?? ?? ?? ?? 48 ?? ?? 74 ?? 48 8D ?? ?? ?? E8 ?? ?? ?? ?? 49 8B ?? ?? ?? ?? ?? EB");
|
||||||
Cameraaddress = Memory::AOBScan("", CameraStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
constexpr auto BenchMarkStringObfuscated = make_obfuscated<0xC3>("88 86 58 03 ?? ?? 48 8B ?? ?? ?? 48 83 ?? ?? 5F C3");
|
||||||
|
constexpr auto HUDStringObfuscated = make_obfuscated<0x8A>("FF ?? 48 8B ?? ?? ?? 0F ?? ?? 48 ?? ?? 0F ?? ?? 48 83");
|
||||||
if (!Cameraaddress)
|
constexpr auto CAStringObfuscated = make_obfuscated<0xFC>("7F ?? 89 B3 ?? ?? ?? ?? 8B ?? ?? 39 05 ?? ?? ?? ?? 0F");
|
||||||
logger->warn("Camera signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
constexpr auto VignettingStringObfuscated = make_obfuscated<0x97>("8B ?? 83 ?? ?? 7D ?? 89 B3");
|
||||||
else
|
constexpr auto FogStringObfuscated = make_obfuscated<0x46>("83 ?? ?? ?? 75 ?? B3 ?? EB ?? 32 ?? 48 8B ?? ?? ?? 48 ?? ?? 74 ?? E8");
|
||||||
logger->info("Camera signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Cameraaddress));
|
constexpr auto WorldTimeDilationStringObfuscated = make_obfuscated<0x6E>("F3 0F 10 ?? ?? ?? ?? ?? F3 0F 10 ?? ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? C3");
|
||||||
}
|
// Prepare all data for scanning
|
||||||
|
std::vector<AOBScanEntry> signatures = {
|
||||||
if (!SetBenchmarkModeaddress) {
|
Make(&FOVaddress, FOVStringObfuscated, "FOV"),
|
||||||
constexpr auto BenchMarkStringObfuscated = make_obfuscated<0x4A>("88 86 58 03 ?? ?? 48 8B ?? ?? ?? 48 83 ?? ?? 5F C3");
|
Make(&Cameraaddress, CameraStringObfuscated, "Camera"),
|
||||||
SetBenchmarkModeaddress = Memory::AOBScan("", BenchMarkStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
Make(&SetBenchmarkModeaddress, BenchMarkStringObfuscated, "Set Benchmark mode"),
|
||||||
|
Make(&HUDaddress, HUDStringObfuscated, "HUD"),
|
||||||
if (!SetBenchmarkModeaddress)
|
Make(&CAaddress, CAStringObfuscated, "Chromatic aberrations"),
|
||||||
logger->warn("Set BenchMark mode signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
Make(&Vignettingaddress, VignettingStringObfuscated, "Vignetting"),
|
||||||
else
|
Make(&Fogaddress, FogStringObfuscated, "Fog"),
|
||||||
logger->info("Set BenchMark mode signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(SetBenchmarkModeaddress));
|
Make(&WorldTimedilationaddress, WorldTimeDilationStringObfuscated, "World time dilation")
|
||||||
}
|
};
|
||||||
|
// Scan all signature in a batch
|
||||||
if (!HUDaddress) {
|
Memory::AOBScanBatch(signatures, logger);
|
||||||
constexpr auto HUDStringObfuscated = make_obfuscated<0x4A>("FF ?? 48 8B ?? ?? ?? 0F ?? ?? 48 ?? ?? 0F ?? ?? 48 83");
|
|
||||||
HUDaddress = Memory::AOBScan("", HUDStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
|
||||||
|
|
||||||
if (!HUDaddress)
|
|
||||||
logger->warn("HUD signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
|
||||||
else
|
|
||||||
logger->info("HUD signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(HUDaddress));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CAaddress) {
|
|
||||||
constexpr auto CAStringObfuscated = make_obfuscated<0x4A>("7F ?? 89 B3 ?? ?? ?? ?? 8B ?? ?? 39 05 ?? ?? ?? ?? 0F");
|
|
||||||
CAaddress = Memory::AOBScan("", CAStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
|
||||||
|
|
||||||
if (!CAaddress)
|
|
||||||
logger->warn("Chromatic aberrations signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
|
||||||
else
|
|
||||||
logger->info("Chromatic aberrations signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(CAaddress));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Vignettingaddress) {
|
|
||||||
constexpr auto VignettingStringObfuscated = make_obfuscated<0x4A>("8B ?? 83 ?? ?? 7D ?? 89 B3");
|
|
||||||
Vignettingaddress = Memory::AOBScan("", VignettingStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
|
||||||
|
|
||||||
if (!Vignettingaddress)
|
|
||||||
logger->warn("Vignetting signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
|
||||||
else
|
|
||||||
logger->info("Vignetting signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Vignettingaddress));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Fogaddress) {
|
|
||||||
constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("83 ?? ?? ?? 75 ?? B3 ?? EB ?? 32 ?? 48 8B ?? ?? ?? 48 ?? ?? 74 ?? E8");
|
|
||||||
Fogaddress = Memory::AOBScan("", FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
|
||||||
|
|
||||||
if (!Fogaddress)
|
|
||||||
logger->warn("Fog signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
|
||||||
else
|
|
||||||
logger->info("Fog signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Fogaddress));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!WorldTimedilationaddress) {
|
|
||||||
constexpr auto WorldTimeDilationStringObfuscated = make_obfuscated<0x4A>("F3 0F 10 ?? ?? ?? ?? ?? F3 0F 10 ?? ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? C3");
|
|
||||||
WorldTimedilationaddress = Memory::AOBScan("", WorldTimeDilationStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
|
||||||
|
|
||||||
if (!WorldTimedilationaddress)
|
|
||||||
logger->warn("World time dilation signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
|
||||||
else
|
|
||||||
logger->info("World time dilation signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(WorldTimedilationaddress));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FOVaddress && Cameraaddress && SetBenchmarkModeaddress && HUDaddress &&
|
if (FOVaddress && Cameraaddress && SetBenchmarkModeaddress && HUDaddress &&
|
||||||
CAaddress && Vignettingaddress && Fogaddress && WorldTimedilationaddress)
|
CAaddress && Vignettingaddress && Fogaddress && WorldTimedilationaddress)
|
||||||
@@ -210,55 +157,22 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
|||||||
|
|
||||||
if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
|
if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
|
||||||
logger->info("------------ UEngine offsets search ------------");
|
logger->info("------------ UEngine offsets search ------------");
|
||||||
uint8_t* baseModule = reinterpret_cast<uint8_t*>(GetModuleHandleA(nullptr)); // Get game base address
|
|
||||||
|
|
||||||
constexpr auto GWorldStringObfuscated = make_obfuscated<0x4A>("48 8B ?? ?? ?? ?? ?? 48 ?? ?? 74 ?? 48 ?? ?? E8 ?? ?? ?? ?? 83 ?? ?? 74");
|
constexpr auto GWorldStringObfuscated = make_obfuscated<0xCA>("48 8B ?? ?? ?? ?? ?? 48 ?? ?? 74 ?? 48 ?? ?? E8 ?? ?? ?? ?? 83 ?? ?? 74");
|
||||||
GWorldaddress = Memory::AOBScan("", GWorldStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
constexpr auto GObjetcsStringObfuscated = make_obfuscated<0x87>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33");
|
||||||
constexpr auto GObjetcsStringObfuscated = make_obfuscated<0x4A>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33");
|
constexpr auto AppendStringStringObfuscated = make_obfuscated<0x32>("48 89 ?? ?? ?? 48 89 ?? ?? ?? 57 48 ?? ?? ?? 8B ?? 48 ?? ?? 8B ?? 44 ?? ?? ?? C1 ?? ?? 48 ?? ?? 80 3D ?? ?? ?? ?? ?? 89 ?? ?? ?? 44 89 ?? ?? ?? 74 ?? 4C 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 4C ?? ?? C6 05 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? 48 ?? ?? 48 ?? ?? ?? 8D ?? ?? 49 03 ?? ?? ?? E8 ?? ?? ?? ?? 83");
|
||||||
GObjectsaddress = Memory::AOBScan("", GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
constexpr auto ProcessEventStringObfuscated = make_obfuscated<0xAC>("40 ?? 56 57 41 ?? 41 ?? 41 ?? 41 ?? 48 81 ?? ?? ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? ?? ?? 8B");
|
||||||
constexpr auto AppendStringStringObfuscated = make_obfuscated<0x4A>("48 89 ?? ?? ?? 48 89 ?? ?? ?? 57 48 ?? ?? ?? 8B ?? 48 ?? ?? 8B ?? 44 ?? ?? ?? C1 ?? ?? 48 ?? ?? 80 3D ?? ?? ?? ?? ?? 89 ?? ?? ?? 44 89 ?? ?? ?? 74 ?? 4C 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 4C ?? ?? C6 05 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? 48 ?? ?? 48 ?? ?? ?? 8D ?? ?? 49 03 ?? ?? ?? E8 ?? ?? ?? ?? 83");
|
// Prepare all data for scanning
|
||||||
AppendStringaddress = Memory::AOBScan("", AppendStringStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
std::vector<OffsetScanEntry> UEoffsetsScans = {
|
||||||
constexpr auto ProcessEventStringObfuscated = make_obfuscated<0x4A>("40 ?? 56 57 41 ?? 41 ?? 41 ?? 41 ?? 48 81 ?? ?? ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? ?? ?? 8B");
|
Make(&GWorldaddress, GWorldStringObfuscated, "GWorld", OffsetCalcType::GetOffsetFromOpcode, &Offsets::GWorld, 0x3),
|
||||||
ProcessEventaddress = Memory::AOBScan("", ProcessEventStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
Make(&GObjectsaddress, GObjetcsStringObfuscated, "GObjects", OffsetCalcType::GetOffsetFromOpcode, &Offsets::GObjects, 0x3),
|
||||||
|
Make(&AppendStringaddress, AppendStringStringObfuscated, "AppendString", OffsetCalcType::UE_CalculateOffset, &Offsets::AppendString),
|
||||||
|
Make(&ProcessEventaddress, ProcessEventStringObfuscated, "ProcessEvent", OffsetCalcType::UE_CalculateOffset, &Offsets::ProcessEvent)
|
||||||
|
};
|
||||||
|
// Retrieve all Unreal Engine offsets in a batch
|
||||||
|
Memory::OffsetScanBatch(UEoffsetsScans, baseModule, logger, "");
|
||||||
|
|
||||||
if (!GWorldaddress)
|
if (!init) logger->info("-------------- Fixes initialisation -------------");
|
||||||
logger->warn("GWorld signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
|
||||||
else {
|
|
||||||
uint32_t gWorldOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GWorldaddress + 0x3) -
|
|
||||||
baseModule);
|
|
||||||
logger->info("GWorld offset is: 0x{:X}.", gWorldOffset);
|
|
||||||
Offsets::GWorld = static_cast<UC::uint32>(gWorldOffset); // Update GWorld offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!GObjectsaddress)
|
|
||||||
logger->warn("GObjects signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
|
||||||
else {
|
|
||||||
uint32_t gObjectsOffset = static_cast<uint32_t>(Memory::GetOffsetFromOpcode(GObjectsaddress + 0x3) -
|
|
||||||
baseModule);
|
|
||||||
logger->info("GObjects offset is: 0x{:X}.", gObjectsOffset);
|
|
||||||
Offsets::GObjects = static_cast<UC::uint32>(gObjectsOffset); // Update GObjects offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!AppendStringaddress)
|
|
||||||
logger->warn("AppendString signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
|
||||||
else {
|
|
||||||
std::optional<uint32_t> gAppendStringOffsetOpt = UE::CalculateOffset("", AppendStringaddress); // Get Offset from opcode
|
|
||||||
uint32_t gAppendStringOffset = *gAppendStringOffsetOpt;
|
|
||||||
logger->info("AppendString offset is: 0x{:X}.", gAppendStringOffset);
|
|
||||||
Offsets::AppendString = static_cast<UC::uint32>(gAppendStringOffset); // Update AppendString offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ProcessEventaddress)
|
|
||||||
logger->warn("Process Event signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
|
|
||||||
else {
|
|
||||||
std::optional<uint32_t> gProcessEventOffsetOpt = UE::CalculateOffset("", ProcessEventaddress);
|
|
||||||
uint32_t gProcessEventOffset = *gProcessEventOffsetOpt;
|
|
||||||
logger->info("Process Event offset is: 0x{:X}.", gProcessEventOffset);
|
|
||||||
Offsets::ProcessEvent = static_cast<UC::uint32>(gProcessEventOffset);// Update ProcessEvent offset
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!init)
|
|
||||||
logger->info("-------------- Fixes initialisation -------------");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +186,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
|
|||||||
if (!init && Fogaddress) FogFixEnabled();
|
if (!init && Fogaddress) FogFixEnabled();
|
||||||
if (!init && WorldTimedilationaddress) TimeDilation();
|
if (!init && WorldTimedilationaddress) TimeDilation();
|
||||||
if (!init && GObjectsaddress && AppendStringaddress && ProcessEventaddress) EnableConsole();
|
if (!init && GObjectsaddress && AppendStringaddress && ProcessEventaddress) EnableConsole();
|
||||||
if (ConstrainAspectaddress) UltraWideFixEnabled();
|
if (FOVaddress) UltraWideFixEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setters for Reshade addon call
|
// Setters for Reshade addon call
|
||||||
@@ -314,25 +228,6 @@ extern "C" __declspec(dllexport) void SetCameraSmoothness(float smoothness) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unreal Engine functions
|
// Unreal Engine functions
|
||||||
/**
|
|
||||||
* @brief Converts a rotator (Pitch, Yaw) to a forward direction vector.
|
|
||||||
* Computes a normalized forward vector from the given FRotator,
|
|
||||||
* using Pitch and Yaw angles (in degrees).
|
|
||||||
* @param rotator Input rotation (degrees).
|
|
||||||
* @return Forward direction vector.
|
|
||||||
*/
|
|
||||||
static FVector RotatorToForwardVector(const FRotator& rotator)
|
|
||||||
{
|
|
||||||
const float DEG_TO_RAD = 3.1415926535f / 180.0f;
|
|
||||||
|
|
||||||
float cp = cosf(rotator.Pitch * DEG_TO_RAD);
|
|
||||||
float sp = sinf(rotator.Pitch * DEG_TO_RAD);
|
|
||||||
float cy = cosf(rotator.Yaw * DEG_TO_RAD);
|
|
||||||
float sy = sinf(rotator.Yaw * DEG_TO_RAD);
|
|
||||||
|
|
||||||
return FVector(cp * cy, cp * sy, sp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the current player Pawn from the world.
|
* @brief Gets the current player Pawn from the world.
|
||||||
* @param world Optional UWorld pointer.
|
* @param world Optional UWorld pointer.
|
||||||
@@ -450,8 +345,10 @@ static void CameraFixEnabled() {
|
|||||||
FVector pawnPos = pawn->K2_GetActorLocation();
|
FVector pawnPos = pawn->K2_GetActorLocation();
|
||||||
FVector engineCamPos = cameraParams->ViewLocation;
|
FVector engineCamPos = cameraParams->ViewLocation;
|
||||||
// --- Camera direction ---
|
// --- Camera direction ---
|
||||||
FVector forward = RotatorToForwardVector(cameraParams->ViewRotation);
|
Vector forward = RotatorToForwardVector(*reinterpret_cast<Rotator*>(&cameraParams->ViewRotation));
|
||||||
FVector backward = forward * -1.f;
|
// Transform own vector into UE SDK vector
|
||||||
|
FVector forwardVector { forward.X , forward.Y, forward.Z };
|
||||||
|
FVector backward = forwardVector * -1.f;
|
||||||
// --- ENGINE OFFSET (full) ---
|
// --- ENGINE OFFSET (full) ---
|
||||||
FVector engineOffset = engineCamPos - pawnPos;
|
FVector engineOffset = engineCamPos - pawnPos;
|
||||||
// --- DECOMPOSE OFFSET ---
|
// --- DECOMPOSE OFFSET ---
|
||||||
@@ -459,12 +356,11 @@ static void CameraFixEnabled() {
|
|||||||
float engineBackDist = engineOffset.Dot(backward);
|
float engineBackDist = engineOffset.Dot(backward);
|
||||||
g_NativeCameraDistance = engineBackDist;
|
g_NativeCameraDistance = engineBackDist;
|
||||||
FVector backComponent = backward * engineBackDist;
|
FVector backComponent = backward * engineBackDist;
|
||||||
|
// No need to set camera offset in these modes
|
||||||
if (bIsInBenchmarkMode || bIsInCinematicMode || bIsAiming) return;
|
if (bIsInBenchmarkMode || bIsInCinematicMode || bIsAiming) return;
|
||||||
|
|
||||||
// What we KEEP (height + lateral)
|
// What we KEEP (height + lateral)
|
||||||
FVector preservedOffset = engineOffset - backComponent;
|
FVector preservedOffset = engineOffset - backComponent;
|
||||||
|
|
||||||
// --- Desired corrected distance ---
|
// --- Desired corrected distance ---
|
||||||
float maxDistance = g_TransitionCameraOffset;
|
float maxDistance = g_TransitionCameraOffset;
|
||||||
FVector traceStart = pawnPos /*+ preservedOffset*/;
|
FVector traceStart = pawnPos /*+ preservedOffset*/;
|
||||||
@@ -476,16 +372,11 @@ static void CameraFixEnabled() {
|
|||||||
float radius = 12.f;
|
float radius = 12.f;
|
||||||
|
|
||||||
bool bHit = UKismetSystemLibrary::SphereTraceMulti(
|
bool bHit = UKismetSystemLibrary::SphereTraceMulti(
|
||||||
object,
|
object, traceStart, traceEnd, radius,
|
||||||
traceStart,
|
|
||||||
traceEnd,
|
|
||||||
radius,
|
|
||||||
ETraceTypeQuery::TraceTypeQuery2, // camera channel
|
ETraceTypeQuery::TraceTypeQuery2, // camera channel
|
||||||
true,
|
true, ignoreActors,
|
||||||
ignoreActors,
|
|
||||||
EDrawDebugTrace::None,
|
EDrawDebugTrace::None,
|
||||||
&hits,
|
&hits, true,
|
||||||
true,
|
|
||||||
FLinearColor(1, 0, 0, 1),
|
FLinearColor(1, 0, 0, 1),
|
||||||
FLinearColor(0, 1, 0, 1),
|
FLinearColor(0, 1, 0, 1),
|
||||||
0.f);
|
0.f);
|
||||||
@@ -493,13 +384,11 @@ static void CameraFixEnabled() {
|
|||||||
// --- Compute target distance ---
|
// --- Compute target distance ---
|
||||||
float targetDist = maxDistance;
|
float targetDist = maxDistance;
|
||||||
|
|
||||||
if (bHit && hits.Num() > 0)
|
if (bHit && hits.Num() > 0) {
|
||||||
{
|
|
||||||
float best = maxDistance;
|
float best = maxDistance;
|
||||||
float padding = 15.f;
|
float padding = 15.f;
|
||||||
|
|
||||||
for (const FHitResult& hit : hits)
|
for (const FHitResult& hit : hits) {
|
||||||
{
|
|
||||||
if (hit.bStartPenetrating) continue;
|
if (hit.bStartPenetrating) continue;
|
||||||
if (hit.PenetrationDepth > 2.f) continue;
|
if (hit.PenetrationDepth > 2.f) continue;
|
||||||
|
|
||||||
@@ -522,8 +411,7 @@ static void CameraFixEnabled() {
|
|||||||
lastSafeDistance = std::clamp(lastSafeDistance, 0.f, maxDistance);
|
lastSafeDistance = std::clamp(lastSafeDistance, 0.f, maxDistance);
|
||||||
|
|
||||||
// --- FINAL CAMERA POSITION ---
|
// --- FINAL CAMERA POSITION ---
|
||||||
FVector finalCamPos = pawnPos + preservedOffset +
|
FVector finalCamPos = pawnPos + preservedOffset + backward * lastSafeDistance;
|
||||||
backward * lastSafeDistance;
|
|
||||||
|
|
||||||
if (!world->K2_GetWorldSettings()) return;
|
if (!world->K2_GetWorldSettings()) return;
|
||||||
// --- APPLY ---
|
// --- APPLY ---
|
||||||
@@ -550,8 +438,7 @@ static void CameraFixEnabled() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float dt = g_LastCameraDeltaTime;
|
float dt = g_LastCameraDeltaTime;
|
||||||
// Secure
|
if (dt <= 0.f || dt > 0.1f) dt = 1.f / 60.f; // Secure
|
||||||
if (dt <= 0.f || dt > 0.1f) dt = 1.f / 60.f;
|
|
||||||
|
|
||||||
float targetOffset = g_CameraOffset;
|
float targetOffset = g_CameraOffset;
|
||||||
if (bIsInCinematicMode || bIsAiming) targetOffset = g_NativeCameraDistance;
|
if (bIsInCinematicMode || bIsAiming) targetOffset = g_NativeCameraDistance;
|
||||||
@@ -641,10 +528,25 @@ static void TimeDilation() {
|
|||||||
logger->info("Time dilation fix disabled");
|
logger->info("Time dilation fix disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void FogFixEnabled() {
|
||||||
|
if (g_fix_enabled && g_Fog_fix_enabled && Fogaddress) {
|
||||||
|
if (!FogHook) {
|
||||||
|
FogHook = safetyhook::create_mid(Fogaddress,
|
||||||
|
[](SafetyHookContext& ctx) {
|
||||||
|
if (!ctx.rax) return;
|
||||||
|
*reinterpret_cast<uint8_t*>(ctx.rax + 0x4) = g_fix_enabled && g_Fog_fix_enabled ? 0 : 1; // r.Fog = 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
logger->info("Fog fix enabled");
|
||||||
|
}
|
||||||
|
if (!(g_fix_enabled && g_Fog_fix_enabled) && Fogaddress)
|
||||||
|
logger->info("Fog fix disabled");
|
||||||
|
}
|
||||||
|
|
||||||
// Memory patch fixes
|
// Memory patch fixes
|
||||||
static void UltraWideFixEnabled() {
|
static void UltraWideFixEnabled() {
|
||||||
if (ConstrainAspectaddress)
|
if (FOVaddress)
|
||||||
Memory::PatchBytes(ConstrainAspectaddress, "\x31\xC0\x90\x90\x90\x90\x90", 7); // bConstrainAspectRatio = 0
|
Memory::PatchBytes(FOVaddress + 0x25, "\x31\xC0\x90\x90\x90\x90\x90", 7); // bConstrainAspectRatio = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CAFixEnabled() {
|
static void CAFixEnabled() {
|
||||||
@@ -669,21 +571,6 @@ static void VignettingFixEnabled() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FogFixEnabled() {
|
|
||||||
if (g_fix_enabled && g_Fog_fix_enabled && Fogaddress) {
|
|
||||||
if (!FogHook) {
|
|
||||||
FogHook = safetyhook::create_mid(Fogaddress,
|
|
||||||
[](SafetyHookContext& ctx) {
|
|
||||||
if (!ctx.rax) return;
|
|
||||||
*reinterpret_cast<uint8_t*>(ctx.rax + 0x4) = g_fix_enabled && g_Fog_fix_enabled ? 0 : 1; // r.Fog = 0
|
|
||||||
});
|
|
||||||
}
|
|
||||||
logger->info("Fog fix enabled");
|
|
||||||
}
|
|
||||||
if (!(g_fix_enabled && g_Fog_fix_enabled) && Fogaddress)
|
|
||||||
logger->info("Fog fix disabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
// UE Console creation
|
// UE Console creation
|
||||||
static void EnableConsole()
|
static void EnableConsole()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user