mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-28 23:06:24 +02:00
commit
29a78c14a2
2
.github/workflows/github.yml
vendored
2
.github/workflows/github.yml
vendored
@ -148,7 +148,7 @@ jobs:
|
||||
- name: Ensure LF line endings
|
||||
if: ${{ startsWith(matrix.preset, 'linux-clang-test') }}
|
||||
run: |
|
||||
find . -path ./.git -prune -o -path ./AI/FuzzyLite -prune -prune -o -path ./test/googletest \
|
||||
find . -path ./.git -prune -o -path ./AI/FuzzyLite -prune -o -path ./test/googletest \
|
||||
-o -path ./osx -prune -o -type f \
|
||||
-not -name '*.png' -and -not -name '*.vcxproj*' -and -not -name '*.props' -and -not -name '*.wav' -and -not -name '*.ico' -and -not -name '*.bat' -print0 | \
|
||||
{ ! xargs -0 grep -l -z -P '\r\n'; }
|
||||
|
@ -197,7 +197,7 @@ BattleAction CBattleAI::useCatapult(const BattleID & battleID, const CStack * st
|
||||
}
|
||||
else
|
||||
{
|
||||
EWallPart wallParts[] = {
|
||||
std::array wallParts {
|
||||
EWallPart::KEEP,
|
||||
EWallPart::BOTTOM_TOWER,
|
||||
EWallPart::UPPER_TOWER,
|
||||
|
@ -58,7 +58,7 @@ std::vector<BattleHex> BattleEvaluator::getBrokenWallMoatHexes() const
|
||||
if(state != EWallState::DESTROYED)
|
||||
continue;
|
||||
|
||||
auto wallHex = cb->getBattle(battleID)->wallPartToBattleHex((EWallPart)wallPart);
|
||||
auto wallHex = cb->getBattle(battleID)->wallPartToBattleHex(wallPart);
|
||||
auto moatHex = wallHex.cloneInDirection(BattleHex::LEFT);
|
||||
|
||||
result.push_back(moatHex);
|
||||
@ -142,7 +142,7 @@ BattleAction BattleEvaluator::selectStackAction(const CStack * stack)
|
||||
logAi->debug("BattleAI: %s -> %s x %d, from %d curpos %d dist %d speed %d: +%2f -%2f = %2f",
|
||||
bestAttack.attackerState->unitType()->getJsonKey(),
|
||||
bestAttack.affectedUnits[0]->unitType()->getJsonKey(),
|
||||
(int)bestAttack.affectedUnits[0]->getCount(),
|
||||
bestAttack.affectedUnits[0]->getCount(),
|
||||
(int)bestAttack.from,
|
||||
(int)bestAttack.attack.attacker->getPosition().hex,
|
||||
bestAttack.attack.chargeDistance,
|
||||
@ -315,7 +315,7 @@ BattleAction BattleEvaluator::goTowardsNearest(const CStack * stack, std::vector
|
||||
else
|
||||
{
|
||||
BattleHex currentDest = bestNeighbor;
|
||||
while(1)
|
||||
while(true)
|
||||
{
|
||||
if(!currentDest.isValid())
|
||||
{
|
||||
|
@ -12,9 +12,9 @@
|
||||
#include "../../lib/CStack.h"
|
||||
|
||||
AttackerValue::AttackerValue()
|
||||
: value(0),
|
||||
isRetalitated(false)
|
||||
{
|
||||
value = 0;
|
||||
isRetalitated = false;
|
||||
}
|
||||
|
||||
MoveTarget::MoveTarget()
|
||||
@ -354,7 +354,7 @@ MoveTarget BattleExchangeEvaluator::findMoveTowardsUnreachable(
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<const battle::Unit *> BattleExchangeEvaluator::getAdjacentUnits(const battle::Unit * blockerUnit)
|
||||
std::vector<const battle::Unit *> BattleExchangeEvaluator::getAdjacentUnits(const battle::Unit * blockerUnit) const
|
||||
{
|
||||
std::queue<const battle::Unit *> queue;
|
||||
std::vector<const battle::Unit *> checkedStacks;
|
||||
|
@ -186,7 +186,7 @@ public:
|
||||
DamageCache & damageCache,
|
||||
std::shared_ptr<HypotheticBattle> hb);
|
||||
|
||||
std::vector<const battle::Unit *> getAdjacentUnits(const battle::Unit * unit);
|
||||
std::vector<const battle::Unit *> getAdjacentUnits(const battle::Unit * unit) const;
|
||||
|
||||
float getPositiveEffectMultiplier() const { return 1; }
|
||||
float getNegativeEffectMultiplier() const { return negativeEffectMultiplier; }
|
||||
|
@ -15,7 +15,7 @@
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
HitMapInfo HitMapInfo::NoTreat;
|
||||
HitMapInfo HitMapInfo::NoThreat;
|
||||
|
||||
double HitMapInfo::value() const
|
||||
{
|
||||
@ -39,7 +39,7 @@ void DangerHitMapAnalyzer::updateHitMap()
|
||||
hitMap.resize(boost::extents[mapSize.x][mapSize.y][mapSize.z]);
|
||||
|
||||
enemyHeroAccessibleObjects.clear();
|
||||
townTreats.clear();
|
||||
townThreats.clear();
|
||||
|
||||
std::map<PlayerColor, std::map<const CGHeroInstance *, HeroRole>> heroes;
|
||||
|
||||
@ -57,7 +57,7 @@ void DangerHitMapAnalyzer::updateHitMap()
|
||||
|
||||
for(auto town : ourTowns)
|
||||
{
|
||||
townTreats[town->id]; // insert empty list
|
||||
townThreats[town->id]; // insert empty list
|
||||
}
|
||||
|
||||
foreach_tile_pos([&](const int3 & pos){
|
||||
@ -91,21 +91,21 @@ void DangerHitMapAnalyzer::updateHitMap()
|
||||
|
||||
auto & node = hitMap[pos.x][pos.y][pos.z];
|
||||
|
||||
HitMapInfo newTreat;
|
||||
HitMapInfo newThreat;
|
||||
|
||||
newTreat.hero = path.targetHero;
|
||||
newTreat.turn = path.turn();
|
||||
newTreat.danger = path.getHeroStrength();
|
||||
newThreat.hero = path.targetHero;
|
||||
newThreat.turn = path.turn();
|
||||
newThreat.danger = path.getHeroStrength();
|
||||
|
||||
if(newTreat.value() > node.maximumDanger.value())
|
||||
if(newThreat.value() > node.maximumDanger.value())
|
||||
{
|
||||
node.maximumDanger = newTreat;
|
||||
node.maximumDanger = newThreat;
|
||||
}
|
||||
|
||||
if(newTreat.turn < node.fastestDanger.turn
|
||||
|| (newTreat.turn == node.fastestDanger.turn && node.fastestDanger.danger < newTreat.danger))
|
||||
if(newThreat.turn < node.fastestDanger.turn
|
||||
|| (newThreat.turn == node.fastestDanger.turn && node.fastestDanger.danger < newThreat.danger))
|
||||
{
|
||||
node.fastestDanger = newTreat;
|
||||
node.fastestDanger = newThreat;
|
||||
}
|
||||
|
||||
auto objects = cb->getVisitableObjs(pos, false);
|
||||
@ -114,24 +114,24 @@ void DangerHitMapAnalyzer::updateHitMap()
|
||||
{
|
||||
if(obj->ID == Obj::TOWN && obj->getOwner() == ai->playerID)
|
||||
{
|
||||
auto & treats = townTreats[obj->id];
|
||||
auto treat = std::find_if(treats.begin(), treats.end(), [&](const HitMapInfo & i) -> bool
|
||||
auto & threats = townThreats[obj->id];
|
||||
auto threat = std::find_if(threats.begin(), threats.end(), [&](const HitMapInfo & i) -> bool
|
||||
{
|
||||
return i.hero.hid == path.targetHero->id;
|
||||
});
|
||||
|
||||
if(treat == treats.end())
|
||||
if(threat == threats.end())
|
||||
{
|
||||
treats.emplace_back();
|
||||
treat = std::prev(treats.end(), 1);
|
||||
threats.emplace_back();
|
||||
threat = std::prev(threats.end(), 1);
|
||||
}
|
||||
|
||||
if(newTreat.value() > treat->value())
|
||||
if(newThreat.value() > threat->value())
|
||||
{
|
||||
*treat = newTreat;
|
||||
*threat = newThreat;
|
||||
}
|
||||
|
||||
if(newTreat.turn == 0)
|
||||
if(newThreat.turn == 0)
|
||||
{
|
||||
if(cb->getPlayerRelations(obj->tempOwner, ai->playerID) != PlayerRelations::ENEMIES)
|
||||
enemyHeroAccessibleObjects.emplace_back(path.targetHero, obj);
|
||||
@ -240,13 +240,13 @@ void DangerHitMapAnalyzer::calculateTileOwners()
|
||||
});
|
||||
}
|
||||
|
||||
const std::vector<HitMapInfo> & DangerHitMapAnalyzer::getTownTreats(const CGTownInstance * town) const
|
||||
const std::vector<HitMapInfo> & DangerHitMapAnalyzer::getTownThreats(const CGTownInstance * town) const
|
||||
{
|
||||
static const std::vector<HitMapInfo> empty = {};
|
||||
|
||||
auto result = townTreats.find(town->id);
|
||||
auto result = townThreats.find(town->id);
|
||||
|
||||
return result == townTreats.end() ? empty : result->second;
|
||||
return result == townThreats.end() ? empty : result->second;
|
||||
}
|
||||
|
||||
PlayerColor DangerHitMapAnalyzer::getTileOwner(const int3 & tile) const
|
||||
@ -271,14 +271,14 @@ uint64_t DangerHitMapAnalyzer::enemyCanKillOurHeroesAlongThePath(const AIPath &
|
||||
|| (info.maximumDanger.turn <= turn && !isSafeToVisit(path.targetHero, path.heroArmy, info.maximumDanger.danger));
|
||||
}
|
||||
|
||||
const HitMapNode & DangerHitMapAnalyzer::getObjectTreat(const CGObjectInstance * obj) const
|
||||
const HitMapNode & DangerHitMapAnalyzer::getObjectThreat(const CGObjectInstance * obj) const
|
||||
{
|
||||
auto tile = obj->visitablePos();
|
||||
|
||||
return getTileTreat(tile);
|
||||
return getTileThreat(tile);
|
||||
}
|
||||
|
||||
const HitMapNode & DangerHitMapAnalyzer::getTileTreat(const int3 & tile) const
|
||||
const HitMapNode & DangerHitMapAnalyzer::getTileThreat(const int3 & tile) const
|
||||
{
|
||||
const HitMapNode & info = hitMap[tile.x][tile.y][tile.z];
|
||||
|
||||
|
@ -18,7 +18,7 @@ struct AIPath;
|
||||
|
||||
struct HitMapInfo
|
||||
{
|
||||
static HitMapInfo NoTreat;
|
||||
static HitMapInfo NoThreat;
|
||||
|
||||
uint64_t danger;
|
||||
uint8_t turn;
|
||||
@ -74,7 +74,7 @@ private:
|
||||
bool hitMapUpToDate = false;
|
||||
bool tileOwnersUpToDate = false;
|
||||
const Nullkiller * ai;
|
||||
std::map<ObjectInstanceID, std::vector<HitMapInfo>> townTreats;
|
||||
std::map<ObjectInstanceID, std::vector<HitMapInfo>> townThreats;
|
||||
|
||||
public:
|
||||
DangerHitMapAnalyzer(const Nullkiller * ai) :ai(ai) {}
|
||||
@ -82,14 +82,14 @@ public:
|
||||
void updateHitMap();
|
||||
void calculateTileOwners();
|
||||
uint64_t enemyCanKillOurHeroesAlongThePath(const AIPath & path) const;
|
||||
const HitMapNode & getObjectTreat(const CGObjectInstance * obj) const;
|
||||
const HitMapNode & getTileTreat(const int3 & tile) const;
|
||||
const HitMapNode & getObjectThreat(const CGObjectInstance * obj) const;
|
||||
const HitMapNode & getTileThreat(const int3 & tile) const;
|
||||
std::set<const CGObjectInstance *> getOneTurnAccessibleObjects(const CGHeroInstance * enemy) const;
|
||||
void reset();
|
||||
void resetTileOwners() { tileOwnersUpToDate = false; }
|
||||
PlayerColor getTileOwner(const int3 & tile) const;
|
||||
const CGTownInstance * getClosestTown(const int3 & tile) const;
|
||||
const std::vector<HitMapInfo> & getTownTreats(const CGTownInstance * town) const;
|
||||
const std::vector<HitMapInfo> & getTownThreats(const CGTownInstance * town) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
namespace NKAI
|
||||
{
|
||||
|
||||
const float TREAT_IGNORE_RATIO = 2;
|
||||
const float THREAT_IGNORE_RATIO = 2;
|
||||
|
||||
using namespace Goals;
|
||||
|
||||
@ -46,20 +46,20 @@ Goals::TGoalVec DefenceBehavior::decompose() const
|
||||
return tasks;
|
||||
}
|
||||
|
||||
bool isTreatUnderControl(const CGTownInstance * town, const HitMapInfo & treat, const std::vector<AIPath> & paths)
|
||||
bool isThreatUnderControl(const CGTownInstance * town, const HitMapInfo & threat, const std::vector<AIPath> & paths)
|
||||
{
|
||||
int dayOfWeek = cb->getDate(Date::DAY_OF_WEEK);
|
||||
|
||||
for(const AIPath & path : paths)
|
||||
{
|
||||
bool treatIsWeak = path.getHeroStrength() / (float)treat.danger > TREAT_IGNORE_RATIO;
|
||||
bool needToSaveGrowth = treat.turn == 0 && dayOfWeek == 7;
|
||||
bool threatIsWeak = path.getHeroStrength() / (float)threat.danger > THREAT_IGNORE_RATIO;
|
||||
bool needToSaveGrowth = threat.turn == 0 && dayOfWeek == 7;
|
||||
|
||||
if(treatIsWeak && !needToSaveGrowth)
|
||||
if(threatIsWeak && !needToSaveGrowth)
|
||||
{
|
||||
if((path.exchangeCount == 1 && path.turn() < treat.turn)
|
||||
|| path.turn() < treat.turn - 1
|
||||
|| (path.turn() < treat.turn && treat.turn >= 2))
|
||||
if((path.exchangeCount == 1 && path.turn() < threat.turn)
|
||||
|| path.turn() < threat.turn - 1
|
||||
|| (path.turn() < threat.turn && threat.turn >= 2))
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
logAi->trace(
|
||||
@ -79,16 +79,16 @@ bool isTreatUnderControl(const CGTownInstance * town, const HitMapInfo & treat,
|
||||
|
||||
void handleCounterAttack(
|
||||
const CGTownInstance * town,
|
||||
const HitMapInfo & treat,
|
||||
const HitMapInfo & threat,
|
||||
const HitMapInfo & maximumDanger,
|
||||
Goals::TGoalVec & tasks)
|
||||
{
|
||||
if(treat.hero.validAndSet()
|
||||
&& treat.turn <= 1
|
||||
&& (treat.danger == maximumDanger.danger || treat.turn < maximumDanger.turn))
|
||||
if(threat.hero.validAndSet()
|
||||
&& threat.turn <= 1
|
||||
&& (threat.danger == maximumDanger.danger || threat.turn < maximumDanger.turn))
|
||||
{
|
||||
auto heroCapturingPaths = ai->nullkiller->pathfinder->getPathInfo(treat.hero->visitablePos());
|
||||
auto goals = CaptureObjectsBehavior::getVisitGoals(heroCapturingPaths, treat.hero.get());
|
||||
auto heroCapturingPaths = ai->nullkiller->pathfinder->getPathInfo(threat.hero->visitablePos());
|
||||
auto goals = CaptureObjectsBehavior::getVisitGoals(heroCapturingPaths, threat.hero.get());
|
||||
|
||||
for(int i = 0; i < heroCapturingPaths.size(); i++)
|
||||
{
|
||||
@ -99,7 +99,7 @@ void handleCounterAttack(
|
||||
|
||||
Composition composition;
|
||||
|
||||
composition.addNext(DefendTown(town, treat, path, true)).addNext(goal);
|
||||
composition.addNext(DefendTown(town, threat, path, true)).addNext(goal);
|
||||
|
||||
tasks.push_back(Goals::sptr(composition));
|
||||
}
|
||||
@ -152,19 +152,19 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
{
|
||||
logAi->trace("Evaluating defence for %s", town->getNameTranslated());
|
||||
|
||||
auto treatNode = ai->nullkiller->dangerHitMap->getObjectTreat(town);
|
||||
std::vector<HitMapInfo> treats = ai->nullkiller->dangerHitMap->getTownTreats(town);
|
||||
auto threatNode = ai->nullkiller->dangerHitMap->getObjectThreat(town);
|
||||
std::vector<HitMapInfo> threats = ai->nullkiller->dangerHitMap->getTownThreats(town);
|
||||
|
||||
treats.push_back(treatNode.fastestDanger); // no guarantee that fastest danger will be there
|
||||
threats.push_back(threatNode.fastestDanger); // no guarantee that fastest danger will be there
|
||||
|
||||
if(town->garrisonHero && handleGarrisonHeroFromPreviousTurn(town, tasks))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!treatNode.fastestDanger.hero)
|
||||
if(!threatNode.fastestDanger.hero)
|
||||
{
|
||||
logAi->trace("No treat found for town %s", town->getNameTranslated());
|
||||
logAi->trace("No threat found for town %s", town->getNameTranslated());
|
||||
|
||||
return;
|
||||
}
|
||||
@ -179,23 +179,23 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
|
||||
auto paths = ai->nullkiller->pathfinder->getPathInfo(town->visitablePos());
|
||||
|
||||
for(auto & treat : treats)
|
||||
for(auto & threat : threats)
|
||||
{
|
||||
logAi->trace(
|
||||
"Town %s has treat %lld in %s turns, hero: %s",
|
||||
"Town %s has threat %lld in %s turns, hero: %s",
|
||||
town->getNameTranslated(),
|
||||
treat.danger,
|
||||
std::to_string(treat.turn),
|
||||
treat.hero ? treat.hero->getNameTranslated() : std::string("<no hero>"));
|
||||
threat.danger,
|
||||
std::to_string(threat.turn),
|
||||
threat.hero ? threat.hero->getNameTranslated() : std::string("<no hero>"));
|
||||
|
||||
handleCounterAttack(town, treat, treatNode.maximumDanger, tasks);
|
||||
handleCounterAttack(town, threat, threatNode.maximumDanger, tasks);
|
||||
|
||||
if(isTreatUnderControl(town, treat, paths))
|
||||
if(isThreatUnderControl(town, threat, paths))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
evaluateRecruitingHero(tasks, treat, town);
|
||||
evaluateRecruitingHero(tasks, threat, town);
|
||||
|
||||
if(paths.empty())
|
||||
{
|
||||
@ -236,7 +236,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
continue;
|
||||
}
|
||||
|
||||
if(path.turn() <= treat.turn - 2)
|
||||
if(path.turn() <= threat.turn - 2)
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Defer defence of %s by %s because he has enough time to reach the town next trun",
|
||||
@ -264,7 +264,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
{
|
||||
tasks.push_back(
|
||||
Goals::sptr(Composition()
|
||||
.addNext(DefendTown(town, treat, path.targetHero))
|
||||
.addNext(DefendTown(town, threat, path.targetHero))
|
||||
.addNext(ExchangeSwapTownHeroes(town, town->visitingHero.get(), HeroLockedReason::DEFENCE))));
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
|
||||
tasks.push_back(
|
||||
Goals::sptr(Composition()
|
||||
.addNext(DefendTown(town, treat, path))
|
||||
.addNext(DefendTown(town, threat, path))
|
||||
.addNextSequence({
|
||||
sptr(ExchangeSwapTownHeroes(town, town->visitingHero.get())),
|
||||
sptr(ExecuteHeroChain(path, town)),
|
||||
@ -291,7 +291,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(threat.turn == 0 || (path.turn() <= threat.turn && path.getHeroStrength() * SAFE_ATTACK_CONSTANT >= threat.danger))
|
||||
{
|
||||
if(ai->nullkiller->arePathHeroesLocked(path))
|
||||
{
|
||||
@ -324,7 +324,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
}
|
||||
Composition composition;
|
||||
|
||||
composition.addNext(DefendTown(town, treat, path));
|
||||
composition.addNext(DefendTown(town, threat, path));
|
||||
TGoalVec sequence;
|
||||
|
||||
if(town->garrisonHero && path.targetHero == town->garrisonHero.get() && path.exchangeCount == 1)
|
||||
@ -402,7 +402,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
logAi->debug("Found %d tasks", tasks.size());
|
||||
}
|
||||
|
||||
void DefenceBehavior::evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitMapInfo & treat, const CGTownInstance * town) const
|
||||
void DefenceBehavior::evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitMapInfo & threat, const CGTownInstance * town) const
|
||||
{
|
||||
if(town->hasBuilt(BuildingID::TAVERN)
|
||||
&& cb->getResourceAmount(EGameResID::GOLD) > GameConstants::HERO_GOLD_COST)
|
||||
@ -411,7 +411,7 @@ void DefenceBehavior::evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitM
|
||||
|
||||
for(auto hero : heroesInTavern)
|
||||
{
|
||||
if(hero->getTotalStrength() < treat.danger)
|
||||
if(hero->getTotalStrength() < threat.danger)
|
||||
continue;
|
||||
|
||||
auto myHeroes = cb->getHeroesInfo();
|
||||
@ -463,7 +463,7 @@ void DefenceBehavior::evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitM
|
||||
|
||||
sequence.push_back(sptr(Goals::RecruitHero(town, hero)));
|
||||
|
||||
tasks.push_back(sptr(Goals::Composition().addNext(DefendTown(town, treat, hero)).addNextSequence(sequence)));
|
||||
tasks.push_back(sptr(Goals::Composition().addNext(DefendTown(town, threat, hero)).addNextSequence(sequence)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* BuyArmyBehavior.h, part of VCMI engine
|
||||
* DefenceBehavior.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
@ -39,7 +39,7 @@ namespace Goals
|
||||
|
||||
private:
|
||||
void evaluateDefence(Goals::TGoalVec & tasks, const CGTownInstance * town) const;
|
||||
void evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitMapInfo & treat, const CGTownInstance * town) const;
|
||||
void evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitMapInfo & threat, const CGTownInstance * town) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -593,15 +593,15 @@ float RewardEvaluator::getSkillReward(const CGObjectInstance * target, const CGH
|
||||
|
||||
const HitMapInfo & RewardEvaluator::getEnemyHeroDanger(const int3 & tile, uint8_t turn) const
|
||||
{
|
||||
auto & treatNode = ai->dangerHitMap->getTileTreat(tile);
|
||||
auto & treatNode = ai->dangerHitMap->getTileThreat(tile);
|
||||
|
||||
if(treatNode.maximumDanger.danger == 0)
|
||||
return HitMapInfo::NoTreat;
|
||||
return HitMapInfo::NoThreat;
|
||||
|
||||
if(treatNode.maximumDanger.turn <= turn)
|
||||
return treatNode.maximumDanger;
|
||||
|
||||
return treatNode.fastestDanger.turn <= turn ? treatNode.fastestDanger : HitMapInfo::NoTreat;
|
||||
return treatNode.fastestDanger.turn <= turn ? treatNode.fastestDanger : HitMapInfo::NoThreat;
|
||||
}
|
||||
|
||||
int32_t getArmyCost(const CArmedInstance * army)
|
||||
|
@ -1511,7 +1511,7 @@ void VCAI::wander(HeroPtr h)
|
||||
if(e.goal->goalType == Goals::EGoals::VISIT_TILE || e.goal->goalType == Goals::EGoals::VISIT_OBJ)
|
||||
continue;
|
||||
|
||||
throw e;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -260,7 +260,7 @@ public:
|
||||
//optimization - use one SM for every hero call
|
||||
|
||||
const CGTownInstance * findTownWithTavern() const;
|
||||
bool canRecruitAnyHero(const CGTownInstance * t = NULL) const;
|
||||
bool canRecruitAnyHero(const CGTownInstance * t = nullptr) const;
|
||||
|
||||
Goals::TSubgoal getGoal(HeroPtr h) const;
|
||||
bool canAct(HeroPtr h) const;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
//VCMI PROJECT CODE CONTRIBUTORS:
|
||||
std::vector<std::vector<std::string>> contributors = {
|
||||
const std::vector<std::vector<std::string>> contributors = {
|
||||
// Task Name Aka E-Mail
|
||||
{ "Idea", "Michał Urbańczyk", "Tow", "impono@gmail.com" },
|
||||
{ "Idea", "Mateusz B.", "Tow dragon", "matcio1@gmail.com" },
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from pprint import pprint
|
||||
|
||||
@ -12,19 +13,19 @@ import yaml
|
||||
# json: strict, but doesn't preserve line numbers necessarily, since it strips comments before parsing
|
||||
# json5: strict and preserves line numbers even for files with line comments
|
||||
# yaml: less strict, allows e.g. leading zeros
|
||||
VALIDATION_TYPE = 'json5'
|
||||
VALIDATION_TYPE = "json5"
|
||||
|
||||
errors = []
|
||||
for path in sorted(Path('.').glob('**/*.json')):
|
||||
for path in sorted(Path(".").glob("**/*.json")):
|
||||
# because path is an object and not a string
|
||||
path_str = str(path)
|
||||
try:
|
||||
with open(path_str, 'r') as file:
|
||||
if VALIDATION_TYPE == 'json':
|
||||
with open(path_str, "r") as file:
|
||||
if VALIDATION_TYPE == "json":
|
||||
jstyleson.load(file)
|
||||
elif VALIDATION_TYPE == 'json5':
|
||||
elif VALIDATION_TYPE == "json5":
|
||||
json5.load(file)
|
||||
elif VALIDATION_TYPE == 'yaml':
|
||||
elif VALIDATION_TYPE == "yaml":
|
||||
file = file.read().replace("\t", " ")
|
||||
file = file.replace("//", "#")
|
||||
yaml.safe_load(file)
|
||||
@ -36,16 +37,16 @@ for path in sorted(Path('.').glob('**/*.json')):
|
||||
error_pos = path_str
|
||||
|
||||
# create error position strings for each type of parser
|
||||
if hasattr(exc, 'pos'):
|
||||
if hasattr(exc, "pos"):
|
||||
# 'json'
|
||||
# https://stackoverflow.com/a/72850269/2278742
|
||||
error_pos = f"{path_str}:{exc.lineno}:{exc.colno}"
|
||||
print(error_pos)
|
||||
elif VALIDATION_TYPE == 'json5':
|
||||
elif VALIDATION_TYPE == "json5":
|
||||
# 'json5'
|
||||
pos = re.findall(r'\d+', str(exc))
|
||||
pos = re.findall(r"\d+", str(exc))
|
||||
error_pos = f"{path_str}:{pos[0]}:{pos[-1]}"
|
||||
elif hasattr(exc, 'problem_mark'):
|
||||
elif hasattr(exc, "problem_mark"):
|
||||
# 'yaml'
|
||||
mark = exc.problem_mark
|
||||
error_pos = f"{path_str}:{mark.line+1}:{mark.column+1}"
|
||||
@ -54,6 +55,6 @@ for path in sorted(Path('.').glob('**/*.json')):
|
||||
errors.append({"error_pos": error_pos, "error_msg": exc})
|
||||
|
||||
if errors:
|
||||
print("Summary of errors:")
|
||||
print("The following JSON files are invalid:")
|
||||
pprint(errors)
|
||||
raise Exception("Not all JSON files are valid")
|
||||
sys.exit(1)
|
||||
|
@ -86,7 +86,7 @@ static void prog_version()
|
||||
|
||||
static void prog_help(const po::options_description &opts)
|
||||
{
|
||||
auto time = std::time(0);
|
||||
auto time = std::time(nullptr);
|
||||
printf("%s - A Heroes of Might and Magic 3 clone\n", GameConstants::VCMI_VERSION.c_str());
|
||||
printf("Copyright (C) 2007-%d VCMI dev team - see AUTHORS file\n", std::localtime(&time)->tm_year + 1900);
|
||||
printf("This is free software; see the source for copying conditions. There is NO\n");
|
||||
|
@ -305,7 +305,7 @@ bool CVideoPlayer::nextFrame()
|
||||
sws_scale(sws, frame->data, frame->linesize,
|
||||
0, codecContext->height, data, linesize);
|
||||
|
||||
SDL_UpdateYUVTexture(texture, NULL, data[0], linesize[0],
|
||||
SDL_UpdateYUVTexture(texture, nullptr, data[0], linesize[0],
|
||||
data[1], linesize[1],
|
||||
data[2], linesize[2]);
|
||||
av_freep(&data[0]);
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
class IMainVideoPlayer : public IVideoPlayer
|
||||
{
|
||||
public:
|
||||
virtual void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true, std::function<void()> restart = 0){}
|
||||
virtual void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true, std::function<void()> restart = nullptr){}
|
||||
virtual bool openAndPlayVideo(const VideoPath & name, int x, int y, bool stopOnKey = false, bool scale = false)
|
||||
{
|
||||
return false;
|
||||
|
@ -698,7 +698,7 @@ void CClient::reinitScripting()
|
||||
#endif
|
||||
}
|
||||
|
||||
void CClient::removeGUI()
|
||||
void CClient::removeGUI() const
|
||||
{
|
||||
// CClient::endGame
|
||||
GH.curInt = nullptr;
|
||||
|
@ -216,7 +216,7 @@ public:
|
||||
|
||||
void showInfoDialog(InfoWindow * iw) override {};
|
||||
void showInfoDialog(const std::string & msg, PlayerColor player) override {};
|
||||
void removeGUI();
|
||||
void removeGUI() const;
|
||||
|
||||
#if SCRIPTING_ENABLED
|
||||
scripting::Pool * getGlobalContextPool() const override;
|
||||
|
@ -367,19 +367,21 @@ void ApplyClientNetPackVisitor::visitGiveBonus(GiveBonus & pack)
|
||||
void ApplyFirstClientNetPackVisitor::visitChangeObjPos(ChangeObjPos & pack)
|
||||
{
|
||||
CGObjectInstance *obj = gs.getObjInstance(pack.objid);
|
||||
if(CGI->mh)
|
||||
if(CGI && CGI->mh)
|
||||
{
|
||||
CGI->mh->onObjectFadeOut(obj, pack.initiator);
|
||||
|
||||
CGI->mh->waitForOngoingAnimations();
|
||||
CGI->mh->waitForOngoingAnimations();
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyClientNetPackVisitor::visitChangeObjPos(ChangeObjPos & pack)
|
||||
{
|
||||
CGObjectInstance *obj = gs.getObjInstance(pack.objid);
|
||||
if(CGI->mh)
|
||||
if(CGI && CGI->mh)
|
||||
{
|
||||
CGI->mh->onObjectFadeIn(obj, pack.initiator);
|
||||
|
||||
CGI->mh->waitForOngoingAnimations();
|
||||
CGI->mh->waitForOngoingAnimations();
|
||||
}
|
||||
cl.invalidatePaths();
|
||||
}
|
||||
|
||||
|
@ -28,13 +28,10 @@ void FramerateManager::framerateDelay()
|
||||
{
|
||||
Duration timeSpentBusy = Clock::now() - lastTimePoint;
|
||||
|
||||
if(!vsyncEnabled)
|
||||
if(!vsyncEnabled && timeSpentBusy < targetFrameTime)
|
||||
{
|
||||
// if FPS is higher than it should be, then wait some time
|
||||
if(timeSpentBusy < targetFrameTime)
|
||||
{
|
||||
boost::this_thread::sleep_for(targetFrameTime - timeSpentBusy);
|
||||
}
|
||||
boost::this_thread::sleep_for(targetFrameTime - timeSpentBusy);
|
||||
}
|
||||
|
||||
// compute actual timeElapsed taking into account actual sleep interval
|
||||
|
@ -3,7 +3,7 @@ import os, sys, shutil
|
||||
|
||||
img = Image.open(sys.argv[1])
|
||||
if img.size != (1024,1024):
|
||||
print "Input image must be 1024x1024. Provided image is %dx%d" % img.size
|
||||
print("Input image must be 1024x1024. Provided image is %dx%d" % img.size)
|
||||
|
||||
os.mkdir("vcmi.iconset")
|
||||
for i in [16, 32, 128, 256, 512]:
|
||||
|
@ -264,7 +264,7 @@ int CHighScoreInputScreen::addEntry(std::string text) {
|
||||
newNode["scenarioName"].String() = calc.calculate().cheater ? CGI->generaltexth->translate("core.genrltxt.260") : calc.parameters[0].scenarioName;
|
||||
newNode["days"].Integer() = calc.calculate().sumDays;
|
||||
newNode["points"].Integer() = calc.calculate().cheater ? 0 : calc.calculate().total;
|
||||
newNode["datetime"].String() = vstd::getFormattedDateTime(std::time(0));
|
||||
newNode["datetime"].String() = vstd::getFormattedDateTime(std::time(nullptr));
|
||||
newNode["posFlag"].Bool() = true;
|
||||
|
||||
baseNode.push_back(newNode);
|
||||
|
@ -59,7 +59,7 @@ void CursorSoftware::updateTexture()
|
||||
CSDL_Ext::fillSurface(cursorSurface, CSDL_Ext::toSDL(Colors::TRANSPARENCY));
|
||||
|
||||
cursorImage->draw(cursorSurface);
|
||||
SDL_UpdateTexture(cursorTexture, NULL, cursorSurface->pixels, cursorSurface->pitch);
|
||||
SDL_UpdateTexture(cursorTexture, nullptr, cursorSurface->pixels, cursorSurface->pitch);
|
||||
needUpdate = false;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ void CSDL_Ext::updateRect(SDL_Surface *surface, const Rect & rect )
|
||||
logGlobal->error("%sSDL_UpdateTexture %s", __FUNCTION__, SDL_GetError());
|
||||
|
||||
SDL_RenderClear(mainRenderer);
|
||||
if(0 != SDL_RenderCopy(mainRenderer, screenTexture, NULL, NULL))
|
||||
if(0 != SDL_RenderCopy(mainRenderer, screenTexture, nullptr, nullptr))
|
||||
logGlobal->error("%sSDL_RenderCopy %s", __FUNCTION__, SDL_GetError());
|
||||
SDL_RenderPresent(mainRenderer);
|
||||
|
||||
@ -813,8 +813,8 @@ void CSDL_Ext::fillRectBlended( SDL_Surface *dst, const Rect & dstrect, const SD
|
||||
uint32_t sdlColor = SDL_MapRGBA(dst->format, color.r, color.g, color.b, color.a);
|
||||
|
||||
SDL_Surface * tmp = SDL_CreateRGBSurface(0, newRect.w, newRect.h, dst->format->BitsPerPixel, dst->format->Rmask, dst->format->Gmask, dst->format->Bmask, dst->format->Amask);
|
||||
SDL_FillRect(tmp, NULL, sdlColor);
|
||||
SDL_BlitSurface(tmp, NULL, dst, &newRect);
|
||||
SDL_FillRect(tmp, nullptr, sdlColor);
|
||||
SDL_BlitSurface(tmp, nullptr, dst, &newRect);
|
||||
SDL_FreeSurface(tmp);
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ void CButton::setBorderColor(std::optional<ColorRGBA> newBorderColor)
|
||||
borderColor = newBorderColor;
|
||||
}
|
||||
|
||||
void CButton::addCallback(std::function<void()> callback)
|
||||
void CButton::addCallback(const std::function<void()> & callback)
|
||||
{
|
||||
this->callback += callback;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
void setBorderColor(std::optional<ColorRGBA> borderColor);
|
||||
|
||||
/// adds one more callback to on-click actions
|
||||
void addCallback(std::function<void()> callback);
|
||||
void addCallback(const std::function<void()> & callback);
|
||||
|
||||
/// adds overlay on top of button image. Only one overlay can be active at once
|
||||
void addOverlay(std::shared_ptr<CIntObject> newOverlay);
|
||||
|
@ -96,7 +96,7 @@ void CPicture::showAll(Canvas & to)
|
||||
}
|
||||
}
|
||||
|
||||
void CPicture::setAlpha(int value)
|
||||
void CPicture::setAlpha(uint8_t value)
|
||||
{
|
||||
bg->setAlpha(value);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
|
||||
/// set alpha value for whole surface. Note: may be messed up if surface is shared
|
||||
/// 0=transparent, 255=opaque
|
||||
void setAlpha(int value);
|
||||
void setAlpha(uint8_t value);
|
||||
void scaleTo(Point size);
|
||||
void colorize(PlayerColor player);
|
||||
|
||||
|
@ -969,9 +969,9 @@ void CCastleBuildings::enterMagesGuild()
|
||||
{
|
||||
const StartInfo *si = LOCPLINT->cb->getStartInfo();
|
||||
// it would be nice to find a way to move this hack to config/mapOverrides.json
|
||||
if(si && si->campState && si->campState && // We're in campaign,
|
||||
if(si && si->campState && // We're in campaign,
|
||||
(si->campState->getFilename() == "DATA/YOG.H3C") && // which is "Birth of a Barbarian",
|
||||
(hero->subID == 45)) // and the hero is Yog (based on Solmyr)
|
||||
(hero->subID == 45)) // and the hero is Yog (based on Solmyr)
|
||||
{
|
||||
// "Yog has given up magic in all its forms..."
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[736]);
|
||||
|
@ -23,7 +23,7 @@ class AboutProjectView : public QWidget
|
||||
|
||||
void changeEvent(QEvent *event) override;
|
||||
public:
|
||||
explicit AboutProjectView(QWidget * parent = 0);
|
||||
explicit AboutProjectView(QWidget * parent = nullptr);
|
||||
|
||||
public slots:
|
||||
|
||||
|
@ -150,7 +150,7 @@ void FirstLaunchView::activateTabModPreset()
|
||||
|
||||
void FirstLaunchView::exitSetup()
|
||||
{
|
||||
if(auto * mainWindow = dynamic_cast<MainWindow *>(qApp->activeWindow()))
|
||||
if(auto * mainWindow = dynamic_cast<MainWindow *>(QApplication::activeWindow()))
|
||||
mainWindow->exitSetup();
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ void FirstLaunchView::languageSelected(const QString & selectedLanguage)
|
||||
Settings node = settings.write["general"]["language"];
|
||||
node->String() = selectedLanguage.toStdString();
|
||||
|
||||
if(auto * mainWindow = dynamic_cast<MainWindow *>(qApp->activeWindow()))
|
||||
if(auto * mainWindow = dynamic_cast<MainWindow *>(QApplication::activeWindow()))
|
||||
mainWindow->updateTranslation();
|
||||
}
|
||||
|
||||
@ -398,7 +398,7 @@ bool FirstLaunchView::checkCanInstallExtras()
|
||||
|
||||
CModListView * FirstLaunchView::getModView()
|
||||
{
|
||||
auto * mainWindow = dynamic_cast<MainWindow *>(qApp->activeWindow());
|
||||
auto * mainWindow = dynamic_cast<MainWindow *>(QApplication::activeWindow());
|
||||
|
||||
assert(mainWindow);
|
||||
if (!mainWindow)
|
||||
|
@ -67,7 +67,7 @@ class FirstLaunchView : public QWidget
|
||||
void installMod(const QString & modID);
|
||||
|
||||
public:
|
||||
explicit FirstLaunchView(QWidget * parent = 0);
|
||||
explicit FirstLaunchView(QWidget * parent = nullptr);
|
||||
|
||||
public slots:
|
||||
|
||||
|
@ -194,7 +194,7 @@ class SocketLobby : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SocketLobby(QObject *parent = 0);
|
||||
explicit SocketLobby(QObject *parent = nullptr);
|
||||
void connectServer(const QString & host, int port, const QString & username, int timeout);
|
||||
void disconnectServer();
|
||||
void requestNewSession(const QString & session, int totalPlayers, const QString & pswd, const QMap<QString, QString> & mods);
|
||||
|
@ -181,7 +181,7 @@ QVariant CModEntry::getValueImpl(QString value, bool localized) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariantMap CModList::copyField(QVariantMap data, QString from, QString to)
|
||||
QVariantMap CModList::copyField(QVariantMap data, QString from, QString to) const
|
||||
{
|
||||
QVariantMap renamed;
|
||||
|
||||
|
@ -85,7 +85,7 @@ class CModList
|
||||
QVariantMap localModList;
|
||||
QVariantMap modSettings;
|
||||
|
||||
QVariantMap copyField(QVariantMap data, QString from, QString to);
|
||||
QVariantMap copyField(QVariantMap data, QString from, QString to) const;
|
||||
|
||||
public:
|
||||
virtual void resetRepositories();
|
||||
|
@ -56,7 +56,7 @@ class CModListModel : public QAbstractItemModel, public CModList
|
||||
QVariant getIcon(const CModEntry & mod, int field) const;
|
||||
|
||||
public:
|
||||
explicit CModListModel(QObject * parent = 0);
|
||||
explicit CModListModel(QObject * parent = nullptr);
|
||||
|
||||
/// CModListContainer overrides
|
||||
void resetRepositories() override;
|
||||
@ -93,5 +93,5 @@ class CModFilterModel : public QSortFilterProxyModel
|
||||
public:
|
||||
void setTypeFilter(int filteredType, int filterMask);
|
||||
|
||||
CModFilterModel(CModListModel * model, QObject * parent = 0);
|
||||
CModFilterModel(CModListModel * model, QObject * parent = nullptr);
|
||||
};
|
||||
|
@ -64,7 +64,7 @@ signals:
|
||||
void modsChanged();
|
||||
|
||||
public:
|
||||
explicit CModListView(QWidget * parent = 0);
|
||||
explicit CModListView(QWidget * parent = nullptr);
|
||||
~CModListView();
|
||||
|
||||
void loadScreenshots();
|
||||
|
@ -23,12 +23,12 @@ class ImageViewer : public QDialog
|
||||
|
||||
void changeEvent(QEvent *event) override;
|
||||
public:
|
||||
explicit ImageViewer(QWidget * parent = 0);
|
||||
explicit ImageViewer(QWidget * parent = nullptr);
|
||||
~ImageViewer();
|
||||
|
||||
void setPixmap(QPixmap & pixmap);
|
||||
|
||||
static void showPixmap(QPixmap & pixmap, QWidget * parent = 0);
|
||||
static void showPixmap(QPixmap & pixmap, QWidget * parent = nullptr);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent * event) override;
|
||||
|
@ -20,7 +20,7 @@ class CSettingsView : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CSettingsView(QWidget * parent = 0);
|
||||
explicit CSettingsView(QWidget * parent = nullptr);
|
||||
~CSettingsView();
|
||||
|
||||
void loadSettings();
|
||||
|
@ -110,7 +110,7 @@ int AFactionMember::moraleValAndBonusList(TConstBonusListPtr & bonusList) const
|
||||
bonusList = getBonusBearer()->getBonuses(moraleSelector, cachingStrMor);
|
||||
|
||||
int32_t maxGoodMorale = VLC->settings()->getVector(EGameSettings::COMBAT_GOOD_MORALE_DICE).size();
|
||||
int32_t maxBadMorale = -VLC->settings()->getVector(EGameSettings::COMBAT_BAD_MORALE_DICE).size();
|
||||
int32_t maxBadMorale = - (int32_t) VLC->settings()->getVector(EGameSettings::COMBAT_BAD_MORALE_DICE).size();
|
||||
|
||||
return std::clamp(bonusList->totalValue(), maxBadMorale, maxGoodMorale);
|
||||
}
|
||||
@ -129,7 +129,7 @@ int AFactionMember::luckValAndBonusList(TConstBonusListPtr & bonusList) const
|
||||
bonusList = getBonusBearer()->getBonuses(luckSelector, cachingStrLuck);
|
||||
|
||||
int32_t maxGoodLuck = VLC->settings()->getVector(EGameSettings::COMBAT_GOOD_LUCK_DICE).size();
|
||||
int32_t maxBadLuck = -VLC->settings()->getVector(EGameSettings::COMBAT_BAD_LUCK_DICE).size();
|
||||
int32_t maxBadLuck = - (int32_t) VLC->settings()->getVector(EGameSettings::COMBAT_BAD_LUCK_DICE).size();
|
||||
|
||||
return std::clamp(bonusList->totalValue(), maxBadLuck, maxGoodLuck);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
|
||||
HMODULE hModule = nullptr;
|
||||
GetModuleFileNameA(hModule, buffer, MAX_PATH);
|
||||
mname = strrchr(buffer, '\\');
|
||||
if (mname != 0)
|
||||
if (mname != nullptr)
|
||||
mname++;
|
||||
else
|
||||
mname = buffer;
|
||||
|
@ -140,7 +140,7 @@ struct DLL_LINKAGE StartInfo
|
||||
}
|
||||
|
||||
StartInfo() : mode(INVALID), difficulty(1), seedToBeUsed(0), seedPostInit(0),
|
||||
mapfileChecksum(0), startTimeIso8601(vstd::getDateTimeISO8601Basic(std::time(0))), fileURI("")
|
||||
mapfileChecksum(0), startTimeIso8601(vstd::getDateTimeISO8601Basic(std::time(nullptr))), fileURI("")
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ void CGameState::initNewGame(const IMapService * mapService, bool allowSavingRan
|
||||
|
||||
const std::string templateName = options->getMapTemplate()->getName();
|
||||
const ui32 seed = scenarioOps->seedToBeUsed;
|
||||
const std::string dt = vstd::getDateTimeISO8601Basic(std::time(0));
|
||||
const std::string dt = vstd::getDateTimeISO8601Basic(std::time(nullptr));
|
||||
|
||||
const std::string fileName = boost::str(boost::format("%s_%s_%d.vmap") % dt % templateName % seed );
|
||||
const auto fullPath = path / fileName;
|
||||
|
@ -279,11 +279,10 @@ void CGPandoraBox::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
|| vinfo.reward.heroExperience
|
||||
|| vinfo.reward.manaDiff
|
||||
|| vinfo.reward.resources.nonZero()
|
||||
|| !vinfo.reward.artifacts.empty()
|
||||
|| !vinfo.reward.bonuses.empty()
|
||||
|| !vinfo.reward.artifacts.empty()
|
||||
|| !vinfo.reward.secondary.empty()
|
||||
|| !vinfo.reward.artifacts.empty()
|
||||
|| !vinfo.reward.creatures.empty();
|
||||
|| !vinfo.reward.creatures.empty()
|
||||
|| !vinfo.reward.secondary.empty();
|
||||
|
||||
if(hasSomething)
|
||||
configuration.info.push_back(vinfo);
|
||||
|
@ -158,7 +158,13 @@ const IMarket * IMarket::castFrom(const CGObjectInstance *obj, bool verbose)
|
||||
{
|
||||
auto * imarket = dynamic_cast<const IMarket *>(obj);
|
||||
if(verbose && !imarket)
|
||||
logGlobal->error("Cannot cast to IMarket object type %s", obj->typeName);
|
||||
{
|
||||
logGlobal->error("Cannot cast to IMarket");
|
||||
if(obj)
|
||||
{
|
||||
logGlobal->error("Object type %s", obj->typeName);
|
||||
}
|
||||
}
|
||||
return imarket;
|
||||
}
|
||||
|
||||
|
@ -2105,7 +2105,7 @@ void SetObjectProperty::applyGs(CGameState * gs) const
|
||||
state->towns -= t;
|
||||
|
||||
if(state->towns.empty())
|
||||
*state->daysWithoutCastle = 0;
|
||||
state->daysWithoutCastle = 0;
|
||||
}
|
||||
if(PlayerColor(val).isValidPlayer())
|
||||
{
|
||||
|
@ -201,7 +201,7 @@ void RoadPlacer::connectRoads()
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
logGlobal->error("Unhandled exception while drawing road to node %s: %s", node.toString(), e.what());
|
||||
throw e;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ struct VectorizedObjectInfo
|
||||
class DLL_LINKAGE CSerializer
|
||||
{
|
||||
template<typename T>
|
||||
static si32 idToNumber(const T &t, typename std::enable_if<std::is_convertible<T,si32>::value>::type * dummy = 0)
|
||||
static si32 idToNumber(const T &t, typename std::enable_if<std::is_convertible<T,si32>::value>::type * dummy = nullptr)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
@ -685,7 +685,7 @@ void Inspector::setProperty(CGHeroPlaceholder * o, const QString & key, const QV
|
||||
|
||||
if(key == "Hero type")
|
||||
{
|
||||
o->heroType.value() = HeroTypeID(value.toInt());
|
||||
o->heroType = HeroTypeID(value.toInt());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ bool CVCMIServer::prepareToStartGame()
|
||||
{
|
||||
case StartInfo::CAMPAIGN:
|
||||
logNetwork->info("Preparing to start new campaign");
|
||||
si->startTimeIso8601 = vstd::getDateTimeISO8601Basic(std::time(0));
|
||||
si->startTimeIso8601 = vstd::getDateTimeISO8601Basic(std::time(nullptr));
|
||||
si->fileURI = mi->fileURI;
|
||||
si->campState->setCurrentMap(campaignMap);
|
||||
si->campState->setCurrentMapBonus(campaignBonus);
|
||||
@ -325,7 +325,7 @@ bool CVCMIServer::prepareToStartGame()
|
||||
|
||||
case StartInfo::NEW_GAME:
|
||||
logNetwork->info("Preparing to start new game");
|
||||
si->startTimeIso8601 = vstd::getDateTimeISO8601Basic(std::time(0));
|
||||
si->startTimeIso8601 = vstd::getDateTimeISO8601Basic(std::time(nullptr));
|
||||
si->fileURI = mi->fileURI;
|
||||
gh->init(si.get(), progressTracking);
|
||||
break;
|
||||
@ -1124,7 +1124,7 @@ static void handleCommandOptions(int argc, const char * argv[], boost::program_o
|
||||
#ifndef SINGLE_PROCESS_APP
|
||||
if(options.count("help"))
|
||||
{
|
||||
auto time = std::time(0);
|
||||
auto time = std::time(nullptr);
|
||||
printf("%s - A Heroes of Might and Magic 3 clone\n", GameConstants::VCMI_VERSION.c_str());
|
||||
printf("Copyright (C) 2007-%d VCMI dev team - see AUTHORS file\n", std::localtime(&time)->tm_year + 1900);
|
||||
printf("This is free software; see the source for copying conditions. There is NO\n");
|
||||
|
@ -284,7 +284,7 @@ const CStack * BattleFlowProcessor::getNextStack(const CBattleInfoCallback & bat
|
||||
gameHandler->sendAndApply(&bte);
|
||||
}
|
||||
|
||||
if(!next->willMove())
|
||||
if(!next || !next->willMove())
|
||||
return nullptr;
|
||||
|
||||
return stack;
|
||||
|
Loading…
Reference in New Issue
Block a user