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

Humungous refactor

This commit is contained in:
Jack Andersen
2016-03-04 13:04:53 -10:00
parent 552ec1db4a
commit 783fb4c4fe
330 changed files with 2943 additions and 3077 deletions

View File

@@ -6,21 +6,21 @@ namespace DataSpec
namespace DNAMP1
{
void SCLY::read(Athena::io::IStreamReader& rs)
void SCLY::read(athena::io::IStreamReader& rs)
{
fourCC = rs.readUint32Little();
version = rs.readUint32Big();
layerCount = rs.readUint32Big();
rs.enumerateBig(layerSizes, layerCount);
atUint32 i = 0;
rs.enumerate<ScriptLayer>(layers, layerCount, [&i,this](Athena::io::IStreamReader& rs, ScriptLayer& layer) {
rs.enumerate<ScriptLayer>(layers, layerCount, [&i,this](athena::io::IStreamReader& rs, ScriptLayer& layer) {
atUint64 start = rs.position();
layer.read(rs);
rs.seek(start + layerSizes[i++], Athena::Begin);
rs.seek(start + layerSizes[i++], athena::Begin);
});
}
void SCLY::write(Athena::io::IStreamWriter& ws) const
void SCLY::write(athena::io::IStreamWriter& ws) const
{
ws.writeUint32Big(fourCC);
ws.writeUint32Big(version);
@@ -40,14 +40,14 @@ void SCLY::exportToLayerDirectories(const PAK::Entry& entry, PAKRouter<PAKBridge
{
for (atUint32 i = 0; i < layerCount; i++)
{
HECL::ProjectPath layerPath = pakRouter.getAreaLayerWorking(entry.id, i);
if (layerPath.getPathType() == HECL::ProjectPath::Type::None)
hecl::ProjectPath layerPath = pakRouter.getAreaLayerWorking(entry.id, i);
if (layerPath.getPathType() == hecl::ProjectPath::Type::None)
layerPath.makeDir();
HECL::ProjectPath yamlFile = HECL::ProjectPath(layerPath, _S("objects.yaml"));
if (force || yamlFile.getPathType() == HECL::ProjectPath::Type::None)
hecl::ProjectPath yamlFile = hecl::ProjectPath(layerPath, _S("objects.yaml"));
if (force || yamlFile.getPathType() == hecl::ProjectPath::Type::None)
{
FILE* yaml = HECL::Fopen(yamlFile.getAbsolutePath().c_str(), _S("wb"));
FILE* yaml = hecl::Fopen(yamlFile.getAbsolutePath().c_str(), _S("wb"));
layers[i].toYAMLFile(yaml);
fclose(yaml);
}
@@ -80,33 +80,32 @@ void SCLY::ScriptLayer::nameIDs(PAKRouter<PAKBridge>& pakRouter) const
obj->nameIDs(pakRouter);
}
void SCLY::read(Athena::io::YAMLDocReader& docin)
void SCLY::read(athena::io::YAMLDocReader& docin)
{
fourCC = docin.readUint32("fourCC");
version = docin.readUint32("version");
layerCount = docin.readUint32("layerCount");
docin.enumerate("layerSizes", layerSizes, layerCount);
docin.enumerate("layers", layers, layerCount);
layerCount = docin.enumerate("layerSizes", layerSizes);
docin.enumerate("layers", layers);
}
void SCLY::write(Athena::io::YAMLDocWriter& docout) const
void SCLY::write(athena::io::YAMLDocWriter& docout) const
{
docout.writeUint32("fourCC", fourCC);
docout.writeUint32("version", version);
docout.writeUint32("layerCount", layerCount);
docout.enumerate("layerSizes", layerSizes);
docout.enumerate("layers", layers);
}
const char* SCLY::DNAType()
{
return "Retro::DNAMP1::SCLY";
return "urde::DNAMP1::SCLY";
}
void SCLY::ScriptLayer::read(Athena::io::IStreamReader& rs)
void SCLY::ScriptLayer::read(athena::io::IStreamReader& rs)
{
unknown = rs.readUByte();
objectCount = rs.readUint32Big();
objects.clear();
objects.reserve(objectCount);
for (atUint32 i = 0; i < objectCount; i++)
{
@@ -125,20 +124,22 @@ void SCLY::ScriptLayer::read(Athena::io::IStreamReader& rs)
objects.push_back(std::move(obj));
size_t actualLen = rs.position() - start;
if (actualLen != len)
Log.report(LogVisor::FatalError, _S("Error while reading object of type 0x%.2X, did not read the expected amount of data, read 0x%x, expected 0x%x"), (atUint32)type, actualLen, len);
rs.seek(start + len, Athena::Begin);
Log.report(logvisor::Fatal, _S("Error while reading object of type 0x%.2X, did not read the expected amount of data, read 0x%x, expected 0x%x"), (atUint32)type, actualLen, len);
rs.seek(start + len, athena::Begin);
}
else
Log.report(LogVisor::FatalError, _S("Unable to find type 0x%X in object database"), (atUint32)type);
Log.report(logvisor::Fatal, _S("Unable to find type 0x%X in object database"), (atUint32)type);
}
}
void SCLY::ScriptLayer::read(Athena::io::YAMLDocReader& rs)
void SCLY::ScriptLayer::read(athena::io::YAMLDocReader& rs)
{
unknown = rs.readUByte("unknown");
objectCount = rs.readUint32("objectCount");
objects.reserve(objectCount);
rs.enterSubVector("objects");
size_t objCount;
rs.enterSubVector("objects", objCount);
objectCount = objCount;
objects.clear();
objects.reserve(objCount);
for (atUint32 i = 0; i < objectCount; i++)
{
rs.enterSubRecord(nullptr);
@@ -154,14 +155,14 @@ void SCLY::ScriptLayer::read(Athena::io::YAMLDocReader& rs)
objects.push_back(std::move(obj));
}
else
Log.report(LogVisor::FatalError, _S("Unable to find type 0x%X in object database"), (atUint32)type);
Log.report(logvisor::Fatal, _S("Unable to find type 0x%X in object database"), (atUint32)type);
rs.leaveSubRecord();
}
rs.leaveSubVector();
}
void SCLY::ScriptLayer::write(Athena::io::IStreamWriter& ws) const
void SCLY::ScriptLayer::write(athena::io::IStreamWriter& ws) const
{
ws.writeUByte(unknown);
ws.writeUint32Big(objectCount);
@@ -183,10 +184,9 @@ size_t SCLY::ScriptLayer::binarySize(size_t __isz) const
return __isz;
}
void SCLY::ScriptLayer::write(Athena::io::YAMLDocWriter& ws) const
void SCLY::ScriptLayer::write(athena::io::YAMLDocWriter& ws) const
{
ws.writeUByte("unknown", unknown);
ws.writeUint32("objectCount", objectCount);
ws.enterSubVector("objects");
for (const std::unique_ptr<IScriptObject>& obj : objects)
{
@@ -200,7 +200,7 @@ void SCLY::ScriptLayer::write(Athena::io::YAMLDocWriter& ws) const
const char* SCLY::ScriptLayer::DNAType()
{
return "Retro::DNAMP1::SCLY::ScriptLayer";
return "urde::DNAMP1::SCLY::ScriptLayer";
}
}