mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-23 00:28:08 +02:00
final fixup
This commit is contained in:
@ -856,20 +856,12 @@ bool CArtifactInstance::canBePutAt(const ArtifactLocation & al, bool assumeDestR
|
||||
|
||||
void CArtifactInstance::putAt(ArtifactLocation al)
|
||||
{
|
||||
assert(canBePutAt(al));
|
||||
|
||||
al.getHolderArtSet()->CArtifactSet::putArtifact(al.slot, this);
|
||||
if(ArtifactUtils::isSlotEquipment(al.slot))
|
||||
al.getHolderNode()->attachTo(*this);
|
||||
al.getHolderArtSet()->putArtifact(al.slot, this);
|
||||
}
|
||||
|
||||
void CArtifactInstance::removeFrom(ArtifactLocation al)
|
||||
{
|
||||
assert(al.getHolderArtSet()->getArt(al.slot) == this);
|
||||
|
||||
al.getHolderArtSet()->removeArtifact(al.slot);
|
||||
if(ArtifactUtils::isSlotEquipment(al.slot))
|
||||
al.getHolderNode()->detachFrom(*this);
|
||||
}
|
||||
|
||||
bool CArtifactInstance::canBeDisassembled() const
|
||||
@ -930,16 +922,6 @@ 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)
|
||||
|
@ -158,12 +158,12 @@ public:
|
||||
ArtifactID getTypeId() const;
|
||||
bool canBePutAt(const ArtifactLocation & al, bool assumeDestRemoved = false) const; //forwards to the above one
|
||||
virtual bool canBeDisassembled() const;
|
||||
virtual void putAt(ArtifactLocation al);
|
||||
virtual void removeFrom(ArtifactLocation al);
|
||||
/// Checks if this a part of this artifact: artifact instance is a part
|
||||
/// 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);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
@ -195,9 +195,7 @@ public:
|
||||
|
||||
std::vector<ConstituentInfo> constituentsInfo;
|
||||
|
||||
void removeFrom(ArtifactLocation al) override;
|
||||
bool isPart(const CArtifactInstance *supposedPart) const override;
|
||||
|
||||
void createConstituents();
|
||||
void addAsConstituent(CArtifactInstance * art, const ArtifactPosition & slot);
|
||||
|
||||
@ -323,7 +321,7 @@ public:
|
||||
|
||||
virtual ArtBearer::ArtBearer bearerType() const = 0;
|
||||
virtual void putArtifact(ArtifactPosition slot, CArtifactInstance * art);
|
||||
void removeArtifact(ArtifactPosition slot);
|
||||
virtual void removeArtifact(ArtifactPosition slot);
|
||||
virtual ~CArtifactSet();
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "CCreatureSet.h"
|
||||
|
||||
#include "ArtifactUtils.h"
|
||||
#include "CConfigHandler.h"
|
||||
#include "CCreatureHandler.h"
|
||||
#include "VCMI_Lib.h"
|
||||
@ -870,7 +871,20 @@ ArtBearer::ArtBearer CStackInstance::bearerType() const
|
||||
void CStackInstance::putArtifact(ArtifactPosition pos, CArtifactInstance * art)
|
||||
{
|
||||
assert(!getArt(pos));
|
||||
art->putAt(ArtifactLocation(this, pos));
|
||||
assert(art->artType->canBePutAt(this, pos));
|
||||
|
||||
CArtifactSet::putArtifact(pos, art);
|
||||
if(ArtifactUtils::isSlotEquipment(pos))
|
||||
attachTo(*art);
|
||||
}
|
||||
|
||||
void CStackInstance::removeArtifact(ArtifactPosition pos)
|
||||
{
|
||||
assert(getArt(pos));
|
||||
|
||||
CArtifactSet::removeArtifact(pos);
|
||||
if(ArtifactUtils::isSlotEquipment(pos))
|
||||
detachFrom(*getArt(pos));
|
||||
}
|
||||
|
||||
void CStackInstance::serializeJson(JsonSerializeFormat & handler)
|
||||
|
@ -121,6 +121,7 @@ public:
|
||||
virtual void giveStackExp(TExpType exp);
|
||||
bool valid(bool allowUnrandomized) const;
|
||||
void putArtifact(ArtifactPosition pos, CArtifactInstance * art) override;//from CArtifactSet
|
||||
void removeArtifact(ArtifactPosition pos) override;
|
||||
ArtBearer::ArtBearer bearerType() const override; //from CArtifactSet
|
||||
virtual std::string nodeName() const override; //from CBonusSystemnode
|
||||
void deserializationFix();
|
||||
|
@ -1798,7 +1798,6 @@ void PutArtifact::applyGs(CGameState *gs)
|
||||
assert(vstd::contains(gs->map->artInstances, art));
|
||||
assert(!art->getParentNodes().empty());
|
||||
art->putAt(al);
|
||||
//al.hero->putArtifact(al.slot, art);
|
||||
}
|
||||
|
||||
void EraseArtifact::applyGs(CGameState *gs)
|
||||
|
@ -1031,7 +1031,21 @@ std::string CGHeroInstance::getBiographyTextID() const
|
||||
void CGHeroInstance::putArtifact(ArtifactPosition pos, CArtifactInstance *art)
|
||||
{
|
||||
assert(!getArt(pos));
|
||||
art->putAt(ArtifactLocation(this, pos));
|
||||
assert(art->artType->canBePutAt(this, pos));
|
||||
|
||||
CArtifactSet::putArtifact(pos, art);
|
||||
if(ArtifactUtils::isSlotEquipment(pos))
|
||||
attachTo(*art);
|
||||
}
|
||||
|
||||
void CGHeroInstance::removeArtifact(ArtifactPosition pos)
|
||||
{
|
||||
auto art = getArt(pos);
|
||||
assert(art);
|
||||
|
||||
CArtifactSet::removeArtifact(pos);
|
||||
if(ArtifactUtils::isSlotEquipment(pos))
|
||||
detachFrom(*art);
|
||||
}
|
||||
|
||||
bool CGHeroInstance::hasSpellbook() const
|
||||
|
@ -223,9 +223,9 @@ public:
|
||||
void initHero(CRandomGenerator & rand, const HeroTypeID & SUBID);
|
||||
|
||||
void putArtifact(ArtifactPosition pos, CArtifactInstance * art) override;
|
||||
void removeArtifact(ArtifactPosition pos) override;
|
||||
void initExp(CRandomGenerator & rand);
|
||||
void initArmy(CRandomGenerator & rand, IArmyDescriptor *dst = nullptr);
|
||||
//void giveArtifact (ui32 aid);
|
||||
void pushPrimSkill(PrimarySkill::PrimarySkill which, int val);
|
||||
ui8 maxlevelsToMagicSchool() const;
|
||||
ui8 maxlevelsToWisdom() const;
|
||||
|
Reference in New Issue
Block a user