|
@@ -56,11 +56,26 @@ const std::vector<const CArtifact*> & CCombinedArtifact::getConstituents() const
|
|
|
return constituents;
|
|
|
}
|
|
|
|
|
|
-const std::vector<const CArtifact*> & CCombinedArtifact::getPartOf() const
|
|
|
+const std::set<const CArtifact*> & CCombinedArtifact::getPartOf() const
|
|
|
{
|
|
|
return partOf;
|
|
|
}
|
|
|
|
|
|
+void CCombinedArtifact::setFused(bool isFused)
|
|
|
+{
|
|
|
+ fused = isFused;
|
|
|
+}
|
|
|
+
|
|
|
+bool CCombinedArtifact::isFused() const
|
|
|
+{
|
|
|
+ return fused;
|
|
|
+}
|
|
|
+
|
|
|
+bool CCombinedArtifact::hasParts() const
|
|
|
+{
|
|
|
+ return isCombined() && !isFused();
|
|
|
+}
|
|
|
+
|
|
|
bool CScrollArtifact::isScroll() const
|
|
|
{
|
|
|
return static_cast<const CArtifact*>(this)->getId() == ArtifactID::SPELL_SCROLL;
|
|
@@ -203,7 +218,7 @@ bool CArtifact::canBePutAt(const CArtifactSet * artSet, ArtifactPosition slot, b
|
|
|
|
|
|
auto artCanBePutAt = [this, simpleArtCanBePutAt](const CArtifactSet * artSet, ArtifactPosition slot, bool assumeDestRemoved) -> bool
|
|
|
{
|
|
|
- if(isCombined())
|
|
|
+ if(hasParts())
|
|
|
{
|
|
|
if(!simpleArtCanBePutAt(artSet, slot, assumeDestRemoved))
|
|
|
return false;
|
|
@@ -606,19 +621,21 @@ void CArtHandler::loadType(CArtifact * art, const JsonNode & node) const
|
|
|
|
|
|
void CArtHandler::loadComponents(CArtifact * art, const JsonNode & node)
|
|
|
{
|
|
|
- if (!node["components"].isNull())
|
|
|
+ if(!node["components"].isNull())
|
|
|
{
|
|
|
for(const auto & component : node["components"].Vector())
|
|
|
{
|
|
|
- VLC->identifiers()->requestIdentifier("artifact", component, [=](si32 id)
|
|
|
+ VLC->identifiers()->requestIdentifier("artifact", component, [this, art](int32_t id)
|
|
|
{
|
|
|
// when this code is called both combinational art as well as component are loaded
|
|
|
// so it is safe to access any of them
|
|
|
art->constituents.push_back(ArtifactID(id).toArtifact());
|
|
|
- objects[id]->partOf.push_back(art);
|
|
|
+ objects[id]->partOf.insert(art);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ if(!node["fusedComponents"].isNull())
|
|
|
+ art->setFused(node["fusedComponents"].Bool());
|
|
|
}
|
|
|
|
|
|
void CArtHandler::makeItCreatureArt(CArtifact * a, bool onlyCreature)
|
|
@@ -767,8 +784,27 @@ bool CArtifactSet::hasArt(const ArtifactID & aid, bool onlyWorn, bool searchComb
|
|
|
CArtifactSet::ArtPlacementMap CArtifactSet::putArtifact(const ArtifactPosition & slot, CArtifactInstance * art)
|
|
|
{
|
|
|
ArtPlacementMap resArtPlacement;
|
|
|
+ const auto putToSlot = [this](const ArtifactPosition & targetSlot, CArtifactInstance * targetArt, bool locked)
|
|
|
+ {
|
|
|
+ ArtSlotInfo * slotInfo;
|
|
|
+ if(targetSlot == ArtifactPosition::TRANSITION_POS)
|
|
|
+ {
|
|
|
+ slotInfo = &artifactsTransitionPos;
|
|
|
+ }
|
|
|
+ else if(ArtifactUtils::isSlotEquipment(targetSlot))
|
|
|
+ {
|
|
|
+ slotInfo = &artifactsWorn[targetSlot];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ auto position = artifactsInBackpack.begin() + targetSlot - ArtifactPosition::BACKPACK_START;
|
|
|
+ slotInfo = &(*artifactsInBackpack.emplace(position));
|
|
|
+ }
|
|
|
+ slotInfo->artifact = targetArt;
|
|
|
+ slotInfo->locked = locked;
|
|
|
+ };
|
|
|
|
|
|
- setNewArtSlot(slot, art, false);
|
|
|
+ putToSlot(slot, art, false);
|
|
|
if(art->artType->isCombined() && ArtifactUtils::isSlotEquipment(slot))
|
|
|
{
|
|
|
const CArtifactInstance * mainPart = nullptr;
|
|
@@ -789,7 +825,7 @@ CArtifactSet::ArtPlacementMap CArtifactSet::putArtifact(const ArtifactPosition &
|
|
|
partSlot = ArtifactUtils::getArtAnyPosition(this, part.art->getTypeId());
|
|
|
|
|
|
assert(ArtifactUtils::isSlotEquipment(partSlot));
|
|
|
- setNewArtSlot(partSlot, part.art, true);
|
|
|
+ putToSlot(partSlot, part.art, true);
|
|
|
resArtPlacement.emplace(part.art, partSlot);
|
|
|
}
|
|
|
else
|
|
@@ -877,7 +913,15 @@ const ArtSlotInfo * CArtifactSet::getSlot(const ArtifactPosition & pos) const
|
|
|
|
|
|
void CArtifactSet::lockSlot(const ArtifactPosition & pos)
|
|
|
{
|
|
|
- setNewArtSlot(pos, nullptr, true);
|
|
|
+ if(pos == ArtifactPosition::TRANSITION_POS)
|
|
|
+ artifactsTransitionPos.locked = true;
|
|
|
+ else if(ArtifactUtils::isSlotEquipment(pos))
|
|
|
+ artifactsWorn[pos].locked = true;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ assert(artifactsInBackpack.size() > pos - ArtifactPosition::BACKPACK_START);
|
|
|
+ (artifactsInBackpack.begin() + pos - ArtifactPosition::BACKPACK_START)->locked = true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
bool CArtifactSet::isPositionFree(const ArtifactPosition & pos, bool onlyLockCheck) const
|
|
@@ -891,28 +935,6 @@ bool CArtifactSet::isPositionFree(const ArtifactPosition & pos, bool onlyLockChe
|
|
|
return true; //no slot means not used
|
|
|
}
|
|
|
|
|
|
-void CArtifactSet::setNewArtSlot(const ArtifactPosition & slot, CArtifactInstance * art, bool locked)
|
|
|
-{
|
|
|
- assert(!vstd::contains(artifactsWorn, slot));
|
|
|
-
|
|
|
- ArtSlotInfo * slotInfo;
|
|
|
- if(slot == ArtifactPosition::TRANSITION_POS)
|
|
|
- {
|
|
|
- slotInfo = &artifactsTransitionPos;
|
|
|
- }
|
|
|
- else if(ArtifactUtils::isSlotEquipment(slot))
|
|
|
- {
|
|
|
- slotInfo = &artifactsWorn[slot];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- auto position = artifactsInBackpack.begin() + slot - ArtifactPosition::BACKPACK_START;
|
|
|
- slotInfo = &(*artifactsInBackpack.emplace(position));
|
|
|
- }
|
|
|
- slotInfo->artifact = art;
|
|
|
- slotInfo->locked = locked;
|
|
|
-}
|
|
|
-
|
|
|
void CArtifactSet::artDeserializationFix(CBonusSystemNode *node)
|
|
|
{
|
|
|
for(auto & elem : artifactsWorn)
|