diff --git a/client/mapHandler.cpp b/client/mapHandler.cpp index aa3012ab3..e08938d31 100644 --- a/client/mapHandler.cpp +++ b/client/mapHandler.cpp @@ -1036,10 +1036,14 @@ IImage * CMapHandler::CMapBlitter::findBoatFlagBitmap(const CGBoat * boat, int a IImage * CMapHandler::CMapBlitter::findFlagBitmapInternal(std::shared_ptr animation, int anim, int group, ui8 dir, bool moving) const { + size_t groupSize = animation->size(group); + if(groupSize == 0) + return nullptr; + if(moving) - return animation->getImage(anim % animation->size(group), group); + return animation->getImage(anim % groupSize, group); else - return animation->getImage((anim / 4) % animation->size(group), group); + return animation->getImage((anim / 4) % groupSize, group); } CMapHandler::AnimBitmapHolder CMapHandler::CMapBlitter::findObjectBitmap(const CGObjectInstance * obj, int anim) const @@ -1053,7 +1057,13 @@ CMapHandler::AnimBitmapHolder CMapHandler::CMapBlitter::findObjectBitmap(const C // normal object std::shared_ptr animation = graphics->getAnimation(obj); - IImage * bitmap = animation->getImage((anim + getPhaseShift(obj)) % animation->size()); + size_t groupSize = animation->size(); + if(groupSize == 0) + return CMapHandler::AnimBitmapHolder(); + + IImage * bitmap = animation->getImage((anim + getPhaseShift(obj)) % groupSize); + if(!bitmap) + return CMapHandler::AnimBitmapHolder(); bitmap->setFlagColor(obj->tempOwner);