diff --git a/AI/BattleAI/BattleExchangeVariant.cpp b/AI/BattleAI/BattleExchangeVariant.cpp index d796134cd..05ea71ba9 100644 --- a/AI/BattleAI/BattleExchangeVariant.cpp +++ b/AI/BattleAI/BattleExchangeVariant.cpp @@ -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; } diff --git a/AI/Nullkiller/AIGateway.cpp b/AI/Nullkiller/AIGateway.cpp index 955269029..85acbe46c 100644 --- a/AI/Nullkiller/AIGateway.cpp +++ b/AI/Nullkiller/AIGateway.cpp @@ -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 gsLock(CGameState::mutex); diff --git a/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp b/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp index 359ccc1ca..54ce129ab 100644 --- a/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp +++ b/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp @@ -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; } diff --git a/AI/VCAI/BuildingManager.cpp b/AI/VCAI/BuildingManager.cpp index 083abe9c4..5aeba8c6b 100644 --- a/AI/VCAI/BuildingManager.cpp +++ b/AI/VCAI/BuildingManager.cpp @@ -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; diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index d2da3e13a..68a121f41 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -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 gsLock(CGameState::mutex); diff --git a/CCallback.cpp b/CCallback.cpp index 227e2f0a9..1b1b034b9 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -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); diff --git a/client/battle/BattleWindow.cpp b/client/battle/BattleWindow.cpp index 3f1b402f4..538b60b6c 100644 --- a/client/battle/BattleWindow.cpp +++ b/client/battle/BattleWindow.cpp @@ -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; diff --git a/client/lobby/OptionsTab.cpp b/client/lobby/OptionsTab.cpp index 67dee51f9..1cb24adcb 100644 --- a/client/lobby/OptionsTab.cpp +++ b/client/lobby/OptionsTab.cpp @@ -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(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("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(); } -} \ No newline at end of file +} diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index 041fdf0d4..d7bd05405 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -1351,9 +1351,9 @@ CHallInterface::CBuildingBox::CBuildingBox(int x, int y, const CGTownInstance * }; icon = std::make_shared(town->town->clientInfo.buildingsIcons, building->bid, 0, 2, 2); - header = std::make_shared("TPTHBAR", panelIndex[state], 0, 1, 73); - if(iconIndex[state] >=0) - mark = std::make_shared("TPTHCHK", iconIndex[state], 0, 136, 56); + header = std::make_shared("TPTHBAR", panelIndex[static_cast(state)], 0, 1, 73); + if(iconIndex[static_cast(state)] >=0) + mark = std::make_shared("TPTHCHK", iconIndex[static_cast(state)], 0, 136, 56); name = std::make_shared(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(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(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(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(state)]; switch (state) { case EBuildingState::ALREADY_PRESENT: diff --git a/client/windows/CCastleInterface.h b/client/windows/CCastleInterface.h index d3bbc29ae..8aa56bbf1 100644 --- a/client/windows/CCastleInterface.h +++ b/client/windows/CCastleInterface.h @@ -265,7 +265,7 @@ class CHallInterface : public CStatusbarWindow const CGTownInstance * town; const CBuilding * building; - ui32 state;//Buildings::EBuildStructure enum + EBuildingState state; std::shared_ptr header; std::shared_ptr icon; @@ -303,10 +303,10 @@ class CBuildWindow: public CStatusbarWindow std::shared_ptr buy; std::shared_ptr 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 diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index 6e291bc7c..cecd521ef 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -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(it.second)]; } personalities.push_back(std::make_shared(283 + 66*counter, 459, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, text)); diff --git a/include/vcmi/FactionMember.h b/include/vcmi/FactionMember.h index 77c95f78e..d60509f95 100644 --- a/include/vcmi/FactionMember.h +++ b/include/vcmi/FactionMember.h @@ -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 { diff --git a/lib/CGameInfoCallback.cpp b/lib/CGameInfoCallback.cpp index 7a89fcf4c..de685aa14 100644 --- a/lib/CGameInfoCallback.cpp +++ b/lib/CGameInfoCallback.cpp @@ -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 lock(*gs->mx); return gs->getDate(mode); @@ -551,7 +551,7 @@ std::shared_ptr> CGameInfoCallback::ge return std::shared_ptr>(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); diff --git a/lib/CGameInfoCallback.h b/lib/CGameInfoCallback.h index caebb235a..54ab697fb 100644 --- a/lib/CGameInfoCallback.h +++ b/lib/CGameInfoCallback.h @@ -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 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 getVisibleTeleportObjects(std::vector 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 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 getVisibleTeleportObjects(std::vector ids, PlayerColor player) const; diff --git a/lib/GameConstants.h b/lib/GameConstants.h index d9667dd56..5c8fc936f 100644 --- a/lib/GameConstants.h +++ b/lib/GameConstants.h @@ -412,7 +412,7 @@ class TeleportChannelID : public BaseForID }; // 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, diff --git a/lib/battle/BattleHex.h b/lib/battle/BattleHex.h index 060962780..731252284 100644 --- a/lib/battle/BattleHex.h +++ b/lib/battle/BattleHex.h @@ -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::min(); static constexpr si16 HEX_AFTER_ALL = std::numeric_limits::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 diff --git a/lib/battle/CBattleInfoCallback.cpp b/lib/battle/CBattleInfoCallback.cpp index 23c20abe3..505c69297 100644 --- a/lib/battle/CBattleInfoCallback.cpp +++ b/lib/battle/CBattleInfoCallback.cpp @@ -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> 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; iobstacleType == 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 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 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 diff --git a/lib/battle/CBattleInfoCallback.h b/lib/battle/CBattleInfoCallback.h index 00decc929..ae76c04d2 100644 --- a/lib/battle/CBattleInfoCallback.h +++ b/lib/battle/CBattleInfoCallback.h @@ -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; diff --git a/lib/gameState/CGameState.cpp b/lib/gameState/CGameState.cpp index 2e6e15c2e..05d9a6bb0 100644 --- a/lib/gameState/CGameState.cpp +++ b/lib/gameState/CGameState.cpp @@ -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) diff --git a/lib/gameState/CGameState.h b/lib/gameState/CGameState.h index d151e91d3..40c3af61e 100644 --- a/lib/gameState/CGameState.h +++ b/lib/gameState/CGameState.h @@ -133,7 +133,7 @@ public: bool isVisible(int3 pos, const std::optional & player) const override; bool isVisible(const CGObjectInstance * obj, const std::optional & 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 ----- diff --git a/lib/gameState/SThievesGuildInfo.h b/lib/gameState/SThievesGuildInfo.h index f3423d05f..b712d543e 100644 --- a/lib/gameState/SThievesGuildInfo.h +++ b/lib/gameState/SThievesGuildInfo.h @@ -22,7 +22,7 @@ struct DLL_LINKAGE SThievesGuildInfo std::map colorToBestHero; //maps player's color to his best heros' - std::map personality; // color to personality // ai tactic + std::map personality; // color to personality // ai tactic std::map bestCreature; // color to ID // id or -1 if not known // template void serialize(Handler &h, const int version) diff --git a/lib/mapping/CMapHeader.h b/lib/mapping/CMapHeader.h index e5cf5d5fa..8b04c1f2e 100644 --- a/lib/mapping/CMapHeader.h +++ b/lib/mapping/CMapHeader.h @@ -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 allowedFactions; bool isFactionRandom; diff --git a/lib/mapping/MapFormatH3M.cpp b/lib/mapping/MapFormatH3M.cpp index 2c03c42c6..57fb49a9e 100644 --- a/lib/mapping/MapFormatH3M.cpp +++ b/lib/mapping/MapFormatH3M.cpp @@ -215,7 +215,7 @@ void CMapLoaderH3M::readPlayerInfo() continue; } - playerInfo.aiTactic = static_cast(reader->readUInt8()); + playerInfo.aiTactic = static_cast(reader->readUInt8()); if(features.levelSOD) reader->skipUnused(1); //TODO: check meaning? diff --git a/lib/rmg/RmgMap.cpp b/lib/rmg/RmgMap.cpp index c1a908999..85c0c8590 100644 --- a/lib/rmg/RmgMap.cpp +++ b/lib/rmg/RmgMap.cpp @@ -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); diff --git a/lib/rmg/RmgMap.h b/lib/rmg/RmgMap.h index 8ceac0657..11213d031 100644 --- a/lib/rmg/RmgMap.h +++ b/lib/rmg/RmgMap.h @@ -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; diff --git a/lib/rmg/RmgObject.cpp b/lib/rmg/RmgObject.cpp index 1991b81a6..31e287e06 100644 --- a/lib/rmg/RmgObject.cpp +++ b/lib/rmg/RmgObject.cpp @@ -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); diff --git a/lib/rmg/TileInfo.cpp b/lib/rmg/TileInfo.cpp index 405a430b5..e1701a3b7 100644 --- a/lib/rmg/TileInfo.cpp +++ b/lib/rmg/TileInfo.cpp @@ -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; } diff --git a/lib/rmg/TileInfo.h b/lib/rmg/TileInfo.h index 61e874a74..6df6fcc60 100644 --- a/lib/rmg/TileInfo.h +++ b/lib/rmg/TileInfo.h @@ -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; }; diff --git a/lib/spells/ISpellMechanics.cpp b/lib/spells/ISpellMechanics.cpp index b7621c14f..a7d22fcb0 100644 --- a/lib/spells/ISpellMechanics.cpp +++ b/lib/spells/ISpellMechanics.cpp @@ -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; diff --git a/lib/spells/ISpellMechanics.h b/lib/spells/ISpellMechanics.h index efbbc53b8..7d6e395ca 100644 --- a/lib/spells/ISpellMechanics.h +++ b/lib/spells/ISpellMechanics.h @@ -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 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; diff --git a/server/battles/BattleActionProcessor.cpp b/server/battles/BattleActionProcessor.cpp index 42581078f..c08d4ce38 100644 --- a/server/battles/BattleActionProcessor.cpp +++ b/server/battles/BattleActionProcessor.cpp @@ -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 & obst) + bool hasWideMoat = vstd::contains_if(gameHandler->battleGetAllObstaclesOnPos(BattleHex(BattleHex::GATE_BRIDGE), false), [](const std::shared_ptr & 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]; } diff --git a/server/battles/BattleProcessor.cpp b/server/battles/BattleProcessor.cpp index 445fa5007..0ed52c6ef 100644 --- a/server/battles/BattleProcessor.cpp +++ b/server/battles/BattleProcessor.cpp @@ -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 & 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 & obst) { return obst->obstacleType == CObstacleInstance::MOAT; }); diff --git a/test/mock/mock_IGameInfoCallback.h b/test/mock/mock_IGameInfoCallback.h index fb754691d..53c2b1178 100644 --- a/test/mock/mock_IGameInfoCallback.h +++ b/test/mock/mock_IGameInfoCallback.h @@ -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 diff --git a/test/mock/mock_spells_Mechanics.h b/test/mock/mock_spells_Mechanics.h index 10b4b2a57..985e093f3 100644 --- a/test/mock/mock_spells_Mechanics.h +++ b/test/mock/mock_spells_Mechanics.h @@ -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));