1
0
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:
Michał W. Urbańczyk
2009-09-11 05:45:40 +00:00
parent a9617b3dfd
commit df87b34662
8 changed files with 125 additions and 45 deletions

View File

@@ -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;
}