Skip to content

Commit

Permalink
refactor: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
shad0wshayd3 committed Nov 16, 2024
1 parent c8ae644 commit f8debb9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion extern/commonlibf4
4 changes: 1 addition & 3 deletions src/PCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "F4SE/F4SE.h"
#include "RE/Fallout.h"
#include "REX/REX.h"

#include <xbyak/xbyak.h>
#include "REX/REX/INI.h"

using namespace std::literals;
32 changes: 15 additions & 17 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Config
{
namespace General
{
static REX::INI::U32 iScrapHeapMult{ "General"sv, "iScrapHeapMult"sv, 2 };
static REX::INI::U32 iScrapHeapMult{ "General"sv, "iScrapHeapMult"sv, 2u };
}

static void Load()
Expand All @@ -14,13 +14,18 @@ namespace Config
}
}

class ScrapHeap
namespace ScrapHeap
{
public:
static std::uint32_t MaxMemory{ 0x04000000u };
static std::uint32_t QMaxMemory()
{
return MaxMemory;
}

static void Install()
{
static REL::Relocation target{ REL::ID(2228361) };
target.write_func(0x10, QMaxMemory);
target.replace_func(0x10, QMaxMemory);

auto iScrapHeapMult = Config::General::iScrapHeapMult.GetValue();
switch (iScrapHeapMult)
Expand All @@ -30,30 +35,22 @@ class ScrapHeap
break;
case 2:
F4SE::log::info("ScrapHeap patched [0x08000000 (~130mb)]"sv);
MaxMemory = 0x08000000;
MaxMemory = 0x08000000u;
break;
case 3:
F4SE::log::info("ScrapHeap patched [0x0C000000 (~200mb)]"sv);
MaxMemory = 0x0C000000;
MaxMemory = 0x0C000000u;
break;
case 4:
F4SE::log::info("ScrapHeap patched [0x0FF00000 (~270mb)]"sv);
MaxMemory = 0x0FF00000;
MaxMemory = 0x0FF00000u;
break;
default:
F4SE::log::info("ScrapHeapMult invalid: value must be between 1 and 4, is {:d}."sv, iScrapHeapMult);
break;
}
}

private:
static std::uint32_t QMaxMemory()
{
return MaxMemory;
}

inline static std::uint32_t MaxMemory{ 0x04000000 };
};
}

namespace
{
Expand All @@ -63,7 +60,6 @@ namespace
{
case F4SE::MessagingInterface::kPostLoad:
{
Config::Load();
ScrapHeap::Install();
break;
}
Expand All @@ -78,5 +74,7 @@ F4SEPluginLoad(const F4SE::LoadInterface* a_F4SE)
F4SE::Init(a_F4SE);
F4SE::GetMessagingInterface()->RegisterListener(MessageCallback);

Config::Load();

return true;
}
1 change: 0 additions & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ add_rules("mode.debug", "mode.releasedbg")
add_rules("plugin.vsxmake.autoupdate")

-- add options
set_config("f4se_xbyak", true)
set_config("rex_ini", true)

-- setup targets
Expand Down

0 comments on commit f8debb9

Please sign in to comment.