diff --git a/src/ZoneCode/Game/IW3/XAssets/FxEffectDef.txt b/src/ZoneCode/Game/IW3/XAssets/FxEffectDef.txt index b4311136..fff0e03e 100644 --- a/src/ZoneCode/Game/IW3/XAssets/FxEffectDef.txt +++ b/src/ZoneCode/Game/IW3/XAssets/FxEffectDef.txt @@ -35,7 +35,7 @@ set condition material FxElemDef::elemType == FX_ELEM_TYPE_SPRITE_BILLBOARD use FxEffectDefRef; set condition handle never; set string name; -set assetref name ASSET_TYPE_FX; +set assetref name AssetFx; // FxTrailDef use FxTrailDef; diff --git a/src/ZoneCode/Game/IW3/XAssets/WeaponDef.txt b/src/ZoneCode/Game/IW3/XAssets/WeaponDef.txt index 290b6d19..77401b6e 100644 --- a/src/ZoneCode/Game/IW3/XAssets/WeaponDef.txt +++ b/src/ZoneCode/Game/IW3/XAssets/WeaponDef.txt @@ -7,7 +7,7 @@ set string szInternalName; set string szDisplayName; set string szOverlayName; set string szXAnims; -set assetref szXAnims ASSET_TYPE_XANIMPARTS; +set assetref szXAnims AssetXAnim; set string szModeName; set scriptstring hideTags; set scriptstring notetrackSoundMapKeys; diff --git a/src/ZoneCode/Game/IW4/XAssets/FxEffectDef.txt b/src/ZoneCode/Game/IW4/XAssets/FxEffectDef.txt index 3b44b01f..a72c5715 100644 --- a/src/ZoneCode/Game/IW4/XAssets/FxEffectDef.txt +++ b/src/ZoneCode/Game/IW4/XAssets/FxEffectDef.txt @@ -37,7 +37,7 @@ set condition material FxElemDef::elemType == FX_ELEM_TYPE_SPRITE_BILLBOARD use FxEffectDefRef; set condition handle never; set string name; -set assetref name ASSET_TYPE_FX; +set assetref name AssetFx; // FxElemExtendedDefPtr use FxElemExtendedDefPtr; diff --git a/src/ZoneCode/Game/IW4/XAssets/WeaponCompleteDef.txt b/src/ZoneCode/Game/IW4/XAssets/WeaponCompleteDef.txt index a2911b7f..0a6a5d3c 100644 --- a/src/ZoneCode/Game/IW4/XAssets/WeaponCompleteDef.txt +++ b/src/ZoneCode/Game/IW4/XAssets/WeaponCompleteDef.txt @@ -10,7 +10,7 @@ set reusable hideTags; set scriptstring hideTags; set count hideTags 32; set string szXAnims; -set assetref szXAnims ASSET_TYPE_XANIMPARTS; +set assetref szXAnims AssetXAnim; set reusable szXAnims; set count szXAnims 37; set string szAltWeaponName; @@ -26,11 +26,11 @@ set reusable gunXModel; set count gunXModel 16; set reusable szXAnimsRightHanded; set string szXAnimsRightHanded; -set assetref szXAnimsRightHanded ASSET_TYPE_XANIMPARTS; +set assetref szXAnimsRightHanded AssetXAnim; set count szXAnimsRightHanded 37; set reusable szXAnimsLeftHanded; set string szXAnimsLeftHanded; -set assetref szXAnimsLeftHanded ASSET_TYPE_XANIMPARTS; +set assetref szXAnimsLeftHanded AssetXAnim; set count szXAnimsLeftHanded 37; set string szModeName; set reusable notetrackSoundMapKeys; diff --git a/src/ZoneCode/Game/IW5/XAssets/FxEffectDef.txt b/src/ZoneCode/Game/IW5/XAssets/FxEffectDef.txt index 2a83e44a..5e1aef7c 100644 --- a/src/ZoneCode/Game/IW5/XAssets/FxEffectDef.txt +++ b/src/ZoneCode/Game/IW5/XAssets/FxEffectDef.txt @@ -38,7 +38,7 @@ set condition material FxElemDef::elemType == FX_ELEM_TYPE_SPRITE_BILLBOARD use FxEffectDefRef; set condition handle never; set string name; -set assetref name ASSET_TYPE_FX; +set assetref name AssetFx; // FxElemExtendedDefPtr use FxElemExtendedDefPtr; diff --git a/src/ZoneCode/Game/IW5/XAssets/WeaponCompleteDef.txt b/src/ZoneCode/Game/IW5/XAssets/WeaponCompleteDef.txt index 6846512e..abeb9c9d 100644 --- a/src/ZoneCode/Game/IW5/XAssets/WeaponCompleteDef.txt +++ b/src/ZoneCode/Game/IW5/XAssets/WeaponCompleteDef.txt @@ -16,7 +16,7 @@ set count underBarrels 3; set reusable others; set count others 4; set string szXAnims; -set assetref szXAnims ASSET_TYPE_XANIMPARTS; +set assetref szXAnims AssetXAnim; set reusable szXAnims; set count szXAnims WEAP_ANIM_COUNT; set reusable animOverrides; @@ -39,8 +39,8 @@ set count aiVsPlayerAccuracyGraphKnots aiVsPlayerAccuracyGraphKnotCount; use AnimOverrideEntry; set string overrideAnim; set string altmodeAnim; -set assetref overrideAnim ASSET_TYPE_XANIMPARTS; -set assetref altmodeAnim ASSET_TYPE_XANIMPARTS; +set assetref overrideAnim AssetXAnim; +set assetref altmodeAnim AssetXAnim; // NoteTrackToSoundEntry use NoteTrackToSoundEntry; @@ -58,11 +58,11 @@ set reusable gunXModel; set count gunXModel 16; set reusable szXAnimsRightHanded; set string szXAnimsRightHanded; -set assetref szXAnimsRightHanded ASSET_TYPE_XANIMPARTS; +set assetref szXAnimsRightHanded AssetXAnim; set count szXAnimsRightHanded WEAP_ANIM_COUNT; set reusable szXAnimsLeftHanded; set string szXAnimsLeftHanded; -set assetref szXAnimsLeftHanded ASSET_TYPE_XANIMPARTS; +set assetref szXAnimsLeftHanded AssetXAnim; set count szXAnimsLeftHanded WEAP_ANIM_COUNT; set string szModeName; set reusable notetrackSoundMapKeys; @@ -121,4 +121,4 @@ set condition sound never; // snd_alias_list_name use snd_alias_list_name; set string soundName; -set assetref soundName ASSET_TYPE_SOUND; +set assetref soundName AssetSound; diff --git a/src/ZoneCode/Game/T5/XAssets/FxEffectDef.txt b/src/ZoneCode/Game/T5/XAssets/FxEffectDef.txt index bd40a3ec..21e0b67b 100644 --- a/src/ZoneCode/Game/T5/XAssets/FxEffectDef.txt +++ b/src/ZoneCode/Game/T5/XAssets/FxEffectDef.txt @@ -37,7 +37,7 @@ set condition material FxElemDef::elemType == FX_ELEM_TYPE_SPRITE_BILLBOARD use FxEffectDefRef; set condition handle never; set string name; -set assetref name ASSET_TYPE_FX; +set assetref name AssetFx; // FxTrailDef use FxTrailDef; diff --git a/src/ZoneCode/Game/T5/XAssets/WeaponVariantDef.txt b/src/ZoneCode/Game/T5/XAssets/WeaponVariantDef.txt index fb15e40f..488a69d9 100644 --- a/src/ZoneCode/Game/T5/XAssets/WeaponVariantDef.txt +++ b/src/ZoneCode/Game/T5/XAssets/WeaponVariantDef.txt @@ -8,7 +8,7 @@ set reusable weapDef; set string szDisplayName; set string szAltWeaponName; set string szXAnims; -set assetref szXAnims ASSET_TYPE_XANIMPARTS; +set assetref szXAnims AssetXAnim; set count szXAnims NUM_WEAP_ANIMS; set reusable szXAnims; set scriptstring hideTags; diff --git a/src/ZoneCode/Game/T6/XAssets/FxEffectDef.txt b/src/ZoneCode/Game/T6/XAssets/FxEffectDef.txt index 0009e0d5..82e55b49 100644 --- a/src/ZoneCode/Game/T6/XAssets/FxEffectDef.txt +++ b/src/ZoneCode/Game/T6/XAssets/FxEffectDef.txt @@ -38,7 +38,7 @@ set condition material FxElemDef::elemType == FX_ELEM_TYPE_SPRITE_BILLBOARD use FxEffectDefRef; set condition handle never; set string name; -set assetref name ASSET_TYPE_FX; +set assetref name AssetFx; // FxElemExtendedDefPtr use FxElemExtendedDefPtr; diff --git a/src/ZoneCode/Game/T6/XAssets/WeaponAttachmentUnique.txt b/src/ZoneCode/Game/T6/XAssets/WeaponAttachmentUnique.txt index 4fd2b883..ce6db77d 100644 --- a/src/ZoneCode/Game/T6/XAssets/WeaponAttachmentUnique.txt +++ b/src/ZoneCode/Game/T6/XAssets/WeaponAttachmentUnique.txt @@ -12,7 +12,7 @@ set reusable hideTags; set string viewModelTag; set string worldModelTag; set string szXAnims; -set assetref szXAnims ASSET_TYPE_XANIMPARTS; +set assetref szXAnims AssetXAnim; set count szXAnims 88; set reusable szXAnims; set count locationDamageMultipliers 21; diff --git a/src/ZoneCode/Game/T6/XAssets/WeaponVariantDef.txt b/src/ZoneCode/Game/T6/XAssets/WeaponVariantDef.txt index 610d37ab..c39b148b 100644 --- a/src/ZoneCode/Game/T6/XAssets/WeaponVariantDef.txt +++ b/src/ZoneCode/Game/T6/XAssets/WeaponVariantDef.txt @@ -13,7 +13,7 @@ set reusable attachments; set count attachmentUniques 95; set reusable attachmentUniques; set string szXAnims; -set assetref szXAnims ASSET_TYPE_XANIMPARTS; +set assetref szXAnims AssetXAnim; set count szXAnims NUM_WEAP_ANIMS; set reusable szXAnims; set scriptstring hideTags; diff --git a/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.cpp b/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.cpp index ab4b5323..a19fc05c 100644 --- a/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.cpp +++ b/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.cpp @@ -8,7 +8,6 @@ MemberInformation::MemberInformation(StructureInformation* parent, StructureInfo m_is_script_string(false), m_is_reusable(false), m_is_leaf(false), - m_fast_file_block(nullptr), - m_asset_ref(nullptr) + m_fast_file_block(nullptr) { } diff --git a/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.h b/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.h index fb5699e3..f517e069 100644 --- a/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.h +++ b/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.h @@ -25,5 +25,5 @@ public: std::unique_ptr m_alloc_alignment; std::unique_ptr m_post_load_action; const FastFileBlock* m_fast_file_block; - const EnumMember* m_asset_ref; + std::string m_asset_ref; }; diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp index 050c993a..9c79ad0a 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp @@ -397,22 +397,22 @@ namespace { if (modifier.IsArray()) { - LINEF("MarkArray_IndirectAssetRef({0}, {1}, {2});", - member->m_asset_ref->m_name, + LINEF("MarkArray_IndirectAssetRef({0}::EnumEntry, {1}, {2});", + member->m_asset_ref, MakeMemberAccess(info, member, modifier), modifier.GetArraySize()) } else { - LINEF("MarkArray_IndirectAssetRef({0}, {1}, {2});", - member->m_asset_ref->m_name, + LINEF("MarkArray_IndirectAssetRef({0}::EnumEntry, {1}, {2});", + member->m_asset_ref, MakeMemberAccess(info, member, modifier), MakeEvaluation(modifier.GetPointerArrayCountEvaluation())) } } else if (loadType == MemberLoadType::SINGLE_POINTER) { - LINEF("Mark_IndirectAssetRef({0}, {1});", member->m_asset_ref->m_name, MakeMemberAccess(info, member, modifier)) + LINEF("Mark_IndirectAssetRef({0}::EnumEntry, {1});", member->m_asset_ref, MakeMemberAccess(info, member, modifier)) } else { @@ -505,7 +505,7 @@ namespace { MarkMember_ScriptString(info, member, modifier, loadType); } - else if (member->m_asset_ref) + else if (!member->m_asset_ref.empty()) { MarkMember_AssetRef(info, member, modifier, loadType); } @@ -740,7 +740,7 @@ namespace if (computations.ShouldIgnore() || computations.IsInRuntimeBlock()) return; - if (member->m_is_script_string || member->m_asset_ref + if (member->m_is_script_string || !member->m_asset_ref.empty() || member->m_type && (member->m_type->m_requires_marking || StructureComputations(member->m_type).IsAsset())) { if (info->m_definition->GetType() == DataDefinitionType::UNION) diff --git a/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAsset.cpp b/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAsset.cpp index 84e78363..c6bc11a2 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAsset.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAsset.cpp @@ -5,8 +5,8 @@ namespace { - static constexpr auto CAPTURE_TYPE = 1; - static constexpr auto CAPTURE_ASSET_NAME = 2; + constexpr auto CAPTURE_TYPE = 1; + constexpr auto CAPTURE_ASSET_NAME = 2; } // namespace SequenceAsset::SequenceAsset() @@ -31,7 +31,7 @@ void SequenceAsset::ProcessMatch(CommandsParserState* state, SequenceResult(definition); + const auto* definitionWithMembers = dynamic_cast(definition); if (definitionWithMembers == nullptr) throw ParsingException(typeNameToken.GetPos(), "Type must be struct or union"); diff --git a/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAssetRef.cpp b/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAssetRef.cpp index 2a8912e5..12524f4c 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAssetRef.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAssetRef.cpp @@ -7,10 +7,17 @@ namespace { - static constexpr auto TAG_DEFAULT = 1; + constexpr auto CAPTURE_TYPE = 1; + constexpr auto CAPTURE_ASSET_NAME = 2; - static constexpr auto CAPTURE_TYPE = 1; - static constexpr auto CAPTURE_ASSET_TYPE_ENUM_ENTRY = 2; + bool AssetWithNameIsKnown(const std::string& assetName, const IDataRepository& repository) + { + return std::ranges::any_of(repository.GetAllStructureInformation(), + [&assetName](const StructureInformation* info) + { + return !info->m_asset_name.empty() && info->m_asset_name == assetName; + }); + } } // namespace SequenceAssetRef::SequenceAssetRef() @@ -22,17 +29,18 @@ SequenceAssetRef::SequenceAssetRef() create.Keyword("set"), create.Keyword("assetref"), create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE), - create.Identifier().Capture(CAPTURE_ASSET_TYPE_ENUM_ENTRY), + create.Identifier().Capture(CAPTURE_ASSET_NAME), create.Char(';'), }); } void SequenceAssetRef::ProcessMatch(CommandsParserState* state, SequenceResult& result) const { - const auto& enumEntryToken = result.NextCapture(CAPTURE_ASSET_TYPE_ENUM_ENTRY); - const auto* enumMember = state->GetRepository()->GetEnumMemberByName(enumEntryToken.IdentifierValue()); - if (enumMember == nullptr) - throw ParsingException(enumEntryToken.GetPos(), "Unknown asset type enum entry"); + const auto& assetNameToken = result.NextCapture(CAPTURE_ASSET_NAME); + auto assetName = assetNameToken.IdentifierValue(); + + if (!AssetWithNameIsKnown(assetName, *state->GetRepository())) + throw ParsingException(assetNameToken.GetPos(), "No asset with this name"); const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE); @@ -75,5 +83,5 @@ void SequenceAssetRef::ProcessMatch(CommandsParserState* state, SequenceResultm_type->GetType() != DataDefinitionType::BASE_TYPE) throw ParsingException(typeNameToken.GetPos(), "Invalid type for string, must be a base type"); - lastMember->m_asset_ref = enumMember; + lastMember->m_asset_ref = std::move(assetName); } diff --git a/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/MarkingRequiredPostProcessor.cpp b/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/MarkingRequiredPostProcessor.cpp index 137beb7a..f09a2932 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/MarkingRequiredPostProcessor.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/MarkingRequiredPostProcessor.cpp @@ -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 && StructureComputations(member->m_type).IsAsset()) + if (member->m_is_script_string || !member->m_asset_ref.empty() || member->m_type && StructureComputations(member->m_type).IsAsset()) { info->m_requires_marking = true; return true;