浏览代码

* Fixed duplication issue when transferring artifact to backpack. Really should be no bugs left now for the artifact screens.
* Tweaked artifact assembly to behave a bit more like H3; right-clicked artifact becomes the assembled one if it's in the right spot.
* Fixed so the backpack won't scroll when selecting the last artifact in the backpack.

OnionKnight 15 年之前
父节点
当前提交
dc2a0730e6
共有 2 个文件被更改,包括 37 次插入14 次删除
  1. 6 6
      client/GUIClasses.cpp
  2. 31 8
      server/CGameHandler.cpp

+ 6 - 6
client/GUIClasses.cpp

@@ -3745,6 +3745,8 @@ void CArtPlace::select ()
 	if (locked())
 		return;
 
+	int backpackCorrection = -(slotID - 19 < ourOwner->backpackPos);
+
 	CGI->curh->dragAndDropCursor(graphics->artDefs->ourImages[ourArt->id].bitmap);
 
 	ourOwner->commonInfo->srcArtifact = ourArt;
@@ -3781,16 +3783,14 @@ void CArtPlace::select ()
 		cew->activate();
 	}
 
-	if (slotID >= 19) {
-		// Correcting position in backpack.
-		ourOwner->scrollBackpack(-(slotID - 19 < ourOwner->backpackPos));
-	} else {
+	if (slotID >= 19)
+		ourOwner->scrollBackpack(backpackCorrection);
+	else
 		ourOwner->eraseSlotData(this, slotID);
-	}
 }
 
 /**
- * Deselects the artifact slot.
+ * Deselects the artifact slot. FIXME: Not used. Maybe it should?
  */
 void CArtPlace::deselect ()
 {

+ 31 - 8
server/CGameHandler.cpp

@@ -2625,7 +2625,7 @@ bool CGameHandler::swapArtifacts(si32 srcHeroID, si32 destHeroID, ui16 srcSlot,
 	// If dest does not fit in src, put it in dest's backpack instead.
 	if (srcHeroID == destHeroID) // To avoid stumbling on own locks, remove artifact first.
 		sha.setArtAtPos(destSlot, -1);
-	bool destFits = !destArtifact || srcSlot >= 19 || destArtifact->fitsAt(sha.artifWorn, srcSlot);
+	bool destFits = !destArtifact || srcSlot >= 19 || destSlot >= 19 || destArtifact->fitsAt(sha.artifWorn, srcSlot);
 	if (srcHeroID == destHeroID && destArtifact)
 		sha.setArtAtPos(destSlot, destArtifact->id);
 
@@ -2697,19 +2697,41 @@ bool CGameHandler::assembleArtifacts (si32 heroID, ui16 artifactSlot, bool assem
 			return false;
 		}
 
+		// Perform assembly.
 		bool destConsumed = false; // Determines which constituent that will be counted for together with the artifact.
+		const bool destSpecific = vstd::contains(artifact.possibleSlots, artifactSlot); // Prefer the chosen slot as the location for the assembled artifact.
+
 		BOOST_FOREACH(ui32 constituentID, *artifact.constituents) {
+			if (destSpecific && constituentID == destArtifact->id) {
+				sha.artifWorn[artifactSlot] = assembleTo;
+				destConsumed = true;
+				continue;
+			}
+
 			bool found = false;
 			for (std::map<ui16, ui32>::iterator it = sha.artifWorn.begin(); it != sha.artifWorn.end(); ++it) {
-				if (it->second == constituentID) {
-					if (!destConsumed && vstd::contains(artifact.possibleSlots, it->first)) {
-						it->second = assembleTo;
-						destConsumed = true;
+				if (it->second == constituentID) { // Found possible constituent to substitute.
+					if (destSpecific && !destConsumed && it->second == destArtifact->id) {
+						// Find the specified destination for assembled artifact.
+						if (it->first == artifactSlot) {
+							it->second = assembleTo;
+							destConsumed = true;
+
+							found = true;
+							break;
+						}
 					} else {
-						it->second = 145;
+						// Either put the assembled artifact in a fitting spot, or put a lock.
+						if (!destSpecific && !destConsumed && vstd::contains(artifact.possibleSlots, it->first)) {
+							it->second = assembleTo;
+							destConsumed = true;
+						} else {
+							it->second = 145;
+						}
+
+						found = true;
+						break;
 					}
-					found = true;
-					break;
 				}
 			}
 			if (!found) {
@@ -2718,6 +2740,7 @@ bool CGameHandler::assembleArtifacts (si32 heroID, ui16 artifactSlot, bool assem
 			}
 		}
 	} else {
+		// Perform disassembly.
 		bool destConsumed = false; // Determines which constituent that will be counted for together with the artifact.
 		BOOST_FOREACH(ui32 constituentID, *destArtifact->constituents) {
 			const CArtifact &constituent = VLC->arth->artifacts[constituentID];