Skip to content

Commit bf5db53

Browse files
committed
fix greymovies
1 parent 51feae4 commit bf5db53

12 files changed

+144
-9
lines changed

X-Cell-FO4.vcxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@
3737
<ClCompile Include="depends\f4se\f4se\f4se\GameThreads.cpp" />
3838
<ClCompile Include="depends\f4se\f4se\f4se\GameTypes.cpp" />
3939
<ClCompile Include="depends\f4se\f4se\f4se\GameUtilities.cpp" />
40+
<ClCompile Include="depends\f4se\f4se\f4se\ScaleformMovie.cpp" />
41+
<ClCompile Include="depends\f4se\f4se\f4se\ScaleformTypes.cpp" />
42+
<ClCompile Include="depends\f4se\f4se\f4se\ScaleformValue.cpp" />
4043
<ClCompile Include="depends\typeinfo\ms_rtti.cpp" />
4144
<ClCompile Include="source\xc_assertion.cpp" />
4245
<ClCompile Include="source\xc_dllmain.cpp" />
4346
<ClCompile Include="source\xc_patch.cpp" />
4447
<ClCompile Include="source\xc_patch_archive_limit.cpp" />
4548
<ClCompile Include="source\xc_patch_facegen.cpp" />
49+
<ClCompile Include="source\xc_fix_greymovies.cpp" />
4650
<ClCompile Include="source\xc_patch_io.cpp" />
4751
<ClCompile Include="source\xc_patch_libdeflate.cpp" />
4852
<ClCompile Include="source\xc_patch_loadscreen.cpp" />
@@ -71,12 +75,16 @@
7175
<ClInclude Include="depends\f4se\f4se\f4se\GameThreads.h" />
7276
<ClInclude Include="depends\f4se\f4se\f4se\GameTypes.h" />
7377
<ClInclude Include="depends\f4se\f4se\f4se\GameUtilities.h" />
78+
<ClInclude Include="depends\f4se\f4se\f4se\ScaleformMovie.h" />
79+
<ClInclude Include="depends\f4se\f4se\f4se\ScaleformTypes.h" />
80+
<ClInclude Include="depends\f4se\f4se\f4se\ScaleformValue.h" />
7481
<ClInclude Include="depends\typeinfo\ms_rtti.h" />
7582
<ClInclude Include="include\xc_assertion.h" />
7683
<ClInclude Include="include\xc_common.h" />
7784
<ClInclude Include="include\xc_patch.h" />
7885
<ClInclude Include="include\xc_patch_archive_limit.h" />
7986
<ClInclude Include="include\xc_patch_facegen.h" />
87+
<ClInclude Include="include\xc_fix_greymovies.h" />
8088
<ClInclude Include="include\xc_patch_io.h" />
8189
<ClInclude Include="include\xc_patch_libdeflate.h" />
8290
<ClInclude Include="include\xc_patch_loadscreen.h" />

X-Cell-FO4.vcxproj.filters

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@
126126
<ClCompile Include="source\xc_patch_libdeflate.cpp">
127127
<Filter>Исходные файлы\patches</Filter>
128128
</ClCompile>
129+
<ClCompile Include="source\xc_fix_greymovies.cpp">
130+
<Filter>Исходные файлы\patches</Filter>
131+
</ClCompile>
132+
<ClCompile Include="depends\f4se\f4se\f4se\ScaleformMovie.cpp">
133+
<Filter>f4se</Filter>
134+
</ClCompile>
135+
<ClCompile Include="depends\f4se\f4se\f4se\ScaleformValue.cpp">
136+
<Filter>f4se</Filter>
137+
</ClCompile>
138+
<ClCompile Include="depends\f4se\f4se\f4se\ScaleformTypes.cpp">
139+
<Filter>f4se</Filter>
140+
</ClCompile>
129141
</ItemGroup>
130142
<ItemGroup>
131143
<ClInclude Include="depends\f4se\f4se\f4se\GameEvents.h">
@@ -233,6 +245,18 @@
233245
<ClInclude Include="include\xc_patch_libdeflate.h">
234246
<Filter>Файлы заголовков\patches</Filter>
235247
</ClInclude>
248+
<ClInclude Include="include\xc_fix_greymovies.h">
249+
<Filter>Файлы заголовков\patches</Filter>
250+
</ClInclude>
251+
<ClInclude Include="depends\f4se\f4se\f4se\ScaleformMovie.h">
252+
<Filter>f4se</Filter>
253+
</ClInclude>
254+
<ClInclude Include="depends\f4se\f4se\f4se\ScaleformValue.h">
255+
<Filter>f4se</Filter>
256+
</ClInclude>
257+
<ClInclude Include="depends\f4se\f4se\f4se\ScaleformTypes.h">
258+
<Filter>f4se</Filter>
259+
</ClInclude>
236260
</ItemGroup>
237261
<ItemGroup>
238262
<None Include="depends\f4se\f4se\f4se\GameRTTI.inl">

