mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-14 02:33:51 +02:00
Fixed Commander artifacts management, including #968.
This commit is contained in:
parent
41480a489e
commit
e0135ab6a6
@ -533,7 +533,13 @@ void CCreatureWindow::passArtifactToHero()
|
||||
|
||||
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();
|
||||
displayedArtifact = size ? (displayedArtifact % size) : ArtifactPosition::CREATURE_SLOT; //0
|
||||
setArt (stack->getArt(displayedArtifact));
|
||||
|
@ -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
|
||||
|
@ -29,7 +29,7 @@ namespace ArtifactPosition
|
||||
AFTER_LAST,
|
||||
//cres
|
||||
CREATURE_SLOT = 0,
|
||||
COMMANDER1 = 0, COMMANDER2, COMMANDER3, COMMANDER4, COMMANDER5, COMMANDER6
|
||||
COMMANDER1 = 0, COMMANDER2, COMMANDER3, COMMANDER4, COMMANDER5, COMMANDER6, COMMANDER_AFTER_LAST
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user