From 9e2b4bdd9db5bf974866993261c94f04e8b5f6a8 Mon Sep 17 00:00:00 2001 From: Alexey Date: Sat, 9 Nov 2024 16:55:04 +0300 Subject: [PATCH] [CKPE] FO4: - Fixed GetCrime: 7 element is always nullptr --- .../Core/EngineFO4Patches.cpp | 2 + ...reation Kit Platform Extended Core.vcxproj | 2 + ...Kit Platform Extended Core.vcxproj.filters | 6 + .../FO4/CrashConditionItemGetCrime.cpp | 115 ++++++++++++++++++ .../Patches/FO4/CrashConditionItemGetCrime.h | 43 +++++++ .../Version/build_version.txt | Bin 12 -> 12 bytes .../Version/resource_version2.h | Bin 2004 -> 2004 bytes .../CrashConditionItemGetCrime.relb | 5 + ...nKitPlatformExtended_FO4_1_10_162.database | Bin 41534 -> 41664 bytes .../CrashConditionItemGetCrime.relb | 5 + ...itPlatformExtended_FO4_1_10_982_3.database | Bin 25401 -> 25588 bytes 11 files changed, 178 insertions(+) create mode 100644 Creation Kit Platform Extended Core/Patches/FO4/CrashConditionItemGetCrime.cpp create mode 100644 Creation Kit Platform Extended Core/Patches/FO4/CrashConditionItemGetCrime.h create mode 100644 Database/FO4/1_10_162_0/CrashConditionItemGetCrime.relb create mode 100644 Database/FO4/1_10_982_3/CrashConditionItemGetCrime.relb diff --git a/Creation Kit Platform Extended Core/Core/EngineFO4Patches.cpp b/Creation Kit Platform Extended Core/Core/EngineFO4Patches.cpp index 93bc902..6fa4bf7 100644 --- a/Creation Kit Platform Extended Core/Core/EngineFO4Patches.cpp +++ b/Creation Kit Platform Extended Core/Core/EngineFO4Patches.cpp @@ -50,6 +50,7 @@ #include "Patches/FO4/CrashInventory.h" #include "Patches/FO4/ChooseSoundFileF4.h" #include "Patches/FO4/RunNetworkDisable.h" +#include "Patches/FO4/CrashConditionItemGetCrime.h" #include "Patches/Windows/FO4/MainWindowF4.h" #include "Patches/Windows/FO4/ObjectWindowF4.h" @@ -113,6 +114,7 @@ namespace CreationKitPlatformExtended new Patches::ChooseSoundFilePatch(), new Patches::CrashInventoryPatch(), new Patches::RunNetworkDisablePatch(), + new Patches::CrashConditionItemGetCrimePatch(), new Patches::MainWindow(), new Patches::ObjectWindow(), diff --git a/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj b/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj index 7ea307b..3b2ede5 100644 --- a/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj +++ b/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj @@ -209,6 +209,7 @@ + @@ -602,6 +603,7 @@ + diff --git a/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj.filters b/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj.filters index bd29d2f..c6c9146 100644 --- a/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj.filters +++ b/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj.filters @@ -865,6 +865,9 @@ Patches\FO4 + + Patches\FO4 + @@ -2122,6 +2125,9 @@ Patches\FO4 + + Patches\FO4 + diff --git a/Creation Kit Platform Extended Core/Patches/FO4/CrashConditionItemGetCrime.cpp b/Creation Kit Platform Extended Core/Patches/FO4/CrashConditionItemGetCrime.cpp new file mode 100644 index 0000000..41cfa6b --- /dev/null +++ b/Creation Kit Platform Extended Core/Patches/FO4/CrashConditionItemGetCrime.cpp @@ -0,0 +1,115 @@ +// Copyright © 2023-2024 aka perchik71. All rights reserved. +// Contacts: +// License: https://www.gnu.org/licenses/gpl-3.0.html + +#include "Core/Engine.h" +#include "Editor API/EditorUI.h" +#include "CrashConditionItemGetCrime.h" + +namespace CreationKitPlatformExtended +{ + namespace Patches + { + namespace Fallout4 + { + class GameSettingCollection + { + public: + // format: \x0 + char* Data; + }; + + template + class SettingT + { + public: + virtual ~SettingT() = default; + + char* Name; + GameSettingCollection Option; + }; + + SettingT** pointer_CrashConditionItemGetCrimePatch_data = nullptr; + + CrashConditionItemGetCrimePatch::CrashConditionItemGetCrimePatch() : Module(GlobalEnginePtr) + {} + + bool CrashConditionItemGetCrimePatch::HasOption() const + { + return false; + } + + bool CrashConditionItemGetCrimePatch::HasCanRuntimeDisabled() const + { + return false; + } + + const char* CrashConditionItemGetCrimePatch::GetOptionName() const + { + return nullptr; + } + + const char* CrashConditionItemGetCrimePatch::GetName() const + { + return "Crash Condition Item GetCrime"; + } + + bool CrashConditionItemGetCrimePatch::HasDependencies() const + { + return false; + } + + Array CrashConditionItemGetCrimePatch::GetDependencies() const + { + return {}; + } + + bool CrashConditionItemGetCrimePatch::QueryFromPlatform(EDITOR_EXECUTABLE_TYPE eEditorCurrentVersion, + const char* lpcstrPlatformRuntimeVersion) const + { + return (eEditorCurrentVersion <= EDITOR_EXECUTABLE_TYPE::EDITOR_FALLOUT_C4_LAST) && + (eEditorCurrentVersion != EDITOR_EXECUTABLE_TYPE::EDITOR_FALLOUT_C4_1_10_943_1); + } + + bool CrashConditionItemGetCrimePatch::Activate(const Relocator* lpRelocator, + const RelocationDatabaseItem* lpRelocationDatabaseItem) + { + if (lpRelocationDatabaseItem->Version() == 1) + { + // Strangely, there are 6 elements in the array in memory, when Beth is forced to pass exactly 7 + // 7 element is always nullptr + + lpRelocator->DetourJump(_RELDATA_RAV(0), (uintptr_t)&sub); + pointer_CrashConditionItemGetCrimePatch_data = (SettingT**)_RELDATA_ADDR(1); + + return true; + } + + return false; + } + + bool CrashConditionItemGetCrimePatch::Shutdown(const Relocator* lpRelocator, + const RelocationDatabaseItem* lpRelocationDatabaseItem) + { + return false; + } + + void CrashConditionItemGetCrimePatch::sub(HWND hCombobox) + { + if (!hCombobox) return; + + EditorAPI::EditorUI::HKSendMessageA(hCombobox, CB_RESETCONTENT, 0, 0); + EditorAPI::EditorUI::ComboBoxInsertItemDeferred(hCombobox, " ANY ", nullptr, 1); + + auto Array = pointer_CrashConditionItemGetCrimePatch_data; + if (!Array) return; + + uint32_t index = 0; + do { + if (auto Setting = Array[index]; Setting) + EditorAPI::EditorUI::ComboBoxInsertItemDeferred(hCombobox, Setting->Name, (void*)index, 1); + } while (++index < 7); + } + } + } +} \ No newline at end of file diff --git a/Creation Kit Platform Extended Core/Patches/FO4/CrashConditionItemGetCrime.h b/Creation Kit Platform Extended Core/Patches/FO4/CrashConditionItemGetCrime.h new file mode 100644 index 0000000..3750644 --- /dev/null +++ b/Creation Kit Platform Extended Core/Patches/FO4/CrashConditionItemGetCrime.h @@ -0,0 +1,43 @@ +// Copyright © 2023-2024 aka perchik71. All rights reserved. +// Contacts: +// License: https://www.gnu.org/licenses/gpl-3.0.html + +#pragma once + +#include "Core/Module.h" +#include "Core/Relocator.h" +#include "Core/RelocationDatabase.h" + +namespace CreationKitPlatformExtended +{ + namespace Patches + { + namespace Fallout4 + { + using namespace CreationKitPlatformExtended::Core; + + class CrashConditionItemGetCrimePatch : public Module + { + public: + CrashConditionItemGetCrimePatch(); + + virtual bool HasOption() const; + virtual bool HasCanRuntimeDisabled() const; + virtual const char* GetOptionName() const; + virtual const char* GetName() const; + virtual bool HasDependencies() const; + virtual Array GetDependencies() const; + + static void sub(HWND hCombobox); + protected: + virtual bool QueryFromPlatform(EDITOR_EXECUTABLE_TYPE eEditorCurrentVersion, + const char* lpcstrPlatformRuntimeVersion) const; + virtual bool Activate(const Relocator* lpRelocator, const RelocationDatabaseItem* lpRelocationDatabaseItem); + virtual bool Shutdown(const Relocator* lpRelocator, const RelocationDatabaseItem* lpRelocationDatabaseItem); + private: + CrashConditionItemGetCrimePatch(const CrashConditionItemGetCrimePatch&) = default; + CrashConditionItemGetCrimePatch& operator=(const CrashConditionItemGetCrimePatch&) = default; + }; + } + } +} \ No newline at end of file diff --git a/Creation Kit Platform Extended Core/Version/build_version.txt b/Creation Kit Platform Extended Core/Version/build_version.txt index f6d7efa3da5ec38c9bce16a983dc822a9ab0c093..c8d684f8d7ef3284baa40ea8c3668dbcd5480c97 100644 GIT binary patch literal 12 TcmezW&z!-G!IFWOfr|kE99{yu literal 12 RcmezW&z!*w2zeQ}7yukh0=NJG diff --git a/Creation Kit Platform Extended Core/Version/resource_version2.h b/Creation Kit Platform Extended Core/Version/resource_version2.h index 0ace2e20cd46dcb1fd8de08d0e90fef60703bbdc..8c3d5defa81ee28c8035ba1d383490631642448e 100644 GIT binary patch delta 26 icmcb@e}#X;BW6|$23`iP$&Ad>lOtHAHp{T=UlOtHAHp{T=U \ No newline at end of file diff --git a/Database/FO4/1_10_162_0/CreationKitPlatformExtended_FO4_1_10_162.database b/Database/FO4/1_10_162_0/CreationKitPlatformExtended_FO4_1_10_162.database index d36c5c5cbcd37ad28153b92a43c6171c33ace213..75d42453894b6d566335fb8b0dd74420e9c8b58c 100644 GIT binary patch delta 147 zcmdmYgz3OhrU?p+-WwG~CF+|PAb=4_$uc+>B^GBWIOpf3WR_&+=P7uWq~ \ No newline at end of file diff --git a/Database/FO4/1_10_982_3/CreationKitPlatformExtended_FO4_1_10_982_3.database b/Database/FO4/1_10_982_3/CreationKitPlatformExtended_FO4_1_10_982_3.database index b27566a2af07d0e2ed78b554ff33897f3b83a547..20340420fe23950ee230fa037c2c636849b9e9f4 100644 GIT binary patch delta 184 zcmdmajPc8H#t90Hz8e+g`CWE1Kma3$2s`572CTktc6002QX BD;)p; delta 19 bcmexzoN?zd#t90HJ{uL~`8WUO{}~JbRhkGx