2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 13:44:56 +00:00

Integrate URDEVersionInfo

This commit is contained in:
2020-04-15 06:42:44 -07:00
parent e553a9022f
commit 52b4db2f00
11 changed files with 144 additions and 87 deletions

View File

@@ -9,6 +9,7 @@ make_dnalist(CMDL
EGMC
SAVWCommon
ParticleCommon
URDEVersionInfo
Tweaks/ITweakPlayerGun)
set(DNACOMMON_SOURCES
@@ -40,6 +41,7 @@ set(DNACOMMON_SOURCES
RigInverter.hpp RigInverter.cpp
AROTBuilder.hpp AROTBuilder.cpp
OBBTreeBuilder.hpp OBBTreeBuilder.cpp
URDEVersionInfo.hpp
Tweaks/ITweak.hpp
Tweaks/TweakWriter.hpp
Tweaks/ITweakGame.hpp

View File

@@ -3,11 +3,12 @@
#include <cstdlib>
#endif
#include "SpecBase.hpp"
#include "Blender/BlenderSupport.hpp"
#include "DNACommon/DNACommon.hpp"
#include "DNACommon/TXTR.hpp"
#include "AssetNameMap.hpp"
#include "DataSpec/SpecBase.hpp"
#include "DataSpec/Blender/BlenderSupport.hpp"
#include "DataSpec/DNACommon/DNACommon.hpp"
#include "DataSpec/DNACommon/TXTR.hpp"
#include "DataSpec/AssetNameMap.hpp"
#include "DataSpec/DNACommon/URDEVersionInfo.hpp"
#include "hecl/ClientProcess.hpp"
#include "nod/DiscBase.hpp"
#include "nod/nod.hpp"
@@ -42,7 +43,9 @@ SpecBase::SpecBase(const hecl::Database::DataSpecEntry* specEntry, hecl::Databas
: hecl::Database::IDataSpec(specEntry)
, m_project(project)
, m_pc(pc)
, m_masterShader(project.getProjectWorkingPath(), ".hecl/RetroMasterShader.blend") {
, m_masterShader(project.getProjectWorkingPath(), ".hecl/RetroMasterShader.blend")
, m_region(ERegion::Invalid)
, m_game(EGame::Invalid) {
AssetNameMap::InitAssetNameMap();
SpecBase::setThreadProject();
}
@@ -128,8 +131,7 @@ bool IsPathAudioGroup(const hecl::ProjectPath& path) {
}
static bool IsPathSong(const hecl::ProjectPath& path) {
if (path.getPathType() != hecl::ProjectPath::Type::Glob ||
!path.getWithExtension(_SYS_STR(".mid"), true).isFile() ||
if (path.getPathType() != hecl::ProjectPath::Type::Glob || !path.getWithExtension(_SYS_STR(".mid"), true).isFile() ||
!path.getWithExtension(_SYS_STR(".yaml"), true).isFile()) {
return path.isFile() && path.getLastComponentExt() == _SYS_STR("mid") &&
path.getWithExtension(_SYS_STR(".yaml"), true).isFile();
@@ -311,7 +313,8 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector
hecl::SystemStringConv chSysName(sub.name);
if (!sub.cskrId.empty()) {
hecl::SystemStringConv cskrSysName(sub.cskrId);
pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.CSKR")), chSysName, cskrSysName)));
pathsOut.push_back(
asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.CSKR")), chSysName, cskrSysName)));
} else {
pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.CSKR")), chSysName)));
}
@@ -327,7 +330,8 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector
flattenDependenciesBlend(overlay.mesh, pathsOut, btok);
pathsOut.push_back(overlay.mesh);
}
pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.{}_{}.CSKR")), chSysName, overlaySys, overlayCskrId)));
pathsOut.push_back(asGlob.ensureAuxInfo(
fmt::format(FMT_STRING(_SYS_STR("{}.{}_{}.CSKR")), chSysName, overlaySys, overlayCskrId)));
}
}
};
@@ -345,7 +349,8 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector
hecl::SystemStringConv chSysName(att.name);
hecl::SystemStringConv sysCskrId(att.cskrId);
pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}_{}.CSKR")), chSysName, sysCskrId)));
pathsOut.push_back(
asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}_{}.CSKR")), chSysName, sysCskrId)));
if (att.armature >= 0) {
const auto& arm = actor.armatures[att.armature];
@@ -358,8 +363,9 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector
hecl::SystemStringConv actSysName(act.first);
hecl::SystemStringConv actAnimId(act.second);
pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.ANIM")), actSysName, actAnimId)));
hecl::SystemString searchPrefix(asGlob.getWithExtension(
fmt::format(FMT_STRING(_SYS_STR(".{}_")), actSysName).c_str(), true).getLastComponent());
hecl::SystemString searchPrefix(
asGlob.getWithExtension(fmt::format(FMT_STRING(_SYS_STR(".{}_")), actSysName).c_str(), true)
.getLastComponent());
hecl::ProjectPath evntPath;
for (const auto& ent : dEnum) {
if (hecl::StringUtils::BeginsWith(ent.m_name, searchPrefix.c_str()) &&
@@ -628,8 +634,7 @@ void SpecBase::doPackage(const hecl::ProjectPath& path, const hecl::Database::Da
std::unordered_set<urde::SObjectTag> addedTags;
addedTags.reserve(buildList.size());
for (auto& tag : buildList) {
if ((i == 0 && tag.type == FOURCC('CMDL')) ||
(i == 1 && tag.type != FOURCC('CMDL'))) {
if ((i == 0 && tag.type == FOURCC('CMDL')) || (i == 1 && tag.type != FOURCC('CMDL'))) {
if (addedTags.find(tag) != addedTags.end())
continue;
addedTags.insert(tag);
@@ -1010,11 +1015,10 @@ bool SpecBase::addFileToIndex(const hecl::ProjectPath& path, athena::io::YAMLDoc
hecl::SystemStringConv overlaySys(overlay.first);
hecl::SystemStringConv overlayCskrId(overlay.second);
if (!overlay.second.empty()) {
subPath =
asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.{}_{}.CSKR")), subName, overlaySys, overlayCskrId));
subPath = asGlob.ensureAuxInfo(
fmt::format(FMT_STRING(_SYS_STR("{}.{}_{}.CSKR")), subName, overlaySys, overlayCskrId));
} else {
subPath =
asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.{}.CSKR")), subName, overlaySys));
subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.{}.CSKR")), subName, overlaySys));
}
insertPathTag(cacheWriter, buildTagFromPath(subPath), subPath);
}
@@ -1026,11 +1030,10 @@ bool SpecBase::addFileToIndex(const hecl::ProjectPath& path, athena::io::YAMLDoc
hecl::SystemStringConv attachmentCskrId(attachment.second);
hecl::ProjectPath subPath;
if (!attachment.second.empty()) {
subPath =
asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}_{}.CSKR")), attachmentSys, attachmentCskrId));
subPath = asGlob.ensureAuxInfo(
fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}_{}.CSKR")), attachmentSys, attachmentCskrId));
} else {
subPath =
asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}.CSKR")), attachmentSys));
subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}.CSKR")), attachmentSys));
}
insertPathTag(cacheWriter, buildTagFromPath(subPath), subPath);
}
@@ -1164,8 +1167,8 @@ void SpecBase::backgroundIndexProc() {
}
}
}
Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Name index of '{}' loaded; {} names")), getOriginalSpec().m_name,
m_catalogNameToTag.size());
Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Name index of '{}' loaded; {} names")),
getOriginalSpec().m_name, m_catalogNameToTag.size());
}
}
}
@@ -1208,15 +1211,16 @@ void SpecBase::waitForIndexComplete() const {
}
}
void SpecBase::WriteVersionInfo(hecl::Database::Project &project, const hecl::ProjectPath &pakPath) {
hecl::ProjectPath versionPath(pakPath, _SYS_STR("version.yaml"));
versionPath.makeDirChain(false);
void SpecBase::WriteVersionInfo(hecl::Database::Project& project, const hecl::ProjectPath& pakPath) {
hecl::ProjectPath versionPath(pakPath, _SYS_STR("version.yaml"));
versionPath.makeDirChain(false);
athena::io::YAMLDocWriter yamlW("URDEVersionData");
yamlW.writeString("version", m_version);
yamlW.writeByte("region", atUint8(m_region));
yamlW.writeBool("is_trilogy", !m_standalone);
athena::io::FileWriter fileW(versionPath.getAbsolutePath());
yamlW.finish(&fileW);
URDEVersionInfo info;
info.version = m_version;
info.region = m_region;
info.game = m_game;
info.isTrilogy = !m_standalone;
athena::io::FileWriter writer(versionPath.getAbsolutePath());
athena::io::ToYAMLStream(info, writer);
}
} // namespace DataSpec

