[IMaterial] Fix technique mapping

This commit is contained in:
momo5502 2017-04-16 01:51:41 +02:00
parent 79c38f44f3
commit a177e20bf6

View File

@ -52,14 +52,20 @@ namespace Assets
"_eyeoffset", "_eyeoffset",
}; };
for(int i = 0; i < ARRAYSIZE(techsetSuffix) && !asset->techniqueSet; ++i) if (!asset->techniqueSet)
{ {
asset->techniqueSet = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET, (techset + techsetSuffix[i]).data(), builder).techniqueSet; for (int i = 0; i < ARRAYSIZE(techsetSuffix); ++i)
{
Game::MaterialTechniqueSet* techsetPtr = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET, (techset + techsetSuffix[i]).data(), builder).techniqueSet;
if(asset->techniqueSet) if (techsetPtr)
{ {
if (asset->techniqueSet->name[0] == ',') continue; asset->techniqueSet = techsetPtr;
if (asset->techniqueSet->name[0] == ',') continue; // Try to find a better one
Components::Logger::Print("Techset '%s' has been mapped to '%s'\n", techset.data(), asset->techniqueSet->name); Components::Logger::Print("Techset '%s' has been mapped to '%s'\n", techset.data(), asset->techniqueSet->name);
break;
}
} }
} }
@ -125,6 +131,8 @@ namespace Assets
// Find correct sortkey by comparing techsets // Find correct sortkey by comparing techsets
Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_MATERIAL, [](Game::XAssetHeader header, void* data) Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_MATERIAL, [](Game::XAssetHeader header, void* data)
{
if (!replacementFound)
{ {
Game::Material* material = reinterpret_cast<Game::Material*>(data); Game::Material* material = reinterpret_cast<Game::Material*>(data);
const char* name = material->techniqueSet->name; const char* name = material->techniqueSet->name;
@ -143,11 +151,12 @@ namespace Assets
replacementFound = true; replacementFound = true;
} }
}
}, asset, false); }, asset, false);
if(!replacementFound) if(!replacementFound)
{ {
Components::Logger::Print("No replacment found for material %s with technset %s\n", asset->name, asset->techniqueSet->name); Components::Logger::Print("No replacement found for material %s with techset %s\n", asset->name, asset->techniqueSet->name);
} }
if (!reader.end()) if (!reader.end())