mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Fixed Commander artifacts management, including #968.
This commit is contained in:
@ -533,7 +533,13 @@ void CCreatureWindow::passArtifactToHero()
|
|||||||
|
|
||||||
void CCreatureWindow::artifactRemoved (const ArtifactLocation &artLoc)
|
void CCreatureWindow::artifactRemoved (const ArtifactLocation &artLoc)
|
||||||
{
|
{
|
||||||
//TODO: align artifacts to remove holes
|
//align artifacts to remove holes
|
||||||
|
BOOST_FOREACH (auto al, stack->artifactsWorn)
|
||||||
|
{
|
||||||
|
int freeSlot = al.second.artifact->firstAvailableSlot(stack);
|
||||||
|
if (freeSlot < al.first)
|
||||||
|
LOCPLINT->cb->swapArtifacts (ArtifactLocation(stack, al.first), ArtifactLocation(stack, freeSlot));
|
||||||
|
}
|
||||||
int size = stack->artifactsWorn.size();
|
int size = stack->artifactsWorn.size();
|
||||||
displayedArtifact = size ? (displayedArtifact % size) : ArtifactPosition::CREATURE_SLOT; //0
|
displayedArtifact = size ? (displayedArtifact % size) : ArtifactPosition::CREATURE_SLOT; //0
|
||||||
setArt (stack->getArt(displayedArtifact));
|
setArt (stack->getArt(displayedArtifact));
|
||||||
|
@ -312,15 +312,20 @@ void CHeroWindow::commanderWindow()
|
|||||||
{
|
{
|
||||||
const CGHeroInstance *srcHero = commonInfo->src.AOH->getHero();
|
const CGHeroInstance *srcHero = commonInfo->src.AOH->getHero();
|
||||||
artSelected = true;
|
artSelected = true;
|
||||||
ArtifactLocation src (srcHero, commonInfo->src.slotID);
|
int freeSlot = art->firstAvailableSlot (curHero->commander);
|
||||||
ArtifactLocation dst (curHero->commander.get(), art->firstAvailableSlot (curHero->commander));
|
if (freeSlot < ArtifactPosition::COMMANDER_AFTER_LAST) //we don't want to put it in commander's backpack!
|
||||||
if (art->canBePutAt(dst, true))
|
{
|
||||||
{ //equip clicked stack
|
ArtifactLocation src (srcHero, commonInfo->src.slotID);
|
||||||
if(dst.getArt())
|
ArtifactLocation dst (curHero->commander.get(), freeSlot);
|
||||||
{
|
|
||||||
LOCPLINT->cb->swapArtifacts (dst, ArtifactLocation(srcHero, dst.getArt()->firstBackpackSlot(srcHero)));
|
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
|
else
|
||||||
|
@ -29,7 +29,7 @@ namespace ArtifactPosition
|
|||||||
AFTER_LAST,
|
AFTER_LAST,
|
||||||
//cres
|
//cres
|
||||||
CREATURE_SLOT = 0,
|
CREATURE_SLOT = 0,
|
||||||
COMMANDER1 = 0, COMMANDER2, COMMANDER3, COMMANDER4, COMMANDER5, COMMANDER6
|
COMMANDER1 = 0, COMMANDER2, COMMANDER3, COMMANDER4, COMMANDER5, COMMANDER6, COMMANDER_AFTER_LAST
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user