View File

@@ -12,6 +12,7 @@
#include "hecl/Blender/Token.hpp"
#include "Runtime/RetroTypes.hpp"
namespace nod {
class DiscBase;
class Node;
@@ -23,13 +24,8 @@ class YAMLDocWriter;
} // namespace athena::io
namespace DataSpec {
enum class ERegion {
Invalid = 0,
NTSC_U = 'E',
PAL = 'P',
NTSC_J = 'J'
};
enum class ERegion;
enum class EGame;
struct SpecBase : hecl::Database::IDataSpec {
/* HECL Adaptors */
void setThreadProject() override;
@@ -203,9 +199,10 @@ protected:
const std::unordered_map<urde::CAssetId, std::vector<uint8_t>>& mlvlData);
std::unique_ptr<nod::DiscBase> m_disc;
bool m_isWii;
bool m_standalone;
ERegion m_region = ERegion::Invalid;
bool m_isWii{};
bool m_standalone{};
ERegion m_region;
EGame m_game;
std::string m_version;
void WriteVersionInfo(hecl::Database::Project& project, const hecl::ProjectPath& pakPath);

View File

@@ -29,6 +29,7 @@
#include "DNACommon/DPSC.hpp"
#include "DNACommon/DGRP.hpp"
#include "DNACommon/MAPU.hpp"
#include "DNACommon/URDEVersionInfo.hpp"
#include "DNACommon/Tweaks/TweakWriter.hpp"
#include "DNAMP1/Tweaks/CTweakPlayerRes.hpp"
#include "DNAMP1/Tweaks/CTweakGunRes.hpp"
@@ -46,7 +47,6 @@
#include "DNAMP1/Tweaks/CTweakPlayerGun.hpp"
#include "DNAMP1/MazeSeeds.hpp"
#include "DNAMP1/SnowForces.hpp"
#include "hecl/ClientProcess.hpp"
#include "hecl/MultiProgressPrinter.hpp"
#include "hecl/Blender/Connection.hpp"
@@ -145,7 +145,8 @@ struct SpecMP1 : SpecBase {
, m_workPath(project.getProjectWorkingPath(), _SYS_STR("MP1"))
, m_cookPath(project.getProjectCookedPath(SpecEntMP1), _SYS_STR("MP1"))
, m_pakRouter(*this, m_workPath, m_cookPath) {
setThreadProject();
m_game = EGame::MetroidPrime1;
SpecBase::setThreadProject();
}
void buildPaks(nod::Node& root, const std::vector<hecl::SystemString>& args, ExtractReport& rep) {
@@ -197,8 +198,9 @@ struct SpecMP1 : SpecBase {
/* Sort PAKs alphabetically */
m_orderedPaks.clear();
for (DNAMP1::PAKBridge& dpak : m_paks)
for (DNAMP1::PAKBridge& dpak : m_paks) {
m_orderedPaks[std::string(dpak.getName())] = &dpak;
}
/* Assemble extract report */
rep.childOpts.reserve(m_orderedPaks.size());
@@ -218,9 +220,10 @@ struct SpecMP1 : SpecBase {
const std::vector<hecl::SystemString>& args, std::vector<ExtractReport>& reps) override {
nod::IPartition* partition = disc.getDataPartition();
m_dolBuf = partition->getDOLBuf();
const char* buildInfo = (char*)memmem(m_dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16) + 19;
const char* buildInfo =
static_cast<char*>(memmem(m_dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16)) + 19;
if (!buildInfo)
if (buildInfo == nullptr)
return false;
m_version = std::string(buildInfo);
@@ -275,15 +278,15 @@ struct SpecMP1 : SpecBase {
}
m_dolBuf = dolIt->getBuf();
const char* buildInfo = (char*)memmem(m_dolBuf.get(), dolIt->size(), "MetroidBuildInfo", 16) + 19;
const char* buildInfo = static_cast<char*>(memmem(m_dolBuf.get(), dolIt->size(), "MetroidBuildInfo", 16)) + 19;
/* Root Report */
ExtractReport& rep = reps.emplace_back();
rep.name = _SYS_STR("MP1");
rep.desc = _SYS_STR("Metroid Prime ") + regstr;
if (buildInfo) {
std::string buildStr(buildInfo);
hecl::SystemStringConv buildView(buildStr);
if (buildInfo != nullptr) {
m_version = std::string(buildInfo);
hecl::SystemStringConv buildView(m_version);
rep.desc += _SYS_STR(" (") + buildView + _SYS_STR(")");
}

View File

@@ -12,6 +12,7 @@
#include "DNACommon/MAPU.hpp"
#include "DNACommon/PATH.hpp"
#include "DNACommon/TXTR.hpp"
#include "DNACommon/URDEVersionInfo.hpp"
#include "hecl/ClientProcess.hpp"
#include "hecl/Blender/Connection.hpp"
@@ -111,7 +112,8 @@ struct SpecMP2 : SpecBase {
, m_workPath(project.getProjectWorkingPath(), _SYS_STR("MP2"))
, m_cookPath(project.getProjectCookedPath(SpecEntMP2), _SYS_STR("MP2"))
, m_pakRouter(*this, m_workPath, m_cookPath) {
setThreadProject();
m_game = EGame::MetroidPrime2;
SpecBase::setThreadProject();
}
void buildPaks(nod::Node& root, const std::vector<hecl::SystemString>& args, ExtractReport& rep) {
@@ -183,9 +185,10 @@ struct SpecMP2 : SpecBase {
const std::vector<hecl::SystemString>& args, std::vector<ExtractReport>& reps) override {
nod::IPartition* partition = disc.getDataPartition();
std::unique_ptr<uint8_t[]> dolBuf = partition->getDOLBuf();
const char* buildInfo = (char*)memmem(dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16) + 19;
if (!buildInfo)
const char* buildInfo = static_cast<char*>(memmem(dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16)) + 19;
if (buildInfo == nullptr) {
return false;
}
m_version = std::string(buildInfo);
/* Root Report */
@@ -206,7 +209,7 @@ struct SpecMP2 : SpecBase {
const std::vector<hecl::SystemString>& args, std::vector<ExtractReport>& reps) override {
std::vector<hecl::SystemString> mp2args;
bool doExtract = false;
if (args.size()) {
if (!args.empty()) {
/* Needs filter */
for (const hecl::SystemString& arg : args) {
hecl::SystemString lowerArg = arg;
@@ -237,15 +240,15 @@ struct SpecMP2 : SpecBase {
}
std::unique_ptr<uint8_t[]> dolBuf = dolIt->getBuf();
const char* buildInfo = (char*)memmem(dolBuf.get(), dolIt->size(), "MetroidBuildInfo", 16) + 19;
const char* buildInfo = static_cast<char*>(memmem(dolBuf.get(), dolIt->size(), "MetroidBuildInfo", 16)) + 19;
/* Root Report */
ExtractReport& rep = reps.emplace_back();
rep.name = _SYS_STR("MP2");
rep.desc = _SYS_STR("Metroid Prime 2 ") + regstr;
if (buildInfo) {
std::string buildStr(buildInfo);
hecl::SystemStringConv buildView(buildStr);
if (buildInfo != nullptr) {
m_version = std::string(buildInfo);
hecl::SystemStringConv buildView(m_version);
rep.desc += _SYS_STR(" (") + buildView + _SYS_STR(")");
}

View File

@@ -9,6 +9,7 @@
#include "DataSpec/DNAMP3/MAPA.hpp"
#include "DataSpec/DNAMP2/STRG.hpp"
#include "DataSpec/DNACommon/TXTR.hpp"
#include "DataSpec/DNACommon/URDEVersionInfo.hpp"
#include "hecl/ClientProcess.hpp"
#include "hecl/Blender/Connection.hpp"
@@ -89,11 +90,7 @@ struct TextureCache {
};
struct SpecMP3 : SpecBase {
bool checkStandaloneID(const char* id) const override {
if (!memcmp(id, "RM3", 3))
return true;
return false;
}
bool checkStandaloneID(const char* id) const override { return memcmp(id, "RM3", 3) == 0; }
bool doMP3 = false;
std::vector<const nod::Node*> m_nonPaks;
@@ -122,7 +119,8 @@ struct SpecMP3 : SpecBase {
, m_feWorkPath(project.getProjectWorkingPath(), _SYS_STR("fe"))
, m_feCookPath(project.getProjectCookedPath(SpecEntMP3), _SYS_STR("fe"))
, m_fePakRouter(*this, m_feWorkPath, m_feCookPath) {
setThreadProject();
m_game = EGame::MetroidPrime3;
SpecBase::setThreadProject();
}
void buildPaks(nod::Node& root, const std::vector<hecl::SystemString>& args, ExtractReport& rep, bool fe) {
@@ -223,13 +221,15 @@ struct SpecMP3 : SpecBase {
doMP3 = true;
nod::IPartition* partition = disc.getDataPartition();
std::unique_ptr<uint8_t[]> dolBuf = partition->getDOLBuf();
const char* buildInfo = (char*)memmem(dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16) + 19;
if (!buildInfo)
const char* buildInfo = static_cast<char*>(memmem(dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16)) + 19;
if (buildInfo == nullptr) {
return false;
}
/* We don't want no stinking demo dammit */
if (!strcmp(buildInfo, "Build v3.068 3/2/2006 14:55:13"))
if (strcmp(buildInfo, "Build v3.068 3/2/2006 14:55:13") == 0) {
return false;
}
m_version = std::string(buildInfo);
/* Root Report */
@@ -317,8 +317,8 @@ struct SpecMP3 : SpecBase {
rep.name = _SYS_STR("MP3");
rep.desc = _SYS_STR("Metroid Prime 3 ") + regstr;
std::string buildStr(buildInfo);
hecl::SystemStringConv buildView(buildStr);
m_version = std::string(buildInfo);
hecl::SystemStringConv buildView(m_version);
rep.desc += _SYS_STR(" (") + buildView + _SYS_STR(")");
/* Iterate PAKs and build level options */