diff --git a/lib/mapObjects/CObjectHandler.cpp b/lib/mapObjects/CObjectHandler.cpp index 8c785b374..8b28f36a8 100644 --- a/lib/mapObjects/CObjectHandler.cpp +++ b/lib/mapObjects/CObjectHandler.cpp @@ -169,7 +169,7 @@ std::set CGObjectInstance::getBlockedPos() const { for(int h=0; hgameState()->map->removeBlockVisTiles(this, true); auto handler = VLC->objtypeh->getHandlerFor(ID, subID); - if (!handler->getTemplates(tile.terType).empty()) + if(!handler) + { + logGlobal->errorStream() << boost::format( + "Unknown object type %d:%d at %s") % ID % subID % visitablePos(); + return; + } + if(!handler->getTemplates(tile.terType).empty()) appearance = handler->getTemplates(tile.terType)[0]; else appearance = handler->getTemplates()[0]; // get at least some appearance since alternative is crash @@ -328,9 +334,9 @@ int3 IBoatGenerator::bestLocation() const for (auto & offset : offsets) { - if (const TerrainTile *tile = IObjectInterface::cb->getTile(o->pos + offset, false)) //tile is in the map + if(const TerrainTile *tile = IObjectInterface::cb->getTile(o->pos + offset, false)) //tile is in the map { - if (tile->terType == ETerrainType::WATER && (!tile->blocked || tile->blockingObjects.front()->ID == Obj::BOAT)) //and is water and is not blocked or is blocked by boat + if(tile->terType == ETerrainType::WATER && (!tile->blocked || tile->blockingObjects.front()->ID == Obj::BOAT)) //and is water and is not blocked or is blocked by boat return o->pos + offset; } }