1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

remove unused variables

This commit is contained in:
Andrey Filipenkov 2022-09-22 11:49:55 +03:00
parent 143b0983e6
commit c9c79887a7
13 changed files with 11 additions and 58 deletions

View File

@ -204,7 +204,6 @@ std::shared_ptr<CCreatureSet> ArmyManager::getArmyAvailableToBuyAsCCreatureSet(
TResources availableRes) const TResources availableRes) const
{ {
std::vector<creInfo> creaturesInDwellings; std::vector<creInfo> creaturesInDwellings;
int freeHeroSlots = GameConstants::ARMY_SIZE;
auto army = std::make_shared<TemporaryArmy>(); auto army = std::make_shared<TemporaryArmy>();
for(int i = dwelling->creatures.size() - 1; i >= 0; i--) for(int i = dwelling->creatures.size() - 1; i >= 0; i--)
@ -497,4 +496,4 @@ ArmyUpgradeInfo ArmyManager::calculateCreaturesUpgrade(
} }
return result; return result;
} }

View File

@ -129,8 +129,6 @@ void BuildAnalyzer::update()
{ {
logAi->trace("Checking town %s", town->name); logAi->trace("Checking town %s", town->name);
auto townInfo = town->town;
developmentInfos.push_back(TownDevelopmentInfo(town)); developmentInfos.push_back(TownDevelopmentInfo(town));
TownDevelopmentInfo & developmentInfo = developmentInfos.back(); TownDevelopmentInfo & developmentInfo = developmentInfos.back();
@ -399,4 +397,4 @@ std::string BuildingInfo::toString() const
+ ", creature: " + std::to_string(creatureGrows) + " x " + std::to_string(creatureLevel) + ", creature: " + std::to_string(creatureGrows) + " x " + std::to_string(creatureLevel)
+ " x " + creatureCost.toString() + " x " + creatureCost.toString()
+ ", daily: " + dailyIncome.toString(); + ", daily: " + dailyIncome.toString();
} }

View File

@ -54,11 +54,10 @@ private:
static SecondarySkillEvaluator scountSkillsScores; static SecondarySkillEvaluator scountSkillsScores;
CCallback * cb; //this is enough, but we downcast from CCallback CCallback * cb; //this is enough, but we downcast from CCallback
const Nullkiller * ai;
std::map<HeroPtr, HeroRole> heroRoles; std::map<HeroPtr, HeroRole> heroRoles;
public: public:
HeroManager(CCallback * CB, const Nullkiller * ai) : cb(CB), ai(ai) {} HeroManager(CCallback * CB, const Nullkiller * ai) : cb(CB) {}
const std::map<HeroPtr, HeroRole> & getHeroRoles() const override; const std::map<HeroPtr, HeroRole> & getHeroRoles() const override;
HeroRole getHeroRole(const HeroPtr & hero) const override; HeroRole getHeroRole(const HeroPtr & hero) const override;
int selectBestSkill(const HeroPtr & hero, const std::vector<SecondarySkill> & skills) const override; int selectBestSkill(const HeroPtr & hero, const std::vector<SecondarySkill> & skills) const override;

View File

