mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-02-10 17:43:03 +00:00
refactor: asset refs are specified via asset name not enum entry
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,5 +25,5 @@ public:
|
||||
std::unique_ptr<IEvaluation> m_alloc_alignment;
|
||||
std::unique_ptr<CustomAction> m_post_load_action;
|
||||
const FastFileBlock* m_fast_file_block;
|
||||
const EnumMember* m_asset_ref;
|
||||
std::string m_asset_ref;
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<Comm
|
||||
if (definition == nullptr)
|
||||
throw ParsingException(typeNameToken.GetPos(), "Unknown type");
|
||||
|
||||
auto* definitionWithMembers = dynamic_cast<DefinitionWithMembers*>(definition);
|
||||
const auto* definitionWithMembers = dynamic_cast<DefinitionWithMembers*>(definition);
|
||||
if (definitionWithMembers == nullptr)
|
||||
throw ParsingException(typeNameToken.GetPos(), "Type must be struct or union");
|
||||
|
||||
|
||||
@@ -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<CommandsParserValue>& 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, SequenceResult<C
|
||||
if (typeDecl->m_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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user