diff --git a/Metal Gear Solid Delta/dllmain.cpp b/Metal Gear Solid Delta/dllmain.cpp index 8dac399..9e4dde8 100644 --- a/Metal Gear Solid Delta/dllmain.cpp +++ b/Metal Gear Solid Delta/dllmain.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "SDK/Basic.hpp" #include "SDK/Engine_classes.hpp" @@ -20,6 +21,9 @@ const float baseAspect = 1.777777791; // Logger std::shared_ptr logger; +// UE console +static bool consoleCreated = false; + // Screen informations static int screenWidth = GetSystemMetrics(SM_CXSCREEN); static int screenHeight = GetSystemMetrics(SM_CYSCREEN); @@ -77,6 +81,7 @@ static void DOFFixEnabled(bool fix_enabled); static void CAFixEnabled(bool fix_enabled); static void VignettingFixEnabled(bool fix_enabled); static void FogFixEnabled(bool fix_enabled); +static void EnableConsole(); uint8_t* basePtr = reinterpret_cast(GetModuleHandleA(nullptr)); @@ -266,6 +271,8 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) if (Fogaddress) FogFixEnabled(false); logger->info("All fixes disabled."); } + if (AOBScanDone) + EnableConsole(); } // Setters for Reshade addon calls @@ -350,6 +357,7 @@ static void FOVFixEnabled(bool fix_enabled) { }); } else FOVHook.enable(); + logger->info("FOV fix enabled"); } if (!fix_enabled) { @@ -413,9 +421,11 @@ static void AspectFixEnabled(bool fix_enabled) { auto obj = reinterpret_cast(ctx.rbx); constexpr auto PauseBackScreenStringObfuscated = make_obfuscated<0x4A>("WP_PauseBackScreen"); - const char* pauseBackScreen = PauseBackScreenStringObfuscated.decrypt().c_str(); - - if (obj->GetName().contains(pauseBackScreen)) + auto decrypted = PauseBackScreenStringObfuscated.decrypt(); + if (!decrypted.empty() && decrypted.back() == '\0') + decrypted.pop_back(); + + if (obj->GetName().find(decrypted) != std::string::npos) ctx.xmm0.f64[0] = static_cast(aspectRatio); }); } @@ -475,6 +485,38 @@ static void FogFixEnabled(bool fix_enabled) { } } +// UE Console creation +static void EnableConsole() +{ + std::thread([&]() { + UEngine* Engine = nullptr; + + for (int i = 0; i < 100; ++i) { // gives 10 seconds to recreate console + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + Engine = UEngine::GetEngine(); + + if (Engine && Engine->ConsoleClass && Engine->GameViewport) + break; + } + if (!Engine || !Engine->ConsoleClass || !Engine->GameViewport) + return; + + /* Creates a new UObject of class-type specified by Engine->ConsoleClass */ + UObject* NewObject = UGameplayStatics::SpawnObject(Engine->ConsoleClass, Engine->GameViewport); + if (NewObject) + { + // Set the console viewport so that it will be displayed + Engine->GameViewport->ViewportConsole = static_cast(NewObject); + // Set the all the console shortkey to F8 + for (int i = 0; i < UInputSettings::GetDefaultObj()->ConsoleKeys.Num(); i++) + { + UInputSettings::GetDefaultObj()->ConsoleKeys[i].KeyName = UKismetStringLibrary::Conv_StringToName(L"F8"); + } + } + }).detach(); +} + +// Logging static void InitializeLogger() { try