mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Fixed lots of warnings.
Disabled the following (for MSVC only) that couldn't (or shouldn't) be fixed. 4003: not enough actual parameters for macro 'identifier' 4250: 'class1' : inherits 'class2::member' via dominance 4251: 'type' : class 'type1' needs to have dll-interface to be used by clients of class 'type2' 4275: non dll-interface class 'type1' used as base for dll-interface class 'type2'
This commit is contained in:
@@ -25,12 +25,12 @@ void CEmptyAI::yourTurn()
|
||||
|
||||
void CEmptyAI::heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID)
|
||||
{
|
||||
cb->selectionMade(CRandomGenerator::getDefault().nextInt(skills.size() - 1), queryID);
|
||||
cb->selectionMade(CRandomGenerator::getDefault().nextInt((int)skills.size() - 1), queryID);
|
||||
}
|
||||
|
||||
void CEmptyAI::commanderGotLevel(const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID)
|
||||
{
|
||||
cb->selectionMade(CRandomGenerator::getDefault().nextInt(skills.size() - 1), queryID);
|
||||
cb->selectionMade(CRandomGenerator::getDefault().nextInt((int)skills.size() - 1), queryID);
|
||||
}
|
||||
|
||||
void CEmptyAI::showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel)
|
||||
|
||||
@@ -54,8 +54,8 @@ struct EnemyInfo
|
||||
void calcDmg(const CStack * ourStack)
|
||||
{
|
||||
TDmgRange retal, dmg = cbc->battleEstimateDamage(ourStack, s, &retal);
|
||||
adi = (dmg.first + dmg.second) / 2;
|
||||
adr = (retal.first + retal.second) / 2;
|
||||
adi = static_cast<int>((dmg.first + dmg.second) / 2);
|
||||
adr = static_cast<int>((retal.first + retal.second) / 2);
|
||||
}
|
||||
|
||||
bool operator==(const EnemyInfo& ei) const
|
||||
|
||||
@@ -46,10 +46,10 @@ struct armyStructure
|
||||
|
||||
armyStructure evaluateArmyStructure(const CArmedInstance * army)
|
||||
{
|
||||
ui64 totalStrenght = army->getArmyStrength();
|
||||
double walkersStrenght = 0;
|
||||
double flyersStrenght = 0;
|
||||
double shootersStrenght = 0;
|
||||
ui64 totalStrength = army->getArmyStrength();
|
||||
double walkersStrength = 0;
|
||||
double flyersStrength = 0;
|
||||
double shootersStrength = 0;
|
||||
ui32 maxSpeed = 0;
|
||||
|
||||
static const CSelector selectorSHOOTER = Selector::type(Bonus::SHOOTER);
|
||||
@@ -67,23 +67,23 @@ armyStructure evaluateArmyStructure(const CArmedInstance * army)
|
||||
const CCreature * creature = s.second->type;
|
||||
if(creature->hasBonus(selectorSHOOTER, keySHOOTER))
|
||||
{
|
||||
shootersStrenght += s.second->getPower();
|
||||
shootersStrength += s.second->getPower();
|
||||
walker = false;
|
||||
}
|
||||
if(creature->hasBonus(selectorFLYING, keyFLYING))
|
||||
{
|
||||
flyersStrenght += s.second->getPower();
|
||||
flyersStrength += s.second->getPower();
|
||||
walker = false;
|
||||
}
|
||||
if(walker)
|
||||
walkersStrenght += s.second->getPower();
|
||||
walkersStrength += s.second->getPower();
|
||||
|
||||
vstd::amax(maxSpeed, creature->valOfBonuses(selectorSTACKS_SPEED, keySTACKS_SPEED));
|
||||
}
|
||||
armyStructure as;
|
||||
as.walkers = walkersStrenght / totalStrenght;
|
||||
as.shooters = shootersStrenght / totalStrenght;
|
||||
as.flyers = flyersStrenght / totalStrenght;
|
||||
as.walkers = static_cast<float>(walkersStrength / totalStrength);
|
||||
as.shooters = static_cast<float>(shootersStrength / totalStrength);
|
||||
as.flyers = static_cast<float>(flyersStrength / totalStrength);
|
||||
as.maxSpeed = maxSpeed;
|
||||
assert(as.walkers || as.flyers || as.shooters);
|
||||
return as;
|
||||
@@ -346,7 +346,7 @@ void HeroMovementGoalEngineBase::setSharedFuzzyVariables(Goals::AbstractGoal & g
|
||||
float strengthRatioData = 10.0f; //we are much stronger than enemy
|
||||
ui64 danger = fh->evaluateDanger(goal.tile, goal.hero.h);
|
||||
if(danger)
|
||||
strengthRatioData = (fl::scalar)goal.hero.h->getTotalStrength() / danger;
|
||||
strengthRatioData = static_cast<float>((fl::scalar)goal.hero.h->getTotalStrength() / danger);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -419,7 +419,7 @@ float VisitObjEngine::evaluate(Goals::VisitObj & goal)
|
||||
{
|
||||
objectValue->setValue(objValue);
|
||||
engine.process();
|
||||
output = value->getValue();
|
||||
output = static_cast<float>(value->getValue());
|
||||
}
|
||||
catch(fl::Exception & fe)
|
||||
{
|
||||
@@ -448,7 +448,7 @@ float VisitTileEngine::evaluate(Goals::VisitTile & goal)
|
||||
{
|
||||
engine.process();
|
||||
|
||||
goal.priority = value->getValue();
|
||||
goal.priority = static_cast<float>(value->getValue());
|
||||
}
|
||||
catch(fl::Exception & fe)
|
||||
{
|
||||
|
||||
@@ -115,7 +115,7 @@ float FuzzyHelper::evaluate(Goals::AdventureSpellCast & g)
|
||||
float FuzzyHelper::evaluate(Goals::CompleteQuest & g)
|
||||
{
|
||||
// TODO: How to evaluate quest complexity?
|
||||
const float questPenalty = 0.2;
|
||||
const float questPenalty = 0.2f;
|
||||
|
||||
if(!g.parent)
|
||||
{
|
||||
@@ -150,7 +150,7 @@ float FuzzyHelper::evaluate(Goals::GatherArmy & g)
|
||||
{
|
||||
//the more army we need, the more important goal
|
||||
//the more army we lack, the less important goal
|
||||
float army = g.hero->getArmyStrength();
|
||||
float army = static_cast<float>(g.hero->getArmyStrength());
|
||||
float ratio = g.value / std::max(g.value - army, 2000.0f); //2000 is about the value of hero recruited from tavern
|
||||
return 5 * (ratio / (ratio + 2)); //so 50% army gives 2.5, asymptotic 5
|
||||
}
|
||||
@@ -240,7 +240,7 @@ ui64 FuzzyHelper::evaluateDanger(crint3 tile, const CGHeroInstance * visitor, co
|
||||
if(armedObj)
|
||||
{
|
||||
float tacticalAdvantage = tacticalAdvantageEngine.getTacticalAdvantage(visitor, armedObj);
|
||||
objectDanger *= tacticalAdvantage; //this line tends to go infinite for allied towns (?)
|
||||
objectDanger = static_cast<ui64>(objectDanger * tacticalAdvantage); //this line tends to go infinite for allied towns (?)
|
||||
}
|
||||
}
|
||||
if(dangerousObject->ID == Obj::SUBTERRANEAN_GATE)
|
||||
|
||||
@@ -35,7 +35,7 @@ TSubgoal BuyArmy::whatToDoToAchieve()
|
||||
{
|
||||
//TODO: calculate the actual cost of units instead
|
||||
TResources price;
|
||||
price[Res::GOLD] = value * 0.4f; //some approximate value
|
||||
price[Res::GOLD] = static_cast<int>(value * 0.4f); //some approximate value
|
||||
return ai->ah->whatToDo(price, iAmElementar()); //buy right now or gather resources
|
||||
}
|
||||
|
||||
|
||||
@@ -414,7 +414,7 @@ TSubgoal Explore::exploreNearestNeighbour(HeroPtr h) const
|
||||
|
||||
//look for nearby objs -> visit them if they're close enough
|
||||
const int DIST_LIMIT = 3;
|
||||
const float COST_LIMIT = .2; //todo: fine tune
|
||||
const float COST_LIMIT = .2f; //todo: fine tune
|
||||
|
||||
std::vector<const CGObjectInstance *> nearbyVisitableObjs;
|
||||
for(int x = hpos.x - DIST_LIMIT; x <= hpos.x + DIST_LIMIT; ++x) //get only local objects instead of all possible objects on the map
|
||||
|
||||
@@ -148,7 +148,7 @@ TGoalVec GatherArmy::getAllPossibleSubgoals()
|
||||
{
|
||||
auto dwelling = dynamic_cast<const CGDwelling *>(obj);
|
||||
|
||||
ui32 val = std::min<ui32>(value, ai->ah->howManyReinforcementsCanBuy(hero.get(), dwelling));
|
||||
ui32 val = std::min((ui32)value, (ui32)ai->ah->howManyReinforcementsCanBuy(hero.get(), dwelling));
|
||||
|
||||
if(val)
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ TGoalVec VisitObj::getAllPossibleSubgoals()
|
||||
if(isSafeToVisit(hero, pos))
|
||||
goalList.push_back(sptr(VisitObj(obj->id.getNum()).sethero(hero)));
|
||||
else
|
||||
goalList.push_back(sptr(GatherArmy(fh->evaluateDanger(pos, hero.h) * SAFE_ATTACK_CONSTANT).sethero(hero).setisAbstract(true)));
|
||||
goalList.push_back(sptr(GatherArmy((int)(fh->evaluateDanger(pos, hero.h) * SAFE_ATTACK_CONSTANT)).sethero(hero).setisAbstract(true)));
|
||||
|
||||
return goalList;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ TGoalVec VisitObj::getAllPossibleSubgoals()
|
||||
if(isSafeToVisit(potentialVisitor, pos))
|
||||
goalList.push_back(sptr(VisitObj(obj->id.getNum()).sethero(potentialVisitor)));
|
||||
else
|
||||
goalList.push_back(sptr(GatherArmy(fh->evaluateDanger(pos, potentialVisitor) * SAFE_ATTACK_CONSTANT).sethero(potentialVisitor).setisAbstract(true)));
|
||||
goalList.push_back(sptr(GatherArmy((int)(fh->evaluateDanger(pos, potentialVisitor) * SAFE_ATTACK_CONSTANT)).sethero(potentialVisitor).setisAbstract(true)));
|
||||
}
|
||||
}
|
||||
if(!goalList.empty())
|
||||
|
||||
@@ -49,7 +49,7 @@ TSubgoal VisitTile::whatToDoToAchieve()
|
||||
}
|
||||
else
|
||||
{
|
||||
return sptr(GatherArmy(fh->evaluateDanger(tile, *ret->hero) * SAFE_ATTACK_CONSTANT)
|
||||
return sptr(GatherArmy((int)(fh->evaluateDanger(tile, *ret->hero) * SAFE_ATTACK_CONSTANT))
|
||||
.sethero(ret->hero).setisAbstract(true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
#include "../Goals/AbstractGoal.h"
|
||||
#include "Actions/ISpecialAction.h"
|
||||
|
||||
struct AIPathNode;
|
||||
|
||||
struct AIPathNode : public CGPathNode
|
||||
{
|
||||
uint32_t chainMask;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace AIPathfinding
|
||||
source->manaCost);
|
||||
#endif
|
||||
|
||||
return hero->mana >= source->manaCost + getManaCost(hero);
|
||||
return hero->mana >= (si32)(source->manaCost + getManaCost(hero));
|
||||
}
|
||||
|
||||
uint32_t SummonBoatAction::getManaCost(const CGHeroInstance * hero) const
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "../../AIUtility.h"
|
||||
#include "../../Goals/AbstractGoal.h"
|
||||
|
||||
class AIPathNode;
|
||||
struct AIPathNode;
|
||||
|
||||
class ISpecialAction
|
||||
{
|
||||
|
||||
@@ -178,7 +178,7 @@ Goals::TGoalVec PathfindingManager::findPath(
|
||||
#ifdef VCMI_TRACE_PATHFINDER
|
||||
logAi->trace("Gather army for %s, value=%s", hero->name, std::to_string(danger));
|
||||
#endif
|
||||
result.push_back(sptr(Goals::GatherArmy(danger * SAFE_ATTACK_CONSTANT).sethero(hero).setisAbstract(true)));
|
||||
result.push_back(sptr(Goals::GatherArmy((int)(danger * SAFE_ATTACK_CONSTANT)).sethero(hero).setisAbstract(true)));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace AIPathfinding
|
||||
auto boatNodeOptional = nodeStorage->getOrCreateNode(
|
||||
node->coord,
|
||||
node->layer,
|
||||
node->chainMask | virtualBoat->getSpecialChain());
|
||||
(int)(node->chainMask | virtualBoat->getSpecialChain()));
|
||||
|
||||
if(boatNodeOptional)
|
||||
{
|
||||
|
||||
@@ -631,7 +631,7 @@ void VCAI::showBlockingDialog(const std::string & text, const std::vector<Compon
|
||||
% components.size() % text));
|
||||
|
||||
if(selection) //select from multiple components -> take the last one (they're indexed [1-size])
|
||||
sel = components.size();
|
||||
sel = static_cast<int>(components.size());
|
||||
|
||||
if(!selection && cancel) //yes&no -> always answer yes, we are a brave AI :)
|
||||
sel = 1;
|
||||
@@ -812,6 +812,7 @@ void VCAI::makeTurn()
|
||||
}
|
||||
catch (boost::thread_interrupted & e)
|
||||
{
|
||||
(void)e;
|
||||
logAi->debug("Making turn thread has been interrupted. We'll end without calling endTurn.");
|
||||
return;
|
||||
}
|
||||
@@ -968,6 +969,7 @@ void VCAI::mainLoop()
|
||||
}
|
||||
catch (boost::thread_interrupted & e)
|
||||
{
|
||||
(void)e;
|
||||
logAi->debug("Player %d: Making turn thread received an interruption!", playerID);
|
||||
throw; //rethrow, we want to truly end this thread
|
||||
}
|
||||
@@ -1820,7 +1822,7 @@ bool VCAI::moveHeroToTile(int3 dst, HeroPtr h)
|
||||
logAi->error("Hero %s cannot reach %s.", h->name, dst.toString());
|
||||
throw goalFulfilledException(sptr(Goals::VisitTile(dst).sethero(h)));
|
||||
}
|
||||
int i = path.nodes.size() - 1;
|
||||
int i = (int)path.nodes.size() - 1;
|
||||
|
||||
auto getObj = [&](int3 coord, bool ignoreHero)
|
||||
{
|
||||
@@ -2112,12 +2114,12 @@ void VCAI::tryRealize(Goals::Trade & g) //trade
|
||||
|
||||
int toGive, toGet;
|
||||
m->getOffer(res, g.resID, toGive, toGet, EMarketMode::RESOURCE_RESOURCE);
|
||||
toGive = toGive * (it->resVal / toGive); //round down
|
||||
toGive = static_cast<int>(toGive * (it->resVal / toGive)); //round down
|
||||
//TODO trade only as much as needed
|
||||
if (toGive) //don't try to sell 0 resources
|
||||
{
|
||||
cb->trade(obj, EMarketMode::RESOURCE_RESOURCE, res, g.resID, toGive);
|
||||
accquiredResources = toGet * (it->resVal / toGive);
|
||||
accquiredResources = static_cast<int>(toGet * (it->resVal / toGive));
|
||||
logAi->debug("Traded %d of %s for %d of %s at %s", toGive, res, accquiredResources, g.resID, obj->getObjectName());
|
||||
}
|
||||
if (ah->freeResources()[g.resID] >= g.value)
|
||||
@@ -2330,6 +2332,7 @@ void VCAI::striveToGoal(Goals::TSubgoal basicGoal)
|
||||
}
|
||||
catch (boost::thread_interrupted & e)
|
||||
{
|
||||
(void)e;
|
||||
logAi->debug("Player %d: Making turn thread received an interruption!", playerID);
|
||||
throw; //rethrow, we want to truly end this thread
|
||||
}
|
||||
@@ -2625,7 +2628,7 @@ void AIStatus::removeQuery(QueryID ID)
|
||||
int AIStatus::getQueriesCount()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mx);
|
||||
return remainingQueries.size();
|
||||
return static_cast<int>(remainingQueries.size());
|
||||
}
|
||||
|
||||
void AIStatus::startedTurn()
|
||||
|
||||
Reference in New Issue
Block a user