1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Regressions fixed

This commit is contained in:
SoundSSGood
2022-12-29 20:39:01 +02:00
parent c706b4d419
commit 4005b48360
5 changed files with 63 additions and 23 deletions

View File

@@ -3910,21 +3910,24 @@ bool CGameHandler::moveArtifact(const ArtifactLocation &al1, const ArtifactLocat
if(ArtifactUtils::isSlotBackpack(dst.slot))
vstd::amin(dst.slot, ArtifactPosition(GameConstants::BACKPACK_START + (si32)dst.getHolderArtSet()->artifactsInBackpack.size()));
if(src.slot == dst.slot && src.artHolder == dst.artHolder)
COMPLAIN_RET("Won't move artifact: Dest same as source!");
// Check if dst slot is occupied
if(!ArtifactUtils::isSlotBackpack(dst.slot) && destArtifact)
if(!(src.slot == ArtifactPosition::TRANSITION_POS && dst.slot == ArtifactPosition::TRANSITION_POS))
{
// Previous artifact must be removed first
moveArtifact(dst, ArtifactLocation(dst.artHolder, ArtifactPosition::TRANSITION_POS));
}
auto hero = boost::get<ConstTransitivePtr<CGHeroInstance>>(dst.artHolder);
if(ArtifactUtils::checkSpellbookIsNeeded(hero, srcArtifact->artType->id, dst.slot))
giveHeroNewArtifact(hero, VLC->arth->objects[ArtifactID::SPELLBOOK], ArtifactPosition::SPELLBOOK);
if(src.slot == dst.slot && src.artHolder == dst.artHolder)
COMPLAIN_RET("Won't move artifact: Dest same as source!");
MoveArtifact ma(&src, &dst);
sendAndApply(&ma);
// Check if dst slot is occupied
if(!ArtifactUtils::isSlotBackpack(dst.slot) && destArtifact)
{
// Previous artifact must be removed first
moveArtifact(dst, ArtifactLocation(dst.artHolder, ArtifactPosition::TRANSITION_POS));
}
auto hero = boost::get<ConstTransitivePtr<CGHeroInstance>>(dst.artHolder);
if(ArtifactUtils::checkSpellbookIsNeeded(hero, srcArtifact->artType->id, dst.slot))
giveHeroNewArtifact(hero, VLC->arth->objects[ArtifactID::SPELLBOOK], ArtifactPosition::SPELLBOOK);
MoveArtifact ma(&src, &dst);
sendAndApply(&ma);
}
return true;
}