@ -53,8 +53,6 @@ Goals::TGoalVec BuildingBehavior::decompose() const
for(auto & developmentInfo : developmentInfos) for(auto & developmentInfo : developmentInfos)
{ {
auto town = developmentInfo.town;
for(auto & buildingInfo : developmentInfo.toBuild) for(auto & buildingInfo : developmentInfo.toBuild)
{ {
if(goldPreasure < MAX_GOLD_PEASURE || buildingInfo.dailyIncome[Res::GOLD] > 0) if(goldPreasure < MAX_GOLD_PEASURE || buildingInfo.dailyIncome[Res::GOLD] > 0)

View File

@ -645,7 +645,6 @@ public:
} }
auto heroPtr = task->hero; auto heroPtr = task->hero;
auto day = ai->cb->getDate(Date::DAY);
auto hero = heroPtr.get(ai->cb.get()); auto hero = heroPtr.get(ai->cb.get());
bool checkGold = evaluationContext.danger == 0; bool checkGold = evaluationContext.danger == 0;
auto army = path.heroArmy; auto army = path.heroArmy;
@ -670,11 +669,8 @@ public:
class ClusterEvaluationContextBuilder : public IEvaluationContextBuilder class ClusterEvaluationContextBuilder : public IEvaluationContextBuilder
{ {
private:
const Nullkiller * ai;
public: public:
ClusterEvaluationContextBuilder(const Nullkiller * ai) : ai(ai) {} ClusterEvaluationContextBuilder(const Nullkiller * ai) {}
virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
{ {
@ -699,7 +695,6 @@ public:
for(auto objInfo : objects) for(auto objInfo : objects)
{ {
auto target = objInfo.first; auto target = objInfo.first;
auto day = ai->cb->getDate(Date::DAY);
bool checkGold = objInfo.second.danger == 0; bool checkGold = objInfo.second.danger == 0;
auto army = hero; auto army = hero;
@ -718,9 +713,6 @@ public:
if(boost > 8) if(boost > 8)
break; break;
} }
const AIPath & pathToCenter = clusterGoal.getPathToCenter();
} }
}; };

View File

@ -24,9 +24,6 @@ namespace AIPathfinding
class SummonBoatAction : public VirtualBoatAction class SummonBoatAction : public VirtualBoatAction
{ {
private:
const CGHeroInstance * hero;
public: public:
virtual void execute(const CGHeroInstance * hero) const override; virtual void execute(const CGHeroInstance * hero) const override;
@ -71,4 +68,4 @@ namespace AIPathfinding
virtual const CGObjectInstance * targetObject() const override; virtual const CGObjectInstance * targetObject() const override;
}; };
} }

View File

@ -269,8 +269,6 @@ ExchangeResult HeroExchangeMap::tryExchangeNoLock(const ChainActor * other)
return result; // already inserted return result; // already inserted
} }
auto position = inserted.first;
auto differentMasks = (actor->chainMask & other->chainMask) == 0; auto differentMasks = (actor->chainMask & other->chainMask) == 0;
if(!differentMasks) return result; if(!differentMasks) return result;
@ -461,15 +459,6 @@ CCreatureSet * DwellingActor::getDwellingCreatures(const CGDwelling * dwelling,
continue; continue;
auto creature = creatureInfo.second.back().toCreature(); auto creature = creatureInfo.second.back().toCreature();
auto count = creatureInfo.first;
if(waitForGrowth)
{
const CGTownInstance * town = dynamic_cast<const CGTownInstance *>(dwelling);
count += town ? town->creatureGrowth(creature->level) : creature->growth;
}
dwellingCreatures->addToSlot( dwellingCreatures->addToSlot(
dwellingCreatures->getSlotFor(creature), dwellingCreatures->getSlotFor(creature),
creature->idNumber, creature->idNumber,
@ -487,4 +476,4 @@ TownGarrisonActor::TownGarrisonActor(const CGTownInstance * town, uint64_t chain
std::string TownGarrisonActor::toString() const std::string TownGarrisonActor::toString() const
{ {
return town->name; return town->name;
} }

View File

@ -126,7 +126,6 @@ namespace AIPathfinding
const AIPathNode * destinationNode = nodeStorage->getAINode(destination.node); const AIPathNode * destinationNode = nodeStorage->getAINode(destination.node);
auto questObj = dynamic_cast<const IQuestObject *>(destination.nodeObject); auto questObj = dynamic_cast<const IQuestObject *>(destination.nodeObject);
auto questInfo = QuestInfo(questObj->quest, destination.nodeObject, destination.coord); auto questInfo = QuestInfo(questObj->quest, destination.nodeObject, destination.coord);
auto nodeHero = pathfinderHelper->hero;
QuestAction questAction(questInfo); QuestAction questAction(questInfo);
if(destination.nodeObject->ID == Obj::QUEST_GUARD && questObj->quest->missionType == CQuest::MISSION_NONE) 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) nodeStorage->updateAINode(destination.node, [&](AIPathNode * node)
{ {
auto questInfo = QuestInfo(questObj->quest, destination.nodeObject, destination.coord);
node->specialAction.reset(new QuestAction(questAction)); node->specialAction.reset(new QuestAction(questAction));
}); });
} }

