mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
artifactTransitionPos created
This commit is contained in:
parent
48c01157e6
commit
6b7ce798d0
@ -740,11 +740,11 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact
|
||||
}
|
||||
else if(commonInfo->dst == src) //the dest artifact was moved -> we are picking it
|
||||
{
|
||||
assert(dst.slot >= GameConstants::BACKPACK_START);
|
||||
assert(ArtifactUtils::isSlotBackpack(dst.slot));
|
||||
commonInfo->reset();
|
||||
|
||||
CArtifactsOfHero::ArtPlacePtr ap;
|
||||
for(CArtifactsOfHero *aoh : commonInfo->participants)
|
||||
for(CArtifactsOfHero * aoh : commonInfo->participants)
|
||||
{
|
||||
if(dst.isHolder(aoh->curHero))
|
||||
{
|
||||
|
@ -824,7 +824,12 @@ bool CArtifactInstance::canBePutAt(const ArtifactLocation & al, bool assumeDestR
|
||||
|
||||
bool CArtifactInstance::canBePutAt(const CArtifactSet *artSet, ArtifactPosition slot, bool assumeDestRemoved) const
|
||||
{
|
||||
if(slot >= GameConstants::BACKPACK_START)
|
||||
if(slot == ArtifactPosition::TRANSITION_POS)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(ArtifactUtils::isSlotBackpack(slot))
|
||||
{
|
||||
if(artType->isBig())
|
||||
return false;
|
||||
@ -851,7 +856,7 @@ void CArtifactInstance::putAt(ArtifactLocation al)
|
||||
assert(canBePutAt(al));
|
||||
|
||||
al.getHolderArtSet()->setNewArtSlot(al.slot, this, false);
|
||||
if(!ArtifactUtils::isSlotBackpack(al.slot))
|
||||
if(!ArtifactUtils::isSlotBackpack(al.slot) && (al.slot != ArtifactPosition::TRANSITION_POS))
|
||||
al.getHolderNode()->attachTo(*this);
|
||||
}
|
||||
|
||||
@ -1329,6 +1334,8 @@ const CCombinedArtifactInstance *CArtifactSet::getAssemblyByConstituent(Artifact
|
||||
|
||||
const ArtSlotInfo * CArtifactSet::getSlot(ArtifactPosition pos) const
|
||||
{
|
||||
if(pos == ArtifactPosition::TRANSITION_POS)
|
||||
return &artifactTransitionPos;
|
||||
if(vstd::contains(artifactsWorn, pos))
|
||||
return &artifactsWorn.at(pos);
|
||||
if(pos >= ArtifactPosition::AFTER_LAST )
|
||||
@ -1355,7 +1362,9 @@ ArtSlotInfo & CArtifactSet::retrieveNewArtSlot(ArtifactPosition slot)
|
||||
{
|
||||
assert(!vstd::contains(artifactsWorn, slot));
|
||||
|
||||
if (!ArtifactUtils::isSlotBackpack(slot))
|
||||
if(slot == ArtifactPosition::TRANSITION_POS)
|
||||
return artifactTransitionPos;
|
||||
if(!ArtifactUtils::isSlotBackpack(slot))
|
||||
return artifactsWorn[slot];
|
||||
|
||||
ArtSlotInfo newSlot;
|
||||
|
@ -317,6 +317,7 @@ class DLL_LINKAGE CArtifactSet
|
||||
public:
|
||||
std::vector<ArtSlotInfo> artifactsInBackpack; //hero's artifacts from bag
|
||||
std::map<ArtifactPosition, ArtSlotInfo> artifactsWorn; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
|
||||
ArtSlotInfo artifactTransitionPos; // Used as transition position for manual artifact exchange
|
||||
|
||||
ArtSlotInfo & retrieveNewArtSlot(ArtifactPosition slot);
|
||||
void setNewArtSlot(ArtifactPosition slot, CArtifactInstance *art, bool locked);
|
||||
|
@ -983,6 +983,7 @@ class ArtifactPosition
|
||||
public:
|
||||
enum EArtifactPosition
|
||||
{
|
||||
TRANSITION_POS = -3,
|
||||
FIRST_AVAILABLE = -2,
|
||||
PRE_FIRST = -1, //sometimes used as error, sometimes as first free in backpack
|
||||
HEAD, SHOULDERS, NECK, RIGHT_HAND, LEFT_HAND, TORSO, //5
|
||||
|
@ -3907,17 +3907,17 @@ bool CGameHandler::moveArtifact(const ArtifactLocation &al1, const ArtifactLocat
|
||||
if (src.slot == ArtifactPosition::MACH4 || dst.slot == ArtifactPosition::MACH4)
|
||||
COMPLAIN_RET("Cannot move catapult!");
|
||||
|
||||
if (dst.slot >= GameConstants::BACKPACK_START)
|
||||
if(ArtifactUtils::isSlotBackpack(dst.slot))
|
||||
vstd::amin(dst.slot, ArtifactPosition(GameConstants::BACKPACK_START + (si32)dst.getHolderArtSet()->artifactsInBackpack.size()));
|
||||
|
||||
if (src.slot == dst.slot && src.artHolder == dst.artHolder)
|
||||
if(src.slot == dst.slot && src.artHolder == dst.artHolder)
|
||||
COMPLAIN_RET("Won't move artifact: Dest same as source!");
|
||||
|
||||
if (dst.slot < GameConstants::BACKPACK_START && destArtifact) //moving art to another slot
|
||||
// Check if dst slot is occupied
|
||||
if(!ArtifactUtils::isSlotBackpack(dst.slot) && destArtifact)
|
||||
{
|
||||
//old artifact must be removed first
|
||||
moveArtifact(dst, ArtifactLocation(dst.artHolder, ArtifactPosition(
|
||||
(si32)dst.getHolderArtSet()->artifactsInBackpack.size() + GameConstants::BACKPACK_START)));
|
||||
// Previous artifact must be removed first
|
||||
moveArtifact(dst, ArtifactLocation(dst.artHolder, ArtifactPosition::TRANSITION_POS));
|
||||
}
|
||||
auto hero = boost::get<ConstTransitivePtr<CGHeroInstance>>(dst.artHolder);
|
||||
if(ArtifactUtils::checkSpellbookIsNeeded(hero, srcArtifact->artType->id, dst.slot))
|
||||
|
Loading…
Reference in New Issue
Block a user