Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit f2de4d4

Browse files
committed
[X-CELL]
Fixes bugs when toggling references with LOD
1 parent 330c656 commit f2de4d4

12 files changed

Lines changed: 135 additions & 0 deletions

X-Cell-FO4.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<ClCompile Include="source\XCellModuleIO.cpp" />
3434
<ClCompile Include="source\XCellModuleLibDeflate.cpp" />
3535
<ClCompile Include="source\XCellModuleLoadScreen.cpp" />
36+
<ClCompile Include="source\XCellModuleLODDistanceFix.cpp" />
3637
<ClCompile Include="source\XCellModuleManager.cpp" />
3738
<ClCompile Include="source\XCellModuleMemory.cpp" />
3839
<ClCompile Include="source\XCellModulePackageAllocateLocation.cpp" />
@@ -73,6 +74,7 @@
7374
<ClInclude Include="include\XCellModuleIO.h" />
7475
<ClInclude Include="include\XCellModuleLibDeflate.h" />
7576
<ClInclude Include="include\XCellModuleLoadScreen.h" />
77+
<ClInclude Include="include\XCellModuleLODDistanceFix.h" />
7678
<ClInclude Include="include\XCellModuleManager.h" />
7779
<ClInclude Include="include\XCellModuleMemory.h" />
7880
<ClInclude Include="include\XCellModulePackageAllocateLocation.h" />

X-Cell-FO4.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@
147147
<ClCompile Include="source\XCellModuleInitTints.cpp">
148148
<Filter>Исходные файлы\Modules</Filter>
149149
</ClCompile>
150+
<ClCompile Include="source\XCellModuleLODDistanceFix.cpp">
151+
<Filter>Исходные файлы\Modules</Filter>
152+
</ClCompile>
150153
</ItemGroup>
151154
<ItemGroup>
152155
<ClInclude Include="include\XCellCommon.h">
@@ -275,6 +278,9 @@
275278
<ClInclude Include="include\XCellModuleInitTints.h">
276279
<Filter>Файлы заголовков\Modules</Filter>
277280
</ClInclude>
281+
<ClInclude Include="include\XCellModuleLODDistanceFix.h">
282+
<Filter>Файлы заголовков\Modules</Filter>
283+
</ClInclude>
278284
</ItemGroup>
279285
<ItemGroup>
280286
<None Include="version\resource_version2.tmp">

data/f4se/plugins/x-cell.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ bUpscaler=false # [Experimental] Increase FPS due to scaling, requires Win 8
1212

1313
[Fixes] # Common fixes
1414
bInitTints=true # Removes the block on loading NPCs tints of the Fallout4.esm file, as well as for NPCs with set the IsChargenPresent flag.
15+
bLODDistance=true # Fixes bugs when toggling references with LOD causing LOD to briefly enable and disable by removing the "Has Distant LOD" and "Visible When Distant" flag checks: https://www.youtube.com/watch?v=hgMm9Z8lHfU.
1516

1617
[NGFixes] # Only NG version game. Already present in Buffout 4, but are missing in Buffout 4 NG (at time 28.09.2024).
1718
bGreyMovies=true # Fixes a bug where movies that don't define "BackgroundAlpha" on their movie root could load with a grey background.

fomod/info.xml

0 Bytes
Binary file not shown.

include/XCellCVar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ namespace XCell
6565
extern std::shared_ptr<Setting> CVarNoUseTAA;
6666
// Removes the block on loading NPCs tints of the Fallout4.esm file, as well as for NPCs with set the IsChargenPresent flag.
6767
extern std::shared_ptr<Setting> CVarInitTints;
68+
// Fixes bugs when toggling references with LOD causing LOD to briefly enable and disable by removing the "Has Distant LOD" and "Visible When Distant" flag checks: https://www.youtube.com/watch?v=hgMm9Z8lHfU.
69+
extern std::shared_ptr<Setting> CVarLODDistance;
6870
// Debugging messages about the presence of facegen in the NPC in console and log (Need bFacegen patch).
6971
extern std::shared_ptr<Setting> CVarDbgFacegenOutput;
7072

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright © 2024-2025 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+
// XCell
8+
#include "XCellModule.h"
9+
#include "XCellRelocator.h"
10+
11+
namespace XCell
12+
{
13+
class ModuleLODDistanceFix : public Module
14+
{
15+
REL::Patch _fixes[8];
16+
public:
17+
static constexpr auto SourceName = "Module LOD Distance Fix";
18+
19+
ModuleLODDistanceFix(void* Context);
20+
virtual ~ModuleLODDistanceFix() = default;
21+
22+
ModuleLODDistanceFix(const ModuleLODDistanceFix&) = delete;
23+
ModuleLODDistanceFix& operator=(const ModuleLODDistanceFix&) = delete;
24+
protected:
25+
virtual HRESULT InstallImpl();
26+
virtual HRESULT ShutdownImpl();
27+
};
28+
}

source/XCellCVar.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace XCell
1616
std::shared_ptr<Setting> CVarUpscaler = std::make_shared<Setting>("bUpscaler:Patches", false);
1717

1818
std::shared_ptr<Setting> CVarInitTints = std::make_shared<Setting>("bInitTints:Fixes", true);
19+
std::shared_ptr<Setting> CVarLODDistance = std::make_shared<Setting>("bLODDistance:Fixes", true);
1920

