mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
Preserve zone definition meta data order
This commit is contained in:
@ -62,23 +62,23 @@ void ZoneCreator::HandleMetadata(Zone* zone, ZoneCreationContext& context) const
|
||||
{
|
||||
std::vector<KeyValuePair> kvpList;
|
||||
|
||||
for (const auto& [metaKey, metaValue] : context.m_definition->m_metadata)
|
||||
for (const auto& metaData : context.m_definition->m_metadata)
|
||||
{
|
||||
if (metaKey.rfind("level.", 0) == 0)
|
||||
if (metaData->m_key.rfind("level.", 0) == 0)
|
||||
{
|
||||
const std::string strValue = metaKey.substr(std::char_traits<char>::length("level."));
|
||||
if(strValue.empty())
|
||||
const std::string strValue = metaData->m_key.substr(std::char_traits<char>::length("level."));
|
||||
if (strValue.empty())
|
||||
continue;
|
||||
|
||||
int keyHash;
|
||||
if(strValue[0] == '@')
|
||||
if (strValue[0] == '@')
|
||||
{
|
||||
char* endPtr;
|
||||
keyHash = strtol(&strValue[1], &endPtr, 16);
|
||||
|
||||
if(endPtr != &strValue[strValue.size()])
|
||||
if (endPtr != &strValue[strValue.size()])
|
||||
{
|
||||
std::cout << "Could not parse metadata key \"" << metaKey << "\" as hash" << std::endl;
|
||||
std::cout << "Could not parse metadata key \"" << metaData->m_key << "\" as hash" << std::endl;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -87,25 +87,24 @@ void ZoneCreator::HandleMetadata(Zone* zone, ZoneCreationContext& context) const
|
||||
keyHash = CommonT6::Com_HashKey(strValue.c_str(), 64);
|
||||
}
|
||||
|
||||
|
||||
KeyValuePair kvp
|
||||
{
|
||||
keyHash,
|
||||
CommonT6::Com_HashKey(zone->m_name.c_str(), 64),
|
||||
zone->GetMemory()->Dup(metaValue.c_str())
|
||||
zone->GetMemory()->Dup(metaData->m_value.c_str())
|
||||
};
|
||||
kvpList.push_back(kvp);
|
||||
}
|
||||
}
|
||||
|
||||
if(!kvpList.empty())
|
||||
if (!kvpList.empty())
|
||||
{
|
||||
auto* kvps = zone->GetMemory()->Create<KeyValuePairs>();
|
||||
kvps->name = zone->GetMemory()->Dup(zone->m_name.c_str());
|
||||
kvps->numVariables = kvpList.size();
|
||||
kvps->keyValuePairs = static_cast<KeyValuePair*>(zone->GetMemory()->Alloc(sizeof(KeyValuePair) * kvpList.size()));
|
||||
|
||||
for(auto i = 0u; i < kvpList.size(); i++)
|
||||
for (auto i = 0u; i < kvpList.size(); i++)
|
||||
kvps->keyValuePairs[i] = kvpList[i];
|
||||
|
||||
zone->m_pools->AddAsset(ASSET_TYPE_KEYVALUEPAIRS, zone->m_name, kvps, std::vector<XAssetInfoGeneric*>(), std::vector<scr_string_t>());
|
||||
|
@ -362,17 +362,17 @@ class Linker::Impl
|
||||
static bool GetGameNameFromZoneDefinition(std::string& gameName, const std::string& zoneName, const ZoneDefinition& zoneDefinition)
|
||||
{
|
||||
auto firstGameEntry = true;
|
||||
const auto [rangeBegin, rangeEnd] = zoneDefinition.m_metadata.equal_range(METADATA_GAME);
|
||||
const auto [rangeBegin, rangeEnd] = zoneDefinition.m_metadata_lookup.equal_range(METADATA_GAME);
|
||||
for (auto i = rangeBegin; i != rangeEnd; ++i)
|
||||
{
|
||||
if (firstGameEntry)
|
||||
{
|
||||
gameName = i->second;
|
||||
gameName = i->second->m_value;
|
||||
firstGameEntry = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gameName != i->second)
|
||||
if (gameName != i->second->m_value)
|
||||
{
|
||||
std::cout << "Conflicting game names in zone \"" << zoneName << "\": " << gameName << " != " << i->second << std::endl;
|
||||
return false;
|
||||
@ -391,10 +391,10 @@ class Linker::Impl
|
||||
|
||||
static bool LoadGdtFilesFromZoneDefinition(std::vector<std::unique_ptr<Gdt>>& gdtList, const std::string& zoneName, const ZoneDefinition& zoneDefinition, ISearchPath* gdtSearchPath)
|
||||
{
|
||||
const auto [rangeBegin, rangeEnd] = zoneDefinition.m_metadata.equal_range(METADATA_GDT);
|
||||
const auto [rangeBegin, rangeEnd] = zoneDefinition.m_metadata_lookup.equal_range(METADATA_GDT);
|
||||
for (auto i = rangeBegin; i != rangeEnd; ++i)
|
||||
{
|
||||
const auto gdtFile = gdtSearchPath->Open(i->second + ".gdt");
|
||||
const auto gdtFile = gdtSearchPath->Open(i->second->m_value + ".gdt");
|
||||
if (!gdtFile.IsOpen())
|
||||
{
|
||||
std::cout << "Failed to open file for gdt \"" << i->second << "\"" << std::endl;
|
||||
|
Reference in New Issue
Block a user