2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 05:07:43 +00:00

Massive fmtlib refactor

This commit is contained in:
Jack Andersen
2019-07-19 18:27:21 -10:00
parent e38a3ece89
commit 7a3da1f7a6
228 changed files with 2071 additions and 2116 deletions

View File

@@ -19,7 +19,7 @@ void ProjectResourceFactoryBase::BeginBackgroundIndex(hecl::Database::Project& p
}
bool ProjectResourceFactoryBase::SyncCook(const hecl::ProjectPath& working) {
Log.report(logvisor::Warning, _SYS_STR("sync-cooking %s"), working.getRelativePath().data());
Log.report(logvisor::Warning, fmt(_SYS_STR("sync-cooking {}")), working.getRelativePath());
return m_clientProc.syncCook(working, m_cookSpec.get(), hecl::blender::SharedBlenderToken, false, false);
}
@@ -35,12 +35,12 @@ CFactoryFnReturn ProjectResourceFactoryBase::BuildSync(const SObjectTag& tag, co
u32 length = fr->length();
std::unique_ptr<u8[]> memBuf = fr->readUBytes(length);
CFactoryFnReturn ret = m_factoryMgr.MakeObjectFromMemory(tag, std::move(memBuf), length, false, paramXfer, selfRef);
Log.report(logvisor::Info, "sync-built %.4s %08X", tag.type.getChars(), u32(tag.id.Value()));
Log.report(logvisor::Info, fmt("sync-built {}"), tag);
return ret;
}
CFactoryFnReturn ret = m_factoryMgr.MakeObject(tag, *fr, paramXfer, selfRef);
Log.report(logvisor::Info, "sync-built %.4s %08X", tag.type.getChars(), u32(tag.id.Value()));
Log.report(logvisor::Info, fmt("sync-built {}"), tag);
return ret;
}
@@ -50,7 +50,7 @@ void ProjectResourceFactoryBase::AsyncTask::EnsurePath(const urde::SObjectTag& t
/* Ensure requested resource is on the filesystem */
if (!path.isFileOrGlob()) {
Log.report(logvisor::Error, _SYS_STR("unable to find resource path '%s'"), path.getRelativePath().data());
Log.report(logvisor::Error, fmt(_SYS_STR("unable to find resource path '{}'")), path.getRelativePath());
m_failed = true;
return;
}
@@ -63,8 +63,8 @@ void ProjectResourceFactoryBase::AsyncTask::EnsurePath(const urde::SObjectTag& t
/* Last chance type validation */
urde::SObjectTag verifyTag = m_parent.TagFromPath(path);
if (verifyTag.type != tag.type) {
Log.report(logvisor::Error, _SYS_STR("%s: expected type '%.4s', found '%.4s'"), path.getRelativePath().data(),
tag.type.getChars(), verifyTag.type.getChars());
Log.report(logvisor::Error, fmt(_SYS_STR("{}: expected type '{}', found '{}'")), path.getRelativePath(),
tag.type, verifyTag.type);
m_failed = true;
return;
}
@@ -88,8 +88,7 @@ void ProjectResourceFactoryBase::AsyncTask::CookComplete() {
/* Ensure cooked rep is on the filesystem */
athena::io::FileReader fr(m_cookedPath.getAbsolutePath(), 32 * 1024, false);
if (fr.hasError()) {
Log.report(logvisor::Error, _SYS_STR("unable to open cooked resource path '%s'"),
m_cookedPath.getAbsolutePath().data());
Log.report(logvisor::Error, fmt(_SYS_STR("unable to open cooked resource path '{}'")), m_cookedPath.getAbsolutePath());
m_failed = true;
return;
}
@@ -169,7 +168,7 @@ bool ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag, const he
std::optional<athena::io::FileReader>& fr) {
/* Ensure requested resource is on the filesystem */
if (!path.isFileOrGlob()) {
Log.report(logvisor::Error, _SYS_STR("unable to find resource path '%s'"), path.getAbsolutePath().data());
Log.report(logvisor::Error, fmt(_SYS_STR("unable to find resource path '{}'")), path.getAbsolutePath());
return false;
}
@@ -181,8 +180,8 @@ bool ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag, const he
/* Last chance type validation */
urde::SObjectTag verifyTag = TagFromPath(path);
if (verifyTag.type != tag.type) {
Log.report(logvisor::Error, _SYS_STR("%s: expected type '%.4s', found '%.4s'"), path.getRelativePath().data(),
tag.type.getChars(), verifyTag.type.getChars());
Log.report(logvisor::Error, fmt(_SYS_STR("{}: expected type '{}', found '{}'")), path.getRelativePath(),
tag.type, verifyTag.type);
return false;
}
@@ -193,7 +192,7 @@ bool ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag, const he
if (!cooked.isFile() || cooked.getModtime() < path.getModtime()) {
/* Do a blocking cook here */
if (!SyncCook(path)) {
Log.report(logvisor::Error, _SYS_STR("unable to cook resource path '%s'"), path.getAbsolutePath().data());
Log.report(logvisor::Error, fmt(_SYS_STR("unable to cook resource path '{}'")), path.getAbsolutePath());
return false;
}
}
@@ -202,7 +201,7 @@ bool ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag, const he
/* Ensure cooked rep is on the filesystem */
fr.emplace(cooked.getAbsolutePath(), 32 * 1024, false);
if (fr->hasError()) {
Log.report(logvisor::Error, _SYS_STR("unable to open cooked resource path '%s'"), cooked.getAbsolutePath().data());
Log.report(logvisor::Error, fmt(_SYS_STR("unable to open cooked resource path '{}'")), cooked.getAbsolutePath());
return false;
}
@@ -213,7 +212,7 @@ std::unique_ptr<urde::IObj> ProjectResourceFactoryBase::Build(const urde::SObjec
const urde::CVParamTransfer& paramXfer,
CObjectReference* selfRef) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id on type '%.4s'", tag.type.getChars());
Log.report(logvisor::Fatal, fmt("attempted to access null id on type '{}'"), tag.type);
const hecl::ProjectPath* resPath = nullptr;
if (!WaitForTagReady(tag, resPath))
@@ -241,16 +240,14 @@ std::unique_ptr<urde::IObj> ProjectResourceFactoryBase::Build(const urde::SObjec
}
//*task.xc_targetObjPtr = newObj.get();
Log.report(logvisor::Warning, "spin-built %.4s %08X", task.x0_tag.type.getChars(), u32(task.x0_tag.id.Value()));
Log.report(logvisor::Warning, fmt("spin-built {}"), task.x0_tag);
_RemoveTask(asyncSearch);
return newObj;
} else if (task.m_complete) {
Log.report(logvisor::Error, "unable to spin-build %.4s %08X; Resource requested as cook-only",
task.x0_tag.type.getChars(), u32(task.x0_tag.id.Value()));
Log.report(logvisor::Error, fmt("unable to spin-build {}; Resource requested as cook-only"), task.x0_tag);
} else {
Log.report(logvisor::Error, "unable to spin-build %.4s %08X", task.x0_tag.type.getChars(),
u32(task.x0_tag.id.Value()));
Log.report(logvisor::Error, fmt("unable to spin-build {}"), task.x0_tag);
}
_RemoveTask(asyncSearch);
@@ -273,14 +270,14 @@ std::shared_ptr<AsyncTask> ProjectResourceFactoryBase::BuildAsyncInternal(const
void ProjectResourceFactoryBase::BuildAsync(const urde::SObjectTag& tag, const urde::CVParamTransfer& paramXfer,
std::unique_ptr<urde::IObj>* objOut, CObjectReference* selfRef) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id on type '%.4s'", tag.type.getChars());
Log.report(logvisor::Fatal, fmt("attempted to access null id on type '{}'"), tag.type);
BuildAsyncInternal(tag, paramXfer, objOut, selfRef);
}
u32 ProjectResourceFactoryBase::ResourceSize(const SObjectTag& tag) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id on type '%.4s'", tag.type.getChars());
Log.report(logvisor::Fatal, fmt("attempted to access null id on type '{}'"), tag.type);
/* Ensure resource at requested path is indexed and not cooking */
const hecl::ProjectPath* resPath = nullptr;
@@ -298,7 +295,7 @@ u32 ProjectResourceFactoryBase::ResourceSize(const SObjectTag& tag) {
std::shared_ptr<urde::IDvdRequest> ProjectResourceFactoryBase::LoadResourceAsync(const urde::SObjectTag& tag,
void* target) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id");
Log.report(logvisor::Fatal, fmt("attempted to access null id"));
if (m_asyncLoadMap.find(tag) != m_asyncLoadMap.end())
return {};
return std::static_pointer_cast<urde::IDvdRequest>(
@@ -308,7 +305,7 @@ std::shared_ptr<urde::IDvdRequest> ProjectResourceFactoryBase::LoadResourceAsync
std::shared_ptr<urde::IDvdRequest> ProjectResourceFactoryBase::LoadResourcePartAsync(const urde::SObjectTag& tag,
u32 off, u32 size, void* target) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id");
Log.report(logvisor::Fatal, fmt("attempted to access null id"));
if (m_asyncLoadMap.find(tag) != m_asyncLoadMap.end())
return {};
return std::static_pointer_cast<urde::IDvdRequest>(
@@ -317,7 +314,7 @@ std::shared_ptr<urde::IDvdRequest> ProjectResourceFactoryBase::LoadResourcePartA
std::unique_ptr<u8[]> ProjectResourceFactoryBase::LoadResourceSync(const urde::SObjectTag& tag) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id");
Log.report(logvisor::Fatal, fmt("attempted to access null id"));
/* Ensure resource at requested path is indexed and not cooking */
const hecl::ProjectPath* resPath = nullptr;
@@ -335,7 +332,7 @@ std::unique_ptr<u8[]> ProjectResourceFactoryBase::LoadResourceSync(const urde::S
std::unique_ptr<u8[]> ProjectResourceFactoryBase::LoadNewResourcePartSync(const urde::SObjectTag& tag, u32 off,
u32 size) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id");
Log.report(logvisor::Fatal, fmt("attempted to access null id"));
/* Ensure resource at requested path is indexed and not cooking */
const hecl::ProjectPath* resPath = nullptr;
@@ -354,7 +351,7 @@ std::unique_ptr<u8[]> ProjectResourceFactoryBase::LoadNewResourcePartSync(const
std::shared_ptr<AsyncTask> ProjectResourceFactoryBase::CookResourceAsync(const urde::SObjectTag& tag) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id");
Log.report(logvisor::Fatal, fmt("attempted to access null id"));
if (m_asyncLoadMap.find(tag) != m_asyncLoadMap.end())
return {};
return _AddTask(std::make_shared<AsyncTask>(*this, tag));
@@ -364,7 +361,7 @@ void ProjectResourceFactoryBase::CancelBuild(const urde::SObjectTag& tag) { _Rem
bool ProjectResourceFactoryBase::CanBuild(const urde::SObjectTag& tag) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id");
Log.report(logvisor::Fatal, fmt("attempted to access null id"));
const hecl::ProjectPath* resPath = nullptr;
if (!WaitForTagReady(tag, resPath))
@@ -400,8 +397,7 @@ bool ProjectResourceFactoryBase::AsyncPumpTask(ItType& it) {
hecl::ProjectPath path = static_cast<DataSpec::SpecBase&>(*m_cookSpec).pathFromTag(task.x0_tag);
if (!path) {
if (!static_cast<DataSpec::SpecBase&>(*m_cookSpec).backgroundIndexRunning()) {
Log.report(logvisor::Error, _SYS_STR("unable to find async load resource (%.4s, %08X)"),
task.x0_tag.type.getChars(), task.x0_tag.id);
Log.report(logvisor::Error, fmt(_SYS_STR("unable to find async load resource ({})")), task.x0_tag);
it = _RemoveTask(it);
}
return true;
@@ -424,14 +420,14 @@ bool ProjectResourceFactoryBase::AsyncPumpTask(ItType& it) {
}
*task.xc_targetObjPtr = std::move(newObj);
Log.report(logvisor::Info, "async-built %.4s %08X", task.x0_tag.type.getChars(), u32(task.x0_tag.id.Value()));
Log.report(logvisor::Info, fmt("async-built {}"), task.x0_tag);
} else if (task.xc_targetDataPtr) {
/* Buffer only */
*task.xc_targetDataPtr = std::move(task.x10_loadBuffer);
Log.report(logvisor::Info, "async-loaded %.4s %08X", task.x0_tag.type.getChars(), u32(task.x0_tag.id.Value()));
Log.report(logvisor::Info, fmt("async-loaded {}"), task.x0_tag);
} else if (task.xc_targetDataRawPtr) {
/* Buffer only raw */
Log.report(logvisor::Info, "async-loaded %.4s %08X", task.x0_tag.type.getChars(), u32(task.x0_tag.id.Value()));
Log.report(logvisor::Info, fmt("async-loaded {}"), task.x0_tag);
}
}