Skip to content

Commit 49a0940

Browse files
committed
Update CommonLibF4, Add ToggleGrassCommand Module
1 parent da88eca commit 49a0940

10 files changed

Lines changed: 77 additions & 3 deletions

File tree

.Build/F4SE/Plugins/Addictol.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ bViewmodelShading = true
177177
# Fixes the first-person viewmodel getting blurred by depth-of-field (iron-sight ADS, dialogue camera) by re-rasterizing it after the DoF pass.
178178
bDofFix = true
179179

180+
# Fixes the "ToggleGrass" / "tg" command being a reference function in the AE versions of the game.
181+
bToggleGrassCommand = true
182+
180183

181184
[Warnings]
182185

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
#include <AdModule.h>
4+
5+
namespace Addictol
6+
{
7+
class ModuleToggleGrassCommand :
8+
public Module
9+
{
10+
public:
11+
ModuleToggleGrassCommand();
12+
virtual ~ModuleToggleGrassCommand() = default;
13+
14+
[[nodiscard]] virtual bool DoQuery() const noexcept override;
15+
[[nodiscard]] virtual bool DoInstall([[maybe_unused]] F4SE::MessagingInterface::Message* a_msg = nullptr) noexcept override;
16+
[[nodiscard]] virtual bool DoListener([[maybe_unused]] F4SE::MessagingInterface::Message* a_msg = nullptr) noexcept override;
17+
[[nodiscard]] virtual bool DoPapyrusListener([[maybe_unused]] RE::BSScript::IVirtualMachine* a_vm) noexcept override;
18+
};
19+
}

