mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
fix: consider attachmentunique szXAnims an assetref
This commit is contained in:
parent
741fc3857e
commit
68dfac10db
@ -153,6 +153,9 @@ namespace T6
|
|||||||
AUFT_OVERLAYRETICLE,
|
AUFT_OVERLAYRETICLE,
|
||||||
AUFT_CAMO,
|
AUFT_CAMO,
|
||||||
|
|
||||||
|
// Custom
|
||||||
|
AUFT_ANIM_NAME,
|
||||||
|
|
||||||
AUFT_NUM_FIELD_TYPES,
|
AUFT_NUM_FIELD_TYPES,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,20 +23,20 @@ namespace T6
|
|||||||
std::vector<std::string> valueArray;
|
std::vector<std::string> valueArray;
|
||||||
if (!ParseAsArray(value, valueArray))
|
if (!ParseAsArray(value, valueArray))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to parse hide tags as array" << std::endl;
|
std::cerr << "Failed to parse hide tags as array" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valueArray.size() > std::extent<decltype(WeaponFullDef::hideTags)>::value)
|
if (valueArray.size() > std::extent_v<decltype(WeaponFullDef::hideTags)>)
|
||||||
{
|
{
|
||||||
std::cout << "Cannot have more than " << std::extent<decltype(WeaponFullDef::hideTags)>::value << " hide tags!" << std::endl;
|
std::cerr << "Cannot have more than " << std::extent_v<decltype(WeaponFullDef::hideTags)> << " hide tags!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* hideTags = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
|
auto* hideTags = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
|
||||||
auto currentHideTag = 0u;
|
auto currentHideTag = 0u;
|
||||||
|
|
||||||
if (valueArray.size() < std::extent<decltype(WeaponFullDef::hideTags)>::value)
|
if (valueArray.size() < std::extent_v<decltype(WeaponFullDef::hideTags)>)
|
||||||
{
|
{
|
||||||
m_used_script_string_list.emplace(m_zone_script_strings.AddOrGetScriptString(""));
|
m_used_script_string_list.emplace(m_zone_script_strings.AddOrGetScriptString(""));
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ namespace T6
|
|||||||
m_used_script_string_list.emplace(scrString);
|
m_used_script_string_list.emplace(scrString);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; currentHideTag < std::extent<decltype(WeaponFullDef::hideTags)>::value; currentHideTag++)
|
for (; currentHideTag < std::extent_v<decltype(WeaponFullDef::hideTags)>; currentHideTag++)
|
||||||
{
|
{
|
||||||
hideTags[currentHideTag] = m_zone_script_strings.GetScriptString("");
|
hideTags[currentHideTag] = m_zone_script_strings.GetScriptString("");
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ namespace T6
|
|||||||
|
|
||||||
if (camo == nullptr)
|
if (camo == nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Failed to load camo asset \"" << value << "\"" << std::endl;
|
std::cerr << "Failed to load camo asset \"" << value << "\"\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,23 +78,38 @@ namespace T6
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConvertAnimName(const cspField_t& field, const std::string& value)
|
||||||
|
{
|
||||||
|
if (ConvertString(value, field.iOffset))
|
||||||
|
{
|
||||||
|
if (!value.empty())
|
||||||
|
m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(ASSET_TYPE_XANIMPARTS, value));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool ConvertExtensionField(const cspField_t& field, const std::string& value) override
|
bool ConvertExtensionField(const cspField_t& field, const std::string& value) override
|
||||||
{
|
{
|
||||||
switch (static_cast<attachmentUniqueFieldType_t>(field.iFieldType))
|
switch (static_cast<attachmentUniqueFieldType_t>(field.iFieldType))
|
||||||
{
|
{
|
||||||
case AUFT_ATTACHMENTTYPE:
|
case AUFT_ATTACHMENTTYPE:
|
||||||
return ConvertEnumInt(value, field.iOffset, szAttachmentTypeNames, std::extent<decltype(szAttachmentTypeNames)>::value);
|
return ConvertEnumInt(value, field.iOffset, szAttachmentTypeNames, std::extent_v<decltype(szAttachmentTypeNames)>);
|
||||||
|
|
||||||
case AUFT_HIDETAGS:
|
case AUFT_HIDETAGS:
|
||||||
return ConvertHideTags(field, value);
|
return ConvertHideTags(field, value);
|
||||||
|
|
||||||
case AUFT_OVERLAYRETICLE:
|
case AUFT_OVERLAYRETICLE:
|
||||||
return ConvertEnumInt(value, field.iOffset, szWeapOverlayReticleNames, std::extent<decltype(szWeapOverlayReticleNames)>::value);
|
return ConvertEnumInt(value, field.iOffset, szWeapOverlayReticleNames, std::extent_v<decltype(szWeapOverlayReticleNames)>);
|
||||||
|
|
||||||
case AUFT_CAMO:
|
case AUFT_CAMO:
|
||||||
return ConvertWeaponCamo(field, value);
|
return ConvertWeaponCamo(field, value);
|
||||||
|
|
||||||
|
case AUFT_ANIM_NAME:
|
||||||
|
return ConvertAnimName(field, value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
return false;
|
return false;
|
||||||
@ -147,7 +162,7 @@ bool AssetLoaderWeaponAttachmentUnique::ExtractAttachmentsFromAssetName(const st
|
|||||||
c = static_cast<char>(tolower(c));
|
c = static_cast<char>(tolower(c));
|
||||||
|
|
||||||
auto foundAttachment = false;
|
auto foundAttachment = false;
|
||||||
for (auto attachIndex = 0u; attachIndex < std::extent<decltype(szAttachmentTypeNames)>::value; attachIndex++)
|
for (auto attachIndex = 0u; attachIndex < std::extent_v<decltype(szAttachmentTypeNames)>; attachIndex++)
|
||||||
{
|
{
|
||||||
if (specifiedAttachName == szAttachmentTypeNames[attachIndex])
|
if (specifiedAttachName == szAttachmentTypeNames[attachIndex])
|
||||||
{
|
{
|
||||||
@ -177,13 +192,13 @@ bool AssetLoaderWeaponAttachmentUnique::CalculateAttachmentUniqueFields(const st
|
|||||||
std::vector<eAttachment> attachmentsFromName;
|
std::vector<eAttachment> attachmentsFromName;
|
||||||
if (!ExtractAttachmentsFromAssetName(assetName, attachmentsFromName))
|
if (!ExtractAttachmentsFromAssetName(assetName, attachmentsFromName))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to determine attachments from attachment unique name \"" << assetName << "\"" << std::endl;
|
std::cerr << "Failed to determine attachments from attachment unique name \"" << assetName << "\"\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachmentsFromName.size() > 1)
|
if (attachmentsFromName.size() > 1)
|
||||||
{
|
{
|
||||||
for (auto attachment : attachmentsFromName)
|
for (const auto attachment : attachmentsFromName)
|
||||||
{
|
{
|
||||||
attachmentUnique->attachment.combinedAttachmentTypeMask |= 1 << attachment;
|
attachmentUnique->attachment.combinedAttachmentTypeMask |= 1 << attachment;
|
||||||
}
|
}
|
||||||
@ -200,16 +215,11 @@ bool AssetLoaderWeaponAttachmentUnique::LoadFromInfoString(
|
|||||||
memset(attachmentUniqueFull, 0, sizeof(WeaponAttachmentUniqueFull));
|
memset(attachmentUniqueFull, 0, sizeof(WeaponAttachmentUniqueFull));
|
||||||
LinkAttachmentUniqueFullSubStructs(attachmentUniqueFull);
|
LinkAttachmentUniqueFullSubStructs(attachmentUniqueFull);
|
||||||
|
|
||||||
InfoStringToWeaponAttachmentUniqueConverter converter(infoString,
|
InfoStringToWeaponAttachmentUniqueConverter converter(
|
||||||
attachmentUniqueFull,
|
infoString, attachmentUniqueFull, zone->m_script_strings, memory, manager, attachment_unique_fields, std::extent_v<decltype(attachment_unique_fields)>);
|
||||||
zone->m_script_strings,
|
|
||||||
memory,
|
|
||||||
manager,
|
|
||||||
attachment_unique_fields,
|
|
||||||
std::extent<decltype(attachment_unique_fields)>::value);
|
|
||||||
if (!converter.Convert())
|
if (!converter.Convert())
|
||||||
{
|
{
|
||||||
std::cout << "Failed to parse attachment unique: \"" << assetName << "\"" << std::endl;
|
std::cerr << "Failed to parse attachment unique: \"" << assetName << "\"\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,11 +228,12 @@ bool AssetLoaderWeaponAttachmentUnique::LoadFromInfoString(
|
|||||||
|
|
||||||
attachmentUniqueFull->attachment.szInternalName = memory->Dup(assetName.c_str());
|
attachmentUniqueFull->attachment.szInternalName = memory->Dup(assetName.c_str());
|
||||||
|
|
||||||
auto* assetInfo = GlobalAssetPool<WeaponAttachmentUnique>::GetAssetByName(assetName);
|
manager->AddAsset(ASSET_TYPE_ATTACHMENT_UNIQUE,
|
||||||
auto* asset = assetInfo ? assetInfo->Asset() : nullptr;
|
assetName,
|
||||||
|
&attachmentUniqueFull->attachment,
|
||||||
manager->AddAsset(
|
converter.GetDependencies(),
|
||||||
ASSET_TYPE_ATTACHMENT_UNIQUE, assetName, &attachmentUniqueFull->attachment, converter.GetDependencies(), converter.GetUsedScriptStrings());
|
converter.GetUsedScriptStrings(),
|
||||||
|
converter.GetIndirectAssetReferences());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -245,14 +256,14 @@ bool AssetLoaderWeaponAttachmentUnique::CanLoadFromGdt() const
|
|||||||
bool AssetLoaderWeaponAttachmentUnique::LoadFromGdt(
|
bool AssetLoaderWeaponAttachmentUnique::LoadFromGdt(
|
||||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||||
{
|
{
|
||||||
auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_WEAPON_ATTACHMENT_UNIQUE, assetName);
|
const auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_WEAPON_ATTACHMENT_UNIQUE, assetName);
|
||||||
if (gdtEntry == nullptr)
|
if (gdtEntry == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
InfoString infoString;
|
InfoString infoString;
|
||||||
if (!infoString.FromGdtProperties(*gdtEntry))
|
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read attachment unique gdt entry: \"" << assetName << "\"" << std::endl;
|
std::cerr << "Failed to read attachment unique gdt entry: \"" << assetName << "\"\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +286,7 @@ bool AssetLoaderWeaponAttachmentUnique::LoadFromRaw(
|
|||||||
InfoString infoString;
|
InfoString infoString;
|
||||||
if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT_UNIQUE, *file.m_stream))
|
if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT_UNIQUE, *file.m_stream))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read attachment unique raw file: \"" << fileName << "\"" << std::endl;
|
std::cerr << "Failed to read attachment unique raw file: \"" << fileName << "\"\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ set reusable hideTags;
|
|||||||
set string viewModelTag;
|
set string viewModelTag;
|
||||||
set string worldModelTag;
|
set string worldModelTag;
|
||||||
set string szXAnims;
|
set string szXAnims;
|
||||||
|
set assetref szXAnims ASSET_TYPE_XANIMPARTS;
|
||||||
set count szXAnims 88;
|
set count szXAnims 88;
|
||||||
set reusable szXAnims;
|
set reusable szXAnims;
|
||||||
set count locationDamageMultipliers 21;
|
set count locationDamageMultipliers 21;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user