2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 18:24:55 +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

@@ -150,8 +150,7 @@ void PAKBridge::build() {
std::string idStr = area.areaMREAId.toString();
areaDeps.name = hecl::SystemString(_SYS_STR("MREA_")) + hecl::SystemStringConv(idStr).c_str();
}
hecl::SystemChar num[16];
hecl::SNPrintf(num, 16, _SYS_STR("%02u "), ai);
hecl::SystemString num = fmt::format(fmt(_SYS_STR("{:02d} ")), ai);
areaDeps.name = num + areaDeps.name;
std::string lowerName(hecl::SystemUTF8Conv(areaDeps.name).str());
@@ -175,7 +174,7 @@ void PAKBridge::build() {
layer.active = layerFlags.flags >> (l - 1) & 0x1;
layer.name = hecl::StringUtils::TrimWhitespace(layer.name);
hecl::SNPrintf(num, 16, _SYS_STR("%02u "), l - 1);
num = fmt::format(fmt(_SYS_STR("{:02d} ")), l - 1);
layer.name = num + layer.name;
layer.resources.reserve(area.depLayers[l] - r);
@@ -208,37 +207,37 @@ void PAKBridge::addCMDLRigPairs(PAKRouter<PAKBridge>& pakRouter, CharacterAssoci
for (const ANCS::CharacterSet::CharacterInfo& ci : ancs.characterSet.characters) {
charAssoc.m_cmdlRigs[ci.cmdl] = std::make_pair(ci.cskr, ci.cinf);
charAssoc.m_cskrCinfToCharacter[ci.cskr] =
std::make_pair(entry.second.id, hecl::Format("%s.CSKR", ci.name.c_str()));
std::make_pair(entry.second.id, fmt::format(fmt("{}.CSKR"), ci.name));
charAssoc.m_cskrCinfToCharacter[ci.cinf] =
std::make_pair(entry.second.id, hecl::Format("CINF_%08X.CINF", ci.cinf.toUint32()));
std::make_pair(entry.second.id, fmt::format(fmt("CINF_{}.CINF"), ci.cinf));
PAK::Entry* cmdlEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cmdl);
PAK::Entry* cskrEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cskr);
PAK::Entry* cinfEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cinf);
cmdlEnt->name = hecl::Format("ANCS_%08X_%s_model", entry.first.toUint32(), ci.name.c_str());
cskrEnt->name = hecl::Format("ANCS_%08X_%s_skin", entry.first.toUint32(), ci.name.c_str());
cinfEnt->name = hecl::Format("ANCS_%08X_%s_skel", entry.first.toUint32(), ci.name.c_str());
if (ci.cmdlIce && ci.cskrIce) {
cmdlEnt->name = fmt::format(fmt("ANCS_{}_{}_model"), entry.first, ci.name);
cskrEnt->name = fmt::format(fmt("ANCS_{}_{}_skin"), entry.first, ci.name);
cinfEnt->name = fmt::format(fmt("ANCS_{}_{}_skel"), entry.first, ci.name);
if (ci.cmdlIce.isValid() && ci.cskrIce.isValid()) {
charAssoc.m_cmdlRigs[ci.cmdlIce] = std::make_pair(ci.cskrIce, ci.cinf);
charAssoc.m_cskrCinfToCharacter[ci.cskrIce] =
std::make_pair(entry.second.id, hecl::Format("%s.ICE.CSKR", ci.name.c_str()));
std::make_pair(entry.second.id, fmt::format(fmt("{}.ICE.CSKR"), ci.name));
PAK::Entry* cmdlEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cmdlIce);
PAK::Entry* cskrEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cskrIce);
cmdlEnt->name = hecl::Format("ANCS_%08X_%s_icemodel", entry.first.toUint32(), ci.name.c_str());
cskrEnt->name = hecl::Format("ANCS_%08X_%s_iceskin", entry.first.toUint32(), ci.name.c_str());
cmdlEnt->name = fmt::format(fmt("ANCS_{}_{}_icemodel"), entry.first, ci.name);
cskrEnt->name = fmt::format(fmt("ANCS_{}_{}_iceskin"), entry.first, ci.name);
}
}
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>> animInfo;
ancs.getAnimationResInfo(&pakRouter, animInfo);
for (auto& ae : animInfo) {
PAK::Entry* animEnt = (PAK::Entry*)m_pak.lookupEntry(ae.second.animId);
animEnt->name = hecl::Format("ANCS_%08X_%s", entry.first.toUint32(), ae.second.name.c_str());
animEnt->name = fmt::format(fmt("ANCS_{}_{}"), entry.first, ae.second.name);
charAssoc.m_cskrCinfToCharacter[ae.second.animId] =
std::make_pair(entry.second.id, hecl::Format("%s.ANIM", ae.second.name.c_str()));
if (ae.second.evntId) {
std::make_pair(entry.second.id, fmt::format(fmt("{}.ANIM"), ae.second.name));
if (ae.second.evntId.isValid()) {
PAK::Entry* evntEnt = (PAK::Entry*)m_pak.lookupEntry(ae.second.evntId);
evntEnt->name = hecl::Format("ANCS_%08X_%s_evnt", entry.first.toUint32(), ae.second.name.c_str());
evntEnt->name = fmt::format(fmt("ANCS_{}_{}_evnt"), entry.first, ae.second.name);
charAssoc.m_cskrCinfToCharacter[ae.second.evntId] =
std::make_pair(entry.second.id, hecl::Format("%s.evnt.yaml", ae.second.name.c_str()));
std::make_pair(entry.second.id, fmt::format(fmt("{}.evnt.yaml"), ae.second.name));
}
}
} else if (entry.second.type == FOURCC('MREA')) {
@@ -254,7 +253,7 @@ void PAKBridge::addPATHToMREA(PAKRouter<PAKBridge>& pakRouter,
if (entry.second.type == FOURCC('MREA')) {
PAKEntryReadStream rs = entry.second.beginReadStream(m_node);
UniqueID32 pathID = MREA::GetPATHId(rs);
if (pathID)
if (pathID.isValid())
pathToMrea[pathID] = entry.first;
}
}
@@ -274,7 +273,7 @@ void PAKBridge::addMAPATransforms(PAKRouter<PAKBridge>& pakRouter,
}
hecl::ProjectPath mlvlDirPath = pakRouter.getWorking(&entry.second).getParentPath();
if (mlvl.worldNameId)
if (mlvl.worldNameId.isValid())
pathOverrides[mlvl.worldNameId] = hecl::ProjectPath(mlvlDirPath, _SYS_STR("!name.yaml"));
for (const MLVL::Area& area : mlvl.areas) {
@@ -284,17 +283,17 @@ void PAKBridge::addMAPATransforms(PAKRouter<PAKBridge>& pakRouter,
const PAK::Entry* areaEntry = pakRouter.lookupEntry(area.areaMREAId, &areaNode);
PAKEntryReadStream rs = areaEntry->beginReadStream(*areaNode);
UniqueID32 pathId = MREA::GetPATHId(rs);
if (pathId)
if (pathId.isValid())
addTo[pathId] = zeus::CMatrix4f(area.transformMtx[0], area.transformMtx[1], area.transformMtx[2], BottomRow)
.transposed();
}
hecl::ProjectPath areaDirPath = pakRouter.getWorking(area.areaMREAId).getParentPath();
if (area.areaNameId)
if (area.areaNameId.isValid())
pathOverrides[area.areaNameId] = hecl::ProjectPath(areaDirPath, _SYS_STR("!name.yaml"));
}
if (mlvl.worldMap) {
if (mlvl.worldMap.isValid()) {
const nod::Node* mapNode;
const PAK::Entry* mapEntry = pakRouter.lookupEntry(mlvl.worldMap, &mapNode);
if (mapEntry) {
@@ -319,7 +318,7 @@ void PAKBridge::addMAPATransforms(PAKRouter<PAKBridge>& pakRouter,
}
ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const nod::Node& pakNode, const PAK& pak, const PAK::Entry& entry) {
switch (entry.type) {
switch (entry.type.toUint32()) {
case SBIG('STRG'):
return {STRG::Extract, {_SYS_STR(".yaml")}};
case SBIG('SCAN'):