Athena YAML refactor

This commit is contained in:
Jack Andersen 2016-08-21 17:47:48 -10:00
parent bf049843e1
commit f8fb72250a
36 changed files with 124 additions and 187 deletions

View File

@ -305,13 +305,12 @@ template struct CRSM<UniqueID64>;
template <class IDType>
bool ExtractCRSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w"));
if (fp)
athena::io::FileWriter writer(outPath.getAbsolutePath());
if (writer.isOpen())
{
CRSM<IDType> crsm;
crsm.read(rs);
crsm.toYAMLFile(fp);
fclose(fp);
crsm.toYAMLStream(writer);
return true;
}
return false;

View File

@ -110,13 +110,12 @@ template struct DGRP<UniqueID64>;
template <class IDType>
bool ExtractDGRP(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w"));
if (fp)
athena::io::FileWriter writer(outPath.getAbsolutePath());
if (writer.isOpen())
{
DGRP<IDType> dgrp;
dgrp.read(rs);
dgrp.toYAMLFile(fp);
fclose(fp);
dgrp.toYAMLStream(writer);
return true;
}
return false;

View File

@ -3,6 +3,8 @@
#include <stdio.h>
#include <athena/DNAYaml.hpp>
#include <athena/FileReader.hpp>
#include <athena/FileWriter.hpp>
#include <nod/DiscBase.hpp>
#include "hecl/hecl.hpp"
#include "hecl/Database.hpp"

View File

@ -410,13 +410,12 @@ template struct DPSM<UniqueID64>;
template <class IDType>
bool ExtractDPSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w"));
if (fp)
athena::io::FileWriter writer(outPath.getAbsolutePath());
if (writer.isOpen())
{
DPSM<IDType> dpsm;
dpsm.read(rs);
dpsm.toYAMLFile(fp);
fclose(fp);
dpsm.toYAMLStream(writer);
return true;
}
return false;

View File

@ -450,13 +450,12 @@ template struct ELSM<UniqueID64>;
template <class IDType>
bool ExtractELSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w"));
if (fp)
athena::io::FileWriter writer(outPath.getAbsolutePath());
if (writer.isOpen())
{
ELSM<IDType> elsm;
elsm.read(rs);
elsm.toYAMLFile(fp);
fclose(fp);
elsm.toYAMLStream(writer);
return true;
}
return false;

View File

@ -547,13 +547,12 @@ template struct FONT<UniqueID64>;
template <class IDType>
bool ExtractFONT(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w"));
if (fp)
athena::io::FileWriter writer(outPath.getAbsolutePath());
if (writer.isOpen())
{
FONT<IDType> font;
font.read(rs);
font.toYAMLFile(fp);
fclose(fp);
font.toYAMLStream(writer);
return true;
}
return false;

View File

@ -984,13 +984,12 @@ template struct FSM2<UniqueID64>;
template <class IDType>
bool ExtractFSM2(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w"));
if (fp)
athena::io::FileWriter writer(outPath.getAbsolutePath());
if (writer.isOpen())
{
FSM2<IDType> fsm2;
fsm2.read(rs);
fsm2.toYAMLFile(fp);
fclose(fp);
fsm2.toYAMLStream(writer);
return true;
}
return false;

View File

@ -214,10 +214,8 @@ void PAKRouter<BRIDGETYPE>::build(std::vector<BRIDGETYPE>& bridges, std::functio
intptr_t curBridgeIdx = reinterpret_cast<intptr_t>(m_curBridgeIdx.get());
const hecl::ProjectPath& pakPath = m_bridgePaths[curBridgeIdx].first;
hecl::SystemString catalogPath = hecl::ProjectPath(pakPath, "catalog.yaml").getAbsolutePath();
FILE* catalog = hecl::Fopen(catalogPath.c_str(), _S("w"));
yaml_emitter_set_output_file(catalogWriter.getEmitter(), catalog);
catalogWriter.finish();
fclose(catalog);
athena::io::FileWriter writer(catalogPath);
catalogWriter.finish(&writer);
}
}

View File

@ -1538,13 +1538,12 @@ template struct GPSM<UniqueID64>;
template <class IDType>
bool ExtractGPSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w"));
if (fp)
athena::io::FileWriter writer(outPath.getAbsolutePath());
if (writer.isOpen())
{
GPSM<IDType> gpsm;
gpsm.read(rs);
gpsm.toYAMLFile(fp);
fclose(fp);
gpsm.toYAMLStream(writer);
return true;
}
return false;

View File

@ -45,9 +45,8 @@ static bool ExtractSAVW(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath
{
SAVW savw;
savw.read(rs);
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
savw.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(outPath.getAbsolutePath());
savw.toYAMLStream(writer);
return true;
}

View File

@ -544,13 +544,12 @@ template struct SWSH<UniqueID64>;
template <class IDType>
bool ExtractSWSH(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w"));
if (fp)
athena::io::FileWriter writer(outPath.getAbsolutePath());
if (writer.isOpen())
{
SWSH<IDType> swsh;
swsh.read(rs);
swsh.toYAMLFile(fp);
fclose(fp);
swsh.toYAMLStream(writer);
return true;
}
return false;

View File

@ -725,13 +725,12 @@ template struct WPSM<UniqueID64>;
template <class IDType>
bool ExtractWPSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w"));
if (fp)
athena::io::FileWriter writer(outPath.getAbsolutePath());
if (writer.isOpen())
{
WPSM<IDType> wpsm;
wpsm.read(rs);
wpsm.toYAMLFile(fp);
fclose(fp);
wpsm.toYAMLStream(writer);
return true;
}
return false;

View File

@ -159,9 +159,8 @@ struct AFSM : public BigYAML
{
AFSM afsm;
afsm.read(rs);
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
afsm.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(outPath.getAbsolutePath());
afsm.toYAMLStream(writer);
return true;
}
};

View File

@ -1031,9 +1031,8 @@ bool ANCS::Extract(const SpecBase& dataSpec,
{
if (force || yamlType == hecl::ProjectPath::Type::None)
{
FILE* fp = hecl::Fopen(yamlPath.getAbsolutePath().c_str(), _S("w"));
ancs.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(yamlPath.getAbsolutePath());
ancs.toYAMLStream(writer);
}
if (force || blendType == hecl::ProjectPath::Type::None)
@ -1062,9 +1061,8 @@ bool ANCS::Extract(const SpecBase& dataSpec,
EVNT evnt;
if (pakRouter.lookupAndReadDNA(res.second.evntId, evnt, true))
{
FILE* fp = hecl::Fopen(evntYamlPath.getAbsolutePath().c_str(), _S("w"));
evnt.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(evntYamlPath.getAbsolutePath());
evnt.toYAMLStream(writer);
}
}
}
@ -1085,25 +1083,23 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
Log.report(logvisor::Fatal, _S("'%s' not found as file"),
yamlPath.getRelativePath().c_str());
FILE* yamlFp = hecl::Fopen(yamlPath.getAbsolutePath().c_str(), _S("r"));
if (!yamlFp)
athena::io::FileReader reader(yamlPath.getAbsolutePath());
if (!reader.isOpen())
Log.report(logvisor::Fatal, _S("can't open '%s' for reading"),
yamlPath.getRelativePath().c_str());
if (!BigYAML::ValidateFromYAMLFile<ANCS>(yamlFp))
if (!BigYAML::ValidateFromYAMLStream<ANCS>(reader))
{
Log.report(logvisor::Fatal, _S("'%s' is not urde::DNAMP1::ANCS type"),
yamlPath.getRelativePath().c_str());
}
athena::io::YAMLDocReader yamlReader;
yaml_parser_set_input_file(yamlReader.getParser(), yamlFp);
if (!yamlReader.parse())
if (!yamlReader.parse(&reader))
{
Log.report(logvisor::Fatal, _S("unable to parse '%s'"),
yamlPath.getRelativePath().c_str());
}
fclose(yamlFp);
ANCS ancs;
ancs.read(yamlReader);
@ -1263,12 +1259,11 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
_S(".evnt.yaml")).c_str(), true);
if (evntYamlPath.getPathType() == hecl::ProjectPath::Type::File)
{
FILE* fp = hecl::Fopen(evntYamlPath.getAbsolutePath().c_str(), _S("r"));
if (fp)
athena::io::FileReader reader(evntYamlPath.getAbsolutePath());
if (reader.isOpen())
{
EVNT evnt;
evnt.fromYAMLFile(fp);
fclose(fp);
evnt.fromYAMLStream(reader);
anim.m_anim->evnt = evntYamlPath;
hecl::ProjectPath evntYamlOut = cookedOut.getWithExtension(_S(".evnt"));

View File

@ -85,9 +85,8 @@ struct EVNT : BigYAML
{
EVNT evnt;
evnt.read(rs);
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
evnt.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(outPath.getAbsolutePath());
evnt.toYAMLStream(writer);
return true;
}
};

View File

@ -117,9 +117,8 @@ struct MLVL : BigYAML
{
MLVL mlvl;
mlvl.read(rs);
FILE* fp = hecl::Fopen(outPath.getWithExtension(_S(".yaml"), true).getAbsolutePath().c_str(), _S("w"));
mlvl.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(outPath.getWithExtension(_S(".yaml"), true).getAbsolutePath());
mlvl.toYAMLStream(writer);
hecl::BlenderConnection& conn = btok.getBlenderConnection();
return DNAMLVL::ReadMLVLToBlender(conn, mlvl, outPath, pakRouter,
entry, force, fileChanged);

View File

@ -341,23 +341,15 @@ bool MREA::PCCook(const hecl::ProjectPath& outPath,
sclyData.version = 1;
for (const hecl::ProjectPath& layer : layerScriptPaths)
{
FILE* yamlFile = hecl::Fopen(layer.getAbsolutePath().c_str(), _S("r"));
if (!yamlFile)
athena::io::FileReader freader(layer.getAbsolutePath());
if (!freader.isOpen())
continue;
if (!BigYAML::ValidateFromYAMLFile<DNAMP1::SCLY::ScriptLayer>(yamlFile))
{
fclose(yamlFile);
if (!BigYAML::ValidateFromYAMLStream<DNAMP1::SCLY::ScriptLayer>(freader))
continue;
}
athena::io::YAMLDocReader reader;
yaml_parser_set_input_file(reader.getParser(), yamlFile);
if (!reader.parse())
{
fclose(yamlFile);
if (!reader.parse(&freader))
continue;
}
fclose(yamlFile);
sclyData.layers.emplace_back();
sclyData.layers.back().read(reader);

View File

@ -156,18 +156,16 @@ struct SCAN : BigYAML
{
SCAN scan;
scan.read(rs);
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
scan.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(outPath.getAbsolutePath());
scan.toYAMLStream(writer);
return true;
}
static bool Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath)
{
SCAN scan;
FILE* fp = hecl::Fopen(inPath.getAbsolutePath().c_str(), _S("rb"));
scan.fromYAMLFile(fp);
fclose(fp);
athena::io::FileReader reader(inPath.getAbsolutePath());
scan.fromYAMLStream(reader);
athena::io::FileWriter ws(outPath.getAbsolutePath());
scan.write(ws);
return true;

View File

@ -54,9 +54,8 @@ void SCLY::exportToLayerDirectories(const PAK::Entry& entry, PAKRouter<PAKBridge
hecl::ProjectPath yamlFile(layerPath, _S("objects.yaml"));
if (force || yamlFile.getPathType() == hecl::ProjectPath::Type::None)
{
FILE* yaml = hecl::Fopen(yamlFile.getAbsolutePath().c_str(), _S("wb"));
layers[i].toYAMLFile(yaml);
fclose(yaml);
athena::io::FileWriter writer(yamlFile.getAbsolutePath());
layers[i].toYAMLStream(writer);
}
}
}

View File

@ -62,18 +62,16 @@ struct STRG : ISTRG
{
STRG strg;
strg.read(rs);
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
strg.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(outPath.getAbsolutePath());
strg.toYAMLStream(writer);
return true;
}
static bool Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath)
{
STRG strg;
FILE* fp = hecl::Fopen(inPath.getAbsolutePath().c_str(), _S("rb"));
strg.fromYAMLFile(fp);
fclose(fp);
athena::io::FileReader reader(inPath.getAbsolutePath());
strg.fromYAMLStream(reader);
athena::io::FileWriter ws(outPath.getAbsolutePath());
strg.write(ws);
return true;

View File

@ -240,9 +240,8 @@ struct ANCS : BigYAML
if (force || yamlType == hecl::ProjectPath::Type::None)
{
FILE* fp = hecl::Fopen(yamlPath.getAbsolutePath().c_str(), _S("wb"));
ancs.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(yamlPath.getAbsolutePath());
ancs.toYAMLStream(writer);
}
if (force || blendType == hecl::ProjectPath::Type::None)

View File

@ -105,9 +105,8 @@ struct MLVL : BigYAML
{
MLVL mlvl;
mlvl.read(rs);
FILE* fp = hecl::Fopen(outPath.getWithExtension(_S(".yaml"), true).getAbsolutePath().c_str(), _S("wb"));
mlvl.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(outPath.getWithExtension(_S(".yaml"), true).getAbsolutePath());
mlvl.toYAMLStream(writer);
hecl::BlenderConnection& conn = btok.getBlenderConnection();
return DNAMLVL::ReadMLVLToBlender(conn, mlvl, outPath, pakRouter,
entry, force, fileChanged);

View File

@ -68,18 +68,16 @@ struct STRG : ISTRG
{
STRG strg;
strg.read(rs);
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
strg.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(outPath.getAbsolutePath());
strg.toYAMLStream(writer);
return true;
}
static bool Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath)
{
STRG strg;
FILE* fp = hecl::Fopen(inPath.getAbsolutePath().c_str(), _S("rb"));
strg.fromYAMLFile(fp);
fclose(fp);
athena::io::FileReader reader(inPath.getAbsolutePath());
strg.fromYAMLStream(reader);
athena::io::FileWriter ws(outPath.getAbsolutePath());
strg.write(ws);
return true;

View File

@ -329,9 +329,8 @@ struct CHAR : BigYAML
if (force || yamlType == hecl::ProjectPath::Type::None)
{
FILE* fp = hecl::Fopen(yamlPath.getAbsolutePath().c_str(), _S("wb"));
aChar.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(yamlPath.getAbsolutePath());
aChar.toYAMLStream(writer);
}
if (force || blendType == hecl::ProjectPath::Type::None)

View File

@ -94,9 +94,8 @@ struct MLVL : BigYAML
{
MLVL mlvl;
mlvl.read(rs);
FILE* fp = hecl::Fopen(outPath.getWithExtension(_S(".yaml"), true).getAbsolutePath().c_str(), _S("wb"));
mlvl.toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(outPath.getWithExtension(_S(".yaml"), true).getAbsolutePath());
mlvl.toYAMLStream(writer);
hecl::BlenderConnection& conn = btok.getBlenderConnection();
return DNAMLVL::ReadMLVLToBlender(conn, mlvl, outPath, pakRouter,
entry, force, fileChanged);

View File

@ -67,18 +67,16 @@ struct STRG : ISTRG
static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
{
std::unique_ptr<ISTRG> strg = LoadSTRG(rs);
FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
strg->toYAMLFile(fp);
fclose(fp);
athena::io::FileWriter writer(outPath.getAbsolutePath());
strg->toYAMLStream(writer);
return true;
}
static bool Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath)
{
STRG strg;
FILE* fp = hecl::Fopen(inPath.getAbsolutePath().c_str(), _S("rb"));
strg.fromYAMLFile(fp);
fclose(fp);
athena::io::FileReader reader(inPath.getAbsolutePath());
strg.fromYAMLStream(reader);
athena::io::FileWriter ws(outPath.getAbsolutePath());
strg.write(ws);
return true;

View File

@ -141,9 +141,8 @@ bool SpecBase::canCook(const hecl::ProjectPath& path, hecl::BlenderToken& btok)
}
else if (hecl::IsPathYAML(path))
{
FILE* fp = hecl::Fopen(path.getAbsolutePath().c_str(), _S("r"));
bool retval = validateYAMLDNAType(fp);
fclose(fp);
athena::io::FileReader reader(path.getAbsolutePath());
bool retval = validateYAMLDNAType(reader);
return retval;
}
return false;
@ -217,9 +216,8 @@ void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& co
}
else if (hecl::IsPathYAML(path))
{
FILE* fp = hecl::Fopen(path.getAbsolutePath().c_str(), _S("r"));
cookYAML(cookedPath, path, fp, progress);
fclose(fp);
athena::io::FileReader reader(path.getAbsolutePath());
cookYAML(cookedPath, path, reader, progress);
}
}

View File

@ -49,7 +49,7 @@ struct SpecBase : hecl::Database::IDataSpec
virtual bool checkPathPrefix(const hecl::ProjectPath& path)=0;
/* Pre-cook handlers */
virtual bool validateYAMLDNAType(FILE* fp) const=0;
virtual bool validateYAMLDNAType(athena::io::IStreamReader& fp) const=0;
/* Cook handlers */
using BlendStream = hecl::BlenderConnection::DataStream;
@ -68,7 +68,7 @@ struct SpecBase : hecl::Database::IDataSpec
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)=0;
virtual void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
FILE* fin, FCookProgress progress)=0;
athena::io::IStreamReader& fin, FCookProgress progress)=0;
const hecl::ProjectPath& getMasterShaderPath() const {return m_masterShader;}

View File

@ -320,10 +320,10 @@ struct SpecMP1 : SpecBase
return path.getRelativePath().compare(0, 4, _S("MP1/")) == 0;
}
bool validateYAMLDNAType(FILE* fp) const
bool validateYAMLDNAType(athena::io::IStreamReader& fp) const
{
athena::io::YAMLDocReader reader;
yaml_parser_set_input_file(reader.getParser(), fp);
yaml_parser_set_input(reader.getParser(), (yaml_read_handler_t*)athena::io::YAMLAthenaReader, &fp);
return reader.ClassTypeOperation([](const char* classType)
{
if (!strcmp(classType, DNAMP1::MLVL::DNAType()))
@ -422,11 +422,10 @@ struct SpecMP1 : SpecBase
}
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
FILE* fin, FCookProgress progress)
athena::io::IStreamReader& fin, FCookProgress progress)
{
athena::io::YAMLDocReader reader;
yaml_parser_set_input_file(reader.getParser(), fin);
if (reader.parse())
if (reader.parse(&fin))
{
std::string classStr = reader.readString("DNAType");
if (classStr.empty())

View File

@ -285,11 +285,11 @@ struct SpecMP2 : SpecBase
return path.getRelativePath().compare(0, 4, _S("MP2/")) == 0;
}
bool validateYAMLDNAType(FILE* fp) const
bool validateYAMLDNAType(athena::io::IStreamReader& fp) const
{
if (BigYAML::ValidateFromYAMLFile<DNAMP2::MLVL>(fp))
if (BigYAML::ValidateFromYAMLStream<DNAMP2::MLVL>(fp))
return true;
if (BigYAML::ValidateFromYAMLFile<DNAMP2::STRG>(fp))
if (BigYAML::ValidateFromYAMLStream<DNAMP2::STRG>(fp))
return true;
return false;
}
@ -313,7 +313,7 @@ struct SpecMP2 : SpecBase
}
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
FILE* fin, FCookProgress progress)
athena::io::IStreamReader& fin, FCookProgress progress)
{
}
};

