metaforce/DataSpec/DNACommon/DGRP.hpp

50 lines
1.2 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2016-04-12 11:37:07 +00:00
#include "DNACommon.hpp"
#include "PAK.hpp"
2017-12-29 08:08:12 +00:00
namespace DataSpec::DNADGRP
2016-04-12 11:37:07 +00:00
{
2018-02-22 07:24:51 +00:00
2016-04-12 11:37:07 +00:00
template <class IDType>
2018-02-22 07:24:51 +00:00
struct AT_SPECIALIZE_PARMS(DataSpec::UniqueID32, DataSpec::UniqueID64) DGRP : BigDNA
2016-04-12 11:37:07 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2016-04-12 11:37:07 +00:00
Value<atUint32> dependCount;
2018-02-22 07:24:51 +00:00
struct ObjectTag : BigDNA
2016-04-12 11:37:07 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2016-04-12 11:37:07 +00:00
DNAFourCC type;
2018-02-24 06:17:17 +00:00
Value<IDType> id;
2018-04-02 04:27:24 +00:00
bool validate() const
{
if (!id.operator bool())
return false;
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id);
return path && !path.isNone();
}
2016-04-12 11:37:07 +00:00
};
2018-02-25 08:23:27 +00:00
Vector<ObjectTag, AT_DNA_COUNT(dependCount)> depends;
2018-04-02 04:27:24 +00:00
void validateDeps()
{
std::vector<ObjectTag> newDeps;
newDeps.reserve(depends.size());
for (const ObjectTag& tag : depends)
if (tag.validate())
newDeps.push_back(tag);
depends = std::move(newDeps);
dependCount = atUint32(depends.size());
}
2016-04-12 11:37:07 +00:00
};
template <class IDType>
bool ExtractDGRP(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
template <class IDType>
bool WriteDGRP(const DGRP<IDType>& dgrp, const hecl::ProjectPath& outPath);
2018-02-22 07:24:51 +00:00
2016-04-12 11:37:07 +00:00
}
2018-02-22 07:24:51 +00:00