mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
* fixes for moving War Machines
* automatic merging same creatures stacks if needed when moving hero to town garrison * minor improvements
This commit is contained in:
@@ -2162,10 +2162,21 @@ bool CGameHandler::garrisonSwap( si32 tid )
|
||||
int pos = csn.getSlotFor(cso.slots.begin()->second.first);
|
||||
if(pos<0)
|
||||
{
|
||||
complain("Cannot make garrison swap, not enough free slots!");
|
||||
return false;
|
||||
//try to merge two other stacks to make place
|
||||
std::pair<TSlot, TSlot> toMerge;
|
||||
if(csn.mergableStacks(toMerge, cso.slots.begin()->first))
|
||||
{
|
||||
//merge
|
||||
csn.slots[toMerge.second].second += csn.slots[toMerge.first].second;
|
||||
csn.slots[toMerge.first] = cso.slots.begin()->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
complain("Cannot make garrison swap, not enough free slots!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(csn.slots.find(pos)!=csn.slots.end()) //add creatures to the existing stack
|
||||
else if(csn.slots.find(pos) != csn.slots.end()) //add creatures to the existing stack
|
||||
{
|
||||
csn.slots[pos].second += cso.slots.begin()->second.second;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user