2
0
Эх сурвалжийг харах

CGameHandler::moveArtifact: check lock status by slot instead of id

This one fix issue 2455. We still need to do something with ArtifactID::ART_LOCK or ids for artifact from mods since they might conflict with each other.
Arseniy Shestakov 9 жил өмнө
parent
commit
39fe9472b6

+ 1 - 1
AI/VCAI/VCAI.cpp

@@ -1086,8 +1086,8 @@ void VCAI::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance * ot
 							if (compareArtifacts(artifact, otherSlot->artifact) && artifact->canBePutAt(destLocation, true)) //combined artifacts are not always allowed to move
 							if (compareArtifacts(artifact, otherSlot->artifact) && artifact->canBePutAt(destLocation, true)) //combined artifacts are not always allowed to move
 							{
 							{
 								cb->swapArtifacts(location, ArtifactLocation(target, target->getArtPos(otherSlot->artifact)));
 								cb->swapArtifacts(location, ArtifactLocation(target, target->getArtPos(otherSlot->artifact)));
-								break;
 								changeMade = true;
 								changeMade = true;
+								break;
 							}
 							}
 						}
 						}
 					}
 					}

+ 1 - 1
lib/GameConstants.h

@@ -942,7 +942,7 @@ public:
 		//CORNUCOPIA = 140,
 		//CORNUCOPIA = 140,
 		//FIXME: the following is only true if WoG is enabled. Otherwise other mod artifacts will take these slots.
 		//FIXME: the following is only true if WoG is enabled. Otherwise other mod artifacts will take these slots.
 		ART_SELECTION = 144,
 		ART_SELECTION = 144,
-		ART_LOCK = 145,
+		ART_LOCK = 145, // FIXME: We must get rid of this one since it's conflict with artifact from mods. See issue 2455
 		AXE_OF_SMASHING = 146,
 		AXE_OF_SMASHING = 146,
 		MITHRIL_MAIL = 147,
 		MITHRIL_MAIL = 147,
 		SWORD_OF_SHARPNESS = 148,
 		SWORD_OF_SHARPNESS = 148,

+ 4 - 1
server/CGameHandler.cpp

@@ -3193,7 +3193,10 @@ bool CGameHandler::moveArtifact(const ArtifactLocation &al1, const ArtifactLocat
 		&& srcArtifact && !srcArtifact->canBePutAt(dst, true))
 		&& srcArtifact && !srcArtifact->canBePutAt(dst, true))
 		COMPLAIN_RET("Cannot move artifact!");
 		COMPLAIN_RET("Cannot move artifact!");
 
 
-	if ((srcArtifact && srcArtifact->artType->id == ArtifactID::ART_LOCK) || (destArtifact && destArtifact->artType->id == ArtifactID::ART_LOCK))
+	auto srcSlot = src.getSlot();
+	auto dstSlot = dst.getSlot();
+
+	if ((srcSlot && srcSlot->locked) || (dstSlot && dstSlot->locked))
 		COMPLAIN_RET("Cannot move artifact locks.");
 		COMPLAIN_RET("Cannot move artifact locks.");
 
 
 	if (dst.slot >= GameConstants::BACKPACK_START && srcArtifact->artType->isBig())
 	if (dst.slot >= GameConstants::BACKPACK_START && srcArtifact->artType->isBig())