mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Merge pull request #2211 from SoundSSGood/art-refactoring-hotfix
Fixing regressions
This commit is contained in:
commit
3924f0f081
@ -225,8 +225,8 @@ void CArtifactsOfHeroBase::updateWornSlots()
|
||||
|
||||
void CArtifactsOfHeroBase::updateBackpackSlots()
|
||||
{
|
||||
for(auto artPlace : backpack)
|
||||
updateSlot(artPlace->slot);
|
||||
if(curHero->artifactsInBackpack.size() <= backpack.size() && backpackPos != 0)
|
||||
backpackPos = 0;
|
||||
scrollBackpackForArtSet(0, *curHero);
|
||||
}
|
||||
|
||||
|
@ -924,6 +924,16 @@ void CCombinedArtifactInstance::addAsConstituent(CArtifactInstance * art, const
|
||||
attachTo(*art);
|
||||
}
|
||||
|
||||
void CCombinedArtifactInstance::removeFrom(ArtifactLocation al)
|
||||
{
|
||||
CArtifactInstance::removeFrom(al);
|
||||
for(auto & part : constituentsInfo)
|
||||
{
|
||||
if(part.slot != ArtifactPosition::PRE_FIRST)
|
||||
part.slot = ArtifactPosition::PRE_FIRST;
|
||||
}
|
||||
}
|
||||
|
||||
void CCombinedArtifactInstance::deserializationFix()
|
||||
{
|
||||
for(ConstituentInfo &ci : constituentsInfo)
|
||||
@ -1092,7 +1102,8 @@ void CArtifactSet::putArtifact(ArtifactPosition slot, CArtifactInstance * art)
|
||||
const CArtifactInstance * mainPart = nullptr;
|
||||
auto & parts = dynamic_cast<CCombinedArtifactInstance*>(art)->constituentsInfo;
|
||||
for(const auto & part : parts)
|
||||
if(vstd::contains(part.art->artType->possibleSlots.at(bearerType()), slot))
|
||||
if(vstd::contains(part.art->artType->possibleSlots.at(bearerType()), slot)
|
||||
&& (part.slot == ArtifactPosition::PRE_FIRST))
|
||||
{
|
||||
mainPart = part.art;
|
||||
break;
|
||||
|
@ -162,9 +162,9 @@ public:
|
||||
/// of itself, additionally truth is returned for constituents of combined arts
|
||||
virtual bool isPart(const CArtifactInstance *supposedPart) const;
|
||||
|
||||
void putAt(ArtifactLocation al);
|
||||
void removeFrom(ArtifactLocation al);
|
||||
void move(const ArtifactLocation & src,const ArtifactLocation & dst);
|
||||
virtual void putAt(ArtifactLocation al);
|
||||
virtual void removeFrom(ArtifactLocation al);
|
||||
virtual void move(const ArtifactLocation & src, const ArtifactLocation & dst);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
@ -198,6 +198,7 @@ public:
|
||||
bool isPart(const CArtifactInstance *supposedPart) const override;
|
||||
void createConstituents();
|
||||
void addAsConstituent(CArtifactInstance * art, const ArtifactPosition & slot);
|
||||
void removeFrom(ArtifactLocation al) override;
|
||||
|
||||
CCombinedArtifactInstance() = default;
|
||||
|
||||
|
@ -1941,13 +1941,14 @@ void AssembledArtifact::applyGs(CGameState *gs)
|
||||
if(!vstd::contains(combinedArt->artType->possibleSlots[artSet->bearerType()], al.slot)
|
||||
&& vstd::contains(combinedArt->artType->possibleSlots[artSet->bearerType()], pos))
|
||||
al.slot = pos;
|
||||
if(al.slot == pos)
|
||||
pos = ArtifactPosition::PRE_FIRST;
|
||||
}
|
||||
else
|
||||
{
|
||||
al.slot = std::min(al.slot, pos);
|
||||
}
|
||||
if(al.slot == pos)
|
||||
pos = ArtifactPosition::PRE_FIRST;
|
||||
}
|
||||
combinedArt->addAsConstituent(constituentInstance, pos);
|
||||
}
|
||||
|
||||
|
@ -1031,7 +1031,6 @@ std::string CGHeroInstance::getBiographyTextID() const
|
||||
|
||||
void CGHeroInstance::putArtifact(ArtifactPosition pos, CArtifactInstance *art)
|
||||
{
|
||||
assert(!getArt(pos));
|
||||
assert(art->artType->canBePutAt(this, pos));
|
||||
|
||||
CArtifactSet::putArtifact(pos, art);
|
||||
|
Loading…
Reference in New Issue
Block a user