瀏覽代碼

The last set of fixes for non-combined artifacts operations.

Michał W. Urbańczyk 14 年之前
父節點
當前提交
502bb5392e
共有 4 個文件被更改,包括 16 次插入7 次删除
  1. 7 4
      client/GUIClasses.cpp
  2. 6 0
      lib/CArtHandler.cpp
  3. 1 0
      lib/CArtHandler.h
  4. 2 3
      lib/NetPacksLib.cpp

+ 7 - 4
client/GUIClasses.cpp

@@ -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

+ 6 - 0
lib/CArtHandler.cpp

@@ -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);

+ 1 - 0
lib/CArtHandler.h

@@ -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)
 	{

+ 2 - 3
lib/NetPacksLib.cpp

@@ -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 )