mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-25 21:38:59 +02:00
The last set of fixes for non-combined artifacts operations.
This commit is contained in:
parent
7b0188a941
commit
502bb5392e
@ -4583,7 +4583,7 @@ void CArtPlace::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(inBackpack) // Backpack destination.
|
||||
{
|
||||
if(slotID == ourOwner->commonInfo->src.slotID + 1) //next slot (our is not visible, so visually same as "old" place) to the art -> make nothing, return artifact to slot
|
||||
if(srcInBackpack && slotID == ourOwner->commonInfo->src.slotID + 1) //next slot (our is not visible, so visually same as "old" place) to the art -> make nothing, return artifact to slot
|
||||
{
|
||||
deselect();
|
||||
}
|
||||
@ -4603,9 +4603,12 @@ void CArtPlace::clickLeft(tribool down, bool previousState)
|
||||
default:
|
||||
setMeAsDest();
|
||||
amin(ourOwner->commonInfo->dst.slotID, ourOwner->curHero->artifactsInBackpack.size() + Arts::BACKPACK_START);
|
||||
if(!ourArt && srcInBackpack && srcInSameHero) //cannot move from backpack to AFTER backpack
|
||||
ourOwner->commonInfo->dst.slotID--; //combined with amin above it will guarantee that dest is at most the last artifact
|
||||
|
||||
if(srcInBackpack && srcInSameHero)
|
||||
{
|
||||
if(!ourArt //cannot move from backpack to AFTER backpack -> combined with amin above it will guarantee that dest is at most the last artifact
|
||||
|| ourOwner->commonInfo->src.slotID < ourOwner->commonInfo->dst.slotID) //rearranging arts in backpack after taking src artifact, the dest id will be shifted
|
||||
ourOwner->commonInfo->dst.slotID--;
|
||||
}
|
||||
if(srcInSameHero && ourOwner->commonInfo->dst.slotID == ourOwner->commonInfo->src.slotID) //we came to src == dst
|
||||
deselect();
|
||||
else
|
||||
|
@ -1001,6 +1001,12 @@ std::vector<const CArtifact *> CArtifactInstance::assemblyPossibilities(const CG
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CArtifactInstance::move(ArtifactLocation &src, ArtifactLocation &dst)
|
||||
{
|
||||
removeFrom(src.hero, src.slot);
|
||||
putAt(dst.hero, dst.slot);
|
||||
}
|
||||
|
||||
bool CCombinedArtifactInstance::canBePutAt(const ArtifactLocation &al, bool assumeDestRemoved /*= false*/) const
|
||||
{
|
||||
return CArtifactInstance::canBePutAt(al, assumeDestRemoved);
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
|
||||
void putAt(CGHeroInstance *h, ui16 slot);
|
||||
void removeFrom(CGHeroInstance *h, ui16 slot);
|
||||
void move(ArtifactLocation &src, ArtifactLocation &dst);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
|
@ -716,9 +716,8 @@ DLL_EXPORT void MoveArtifact::applyGs( CGameState *gs )
|
||||
CArtifactInstance *a = src.getArt();
|
||||
if(dst.slot < Arts::BACKPACK_START)
|
||||
assert(!dst.getArt());
|
||||
|
||||
a->removeFrom(src.hero, src.slot);
|
||||
a->putAt(dst.hero, dst.slot);
|
||||
|
||||
a->move(src, dst);
|
||||
}
|
||||
|
||||
DLL_EXPORT void SetAvailableArtifacts::applyGs( CGameState *gs )
|
||||
|
Loading…
x
Reference in New Issue
Block a user