mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 08:05:45 +00:00
chore: use cerr for error messages in weapon assets for t6
This commit is contained in:
parent
3268954477
commit
66e8f8fa78
@ -24,13 +24,13 @@ 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\n";
|
std::cerr << "Failed to parse hide tags as array\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valueArray.size() > std::extent_v<decltype(WeaponFullDef::hideTags)>)
|
if (valueArray.size() > std::extent_v<decltype(WeaponFullDef::hideTags)>)
|
||||||
{
|
{
|
||||||
std::cout << "Cannot have more than " << std::extent_v<decltype(WeaponFullDef::hideTags)> << " hide tags!\n";
|
std::cerr << "Cannot have more than " << std::extent_v<decltype(WeaponFullDef::hideTags)> << " hide tags!\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,13 +83,13 @@ namespace T6
|
|||||||
std::vector<std::pair<std::string, std::string>> pairs;
|
std::vector<std::pair<std::string, std::string>> pairs;
|
||||||
if (!ParseAsPairs(value, pairs))
|
if (!ParseAsPairs(value, pairs))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to parse notetracksoundmap as pairs\n";
|
std::cerr << "Failed to parse notetracksoundmap as pairs\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pairs.size() > std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>)
|
if (pairs.size() > std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>)
|
||||||
{
|
{
|
||||||
std::cout << "Cannot have more than " << std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)> << " notetracksoundmap entries!\n";
|
std::cerr << "Cannot have more than " << std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)> << " notetracksoundmap entries!\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ 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 attachments as array" << std::endl;
|
std::cerr << "Failed to parse attachments as array\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ namespace T6
|
|||||||
auto* attachmentAssetInfo = m_loading_manager->LoadDependency(ASSET_TYPE_ATTACHMENT, attachmentName);
|
auto* attachmentAssetInfo = m_loading_manager->LoadDependency(ASSET_TYPE_ATTACHMENT, attachmentName);
|
||||||
if (attachmentAssetInfo == nullptr)
|
if (attachmentAssetInfo == nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Failed to load attachment asset \"" << attachmentName << "\"" << std::endl;
|
std::cerr << "Failed to load attachment asset \"" << attachmentName << "\"\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,15 +173,14 @@ namespace T6
|
|||||||
|
|
||||||
if (static_cast<unsigned>(attachmentAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT)
|
if (static_cast<unsigned>(attachmentAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid attachment type " << attachmentAsset->attachmentType << " for attachment asset \"" << attachmentName << "\""
|
std::cerr << "Invalid attachment type " << attachmentAsset->attachmentType << " for attachment asset \"" << attachmentName << "\"\n";
|
||||||
<< std::endl;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachments[attachmentAsset->attachmentType] != nullptr)
|
if (attachments[attachmentAsset->attachmentType] != nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Already loaded attachment with same type " << attachmentAsset->attachmentType << ": \""
|
std::cerr << "Already loaded attachment with same type " << attachmentAsset->attachmentType << ": \""
|
||||||
<< attachments[attachmentAsset->attachmentType]->szInternalName << "\", \"" << attachmentName << "\"" << std::endl;
|
<< attachments[attachmentAsset->attachmentType]->szInternalName << "\", \"" << attachmentName << "\"\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +202,7 @@ 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 attachment uniques as array" << std::endl;
|
std::cerr << "Failed to parse attachment uniques as array\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +214,7 @@ namespace T6
|
|||||||
auto* attachmentUniqueAssetInfo = m_loading_manager->LoadDependency(ASSET_TYPE_ATTACHMENT_UNIQUE, attachmentUniqueName);
|
auto* attachmentUniqueAssetInfo = m_loading_manager->LoadDependency(ASSET_TYPE_ATTACHMENT_UNIQUE, attachmentUniqueName);
|
||||||
if (attachmentUniqueAssetInfo == nullptr)
|
if (attachmentUniqueAssetInfo == nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Failed to load attachment unique asset \"" << attachmentUniqueName << "\"" << std::endl;
|
std::cerr << "Failed to load attachment unique asset \"" << attachmentUniqueName << "\"\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +224,7 @@ namespace T6
|
|||||||
{
|
{
|
||||||
if (attachmentCombinationIndex >= std::extent_v<decltype(WeaponFullDef::attachmentUniques)>)
|
if (attachmentCombinationIndex >= std::extent_v<decltype(WeaponFullDef::attachmentUniques)>)
|
||||||
{
|
{
|
||||||
std::cout << "Cannot have more than "
|
std::cerr << "Cannot have more than "
|
||||||
<< (std::extent_v<decltype(WeaponFullDef::attachmentUniques)> - std::extent_v<decltype(WeaponFullDef::attachments)>)
|
<< (std::extent_v<decltype(WeaponFullDef::attachmentUniques)> - std::extent_v<decltype(WeaponFullDef::attachments)>)
|
||||||
<< " combined attachment attachment unique entries!\n";
|
<< " combined attachment attachment unique entries!\n";
|
||||||
return false;
|
return false;
|
||||||
@ -238,14 +237,14 @@ namespace T6
|
|||||||
{
|
{
|
||||||
if (static_cast<unsigned>(attachmentUniqueAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT)
|
if (static_cast<unsigned>(attachmentUniqueAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid attachment type " << attachmentUniqueAsset->attachmentType << " for attachment unique asset \""
|
std::cerr << "Invalid attachment type " << attachmentUniqueAsset->attachmentType << " for attachment unique asset \""
|
||||||
<< attachmentUniqueName << "\"\n";
|
<< attachmentUniqueName << "\"\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachmentUniques[attachmentUniqueAsset->attachmentType] != nullptr)
|
if (attachmentUniques[attachmentUniqueAsset->attachmentType] != nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Already loaded attachment unique with same type " << attachmentUniqueAsset->attachmentType << ": \""
|
std::cerr << "Already loaded attachment unique with same type " << attachmentUniqueAsset->attachmentType << ": \""
|
||||||
<< attachmentUniques[attachmentUniqueAsset->attachmentType]->szInternalName << "\", \"" << attachmentUniqueName << "\"\n";
|
<< attachmentUniques[attachmentUniqueAsset->attachmentType]->szInternalName << "\", \"" << attachmentUniqueName << "\"\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -534,7 +533,7 @@ void AssetLoaderWeapon::CalculateAttachmentFields(const WeaponFullDef* weapon, u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetLoaderWeapon::CalculateAttachmentFields(WeaponFullDef* weapon)
|
void AssetLoaderWeapon::CalculateAttachmentFields(const WeaponFullDef* weapon)
|
||||||
{
|
{
|
||||||
for (auto attachmentUniqueIndex = 0u; attachmentUniqueIndex < std::extent_v<decltype(WeaponFullDef::attachmentUniques)>; attachmentUniqueIndex++)
|
for (auto attachmentUniqueIndex = 0u; attachmentUniqueIndex < std::extent_v<decltype(WeaponFullDef::attachmentUniques)>; attachmentUniqueIndex++)
|
||||||
{
|
{
|
||||||
@ -556,7 +555,7 @@ bool AssetLoaderWeapon::LoadFromInfoString(
|
|||||||
infoString, weaponFullDef, zone->m_script_strings, memory, manager, weapon_fields, std::extent_v<decltype(weapon_fields)>);
|
infoString, weaponFullDef, zone->m_script_strings, memory, manager, weapon_fields, std::extent_v<decltype(weapon_fields)>);
|
||||||
if (!converter.Convert())
|
if (!converter.Convert())
|
||||||
{
|
{
|
||||||
std::cout << "Failed to parse weapon: \"" << assetName << "\"" << std::endl;
|
std::cerr << "Failed to parse weapon: \"" << assetName << "\"\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,14 +593,14 @@ bool AssetLoaderWeapon::CanLoadFromGdt() const
|
|||||||
bool AssetLoaderWeapon::LoadFromGdt(
|
bool AssetLoaderWeapon::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, assetName);
|
const auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_WEAPON, 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 weapon gdt entry: \"" << assetName << "\"" << std::endl;
|
std::cerr << "Failed to read weapon gdt entry: \"" << assetName << "\"\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,7 +623,7 @@ bool AssetLoaderWeapon::LoadFromRaw(
|
|||||||
InfoString infoString;
|
InfoString infoString;
|
||||||
if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON, *file.m_stream))
|
if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON, *file.m_stream))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read weapon raw file: \"" << fileName << "\"" << std::endl;
|
std::cerr << "Failed to read weapon raw file: \"" << fileName << "\"\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace T6
|
|||||||
|
|
||||||
static void CalculateWeaponFields(WeaponFullDef* weapon);
|
static void CalculateWeaponFields(WeaponFullDef* weapon);
|
||||||
static void CalculateAttachmentFields(const WeaponFullDef* weapon, unsigned attachmentIndex, WeaponAttachmentUnique* attachmentUnique);
|
static void CalculateAttachmentFields(const WeaponFullDef* weapon, unsigned attachmentIndex, WeaponAttachmentUnique* attachmentUnique);
|
||||||
static void CalculateAttachmentFields(WeaponFullDef* weapon);
|
static void CalculateAttachmentFields(const WeaponFullDef* weapon);
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone);
|
LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone);
|
||||||
|
@ -48,7 +48,7 @@ namespace T6
|
|||||||
ATTACHMENT_POINT_TOP, // vzoom
|
ATTACHMENT_POINT_TOP, // vzoom
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(std::extent<decltype(attachmentPointByAttachmentTable)>::value == ATTACHMENT_TYPE_COUNT);
|
static_assert(std::extent_v<decltype(attachmentPointByAttachmentTable)> == ATTACHMENT_TYPE_COUNT);
|
||||||
|
|
||||||
class InfoStringToWeaponAttachmentConverter final : public InfoStringToStructConverter
|
class InfoStringToWeaponAttachmentConverter final : public InfoStringToStructConverter
|
||||||
{
|
{
|
||||||
@ -58,13 +58,13 @@ namespace T6
|
|||||||
switch (static_cast<attachmentFieldType_t>(field.iFieldType))
|
switch (static_cast<attachmentFieldType_t>(field.iFieldType))
|
||||||
{
|
{
|
||||||
case AFT_ATTACHMENTTYPE:
|
case AFT_ATTACHMENTTYPE:
|
||||||
return ConvertEnumInt(value, field.iOffset, szAttachmentTypeNames, std::extent<decltype(szAttachmentTypeNames)>::value);
|
return ConvertEnumInt(value, field.iOffset, szAttachmentTypeNames, std::extent_v<decltype(szAttachmentTypeNames)>);
|
||||||
|
|
||||||
case AFT_PENETRATE_TYPE:
|
case AFT_PENETRATE_TYPE:
|
||||||
return ConvertEnumInt(value, field.iOffset, penetrateTypeNames, std::extent<decltype(penetrateTypeNames)>::value);
|
return ConvertEnumInt(value, field.iOffset, penetrateTypeNames, std::extent_v<decltype(penetrateTypeNames)>);
|
||||||
|
|
||||||
case AFT_FIRETYPE:
|
case AFT_FIRETYPE:
|
||||||
return ConvertEnumInt(value, field.iOffset, szWeapFireTypeNames, std::extent<decltype(szWeapFireTypeNames)>::value);
|
return ConvertEnumInt(value, field.iOffset, szWeapFireTypeNames, std::extent_v<decltype(szWeapFireTypeNames)>);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
@ -102,10 +102,10 @@ bool AssetLoaderWeaponAttachment::LoadFromInfoString(
|
|||||||
memset(attachment, 0, sizeof(WeaponAttachment));
|
memset(attachment, 0, sizeof(WeaponAttachment));
|
||||||
|
|
||||||
InfoStringToWeaponAttachmentConverter converter(
|
InfoStringToWeaponAttachmentConverter converter(
|
||||||
infoString, attachment, zone->m_script_strings, memory, manager, attachment_fields, std::extent<decltype(attachment_fields)>::value);
|
infoString, attachment, zone->m_script_strings, memory, manager, attachment_fields, std::extent_v<decltype(attachment_fields)>);
|
||||||
if (!converter.Convert())
|
if (!converter.Convert())
|
||||||
{
|
{
|
||||||
std::cout << "Failed to parse attachment: \"" << assetName << "\"" << std::endl;
|
std::cerr << "Failed to parse attachment: \"" << assetName << "\"\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,14 +134,14 @@ bool AssetLoaderWeaponAttachment::CanLoadFromGdt() const
|
|||||||
bool AssetLoaderWeaponAttachment::LoadFromGdt(
|
bool AssetLoaderWeaponAttachment::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, assetName);
|
const auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_WEAPON_ATTACHMENT, 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 gdt entry: \"" << assetName << "\"" << std::endl;
|
std::cerr << "Failed to read attachment gdt entry: \"" << assetName << "\"\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ bool AssetLoaderWeaponAttachment::LoadFromRaw(
|
|||||||
InfoString infoString;
|
InfoString infoString;
|
||||||
if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT, *file.m_stream))
|
if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT, *file.m_stream))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read attachment raw file: \"" << fileName << "\"" << std::endl;
|
std::cerr << "Failed to read attachment raw file: \"" << fileName << "\"\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,13 +23,13 @@ namespace T6
|
|||||||
std::vector<std::string> valueArray;
|
std::vector<std::string> valueArray;
|
||||||
if (!ParseAsArray(value, valueArray))
|
if (!ParseAsArray(value, valueArray))
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to parse hide tags as array" << std::endl;
|
std::cerr << "Failed to parse hide tags as array\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valueArray.size() > std::extent_v<decltype(WeaponFullDef::hideTags)>)
|
if (valueArray.size() > std::extent_v<decltype(WeaponFullDef::hideTags)>)
|
||||||
{
|
{
|
||||||
std::cerr << "Cannot have more than " << std::extent_v<decltype(WeaponFullDef::hideTags)> << " hide tags!" << std::endl;
|
std::cerr << "Cannot have more than " << std::extent_v<decltype(WeaponFullDef::hideTags)> << " hide tags!\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user