mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 01:07:43 +00:00
Humungous refactor
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
#include "HECL/CVarManager.hpp"
|
||||
#include "HECL/CVar.hpp"
|
||||
#include <Athena/FileWriter.hpp>
|
||||
#include <Athena/Utility.hpp>
|
||||
#include <HECL/Runtime.hpp>
|
||||
#include "hecl/CVarManager.hpp"
|
||||
#include "hecl/CVar.hpp"
|
||||
#include <athena/FileWriter.hpp>
|
||||
#include <athena/Utility.hpp>
|
||||
#include <hecl/Runtime.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace HECL
|
||||
namespace hecl
|
||||
{
|
||||
|
||||
CVar* com_developer = nullptr;
|
||||
@@ -14,8 +14,8 @@ CVar* com_enableCheats = nullptr;
|
||||
|
||||
CVarManager* CVarManager::m_instance = nullptr;
|
||||
|
||||
LogVisor::LogModule CVarLog("CVarManager");
|
||||
CVarManager::CVarManager(HECL::Runtime::FileStoreManager& store, bool useBinary)
|
||||
logvisor::Module CVarLog("CVarManager");
|
||||
CVarManager::CVarManager(hecl::Runtime::FileStoreManager& store, bool useBinary)
|
||||
: m_store(store),
|
||||
m_useBinary(useBinary)
|
||||
{
|
||||
@@ -42,7 +42,7 @@ void CVarManager::update()
|
||||
bool CVarManager::registerCVar(CVar* cvar)
|
||||
{
|
||||
std::string tmp = cvar->name();
|
||||
Athena::utility::tolower(tmp);
|
||||
athena::utility::tolower(tmp);
|
||||
if (m_cvars.find(tmp) != m_cvars.end())
|
||||
return false;
|
||||
|
||||
@@ -52,7 +52,7 @@ bool CVarManager::registerCVar(CVar* cvar)
|
||||
|
||||
CVar* CVarManager::findCVar(std::string name)
|
||||
{
|
||||
Athena::utility::tolower(name);
|
||||
athena::utility::tolower(name);
|
||||
if (m_cvars.find(name) == m_cvars.end())
|
||||
return nullptr;
|
||||
|
||||
@@ -85,27 +85,27 @@ void CVarManager::deserialize(CVar* cvar)
|
||||
|
||||
CVarContainer container;
|
||||
#if _WIN32
|
||||
HECL::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toWideLiteral();
|
||||
hecl::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toWideLiteral();
|
||||
#else
|
||||
HECL::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toLiteral();
|
||||
hecl::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toLiteral();
|
||||
#endif
|
||||
HECL::Sstat st;
|
||||
hecl::Sstat st;
|
||||
|
||||
if (m_useBinary)
|
||||
{
|
||||
filename += _S(".bin");
|
||||
if (HECL::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode))
|
||||
if (hecl::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode))
|
||||
return;
|
||||
Athena::io::FileReader reader(filename);
|
||||
athena::io::FileReader reader(filename);
|
||||
if (reader.isOpen())
|
||||
container.read(reader);
|
||||
}
|
||||
else
|
||||
{
|
||||
filename += _S(".yaml");
|
||||
if (HECL::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode))
|
||||
if (hecl::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode))
|
||||
return;
|
||||
FILE* f = HECL::Fopen(filename.c_str(), _S("rb"));
|
||||
FILE* f = hecl::Fopen(filename.c_str(), _S("rb"));
|
||||
if (f)
|
||||
container.fromYAMLFile(f);
|
||||
fclose(f);
|
||||
@@ -122,7 +122,7 @@ void CVarManager::deserialize(CVar* cvar)
|
||||
DNACVAR::CVar& tmp = *serialized;
|
||||
if (tmp.m_type != cvar->type())
|
||||
{
|
||||
CVarLog.report(LogVisor::Error, _S("Stored type for %s does not match actual type!"), tmp.m_name.c_str());
|
||||
CVarLog.report(logvisor::Error, _S("Stored type for %s does not match actual type!"), tmp.m_name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -148,22 +148,22 @@ void CVarManager::serialize()
|
||||
container.cvarCount = container.cvars.size();
|
||||
|
||||
#if _WIN32
|
||||
HECL::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toWideLiteral();
|
||||
hecl::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toWideLiteral();
|
||||
#else
|
||||
HECL::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toLiteral();
|
||||
hecl::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toLiteral();
|
||||
#endif
|
||||
|
||||
if (m_useBinary)
|
||||
{
|
||||
filename += _S(".bin");
|
||||
Athena::io::FileWriter writer(filename);
|
||||
athena::io::FileWriter writer(filename);
|
||||
if (writer.isOpen())
|
||||
container.write(writer);
|
||||
}
|
||||
else
|
||||
{
|
||||
filename += _S(".yaml");
|
||||
FILE* f = HECL::Fopen(filename.c_str(), _S("wb"));
|
||||
FILE* f = hecl::Fopen(filename.c_str(), _S("wb"));
|
||||
if (f)
|
||||
container.toYAMLFile(f);
|
||||
fclose(f);
|
||||
|
||||
Reference in New Issue
Block a user