Skip to content

Commit

Permalink
Fixed|Resources: Handle the case of a zero-length lump between S(*)_S…
Browse files Browse the repository at this point in the history
…TART/_END

Some intrepid mod authors may insert a zero-length lump here, which
is then "replaced" with a high-resolution resource later.
  • Loading branch information
danij-deng committed Oct 5, 2014
1 parent a19526f commit 665b0bb
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions doomsday/client/src/resource/resourcesystem.cpp
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 665b0bb

Please sign in to comment.