Correctly draw creatures bigger than 64x64

Battlelist icon
This commit is contained in:
Konrad Kuśnierz 2015-05-12 10:16:14 +02:00
parent 11990815a6
commit 6bd0e37670
2 changed files with 8 additions and 12 deletions

View File

@ -202,27 +202,27 @@ void Creature::drawOutfit(const Rect& destRect, bool resize)
if(g_graphics.canUseFBO()) {
const FrameBufferPtr& outfitBuffer = g_framebuffers.getTemporaryFrameBuffer();
outfitBuffer->resize(Size(2*Otc::TILE_PIXELS, 2*Otc::TILE_PIXELS));
outfitBuffer->resize(Size(exactSize, exactSize));
outfitBuffer->bind();
g_painter->setAlphaWriting(true);
g_painter->clear(Color::alpha);
internalDrawOutfit(Point(Otc::TILE_PIXELS,Otc::TILE_PIXELS) + getDisplacement(), 1, false, true, Otc::South);
internalDrawOutfit(Point(exactSize - Otc::TILE_PIXELS, exactSize - Otc::TILE_PIXELS) + getDisplacement(), 1, false, true, Otc::South);
outfitBuffer->release();
Rect srcRect;
if(resize)
srcRect.resize(exactSize, exactSize);
else
srcRect.resize(2*Otc::TILE_PIXELS*0.75f, 2*Otc::TILE_PIXELS*0.75f);
srcRect.moveBottomRight(Point(2*Otc::TILE_PIXELS - 1, 2*Otc::TILE_PIXELS - 1));
srcRect.resize(exactSize*0.75f, exactSize*0.75f);
srcRect.moveBottomRight(Point(exactSize - 1, exactSize - 1));
outfitBuffer->draw(destRect, srcRect);
} else {
float scaleFactor;
if(resize)
scaleFactor = destRect.width() / (float)exactSize;
else
scaleFactor = destRect.width() / (float)(2*Otc::TILE_PIXELS*0.75f);
Point dest = destRect.bottomRight() - (Point(Otc::TILE_PIXELS,Otc::TILE_PIXELS) - getDisplacement())*scaleFactor;
scaleFactor = destRect.width() / (float)(exactSize*0.75f);
Point dest = destRect.bottomRight() - (Point(exactSize - Otc::TILE_PIXELS, exactSize - Otc::TILE_PIXELS) - getDisplacement()) * scaleFactor;
internalDrawOutfit(dest, scaleFactor, false, true, Otc::South);
}
}

View File

@ -341,12 +341,8 @@ bool Minimap::loadOtmm(const std::string& fileName)
pos.y = fin->getU16();
pos.z = fin->getU8();
// end of file
if(!pos.isValid())
break;
// corrupted file
if(pos.z >= Otc::MAX_Z+1)
// end of file or file is corrupted
if(!pos.isValid() || pos.z >= Otc::MAX_Z+1)
break;
MinimapBlock& block = getBlock(pos);