View File

@ -120,14 +120,12 @@ Goals::TSubgoal ResourceManager::collectResourcesForOurGoal(ResourceObjective &o
return o.goal; 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 if (!income[p.first]) //prioritize resources with 0 income
{ {
resourceType = p.first; resourceType = p.first;
amountToCollect = p.second; amountToCollect = p.second;
goalPriority /= amountToCollect; //need more resources -> lower priority
break; break;
} }
} }
@ -138,7 +136,7 @@ Goals::TSubgoal ResourceManager::collectResourcesForOurGoal(ResourceObjective &o
std::map<Res::ERes, float> daysToEarn; std::map<Res::ERes, float> daysToEarn;
for (auto it : missingResources) for (auto it : missingResources)
daysToEarn[it.first] = (float)missingResources[it.first] / income[it.first]; 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 //theoretically income can be negative, but that falls into this comparison
return lhs.second < rhs.second; return lhs.second < rhs.second;
@ -146,12 +144,9 @@ Goals::TSubgoal ResourceManager::collectResourcesForOurGoal(ResourceObjective &o
resourceType = boost::max_element(daysToEarn, incomeComparer)->first; resourceType = boost::max_element(daysToEarn, incomeComparer)->first;
amountToCollect = missingResources[resourceType]; 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)); return Goals::sptr(Goals::CollectRes(resourceType, amountToCollect).setisAbstract(true));
} }

View File

@ -1083,11 +1083,10 @@ void CBattleInterface::stacksAreAttacked(std::vector<StackAttackedInfo> attacked
std::array<int, 2> killedBySide = {0, 0}; std::array<int, 2> killedBySide = {0, 0};
int targets = 0, damage = 0; int targets = 0;
for(const StackAttackedInfo & attackedInfo : attackedInfos) for(const StackAttackedInfo & attackedInfo : attackedInfos)
{ {
++targets; ++targets;
damage += (int)attackedInfo.dmg;
ui8 side = attackedInfo.defender->side; ui8 side = attackedInfo.defender->side;
killedBySide.at(side) += attackedInfo.amountKilled; killedBySide.at(side) += attackedInfo.amountKilled;

View File

@ -25,10 +25,8 @@ SubscriptionRegistry<ApplyDamage> * ApplyDamage::getRegistry()
} }
CApplyDamage::CApplyDamage(const Environment * env_, BattleStackAttacked * pack_, std::shared_ptr<battle::Unit> target_) CApplyDamage::CApplyDamage(const Environment * env_, BattleStackAttacked * pack_, std::shared_ptr<battle::Unit> target_)
: env(env_), : pack(pack_),
pack(pack_),
target(target_) target(target_)
{ {
initalDamage = pack->damageAmount; initalDamage = pack->damageAmount;
} }

View File

@ -28,12 +28,8 @@ public:
private: private:
int64_t initalDamage; int64_t initalDamage;
const Environment * env;
BattleStackAttacked * pack; BattleStackAttacked * pack;
std::shared_ptr<battle::Unit> target; std::shared_ptr<battle::Unit> target;
}; };
} }

View File

@ -193,11 +193,7 @@ void Zone::fractalize()
rmg::Area clearedTiles(dAreaFree); rmg::Area clearedTiles(dAreaFree);
rmg::Area possibleTiles(dAreaPossible); rmg::Area possibleTiles(dAreaPossible);
rmg::Area tilesToIgnore; //will be erased in this iteration 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 const float minDistance = 10 * 10; //squared
if(type != ETemplateZoneType::JUNCTION) if(type != ETemplateZoneType::JUNCTION)