2021
std::shared_ptr<Setting> CVarGreyMovies = std::make_shared<Setting>("bGreyMovies:NGFixes", true);
2122
std::shared_ptr<Setting> CVarPackageAllocateLocation = std::make_shared<Setting>("bPackageAllocateLocation:NGFixes", true);
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright © 2024-2025 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 "XCellModuleLODDistanceFix.h"
6+
#include "XCellTableID.h"
7+
#include "XCellPlugin.h"
8+
#include "XCellCVar.h"
9+
10+
namespace XCell
11+
{
12+
ModuleLODDistanceFix::ModuleLODDistanceFix(void* Context) :
13+
Module(Context, SourceName, CVarLODDistance)
14+
{
15+
auto gContext = (XCell::Context*)Context;
16+
auto base = gContext->ProcessBase;
17+
18+
//
19+
// It is required because many STATs that are also workshop buildable have LOD
20+
// If you add the flag, it causes bug above.
21+
//
22+
// Sets as always disabled
23+
24+
_fixes[0].Install(REL::ID(260), { 0x31, 0xC0, 0xC3, 0x90 });
25+
_fixes[1].Install(REL::ID(261), { 0x31, 0xC0, 0xC3, 0x90 });
26+
_fixes[2].Install(REL::ID(262), { 0x31, 0xC0, 0xC3, 0x90 });
27+
_fixes[3].Install(REL::ID(263), { 0xEB, 0x2C, 0x90 });
28+
_fixes[4].Install(REL::ID(264), { 0xEB, 0x28, 0x90 });
29+
_fixes[5].Install(REL::ID(265), { 0xEB });
30+
_fixes[6].Install(REL::ID(266), { 0xC3, 0x90 });
31+
32+
if (REL::Version() == RUNTIME_VERSION_1_10_163)
33+
_fixes[7].Install(REL::ID(267), { 0x31, 0xC0, 0xC3, 0x90 });
34+
}
35+
36+
HRESULT ModuleLODDistanceFix::InstallImpl()
37+
{
38+
_fixes[0].Enable();
39+
_fixes[1].Enable();
40+
_fixes[2].Enable();
41+
_fixes[3].Enable();
42+
_fixes[4].Enable();
43+
_fixes[5].Enable();
44+
_fixes[6].Enable();
45+
46+
if (REL::Version() == RUNTIME_VERSION_1_10_163)
47+
_fixes[7].Enable();
48+
49+
return S_OK;
50+
}
51+
52+
HRESULT ModuleLODDistanceFix::ShutdownImpl()
53+
{
54+
// Returned
55+
56+
_fixes[0].Disable();
57+
_fixes[1].Disable();
58+
_fixes[2].Disable();
59+
_fixes[3].Disable();
60+
_fixes[4].Disable();
61+
_fixes[5].Disable();
62+
_fixes[6].Disable();
63+
64+
if (REL::Version() == RUNTIME_VERSION_1_10_163)
65+
_fixes[7].Disable();
66+
67+
return S_OK;
68+
}
69+
}

source/XCellPlugin.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "XCellModulePackageAllocateLocation.h"
2727
#include "XCellModuleWarningCreateTexture2D.h"
2828
#include "XCellModuleInitTints.h"
29+
#include "XCellModuleLODDistanceFix.h"
2930

3031
#define XCELL_IMGUI_INSTALL 0
3132

@@ -136,6 +137,7 @@ namespace XCell
136137

137138
// Fixes
138139
_settings.Add(CVarInitTints);
140+
_settings.Add(CVarLODDistance);
139141
_settings.Add(CVarGreyMovies);
140142
_settings.Add(CVarPackageAllocateLocation);
141143
_settings.Add(CVarWarningCreateTexture2D);
@@ -328,6 +330,7 @@ namespace XCell
328330
if (FAILED(_modules.Add(make_shared<ModulePackageAllocateLocation>(this)))) return E_FAIL;
329331
if (FAILED(_modules.Add(make_shared<ModuleWarningCreateTexture2D>(this)))) return E_FAIL;
330332
if (FAILED(_modules.Add(make_shared<ModuleInitTints>(this)))) return E_FAIL;
333+
if (FAILED(_modules.Add(make_shared<ModuleLODDistanceFix>(this)))) return E_FAIL;
331334
// Required install after all modules
332335
#if XCELL_IMGUI_INSTALL
333336
if (FAILED(_modules.Add(make_shared<ModuleImGUI>(this)))) return E_FAIL;

source/XCellTableID.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,20 @@ namespace XCell
117117
{ 253, 0x11E4F1 },
118118
{ 254, 0x5BDC49 },
119119
{ 255, 0x120504 },
120+
121+
// LOD
122+
{ 260, 0x3F4C6C },
123+
{ 261, 0x3F4C90 },
124+
{ 262, 0x4033C0 },
125+
{ 263, 0x40F37B },
126+
{ 264, 0x40F3DC },
127+
{ 265, 0x3DF32B },
128+
{ 266, 0x7A859C },
129+
{ 267, 0x52A80 },
130+
// 2F3BE2 ??? Keyword?
131+
132+
133+
//42B380
120134
});
121135

122136
TableID K_984(RUNTIME_VERSION_1_10_984, {
@@ -181,6 +195,15 @@ namespace XCell
181195
{ 253, 0x29B434 },
182196
{ 254, 0x60A083 },
183197

198+
// LOD
199+
{ 260, 0x4A7830 },
200+
{ 261, 0x4A7860 },
201+
{ 262, 0x4B6C40 },
202+
{ 263, 0x4C310B },
203+
{ 264, 0x4C316C },
204+
{ 265, 0x3DF32B },
205+
{ 266, 0x4A7890 },
206+
184207
});
185208
}
186209
}

0 commit comments

Comments
 (0)