فهرست منبع

Regressions fixed

SoundSSGood 2 سال پیش
والد
کامیت
4005b48360
5فایلهای تغییر یافته به همراه63 افزوده شده و 23 حذف شده
  1. 29 3
      client/widgets/CArtifactHolder.cpp
  2. 0 2
      client/windows/GUIClasses.cpp
  3. 17 4
      lib/CArtHandler.cpp
  4. 1 1
      lib/CArtHandler.h
  5. 16 13
      server/CGameHandler.cpp

+ 29 - 3
client/widgets/CArtifactHolder.cpp

@@ -670,6 +670,16 @@ CArtifactsOfHero::CArtifactsOfHero(const Point & position, bool createCommonPart
 CArtifactsOfHero::~CArtifactsOfHero()
 CArtifactsOfHero::~CArtifactsOfHero()
 {
 {
 	dispose();
 	dispose();
+	// Artifact located in artifactsTransitionPos should be returned
+	if(!curHero->artifactsTransitionPos.empty())
+	{
+		auto artPlace = getArtPlace(
+			ArtifactUtils::getArtifactDstPosition(curHero->artifactsTransitionPos.begin()->artifact, curHero, curHero->bearerType()));
+		assert(artPlace);
+		assert(artPlace->ourOwner);
+		artPlace->setMeAsDest();
+		artPlace->ourOwner->realizeCurrentTransaction();
+	}
 }
 }
 
 
 void CArtifactsOfHero::updateParentWindow()
 void CArtifactsOfHero::updateParentWindow()
@@ -735,8 +745,21 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation & src, const Artifac
 	// however after first movement we pick the art from TRANSITION_POS and the second movement coming when
 	// however after first movement we pick the art from TRANSITION_POS and the second movement coming when
 	// we have a different artifact may look surprising... but it's valid.
 	// we have a different artifact may look surprising... but it's valid.
 
 
+	// Used when doing dragAndDrop and artifact swap multiple times
+	if(src.slot == ArtifactPosition::TRANSITION_POS && 
+		commonInfo->src.slotID == ArtifactPosition::TRANSITION_POS &&
+		commonInfo->dst.slotID == ArtifactPosition::PRE_FIRST)
+	{
+		auto art = curHero->getArt(ArtifactPosition::TRANSITION_POS);
+		assert(art);
+		CCS->curh->dragAndDropCursor(make_unique<CAnimImage>("artifact", art->artType->getIconIndex()));
+		markPossibleSlots(art);
+
+		commonInfo->src.art = art;
+		commonInfo->src.slotID = src.slot;
+	}
 	// Artifact was taken from us
 	// Artifact was taken from us
-	if(commonInfo->src == src)
+	else if(commonInfo->src == src)
 	{
 	{
 		// Expected movement from slot ot slot
 		// Expected movement from slot ot slot
 		assert(commonInfo->dst == dst
 		assert(commonInfo->dst == dst
@@ -746,13 +769,12 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation & src, const Artifac
 		commonInfo->reset();
 		commonInfo->reset();
 		unmarkSlots();
 		unmarkSlots();
 	}
 	}
-	// The dest artifact was moved -> we are picking it
+	// The dest artifact was moved after the swap -> we are picking it
 	else if(commonInfo->dst == src)
 	else if(commonInfo->dst == src)
 	{
 	{
 		assert(dst.slot == ArtifactPosition::TRANSITION_POS);
 		assert(dst.slot == ArtifactPosition::TRANSITION_POS);
 		commonInfo->reset();
 		commonInfo->reset();
 
 
-		CArtifactsOfHero::ArtPlacePtr ap;
 		for(CArtifactsOfHero * aoh : commonInfo->participants)
 		for(CArtifactsOfHero * aoh : commonInfo->participants)
 		{
 		{
 			if(dst.isHolder(aoh->curHero))
 			if(dst.isHolder(aoh->curHero))
@@ -795,6 +817,10 @@ void CArtifactsOfHero::artifactRemoved(const ArtifactLocation &al)
 
 
 CArtifactsOfHero::ArtPlacePtr CArtifactsOfHero::getArtPlace(int slot)
 CArtifactsOfHero::ArtPlacePtr CArtifactsOfHero::getArtPlace(int slot)
 {
 {
+	if(slot == ArtifactPosition::TRANSITION_POS)
+	{
+		return nullptr;
+	}
 	if(slot < GameConstants::BACKPACK_START)
 	if(slot < GameConstants::BACKPACK_START)
 	{
 	{
 		if(artWorn.find(ArtifactPosition(slot)) == artWorn.end())
 		if(artWorn.find(ArtifactPosition(slot)) == artWorn.end())

+ 0 - 2
client/windows/GUIClasses.cpp

@@ -1249,8 +1249,6 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
 
 
 CExchangeWindow::~CExchangeWindow()
 CExchangeWindow::~CExchangeWindow()
 {
 {
-	artifs[0]->commonInfo = nullptr;
-	artifs[1]->commonInfo = nullptr;
 }
 }
 
 
 const CGarrisonSlot * CExchangeWindow::getSelectedSlotID() const
 const CGarrisonSlot * CExchangeWindow::getSelectedSlotID() const

+ 17 - 4
lib/CArtHandler.cpp

@@ -864,7 +864,7 @@ void CArtifactInstance::removeFrom(ArtifactLocation al)
 {
 {
 	assert(al.getHolderArtSet()->getArt(al.slot) == this);
 	assert(al.getHolderArtSet()->getArt(al.slot) == this);
 	al.getHolderArtSet()->eraseArtSlot(al.slot);
 	al.getHolderArtSet()->eraseArtSlot(al.slot);
-	if(!ArtifactUtils::isSlotBackpack(al.slot))
+	if(!ArtifactUtils::isSlotBackpack(al.slot) && (al.slot != ArtifactPosition::TRANSITION_POS))
 		al.getHolderNode()->detachFrom(*this);
 		al.getHolderNode()->detachFrom(*this);
 }
 }
 
 
@@ -1335,7 +1335,11 @@ const CCombinedArtifactInstance *CArtifactSet::getAssemblyByConstituent(Artifact
 const ArtSlotInfo * CArtifactSet::getSlot(ArtifactPosition pos) const
 const ArtSlotInfo * CArtifactSet::getSlot(ArtifactPosition pos) const
 {
 {
 	if(pos == ArtifactPosition::TRANSITION_POS)
 	if(pos == ArtifactPosition::TRANSITION_POS)
-		return &artifactTransitionPos;
+	{
+		// Always add to the end. Always take from the beginning.
+		assert(!artifactsTransitionPos.empty());
+		return &(*artifactsTransitionPos.begin());
+	}
 	if(vstd::contains(artifactsWorn, pos))
 	if(vstd::contains(artifactsWorn, pos))
 		return &artifactsWorn.at(pos);
 		return &artifactsWorn.at(pos);
 	if(pos >= ArtifactPosition::AFTER_LAST )
 	if(pos >= ArtifactPosition::AFTER_LAST )
@@ -1363,7 +1367,11 @@ ArtSlotInfo & CArtifactSet::retrieveNewArtSlot(ArtifactPosition slot)
 	assert(!vstd::contains(artifactsWorn, slot));
 	assert(!vstd::contains(artifactsWorn, slot));
 
 
 	if(slot == ArtifactPosition::TRANSITION_POS)
 	if(slot == ArtifactPosition::TRANSITION_POS)
-		return artifactTransitionPos;
+	{
+		// Always add to the end. Always take from the beginning.
+		artifactsTransitionPos.push_back(ArtSlotInfo());
+		return artifactsTransitionPos.back();
+	}
 	if(!ArtifactUtils::isSlotBackpack(slot))
 	if(!ArtifactUtils::isSlotBackpack(slot))
 		return artifactsWorn[slot];
 		return artifactsWorn[slot];
 
 
@@ -1384,7 +1392,12 @@ void CArtifactSet::setNewArtSlot(ArtifactPosition slot, CArtifactInstance *art,
 
 
 void CArtifactSet::eraseArtSlot(ArtifactPosition slot)
 void CArtifactSet::eraseArtSlot(ArtifactPosition slot)
 {
 {
-	if(ArtifactUtils::isSlotBackpack(slot))
+	if(slot == ArtifactPosition::TRANSITION_POS)
+	{
+		assert(!artifactsTransitionPos.empty());
+		artifactsTransitionPos.erase(artifactsTransitionPos.begin());
+	}
+	else if(ArtifactUtils::isSlotBackpack(slot))
 	{
 	{
 		auto backpackSlot = ArtifactPosition(slot - GameConstants::BACKPACK_START);
 		auto backpackSlot = ArtifactPosition(slot - GameConstants::BACKPACK_START);
 
 

+ 1 - 1
lib/CArtHandler.h

@@ -317,7 +317,7 @@ class DLL_LINKAGE CArtifactSet
 public:
 public:
 	std::vector<ArtSlotInfo> artifactsInBackpack; //hero's artifacts from bag
 	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
 	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
+	std::vector<ArtSlotInfo> artifactsTransitionPos; // Used as transition position for dragAndDrop artifact exchange
 
 
 	ArtSlotInfo & retrieveNewArtSlot(ArtifactPosition slot);
 	ArtSlotInfo & retrieveNewArtSlot(ArtifactPosition slot);
 	void setNewArtSlot(ArtifactPosition slot, CArtifactInstance *art, bool locked);
 	void setNewArtSlot(ArtifactPosition slot, CArtifactInstance *art, bool locked);

+ 16 - 13
server/CGameHandler.cpp

@@ -3910,21 +3910,24 @@ bool CGameHandler::moveArtifact(const ArtifactLocation &al1, const ArtifactLocat
 	if(ArtifactUtils::isSlotBackpack(dst.slot))
 	if(ArtifactUtils::isSlotBackpack(dst.slot))
 		vstd::amin(dst.slot, ArtifactPosition(GameConstants::BACKPACK_START + (si32)dst.getHolderArtSet()->artifactsInBackpack.size()));
 		vstd::amin(dst.slot, ArtifactPosition(GameConstants::BACKPACK_START + (si32)dst.getHolderArtSet()->artifactsInBackpack.size()));
 
 
-	if(src.slot == dst.slot  &&  src.artHolder == dst.artHolder)
-		COMPLAIN_RET("Won't move artifact: Dest same as source!");
-
-	// Check if dst slot is occupied
-	if(!ArtifactUtils::isSlotBackpack(dst.slot) && destArtifact)
+	if(!(src.slot == ArtifactPosition::TRANSITION_POS && dst.slot == ArtifactPosition::TRANSITION_POS))
 	{
 	{
-		// 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))
-		giveHeroNewArtifact(hero, VLC->arth->objects[ArtifactID::SPELLBOOK], ArtifactPosition::SPELLBOOK);
+		if(src.slot == dst.slot && src.artHolder == dst.artHolder)
+			COMPLAIN_RET("Won't move artifact: Dest same as source!");
 
 
-	MoveArtifact ma(&src, &dst);
-	sendAndApply(&ma);
+		// Check if dst slot is occupied
+		if(!ArtifactUtils::isSlotBackpack(dst.slot) && destArtifact)
+		{
+			// 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))
+			giveHeroNewArtifact(hero, VLC->arth->objects[ArtifactID::SPELLBOOK], ArtifactPosition::SPELLBOOK);
+
+		MoveArtifact ma(&src, &dst);
+		sendAndApply(&ma);
+	}
 	return true;
 	return true;
 }
 }