1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

ArtifactUtils::isSlotBackpack() func + refactoring

This commit is contained in:
SoundSSGood
2022-11-18 22:49:57 +02:00
parent 30bbb57619
commit e6e669d024
5 changed files with 15 additions and 17 deletions

View File

@ -1089,7 +1089,7 @@ DLL_LINKAGE void EraseArtifact::applyGs(CGameState *gs)
DLL_LINKAGE void MoveArtifact::applyGs(CGameState * gs)
{
CArtifactInstance * art = src.getArt();
if(dst.slot < GameConstants::BACKPACK_START)
if(!ArtifactUtils::isSlotBackpack(dst.slot))
assert(!dst.getArt());
art->move(src, dst);
@ -1114,7 +1114,7 @@ DLL_LINKAGE void BulkMoveArtifacts::applyGs(CGameState * gs)
// so all the following indices will be affected. Thus, we need to update
// the subsequent artifact slots to account for that
auto srcPos = slot.srcPos;
if((srcPos >= GameConstants::BACKPACK_START) && (operation != EBulkArtsOp::BULK_PUT))
if(ArtifactUtils::isSlotBackpack(srcPos) && (operation != EBulkArtsOp::BULK_PUT))
{
srcPos = ArtifactPosition(srcPos.num - numBackpackArtifactsMoved);
}
@ -1170,9 +1170,7 @@ DLL_LINKAGE void AssembledArtifact::applyGs(CGameState *gs)
CArtifactSet * artSet = al.getHolderArtSet();
const CArtifactInstance *transformedArt = al.getArt();
assert(transformedArt);
bool combineEquipped = true;
if(al.slot >= GameConstants::BACKPACK_START)
combineEquipped = false;
bool combineEquipped = !ArtifactUtils::isSlotBackpack(al.slot);
assert(vstd::contains(transformedArt->assemblyPossibilities(artSet, combineEquipped), builtArt));
UNUSED(transformedArt);
@ -1196,7 +1194,7 @@ DLL_LINKAGE void AssembledArtifact::applyGs(CGameState *gs)
}
else
{
al.slot = std::min(al.slot, pos)
al.slot = std::min(al.slot, pos);
}
}