1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Fixed Commander artifacts management, including #968.

This commit is contained in:
DjWarmonger
2012-05-25 15:10:38 +00:00
parent 41480a489e
commit e0135ab6a6
3 changed files with 21 additions and 10 deletions

View File

@ -312,15 +312,20 @@ void CHeroWindow::commanderWindow()
{
const CGHeroInstance *srcHero = commonInfo->src.AOH->getHero();
artSelected = true;
ArtifactLocation src (srcHero, commonInfo->src.slotID);
ArtifactLocation dst (curHero->commander.get(), art->firstAvailableSlot (curHero->commander));
if (art->canBePutAt(dst, true))
{ //equip clicked stack
if(dst.getArt())
{
LOCPLINT->cb->swapArtifacts (dst, ArtifactLocation(srcHero, dst.getArt()->firstBackpackSlot(srcHero)));
int freeSlot = art->firstAvailableSlot (curHero->commander);
if (freeSlot < ArtifactPosition::COMMANDER_AFTER_LAST) //we don't want to put it in commander's backpack!
{
ArtifactLocation src (srcHero, commonInfo->src.slotID);
ArtifactLocation dst (curHero->commander.get(), freeSlot);
if (art->canBePutAt(dst, true))
{ //equip clicked stack
if(dst.getArt())
{
LOCPLINT->cb->swapArtifacts (dst, ArtifactLocation(srcHero, dst.getArt()->firstBackpackSlot(srcHero)));
}
LOCPLINT->cb->swapArtifacts(src, dst);
}
LOCPLINT->cb->swapArtifacts(src, dst);
}
}
else