diff --git a/AI/Nullkiller/Engine/PriorityEvaluator.cpp b/AI/Nullkiller/Engine/PriorityEvaluator.cpp index 1a081de8c..77411dac6 100644 --- a/AI/Nullkiller/Engine/PriorityEvaluator.cpp +++ b/AI/Nullkiller/Engine/PriorityEvaluator.cpp @@ -236,7 +236,7 @@ int getDwellingArmyCost(const CGObjectInstance * target) return cost; } -uint64_t evaluateArtifactArmyValue(CArtifactInstance * art) +static uint64_t evaluateArtifactArmyValue(const CArtifactInstance * art) { if(art->artType->getId() == ArtifactID::SPELL_SCROLL) return 1500; diff --git a/AI/Nullkiller/Pathfinding/Actors.cpp b/AI/Nullkiller/Pathfinding/Actors.cpp index b3f186ce5..900d65506 100644 --- a/AI/Nullkiller/Pathfinding/Actors.cpp +++ b/AI/Nullkiller/Pathfinding/Actors.cpp @@ -373,7 +373,7 @@ HeroExchangeArmy * HeroExchangeMap::tryUpgrade( for(auto & creatureToBuy : buyArmy) { - auto targetSlot = target->getSlotFor(dynamic_cast(creatureToBuy.creID.toCreature())); + auto targetSlot = target->getSlotFor(creatureToBuy.creID.toCreature()); target->addToSlot(targetSlot, creatureToBuy.creID, creatureToBuy.count); target->armyCost += creatureToBuy.creID.toCreature()->getFullRecruitCost() * creatureToBuy.count; diff --git a/client/CGameInfo.cpp b/client/CGameInfo.cpp index f57b093a3..bcc0cfc8e 100644 --- a/client/CGameInfo.cpp +++ b/client/CGameInfo.cpp @@ -12,7 +12,7 @@ #include "../lib/VCMI_Lib.h" -const CGameInfo * CGI; +CGameInfo * CGI; CClientState * CCS = nullptr; CServerHandler * CSH; diff --git a/client/CGameInfo.h b/client/CGameInfo.h index 11f1f8111..c07bb3c7d 100644 --- a/client/CGameInfo.h +++ b/client/CGameInfo.h @@ -99,4 +99,4 @@ public: private: const Services * globalServices; }; -extern const CGameInfo* CGI; +extern CGameInfo* CGI; diff --git a/client/CMT.cpp b/client/CMT.cpp index 4e47b70f6..e3b6780f9 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -72,7 +72,7 @@ void init() CStopWatch tmh; loadDLLClasses(); - const_cast(CGI)->setFromLib(); + CGI->setFromLib(); logGlobal->info("Initializing VCMI_Lib: %d ms", tmh.getDiff()); diff --git a/client/Client.cpp b/client/Client.cpp index f1edcf38d..10c2b64e9 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -367,7 +367,7 @@ void CClient::endGame() logNetwork->info("Ending current game!"); removeGUI(); - const_cast(CGI)->mh.reset(); + CGI->mh.reset(); vstd::clear_pointer(gs); logNetwork->info("Deleted mapHandler and gameState."); @@ -389,7 +389,7 @@ void CClient::initMapHandler() // During loading CPlayerInterface from serialized state it's depend on MH if(!settings["session"]["headless"].Bool()) { - const_cast(CGI)->mh = std::make_shared(gs->map); + CGI->mh = std::make_shared(gs->map); logNetwork->trace("Creating mapHandler: %d ms", CSH->th->getDiff()); } diff --git a/lib/CHeroHandler.cpp b/lib/CHeroHandler.cpp index 0fc7b587d..d90ce3fa0 100644 --- a/lib/CHeroHandler.cpp +++ b/lib/CHeroHandler.cpp @@ -155,9 +155,9 @@ bool CHeroClass::isMagicHero() const return affinity == MAGIC; } -int CHeroClass::tavernProbability(FactionID faction) const +int CHeroClass::tavernProbability(FactionID targetFaction) const { - auto it = selectionProbability.find(faction); + auto it = selectionProbability.find(targetFaction); if (it != selectionProbability.end()) return it->second; return 0; diff --git a/lib/JsonRandom.cpp b/lib/JsonRandom.cpp index 7a35d7bb7..39a639fef 100644 --- a/lib/JsonRandom.cpp +++ b/lib/JsonRandom.cpp @@ -31,7 +31,7 @@ VCMI_LIB_NAMESPACE_BEGIN - si32 JsonRandom::loadVariable(std::string variableGroup, const std::string & value, const Variables & variables, si32 defaultValue) + si32 JsonRandom::loadVariable(const std::string & variableGroup, const std::string & value, const Variables & variables, si32 defaultValue) { if (value.empty() || value[0] != '@') { @@ -54,7 +54,7 @@ VCMI_LIB_NAMESPACE_BEGIN if(value.isNull()) return defaultValue; if(value.isNumber()) - return static_cast(value.Float()); + return value.Integer(); if (value.isString()) return loadVariable("number", value.String(), variables, defaultValue); @@ -68,9 +68,9 @@ VCMI_LIB_NAMESPACE_BEGIN if(value.isStruct()) { if (!value["amount"].isNull()) - return static_cast(loadValue(value["amount"], rng, variables, defaultValue)); - si32 min = static_cast(loadValue(value["min"], rng, variables, 0)); - si32 max = static_cast(loadValue(value["max"], rng, variables, 0)); + return loadValue(value["amount"], rng, variables, defaultValue); + si32 min = loadValue(value["min"], rng, variables, 0); + si32 max = loadValue(value["max"], rng, variables, 0); return rng.getIntRange(min, max)(); } return defaultValue; diff --git a/lib/JsonRandom.h b/lib/JsonRandom.h index 613350941..79ab292ce 100644 --- a/lib/JsonRandom.h +++ b/lib/JsonRandom.h @@ -41,7 +41,7 @@ private: template IdentifierType decodeKey(const JsonNode & value, const Variables & variables); - si32 loadVariable(std::string variableGroup, const std::string & value, const Variables & variables, si32 defaultValue); + si32 loadVariable(const std::string & variableGroup, const std::string & value, const Variables & variables, si32 defaultValue); public: using GameCallbackHolder::GameCallbackHolder; diff --git a/lib/bonuses/CBonusSystemNode.cpp b/lib/bonuses/CBonusSystemNode.cpp index f8f45cbbd..3cedf4408 100644 --- a/lib/bonuses/CBonusSystemNode.cpp +++ b/lib/bonuses/CBonusSystemNode.cpp @@ -486,7 +486,7 @@ void CBonusSystemNode::getRedParents(TCNodes & out) const if(!actsAsBonusSourceOnly()) { - for(CBonusSystemNode *child : children) + for(const CBonusSystemNode *child : children) { out.insert(child); } diff --git a/lib/gameState/CGameState.cpp b/lib/gameState/CGameState.cpp index 1d1a10aa9..6987dd802 100644 --- a/lib/gameState/CGameState.cpp +++ b/lib/gameState/CGameState.cpp @@ -171,10 +171,10 @@ CGameState::~CGameState() initialOpts.dellNull(); } -void CGameState::preInit(Services * services, IGameCallback * callback) +void CGameState::preInit(Services * newServices, IGameCallback * newCallback) { - this->services = services; - this->callback = callback; + services = newServices; + callback = newCallback; } void CGameState::init(const IMapService * mapService, StartInfo * si, Load::ProgressAccumulator & progressTracking, bool allowSavingRandomMap) @@ -631,7 +631,7 @@ void CGameState::initHeroes() if (tile.terType->isWater()) { auto handler = VLC->objtypeh->getHandlerFor(Obj::BOAT, hero->getBoatType().getNum()); - CGBoat * boat = dynamic_cast(handler->create(callback, nullptr)); + auto boat = dynamic_cast(handler->create(callback, nullptr)); handler->configureObject(boat, gs->getRandomGenerator()); boat->pos = hero->pos; diff --git a/server/processors/HeroPoolProcessor.cpp b/server/processors/HeroPoolProcessor.cpp index 54612dce2..cef39cf07 100644 --- a/server/processors/HeroPoolProcessor.cpp +++ b/server/processors/HeroPoolProcessor.cpp @@ -247,7 +247,7 @@ std::vector HeroPoolProcessor::findAvailableClassesFor(const const auto & heroesPool = gameHandler->gameState()->heroesPool; FactionID factionID = gameHandler->getPlayerSettings(player)->castle; - for(auto & elem : heroesPool->unusedHeroesFromPool()) + for(const auto & elem : heroesPool->unusedHeroesFromPool()) { if (vstd::contains(result, elem.second->type->heroClass)) continue; @@ -268,7 +268,7 @@ std::vector HeroPoolProcessor::findAvailableHeroesFor(const Pl const auto & heroesPool = gameHandler->gameState()->heroesPool; - for(auto & elem : heroesPool->unusedHeroesFromPool()) + for(const auto & elem : heroesPool->unusedHeroesFromPool()) { assert(!vstd::contains(result, elem.second));