From d50ebd7d5879e9e21c0d3440e1740693ba36b18b Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Sat, 4 Nov 2023 14:34:07 +0200 Subject: [PATCH] #3142 - fi custom campaign selection screen --- client/lobby/CSelectionBase.cpp | 6 ++++-- lib/mapObjects/CGHeroInstance.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/lobby/CSelectionBase.cpp b/client/lobby/CSelectionBase.cpp index 4d7f8987e..51feeaff3 100644 --- a/client/lobby/CSelectionBase.cpp +++ b/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); diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index d9cd4b6c6..d7254799a 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -1530,7 +1530,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())