Addictol/Source/AdConfigValidation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ namespace Addictol
3131
"bCombatMusic", "bWorkbenchSound", "bActorCauseSaveBloat",
3232
"bAnimSignedCrash", "bBethesdaNetCrash",
3333
"bMuzzleFlashLight", "bAltTabFullscreen", "bPowerGridScrap",
34-
"bViewmodelShading", "bDofFix",
35-
"bUtilityShader", "bPipBoyCursorConstraints"
34+
"bViewmodelShading", "bDofFix", "bUtilityShader",
35+
"bPipBoyCursorConstraints", "bToggleGrassCommand"
3636
}},
3737
{ "Warnings", {
3838
"bImageSpaceAdapter", "bDuplicateAddonNodeIndex", "bReferenceHandleLimit"

Addictol/Source/AdRegisterModules.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include <Modules/AdModuleUtilityShader.h>
6363
#include <Modules/AdModulePipBoyCursorConstraints.h>
6464
#include <Modules/AdModuleReferenceHandleLimitWarning.h>
65+
#include <Modules/AdModuleToggleGrassCommand.h>
6566

6667
// Create patches
6768
static auto sModuleThreads = std::make_shared<Addictol::ModuleThreads>();
@@ -126,6 +127,7 @@ static auto sModuleDofFix = std::make_shared<Addictol::ModuleDofFix>();
126127
static auto sModuleUtilityShader = std::make_shared<Addictol::ModuleUtilityShader>();
127128
static auto sModulePipBoyCursorConstraints = std::make_shared<Addictol::ModulePipBoyCursorConstraints>();
128129
static auto sModuleReferenceHandleLimitWarning = std::make_shared<Addictol::ModuleReferenceHandleLimitWarning>();
130+
static auto sModuleToggleGrassCommand = std::make_shared<Addictol::ModuleToggleGrassCommand>();
129131

130132
void AdRegisterPreloadModules()
131133
{
@@ -202,6 +204,7 @@ void AdRegisterModules()
202204
modules.Register(sModuleViewmodelShading);
203205
modules.Register(sModuleDofFix);
204206
modules.Register(sModuleReferenceHandleLimitWarning);
207+
modules.Register(sModuleToggleGrassCommand);
205208

206209
// Registers other patches
207210
modules.Register(sModuleThreads, kGameDataReady);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <Modules/AdModuleToggleGrassCommand.h>
2+
#include <AdUtils.h>
3+
4+
#include <RE/S/SCRIPT_FUNCTION.h>
5+
6+
namespace Addictol
7+
{
8+
static REX::TOML::Bool<> bFixesToggleGrassCommand{ "Fixes"sv, "bToggleGrassCommand"sv, true };
9+
10+
ModuleToggleGrassCommand::ModuleToggleGrassCommand() :
11+
Module("Toggle Grass Command", &bFixesToggleGrassCommand)
12+
{}
13+
14+
bool ModuleToggleGrassCommand::DoQuery() const noexcept
15+
{
16+
// Only needed on AE
17+
return RELEX::IsRuntimeAE();
18+
}
19+
20+
bool ModuleToggleGrassCommand::DoInstall([[maybe_unused]] F4SE::MessagingInterface::Message* a_msg) noexcept
21+
{
22+
RE::SCRIPT_FUNCTION* consoleCommand = RE::SCRIPT_FUNCTION::LocateConsoleCommand("ToggleGrass");
23+
if (consoleCommand)
24+
{
25+
bool isReferenceFunction = false;
26+
REL::WriteSafe(reinterpret_cast<std::uintptr_t>(&consoleCommand->referenceFunction), &isReferenceFunction, sizeof(isReferenceFunction));
27+
}
28+
29+
return true;
30+
}
31+
32+
bool ModuleToggleGrassCommand::DoListener([[maybe_unused]] F4SE::MessagingInterface::Message* a_msg) noexcept
33+
{
34+
return true;
35+
}
36+
37+
bool ModuleToggleGrassCommand::DoPapyrusListener([[maybe_unused]] RE::BSScript::IVirtualMachine* a_vm) noexcept
38+
{
39+
return true;
40+
}
41+
}

VC/Addictol.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<ClCompile Include="..\Addictol\Source\Modules\AdModuleAltTabFullscreen.cpp" />
3030
<ClCompile Include="..\Addictol\Source\Modules\AdModuleDofFix.cpp" />
3131
<ClCompile Include="..\Addictol\Source\Modules\AdModuleDpiScaling.cpp" />
32+
<ClCompile Include="..\Addictol\Source\Modules\AdModuleToggleGrassCommand.cpp" />
3233
<ClCompile Include="..\Addictol\Source\Modules\AdModuleViewmodelShading.cpp" />
3334
<ClCompile Include="..\Addictol\Source\Modules\AdModuleActorCauseSaveBloat.cpp" />
3435
<ClCompile Include="..\Addictol\Source\Modules\AdModuleActorIsHostileToActor.cpp" />
@@ -108,6 +109,7 @@
108109
<ClInclude Include="..\Addictol\Include\Modules\AdModuleAltTabFullscreen.h" />
109110
<ClInclude Include="..\Addictol\Include\Modules\AdModuleDofFix.h" />
110111
<ClInclude Include="..\Addictol\Include\Modules\AdModuleDpiScaling.h" />
112+
<ClInclude Include="..\Addictol\Include\Modules\AdModuleToggleGrassCommand.h" />
111113
<ClInclude Include="..\Addictol\Include\Modules\AdModuleViewmodelShading.h" />
112114
<ClInclude Include="..\Addictol\Include\Modules\AdModuleActorCauseSaveBloat.h" />
113115
<ClInclude Include="..\Addictol\Include\Modules\AdModuleActorIsHostileToActor.h" />

VC/Addictol.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@
241241
<ClCompile Include="..\Addictol\Source\Modules\AdModuleReferenceHandleLimitWarning.cpp">
242242
<Filter>Source\Modules</Filter>
243243
</ClCompile>
244+
<ClCompile Include="..\Addictol\Source\Modules\AdModuleToggleGrassCommand.cpp">
245+
<Filter>Source\Modules</Filter>
246+
</ClCompile>
244247
</ItemGroup>
245248
<ItemGroup>
246249
<ClInclude Include="..\Version\resource_version2.h" />
@@ -475,6 +478,9 @@
475478
<ClInclude Include="..\Addictol\Include\Modules\AdModuleReferenceHandleLimitWarning.h">
476479
<Filter>Include\Modules</Filter>
477480
</ClInclude>
481+
<ClInclude Include="..\Addictol\Include\Modules\AdModuleToggleGrassCommand.h">
482+
<Filter>Include\Modules</Filter>
483+
</ClInclude>
478484
</ItemGroup>
479485
<ItemGroup>
480486
<ResourceCompile Include="..\Version\resource_version.rc" />

Version/build_version.txt

0 Bytes
Binary file not shown.

Version/resource_version2.h

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)