diff --git a/client/widgets/CArtifactsOfHeroAltar.cpp b/client/widgets/CArtifactsOfHeroAltar.cpp index c95d232fa..8011d8bf1 100644 --- a/client/widgets/CArtifactsOfHeroAltar.cpp +++ b/client/widgets/CArtifactsOfHeroAltar.cpp @@ -38,20 +38,3 @@ CArtifactsOfHeroAltar::~CArtifactsOfHeroAltar() { putBackPickedArtifact(); } - -void CArtifactsOfHeroAltar::scrollBackpack(int offset) -{ - CArtifactsOfHeroBase::scrollBackpackForArtSet(offset, *curHero); - redraw(); -} - -void CArtifactsOfHeroAltar::pickUpArtifact(CArtPlace & artPlace) -{ - LOCPLINT->cb->swapArtifacts(ArtifactLocation(curHero->id, artPlace.slot), - ArtifactLocation(curHero->id, ArtifactPosition::TRANSITION_POS)); -} - -void CArtifactsOfHeroAltar::swapArtifacts(const ArtifactLocation & srcLoc, const ArtifactLocation & dstLoc) -{ - LOCPLINT->cb->swapArtifacts(srcLoc, dstLoc); -} diff --git a/client/widgets/CArtifactsOfHeroAltar.h b/client/widgets/CArtifactsOfHeroAltar.h index 324f905af..244b09f9f 100644 --- a/client/widgets/CArtifactsOfHeroAltar.h +++ b/client/widgets/CArtifactsOfHeroAltar.h @@ -16,11 +16,6 @@ class CArtifactsOfHeroAltar : public CArtifactsOfHeroBase { public: - std::set artifactsOnAltar; - CArtifactsOfHeroAltar(const Point & position); ~CArtifactsOfHeroAltar(); - void scrollBackpack(int offset) override; - void pickUpArtifact(CArtPlace & artPlace); - void swapArtifacts(const ArtifactLocation & srcLoc, const ArtifactLocation & dstLoc); }; diff --git a/client/widgets/CArtifactsOfHeroBackpack.cpp b/client/widgets/CArtifactsOfHeroBackpack.cpp index e8387528a..ddc75c544 100644 --- a/client/widgets/CArtifactsOfHeroBackpack.cpp +++ b/client/widgets/CArtifactsOfHeroBackpack.cpp @@ -41,17 +41,6 @@ CArtifactsOfHeroBackpack::CArtifactsOfHeroBackpack() initAOHbackpack(visibleCapacityMax, backpackCap < 0 || visibleCapacityMax < backpackCap); } -void CArtifactsOfHeroBackpack::swapArtifacts(const ArtifactLocation & srcLoc, const ArtifactLocation & dstLoc) -{ - LOCPLINT->cb->swapArtifacts(srcLoc, dstLoc); -} - -void CArtifactsOfHeroBackpack::pickUpArtifact(CArtPlace & artPlace) -{ - LOCPLINT->cb->swapArtifacts(ArtifactLocation(curHero->id, artPlace.slot), - ArtifactLocation(curHero->id, ArtifactPosition::TRANSITION_POS)); -} - void CArtifactsOfHeroBackpack::scrollBackpack(int offset) { if(backpackListBox) @@ -60,7 +49,7 @@ void CArtifactsOfHeroBackpack::scrollBackpack(int offset) auto slot = ArtifactPosition::BACKPACK_START + backpackPos; for(auto artPlace : backpack) { - setSlotData(artPlace, slot, *curHero); + setSlotData(artPlace, slot); slot = slot + 1; } redraw(); @@ -188,9 +177,9 @@ void CArtifactsOfHeroQuickBackpack::setHero(const CGHeroInstance * hero) initAOHbackpack(requiredSlots, false); auto artPlace = backpack.begin(); for(auto & art : filteredArts) - setSlotData(*artPlace++, curHero->getSlotByInstance(art.second), *curHero); + setSlotData(*artPlace++, curHero->getSlotByInstance(art.second)); for(auto & art : filteredScrolls) - setSlotData(*artPlace++, curHero->getSlotByInstance(art.second), *curHero); + setSlotData(*artPlace++, curHero->getSlotByInstance(art.second)); } } @@ -215,5 +204,5 @@ void CArtifactsOfHeroQuickBackpack::swapSelected() break; } if(backpackLoc.slot != ArtifactPosition::PRE_FIRST && filterBySlot != ArtifactPosition::PRE_FIRST && curHero) - swapArtifacts(backpackLoc, ArtifactLocation(curHero->id, filterBySlot)); + LOCPLINT->cb->swapArtifacts(backpackLoc, ArtifactLocation(curHero->id, filterBySlot)); } \ No newline at end of file diff --git a/client/widgets/CArtifactsOfHeroBackpack.h b/client/widgets/CArtifactsOfHeroBackpack.h index f8598fcd9..d79776109 100644 --- a/client/widgets/CArtifactsOfHeroBackpack.h +++ b/client/widgets/CArtifactsOfHeroBackpack.h @@ -24,8 +24,6 @@ class CArtifactsOfHeroBackpack : public CArtifactsOfHeroBase public: CArtifactsOfHeroBackpack(size_t slotsColumnsMax, size_t slotsRowsMax); CArtifactsOfHeroBackpack(); - void swapArtifacts(const ArtifactLocation & srcLoc, const ArtifactLocation & dstLoc); - void pickUpArtifact(CArtPlace & artPlace); void scrollBackpack(int offset) override; void updateBackpackSlots() override; size_t getActiveSlotRowsNum(); diff --git a/client/widgets/CArtifactsOfHeroBase.cpp b/client/widgets/CArtifactsOfHeroBase.cpp index 520e3b1a1..924830ce4 100644 --- a/client/widgets/CArtifactsOfHeroBase.cpp +++ b/client/widgets/CArtifactsOfHeroBase.cpp @@ -123,7 +123,7 @@ void CArtifactsOfHeroBase::setHero(const CGHeroInstance * hero) for(auto slot : artWorn) { - setSlotData(slot.second, slot.first, *curHero); + setSlotData(slot.second, slot.first); } scrollBackpack(0); } @@ -134,16 +134,10 @@ const CGHeroInstance * CArtifactsOfHeroBase::getHero() const } void CArtifactsOfHeroBase::scrollBackpack(int offset) -{ - scrollBackpackForArtSet(offset, *curHero); - redraw(); -} - -void CArtifactsOfHeroBase::scrollBackpackForArtSet(int offset, const CArtifactSet & artSet) { // offset==-1 => to left; offset==1 => to right using slotInc = std::function; - auto artsInBackpack = static_cast(artSet.artifactsInBackpack.size()); + auto artsInBackpack = static_cast(curHero->artifactsInBackpack.size()); auto scrollingPossible = artsInBackpack > backpack.size(); slotInc inc_straight = [](ArtifactPosition & slot) -> ArtifactPosition @@ -170,7 +164,7 @@ void CArtifactsOfHeroBase::scrollBackpackForArtSet(int offset, const CArtifactSe auto slot = ArtifactPosition(ArtifactPosition::BACKPACK_START + backpackPos); for(auto artPlace : backpack) { - setSlotData(artPlace, slot, artSet); + setSlotData(artPlace, slot); slot = inc(slot); } @@ -179,6 +173,8 @@ void CArtifactsOfHeroBase::scrollBackpackForArtSet(int offset, const CArtifactSe leftBackpackRoll->block(!scrollingPossible); if(rightBackpackRoll) rightBackpackRoll->block(!scrollingPossible); + + redraw(); } void CArtifactsOfHeroBase::markPossibleSlots(const CArtifactInstance * art, bool assumeDestRemoved) @@ -235,7 +231,7 @@ void CArtifactsOfHeroBase::updateBackpackSlots() void CArtifactsOfHeroBase::updateSlot(const ArtifactPosition & slot) { - setSlotData(getArtPlace(slot), slot, *curHero); + setSlotData(getArtPlace(slot), slot); } const CArtifactInstance * CArtifactsOfHeroBase::getPickedArtifact() @@ -256,7 +252,7 @@ void CArtifactsOfHeroBase::addGestureCallback(CArtPlace::ClickFunctor callback) } } -void CArtifactsOfHeroBase::setSlotData(ArtPlacePtr artPlace, const ArtifactPosition & slot, const CArtifactSet & artSet) +void CArtifactsOfHeroBase::setSlotData(ArtPlacePtr artPlace, const ArtifactPosition & slot) { // Spurious call from artifactMoved in attempt to update hidden backpack slot if(!artPlace && ArtifactUtils::isSlotBackpack(slot)) @@ -265,7 +261,7 @@ void CArtifactsOfHeroBase::setSlotData(ArtPlacePtr artPlace, const ArtifactPosit } artPlace->slot = slot; - if(auto slotInfo = artSet.getSlot(slot)) + if(auto slotInfo = curHero->getSlot(slot)) { artPlace->lockSlot(slotInfo->locked); artPlace->setArtifact(slotInfo->artifact); @@ -278,7 +274,7 @@ void CArtifactsOfHeroBase::setSlotData(ArtPlacePtr artPlace, const ArtifactPosit arts.insert(std::pair(combinedArt, 0)); for(const auto part : combinedArt->getConstituents()) { - if(artSet.hasArt(part->getId(), false)) + if(curHero->hasArt(part->getId(), false)) arts.at(combinedArt)++; } } diff --git a/client/widgets/CArtifactsOfHeroBase.h b/client/widgets/CArtifactsOfHeroBase.h index f124146ef..83dbc8389 100644 --- a/client/widgets/CArtifactsOfHeroBase.h +++ b/client/widgets/CArtifactsOfHeroBase.h @@ -69,6 +69,5 @@ protected: virtual void init(CHeroArtPlace::ClickFunctor lClickCallback, CHeroArtPlace::ClickFunctor showPopupCallback, const Point & position, BpackScrollFunctor scrollCallback); // Assigns an artifacts to an artifact place depending on it's new slot ID - virtual void setSlotData(ArtPlacePtr artPlace, const ArtifactPosition & slot, const CArtifactSet & artSet); - virtual void scrollBackpackForArtSet(int offset, const CArtifactSet & artSet); + virtual void setSlotData(ArtPlacePtr artPlace, const ArtifactPosition & slot); }; diff --git a/client/widgets/CArtifactsOfHeroKingdom.cpp b/client/widgets/CArtifactsOfHeroKingdom.cpp index 5d6e1e02b..20a9cf855 100644 --- a/client/widgets/CArtifactsOfHeroKingdom.cpp +++ b/client/widgets/CArtifactsOfHeroKingdom.cpp @@ -50,15 +50,3 @@ CArtifactsOfHeroKingdom::~CArtifactsOfHeroKingdom() { putBackPickedArtifact(); } - -void CArtifactsOfHeroKingdom::swapArtifacts(const ArtifactLocation & srcLoc, const ArtifactLocation & dstLoc) -{ - LOCPLINT->cb->swapArtifacts(srcLoc, dstLoc); -} - -void CArtifactsOfHeroKingdom::pickUpArtifact(CArtPlace & artPlace) -{ - LOCPLINT->cb->swapArtifacts(ArtifactLocation(curHero->id, artPlace.slot), - ArtifactLocation(curHero->id, ArtifactPosition::TRANSITION_POS)); -} - diff --git a/client/widgets/CArtifactsOfHeroKingdom.h b/client/widgets/CArtifactsOfHeroKingdom.h index 738b21074..4218fa54f 100644 --- a/client/widgets/CArtifactsOfHeroKingdom.h +++ b/client/widgets/CArtifactsOfHeroKingdom.h @@ -20,9 +20,8 @@ VCMI_LIB_NAMESPACE_END class CArtifactsOfHeroKingdom : public CArtifactsOfHeroBase { public: + CArtifactsOfHeroKingdom() = delete; CArtifactsOfHeroKingdom(ArtPlaceMap ArtWorn, std::vector Backpack, std::shared_ptr leftScroll, std::shared_ptr rightScroll); ~CArtifactsOfHeroKingdom(); - void swapArtifacts(const ArtifactLocation & srcLoc, const ArtifactLocation & dstLoc); - void pickUpArtifact(CArtPlace & artPlace); -}; \ No newline at end of file +}; diff --git a/client/widgets/CArtifactsOfHeroMain.cpp b/client/widgets/CArtifactsOfHeroMain.cpp index 326eff818..fbeb7db8e 100644 --- a/client/widgets/CArtifactsOfHeroMain.cpp +++ b/client/widgets/CArtifactsOfHeroMain.cpp @@ -30,14 +30,3 @@ CArtifactsOfHeroMain::~CArtifactsOfHeroMain() { putBackPickedArtifact(); } - -void CArtifactsOfHeroMain::swapArtifacts(const ArtifactLocation & srcLoc, const ArtifactLocation & dstLoc) -{ - LOCPLINT->cb->swapArtifacts(srcLoc, dstLoc); -} - -void CArtifactsOfHeroMain::pickUpArtifact(CArtPlace & artPlace) -{ - LOCPLINT->cb->swapArtifacts(ArtifactLocation(curHero->id, artPlace.slot), - ArtifactLocation(curHero->id, ArtifactPosition::TRANSITION_POS)); -} diff --git a/client/widgets/CArtifactsOfHeroMain.h b/client/widgets/CArtifactsOfHeroMain.h index 9e7f318dd..6caf0d636 100644 --- a/client/widgets/CArtifactsOfHeroMain.h +++ b/client/widgets/CArtifactsOfHeroMain.h @@ -22,6 +22,4 @@ class CArtifactsOfHeroMain : public CArtifactsOfHeroBase public: CArtifactsOfHeroMain(const Point & position); ~CArtifactsOfHeroMain(); - void swapArtifacts(const ArtifactLocation & srcLoc, const ArtifactLocation & dstLoc); - void pickUpArtifact(CArtPlace & artPlace); }; diff --git a/client/widgets/CArtifactsOfHeroMarket.cpp b/client/widgets/CArtifactsOfHeroMarket.cpp index 52e9828ed..257c212b9 100644 --- a/client/widgets/CArtifactsOfHeroMarket.cpp +++ b/client/widgets/CArtifactsOfHeroMarket.cpp @@ -28,12 +28,12 @@ CArtifactsOfHeroMarket::CArtifactsOfHeroMarket(const Point & position) void CArtifactsOfHeroMarket::scrollBackpack(int offset) { - CArtifactsOfHeroBase::scrollBackpackForArtSet(offset, *curHero); + CArtifactsOfHeroBase::scrollBackpack(offset); // We may have highlight on one of backpack artifacts if(selectArtCallback) { - for(auto & artPlace : backpack) + for(const auto & artPlace : backpack) { if(artPlace->isSelected()) { @@ -42,5 +42,4 @@ void CArtifactsOfHeroMarket::scrollBackpack(int offset) } } } - redraw(); } \ No newline at end of file diff --git a/client/widgets/CWindowWithArtifacts.cpp b/client/widgets/CWindowWithArtifacts.cpp index 022b88ea0..6485ac6da 100644 --- a/client/widgets/CWindowWithArtifacts.cpp +++ b/client/widgets/CWindowWithArtifacts.cpp @@ -33,6 +33,8 @@ #include "../../lib/networkPacks/ArtifactLocation.h" #include "../../lib/CConfigHandler.h" +#include "../../CCallback.h" + void CWindowWithArtifacts::addSet(CArtifactsOfHeroPtr artSet) { artSets.emplace_back(artSet); @@ -81,40 +83,14 @@ const CArtifactInstance * CWindowWithArtifacts::getPickedArtifact() void CWindowWithArtifacts::clickPressedArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition) { - const auto artSetWeak = findAOHbyRef(artsInst); - assert(artSetWeak.has_value()); + const auto artSet = findAOHbyRef(artsInst); + assert(artSet.has_value()); if(artPlace.isLocked()) return; - const auto checkSpecialArts = [](const CGHeroInstance * hero, CArtPlace & artPlace, bool isTrade) -> bool - { - if(artPlace.getArt()->getTypeId() == ArtifactID::SPELLBOOK) - { - GH.windows().createAndPushWindow(hero, LOCPLINT, LOCPLINT->battleInt.get()); - return false; - } - if(artPlace.getArt()->getTypeId() == ArtifactID::CATAPULT) - { - // The Catapult must be equipped - LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[312], - std::vector>(1, std::make_shared(ComponentType::ARTIFACT, ArtifactID(ArtifactID::CATAPULT)))); - return false; - } - if(isTrade) - { - if(!artPlace.getArt()->artType->isTradable()) - { - LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[21], - std::vector>(1, std::make_shared(ComponentType::ARTIFACT, artPlace.getArt()->getTypeId()))); - return false; - } - } - return true; - }; - std::visit( - [checkSpecialArts, this, &artPlace](auto artSetWeak) -> void + [this, &artPlace](auto artSetWeak) -> void { const auto artSetPtr = artSetWeak.lock(); @@ -162,14 +138,14 @@ void CWindowWithArtifacts::clickPressedArtPlaceHero(CArtifactsOfHeroBase & artsI isTransferAllowed = false; } if(isTransferAllowed) - artSetPtr->swapArtifacts(srcLoc, dstLoc); + LOCPLINT->cb->swapArtifacts(srcLoc, dstLoc); } else if(auto art = artPlace.getArt()) { if(artSetPtr->getHero()->tempOwner == LOCPLINT->playerID) { - if(checkSpecialArts(hero, artPlace, std::is_same_v> ? true : false)) - artSetPtr->pickUpArtifact(artPlace); + if(checkSpecialArts(*art, hero, std::is_same_v> ? true : false)) + LOCPLINT->cb->swapArtifacts(ArtifactLocation(artSetPtr->getHero()->id, artPlace.slot), ArtifactLocation(artSetPtr->getHero()->id, ArtifactPosition::TRANSITION_POS)); } else { @@ -217,12 +193,11 @@ void CWindowWithArtifacts::clickPressedArtPlaceHero(CArtifactsOfHeroBase & artsI else if constexpr(std::is_same_v>) { const auto hero = artSetPtr->getHero(); - artSetPtr->swapArtifacts(ArtifactLocation(hero->id, artPlace.slot), - ArtifactLocation(hero->id, artSetPtr->getFilterSlot())); + LOCPLINT->cb->swapArtifacts(ArtifactLocation(hero->id, artPlace.slot), ArtifactLocation(hero->id, artSetPtr->getFilterSlot())); if(closeCallback) closeCallback(); } - }, artSetWeak.value()); + }, artSet.value()); } void CWindowWithArtifacts::showPopupArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition) @@ -475,3 +450,31 @@ void CWindowWithArtifacts::markPossibleSlots() std::visit(artifactAssembledBody, artSetWeak); } } + +bool CWindowWithArtifacts::checkSpecialArts(const CArtifactInstance & artInst, const CGHeroInstance * hero, bool isTrade) +{ + const auto artId = artInst.getTypeId(); + + if(artId == ArtifactID::SPELLBOOK) + { + GH.windows().createAndPushWindow(hero, LOCPLINT, LOCPLINT->battleInt.get()); + return false; + } + if(artId == ArtifactID::CATAPULT) + { + // The Catapult must be equipped + LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[312], + std::vector>(1, std::make_shared(ComponentType::ARTIFACT, ArtifactID(ArtifactID::CATAPULT)))); + return false; + } + if(isTrade) + { + if(!artInst.artType->isTradable()) + { + LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[21], + std::vector>(1, std::make_shared(ComponentType::ARTIFACT, artId))); + return false; + } + } + return true; +} diff --git a/client/widgets/CWindowWithArtifacts.h b/client/widgets/CWindowWithArtifacts.h index 2cd2ddea4..6a1ca1841 100644 --- a/client/widgets/CWindowWithArtifacts.h +++ b/client/widgets/CWindowWithArtifacts.h @@ -50,4 +50,5 @@ protected: std::optional> getState(); std::optional findAOHbyRef(CArtifactsOfHeroBase & artsInst); void markPossibleSlots(); + bool checkSpecialArts(const CArtifactInstance & artInst, const CGHeroInstance * hero, bool isTrade); }; diff --git a/client/widgets/markets/CAltarArtifacts.cpp b/client/widgets/markets/CAltarArtifacts.cpp index 20afc459e..1c917ff70 100644 --- a/client/widgets/markets/CAltarArtifacts.cpp +++ b/client/widgets/markets/CAltarArtifacts.cpp @@ -67,13 +67,6 @@ CAltarArtifacts::CAltarArtifacts(const IMarket * market, const CGHeroInstance * CTradeBase::deselect(); }; -CAltarArtifacts::~CAltarArtifacts() -{ - // TODO: If the backpack capacity limit is enabled, artifacts may remain on the altar. - // Perhaps should be erased in CGameHandler::objectVisitEnded if id of visited object will be available - LOCPLINT->cb->bulkMoveArtifacts(altarId, heroArts->getHero()->id, false, true, true); -} - TExpType CAltarArtifacts::calcExpAltarForHero() { TExpType expOnAltar(0); @@ -136,8 +129,8 @@ void CAltarArtifacts::updateSlots() auto slotsToAdd = tradeSlotsMap; for(auto & altarSlot : items[0]) - { if(altarSlot->id != -1) + { if(tradeSlotsMap.find(altarSlot->getArtInstance()) == tradeSlotsMap.end()) { altarSlot->setID(-1); @@ -147,7 +140,7 @@ void CAltarArtifacts::updateSlots() { slotsToAdd.erase(altarSlot->getArtInstance()); } - } + } for(auto & tradeSlot : slotsToAdd) { @@ -165,7 +158,7 @@ void CAltarArtifacts::updateSlots() { altarSlot->setArtInstance(slotInfo.artifact); altarSlot->subtitle = std::to_string(calcExpCost(slotInfo.artifact)); - tradeSlotsMap.emplace(slotInfo.artifact, altarSlot); + tradeSlotsMap.try_emplace(slotInfo.artifact, altarSlot); break; } } @@ -174,6 +167,14 @@ void CAltarArtifacts::updateSlots() deal->block(tradeSlotsMap.empty()); } +void CAltarArtifacts::putBackArtifacts() +{ + // TODO: If the backpack capacity limit is enabled, artifacts may remain on the altar. + // Perhaps should be erased in CGameHandler::objectVisitEnded if id of visited object will be available + if(!altarArtifacts->artifactsInBackpack.empty()) + LOCPLINT->cb->bulkMoveArtifacts(altarId, heroArts->getHero()->id, false, true, true); +} + void CAltarArtifacts::onSlotClickPressed(const std::shared_ptr & altarSlot, std::shared_ptr & hCurSlot) { assert(altarSlot); @@ -181,11 +182,11 @@ void CAltarArtifacts::onSlotClickPressed(const std::shared_ptr & if(const auto pickedArtInst = heroArts->getPickedArtifact()) { if(pickedArtInst->canBePutAt(altarArtifacts)) + { if(pickedArtInst->artType->isTradable()) { if(altarSlot->id == -1) - tradeSlotsMap.emplace(pickedArtInst, altarSlot); - heroArts->artifactsOnAltar.insert(pickedArtInst); + tradeSlotsMap.try_emplace(pickedArtInst, altarSlot); deal->block(false); LOCPLINT->cb->swapArtifacts(ArtifactLocation(heroArts->getHero()->id, ArtifactPosition::TRANSITION_POS), @@ -196,13 +197,13 @@ void CAltarArtifacts::onSlotClickPressed(const std::shared_ptr & logGlobal->warn("Cannot put special artifact on altar!"); return; } + } } else if(const CArtifactInstance * art = altarSlot->getArtInstance()) { const auto slot = altarArtifacts->getSlotByInstance(art); assert(slot != ArtifactPosition::PRE_FIRST); LOCPLINT->cb->swapArtifacts(ArtifactLocation(altarId, slot), ArtifactLocation(hero->id, ArtifactPosition::TRANSITION_POS)); - heroArts->artifactsOnAltar.erase(art); tradeSlotsMap.erase(art); } } diff --git a/client/widgets/markets/CAltarArtifacts.h b/client/widgets/markets/CAltarArtifacts.h index eb5070626..f2f63a50b 100644 --- a/client/widgets/markets/CAltarArtifacts.h +++ b/client/widgets/markets/CAltarArtifacts.h @@ -16,7 +16,6 @@ class CAltarArtifacts : public CExperienceAltar { public: CAltarArtifacts(const IMarket * market, const CGHeroInstance * hero); - ~CAltarArtifacts(); TExpType calcExpAltarForHero() override; void makeDeal() override; void sacrificeAll() override; @@ -25,6 +24,7 @@ public: std::shared_ptr getAOHset() const; ObjectInstanceID getObjId() const; void updateSlots(); + void putBackArtifacts(); private: ObjectInstanceID altarId; diff --git a/client/windows/CAltarWindow.cpp b/client/windows/CAltarWindow.cpp index f52df407f..b9112aaca 100644 --- a/client/windows/CAltarWindow.cpp +++ b/client/windows/CAltarWindow.cpp @@ -79,14 +79,18 @@ void CAltarWindow::createAltarArtifacts(const IMarket * market, const CGHeroInst auto altarArtifacts = std::make_shared(market, hero); altar = altarArtifacts; artSets.clear(); - addSetAndCallbacks(altarArtifacts->getAOHset()); + addSetAndCallbacks(altarArtifacts->getAOHset()); altarArtifacts->putBackArtifacts(); changeModeButton = std::make_shared(Point(516, 421), AnimationPath::builtin("ALTSACC.DEF"), CGI->generaltexth->zelp[572], std::bind(&CAltarWindow::createAltarCreatures, this, market, hero)); if(altar->hero->getAlignment() == EAlignment::GOOD) changeModeButton->block(true); quitButton = std::make_shared(Point(516, 520), AnimationPath::builtin("IOK6432.DEF"), - CGI->generaltexth->zelp[568], std::bind(&CAltarWindow::close, this), EShortcut::GLOBAL_RETURN); + CGI->generaltexth->zelp[568], [this, altarArtifacts]() + { + altarArtifacts->putBackArtifacts(); + CAltarWindow::close(); + }, EShortcut::GLOBAL_RETURN); altar->setRedrawParent(true); redraw(); }