1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-11 11:31:52 +02:00
This commit is contained in:
DjWarmonger 2013-03-05 07:34:52 +00:00
parent 1d52d68497
commit ca8182f80f

View File

@ -735,6 +735,32 @@ DLL_LINKAGE void RebalanceStacks::applyGs( CGameState *gs )
if(const CCreature *c = dst.army->getCreature(dst.slot)) //stack at dest -> merge
{
assert(c == srcType);
auto alHere = ArtifactLocation (src.getStack(), ArtifactPosition::CREATURE_SLOT);
auto alDest = ArtifactLocation (dst.getStack(), ArtifactPosition::CREATURE_SLOT);
auto artHere = alHere.getArt();
auto artDest = alDest.getArt();
if (artHere)
{
if (alDest.getArt())
{
auto hero = dynamic_cast <CGHeroInstance *>(src.army.get());
if (hero)
{
artDest->move (alDest, ArtifactLocation (hero, alDest.getArt()->firstBackpackSlot (hero)));
}
//else - artifact cna be lost :/
else
{
tlog2 << "Artifact is present at destination slot!";
}
artHere->move (alHere, alDest);
//TODO: choose from dialog
}
else //just move to the other slot before stack gets erased
{
artHere->move (alHere, alDest);
}
}
if (stackExp)
{
ui64 totalExp = srcCount * src.army->getStackExperience(src.slot) + dst.army->getStackCount(dst.slot) * dst.army->getStackExperience(dst.slot);