Jelajahi Sumber

Fix server shutdown on transferring artifact to commander

Ivan Savenko 2 tahun lalu
induk
melakukan
e188060480
1 mengubah file dengan 11 tambahan dan 3 penghapusan
  1. 11 3
      server/CGameHandler.cpp

+ 11 - 3
server/CGameHandler.cpp

@@ -3916,9 +3916,17 @@ bool CGameHandler::moveArtifact(const ArtifactLocation &al1, const ArtifactLocat
 		moveArtifact(dst, ArtifactLocation(dst.artHolder, ArtifactPosition(
 			(si32)dst.getHolderArtSet()->artifactsInBackpack.size() + GameConstants::BACKPACK_START)));
 	}
-	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);
+
+	try
+	{
+		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);
+	}
+	catch (boost::bad_get const &)
+	{
+		// object other than hero received an art - ignore
+	}
 
 	MoveArtifact ma(&src, &dst);
 	sendAndApply(&ma);