1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

Stacks of armed instance are now unique_ptr

This commit is contained in:
Ivan Savenko
2025-03-17 21:11:06 +00:00
parent bdae7285ae
commit c02a8a84fd
33 changed files with 101 additions and 115 deletions

View File

@ -27,14 +27,8 @@ CExchangeController::CExchangeController(ObjectInstanceID hero1, ObjectInstanceI
void CExchangeController::swapArmy()
{
auto getStacks = [](const CArmedInstance * source) -> std::vector<std::pair<SlotID, CStackInstance*>>
{
auto slots = source->Slots();
return std::vector<std::pair<SlotID, CStackInstance*>>(slots.begin(), slots.end());
};
auto leftSlots = getStacks(left);
auto rightSlots = getStacks(right);
const auto & leftSlots = left->Slots();
const auto & rightSlots = right->Slots();
auto i = leftSlots.begin();
auto j = rightSlots.begin();
@ -73,8 +67,8 @@ void CExchangeController::moveArmy(bool leftToRight, std::optional<SlotID> heldS
if(!heldSlot.has_value())
{
auto weakestSlot = vstd::minElementByFun(source->Slots(),
[](const std::pair<SlotID, CStackInstance*> & s) -> int
const auto & weakestSlot = vstd::minElementByFun(source->Slots(),
[](const auto & s) -> int
{
return s.second->getCreatureID().toCreature()->getAIValue();
});