From 665b0bbc810e171606434ad39ea2c08bfe212c52 Mon Sep 17 00:00:00 2001 From: danij Date: Mon, 6 Oct 2014 00:40:27 +0100 Subject: [PATCH] Fixed|Resources: Handle the case of a zero-length lump between S(*)_START/_END Some intrepid mod authors may insert a zero-length lump here, which is then "replaced" with a high-resolution resource later. --- .../client/src/resource/resourcesystem.cpp | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/doomsday/client/src/resource/resourcesystem.cpp b/doomsday/client/src/resource/resourcesystem.cpp index 166e00daf3..334c4a721f 100644 --- a/doomsday/client/src/resource/resourcesystem.cpp +++ b/doomsday/client/src/resource/resourcesystem.cpp @@ -150,7 +150,7 @@ namespace internal } // If defined, the character at position 7 is also a rotation number. - if(name.length() >= 7) + if(name.length() > 7) { if(toSpriteRotation(name.at(7)) < 0) { @@ -1505,27 +1505,30 @@ DENG2_PIMPL(ResourceSystem) Vector2i dimensions; Vector2i origin; - // If this is a Patch read the world dimension and origin offset values. - ByteRefArray fileData = ByteRefArray(file.cache(), file.size()); - if(Patch::recognize(fileData)) + if(file.size()) { - try + // If this is a Patch read the world dimension and origin offset values. + ByteRefArray fileData = ByteRefArray(file.cache(), file.size()); + if(Patch::recognize(fileData)) { - PatchMetadata info = Patch::loadMetadata(fileData); + try + { + PatchMetadata info = Patch::loadMetadata(fileData); - dimensions = info.logicalDimensions; - origin = -info.origin; - } - catch(IByteArray::OffsetError const &) - { - LOG_RES_WARNING("File \"%s:%s\" does not appear to be a valid Patch. " - "World dimension and origin offset not set for sprite \"%s\".") - << NativePath(file.container().composePath()).pretty() - << NativePath(file.composePath()).pretty() - << uri; + dimensions = info.logicalDimensions; + origin = -info.origin; + } + catch(IByteArray::OffsetError const &) + { + LOG_RES_WARNING("File \"%s:%s\" does not appear to be a valid Patch. " + "World dimension and origin offset not set for sprite \"%s\".") + << NativePath(file.container().composePath()).pretty() + << NativePath(file.composePath()).pretty() + << uri; + } } + file.unlock(); } - file.unlock(); de::Uri resourceUri = composeLumpIndexResourceUrn(i); try