浏览代码

Fix discovered bugs from develop branch

Ivan Savenko 5 月之前
父节点
当前提交
04c9e27ccd
共有 3 个文件被更改,包括 8 次插入5 次删除
  1. 3 3
      AI/Nullkiller/AIGateway.cpp
  2. 3 0
      lib/bonuses/Updaters.cpp
  3. 2 2
      server/CGameHandler.cpp

+ 3 - 3
AI/Nullkiller/AIGateway.cpp

@@ -1039,7 +1039,7 @@ void AIGateway::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance
 	auto equipBest = [](const CGHeroInstance * h, const CGHeroInstance * otherh, bool giveStuffToFirstHero) -> void
 	{
 		bool changeMade = false;
-		std::set<std::pair<CArtifactInstance *, CArtifactInstance *> > swappedSet;
+		std::set<std::pair<ArtifactInstanceID, ArtifactInstanceID> > swappedSet;
 		do
 		{
 			changeMade = false;
@@ -1120,13 +1120,13 @@ void AIGateway::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance
 							//combined artifacts are not always allowed to move
 							if(artifactScore > otherArtifactScore && artifact->canBePutAt(target, slot, true))
 							{
-								auto swapPair = std::minmax(artifact, otherSlot->artifact);
+								std::pair swapPair = std::minmax<ArtifactInstanceID>({artifact->getId(), otherSlot->artifactID});
 								if (swappedSet.find(swapPair) != swappedSet.end())
 								{
 									logAi->warn(
 										"Artifacts % s < -> % s have already swapped before, ignored.",
 										artifact->getType()->getJsonKey(),
-										otherSlot->artifact->getType()->getJsonKey());
+										otherSlot->getArt()->getType()->getJsonKey());
 									continue;
 								}
 								logAi->trace(

+ 3 - 0
lib/bonuses/Updaters.cpp

@@ -171,6 +171,9 @@ JsonNode TimesStackLevelUpdater::toJsonNode() const
 
 std::shared_ptr<Bonus> DivideStackLevelUpdater::apply(const std::shared_ptr<Bonus> & b, int level) const
 {
+	if (level == 0)
+		return b; // e.g. war machines & other special units
+
 	auto newBonus = std::make_shared<Bonus>(*b);
 	newBonus->val /= level;
 	newBonus->updater = nullptr; // prevent double-apply

+ 2 - 2
server/CGameHandler.cpp

@@ -1492,8 +1492,8 @@ void CGameHandler::throwNotAllowedAction(const std::shared_ptr<CConnection> & co
 void CGameHandler::wrongPlayerMessage(const std::shared_ptr<CConnection> & connection, const CPackForServer * pack, PlayerColor expectedplayer)
 {
 	auto str = MetaString::createFromTextID("vcmi.server.errors.wrongIdentified");
-	str.appendName(pack->player);
-	str.appendName(expectedplayer);
+	str.replaceName(pack->player);
+	str.replaceName(expectedplayer);
 	logNetwork->error(str.toString());
 
 	playerMessages->sendSystemMessage(connection, str);