소스 검색

Fix SonarQube concerns

Tomasz Zieliński 1 주 전
부모
커밋
1a38c0df3c

+ 0 - 5
lib/rmg/CMapGenerator.cpp

@@ -83,11 +83,6 @@ void CMapGenerator::loadConfig()
 		config.questValues.push_back(i.Integer());
 	for(auto & i : randomMapJson["quests"]["rewardValue"].Vector())
 		config.questRewardValues.push_back(i.Integer());
-	//auto seerHutNode = randomMapJson["seerHutValue"];
-	if (seerHutNode.isNull())
-	// {
-	// 	logGlobal->error("Seer Hut value is not set in randomMap.json, using default value of 500");
-	// }
 	config.seerHutValue = randomMapJson["quests"]["seerHutValue"].Integer();
 	logGlobal->info("Seer Hut value: %d", config.seerHutValue);
 	config.pandoraMultiplierGold = randomMapJson["pandoras"]["valueMultiplierGold"].Integer();

+ 2 - 2
lib/rmg/modificators/QuestArtifactPlacer.cpp

@@ -92,7 +92,7 @@ CGObjectInstance * QuestArtifactPlacer::drawObjectToReplace(ui32 desiredValue)
 	for (auto it = artifactsToReplace.begin(); it != artifactsToReplace.end(); ++it)
 	{
 		const ui32 value = it->value;
-		auto diff = std::abs<int>((int)value - (int)desiredValue);
+		auto diff = std::abs(static_cast<int>(value) - static_cast<int>(desiredValue));
 		if (diff < bestDiff)
 		{
 			bestDiff = diff;
@@ -160,7 +160,7 @@ void QuestArtifactPlacer::placeQuestArtifacts(vstd::RNG & rand)
 }
 
 // TODO: Unused?
-void QuestArtifactPlacer::dropReplacedArtifact(CGObjectInstance* obj)
+void QuestArtifactPlacer::dropReplacedArtifact(const CGObjectInstance* obj)
 {
 	RecursiveLock lock(externalAccessMutex);
 	vstd::erase_if(artifactsToReplace, [obj](const ReplacementCandidate& candidate)

+ 1 - 1
lib/rmg/modificators/QuestArtifactPlacer.h

@@ -32,7 +32,7 @@ public:
 	CGObjectInstance * drawObjectToReplace(ui32 desiredValue);
 	std::vector<CGObjectInstance*> getPossibleArtifactsToReplace() const;
 	void placeQuestArtifacts(vstd::RNG & rand);
-	void dropReplacedArtifact(CGObjectInstance* obj);
+	void dropReplacedArtifact(const CGObjectInstance* obj);
 
 	size_t getMaxQuestArtifactCount() const;
 	[[nodiscard]] ArtifactID drawRandomArtifact();

+ 3 - 3
lib/rmg/modificators/TreasurePlacer.cpp

@@ -487,7 +487,7 @@ void TreasurePlacer::addSeerHuts()
 	//Seer huts with creatures or generic rewards
 
 	ObjectInfo oi(Obj::SEER_HUT, 0);
-	const ui32 seerHutPlacementValue = static_cast<ui32>(generator.getConfig().seerHutValue);
+	const auto seerHutPlacementValue = static_cast<ui32>(generator.getConfig().seerHutValue);
 
 	if(zone.getConnectedZoneIds().size()) //Unlikely, but...
 	{
@@ -539,7 +539,7 @@ void TreasurePlacer::addSeerHuts()
 			int randomAppearance = chooseRandomAppearance(zone.getRand(), Obj::SEER_HUT, zone.getTerrainType());
 			
 			// FIXME: Remove duplicated code for gold, exp and creaure reward
-			const ui32 rewardValue = static_cast<ui32>(((2 * (creature->getAIValue()) * creaturesAmount * (1 + static_cast<float>(map.getZoneCount(creature->getFactionID())) / map.getTotalZoneCount())) - 4000) / 3);
+			const auto rewardValue = static_cast<ui32>(((2 * (creature->getAIValue()) * creaturesAmount * (1 + static_cast<float>(map.getZoneCount(creature->getFactionID())) / map.getTotalZoneCount())) - 4000) / 3);
 
 			if (rewardValue > zone.getMaxTreasureValue())
 			{
@@ -572,7 +572,7 @@ void TreasurePlacer::addSeerHuts()
 			int randomAppearance = chooseRandomAppearance(zone.getRand(), Obj::SEER_HUT, zone.getTerrainType());
 			
 			oi.setTemplates(Obj::SEER_HUT, randomAppearance, zone.getTerrainType());
-			const ui32 rewardValue = static_cast<ui32>(generator.getConfig().questRewardValues[i]);
+			const auto rewardValue = static_cast<ui32>(generator.getConfig().questRewardValues[i]);
 			if (rewardValue > zone.getMaxTreasureValue())
 			{
 				continue;