mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 14:58:10 -05:00
chore: use Asset definition instead of enum entry for zcg
This commit is contained in:
@ -12,7 +12,7 @@ StructureComputations::StructureComputations(const StructureInformation* structu
|
||||
|
||||
bool StructureComputations::IsAsset() const
|
||||
{
|
||||
return m_info->m_asset_enum_entry != nullptr;
|
||||
return !m_info->m_asset_name.empty();
|
||||
}
|
||||
|
||||
MemberInformation* StructureComputations::GetDynamicMember() const
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
StructureInformation::StructureInformation(DefinitionWithMembers* definition)
|
||||
: m_definition(definition),
|
||||
m_asset_enum_entry(nullptr),
|
||||
m_is_leaf(false),
|
||||
m_requires_marking(false),
|
||||
m_has_matching_cross_platform_structure(false),
|
||||
|
@ -16,8 +16,8 @@ class StructureInformation
|
||||
public:
|
||||
explicit StructureInformation(DefinitionWithMembers* definition);
|
||||
|
||||
DefinitionWithMembers* const m_definition;
|
||||
EnumMember* m_asset_enum_entry;
|
||||
DefinitionWithMembers* m_definition;
|
||||
std::string m_asset_name;
|
||||
|
||||
std::vector<StructureInformation*> m_usages;
|
||||
std::vector<std::unique_ptr<MemberInformation>> m_ordered_members;
|
||||
|
@ -262,7 +262,7 @@ namespace
|
||||
LINEF("{0}::{0}(Zone* zone, IZoneInputStream* stream)", LoaderClassName(m_env.m_asset))
|
||||
|
||||
m_intendation++;
|
||||
LINE_STARTF(": AssetLoader({0}, zone, stream)", m_env.m_asset->m_asset_enum_entry->m_name)
|
||||
LINE_STARTF(": AssetLoader({0}::EnumEntry, zone, stream)", m_env.m_asset->m_asset_name)
|
||||
if (m_env.m_has_actions)
|
||||
{
|
||||
LINE_MIDDLE(", m_actions(zone)")
|
||||
|
@ -245,7 +245,7 @@ namespace
|
||||
LINEF("{0}::{0}(Zone* zone)", MarkerClassName(m_env.m_asset))
|
||||
|
||||
m_intendation++;
|
||||
LINEF(": AssetMarker({0}, zone)", m_env.m_asset->m_asset_enum_entry->m_name)
|
||||
LINEF(": AssetMarker({0}::EnumEntry, zone)", m_env.m_asset->m_asset_name)
|
||||
m_intendation--;
|
||||
|
||||
LINE("{")
|
||||
|
@ -261,7 +261,7 @@ namespace
|
||||
"{0}::{0}({1}* asset, const Zone& zone, IZoneOutputStream& stream)", WriterClassName(m_env.m_asset), m_env.m_asset->m_definition->GetFullName())
|
||||
|
||||
m_intendation++;
|
||||
LINEF(": AssetWriter(zone.m_pools->GetAssetOrAssetReference({0}, GetAssetName(asset)), zone, stream)", m_env.m_asset->m_asset_enum_entry->m_name)
|
||||
LINEF(": AssetWriter(zone.m_pools->GetAssetOrAssetReference({0}::EnumEntry, GetAssetName(asset)), zone, stream)", m_env.m_asset->m_asset_name)
|
||||
m_intendation--;
|
||||
|
||||
LINE("{")
|
||||
|
@ -6,7 +6,7 @@
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_ENUM_ENTRY = 2;
|
||||
static constexpr auto CAPTURE_ASSET_NAME = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceAsset::SequenceAsset()
|
||||
@ -17,7 +17,7 @@ SequenceAsset::SequenceAsset()
|
||||
AddMatchers({
|
||||
create.Keyword("asset"),
|
||||
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||
create.Identifier().Capture(CAPTURE_ENUM_ENTRY),
|
||||
create.Identifier().Capture(CAPTURE_ASSET_NAME),
|
||||
create.Char(';'),
|
||||
});
|
||||
}
|
||||
@ -25,7 +25,7 @@ SequenceAsset::SequenceAsset()
|
||||
void SequenceAsset::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
|
||||
{
|
||||
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE);
|
||||
const auto& enumEntryToken = result.NextCapture(CAPTURE_ENUM_ENTRY);
|
||||
const auto& assetNameToken = result.NextCapture(CAPTURE_ASSET_NAME);
|
||||
|
||||
auto* definition = state->GetRepository()->GetDataDefinitionByName(typeNameToken.TypeNameValue());
|
||||
if (definition == nullptr)
|
||||
@ -39,9 +39,7 @@ void SequenceAsset::ProcessMatch(CommandsParserState* state, SequenceResult<Comm
|
||||
if (information == nullptr)
|
||||
throw ParsingException(typeNameToken.GetPos(), "No information for definition");
|
||||
|
||||
auto* enumMember = state->GetRepository()->GetEnumMemberByName(enumEntryToken.IdentifierValue());
|
||||
if (enumMember == nullptr)
|
||||
throw ParsingException(enumEntryToken.GetPos(), "Unknown enum entry");
|
||||
|
||||
information->m_asset_enum_entry = enumMember;
|
||||
information->m_asset_name = assetNameToken.IdentifierValue();
|
||||
if (information->m_asset_name.empty())
|
||||
throw ParsingException(assetNameToken.GetPos(), "Asset name is empty");
|
||||
}
|
||||
|
@ -10,12 +10,12 @@ namespace
|
||||
{
|
||||
bool CalculateRequiresMarking(std::unordered_set<const void*>& visitedStructures, StructureInformation* info)
|
||||
{
|
||||
if (visitedStructures.find(info) != visitedStructures.end())
|
||||
if (visitedStructures.contains(info))
|
||||
return info->m_requires_marking;
|
||||
|
||||
visitedStructures.emplace(info);
|
||||
|
||||
if (info->m_asset_enum_entry)
|
||||
if (StructureComputations(info).IsAsset())
|
||||
{
|
||||
info->m_requires_marking = true;
|
||||
return true;
|
||||
@ -47,7 +47,7 @@ namespace
|
||||
continue;
|
||||
|
||||
// Any script strings, asset refs and assets need to be processed.
|
||||
if (member->m_is_script_string || member->m_asset_ref || member->m_type && member->m_type->m_asset_enum_entry)
|
||||
if (member->m_is_script_string || member->m_asset_ref || member->m_type && StructureComputations(member->m_type).IsAsset())
|
||||
{
|
||||
info->m_requires_marking = true;
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user