diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 383e7b205..30f940ca6 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -5572,13 +5572,21 @@ bool CGameHandler::isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2) return true; } - //Ongoing garrison exchange - if (auto dialog = std::dynamic_pointer_cast(queries.topQuery(o1->tempOwner))) + //Ongoing garrison exchange - usually picking from top garison (from o1 to o2), but who knows + auto dialog = std::dynamic_pointer_cast(queries.topQuery(o1->tempOwner)); + if (!dialog) { - if (dialog->exchangingArmies.at(0) == o1 && dialog->exchangingArmies.at(1) == o2) + dialog = std::dynamic_pointer_cast(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; - if (dialog->exchangingArmies.at(1) == o1 && dialog->exchangingArmies.at(0) == o2) + if (bottomArmy == o1 && topArmy == o2) return true; } }