mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 00:25:44 +00:00
Respect gdt parents when converting to infostring
This commit is contained in:
parent
579c0747d0
commit
a42f75c85e
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <stack>
|
||||||
|
|
||||||
const std::string InfoString::EMPTY_VALUE;
|
const std::string InfoString::EMPTY_VALUE;
|
||||||
|
|
||||||
@ -196,19 +197,37 @@ bool InfoString::FromStream(const std::string& prefix, std::istream& stream)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InfoString::FromGdtProperties(const std::string& prefix, const GdtEntry& gdtEntry)
|
bool InfoString::FromGdtProperties(const GdtEntry& gdtEntry)
|
||||||
{
|
{
|
||||||
const auto foundPrefixEntry = gdtEntry.m_properties.find(GDT_PREFIX_FIELD);
|
std::stack<const GdtEntry*> entryStack;
|
||||||
if (foundPrefixEntry == gdtEntry.m_properties.end() || foundPrefixEntry->second != prefix)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for(const auto& [key, value] : gdtEntry.m_properties)
|
|
||||||
{
|
{
|
||||||
if(key == GDT_PREFIX_FIELD)
|
const auto* currentEntry = &gdtEntry;
|
||||||
continue;
|
while (currentEntry)
|
||||||
|
{
|
||||||
|
entryStack.push(&gdtEntry);
|
||||||
|
currentEntry = gdtEntry.m_parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_keys_by_insertion.push_back(key);
|
while(!entryStack.empty())
|
||||||
m_values.emplace(std::make_pair(key, value));
|
{
|
||||||
|
const auto* currentEntry = entryStack.top();
|
||||||
|
entryStack.pop();
|
||||||
|
|
||||||
|
for (const auto& [key, value] : currentEntry->m_properties)
|
||||||
|
{
|
||||||
|
auto existingEntry = m_values.find(key);
|
||||||
|
if(existingEntry == m_values.end())
|
||||||
|
{
|
||||||
|
m_keys_by_insertion.push_back(key);
|
||||||
|
m_values.emplace(std::make_pair(key, value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
existingEntry->second = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -28,5 +28,5 @@ public:
|
|||||||
|
|
||||||
bool FromStream(std::istream& stream);
|
bool FromStream(std::istream& stream);
|
||||||
bool FromStream(const std::string& prefix, std::istream& stream);
|
bool FromStream(const std::string& prefix, std::istream& stream);
|
||||||
bool FromGdtProperties(const std::string& prefix, const GdtEntry& gdtEntry);
|
bool FromGdtProperties(const GdtEntry& gdtEntry);
|
||||||
};
|
};
|
@ -113,7 +113,7 @@ bool AssetLoaderPhysConstraints::LoadFromGdt(const std::string& assetName, IGdtQ
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
InfoString infoString;
|
InfoString infoString;
|
||||||
if (!infoString.FromGdtProperties(ObjConstants::INFO_STRING_PREFIX_PHYS_CONSTRAINTS, *gdtEntry))
|
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read phys constraints gdt entry: \"" << assetName << "\"" << std::endl;
|
std::cout << "Failed to read phys constraints gdt entry: \"" << assetName << "\"" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
|
@ -96,7 +96,7 @@ bool AssetLoaderPhysPreset::LoadFromGdt(const std::string& assetName, IGdtQuerya
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
InfoString infoString;
|
InfoString infoString;
|
||||||
if (!infoString.FromGdtProperties(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, *gdtEntry))
|
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read phys preset gdt entry: \"" << assetName << "\"" << std::endl;
|
std::cout << "Failed to read phys preset gdt entry: \"" << assetName << "\"" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
|
@ -80,7 +80,7 @@ bool AssetLoaderTracer::LoadFromGdt(const std::string& assetName, IGdtQueryable*
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
InfoString infoString;
|
InfoString infoString;
|
||||||
if (!infoString.FromGdtProperties(ObjConstants::INFO_STRING_PREFIX_TRACER, *gdtEntry))
|
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read tracer gdt entry: \"" << assetName << "\"" << std::endl;
|
std::cout << "Failed to read tracer gdt entry: \"" << assetName << "\"" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
|
@ -136,7 +136,7 @@ bool AssetLoaderVehicle::LoadFromGdt(const std::string& assetName, IGdtQueryable
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
InfoString infoString;
|
InfoString infoString;
|
||||||
if (!infoString.FromGdtProperties(ObjConstants::INFO_STRING_PREFIX_VEHICLE, *gdtEntry))
|
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read vehicle gdt entry: \"" << assetName << "\"" << std::endl;
|
std::cout << "Failed to read vehicle gdt entry: \"" << assetName << "\"" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
|
@ -552,7 +552,7 @@ bool AssetLoaderWeapon::LoadFromGdt(const std::string& assetName, IGdtQueryable*
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
InfoString infoString;
|
InfoString infoString;
|
||||||
if(!infoString.FromGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON, *gdtEntry))
|
if(!infoString.FromGdtProperties(*gdtEntry))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read weapon gdt entry: \"" << assetName << "\"" << std::endl;
|
std::cout << "Failed to read weapon gdt entry: \"" << assetName << "\"" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
|
@ -132,7 +132,7 @@ bool AssetLoaderWeaponAttachment::LoadFromGdt(const std::string& assetName, IGdt
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
InfoString infoString;
|
InfoString infoString;
|
||||||
if (!infoString.FromGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT, *gdtEntry))
|
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read attachment gdt entry: \"" << assetName << "\"" << std::endl;
|
std::cout << "Failed to read attachment gdt entry: \"" << assetName << "\"" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
|
@ -236,7 +236,7 @@ bool AssetLoaderWeaponAttachmentUnique::LoadFromGdt(const std::string& assetName
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
InfoString infoString;
|
InfoString infoString;
|
||||||
if (!infoString.FromGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT_UNIQUE, *gdtEntry))
|
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read attachment unique gdt entry: \"" << assetName << "\"" << std::endl;
|
std::cout << "Failed to read attachment unique gdt entry: \"" << assetName << "\"" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
|
@ -93,7 +93,7 @@ bool AssetLoaderZBarrier::LoadFromGdt(const std::string& assetName, IGdtQueryabl
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
InfoString infoString;
|
InfoString infoString;
|
||||||
if (!infoString.FromGdtProperties(ObjConstants::INFO_STRING_PREFIX_ZBARRIER, *gdtEntry))
|
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||||
{
|
{
|
||||||
std::cout << "Failed to read zbarrier gdt entry: \"" << assetName << "\"" << std::endl;
|
std::cout << "Failed to read zbarrier gdt entry: \"" << assetName << "\"" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user