Skip to content

Commit

Permalink
[CKPE]
Browse files Browse the repository at this point in the history
FO4:
- Fixed GetCrime: 7 element is always nullptr
  • Loading branch information
Perchik71 committed Nov 9, 2024
1 parent 8b80c65 commit 9e2b4bd
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Creation Kit Platform Extended Core/Core/EngineFO4Patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -113,6 +114,7 @@ namespace CreationKitPlatformExtended
new Patches::ChooseSoundFilePatch(),
new Patches::CrashInventoryPatch(),
new Patches::RunNetworkDisablePatch(),
new Patches::CrashConditionItemGetCrimePatch(),

new Patches::MainWindow(),
new Patches::ObjectWindow(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
<ClCompile Include="Patches\FO4\BSResourceLooseFilesPatch.cpp" />
<ClCompile Include="Patches\FO4\BSResourceTextureDB_RE.cpp" />
<ClCompile Include="Patches\FO4\ChooseSoundFileF4.cpp" />
<ClCompile Include="Patches\FO4\CrashConditionItemGetCrime.cpp" />
<ClCompile Include="Patches\FO4\CrashInventory.cpp" />
<ClCompile Include="Patches\FO4\CreateDDS.cpp" />
<ClCompile Include="Patches\FO4\EnableGoInSelGame.cpp" />
Expand Down Expand Up @@ -602,6 +603,7 @@
<ClInclude Include="Patches\FO4\BSResourceLooseFilesPatch.h" />
<ClInclude Include="Patches\FO4\BSResourceTextureDB_RE.h" />
<ClInclude Include="Patches\FO4\ChooseSoundFileF4.h" />
<ClInclude Include="Patches\FO4\CrashConditionItemGetCrime.h" />
<ClInclude Include="Patches\FO4\CrashInventory.h" />
<ClInclude Include="Patches\FO4\CreateDDS.h" />
<ClInclude Include="Patches\FO4\EnableGoInSelGame.h" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,9 @@
<ClCompile Include="Patches\FO4\RunNetworkDisable.cpp">
<Filter>Patches\FO4</Filter>
</ClCompile>
<ClCompile Include="Patches\FO4\CrashConditionItemGetCrime.cpp">
<Filter>Patches\FO4</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="Version">
Expand Down Expand Up @@ -2122,6 +2125,9 @@
<ClInclude Include="Patches\FO4\RunNetworkDisable.h">
<Filter>Patches\FO4</Filter>
</ClInclude>
<ClInclude Include="Patches\FO4\CrashConditionItemGetCrime.h">
<Filter>Patches\FO4</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Version\resource_version.rc">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright © 2023-2024 aka perchik71. All rights reserved.
// Contacts: <email:[email protected]>
// 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: <name>\x0<value>
char* Data;
};

template<typename T>
class SettingT
{
public:
virtual ~SettingT() = default;

char* Name;
GameSettingCollection Option;
};

SettingT<GameSettingCollection>** 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<String> 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<GameSettingCollection>**)_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);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright © 2023-2024 aka perchik71. All rights reserved.
// Contacts: <email:[email protected]>
// 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<String> 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;
};
}
}
}
Binary file modified Creation Kit Platform Extended Core/Version/build_version.txt
Binary file not shown.
Binary file modified Creation Kit Platform Extended Core/Version/resource_version2.h
Binary file not shown.
5 changes: 5 additions & 0 deletions Database/FO4/1_10_162_0/CrashConditionItemGetCrime.relb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Crash Condition Item GetCrime
1
extended
6454C0 0 v0_4885C90F84????????554883EC2048895C2430
4546B10 0 <nope>
Binary file not shown.
5 changes: 5 additions & 0 deletions Database/FO4/1_10_982_3/CrashConditionItemGetCrime.relb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Crash Condition Item GetCrime
1
extended
6E4590 0 4885C90F84????????554883EC2048895C24304533C948897424384533C0BA4B01000048897C2440488BE9FF15????????
3AE2888 0 <nope>
Binary file not shown.

0 comments on commit 9e2b4bd

Please sign in to comment.