diff --git a/doomsday/client/src/resource/model.cpp b/doomsday/client/src/resource/model.cpp index 863f2fed70..7309dd3f99 100644 --- a/doomsday/client/src/resource/model.cpp +++ b/doomsday/client/src/resource/model.cpp @@ -756,7 +756,8 @@ int Model::skinNumber(String name) const { if(!name.isEmpty()) { - for(int i = 0; i < d->skins.count(); ++i) + // Reverse iteration so that later skins override earlier ones. + for(int i = d->skins.count(); i--> 0; ) { Skin const &skin = d->skins.at(i); if(!skin.name.compareWithoutCase(name)) @@ -779,10 +780,7 @@ Model::Skin &Model::skin(int number) const Model::Skin &Model::newSkin(String name) { LOG_AS("Model"); - if(int index = skinNumber(name) > 0) - { - return skin(index); - } + // Allow duplicates so that skin indices remain unchanged for selection by index. d->skins.append(ModelSkin(name)); return d->skins.last(); } diff --git a/doomsday/client/src/resource/resourcesystem.cpp b/doomsday/client/src/resource/resourcesystem.cpp index 108ccdf34e..166e00daf3 100644 --- a/doomsday/client/src/resource/resourcesystem.cpp +++ b/doomsday/client/src/resource/resourcesystem.cpp @@ -1149,7 +1149,7 @@ DENG2_PIMPL(ResourceSystem) if(!mdl) continue; // Load all skins. - foreach(ModelSkin const &skin, mdl->skins()) + for(ModelSkin const &skin : mdl->skins()) { if(Texture *tex = skin.texture) { @@ -1681,10 +1681,6 @@ DENG2_PIMPL(ResourceSystem) for(int i = 0; i < mdl.skinCount(); ++i) { ModelSkin &skin = mdl.skin(i); - - if(skin.name.isEmpty()) - continue; - try { de::Uri foundResourceUri(Path(findSkinPath(skin.name, modelFilePath))); @@ -1694,10 +1690,10 @@ DENG2_PIMPL(ResourceSystem) // We have found one more skin for this model. numFoundSkins += 1; } - catch(FS1::NotFoundError const&) + catch(FS1::NotFoundError const &) { LOG_RES_WARNING("Failed to locate \"%s\" (#%i) for model \"%s\"") - << skin.name << i << NativePath(modelFilePath).pretty(); + << skin.name << i << NativePath(modelFilePath).pretty(); } } @@ -1705,7 +1701,6 @@ DENG2_PIMPL(ResourceSystem) { // Lastly try a skin named similarly to the model in the same directory. de::Uri searchPath(modelFilePath.fileNamePath() / modelFilePath.fileNameWithoutExtension(), RC_GRAPHIC); - try { String foundPath = fileSys().findPath(searchPath, RLF_DEFAULT, @@ -1737,10 +1732,10 @@ DENG2_PIMPL(ResourceSystem) for(ModelSkin const &skin : mdl.skins()) { TextureManifest const *texManifest = skin.texture? &skin.texture->manifest() : 0; - LOGDEV_RES_XVERBOSE(" %i: %s") + LOGDEV_RES_XVERBOSE(" %i: %s %s") << (skinIdx++) << skin.name - << (texManifest? texManifest->composeUri() : "(missing texture)") - << (texManifest? String(" => ") + NativePath(texManifest->resourceUri().compose()).pretty() : ""); + << (texManifest? (String("\"") + texManifest->composeUri() + "\"") : "(missing texture)") + << (texManifest? (String(" => \"") + NativePath(texManifest->resourceUri().compose()).pretty() + "\"") : ""); } #endif }