mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-23 12:08:45 +02:00
Fixing several issues with artifacts in hero window described in note http://bugs.vcmi.eu/view.php?id=761#c1828 . Also resolving #741.
This commit is contained in:
parent
6e492e4e4b
commit
4592ddb74e
@ -4779,6 +4779,15 @@ void CArtPlace::select ()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
picked = true;
|
picked = true;
|
||||||
|
if(ourArt->canBeDisassembled() && slotID < Arts::BACKPACK_START) //worn combined artifact -> locks have to disappear
|
||||||
|
{
|
||||||
|
for(int i = 0; i < Arts::BACKPACK_START; i++)
|
||||||
|
{
|
||||||
|
CArtPlace *ap = ourOwner->getArtPlace(i);
|
||||||
|
ap->picked = ourArt->isPart(ap->ourArt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//int backpackCorrection = -(slotID - Arts::BACKPACK_START < ourOwner->backpackPos);
|
//int backpackCorrection = -(slotID - Arts::BACKPACK_START < ourOwner->backpackPos);
|
||||||
|
|
||||||
CCS->curh->dragAndDropCursor(graphics->artDefs->ourImages[ourArt->artType->id].bitmap);
|
CCS->curh->dragAndDropCursor(graphics->artDefs->ourImages[ourArt->artType->id].bitmap);
|
||||||
@ -4798,6 +4807,12 @@ void CArtPlace::select ()
|
|||||||
void CArtPlace::deselect ()
|
void CArtPlace::deselect ()
|
||||||
{
|
{
|
||||||
picked = false;
|
picked = false;
|
||||||
|
if(ourArt && ourArt->canBeDisassembled()) //combined art returned to its slot -> restore locks
|
||||||
|
{
|
||||||
|
for(int i = 0; i < Arts::BACKPACK_START; i++)
|
||||||
|
ourOwner->getArtPlace(i)->picked = false;
|
||||||
|
}
|
||||||
|
|
||||||
CCS->curh->dragAndDropCursor(NULL);
|
CCS->curh->dragAndDropCursor(NULL);
|
||||||
ourOwner->unmarkSlots();
|
ourOwner->unmarkSlots();
|
||||||
ourOwner->commonInfo->src.clear();
|
ourOwner->commonInfo->src.clear();
|
||||||
@ -5427,7 +5442,6 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact
|
|||||||
assert(commonInfo->dst == dst || dst.slot == dst.hero->artifactsInBackpack.size() + Arts::BACKPACK_START);
|
assert(commonInfo->dst == dst || dst.slot == dst.hero->artifactsInBackpack.size() + Arts::BACKPACK_START);
|
||||||
commonInfo->reset();
|
commonInfo->reset();
|
||||||
unmarkSlots();
|
unmarkSlots();
|
||||||
updateParentWindow();
|
|
||||||
}
|
}
|
||||||
else if(commonInfo->dst == src) //the dest artifact was moved -> we are picking it
|
else if(commonInfo->dst == src) //the dest artifact was moved -> we are picking it
|
||||||
{
|
{
|
||||||
@ -5456,7 +5470,6 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact
|
|||||||
assert(commonInfo->src.AOH);
|
assert(commonInfo->src.AOH);
|
||||||
CCS->curh->dragAndDropCursor(graphics->artDefs->ourImages[dst.getArt()->artType->id].bitmap);
|
CCS->curh->dragAndDropCursor(graphics->artDefs->ourImages[dst.getArt()->artType->id].bitmap);
|
||||||
markPossibleSlots(dst.getArt());
|
markPossibleSlots(dst.getArt());
|
||||||
updateParentWindow();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(src.slot >= Arts::BACKPACK_START &&
|
else if(src.slot >= Arts::BACKPACK_START &&
|
||||||
@ -5466,13 +5479,16 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact
|
|||||||
//int fixedSlot = src.hero->getArtPos(commonInfo->src.art);
|
//int fixedSlot = src.hero->getArtPos(commonInfo->src.art);
|
||||||
commonInfo->src.slotID--;
|
commonInfo->src.slotID--;
|
||||||
assert(commonInfo->src.valid());
|
assert(commonInfo->src.valid());
|
||||||
updateParentWindow();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tlog1 << "Unexpected artifact movement...\n";
|
//when moving one artifact onto another it leads to two art movements: dst->backapck; src->dst
|
||||||
|
// however after first movement we pick the art from backpack and the second movement coming when
|
||||||
|
// we have a different artifact may look surprising... but it's valid.
|
||||||
|
//tlog1 << "Unexpected artifact movement...\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateParentWindow();
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
// if(dst.slot >= Arts::BACKPACK_START && dst.slot - Arts::BACKPACK_START < backpackPos)
|
// if(dst.slot >= Arts::BACKPACK_START && dst.slot - Arts::BACKPACK_START < backpackPos)
|
||||||
// shift++;
|
// shift++;
|
||||||
|
@ -1045,6 +1045,11 @@ int CArtifactInstance::getGivenSpellID() const
|
|||||||
return b->subtype;
|
return b->subtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CArtifactInstance::isPart(const CArtifactInstance *supposedPart) const
|
||||||
|
{
|
||||||
|
return supposedPart == this;
|
||||||
|
}
|
||||||
|
|
||||||
bool CCombinedArtifactInstance::canBePutAt(const ArtifactLocation &al, bool assumeDestRemoved /*= false*/) const
|
bool CCombinedArtifactInstance::canBePutAt(const ArtifactLocation &al, bool assumeDestRemoved /*= false*/) const
|
||||||
{
|
{
|
||||||
bool canMainArtifactBePlaced = CArtifactInstance::canBePutAt(al, assumeDestRemoved);
|
bool canMainArtifactBePlaced = CArtifactInstance::canBePutAt(al, assumeDestRemoved);
|
||||||
@ -1057,6 +1062,14 @@ bool CCombinedArtifactInstance::canBePutAt(const ArtifactLocation &al, bool assu
|
|||||||
assert(artType->constituents);
|
assert(artType->constituents);
|
||||||
std::vector<ConstituentInfo> constituentsToBePlaced = constituentsInfo; //we'll remove constituents from that list, as we find a suitable slot for them
|
std::vector<ConstituentInfo> constituentsToBePlaced = constituentsInfo; //we'll remove constituents from that list, as we find a suitable slot for them
|
||||||
|
|
||||||
|
//it may be that we picked a combined artifact in hero screen (though technically it's still there) to move it
|
||||||
|
//so we remove from the list all constituents that are already present on dst hero in the form of locks
|
||||||
|
BOOST_FOREACH(const ConstituentInfo &constituent, constituentsInfo)
|
||||||
|
{
|
||||||
|
if(constituent.art == al.hero->getArt(constituent.slot, false)) //no need to worry about locked constituent
|
||||||
|
constituentsToBePlaced -= constituent;
|
||||||
|
}
|
||||||
|
|
||||||
//we iterate over all active slots and check if constituents fits them
|
//we iterate over all active slots and check if constituents fits them
|
||||||
for (int i = 0; i < Arts::BACKPACK_START; i++)
|
for (int i = 0; i < Arts::BACKPACK_START; i++)
|
||||||
{
|
{
|
||||||
@ -1191,12 +1204,31 @@ void CCombinedArtifactInstance::deserializationFix()
|
|||||||
attachTo(ci.art);
|
attachTo(ci.art);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CCombinedArtifactInstance::isPart(const CArtifactInstance *supposedPart) const
|
||||||
|
{
|
||||||
|
bool me = CArtifactInstance::isPart(supposedPart);
|
||||||
|
if(me)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//check for constituents
|
||||||
|
BOOST_FOREACH(const ConstituentInfo &constituent, constituentsInfo)
|
||||||
|
if(constituent.art == supposedPart)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
CCombinedArtifactInstance::ConstituentInfo::ConstituentInfo(CArtifactInstance *Art /*= NULL*/, ui16 Slot /*= -1*/)
|
CCombinedArtifactInstance::ConstituentInfo::ConstituentInfo(CArtifactInstance *Art /*= NULL*/, ui16 Slot /*= -1*/)
|
||||||
{
|
{
|
||||||
art = Art;
|
art = Art;
|
||||||
slot = Slot;
|
slot = Slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CCombinedArtifactInstance::ConstituentInfo::operator==(const ConstituentInfo &rhs) const
|
||||||
|
{
|
||||||
|
return art == rhs.art && slot == rhs.slot;
|
||||||
|
}
|
||||||
|
|
||||||
const CArtifactInstance* CArtifactSet::getArt(ui16 pos, bool excludeLocked /*= true*/) const
|
const CArtifactInstance* CArtifactSet::getArt(ui16 pos, bool excludeLocked /*= true*/) const
|
||||||
{
|
{
|
||||||
if(const ArtSlotInfo *si = getSlot(pos))
|
if(const ArtSlotInfo *si = getSlot(pos))
|
||||||
|
@ -79,6 +79,7 @@ public:
|
|||||||
virtual bool canBeDisassembled() const;
|
virtual bool canBeDisassembled() const;
|
||||||
virtual void putAt(CGHeroInstance *h, ui16 slot);
|
virtual void putAt(CGHeroInstance *h, ui16 slot);
|
||||||
virtual void removeFrom(CGHeroInstance *h, ui16 slot);
|
virtual void removeFrom(CGHeroInstance *h, ui16 slot);
|
||||||
|
virtual bool isPart(const CArtifactInstance *supposedPart) const; //checks if this a part of this artifact: artifact instance is a part of itself, additionally truth is returned for consituents of combined arts
|
||||||
|
|
||||||
std::vector<const CArtifact *> assemblyPossibilities(const CGHeroInstance *h) const;
|
std::vector<const CArtifact *> assemblyPossibilities(const CGHeroInstance *h) const;
|
||||||
void move(ArtifactLocation &src, ArtifactLocation &dst);
|
void move(ArtifactLocation &src, ArtifactLocation &dst);
|
||||||
@ -108,6 +109,7 @@ public:
|
|||||||
h & art & slot;
|
h & art & slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==(const ConstituentInfo &rhs) const;
|
||||||
ConstituentInfo(CArtifactInstance *art = NULL, ui16 slot = -1);
|
ConstituentInfo(CArtifactInstance *art = NULL, ui16 slot = -1);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -117,6 +119,7 @@ public:
|
|||||||
bool canBeDisassembled() const OVERRIDE;
|
bool canBeDisassembled() const OVERRIDE;
|
||||||
void putAt(CGHeroInstance *h, ui16 slot) OVERRIDE;
|
void putAt(CGHeroInstance *h, ui16 slot) OVERRIDE;
|
||||||
void removeFrom(CGHeroInstance *h, ui16 slot) OVERRIDE;
|
void removeFrom(CGHeroInstance *h, ui16 slot) OVERRIDE;
|
||||||
|
bool isPart(const CArtifactInstance *supposedPart) const OVERRIDE;
|
||||||
|
|
||||||
void createConstituents();
|
void createConstituents();
|
||||||
void addAsConstituent(CArtifactInstance *art, int slot);
|
void addAsConstituent(CArtifactInstance *art, int slot);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user