include/xc_fix_greymovies.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 <f4se/ScaleformMovie.h>
8+
#include <xc_patch.h>
9+
10+
namespace xc
11+
{
12+
class fix_greymovies : public patch
13+
{
14+
public:
15+
fix_greymovies() = default;
16+
fix_greymovies(const fix_greymovies&) = default;
17+
virtual ~fix_greymovies() = default;
18+
19+
fix_greymovies& operator=(const fix_greymovies&) = default;
20+
21+
static void setbgalpha(GFxMovieView* self, float);
22+
23+
virtual const char* get_name() const noexcept;
24+
virtual bool game_data_ready_handler() const noexcept;
25+
protected:
26+
virtual bool run() const;
27+
};
28+
}

include/xc_patch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace xc
3939

4040
patch& operator=(const patch&) = default;
4141

42-
bool start();
42+
bool start(const char* section);
4343

4444
virtual const char* get_name() const noexcept = 0;
4545
virtual bool game_data_ready_handler() const noexcept = 0;

include/xc_plugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace xc
4040
UInt32 _runtime_version;
4141
settings _settings;
4242
vector<patch*> _patches;
43+
vector<patch*> _fixes;
4344
uintptr_t _base;
4445
msrtti::section _section[3];
4546
F4SEMessagingInterface* _messages;

source/xc_fix_greymovies.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 <f4se/ScaleformValue.h>
6+
#include <xc_fix_greymovies.h>
7+
#include <xc_version.h>
8+
#include <xc_plugin.h>
9+
10+
namespace xc
11+
{
12+
void fix_greymovies::setbgalpha(GFxMovieView* self, float)
13+
{
14+
GFxValue alpha;
15+
16+
if (!self->movieRoot->GetVariable(std::addressof(alpha), "BackgroundAlpha"))
17+
alpha.SetNumber(0.0f);
18+
19+
// set alpha
20+
thisVirtualCall<void>(0x108, self, alpha.GetNumber());
21+
}
22+
23+
const char* fix_greymovies::get_name() const noexcept
24+
{
25+
return "greymovies";
26+
}
27+
28+
bool fix_greymovies::game_data_ready_handler() const noexcept
29+
{
30+
return true;
31+
}
32+
33+
bool fix_greymovies::run() const
34+
{
35+
// only NG
36+
if (g_plugin->get_runtime_version() == RUNTIME_VERSION_1_10_984)
37+
{
38+
auto addr = g_plugin->get_base() + 0x19FFE89;
39+
40+
// mov rcx, rbx
41+
// test al, al
42+
// je fallout4.7FF7DD38FEAF
43+
// movsd xmm1, qword ptr ss:[rsp+0x40]
44+
// cvtpd2ps xmm1, xmm1
45+
// minss xmm1, dword ptr ds:[0x7FF7DDC03D00]
46+
// maxss xmm1, xmm7
47+
// jmp fallout4.7FF7DD38FEB7
48+
// movss xmm1, dword ptr ss:[rbp+0x150]
49+
patch_mem(addr, { 0x48, 0x8B, 0xCB, 0x84, 0xC0, 0x74, 0x18, 0xF2, 0x0F, 0x10, 0x4C, 0x24, 0x40, 0x66, 0x0F, 0x5A, 0xC9, 0xF3,
50+
0x0F, 0x5D, 0x0D, 0x5E, 0x3E, 0x87, 0x00, 0xF3, 0x0F, 0x5F, 0xCF, 0xEB, 0x08, 0xF3, 0x0F, 0x10, 0x8D, 0x50, 0x01, 0x00, 0x00,
51+
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });
52+
detour_call(addr + 0x27, (uintptr_t)&setbgalpha);
53+
}
54+
else
55+
{
56+
_ERROR("The patch \"%s\" has not been installed, as the mod does not know the game", get_name());
57+
return false;
58+
}
59+
60+
return true;
61+
}
62+
}

source/xc_patch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
namespace xc
1010
{
11-
bool patch::start()
11+
bool patch::start(const char* section)
1212
{
13-
if (g_plugin->get_settings()->read_bool("patches", get_name(), false))
13+
if (g_plugin->get_settings()->read_bool(section, get_name(), false))
1414
return start_impl();
1515
return false;
1616
}

source/xc_patch_loadscreen.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ namespace xc
2222

2323
bool patch_loadscreen::run() const
2424
{
25-
auto base = GetModuleHandleA(NULL);
26-
2725
if (g_plugin->get_runtime_version() == RUNTIME_VERSION_1_10_163)
2826
// So that it is never called
2927
// pattern 488945??488B05????????48897D??8B88????????448BFE8975??488BDE85C974??488B98????????488BC3488D34CB483BDE74??

source/xc_plugin.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include <xc_patch_archive_limit.h>
1616
#include <xc_patch_loadscreen.h>
1717

18+
// fixes
19+
#include <xc_fix_greymovies.h>
20+
1821
namespace xc
1922
{
2023
plugin::plugin(const F4SEInterface* f4se) : _messages(nullptr), _f4se(f4se)
@@ -157,6 +160,10 @@ namespace xc
157160

158161
//////////////////
159162

163+
_fixes.push_back(new fix_greymovies());
164+
165+
//////////////////
166+
160167
return true;
161168
}
162169

@@ -175,7 +182,10 @@ namespace xc
175182
__try
176183
{
177184
for (auto i : _patches)
178-
if (i) i->start();
185+
if (i) i->start("patches");
186+
187+
for (auto i : _fixes)
188+
if (i) i->start("fixes");
179189
}
180190
__except (1)
181191
{

version/build_version.txt

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)