From a79ade7d4421436e821c4f0dc38c6343b4ab79ea Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Mon, 24 Aug 2015 20:43:52 -0400 Subject: [PATCH] Garrison: Move all but one creature when last slot --- client/widgets/CGarrisonInt.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/client/widgets/CGarrisonInt.cpp b/client/widgets/CGarrisonInt.cpp index 3f514c4fc..6f18277bc 100644 --- a/client/widgets/CGarrisonInt.cpp +++ b/client/widgets/CGarrisonInt.cpp @@ -299,10 +299,22 @@ void CGarrisonSlot::clickLeft(tribool down, bool previousState) refr = split(); // swap else if(creature != selection->creature) - LOCPLINT->cb->swapCreatures(owner->armedObjs[upg], owner->armedObjs[selection->upg], ID, selection->ID); + { + const CArmedInstance * selectedObj = owner->armedObjs[selection->upg]; + if (!creature && selectedObj->stacksCount() == 1) + LOCPLINT->cb->splitStack(selectedObj, owner->armedObjs[upg], selection->ID, ID, myStack->count - 1); + else + LOCPLINT->cb->swapCreatures(owner->armedObjs[upg], owner->armedObjs[selection->upg], ID, selection->ID); + } // merge else - LOCPLINT->cb->mergeStacks(owner->armedObjs[selection->upg], owner->armedObjs[upg], selection->ID, ID); + { + const CArmedInstance * selectedObj = owner->armedObjs[selection->upg]; + if (selectedObj->stacksCount() == 1) + LOCPLINT->cb->splitStack(owner->armedObjs[upg], selectedObj, selection->ID, ID, 1); + else + LOCPLINT->cb->mergeStacks(owner->armedObjs[selection->upg], owner->armedObjs[upg], selection->ID, ID); + } if(refr) { // Refresh Statusbar