Explorar o código

Added workaround for random objects on water, fixes 1828

Ivan Savenko %!s(int64=11) %!d(string=hai) anos
pai
achega
c0e4591bc7
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      lib/mapObjects/CObjectHandler.cpp

+ 4 - 1
lib/mapObjects/CObjectHandler.cpp

@@ -191,7 +191,10 @@ void CGObjectInstance::setType(si32 ID, si32 subID)
 	//recalculate blockvis tiles - new appearance might have different blockmap than before
 	cb->gameState()->map->removeBlockVisTiles(this, true);
 	auto handler = VLC->objtypeh->getHandlerFor(ID, subID);
-	appearance = handler->getTemplates(tile.terType).at(0);
+	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
 	cb->gameState()->map->addBlockVisTiles(this);
 }