diff --git a/AI/Nullkiller/Analyzers/ArmyManager.cpp b/AI/Nullkiller/Analyzers/ArmyManager.cpp index fef7fcce6..48e2f3169 100644 --- a/AI/Nullkiller/Analyzers/ArmyManager.cpp +++ b/AI/Nullkiller/Analyzers/ArmyManager.cpp @@ -204,7 +204,6 @@ std::shared_ptr ArmyManager::getArmyAvailableToBuyAsCCreatureSet( TResources availableRes) const { std::vector creaturesInDwellings; - int freeHeroSlots = GameConstants::ARMY_SIZE; auto army = std::make_shared(); for(int i = dwelling->creatures.size() - 1; i >= 0; i--) @@ -497,4 +496,4 @@ ArmyUpgradeInfo ArmyManager::calculateCreaturesUpgrade( } return result; -} \ No newline at end of file +} diff --git a/AI/Nullkiller/Analyzers/ArmyManager.h b/AI/Nullkiller/Analyzers/ArmyManager.h index 5d422aa9e..fddad9fcb 100644 --- a/AI/Nullkiller/Analyzers/ArmyManager.h +++ b/AI/Nullkiller/Analyzers/ArmyManager.h @@ -41,6 +41,7 @@ struct ArmyUpgradeInfo class DLL_EXPORT IArmyManager //: public: IAbstractManager { public: + virtual ~IArmyManager() = default; virtual void update() = 0; virtual ui64 howManyReinforcementsCanBuy(const CCreatureSet * target, const CGDwelling * source) const = 0; virtual ui64 howManyReinforcementsCanBuy( diff --git a/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp b/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp index 0b168227c..72314e61d 100644 --- a/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp +++ b/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp @@ -129,8 +129,6 @@ void BuildAnalyzer::update() { logAi->trace("Checking town %s", town->name); - auto townInfo = town->town; - developmentInfos.push_back(TownDevelopmentInfo(town)); TownDevelopmentInfo & developmentInfo = developmentInfos.back(); @@ -399,4 +397,4 @@ std::string BuildingInfo::toString() const + ", creature: " + std::to_string(creatureGrows) + " x " + std::to_string(creatureLevel) + " x " + creatureCost.toString() + ", daily: " + dailyIncome.toString(); -} \ No newline at end of file +} diff --git a/AI/Nullkiller/Analyzers/DangerHitMapAnalyzer.cpp b/AI/Nullkiller/Analyzers/DangerHitMapAnalyzer.cpp index ded809623..8192fd1a4 100644 --- a/AI/Nullkiller/Analyzers/DangerHitMapAnalyzer.cpp +++ b/AI/Nullkiller/Analyzers/DangerHitMapAnalyzer.cpp @@ -63,7 +63,7 @@ void DangerHitMapAnalyzer::updateHitMap() auto & node = hitMap[pos.x][pos.y][pos.z]; if(tileDanger > node.maximumDanger.danger - || tileDanger == node.maximumDanger.danger && node.maximumDanger.turn > turn) + || (tileDanger == node.maximumDanger.danger && node.maximumDanger.turn > turn)) { node.maximumDanger.danger = tileDanger; node.maximumDanger.turn = turn; @@ -71,7 +71,7 @@ void DangerHitMapAnalyzer::updateHitMap() } if(turn < node.fastestDanger.turn - || turn == node.fastestDanger.turn && node.fastestDanger.danger < tileDanger) + || (turn == node.fastestDanger.turn && node.fastestDanger.danger < tileDanger)) { node.fastestDanger.danger = tileDanger; node.fastestDanger.turn = turn; @@ -101,8 +101,8 @@ uint64_t DangerHitMapAnalyzer::enemyCanKillOurHeroesAlongThePath(const AIPath & int turn = path.turn(); const HitMapNode & info = hitMap[tile.x][tile.y][tile.z]; - return info.fastestDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, info.fastestDanger.danger) - || info.maximumDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, info.maximumDanger.danger); + return (info.fastestDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, info.fastestDanger.danger)) + || (info.maximumDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, info.maximumDanger.danger)); } const HitMapNode & DangerHitMapAnalyzer::getObjectTreat(const CGObjectInstance * obj) const diff --git a/AI/Nullkiller/Analyzers/HeroManager.h b/AI/Nullkiller/Analyzers/HeroManager.h index 5ac745c02..8248a2b0b 100644 --- a/AI/Nullkiller/Analyzers/HeroManager.h +++ b/AI/Nullkiller/Analyzers/HeroManager.h @@ -20,6 +20,7 @@ class DLL_EXPORT IHeroManager //: public: IAbstractManager { public: + virtual ~IHeroManager() = default; virtual const std::map & getHeroRoles() const = 0; virtual int selectBestSkill(const HeroPtr & hero, const std::vector & skills) const = 0; virtual HeroRole getHeroRole(const HeroPtr & hero) const = 0; @@ -31,6 +32,7 @@ public: class DLL_EXPORT ISecondarySkillRule { public: + virtual ~ISecondarySkillRule() = default; virtual void evaluateScore(const CGHeroInstance * hero, SecondarySkill skill, float & score) const = 0; }; @@ -52,11 +54,10 @@ private: static SecondarySkillEvaluator scountSkillsScores; CCallback * cb; //this is enough, but we downcast from CCallback - const Nullkiller * ai; std::map heroRoles; public: - HeroManager(CCallback * CB, const Nullkiller * ai) : cb(CB), ai(ai) {} + HeroManager(CCallback * CB, const Nullkiller * ai) : cb(CB) {} const std::map & getHeroRoles() const override; HeroRole getHeroRole(const HeroPtr & hero) const override; int selectBestSkill(const HeroPtr & hero, const std::vector & skills) const override; @@ -102,4 +103,4 @@ private: public: void evaluateScore(const CGHeroInstance * hero, SecondarySkill skill, float & score) const override; -}; \ No newline at end of file +}; diff --git a/AI/Nullkiller/Analyzers/ObjectClusterizer.cpp b/AI/Nullkiller/Analyzers/ObjectClusterizer.cpp index bc60f43ba..dacacf393 100644 --- a/AI/Nullkiller/Analyzers/ObjectClusterizer.cpp +++ b/AI/Nullkiller/Analyzers/ObjectClusterizer.cpp @@ -149,7 +149,7 @@ bool ObjectClusterizer::shouldVisitObject(const CGObjectInstance * obj) const const int3 pos = obj->visitablePos(); - if(obj->ID != Obj::CREATURE_GENERATOR1 && vstd::contains(ai->memory->alreadyVisited, obj) + if((obj->ID != Obj::CREATURE_GENERATOR1 && vstd::contains(ai->memory->alreadyVisited, obj)) || obj->wasVisited(ai->playerID)) { return false; diff --git a/AI/Nullkiller/Behaviors/BuildingBehavior.cpp b/AI/Nullkiller/Behaviors/BuildingBehavior.cpp index 22386683e..5fc50c213 100644 --- a/AI/Nullkiller/Behaviors/BuildingBehavior.cpp +++ b/AI/Nullkiller/Behaviors/BuildingBehavior.cpp @@ -53,8 +53,6 @@ Goals::TGoalVec BuildingBehavior::decompose() const for(auto & developmentInfo : developmentInfos) { - auto town = developmentInfo.town; - for(auto & buildingInfo : developmentInfo.toBuild) { if(goldPreasure < MAX_GOLD_PEASURE || buildingInfo.dailyIncome[Res::GOLD] > 0) diff --git a/AI/Nullkiller/Behaviors/DefenceBehavior.cpp b/AI/Nullkiller/Behaviors/DefenceBehavior.cpp index 88263ecb1..da108da88 100644 --- a/AI/Nullkiller/Behaviors/DefenceBehavior.cpp +++ b/AI/Nullkiller/Behaviors/DefenceBehavior.cpp @@ -106,10 +106,10 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta { if(path.getHeroStrength() > treat.danger) { - if(path.turn() <= treat.turn && dayOfWeek + treat.turn < 6 && isSafeToVisit(path.targetHero, path.heroArmy, treat.danger) - || path.exchangeCount == 1 && path.turn() < treat.turn + if((path.turn() <= treat.turn && dayOfWeek + treat.turn < 6 && isSafeToVisit(path.targetHero, path.heroArmy, treat.danger)) + || (path.exchangeCount == 1 && path.turn() < treat.turn) || path.turn() < treat.turn - 1 - || path.turn() < treat.turn && treat.turn >= 2) + || (path.turn() < treat.turn && treat.turn >= 2)) { logAi->debug( "Hero %s can eliminate danger for town %s using path %s.", @@ -217,7 +217,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta // dismiss creatures we are not able to pick to be able to hide in garrison if(town->garrisonHero || town->getUpperArmy()->stacksCount() == 0 - || town->getUpperArmy()->getArmyStrength() < 500 && town->fortLevel() >= CGTownInstance::CITADEL) + || (town->getUpperArmy()->getArmyStrength() < 500 && town->fortLevel() >= CGTownInstance::CITADEL)) { tasks.push_back( Goals::sptr(Composition() @@ -228,7 +228,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta continue; } - if(treat.turn == 0 || path.turn() <= treat.turn && path.getHeroStrength() * SAFE_ATTACK_CONSTANT >= treat.danger) + if(treat.turn == 0 || (path.turn() <= treat.turn && path.getHeroStrength() * SAFE_ATTACK_CONSTANT >= treat.danger)) { if(ai->nullkiller->arePathHeroesLocked(path)) { @@ -294,4 +294,4 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta } logAi->debug("Found %d tasks", tasks.size()); -} \ No newline at end of file +} diff --git a/AI/Nullkiller/Behaviors/StartupBehavior.cpp b/AI/Nullkiller/Behaviors/StartupBehavior.cpp index 4a1788c67..f5f84187f 100644 --- a/AI/Nullkiller/Behaviors/StartupBehavior.cpp +++ b/AI/Nullkiller/Behaviors/StartupBehavior.cpp @@ -55,7 +55,7 @@ const CGHeroInstance * getNearestHero(const CGTownInstance * town) if(shortestPath.nodes.size() > 1 || shortestPath.turn() != 0 || shortestPath.targetHero->visitablePos().dist2dSQ(town->visitablePos()) > 4 - || town->garrisonHero && shortestPath.targetHero == town->garrisonHero.get()) + || (town->garrisonHero && shortestPath.targetHero == town->garrisonHero.get())) return nullptr; return shortestPath.targetHero; @@ -76,13 +76,13 @@ bool needToRecruitHero(const CGTownInstance * startupTown) for(auto obj : ai->nullkiller->objectClusterizer->getNearbyObjects()) { - if(obj->ID == Obj::RESOURCE && obj->subID == Res::GOLD + if((obj->ID == Obj::RESOURCE && obj->subID == Res::GOLD) || obj->ID == Obj::TREASURE_CHEST || obj->ID == Obj::CAMPFIRE || obj->ID == Obj::WATER_WHEEL) { auto path = paths->getPathInfo(obj->visitablePos()); - if((path->accessible == CGPathNode::BLOCKVIS || path->accessible == CGPathNode::VISIT) + if((path->accessible == CGPathNode::BLOCKVIS || path->accessible == CGPathNode::VISITABLE) && path->reachable()) { treasureSourcesCount++; @@ -162,7 +162,7 @@ Goals::TGoalVec StartupBehavior::decompose() const auto garrisonHeroScore = ai->nullkiller->heroManager->evaluateHero(garrisonHero); if(visitingHeroScore > garrisonHeroScore - || ai->nullkiller->heroManager->getHeroRole(garrisonHero) == HeroRole::SCOUT && ai->nullkiller->heroManager->getHeroRole(visitingHero) == HeroRole::MAIN) + || (ai->nullkiller->heroManager->getHeroRole(garrisonHero) == HeroRole::SCOUT && ai->nullkiller->heroManager->getHeroRole(visitingHero) == HeroRole::MAIN)) { if(canRecruitHero || ai->nullkiller->armyManager->howManyReinforcementsCanGet(visitingHero, garrisonHero) > 200) { diff --git a/AI/Nullkiller/Engine/PriorityEvaluator.cpp b/AI/Nullkiller/Engine/PriorityEvaluator.cpp index 4997fde20..58f97b837 100644 --- a/AI/Nullkiller/Engine/PriorityEvaluator.cpp +++ b/AI/Nullkiller/Engine/PriorityEvaluator.cpp @@ -122,7 +122,7 @@ uint64_t getCreatureBankArmyReward(const CGObjectInstance * target, const CGHero { //No free slot, we might discard our weakest stack weakestStackPower = std::numeric_limits().max(); - for (const auto stack : slots) + for (const auto & stack : slots) { vstd::amin(weakestStackPower, stack.second->getPower()); } @@ -645,7 +645,6 @@ public: } auto heroPtr = task->hero; - auto day = ai->cb->getDate(Date::DAY); auto hero = heroPtr.get(ai->cb.get()); bool checkGold = evaluationContext.danger == 0; auto army = path.heroArmy; @@ -670,11 +669,8 @@ public: class ClusterEvaluationContextBuilder : public IEvaluationContextBuilder { -private: - const Nullkiller * ai; - public: - ClusterEvaluationContextBuilder(const Nullkiller * ai) : ai(ai) {} + ClusterEvaluationContextBuilder(const Nullkiller * ai) {} virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override { @@ -699,7 +695,6 @@ public: for(auto objInfo : objects) { auto target = objInfo.first; - auto day = ai->cb->getDate(Date::DAY); bool checkGold = objInfo.second.danger == 0; auto army = hero; @@ -718,9 +713,6 @@ public: if(boost > 8) break; } - - const AIPath & pathToCenter = clusterGoal.getPathToCenter(); - } }; diff --git a/AI/Nullkiller/Engine/PriorityEvaluator.h b/AI/Nullkiller/Engine/PriorityEvaluator.h index 5ce11de5b..6bcd09c32 100644 --- a/AI/Nullkiller/Engine/PriorityEvaluator.h +++ b/AI/Nullkiller/Engine/PriorityEvaluator.h @@ -61,6 +61,7 @@ struct DLL_EXPORT EvaluationContext class IEvaluationContextBuilder { public: + virtual ~IEvaluationContextBuilder() = default; virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal goal) const = 0; }; diff --git a/AI/Nullkiller/Pathfinding/AINodeStorage.cpp b/AI/Nullkiller/Pathfinding/AINodeStorage.cpp index a5e302557..39049acfb 100644 --- a/AI/Nullkiller/Pathfinding/AINodeStorage.cpp +++ b/AI/Nullkiller/Pathfinding/AINodeStorage.cpp @@ -558,7 +558,7 @@ bool AINodeStorage::selectNextActor() for(auto actor = actors.begin(); actor != actors.end(); actor++) { if(actor->get()->armyValue > currentActor->get()->armyValue - || actor->get()->armyValue == currentActor->get()->armyValue && actor <= currentActor) + || (actor->get()->armyValue == currentActor->get()->armyValue && actor <= currentActor)) { continue; } diff --git a/AI/Nullkiller/Pathfinding/Actions/BoatActions.h b/AI/Nullkiller/Pathfinding/Actions/BoatActions.h index 0db5ff781..4b2812b21 100644 --- a/AI/Nullkiller/Pathfinding/Actions/BoatActions.h +++ b/AI/Nullkiller/Pathfinding/Actions/BoatActions.h @@ -24,9 +24,6 @@ namespace AIPathfinding class SummonBoatAction : public VirtualBoatAction { - private: - const CGHeroInstance * hero; - public: virtual void execute(const CGHeroInstance * hero) const override; @@ -71,4 +68,4 @@ namespace AIPathfinding virtual const CGObjectInstance * targetObject() const override; }; -} \ No newline at end of file +} diff --git a/AI/Nullkiller/Pathfinding/Actions/SpecialAction.h b/AI/Nullkiller/Pathfinding/Actions/SpecialAction.h index 6d7cbbbac..51977963b 100644 --- a/AI/Nullkiller/Pathfinding/Actions/SpecialAction.h +++ b/AI/Nullkiller/Pathfinding/Actions/SpecialAction.h @@ -18,6 +18,8 @@ struct AIPathNode; class SpecialAction { public: + virtual ~SpecialAction() = default; + virtual bool canAct(const AIPathNode * source) const { return true; @@ -39,4 +41,4 @@ public: virtual std::string toString() const = 0; virtual const CGObjectInstance * targetObject() const { return nullptr; } -}; \ No newline at end of file +}; diff --git a/AI/Nullkiller/Pathfinding/Actors.cpp b/AI/Nullkiller/Pathfinding/Actors.cpp index 68d10fecc..e6806a0b2 100644 --- a/AI/Nullkiller/Pathfinding/Actors.cpp +++ b/AI/Nullkiller/Pathfinding/Actors.cpp @@ -269,8 +269,6 @@ ExchangeResult HeroExchangeMap::tryExchangeNoLock(const ChainActor * other) return result; // already inserted } - auto position = inserted.first; - auto differentMasks = (actor->chainMask & other->chainMask) == 0; if(!differentMasks) return result; @@ -461,15 +459,6 @@ CCreatureSet * DwellingActor::getDwellingCreatures(const CGDwelling * dwelling, continue; auto creature = creatureInfo.second.back().toCreature(); - auto count = creatureInfo.first; - - if(waitForGrowth) - { - const CGTownInstance * town = dynamic_cast(dwelling); - - count += town ? town->creatureGrowth(creature->level) : creature->growth; - } - dwellingCreatures->addToSlot( dwellingCreatures->getSlotFor(creature), creature->idNumber, @@ -487,4 +476,4 @@ TownGarrisonActor::TownGarrisonActor(const CGTownInstance * town, uint64_t chain std::string TownGarrisonActor::toString() const { return town->name; -} \ No newline at end of file +} diff --git a/AI/Nullkiller/Pathfinding/Actors.h b/AI/Nullkiller/Pathfinding/Actors.h index ff2618df2..2f18df369 100644 --- a/AI/Nullkiller/Pathfinding/Actors.h +++ b/AI/Nullkiller/Pathfinding/Actors.h @@ -75,7 +75,8 @@ public: TResources armyCost; std::shared_ptr tiCache; - ChainActor(){} + ChainActor() = default; + virtual ~ChainActor() = default; virtual std::string toString() const; ExchangeResult tryExchangeNoLock(const ChainActor * other) const { return tryExchangeNoLock(this, other); } @@ -168,4 +169,4 @@ private: public: TownGarrisonActor(const CGTownInstance * town, uint64_t chainMask); virtual std::string toString() const override; -}; \ No newline at end of file +}; diff --git a/AI/Nullkiller/Pathfinding/Rules/AIMovementAfterDestinationRule.cpp b/AI/Nullkiller/Pathfinding/Rules/AIMovementAfterDestinationRule.cpp index 8ffcf1be7..68aab0c35 100644 --- a/AI/Nullkiller/Pathfinding/Rules/AIMovementAfterDestinationRule.cpp +++ b/AI/Nullkiller/Pathfinding/Rules/AIMovementAfterDestinationRule.cpp @@ -126,7 +126,6 @@ namespace AIPathfinding const AIPathNode * destinationNode = nodeStorage->getAINode(destination.node); auto questObj = dynamic_cast(destination.nodeObject); auto questInfo = QuestInfo(questObj->quest, destination.nodeObject, destination.coord); - auto nodeHero = pathfinderHelper->hero; QuestAction questAction(questInfo); if(destination.nodeObject->ID == Obj::QUEST_GUARD && questObj->quest->missionType == CQuest::MISSION_NONE) @@ -157,8 +156,6 @@ namespace AIPathfinding nodeStorage->updateAINode(destination.node, [&](AIPathNode * node) { - auto questInfo = QuestInfo(questObj->quest, destination.nodeObject, destination.coord); - node->specialAction.reset(new QuestAction(questAction)); }); } diff --git a/AI/VCAI/AIhelper.cpp b/AI/VCAI/AIhelper.cpp index 8e46d50f5..75fca29b2 100644 --- a/AI/VCAI/AIhelper.cpp +++ b/AI/VCAI/AIhelper.cpp @@ -19,10 +19,6 @@ AIhelper::AIhelper() armyManager.reset(new ArmyManager()); } -AIhelper::~AIhelper() -{ -} - bool AIhelper::notifyGoalCompleted(Goals::TSubgoal goal) { return resourceManager->notifyGoalCompleted(goal); @@ -182,4 +178,4 @@ std::vector::iterator AIhelper::getWeakestCreature(std::vector AIhelper::getSortedSlots(const CCreatureSet * target, const CCreatureSet * source) const { return armyManager->getSortedSlots(target, source); -} \ No newline at end of file +} diff --git a/AI/VCAI/AIhelper.h b/AI/VCAI/AIhelper.h index 29d2bc94d..1a33025f0 100644 --- a/AI/VCAI/AIhelper.h +++ b/AI/VCAI/AIhelper.h @@ -36,7 +36,6 @@ class DLL_EXPORT AIhelper : public IResourceManager, public IBuildingManager, pu //TODO: vector public: AIhelper(); - ~AIhelper(); bool canAfford(const TResources & cost) const; TResources reservedResources() const override; diff --git a/AI/VCAI/ArmyManager.h b/AI/VCAI/ArmyManager.h index 7579207da..5e29b41b1 100644 --- a/AI/VCAI/ArmyManager.h +++ b/AI/VCAI/ArmyManager.h @@ -28,6 +28,7 @@ struct SlotInfo class DLL_EXPORT IArmyManager //: public: IAbstractManager { public: + virtual ~IArmyManager() = default; virtual void init(CPlayerSpecificInfoCallback * CB) = 0; virtual void setAI(VCAI * AI) = 0; virtual bool canGetArmy(const CArmedInstance * target, const CArmedInstance * source) const = 0; diff --git a/AI/VCAI/ResourceManager.cpp b/AI/VCAI/ResourceManager.cpp index 027b9e9c2..d676c4488 100644 --- a/AI/VCAI/ResourceManager.cpp +++ b/AI/VCAI/ResourceManager.cpp @@ -120,14 +120,12 @@ Goals::TSubgoal ResourceManager::collectResourcesForOurGoal(ResourceObjective &o return o.goal; } - float goalPriority = 10; //arbitrary, will be divided - for (const resPair & p : missingResources) + for (const resPair p : missingResources) { if (!income[p.first]) //prioritize resources with 0 income { resourceType = p.first; amountToCollect = p.second; - goalPriority /= amountToCollect; //need more resources -> lower priority break; } } @@ -138,7 +136,7 @@ Goals::TSubgoal ResourceManager::collectResourcesForOurGoal(ResourceObjective &o std::map daysToEarn; for (auto it : missingResources) daysToEarn[it.first] = (float)missingResources[it.first] / income[it.first]; - auto incomeComparer = [&income](const timePair & lhs, const timePair & rhs) -> bool + auto incomeComparer = [](const timePair & lhs, const timePair & rhs) -> bool { //theoretically income can be negative, but that falls into this comparison return lhs.second < rhs.second; @@ -146,12 +144,9 @@ Goals::TSubgoal ResourceManager::collectResourcesForOurGoal(ResourceObjective &o resourceType = boost::max_element(daysToEarn, incomeComparer)->first; amountToCollect = missingResources[resourceType]; - goalPriority /= daysToEarn[resourceType]; //more days - lower priority } - if (resourceType == Res::GOLD) - goalPriority *= 1000; - //this is abstract goal and might take soem time to complete + //this is abstract goal and might take some time to complete return Goals::sptr(Goals::CollectRes(resourceType, amountToCollect).setisAbstract(true)); } diff --git a/CCallback.h b/CCallback.h index 7fe4583d3..36d93898a 100644 --- a/CCallback.h +++ b/CCallback.h @@ -35,6 +35,8 @@ struct ArtifactLocation; class IBattleCallback { public: + virtual ~IBattleCallback() = default; + bool waitTillRealize; //if true, request functions will return after they are realized by server bool unlockGsWhenWaiting;//if true after sending each request, gs mutex will be unlocked so the changes can be applied; NOTICE caller must have gs mx locked prior to any call to actiob callback! //battle diff --git a/CMakeLists.txt b/CMakeLists.txt index 98eaa413f..9d7e99df3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,6 +197,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32) #so far all *nix compilers support suc set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing -Wno-switch -Wno-sign-compare -Wno-unused-local-typedefs") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-overloaded-virtual -Wno-type-limits -Wno-unknown-pragmas") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-varargs") # fuzzylite - Operation.h if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-mismatched-tags -Wno-unknown-warning-option -Wno-missing-braces") diff --git a/client/battle/CBattleInterface.cpp b/client/battle/CBattleInterface.cpp index 50d41a8c3..016d161dd 100644 --- a/client/battle/CBattleInterface.cpp +++ b/client/battle/CBattleInterface.cpp @@ -1083,11 +1083,10 @@ void CBattleInterface::stacksAreAttacked(std::vector attacked std::array killedBySide = {0, 0}; - int targets = 0, damage = 0; + int targets = 0; for(const StackAttackedInfo & attackedInfo : attackedInfos) { ++targets; - damage += (int)attackedInfo.dmg; ui8 side = attackedInfo.defender->side; killedBySide.at(side) += attackedInfo.amountKilled; diff --git a/client/gui/SDL_Extensions.h b/client/gui/SDL_Extensions.h index b88054bfa..bc5401a37 100644 --- a/client/gui/SDL_Extensions.h +++ b/client/gui/SDL_Extensions.h @@ -155,6 +155,7 @@ typedef void (*BlitterWithRotationVal)(SDL_Surface *src,SDL_Rect srcRect, SDL_Su class ColorShifter { public: + virtual ~ColorShifter() = default; virtual SDL_Color shiftColor(SDL_Color clr) const = 0; }; diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index 867a7abf0..3944be31a 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -1286,7 +1286,7 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2, int skill = hero->secSkills[g].first, level = hero->secSkills[g].second; // <1, 3> secSkillAreas[b].push_back(std::make_shared()); - secSkillAreas[b][g]->pos = genRect(32, 32, pos.x + 32 + g*36 + b*454 , pos.y + qeLayout ? 83 : 88); + secSkillAreas[b][g]->pos = genRect(32, 32, pos.x + 32 + g*36 + b*454 , pos.y + (qeLayout ? 83 : 88)); secSkillAreas[b][g]->baseType = 1; secSkillAreas[b][g]->type = skill; @@ -1301,12 +1301,12 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2, heroAreas[b] = std::make_shared(257 + 228*b, 13, hero); specialtyAreas[b] = std::make_shared(); - specialtyAreas[b]->pos = genRect(32, 32, pos.x + 69 + 490*b, pos.y + qeLayout ? 41 : 45); + specialtyAreas[b]->pos = genRect(32, 32, pos.x + 69 + 490*b, pos.y + (qeLayout ? 41 : 45)); specialtyAreas[b]->hoverText = CGI->generaltexth->heroscrn[27]; specialtyAreas[b]->text = hero->type->specDescr; experienceAreas[b] = std::make_shared(); - experienceAreas[b]->pos = genRect(32, 32, pos.x + 105 + 490*b, pos.y + qeLayout ? 41 : 45); + experienceAreas[b]->pos = genRect(32, 32, pos.x + 105 + 490*b, pos.y + (qeLayout ? 41 : 45)); experienceAreas[b]->hoverText = CGI->generaltexth->heroscrn[9]; experienceAreas[b]->text = CGI->generaltexth->allTexts[2]; boost::algorithm::replace_first(experienceAreas[b]->text, "%d", boost::lexical_cast(hero->level)); @@ -1314,7 +1314,7 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2, boost::algorithm::replace_first(experienceAreas[b]->text, "%d", boost::lexical_cast(hero->exp)); spellPointsAreas[b] = std::make_shared(); - spellPointsAreas[b]->pos = genRect(32, 32, pos.x + 141 + 490*b, pos.y + qeLayout ? 41 : 45); + spellPointsAreas[b]->pos = genRect(32, 32, pos.x + 141 + 490*b, pos.y + (qeLayout ? 41 : 45)); spellPointsAreas[b]->hoverText = CGI->generaltexth->heroscrn[22]; spellPointsAreas[b]->text = CGI->generaltexth->allTexts[205]; boost::algorithm::replace_first(spellPointsAreas[b]->text, "%s", hero->name); diff --git a/include/vcmi/ServerCallback.h b/include/vcmi/ServerCallback.h index a9a722d4d..af35b4ea5 100644 --- a/include/vcmi/ServerCallback.h +++ b/include/vcmi/ServerCallback.h @@ -27,6 +27,8 @@ struct CatapultAttack; class DLL_LINKAGE ServerCallback { public: + virtual ~ServerCallback() = default; + virtual void complain(const std::string & problem) = 0; virtual bool describeChanges() const = 0; diff --git a/lib/CPathfinder.h b/lib/CPathfinder.h index 2bd7e5790..c047701a4 100644 --- a/lib/CPathfinder.h +++ b/lib/CPathfinder.h @@ -386,6 +386,9 @@ class DLL_LINKAGE INodeStorage { public: using ELayer = EPathfindingLayer; + + virtual ~INodeStorage() = default; + virtual std::vector getInitialNodes() = 0; virtual std::vector calculateNeighbours( @@ -448,6 +451,7 @@ public: PathfinderConfig( std::shared_ptr nodeStorage, std::vector> rules); + virtual ~PathfinderConfig() = default; virtual CPathfinderHelper * getOrCreatePathfinderHelper(const PathNodeInfo & source, CGameState * gs) = 0; }; diff --git a/lib/Terrain.cpp b/lib/Terrain.cpp index 142355961..7f89447d2 100644 --- a/lib/Terrain.cpp +++ b/lib/Terrain.cpp @@ -201,12 +201,6 @@ Terrain::operator std::string() const Terrain::Terrain(const std::string & _name) : name(_name) {} -Terrain& Terrain::operator=(const Terrain & _name) -{ - name = _name.name; - return *this; -} - Terrain& Terrain::operator=(const std::string & _name) { name = _name; diff --git a/lib/Terrain.h b/lib/Terrain.h index d270090e5..95fa343b0 100644 --- a/lib/Terrain.h +++ b/lib/Terrain.h @@ -74,7 +74,6 @@ public: int id() const; //TODO: has to be completely removed - Terrain& operator=(const Terrain & _type); Terrain& operator=(const std::string & _type); DLL_LINKAGE friend bool operator==(const Terrain & l, const Terrain & r); diff --git a/lib/events/ApplyDamage.cpp b/lib/events/ApplyDamage.cpp index 8ba3de747..93b387899 100644 --- a/lib/events/ApplyDamage.cpp +++ b/lib/events/ApplyDamage.cpp @@ -25,10 +25,8 @@ SubscriptionRegistry * ApplyDamage::getRegistry() } CApplyDamage::CApplyDamage(const Environment * env_, BattleStackAttacked * pack_, std::shared_ptr target_) - : env(env_), - pack(pack_), + : pack(pack_), target(target_) - { initalDamage = pack->damageAmount; } diff --git a/lib/events/ApplyDamage.h b/lib/events/ApplyDamage.h index c56d730fe..178d12224 100644 --- a/lib/events/ApplyDamage.h +++ b/lib/events/ApplyDamage.h @@ -28,12 +28,8 @@ public: private: int64_t initalDamage; - const Environment * env; BattleStackAttacked * pack; std::shared_ptr target; }; } - - - diff --git a/lib/rmg/Zone.cpp b/lib/rmg/Zone.cpp index 7323a27fd..6b2f977f2 100644 --- a/lib/rmg/Zone.cpp +++ b/lib/rmg/Zone.cpp @@ -193,11 +193,7 @@ void Zone::fractalize() rmg::Area clearedTiles(dAreaFree); rmg::Area possibleTiles(dAreaPossible); rmg::Area tilesToIgnore; //will be erased in this iteration - - //the more treasure density, the greater distance between paths. Scaling is experimental. - int totalDensity = 0; - for(auto ti : treasureInfo) - totalDensity += ti.density; + const float minDistance = 10 * 10; //squared if(type != ETemplateZoneType::JUNCTION) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 764051636..13a6cd7ab 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -5589,7 +5589,7 @@ bool CGameHandler::isAllowedExchange(ObjectInstanceID id1, ObjectInstanceID id2) auto topArmy = dialog->exchangingArmies.at(0); auto bottomArmy = dialog->exchangingArmies.at(1); - if (topArmy == o1 && bottomArmy == o2 || bottomArmy == o1 && topArmy == o2) + if ((topArmy == o1 && bottomArmy == o2) || (bottomArmy == o1 && topArmy == o2)) return true; } }