Skip to content

Commit d4a59ba

Browse files
committed
added fix PackageAllocateLocation
1 parent bf5db53 commit d4a59ba

13 files changed

+102
-2
lines changed

X-Cell-FO4.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<ClCompile Include="depends\typeinfo\ms_rtti.cpp" />
4444
<ClCompile Include="source\xc_assertion.cpp" />
4545
<ClCompile Include="source\xc_dllmain.cpp" />
46+
<ClCompile Include="source\xc_fix_packageallocatelocation.cpp" />
4647
<ClCompile Include="source\xc_patch.cpp" />
4748
<ClCompile Include="source\xc_patch_archive_limit.cpp" />
4849
<ClCompile Include="source\xc_patch_facegen.cpp" />
@@ -81,6 +82,7 @@
8182
<ClInclude Include="depends\typeinfo\ms_rtti.h" />
8283
<ClInclude Include="include\xc_assertion.h" />
8384
<ClInclude Include="include\xc_common.h" />
85+
<ClInclude Include="include\xc_fix_packageallocatelocation.h" />
8486
<ClInclude Include="include\xc_patch.h" />
8587
<ClInclude Include="include\xc_patch_archive_limit.h" />
8688
<ClInclude Include="include\xc_patch_facegen.h" />

X-Cell-FO4.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@
138138
<ClCompile Include="depends\f4se\f4se\f4se\ScaleformTypes.cpp">
139139
<Filter>f4se</Filter>
140140
</ClCompile>
141+
<ClCompile Include="source\xc_fix_packageallocatelocation.cpp">
142+
<Filter>Исходные файлы\patches</Filter>
143+
</ClCompile>
141144
</ItemGroup>
142145
<ItemGroup>
143146
<ClInclude Include="depends\f4se\f4se\f4se\GameEvents.h">
@@ -257,6 +260,9 @@
257260
<ClInclude Include="depends\f4se\f4se\f4se\ScaleformTypes.h">
258261
<Filter>f4se</Filter>
259262
</ClInclude>
263+
<ClInclude Include="include\xc_fix_packageallocatelocation.h">
264+
<Filter>Файлы заголовков\patches</Filter>
265+
</ClInclude>
260266
</ItemGroup>
261267
<ItemGroup>
262268
<None Include="depends\f4se\f4se\f4se\GameRTTI.inl">
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright © 2024 aka perchik71. All rights reserved.
2+
// Contacts: <email:timencevaleksej@gmail.com>
3+
// License: https://www.gnu.org/licenses/gpl-3.0.html
4+
5+
#pragma once
6+
7+
#include <xc_patch.h>
8+
9+
namespace xc
10+
{
11+
class fix_package_allocate_location : public patch
12+
{
13+
public:
14+
fix_package_allocate_location() = default;
15+
fix_package_allocate_location(const fix_package_allocate_location&) = default;
16+
virtual ~fix_package_allocate_location() = default;
17+
18+
fix_package_allocate_location& operator=(const fix_package_allocate_location&) = default;
19+
20+
static void* sub(void* self);
21+
22+
virtual const char* get_name() const noexcept;
23+
virtual bool game_data_ready_handler() const noexcept;
24+
protected:
25+
virtual bool run() const;
26+
};
27+
}

source/xc_fix_greymovies.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace xc
5353
}
5454
else
5555
{
56-
_ERROR("The patch \"%s\" has not been installed, as the mod does not know the game", get_name());
56+
_ERROR("The fix \"%s\" has not been installed, as the mod does not know the game", get_name());
5757
return false;
5858
}
5959

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright © 2024 aka perchik71. All rights reserved.
2+
// Contacts: <email:timencevaleksej@gmail.com>
3+
// License: https://www.gnu.org/licenses/gpl-3.0.html
4+
5+
#include <xc_fix_packageallocatelocation.h>
6+
#include <xc_version.h>
7+
#include <xc_plugin.h>
8+
9+
namespace xc
10+
{
11+
uintptr_t pointer_package_allocate_location_sub = 0;
12+
13+
void* fix_package_allocate_location::sub(void* self)
14+
{
15+
return self ? fastCall<void*>(pointer_package_allocate_location_sub, self) : nullptr;
16+
}
17+
18+
const char* fix_package_allocate_location::get_name() const noexcept
19+
{
20+
return "package_allocate_location";
21+
}
22+
23+
bool fix_package_allocate_location::game_data_ready_handler() const noexcept
24+
{
25+
return true;
26+
}
27+
28+
bool fix_package_allocate_location::run() const
29+
{
30+
// only NG
31+
if (g_plugin->get_runtime_version() == RUNTIME_VERSION_1_10_984)
32+
{
33+
pointer_package_allocate_location_sub = g_plugin->get_base() + 0x2352E0;
34+
detour_call(g_plugin->get_base() + 0x711CE4, (uintptr_t)&sub);
35+
}
36+
else
37+
{
38+
_ERROR("The fix \"%s\" has not been installed, as the mod does not know the game", get_name());
39+
return false;
40+
}
41+
42+
return true;
43+
}
44+
}

source/xc_patch_libdeflate.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ namespace xc
4242
detour_call((g_plugin->get_base() + 0x2A5352), (uintptr_t)&impl_inflate_init);
4343
detour_call((g_plugin->get_base() + 0x2A5384), (uintptr_t)&impl_inflate);
4444
}
45+
else
46+
{
47+
_ERROR("The patch \"%s\" has not been installed, as the mod does not know the game", get_name());
48+
return false;
49+
}
4550

4651
return true;
4752
}

source/xc_patch_loadscreen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace xc
3131
patch_mem((g_plugin->get_base() + 0xFE23C0), { 0xC3, 0x90 }); // Removing an item from the load logo, any
3232
else
3333
{
34-
_ERROR("The patch has not been installed, as the mod does not know the game");
34+
_ERROR("The patch \"%s\" has not been installed, as the mod does not know the game", get_name());
3535
return false;
3636
}
3737

source/xc_patch_memory.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ namespace xc
253253

254254
bool patch_memory::run() const
255255
{
256+
if (GetModuleHandleA("BakaScrapHeap.dll"))
257+
{
258+
_WARNING("Mod \"Baka ScrapHeap\" has been detected, X-Cell patch \"%s\" is incompatible and will not be enabled.", get_name());
259+
return false;
260+
}
261+
256262
auto base = GetModuleHandleA(NULL);
257263

258264
MEMORYSTATUSEX statex = { 0 };

source/xc_patch_profile.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ namespace xc
3030

3131
bool patch_profile::run() const
3232
{
33+
if (GetModuleHandleA("PrivateProfileRedirector.dll"))
34+
{
35+
_WARNING("Mod \"PrivateProfileRedirector F4\" has been detected, disabling redundant patch \"%s\"", get_name());
36+
return false;
37+
}
38+
3339
auto base = GetModuleHandleA(NULL);
3440

3541
//

source/xc_plugin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
// fixes
1919
#include <xc_fix_greymovies.h>
20+
#include <xc_fix_packageallocatelocation.h>
2021

2122
namespace xc
2223
{
@@ -161,6 +162,7 @@ namespace xc
161162
//////////////////
162163

163164
_fixes.push_back(new fix_greymovies());
165+
_fixes.push_back(new fix_package_allocate_location());
164166

165167
//////////////////
166168

0 commit comments

Comments
 (0)