1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-20 20:23:03 +02:00

Converted (almost) all namespace enum's to enum classes

This commit is contained in:
Ivan Savenko 2023-08-19 22:35:44 +03:00
parent 62cd8b12d4
commit 0240ee886d
34 changed files with 124 additions and 144 deletions

View File

@ -357,7 +357,7 @@ int64_t BattleExchangeEvaluator::calculateExchange(
if(cb->battleGetMySide() == BattlePerspective::LEFT_SIDE
&& cb->battleGetGateState() == EGateState::BLOCKED
&& ap.attack.defender->coversPos(ESiegeHex::GATE_BRIDGE))
&& ap.attack.defender->coversPos(BattleHex::GATE_BRIDGE))
{
return EvaluationResult::INEFFECTIVE_SCORE;
}

View File

@ -773,7 +773,7 @@ void AIGateway::makeTurn()
{
MAKING_TURN;
auto day = cb->getDate(Date::EDateType::DAY);
auto day = cb->getDate(Date::DAY);
logAi->info("Player %d (%s) starting turn, day %d", playerID, playerID.getStr(), day);
boost::shared_lock<boost::shared_mutex> gsLock(CGameState::mutex);

View File

@ -160,7 +160,7 @@ void BuildAnalyzer::update()
updateDailyIncome();
if(ai->cb->getDate(Date::EDateType::DAY) == 1)
if(ai->cb->getDate(Date::DAY) == 1)
{
goldPreasure = 1;
}

View File

@ -38,7 +38,7 @@ bool BuildingManager::tryBuildThisStructure(const CGTownInstance * t, BuildingID
for (BuildingID buildID : toBuild)
{
EBuildingState::EBuildingState canBuild = cb->canBuildStructure(t, buildID);
EBuildingState canBuild = cb->canBuildStructure(t, buildID);
if (canBuild == EBuildingState::HAVE_CAPITAL || canBuild == EBuildingState::FORBIDDEN || canBuild == EBuildingState::NO_WATER)
return false; //we won't be able to build this
}
@ -52,7 +52,7 @@ bool BuildingManager::tryBuildThisStructure(const CGTownInstance * t, BuildingID
{
const CBuilding * b = t->town->buildings.at(buildID);
EBuildingState::EBuildingState canBuild = cb->canBuildStructure(t, buildID);
EBuildingState canBuild = cb->canBuildStructure(t, buildID);
if (canBuild == EBuildingState::ALLOWED)
{
PotentialBuilding pb;

View File

@ -776,7 +776,7 @@ void VCAI::makeTurn()
{
MAKING_TURN;
auto day = cb->getDate(Date::EDateType::DAY);
auto day = cb->getDate(Date::DAY);
logAi->info("Player %d (%s) starting turn, day %d", playerID, playerID.getStr(), day);
boost::shared_lock<boost::shared_mutex> gsLock(CGameState::mutex);

View File

@ -195,7 +195,7 @@ bool CCallback::buildBuilding(const CGTownInstance *town, BuildingID buildingID)
if(town->tempOwner!=player)
return false;
if(!canBuildStructure(town, buildingID))
if(canBuildStructure(town, buildingID) != EBuildingState::ALLOWED)
return false;
BuildStructure pack(town->id,buildingID);

View File

@ -523,7 +523,7 @@ void BattleWindow::bSpellf()
CCS->curh->set(Cursor::Map::POINTER);
ESpellCastProblem::ESpellCastProblem spellCastProblem = owner.curInt->cb->battleCanCastSpell(myHero, spells::Mode::HERO);
ESpellCastProblem spellCastProblem = owner.curInt->cb->battleCanCastSpell(myHero, spells::Mode::HERO);
if(spellCastProblem == ESpellCastProblem::OK)
{
@ -629,7 +629,7 @@ void BattleWindow::blockUI(bool on)
if(hero)
{
ESpellCastProblem::ESpellCastProblem spellcastingProblem = owner.curInt->cb->battleCanCastSpell(hero, spells::Mode::HERO);
ESpellCastProblem spellcastingProblem = owner.curInt->cb->battleCanCastSpell(hero, spells::Mode::HERO);
//if magic is blocked, we leave button active, so the message can be displayed after button click
canCastSpells = spellcastingProblem == ESpellCastProblem::OK || spellcastingProblem == ESpellCastProblem::MAGIC_IS_BLOCKED;

View File

@ -441,7 +441,7 @@ OptionsTab::SelectionWindow::SelectionWindow(PlayerColor _color, SelType _type)
if(initialHero >= -1)
allowedBonus.push_back(0); // artifact
allowedBonus.push_back(1); // gold
if(initialFaction >= 0)
if(initialFaction.getNum() >= 0)
allowedBonus.push_back(2); // resource
recreate();
@ -451,7 +451,7 @@ int OptionsTab::SelectionWindow::calcLines(FactionID faction)
{
double additionalItems = 1; // random
if(faction < 0)
if(faction.getNum() < 0)
return std::ceil(((double)allowedFactions.size() + additionalItems) / elementsPerLine);
int count = 0;
@ -568,8 +568,8 @@ void OptionsTab::SelectionWindow::genContentFactions()
set.castle = PlayerSettings::RANDOM;
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::TOWN);
components.push_back(std::make_shared<CAnimImage>(helper.getImageName(), helper.getImageIndex(), 0, 6, (ICON_SMALL_HEIGHT/2)));
drawOutlinedText(TEXT_POS_X, TEXT_POS_Y, (selectedFaction == PlayerSettings::RANDOM) ? Colors::YELLOW : Colors::WHITE, helper.getName());
if(selectedFaction == PlayerSettings::RANDOM)
drawOutlinedText(TEXT_POS_X, TEXT_POS_Y, (selectedFaction.getNum() == PlayerSettings::RANDOM) ? Colors::YELLOW : Colors::WHITE, helper.getName());
if(selectedFaction.getNum() == PlayerSettings::RANDOM)
components.push_back(std::make_shared<CPicture>("lobby/townBorderSmallActivated", 6, (ICON_SMALL_HEIGHT/2)));
for(auto & elem : allowedFactions)
@ -677,7 +677,7 @@ void OptionsTab::SelectionWindow::setElement(int elem, bool doApply)
{
set.castle = PlayerSettings::RANDOM;
}
if(set.castle != PlayerSettings::NONE)
if(set.castle.getNum() != PlayerSettings::NONE)
{
if(!doApply)
{
@ -800,7 +800,7 @@ void OptionsTab::SelectedBox::clickReleased(const Point & cursorPosition)
if(type == SelType::TOWN && ((pi.allowedFactions.size() < 2 && !pi.isFactionRandom) || foreignPlayer))
return;
if(type == SelType::HERO && ((pi.defaultHero() != -1 || settings.castle < 0) || foreignPlayer))
if(type == SelType::HERO && ((pi.defaultHero() != -1 || settings.castle.getNum() < 0) || foreignPlayer))
return;
if(type == SelType::BONUS && foreignPlayer)
@ -954,4 +954,4 @@ void OptionsTab::PlayerOptionsEntry::hideUnavailableButtons()
buttonBonusLeft->enable();
buttonBonusRight->enable();
}
}
}

View File

@ -1351,9 +1351,9 @@ CHallInterface::CBuildingBox::CBuildingBox(int x, int y, const CGTownInstance *
};
icon = std::make_shared<CAnimImage>(town->town->clientInfo.buildingsIcons, building->bid, 0, 2, 2);
header = std::make_shared<CAnimImage>("TPTHBAR", panelIndex[state], 0, 1, 73);
if(iconIndex[state] >=0)
mark = std::make_shared<CAnimImage>("TPTHCHK", iconIndex[state], 0, 136, 56);
header = std::make_shared<CAnimImage>("TPTHBAR", panelIndex[static_cast<int>(state)], 0, 1, 73);
if(iconIndex[static_cast<int>(state)] >=0)
mark = std::make_shared<CAnimImage>("TPTHCHK", iconIndex[static_cast<int>(state)], 0, 136, 56);
name = std::make_shared<CLabel>(75, 81, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, building->getNameTranslated());
//todo: add support for all possible states
@ -1371,7 +1371,7 @@ void CHallInterface::CBuildingBox::hover(bool on)
else if(state==EBuildingState::CANT_BUILD_TODAY)
toPrint = CGI->generaltexth->allTexts[223];
else
toPrint = CGI->generaltexth->hcommands[state];
toPrint = CGI->generaltexth->hcommands[static_cast<int>(state)];
boost::algorithm::replace_first(toPrint,"%s",building->getNameTranslated());
GH.statusbar()->write(toPrint);
}
@ -1439,7 +1439,7 @@ CHallInterface::CHallInterface(const CGTownInstance * Town):
}
}
CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Building, int state, bool rightClick):
CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Building, EBuildingState state, bool rightClick):
CStatusbarWindow(PLAYER_COLORED | (rightClick ? RCLICK_POPUP : 0), "TPUBUILD"),
town(Town),
building(Building)
@ -1482,7 +1482,7 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
buy = std::make_shared<CButton>(Point(45, 446), "IBUY30", CButton::tooltip(tooltipYes.toString()), [&](){ buyFunc(); }, EShortcut::GLOBAL_ACCEPT);
buy->setBorderColor(Colors::METALLIC_GOLD);
buy->block(state!=7 || LOCPLINT->playerID != town->tempOwner);
buy->block(state!=EBuildingState::ALLOWED || LOCPLINT->playerID != town->tempOwner);
cancel = std::make_shared<CButton>(Point(290, 445), "ICANCEL", CButton::tooltip(tooltipNo.toString()), [&](){ close();}, EShortcut::GLOBAL_CANCEL);
cancel->setBorderColor(Colors::METALLIC_GOLD);
@ -1495,11 +1495,11 @@ void CBuildWindow::buyFunc()
GH.windows().popWindows(2); //we - build window and hall screen
}
std::string CBuildWindow::getTextForState(int state)
std::string CBuildWindow::getTextForState(EBuildingState state)
{
std::string ret;
if(state < EBuildingState::ALLOWED)
ret = CGI->generaltexth->hcommands[state];
ret = CGI->generaltexth->hcommands[static_cast<int>(state)];
switch (state)
{
case EBuildingState::ALREADY_PRESENT:

View File

@ -265,7 +265,7 @@ class CHallInterface : public CStatusbarWindow
const CGTownInstance * town;
const CBuilding * building;
ui32 state;//Buildings::EBuildStructure enum
EBuildingState state;
std::shared_ptr<CAnimImage> header;
std::shared_ptr<CAnimImage> icon;
@ -303,10 +303,10 @@ class CBuildWindow: public CStatusbarWindow
std::shared_ptr<CButton> buy;
std::shared_ptr<CButton> cancel;
std::string getTextForState(int state);
std::string getTextForState(EBuildingState state);
void buyFunc();
public:
CBuildWindow(const CGTownInstance *Town, const CBuilding * building, int State, bool rightClick);
CBuildWindow(const CGTownInstance *Town, const CBuilding * building, EBuildingState State, bool rightClick);
};
//Small class to display

View File

@ -1711,7 +1711,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
}
else if(it.second != EAiTactic::RANDOM)
{
text = CGI->generaltexth->arraytxt[168 + it.second];
text = CGI->generaltexth->arraytxt[168 + static_cast<int>(it.second)];
}
personalities.push_back(std::make_shared<CLabel>(283 + 66*counter, 459, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, text));

View File

@ -15,7 +15,7 @@
VCMI_LIB_NAMESPACE_BEGIN
class BonusList;
enum class PrimarySkill : int32_t;
enum class PrimarySkill : int8_t;
class DLL_LINKAGE AFactionMember: public IConstBonusProvider, public INativeTerrainProvider
{

View File

@ -405,7 +405,7 @@ bool CGameInfoCallback::getHeroInfo(const CGObjectInstance * hero, InfoAboutHero
return true;
}
int CGameInfoCallback::getDate(Date::EDateType mode) const
int CGameInfoCallback::getDate(Date mode) const
{
//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
return gs->getDate(mode);
@ -551,7 +551,7 @@ std::shared_ptr<const boost::multi_array<TerrainTile*, 3>> CGameInfoCallback::ge
return std::shared_ptr<const boost::multi_array<TerrainTile*, 3>>(ptr);
}
EBuildingState::EBuildingState CGameInfoCallback::canBuildStructure( const CGTownInstance *t, BuildingID ID )
EBuildingState CGameInfoCallback::canBuildStructure( const CGTownInstance *t, BuildingID ID )
{
ERROR_RET_VAL_IF(!canGetFullInfo(t), "Town is not owned!", EBuildingState::TOWN_NOT_OWNED);

View File

@ -52,7 +52,7 @@ public:
//TODO: all other public methods of CGameInfoCallback
// //various
virtual int getDate(Date::EDateType mode=Date::DAY) const = 0; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
virtual int getDate(Date mode=Date::DAY) const = 0; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
// const StartInfo * getStartInfo(bool beforeRandomization = false)const;
virtual bool isAllowed(int32_t type, int32_t id) const = 0; //type: 0 - spell; 1- artifact; 2 - secondary skill
@ -107,13 +107,13 @@ public:
// const CGTownInstance * getTownInfo(int val, bool mode)const; //mode = 0 -> val = player town serial; mode = 1 -> val = object id (serial)
// std::vector<const CGHeroInstance *> getAvailableHeroes(const CGObjectInstance * townOrTavern) const; //heroes that can be recruited
// std::string getTavernRumor(const CGObjectInstance * townOrTavern) const;
// EBuildingState::EBuildingState canBuildStructure(const CGTownInstance *t, BuildingID ID);//// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
// EBuildingState canBuildStructure(const CGTownInstance *t, BuildingID ID);//// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
// virtual bool getTownInfo(const CGObjectInstance * town, InfoAboutTown & dest, const CGObjectInstance * selectedObject = nullptr) const;
//from gs
// const TeamState *getTeam(TeamID teamID) const;
// const TeamState *getPlayerTeam(PlayerColor color) const;
// EBuildingState::EBuildingState canBuildStructure(const CGTownInstance *t, BuildingID ID) const;// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
// EBuildingState canBuildStructure(const CGTownInstance *t, BuildingID ID) const;// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
//teleport
// std::vector<ObjectInstanceID> getVisibleTeleportObjects(std::vector<ObjectInstanceID> ids, PlayerColor player) const;
@ -140,7 +140,7 @@ protected:
public:
//various
int getDate(Date::EDateType mode=Date::DAY)const override; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
int getDate(Date mode=Date::DAY)const override; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
virtual const StartInfo * getStartInfo(bool beforeRandomization = false)const;
bool isAllowed(int32_t type, int32_t id) const override; //type: 0 - spell; 1- artifact; 2 - secondary skill
@ -205,13 +205,13 @@ public:
//virtual const CGTownInstance * getTownInfo(int val, bool mode)const; //mode = 0 -> val = player town serial; mode = 1 -> val = object id (serial)
virtual std::vector<const CGHeroInstance *> getAvailableHeroes(const CGObjectInstance * townOrTavern) const; //heroes that can be recruited
virtual std::string getTavernRumor(const CGObjectInstance * townOrTavern) const;
virtual EBuildingState::EBuildingState canBuildStructure(const CGTownInstance *t, BuildingID ID);//// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
virtual EBuildingState canBuildStructure(const CGTownInstance *t, BuildingID ID);//// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
virtual bool getTownInfo(const CGObjectInstance * town, InfoAboutTown & dest, const CGObjectInstance * selectedObject = nullptr) const;
//from gs
virtual const TeamState *getTeam(TeamID teamID) const;
virtual const TeamState *getPlayerTeam(PlayerColor color) const;
//virtual EBuildingState::EBuildingState canBuildStructure(const CGTownInstance *t, BuildingID ID) const;// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
//virtual EBuildingState canBuildStructure(const CGTownInstance *t, BuildingID ID) const;// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
//teleport
virtual std::vector<ObjectInstanceID> getVisibleTeleportObjects(std::vector<ObjectInstanceID> ids, PlayerColor player) const;

View File

@ -412,7 +412,7 @@ class TeleportChannelID : public BaseForID<TeleportChannelID, si32>
};
// Enum declarations
enum class PrimarySkill : int32_t
enum class PrimarySkill : int8_t
{
NONE = -1,
ATTACK,
@ -603,7 +603,7 @@ namespace BuildingSubID
};
}
enum class EMarketMode : int32_t
enum class EMarketMode : int8_t
{
RESOURCE_RESOURCE, RESOURCE_PLAYER, CREATURE_RESOURCE, RESOURCE_ARTIFACT,
ARTIFACT_RESOURCE, ARTIFACT_EXP, CREATURE_EXP, CREATURE_UNDEAD, RESOURCE_SKILL,
@ -701,9 +701,7 @@ namespace MappedKeys
};
}
namespace EAiTactic
{
enum EAiTactic
enum class EAiTactic : int8_t
{
NONE = -1,
RANDOM,
@ -711,29 +709,22 @@ enum EAiTactic
BUILDER,
EXPLORER
};
}
namespace EBuildingState
enum class EBuildingState : int8_t
{
enum EBuildingState
{
HAVE_CAPITAL, NO_WATER, FORBIDDEN, ADD_MAGES_GUILD, ALREADY_PRESENT, CANT_BUILD_TODAY,
NO_RESOURCES, ALLOWED, PREREQUIRES, MISSING_BASE, BUILDING_ERROR, TOWN_NOT_OWNED
};
}
HAVE_CAPITAL, NO_WATER, FORBIDDEN, ADD_MAGES_GUILD, ALREADY_PRESENT, CANT_BUILD_TODAY,
NO_RESOURCES, ALLOWED, PREREQUIRES, MISSING_BASE, BUILDING_ERROR, TOWN_NOT_OWNED
};
namespace ESpellCastProblem
enum class ESpellCastProblem : int8_t
{
enum ESpellCastProblem
{
OK, NO_HERO_TO_CAST_SPELL, CASTS_PER_TURN_LIMIT, NO_SPELLBOOK,
HERO_DOESNT_KNOW_SPELL, NOT_ENOUGH_MANA, ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL,
SPELL_LEVEL_LIMIT_EXCEEDED, NO_SPELLS_TO_DISPEL,
NO_APPROPRIATE_TARGET, STACK_IMMUNE_TO_SPELL, WRONG_SPELL_TARGET, ONGOING_TACTIC_PHASE,
MAGIC_IS_BLOCKED, //For Orb of Inhibition and similar - no casting at all
INVALID
};
}
OK, NO_HERO_TO_CAST_SPELL, CASTS_PER_TURN_LIMIT, NO_SPELLBOOK,
HERO_DOESNT_KNOW_SPELL, NOT_ENOUGH_MANA, ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL,
SPELL_LEVEL_LIMIT_EXCEEDED, NO_SPELLS_TO_DISPEL,
NO_APPROPRIATE_TARGET, STACK_IMMUNE_TO_SPELL, WRONG_SPELL_TARGET, ONGOING_TACTIC_PHASE,
MAGIC_IS_BLOCKED, //For Orb of Inhibition and similar - no casting at all
INVALID
};
namespace ECommander
{
@ -757,7 +748,7 @@ enum class EWallState : int8_t
REINFORCED, // walls in towns with castle
};
enum class EGateState : uint8_t
enum class EGateState : int8_t
{
NONE,
CLOSED,
@ -766,32 +757,16 @@ enum class EGateState : uint8_t
DESTROYED
};
namespace ESiegeHex
{
enum ESiegeHex : si16
{
DESTRUCTIBLE_WALL_1 = 29,
DESTRUCTIBLE_WALL_2 = 78,
DESTRUCTIBLE_WALL_3 = 130,
DESTRUCTIBLE_WALL_4 = 182,
GATE_BRIDGE = 94,
GATE_OUTER = 95,
GATE_INNER = 96
};
}
namespace ETileType
enum class ETileType : int8_t
{
enum ETileType
{
FREE,
POSSIBLE,
BLOCKED,
USED
};
}
FREE,
POSSIBLE,
BLOCKED,
USED
};
enum class ETeleportChannelType
enum class ETeleportChannelType : int8_t
{
IMPASSABLE,
BIDIRECTIONAL,
@ -1006,17 +981,14 @@ namespace SecSkillLevel
};
}
namespace Date
enum class Date : int8_t
{
enum EDateType
{
DAY = 0,
DAY_OF_WEEK = 1,
WEEK = 2,
MONTH = 3,
DAY_OF_MONTH
};
}
DAY = 0,
DAY_OF_WEEK = 1,
WEEK = 2,
MONTH = 3,
DAY_OF_MONTH
};
enum class EActionType : int8_t
{
@ -1041,7 +1013,7 @@ enum class EActionType : int8_t
DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const EActionType actionType);
enum class EDiggingStatus : int32_t
enum class EDiggingStatus : int8_t
{
UNKNOWN = -1,
CAN_DIG = 0,
@ -1348,7 +1320,7 @@ public:
using ESpellSchool = SpellSchool;
enum class EMetaclass: ui8
enum class EMetaclass: int8_t
{
INVALID = 0,
ARTIFACT,

View File

@ -47,6 +47,14 @@ struct DLL_LINKAGE BattleHex //TODO: decide if this should be changed to class f
static constexpr si16 HEX_BEFORE_ALL = std::numeric_limits<si16>::min();
static constexpr si16 HEX_AFTER_ALL = std::numeric_limits<si16>::max();
static constexpr si16 DESTRUCTIBLE_WALL_1 = 29;
static constexpr si16 DESTRUCTIBLE_WALL_2 = 78;
static constexpr si16 DESTRUCTIBLE_WALL_3 = 130;
static constexpr si16 DESTRUCTIBLE_WALL_4 = 182;
static constexpr si16 GATE_BRIDGE = 94;
static constexpr si16 GATE_OUTER = 95;
static constexpr si16 GATE_INNER = 96;
si16 hex;
static constexpr si16 INVALID = -1;
enum EDir

View File

@ -93,7 +93,7 @@ static BattleHex WallPartToHex(EWallPart part)
using namespace SiegeStuffThatShouldBeMovedToHandlers;
ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(const spells::Caster * caster, spells::Mode mode) const
ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(const spells::Caster * caster, spells::Mode mode) const
{
RETURN_IF_NOT_BATTLE(ESpellCastProblem::INVALID);
if(caster == nullptr)
@ -187,7 +187,7 @@ bool CBattleInfoCallback::battleHasPenaltyOnLine(BattleHex from, BattleHex dest,
auto obstacles = battleGetAllObstaclesOnPos(hex, false);
if(hex != ESiegeHex::GATE_BRIDGE || (battleIsGatePassable()))
if(hex != BattleHex::GATE_BRIDGE || (battleIsGatePassable()))
for(const auto & obst : obstacles)
if(obst->obstacleType == CObstacleInstance::MOAT)
pathHasMoat |= true;
@ -821,7 +821,7 @@ std::vector<std::shared_ptr<const CObstacleInstance>> CBattleInfoCallback::getAl
affectedObstacles.push_back(i);
}
for(auto hex : unit->getHexes())
if(hex == ESiegeHex::GATE_BRIDGE && battleIsGatePassable())
if(hex == BattleHex::GATE_BRIDGE && battleIsGatePassable())
for(int i=0; i<affectedObstacles.size(); i++)
if(affectedObstacles.at(i)->obstacleType == CObstacleInstance::MOAT)
affectedObstacles.erase(affectedObstacles.begin()+i);
@ -926,7 +926,7 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
accessability = EAccessibility::UNAVAILABLE;
break;
}
ret[ESiegeHex::GATE_OUTER] = ret[ESiegeHex::GATE_INNER] = accessability;
ret[BattleHex::GATE_OUTER] = ret[BattleHex::GATE_INNER] = accessability;
}
//tiles occupied by standing stacks
@ -955,10 +955,10 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
static const std::pair<EWallPart, BattleHex> lockedIfNotDestroyed[] =
{
//which part of wall, which hex is blocked if this part of wall is not destroyed
std::make_pair(EWallPart::BOTTOM_WALL, BattleHex(ESiegeHex::DESTRUCTIBLE_WALL_4)),
std::make_pair(EWallPart::BELOW_GATE, BattleHex(ESiegeHex::DESTRUCTIBLE_WALL_3)),
std::make_pair(EWallPart::OVER_GATE, BattleHex(ESiegeHex::DESTRUCTIBLE_WALL_2)),
std::make_pair(EWallPart::UPPER_WALL, BattleHex(ESiegeHex::DESTRUCTIBLE_WALL_1))
std::make_pair(EWallPart::BOTTOM_WALL, BattleHex(BattleHex::DESTRUCTIBLE_WALL_4)),
std::make_pair(EWallPart::BELOW_GATE, BattleHex(BattleHex::DESTRUCTIBLE_WALL_3)),
std::make_pair(EWallPart::OVER_GATE, BattleHex(BattleHex::DESTRUCTIBLE_WALL_2)),
std::make_pair(EWallPart::UPPER_WALL, BattleHex(BattleHex::DESTRUCTIBLE_WALL_1))
};
for(const auto & elem : lockedIfNotDestroyed)
@ -1055,7 +1055,7 @@ bool CBattleInfoCallback::isInObstacle(
if(vstd::contains(obstacles, occupiedHex))
{
if(occupiedHex == ESiegeHex::GATE_BRIDGE)
if(occupiedHex == BattleHex::GATE_BRIDGE)
{
if(battleGetGateState() != EGateState::DESTROYED && params.side == BattleSide::ATTACKER)
return true;
@ -1080,7 +1080,7 @@ std::set<BattleHex> CBattleInfoCallback::getStoppers(BattlePerspective::BattlePe
for(const auto & hex : oi->getStoppingTile())
{
if(hex == ESiegeHex::GATE_BRIDGE && oi->obstacleType == CObstacleInstance::MOAT)
if(hex == BattleHex::GATE_BRIDGE && oi->obstacleType == CObstacleInstance::MOAT)
{
if(battleGetGateState() == EGateState::OPENED || battleGetGateState() == EGateState::DESTROYED)
continue; // this tile is disabled by drawbridge on top of it

View File

@ -118,7 +118,7 @@ public:
si8 battleMinSpellLevel(ui8 side) const; //calculates maximum spell level possible to be cast on battlefield - takes into account artifacts of both heroes; if no effects are set, 0 is returned
si8 battleMaxSpellLevel(ui8 side) const; //calculates minimum spell level possible to be cast on battlefield - takes into account artifacts of both heroes; if no effects are set, 0 is returned
int32_t battleGetSpellCost(const spells::Spell * sp, const CGHeroInstance * caster) const; //returns cost of given spell
ESpellCastProblem::ESpellCastProblem battleCanCastSpell(const spells::Caster * caster, spells::Mode mode) const; //returns true if there are no general issues preventing from casting a spell
ESpellCastProblem battleCanCastSpell(const spells::Caster * caster, spells::Mode mode) const; //returns true if there are no general issues preventing from casting a spell
SpellID battleGetRandomStackSpell(CRandomGenerator & rand, const CStack * stack, ERandomSpell mode) const;
SpellID getRandomBeneficialSpell(CRandomGenerator & rand, const CStack * subject) const;

View File

@ -356,7 +356,7 @@ void CGameState::randomizeObject(CGObjectInstance *cur)
}
}
int CGameState::getDate(Date::EDateType mode) const
int CGameState::getDate(Date mode) const
{
int temp;
switch (mode)

View File

@ -133,7 +133,7 @@ public:
bool isVisible(int3 pos, const std::optional<PlayerColor> & player) const override;
bool isVisible(const CGObjectInstance * obj, const std::optional<PlayerColor> & player) const override;
int getDate(Date::EDateType mode=Date::DAY) const override; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
int getDate(Date mode=Date::DAY) const override; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
// ----- getters, setters -----

View File

@ -22,7 +22,7 @@ struct DLL_LINKAGE SThievesGuildInfo
std::map<PlayerColor, InfoAboutHero> colorToBestHero; //maps player's color to his best heros'
std::map<PlayerColor, EAiTactic::EAiTactic> personality; // color to personality // ai tactic
std::map<PlayerColor, EAiTactic> personality; // color to personality // ai tactic
std::map<PlayerColor, si32> bestCreature; // color to ID // id or -1 if not known
// template <typename Handler> void serialize(Handler &h, const int version)

View File

@ -52,7 +52,7 @@ struct DLL_LINKAGE PlayerInfo
bool canHumanPlay;
bool canComputerPlay;
EAiTactic::EAiTactic aiTactic; /// The default value is EAiTactic::RANDOM.
EAiTactic aiTactic; /// The default value is EAiTactic::RANDOM.
std::set<FactionID> allowedFactions;
bool isFactionRandom;

View File

@ -215,7 +215,7 @@ void CMapLoaderH3M::readPlayerInfo()
continue;
}
playerInfo.aiTactic = static_cast<EAiTactic::EAiTactic>(reader->readUInt8());
playerInfo.aiTactic = static_cast<EAiTactic>(reader->readUInt8());
if(features.levelSOD)
reader->skipUnused(1); //TODO: check meaning?

View File

@ -269,7 +269,7 @@ bool RmgMap::isRoad(const int3& tile) const
return tiles[tile.x][tile.y][tile.z].isRoad();
}
void RmgMap::setOccupied(const int3 &tile, ETileType::ETileType state)
void RmgMap::setOccupied(const int3 &tile, ETileType state)
{
assertOnMap(tile);

View File

@ -54,7 +54,7 @@ public:
int height() const;
PlayerInfo & getPlayer(int playerId);
void setOccupied(const int3 &tile, ETileType::ETileType state);
void setOccupied(const int3 &tile, ETileType state);
void setRoad(const int3 &tile, RoadId roadType);
TileInfo getTileInfo(const int3 & tile) const;

View File

@ -356,7 +356,7 @@ void Object::Instance::finalize(RmgMap & map)
for(const auto & tile : getBlockedArea().getTilesVector())
{
map.setOccupied(tile, ETileType::ETileType::USED);
map.setOccupied(tile, ETileType::USED);
}
map.getMapProxy()->insertObject(&dObject);

View File

@ -54,12 +54,12 @@ bool TileInfo::isUsed() const
{
return occupied == ETileType::USED;
}
void TileInfo::setOccupied(ETileType::ETileType value)
void TileInfo::setOccupied(ETileType value)
{
occupied = value;
}
ETileType::ETileType TileInfo::getTileType() const
ETileType TileInfo::getTileType() const
{
return occupied;
}

View File

@ -28,15 +28,15 @@ public:
bool isFree() const;
bool isUsed() const;
bool isRoad() const;
void setOccupied(ETileType::ETileType value);
void setOccupied(ETileType value);
TerrainId getTerrainType() const;
ETileType::ETileType getTileType() const;
ETileType getTileType() const;
void setTerrainType(TerrainId value);
void setRoadType(RoadId type);
private:
float nearestObjectDistance;
ETileType::ETileType occupied;
ETileType occupied;
TerrainId terrain;
RoadId roadType;
};

View File

@ -468,7 +468,7 @@ bool BaseMechanics::adaptGenericProblem(Problem & target) const
return false;
}
bool BaseMechanics::adaptProblem(ESpellCastProblem::ESpellCastProblem source, Problem & target) const
bool BaseMechanics::adaptProblem(ESpellCastProblem source, Problem & target) const
{
if(source == ESpellCastProblem::OK)
return true;

View File

@ -180,7 +180,7 @@ class DLL_LINKAGE Mechanics
public:
virtual ~Mechanics();
virtual bool adaptProblem(ESpellCastProblem::ESpellCastProblem source, Problem & target) const = 0;
virtual bool adaptProblem(ESpellCastProblem source, Problem & target) const = 0;
virtual bool adaptGenericProblem(Problem & target) const = 0;
virtual std::vector<BattleHex> rangeInHexes(BattleHex centralHex) const = 0;
@ -262,7 +262,7 @@ class DLL_LINKAGE BaseMechanics : public Mechanics
public:
virtual ~BaseMechanics();
bool adaptProblem(ESpellCastProblem::ESpellCastProblem source, Problem & target) const override;
bool adaptProblem(ESpellCastProblem source, Problem & target) const override;
bool adaptGenericProblem(Problem & target) const override;
int32_t getSpellIndex() const override;

View File

@ -617,18 +617,18 @@ int BattleActionProcessor::moveStack(int stack, BattleHex dest)
if (gameHandler->gameState()->curB->tacticDistance > 0 && creSpeed > 0)
creSpeed = GameConstants::BFIELD_SIZE;
bool hasWideMoat = vstd::contains_if(gameHandler->battleGetAllObstaclesOnPos(BattleHex(ESiegeHex::GATE_BRIDGE), false), [](const std::shared_ptr<const CObstacleInstance> & obst)
bool hasWideMoat = vstd::contains_if(gameHandler->battleGetAllObstaclesOnPos(BattleHex(BattleHex::GATE_BRIDGE), false), [](const std::shared_ptr<const CObstacleInstance> & obst)
{
return obst->obstacleType == CObstacleInstance::MOAT;
});
auto isGateDrawbridgeHex = [&](BattleHex hex) -> bool
{
if (hasWideMoat && hex == ESiegeHex::GATE_BRIDGE)
if (hasWideMoat && hex == BattleHex::GATE_BRIDGE)
return true;
if (hex == ESiegeHex::GATE_OUTER)
if (hex == BattleHex::GATE_OUTER)
return true;
if (hex == ESiegeHex::GATE_INNER)
if (hex == BattleHex::GATE_INNER)
return true;
return false;
@ -687,11 +687,11 @@ int BattleActionProcessor::moveStack(int stack, BattleHex dest)
{
auto needOpenGates = [&](BattleHex hex) -> bool
{
if (hasWideMoat && hex == ESiegeHex::GATE_BRIDGE)
if (hasWideMoat && hex == BattleHex::GATE_BRIDGE)
return true;
if (hex == ESiegeHex::GATE_BRIDGE && i-1 >= 0 && path.first[i-1] == ESiegeHex::GATE_OUTER)
if (hex == BattleHex::GATE_BRIDGE && i-1 >= 0 && path.first[i-1] == BattleHex::GATE_OUTER)
return true;
else if (hex == ESiegeHex::GATE_OUTER || hex == ESiegeHex::GATE_INNER)
else if (hex == BattleHex::GATE_OUTER || hex == BattleHex::GATE_INNER)
return true;
return false;
@ -719,24 +719,24 @@ int BattleActionProcessor::moveStack(int stack, BattleHex dest)
if (!gateMayCloseAtHex.isValid() && dbState != EGateState::CLOSED)
{
if (hex == ESiegeHex::GATE_INNER && i-1 >= 0 && path.first[i-1] != ESiegeHex::GATE_OUTER)
if (hex == BattleHex::GATE_INNER && i-1 >= 0 && path.first[i-1] != BattleHex::GATE_OUTER)
{
gateMayCloseAtHex = path.first[i-1];
}
if (hasWideMoat)
{
if (hex == ESiegeHex::GATE_BRIDGE && i-1 >= 0 && path.first[i-1] != ESiegeHex::GATE_OUTER)
if (hex == BattleHex::GATE_BRIDGE && i-1 >= 0 && path.first[i-1] != BattleHex::GATE_OUTER)
{
gateMayCloseAtHex = path.first[i-1];
}
else if (hex == ESiegeHex::GATE_OUTER && i-1 >= 0 &&
path.first[i-1] != ESiegeHex::GATE_INNER &&
path.first[i-1] != ESiegeHex::GATE_BRIDGE)
else if (hex == BattleHex::GATE_OUTER && i-1 >= 0 &&
path.first[i-1] != BattleHex::GATE_INNER &&
path.first[i-1] != BattleHex::GATE_BRIDGE)
{
gateMayCloseAtHex = path.first[i-1];
}
}
else if (hex == ESiegeHex::GATE_OUTER && i-1 >= 0 && path.first[i-1] != ESiegeHex::GATE_INNER)
else if (hex == BattleHex::GATE_OUTER && i-1 >= 0 && path.first[i-1] != BattleHex::GATE_INNER)
{
gateMayCloseAtHex = path.first[i-1];
}

View File

@ -177,11 +177,11 @@ void BattleProcessor::updateGateState()
// - if Force Field is cast here, bridge can't open (but can close, in any town)
// - deals moat damage to attacker if bridge is closed (fortress only)
bool hasForceFieldOnBridge = !gameHandler->battleGetAllObstaclesOnPos(BattleHex(ESiegeHex::GATE_BRIDGE), true).empty();
bool hasStackAtGateInner = gameHandler->gameState()->curB->battleGetUnitByPos(BattleHex(ESiegeHex::GATE_INNER), false) != nullptr;
bool hasStackAtGateOuter = gameHandler->gameState()->curB->battleGetUnitByPos(BattleHex(ESiegeHex::GATE_OUTER), false) != nullptr;
bool hasStackAtGateBridge = gameHandler->gameState()->curB->battleGetUnitByPos(BattleHex(ESiegeHex::GATE_BRIDGE), false) != nullptr;
bool hasWideMoat = vstd::contains_if(gameHandler->battleGetAllObstaclesOnPos(BattleHex(ESiegeHex::GATE_BRIDGE), false), [](const std::shared_ptr<const CObstacleInstance> & obst)
bool hasForceFieldOnBridge = !gameHandler->battleGetAllObstaclesOnPos(BattleHex(BattleHex::GATE_BRIDGE), true).empty();
bool hasStackAtGateInner = gameHandler->gameState()->curB->battleGetUnitByPos(BattleHex(BattleHex::GATE_INNER), false) != nullptr;
bool hasStackAtGateOuter = gameHandler->gameState()->curB->battleGetUnitByPos(BattleHex(BattleHex::GATE_OUTER), false) != nullptr;
bool hasStackAtGateBridge = gameHandler->gameState()->curB->battleGetUnitByPos(BattleHex(BattleHex::GATE_BRIDGE), false) != nullptr;
bool hasWideMoat = vstd::contains_if(gameHandler->battleGetAllObstaclesOnPos(BattleHex(BattleHex::GATE_BRIDGE), false), [](const std::shared_ptr<const CObstacleInstance> & obst)
{
return obst->obstacleType == CObstacleInstance::MOAT;
});

View File

@ -16,7 +16,7 @@ class IGameInfoCallbackMock : public IGameInfoCallback
{
public:
//various
MOCK_CONST_METHOD1(getDate, int(Date::EDateType));
MOCK_CONST_METHOD1(getDate, int(Date));
MOCK_CONST_METHOD2(isAllowed, bool(int32_t, int32_t));
//player

View File

@ -18,7 +18,7 @@ namespace spells
class MechanicsMock : public Mechanics
{
public:
MOCK_CONST_METHOD2(adaptProblem, bool(ESpellCastProblem::ESpellCastProblem, Problem &));
MOCK_CONST_METHOD2(adaptProblem, bool(ESpellCastProblem, Problem &));
MOCK_CONST_METHOD1(adaptGenericProblem, bool(Problem &));
MOCK_CONST_METHOD1(rangeInHexes, std::vector<BattleHex>(BattleHex));