mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Fix incorrect assertions
This commit is contained in:
@@ -861,8 +861,6 @@ void CArtifactInstance::removeFrom(ArtifactLocation al)
|
|||||||
al.getHolderArtSet()->eraseArtSlot(al.slot);
|
al.getHolderArtSet()->eraseArtSlot(al.slot);
|
||||||
if(!ArtifactUtils::isSlotBackpack(al.slot))
|
if(!ArtifactUtils::isSlotBackpack(al.slot))
|
||||||
al.getHolderNode()->detachFrom(*this);
|
al.getHolderNode()->detachFrom(*this);
|
||||||
|
|
||||||
//TODO delete me?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CArtifactInstance::canBeDisassembled() const
|
bool CArtifactInstance::canBeDisassembled() const
|
||||||
@@ -1062,7 +1060,9 @@ void CCombinedArtifactInstance::createConstituents()
|
|||||||
|
|
||||||
void CCombinedArtifactInstance::addAsConstituent(CArtifactInstance *art, ArtifactPosition slot)
|
void CCombinedArtifactInstance::addAsConstituent(CArtifactInstance *art, ArtifactPosition slot)
|
||||||
{
|
{
|
||||||
assert(vstd::contains(*artType->constituents, art->artType.get()));
|
assert(vstd::contains_if(*artType->constituents, [=](const CArtifact * constituent){
|
||||||
|
return constituent->id == art->artType->id;
|
||||||
|
}));
|
||||||
assert(art->getParentNodes().size() == 1 && art->getParentNodes().front() == art->artType);
|
assert(art->getParentNodes().size() == 1 && art->getParentNodes().front() == art->artType);
|
||||||
constituentsInfo.push_back(ConstituentInfo(art, slot));
|
constituentsInfo.push_back(ConstituentInfo(art, slot));
|
||||||
attachTo(*art);
|
attachTo(*art);
|
||||||
@@ -1354,11 +1354,16 @@ bool CArtifactSet::isPositionFree(ArtifactPosition pos, bool onlyLockCheck) cons
|
|||||||
ArtSlotInfo & CArtifactSet::retrieveNewArtSlot(ArtifactPosition slot)
|
ArtSlotInfo & CArtifactSet::retrieveNewArtSlot(ArtifactPosition slot)
|
||||||
{
|
{
|
||||||
assert(!vstd::contains(artifactsWorn, slot));
|
assert(!vstd::contains(artifactsWorn, slot));
|
||||||
ArtSlotInfo &ret = !ArtifactUtils::isSlotBackpack(slot)
|
|
||||||
? artifactsWorn[slot]
|
|
||||||
: *artifactsInBackpack.insert(artifactsInBackpack.begin() + (slot - GameConstants::BACKPACK_START), ArtSlotInfo());
|
|
||||||
|
|
||||||
return ret;
|
if (!ArtifactUtils::isSlotBackpack(slot))
|
||||||
|
return artifactsWorn[slot];
|
||||||
|
|
||||||
|
ArtSlotInfo newSlot;
|
||||||
|
size_t index = slot - GameConstants::BACKPACK_START;
|
||||||
|
auto position = artifactsInBackpack.begin() + index;
|
||||||
|
auto inserted = artifactsInBackpack.insert(position, newSlot);
|
||||||
|
|
||||||
|
return *inserted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CArtifactSet::setNewArtSlot(ArtifactPosition slot, CArtifactInstance *art, bool locked)
|
void CArtifactSet::setNewArtSlot(ArtifactPosition slot, CArtifactInstance *art, bool locked)
|
||||||
@@ -1372,9 +1377,10 @@ void CArtifactSet::eraseArtSlot(ArtifactPosition slot)
|
|||||||
{
|
{
|
||||||
if(ArtifactUtils::isSlotBackpack(slot))
|
if(ArtifactUtils::isSlotBackpack(slot))
|
||||||
{
|
{
|
||||||
assert(artifactsInBackpack.begin() + slot < artifactsInBackpack.end());
|
auto backpackSlot = ArtifactPosition(slot - GameConstants::BACKPACK_START);
|
||||||
slot = ArtifactPosition(slot - GameConstants::BACKPACK_START);
|
|
||||||
artifactsInBackpack.erase(artifactsInBackpack.begin() + slot);
|
assert(artifactsInBackpack.begin() + backpackSlot < artifactsInBackpack.end());
|
||||||
|
artifactsInBackpack.erase(artifactsInBackpack.begin() + backpackSlot);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user