Bläddra i källkod

Merge pull request #3145 from vcmi/fix-3142

#3142 - fi custom campaign selection screen
Andrii Danylchenko 1 år sedan
förälder
incheckning
0927d3e3e8
2 ändrade filer med 5 tillägg och 3 borttagningar
  1. 4 2
      client/lobby/CSelectionBase.cpp
  2. 1 1
      lib/mapObjects/CGHeroInstance.cpp

+ 4 - 2
client/lobby/CSelectionBase.cpp

@@ -209,7 +209,6 @@ void InfoCard::changeSelection()
 		return;
 
 	labelSaveDate->setText(mapInfo->date);
-	labelMapSize->setText(std::to_string(mapInfo->mapHeader->width) + "x" + std::to_string(mapInfo->mapHeader->height));
 	mapName->setText(mapInfo->getNameTranslated());
 	mapDescription->setText(mapInfo->getDescriptionTranslated());
 
@@ -220,8 +219,11 @@ void InfoCard::changeSelection()
 	if(SEL->screenType == ESelectionScreen::campaignList)
 		return;
 
-	iconsMapSizes->setFrame(mapInfo->getMapSizeIconId());
 	const CMapHeader * header = mapInfo->mapHeader.get();
+
+	labelMapSize->setText(std::to_string(header->width) + "x" + std::to_string(header->height));
+	iconsMapSizes->setFrame(mapInfo->getMapSizeIconId());
+
 	iconsVictoryCondition->setFrame(header->victoryIconIndex);
 	labelVictoryConditionText->setText(header->victoryMessage.toString());
 	iconsLossCondition->setFrame(header->defeatIconIndex);

+ 1 - 1
lib/mapObjects/CGHeroInstance.cpp

@@ -1533,7 +1533,7 @@ void CGHeroInstance::afterAddToMap(CMap * map)
 {
 	auto existingHero = std::find_if(map->objects.begin(), map->objects.end(), [&](const CGObjectInstance * o) ->bool
 		{
-			return (o->ID == Obj::HERO || o->ID == Obj::PRISON) && o->subID == subID && o != this;
+			return o && (o->ID == Obj::HERO || o->ID == Obj::PRISON) && o->subID == subID && o != this;
 		});
 
 	if(existingHero != map->objects.end())