Selaa lähdekoodia

Merge pull request #5518 from Laserlicht/fix_upgrade_all

[develop] fix crash, when no cost for upgrade
Ivan Savenko 7 kuukautta sitten
vanhempi
sitoutus
ee5cddb52c
1 muutettua tiedostoa jossa 2 lisäystä ja 0 poistoa
  1. 2 0
      client/windows/CCastleInterface.cpp

+ 2 - 0
client/windows/CCastleInterface.cpp

@@ -399,6 +399,8 @@ void CHeroGSlot::gesture(bool on, const Point & initialPosition, const Point & f
 		std::vector<std::shared_ptr<CComponent>> resComps;
 		std::vector<std::shared_ptr<CComponent>> resComps;
 		for(TResources::nziterator i(upgradableSlots.totalCosts); i.valid(); i++)
 		for(TResources::nziterator i(upgradableSlots.totalCosts); i.valid(); i++)
 			resComps.push_back(std::make_shared<CComponent>(ComponentType::RESOURCE, i->resType, i->resVal));
 			resComps.push_back(std::make_shared<CComponent>(ComponentType::RESOURCE, i->resType, i->resVal));
+		if(resComps.empty())
+			resComps.push_back(std::make_shared<CComponent>(ComponentType::RESOURCE, static_cast<GameResID>(GameResID::GOLD), 0)); // add at least gold, when there are no costs
 		resComps.back()->newLine = true;
 		resComps.back()->newLine = true;
 		for(auto & upgradeInfo : upgradableSlots.upgradeInfos)
 		for(auto & upgradeInfo : upgradableSlots.upgradeInfos)
 			resComps.push_back(std::make_shared<CComponent>(ComponentType::CREATURE, upgradeInfo.second.getUpgrade(), obj->Slots().at(upgradeInfo.first)->count));
 			resComps.push_back(std::make_shared<CComponent>(ComponentType::CREATURE, upgradeInfo.second.getUpgrade(), obj->Slots().at(upgradeInfo.first)->count));