浏览代码

fix test & fix build & suggested changes

SoundSSGood 2 年之前
父节点
当前提交
7e6ab5e87b

+ 2 - 2
lib/CArtHandler.cpp

@@ -693,7 +693,7 @@ void CArtHandler::makeItCommanderArt(CArtifact * a, bool onlyCommander)
 		a->possibleSlots[ArtBearer::HERO].clear();
 		a->possibleSlots[ArtBearer::CREATURE].clear();
 	}
-	for(auto & slot : ArtifactUtils::commanderSlots())
+	for(const auto & slot : ArtifactUtils::commanderSlots())
 		a->possibleSlots[ArtBearer::COMMANDER].push_back(ArtifactPosition(slot));
 }
 
@@ -1080,7 +1080,7 @@ void CArtifactSet::serializeJsonArtifacts(JsonSerializeFormat & handler, const s
 
 void CArtifactSet::serializeJsonHero(JsonSerializeFormat & handler, CMap * map)
 {
-	for(auto & slot : ArtifactUtils::allWornSlots())
+	for(const auto & slot : ArtifactUtils::allWornSlots())
 	{
 		serializeJsonSlot(handler, slot, map);
 	}

+ 1 - 0
lib/CGameInfoCallback.cpp

@@ -16,6 +16,7 @@
 #include "gameState/TavernHeroesPool.h"
 #include "gameState/QuestInfo.h"
 #include "mapObjects/CGHeroInstance.h"
+#include "networkPacks/ArtifactLocation.h"
 #include "CGeneralTextHandler.h"
 #include "StartInfo.h" // for StartInfo
 #include "battle/BattleInfo.h" // for BattleInfo

+ 1 - 1
server/battles/BattleResultProcessor.cpp

@@ -396,7 +396,7 @@ void BattleResultProcessor::endBattleConfirm(const CBattleInfoCallback & battle)
 		for (auto armySlot : battle.battleGetArmyObject(loser)->stacks)
 		{
 			auto artifactsWorn = armySlot.second->artifactsWorn;
-			for(auto & artSlot : artifactsWorn)
+			for(const auto & artSlot : artifactsWorn)
 			{
 				MoveArtifact ma;
 				ma.src = ArtifactLocation(finishingBattle->loserHero->id, artSlot.first);

+ 0 - 14
server/queries/MapQueries.cpp

@@ -17,20 +17,6 @@
 #include "../../lib/networkPacks/PacksForServer.h"
 #include "../../lib/serializer/Cast.h"
 
-struct GetEngagedHeroIds
-{
-	std::optional<ObjectInstanceID> operator()(const ConstTransitivePtr<CGHeroInstance> & h) const
-	{
-		return h->id;
-	}
-	std::optional<ObjectInstanceID> operator()(const ConstTransitivePtr<CStackInstance> & s) const
-	{
-		if(s->armyObj && s->armyObj->ID == Obj::HERO)
-			return s->armyObj->id;
-		return std::optional<ObjectInstanceID>();
-	}
-};
-
 TimerPauseQuery::TimerPauseQuery(CGameHandler * owner, PlayerColor player):
 	CQuery(owner)
 {

+ 2 - 2
test/game/CGameStateTest.cpp

@@ -240,7 +240,7 @@ TEST_F(CGameStateTest, issue2765)
 		gameCallback->sendAndApply(&na);
 
 		PutArtifact pack;
-		pack.al = ArtifactLocation(defender, ArtifactPosition::MACH1);
+		pack.al = ArtifactLocation(defender->id, ArtifactPosition::MACH1);
 		pack.art = a;
 		gameCallback->sendAndApply(&pack);
 	}
@@ -334,7 +334,7 @@ TEST_F(CGameStateTest, battleResurrection)
 		gameCallback->sendAndApply(&na);
 
 		PutArtifact pack;
-		pack.al = ArtifactLocation(attacker, ArtifactPosition::SPELLBOOK);
+		pack.al = ArtifactLocation(attacker->id, ArtifactPosition::SPELLBOOK);
 		pack.art = a;
 		gameCallback->sendAndApply(&pack);
 	}