View File

@ -478,13 +478,13 @@ struct SpecMP3 : SpecBase
return path.getRelativePath().compare(0, 4, _S("MP3/")) == 0;
}
bool validateYAMLDNAType(FILE* fp) const
bool validateYAMLDNAType(athena::io::IStreamReader& fp) const
{
if (BigYAML::ValidateFromYAMLFile<DNAMP3::MLVL>(fp))
if (BigYAML::ValidateFromYAMLStream<DNAMP3::MLVL>(fp))
return true;
if (BigYAML::ValidateFromYAMLFile<DNAMP3::STRG>(fp))
if (BigYAML::ValidateFromYAMLStream<DNAMP3::STRG>(fp))
return true;
if (BigYAML::ValidateFromYAMLFile<DNAMP2::STRG>(fp))
if (BigYAML::ValidateFromYAMLStream<DNAMP2::STRG>(fp))
return true;
return false;
}
@ -508,7 +508,7 @@ struct SpecMP3 : SpecBase
}
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
FILE* fin, FCookProgress progress)
athena::io::IStreamReader& fin, FCookProgress progress)
{
}
};

View File

@ -96,34 +96,30 @@ bool ProjectManager::openProject(const hecl::SystemString& path)
}
hecl::ProjectPath urdeSpacesPath(*m_proj, _S(".hecl/urde_spaces.yaml"));
FILE* fp = hecl::Fopen(urdeSpacesPath.getAbsolutePath().c_str(), _S("r"));
athena::io::FileReader reader(urdeSpacesPath.getAbsolutePath());
bool needsSave = false;
athena::io::YAMLDocReader r;
if (!fp)
if (!reader.isOpen())
{
needsSave = true;
goto makeProj;
}
yaml_parser_set_input_file(r.getParser(), fp);
yaml_parser_set_input(r.getParser(), (yaml_read_handler_t*)athena::io::YAMLAthenaReader, &reader);
if (!r.ValidateClassType("UrdeSpacesState"))
{
needsSave = true;
fclose(fp);
goto makeProj;
}
r.reset();
fseek(fp, 0, SEEK_SET);
yaml_parser_set_input_file(r.getParser(), fp);
if (!r.parse())
reader.seek(0, athena::Begin);
if (!r.parse(&reader))
{
needsSave = true;
fclose(fp);
goto makeProj;
}
fclose(fp);
makeProj:
m_vm.ProjectChanged(*m_proj);
@ -163,19 +159,14 @@ bool ProjectManager::saveProject()
return false;
hecl::ProjectPath oldSpacesPath(*m_proj, _S(".hecl/~urde_spaces.yaml"));
FILE* fp = hecl::Fopen(oldSpacesPath.getAbsolutePath().c_str(), _S("w"));
if (!fp)
athena::io::FileWriter writer(oldSpacesPath.getAbsolutePath());
if (!writer.isOpen())
return false;
athena::io::YAMLDocWriter w("UrdeSpacesState");
yaml_emitter_set_output_file(w.getEmitter(), fp);
m_vm.SaveEditorView(w);
if (!w.finish())
{
fclose(fp);
if (!w.finish(&writer))
return false;
}
fclose(fp);
hecl::ProjectPath newSpacesPath(*m_proj, _S(".hecl/urde_spaces.yaml"));

