1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Fixed issue with taking creatures from a Bank, Pandora or joiners

This commit is contained in:
Tomasz Zieliński
2022-09-09 19:30:24 +02:00
committed by Andrii Danylchenko
parent b52faad4c7
commit 6fb7301e8e

View File

@@ -5572,13 +5572,21 @@ bool CGameHandler::isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2)
return true; return true;
} }
//Ongoing garrison exchange //Ongoing garrison exchange - usually picking from top garison (from o1 to o2), but who knows
if (auto dialog = std::dynamic_pointer_cast<CGarrisonDialogQuery>(queries.topQuery(o1->tempOwner))) auto dialog = std::dynamic_pointer_cast<CGarrisonDialogQuery>(queries.topQuery(o1->tempOwner));
if (!dialog)
{ {
if (dialog->exchangingArmies.at(0) == o1 && dialog->exchangingArmies.at(1) == o2) dialog = std::dynamic_pointer_cast<CGarrisonDialogQuery>(queries.topQuery(o2->tempOwner));
}
if (dialog)
{
auto topArmy = dialog->exchangingArmies.at(0);
auto bottomArmy = dialog->exchangingArmies.at(1);
if (topArmy == o1 && bottomArmy == o2)
return true; return true;
if (dialog->exchangingArmies.at(1) == o1 && dialog->exchangingArmies.at(0) == o2) if (bottomArmy == o1 && topArmy == o2)
return true; return true;
} }
} }