Implemented codes list reading for mod loader (#315)

This commit is contained in:
Hyper authored and GitHub committed 2025-02-08 17:12:53 +00:00
1 parent 39272b7975
commit 54aacf9a1f
4 files changed
+50 -12

No files matched your search

+38
View File
@@ -5,7 +5,9 @@
#include <cpu/guest_stack_var.h>
#include <kernel/function.h>
#include <kernel/heap.h>
#include <user/config.h>
#include <user/paths.h>
#include <os/logger.h>
#include <os/process.h>
#include <xxHashMap.h>
@@ -208,6 +210,42 @@ void ModLoader::Init()
if (!mod.includeDirs.empty())
g_mods.emplace_back(std::move(mod));
}
auto codeCount = modsDbIni.get<size_t>("Codes", "CodeCount", 0);
if (codeCount)
{
std::vector<std::string> codes{};
for (size_t i = 0; i < codeCount; i++)
{
auto name = modsDbIni.getString("Codes", fmt::format("Code{}", i), "");
if (name.empty())
continue;
codes.push_back(name);
}
for (auto& def : g_configDefinitions)
{
if (!def->IsHidden() || def->GetSection() != "Codes")
continue;
/* NOTE: this is inefficient, but it happens
once on boot for a handful of codes at release
and is temporary until we support real code mods. */
for (size_t i = 0; i < codes.size(); i++)
{
if (def->GetName() == codes[i])
{
LOGFN("Loaded code: {}", codes[i]);
*(bool*)def->GetValue() = true;
break;
}
}
}
}
}
static constexpr uint32_t LZX_SIGNATURE = 0xFF512EE;