View File

@ -16,14 +16,12 @@ void ProjectResourceFactoryBase::Clear()
void ProjectResourceFactoryBase::ReadCatalog(const hecl::ProjectPath& catalogPath,
athena::io::YAMLDocWriter& nameWriter)
{
FILE* fp = hecl::Fopen(catalogPath.getAbsolutePath().c_str(), _S("r"));
if (!fp)
athena::io::FileReader freader(catalogPath.getAbsolutePath());
if (!freader.isOpen())
return;
athena::io::YAMLDocReader reader;
yaml_parser_set_input_file(reader.getParser(), fp);
bool res = reader.parse();
fclose(fp);
bool res = reader.parse(&freader);
if (!res)
return;
@ -208,13 +206,12 @@ void ProjectResourceFactoryBase::BackgroundIndexProc()
/* Read in tag cache */
if (tagCachePath.getPathType() == hecl::ProjectPath::Type::File)
{
FILE* cacheFile = hecl::Fopen(tagCachePath.getAbsolutePath().c_str(), _S("r"));
if (cacheFile)
athena::io::FileReader reader(tagCachePath.getAbsolutePath());
if (reader.isOpen())
{
Log.report(logvisor::Info, _S("Cache index of '%s' loading"), m_origSpec->m_name);
athena::io::YAMLDocReader cacheReader;
yaml_parser_set_input_file(cacheReader.getParser(), cacheFile);
if (cacheReader.parse())
if (cacheReader.parse(&reader))
{
std::unique_lock<std::mutex> lk(m_backgroundIndexMutex);
m_tagToPath.reserve(cacheReader.getRootNode()->m_mapChildren.size());
@ -231,7 +228,6 @@ void ProjectResourceFactoryBase::BackgroundIndexProc()
}
fprintf(stderr, "\n");
}
fclose(cacheFile);
Log.report(logvisor::Info, _S("Cache index of '%s' loaded; %d tags"),
m_origSpec->m_name, m_tagToPath.size());
@ -239,10 +235,9 @@ void ProjectResourceFactoryBase::BackgroundIndexProc()
{
/* Read in name cache */
Log.report(logvisor::Info, _S("Name index of '%s' loading"), m_origSpec->m_name);
FILE* nameFile = hecl::Fopen(nameCachePath.getAbsolutePath().c_str(), _S("r"));
athena::io::FileReader nreader(nameCachePath.getAbsolutePath());
athena::io::YAMLDocReader nameReader;
yaml_parser_set_input_file(nameReader.getParser(), nameFile);
if (nameReader.parse())
if (nameReader.parse(&nreader))
{
std::unique_lock<std::mutex> lk(m_backgroundIndexMutex);
m_catalogNameToTag.reserve(nameReader.getRootNode()->m_mapChildren.size());
@ -254,7 +249,6 @@ void ProjectResourceFactoryBase::BackgroundIndexProc()
m_catalogNameToTag[child.first] = search->first;
}
}
fclose(nameFile);
Log.report(logvisor::Info, _S("Name index of '%s' loaded; %d names"),
m_origSpec->m_name, m_catalogNameToTag.size());
}
@ -264,10 +258,8 @@ void ProjectResourceFactoryBase::BackgroundIndexProc()
Log.report(logvisor::Info, _S("Name index of '%s' started"), m_origSpec->m_name);
athena::io::YAMLDocWriter nameWriter(nullptr);
BackgroundIndexRecursiveCatalogs(specRoot, nameWriter, 0);
FILE* nameFile = hecl::Fopen(nameCachePath.getAbsolutePath().c_str(), _S("w"));
yaml_emitter_set_output_file(nameWriter.getEmitter(), nameFile);
nameWriter.finish();
fclose(nameFile);
athena::io::FileWriter nwriter(nameCachePath.getAbsolutePath());
nameWriter.finish(&nwriter);
Log.report(logvisor::Info, _S("Name index of '%s' complete; %d names"),
m_origSpec->m_name, m_catalogNameToTag.size());
}
@ -282,15 +274,11 @@ void ProjectResourceFactoryBase::BackgroundIndexProc()
BackgroundIndexRecursiveProc(specRoot, cacheWriter, nameWriter, 0);
tagCachePath.makeDirChain(false);
FILE* cacheFile = hecl::Fopen(tagCachePath.getAbsolutePath().c_str(), _S("w"));
yaml_emitter_set_output_file(cacheWriter.getEmitter(), cacheFile);
cacheWriter.finish();
fclose(cacheFile);
athena::io::FileWriter twriter(tagCachePath.getAbsolutePath());
cacheWriter.finish(&twriter);
FILE* nameFile = hecl::Fopen(nameCachePath.getAbsolutePath().c_str(), _S("w"));
yaml_emitter_set_output_file(nameWriter.getEmitter(), nameFile);
nameWriter.finish();
fclose(nameFile);
athena::io::FileWriter nwriter(nameCachePath.getAbsolutePath());
nameWriter.finish(&nwriter);
m_backgroundBlender.shutdown();
Log.report(logvisor::Info, _S("Background index of '%s' complete; %d tags, %d names"),

View File

@ -32,7 +32,7 @@ void ViewManager::BuildTestPART(urde::IObjectStore& objStore)
SObjectTag samusCharSet = m_projManager.TagFromPath(_S("MP1/Shared/ANCS_77289A4A.blend"));
SObjectTag platModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_6FA561D0.blend"));
SObjectTag bgModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_BC34D54C.blend"));
CAnimRes samusAnimRes(samusCharSet.id, -1, zeus::CVector3f::skOne, -1, true);
CAnimRes samusAnimRes(samusCharSet.id, 2, zeus::CVector3f::skOne, 0, true);
g_GameState->GetWorldTransitionManager()->EnableTransition(samusAnimRes,
platModel.id, zeus::CVector3f::skOne,
bgModel.id, zeus::CVector3f::skOne, false);

2
hecl

@ -1 +1 @@
Subproject commit 3bc81a3fe2711d9d7817e6f24afe7e29ca5e99d3
Subproject commit 9b9dae61566460086a51ccf371fc1bdf682ee5cb

@ -1 +1 @@
Subproject commit 5e695dab622d5095120224297b3c2fea4b3b85ca
Subproject commit 4c675e2e0512c911b76da84b0073396392c7f3a3