diff --git a/AI/EmptyAI/CEmptyAI.cpp b/AI/EmptyAI/CEmptyAI.cpp index f3b4dd9c5..2074535a3 100644 --- a/AI/EmptyAI/CEmptyAI.cpp +++ b/AI/EmptyAI/CEmptyAI.cpp @@ -45,7 +45,7 @@ void CEmptyAI::yourTacticPhase(int distance) cb->battleMakeTacticAction(BattleAction::makeEndOFTacticPhase(cb->battleGetTacticsSide())); } -void CEmptyAI::heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector &skills, QueryID queryID) +void CEmptyAI::heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector &skills, QueryID queryID) { cb->selectionMade(CRandomGenerator::getDefault().nextInt((int)skills.size() - 1), queryID); } diff --git a/AI/EmptyAI/CEmptyAI.h b/AI/EmptyAI/CEmptyAI.h index a71806e62..8a48a797c 100644 --- a/AI/EmptyAI/CEmptyAI.h +++ b/AI/EmptyAI/CEmptyAI.h @@ -26,7 +26,7 @@ public: void yourTurn() override; void yourTacticPhase(int distance) override; void activeStack(const CStack * stack) override; - void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector &skills, QueryID queryID) override; + void heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector &skills, QueryID queryID) override; void commanderGotLevel (const CCommanderInstance * commander, std::vector skills, QueryID queryID) override; void showBlockingDialog(const std::string &text, const std::vector &components, QueryID askID, const int soundID, bool selection, bool cancel) override; void showTeleportDialog(TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID) override; diff --git a/AI/Nullkiller/AIGateway.cpp b/AI/Nullkiller/AIGateway.cpp index 697d11eaa..955269029 100644 --- a/AI/Nullkiller/AIGateway.cpp +++ b/AI/Nullkiller/AIGateway.cpp @@ -314,9 +314,9 @@ void AIGateway::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID her }); } -void AIGateway::heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) +void AIGateway::heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val) { - LOG_TRACE_PARAMS(logAi, "which '%i', val '%i'", which % val); + LOG_TRACE_PARAMS(logAi, "which '%i', val '%i'", static_cast(which) % val); NET_EVENT_HANDLER; } @@ -552,7 +552,7 @@ void AIGateway::yourTurn() makingTurn = std::make_unique(&AIGateway::makeTurn, this); } -void AIGateway::heroGotLevel(const CGHeroInstance * hero, PrimarySkill::PrimarySkill pskill, std::vector & skills, QueryID queryID) +void AIGateway::heroGotLevel(const CGHeroInstance * hero, PrimarySkill pskill, std::vector & skills, QueryID queryID) { LOG_TRACE_PARAMS(logAi, "queryID '%i'", queryID); NET_EVENT_HANDLER; diff --git a/AI/Nullkiller/AIGateway.h b/AI/Nullkiller/AIGateway.h index 3a9c23b31..ec7f61aac 100644 --- a/AI/Nullkiller/AIGateway.h +++ b/AI/Nullkiller/AIGateway.h @@ -113,7 +113,7 @@ public: void initGameInterface(std::shared_ptr env, std::shared_ptr CB) override; void yourTurn() override; - void heroGotLevel(const CGHeroInstance * hero, PrimarySkill::PrimarySkill pskill, std::vector & skills, QueryID queryID) override; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id + void heroGotLevel(const CGHeroInstance * hero, PrimarySkill pskill, std::vector & skills, QueryID queryID) override; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id void commanderGotLevel(const CCommanderInstance * commander, std::vector skills, QueryID queryID) override; //TODO void showBlockingDialog(const std::string & text, const std::vector & components, QueryID askID, const int soundID, bool selection, bool cancel) override; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID. void showGarrisonDialog(const CArmedInstance * up, const CGHeroInstance * down, bool removableUnits, QueryID queryID) override; //all stacks operations between these objects become allowed, interface has to call onEnd when done @@ -144,7 +144,7 @@ public: void heroVisitsTown(const CGHeroInstance * hero, const CGTownInstance * town) override; void tileRevealed(const std::unordered_set & pos) override; void heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query) override; - void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) override; + void heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val) override; void showRecruitmentDialog(const CGDwelling * dwelling, const CArmedInstance * dst, int level) override; void heroMovePointsChanged(const CGHeroInstance * hero) override; void garrisonsChanged(ObjectInstanceID id1, ObjectInstanceID id2) override; diff --git a/AI/Nullkiller/AIUtility.cpp b/AI/Nullkiller/AIUtility.cpp index 04184bcda..501d882c8 100644 --- a/AI/Nullkiller/AIUtility.cpp +++ b/AI/Nullkiller/AIUtility.cpp @@ -241,7 +241,7 @@ bool isObjectPassable(const CGObjectInstance * obj) } // Pathfinder internal helper -bool isObjectPassable(const CGObjectInstance * obj, PlayerColor playerColor, PlayerRelations::PlayerRelations objectRelations) +bool isObjectPassable(const CGObjectInstance * obj, PlayerColor playerColor, PlayerRelations objectRelations) { if((obj->ID == Obj::GARRISON || obj->ID == Obj::GARRISON2) && objectRelations != PlayerRelations::ENEMIES) diff --git a/AI/Nullkiller/AIUtility.h b/AI/Nullkiller/AIUtility.h index b3d50e3e3..646616f1a 100644 --- a/AI/Nullkiller/AIUtility.h +++ b/AI/Nullkiller/AIUtility.h @@ -226,7 +226,7 @@ void foreach_neighbour(CCallback * cbp, const int3 & pos, const Func & foo) // a bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater); bool isObjectPassable(const CGObjectInstance * obj); bool isObjectPassable(const Nullkiller * ai, const CGObjectInstance * obj); -bool isObjectPassable(const CGObjectInstance * obj, PlayerColor playerColor, PlayerRelations::PlayerRelations objectRelations); +bool isObjectPassable(const CGObjectInstance * obj, PlayerColor playerColor, PlayerRelations objectRelations); bool isBlockVisitObj(const int3 & pos); bool isWeeklyRevisitable(const CGObjectInstance * obj); diff --git a/AI/Nullkiller/Engine/PriorityEvaluator.cpp b/AI/Nullkiller/Engine/PriorityEvaluator.cpp index 6e3e5f754..7b0b40086 100644 --- a/AI/Nullkiller/Engine/PriorityEvaluator.cpp +++ b/AI/Nullkiller/Engine/PriorityEvaluator.cpp @@ -244,10 +244,10 @@ uint64_t evaluateArtifactArmyValue(CArtifactInstance * art) 10 * art->valOfBonuses(BonusType::MOVEMENT, 1) + 1200 * art->valOfBonuses(BonusType::STACKS_SPEED) + 700 * art->valOfBonuses(BonusType::MORALE) - + 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK) - + 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE) - + 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, PrimarySkill::KNOWLEDGE) - + 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, PrimarySkill::SPELL_POWER) + + 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::ATTACK)) + + 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::DEFENSE)) + + 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::KNOWLEDGE)) + + 700 * art->valOfBonuses(BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::SPELL_POWER)) + 500 * art->valOfBonuses(BonusType::LUCK); auto classValue = 0; diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 6aa6a187a..d2da3e13a 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -351,9 +351,9 @@ void VCAI::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, Q }); } -void VCAI::heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) +void VCAI::heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val) { - LOG_TRACE_PARAMS(logAi, "which '%i', val '%i'", which % val); + LOG_TRACE_PARAMS(logAi, "which '%i', val '%i'", static_cast(which) % val); NET_EVENT_HANDLER; } @@ -618,7 +618,7 @@ void VCAI::yourTurn() makingTurn = std::make_unique(&VCAI::makeTurn, this); } -void VCAI::heroGotLevel(const CGHeroInstance * hero, PrimarySkill::PrimarySkill pskill, std::vector & skills, QueryID queryID) +void VCAI::heroGotLevel(const CGHeroInstance * hero, PrimarySkill pskill, std::vector & skills, QueryID queryID) { LOG_TRACE_PARAMS(logAi, "queryID '%i'", queryID); NET_EVENT_HANDLER; diff --git a/AI/VCAI/VCAI.h b/AI/VCAI/VCAI.h index e1fd11c0f..34c53f258 100644 --- a/AI/VCAI/VCAI.h +++ b/AI/VCAI/VCAI.h @@ -146,7 +146,7 @@ public: void initGameInterface(std::shared_ptr ENV, std::shared_ptr CB) override; void yourTurn() override; - void heroGotLevel(const CGHeroInstance * hero, PrimarySkill::PrimarySkill pskill, std::vector & skills, QueryID queryID) override; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id + void heroGotLevel(const CGHeroInstance * hero, PrimarySkill pskill, std::vector & skills, QueryID queryID) override; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id void commanderGotLevel(const CCommanderInstance * commander, std::vector skills, QueryID queryID) override; //TODO void showBlockingDialog(const std::string & text, const std::vector & components, QueryID askID, const int soundID, bool selection, bool cancel) override; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID. void showGarrisonDialog(const CArmedInstance * up, const CGHeroInstance * down, bool removableUnits, QueryID queryID) override; //all stacks operations between these objects become allowed, interface has to call onEnd when done @@ -177,7 +177,7 @@ public: void heroVisitsTown(const CGHeroInstance * hero, const CGTownInstance * town) override; void tileRevealed(const std::unordered_set & pos) override; void heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query) override; - void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) override; + void heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val) override; void showRecruitmentDialog(const CGDwelling * dwelling, const CArmedInstance * dst, int level) override; void heroMovePointsChanged(const CGHeroInstance * hero) override; void garrisonsChanged(ObjectInstanceID id1, ObjectInstanceID id2) override; diff --git a/CCallback.cpp b/CCallback.cpp index 93f7fb670..227e2f0a9 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -242,12 +242,12 @@ void CCallback::buyArtifact(const CGHeroInstance *hero, ArtifactID aid) sendRequest(&pack); } -void CCallback::trade(const IMarket * market, EMarketMode::EMarketMode mode, ui32 id1, ui32 id2, ui32 val1, const CGHeroInstance * hero) +void CCallback::trade(const IMarket * market, EMarketMode mode, ui32 id1, ui32 id2, ui32 val1, const CGHeroInstance * hero) { trade(market, mode, std::vector(1, id1), std::vector(1, id2), std::vector(1, val1), hero); } -void CCallback::trade(const IMarket * market, EMarketMode::EMarketMode mode, const std::vector & id1, const std::vector & id2, const std::vector & val1, const CGHeroInstance * hero) +void CCallback::trade(const IMarket * market, EMarketMode mode, const std::vector & id1, const std::vector & id2, const std::vector & val1, const CGHeroInstance * hero) { TradeOnMarketplace pack; pack.marketId = dynamic_cast(market)->id; diff --git a/CCallback.h b/CCallback.h index 637b9b6c9..062ef8185 100644 --- a/CCallback.h +++ b/CCallback.h @@ -75,8 +75,8 @@ public: virtual bool upgradeCreature(const CArmedInstance *obj, SlotID stackPos, CreatureID newID=CreatureID::NONE)=0; //if newID==-1 then best possible upgrade will be made virtual void swapGarrisonHero(const CGTownInstance *town)=0; - virtual void trade(const IMarket * market, EMarketMode::EMarketMode mode, ui32 id1, ui32 id2, ui32 val1, const CGHeroInstance * hero = nullptr)=0; //mode==0: sell val1 units of id1 resource for id2 resiurce - virtual void trade(const IMarket * market, EMarketMode::EMarketMode mode, const std::vector & id1, const std::vector & id2, const std::vector & val1, const CGHeroInstance * hero = nullptr)=0; + virtual void trade(const IMarket * market, EMarketMode mode, ui32 id1, ui32 id2, ui32 val1, const CGHeroInstance * hero = nullptr)=0; //mode==0: sell val1 units of id1 resource for id2 resiurce + virtual void trade(const IMarket * market, EMarketMode mode, const std::vector & id1, const std::vector & id2, const std::vector & val1, const CGHeroInstance * hero = nullptr)=0; virtual int selectionMade(int selection, QueryID queryID) =0; virtual int sendQueryReply(const JsonNode & reply, QueryID queryID) =0; @@ -171,8 +171,8 @@ public: void endTurn() override; void swapGarrisonHero(const CGTownInstance *town) override; void buyArtifact(const CGHeroInstance *hero, ArtifactID aid) override; - void trade(const IMarket * market, EMarketMode::EMarketMode mode, ui32 id1, ui32 id2, ui32 val1, const CGHeroInstance * hero = nullptr) override; - void trade(const IMarket * market, EMarketMode::EMarketMode mode, const std::vector & id1, const std::vector & id2, const std::vector & val1, const CGHeroInstance * hero = nullptr) override; + void trade(const IMarket * market, EMarketMode mode, ui32 id1, ui32 id2, ui32 val1, const CGHeroInstance * hero = nullptr) override; + void trade(const IMarket * market, EMarketMode mode, const std::vector & id1, const std::vector & id2, const std::vector & val1, const CGHeroInstance * hero = nullptr) override; void setFormation(const CGHeroInstance * hero, bool tight) override; void recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero) override; void save(const std::string &fname) override; diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index a5a9a9c31..5d62dbdf0 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -466,10 +466,10 @@ void CPlayerInterface::openTownWindow(const CGTownInstance * town) GH.windows().pushWindow(newCastleInt); } -void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) +void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val) { EVENT_HANDLER_CALLED_BY_CLIENT; - if (which == 4) + if (which == PrimarySkill::EXPERIENCE) { for (auto ctw : GH.windows().findWindows()) ctw->setExpToLevel(); @@ -510,7 +510,7 @@ void CPlayerInterface::receivedResource() GH.windows().totalRedraw(); } -void CPlayerInterface::heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector& skills, QueryID queryID) +void CPlayerInterface::heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector& skills, QueryID queryID) { EVENT_HANDLER_CALLED_BY_CLIENT; waitWhileDialog(); diff --git a/client/CPlayerInterface.h b/client/CPlayerInterface.h index c85fce3be..687fee93c 100644 --- a/client/CPlayerInterface.h +++ b/client/CPlayerInterface.h @@ -109,11 +109,11 @@ protected: // Call-ins from server, should not be called directly, but only via void heroVisit(const CGHeroInstance * visitor, const CGObjectInstance * visitedObj, bool start) override; void heroCreated(const CGHeroInstance* hero) override; - void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector &skills, QueryID queryID) override; + void heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector &skills, QueryID queryID) override; void commanderGotLevel (const CCommanderInstance * commander, std::vector skills, QueryID queryID) override; void heroInGarrisonChange(const CGTownInstance *town) override; void heroMoved(const TryMoveHero & details, bool verbose = true) override; - void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) override; + void heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val) override; void heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val) override; void heroManaPointsChanged(const CGHeroInstance * hero) override; void heroMovePointsChanged(const CGHeroInstance * hero) override; diff --git a/client/Client.h b/client/Client.h index 013db8e28..8eb0a275d 100644 --- a/client/Client.h +++ b/client/Client.h @@ -165,7 +165,7 @@ public: bool removeObject(const CGObjectInstance * obj) override {return false;}; void createObject(const int3 & visitablePosition, Obj type, int32_t subtype ) override {}; void setOwner(const CGObjectInstance * obj, PlayerColor owner) override {}; - void changePrimSkill(const CGHeroInstance * hero, PrimarySkill::PrimarySkill which, si64 val, bool abs = false) override {}; + void changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs = false) override {}; void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs = false) override {}; void showBlockingDialog(BlockingDialog * iw) override {}; diff --git a/client/adventureMap/AdventureMapInterface.cpp b/client/adventureMap/AdventureMapInterface.cpp index 8715275a4..18b683e43 100644 --- a/client/adventureMap/AdventureMapInterface.cpp +++ b/client/adventureMap/AdventureMapInterface.cpp @@ -483,7 +483,7 @@ void AdventureMapInterface::onTileLeftClicked(const int3 &mapPos) } //check if we can select this object bool canSelect = topBlocking && topBlocking->ID == Obj::HERO && topBlocking->tempOwner == LOCPLINT->playerID; - canSelect |= topBlocking && topBlocking->ID == Obj::TOWN && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, topBlocking->tempOwner); + canSelect |= topBlocking && topBlocking->ID == Obj::TOWN && LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, topBlocking->tempOwner) != PlayerRelations::ENEMIES; bool isHero = false; if(LOCPLINT->localState->getCurrentArmy()->ID != Obj::HERO) //hero is not selected (presumably town) diff --git a/client/windows/CHeroWindow.cpp b/client/windows/CHeroWindow.cpp index 771d4a521..9e4f8f2fa 100644 --- a/client/windows/CHeroWindow.cpp +++ b/client/windows/CHeroWindow.cpp @@ -222,7 +222,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded) //primary skills support for(size_t g=0; gbonusValue = curHero->getPrimSkillLevel(static_cast(g)); + primSkillAreas[g]->bonusValue = curHero->getPrimSkillLevel(static_cast(g)); primSkillValues[g]->setText(std::to_string(primSkillAreas[g]->bonusValue)); } diff --git a/client/windows/CKingdomInterface.cpp b/client/windows/CKingdomInterface.cpp index d92c6936f..c145f3d4f 100644 --- a/client/windows/CKingdomInterface.cpp +++ b/client/windows/CKingdomInterface.cpp @@ -315,7 +315,7 @@ si64 InfoBoxHeroData::getValue() switch(type) { case HERO_PRIMARY_SKILL: - return hero->getPrimSkillLevel(static_cast(index)); + return hero->getPrimSkillLevel(static_cast(index)); case HERO_MANA: return hero->mana; case HERO_EXPERIENCE: diff --git a/client/windows/CTradeWindow.cpp b/client/windows/CTradeWindow.cpp index 7787ec4de..4afe99a6c 100644 --- a/client/windows/CTradeWindow.cpp +++ b/client/windows/CTradeWindow.cpp @@ -317,7 +317,7 @@ void CTradeWindow::CTradeableItem::setArtInstance(const CArtifactInstance *art) setID(-1); } -CTradeWindow::CTradeWindow(std::string bgName, const IMarket *Market, const CGHeroInstance *Hero, EMarketMode::EMarketMode Mode): +CTradeWindow::CTradeWindow(std::string bgName, const IMarket *Market, const CGHeroInstance *Hero, EMarketMode Mode): CWindowObject(PLAYER_COLORED, bgName), market(Market), hero(Hero), @@ -585,7 +585,7 @@ void CTradeWindow::getEmptySlots(std::set> & toR toRemove.insert(item); } -void CTradeWindow::setMode(EMarketMode::EMarketMode Mode) +void CTradeWindow::setMode(EMarketMode Mode) { const IMarket *m = market; const CGHeroInstance *h = hero; @@ -616,7 +616,7 @@ void CTradeWindow::artifactSelected(CHeroArtPlace *slot) selectionChanged(true); } -std::string CMarketplaceWindow::getBackgroundForMode(EMarketMode::EMarketMode mode) +std::string CMarketplaceWindow::getBackgroundForMode(EMarketMode mode) { switch(mode) { @@ -635,7 +635,7 @@ std::string CMarketplaceWindow::getBackgroundForMode(EMarketMode::EMarketMode mo return ""; } -CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInstance * Hero, EMarketMode::EMarketMode Mode) +CMarketplaceWindow::CMarketplaceWindow(const IMarket * Market, const CGHeroInstance * Hero, EMarketMode Mode) : CTradeWindow(getBackgroundForMode(Mode), Market, Hero, Mode) { OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); @@ -870,7 +870,7 @@ void CMarketplaceWindow::selectionChanged(bool side) redraw(); } -bool CMarketplaceWindow::printButtonFor(EMarketMode::EMarketMode M) const +bool CMarketplaceWindow::printButtonFor(EMarketMode M) const { return market->allowsTrade(M) && M != mode && (hero || ( M != EMarketMode::CREATURE_RESOURCE && M != EMarketMode::RESOURCE_ARTIFACT && M != EMarketMode::ARTIFACT_RESOURCE )); } @@ -1075,7 +1075,7 @@ void CMarketplaceWindow::updateTraderText() traderText->setText(CGI->generaltexth->allTexts[gnrtxtnr]); } -CAltarWindow::CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero, EMarketMode::EMarketMode Mode) +CAltarWindow::CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero, EMarketMode Mode) : CTradeWindow((Mode == EMarketMode::CREATURE_EXP ? "ALTARMON.bmp" : "ALTRART2.bmp"), Market, Hero, Mode) { OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); diff --git a/client/windows/CTradeWindow.h b/client/windows/CTradeWindow.h index 396b6e435..9b154f013 100644 --- a/client/windows/CTradeWindow.h +++ b/client/windows/CTradeWindow.h @@ -75,7 +75,7 @@ public: std::shared_ptr hRight; EType itemsType[2]; - EMarketMode::EMarketMode mode; + EMarketMode mode; std::shared_ptr ok; std::shared_ptr max; std::shared_ptr deal; @@ -83,7 +83,7 @@ public: std::shared_ptr slider; //for choosing amount to be exchanged bool readyToTrade; - CTradeWindow(std::string bgName, const IMarket * Market, const CGHeroInstance * Hero, EMarketMode::EMarketMode Mode); //c + CTradeWindow(std::string bgName, const IMarket * Market, const CGHeroInstance * Hero, EMarketMode Mode); //c void showAll(Canvas & to) override; @@ -95,7 +95,7 @@ public: void removeItems(const std::set> & toRemove); void removeItem(std::shared_ptr item); void getEmptySlots(std::set> & toRemove); - void setMode(EMarketMode::EMarketMode Mode); //mode setter + void setMode(EMarketMode Mode); //mode setter void artifactSelected(CHeroArtPlace *slot); //used when selling artifacts -> called when user clicked on artifact slot @@ -118,9 +118,9 @@ class CMarketplaceWindow : public CTradeWindow std::shared_ptr titleLabel; std::shared_ptr arts; - bool printButtonFor(EMarketMode::EMarketMode M) const; + bool printButtonFor(EMarketMode M) const; - std::string getBackgroundForMode(EMarketMode::EMarketMode mode); + std::string getBackgroundForMode(EMarketMode mode); public: int r1, r2; //suggested amounts of traded resources bool madeTransaction; //if player made at least one transaction @@ -130,7 +130,7 @@ public: void sliderMoved(int to); void makeDeal(); void selectionChanged(bool side) override; //true == left - CMarketplaceWindow(const IMarket * Market, const CGHeroInstance * Hero = nullptr, EMarketMode::EMarketMode Mode = EMarketMode::RESOURCE_RESOURCE); + CMarketplaceWindow(const IMarket * Market, const CGHeroInstance * Hero = nullptr, EMarketMode Mode = EMarketMode::RESOURCE_RESOURCE); ~CMarketplaceWindow(); Point selectionOffset(bool Left) const override; @@ -157,7 +157,7 @@ public: std::shared_ptr expOnAltar; std::shared_ptr arts; - CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero, EMarketMode::EMarketMode Mode); + CAltarWindow(const IMarket * Market, const CGHeroInstance * Hero, EMarketMode Mode); ~CAltarWindow(); void getExpValues(); diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index e7888cd3e..6e291bc7c 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -400,7 +400,7 @@ void CSplitWindow::sliderMoved(int to) setAmount(rightMin + to, false); } -CLevelWindow::CLevelWindow(const CGHeroInstance * hero, PrimarySkill::PrimarySkill pskill, std::vector & skills, std::function callback) +CLevelWindow::CLevelWindow(const CGHeroInstance * hero, PrimarySkill pskill, std::vector & skills, std::function callback) : CWindowObject(PLAYER_COLORED, "LVLUPBKG"), cb(callback) { @@ -434,9 +434,9 @@ CLevelWindow::CLevelWindow(const CGHeroInstance * hero, PrimarySkill::PrimarySki levelTitle = std::make_shared(192, 162, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, levelTitleText); - skillIcon = std::make_shared("PSKIL42", pskill, 0, 174, 190); + skillIcon = std::make_shared("PSKIL42", static_cast(pskill), 0, 174, 190); - skillValue = std::make_shared(192, 253, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->primarySkillNames[pskill] + " +1"); + skillValue = std::make_shared(192, 253, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->primarySkillNames[static_cast(pskill)] + " +1"); } @@ -1029,7 +1029,7 @@ void CExchangeWindow::updateWidgets() for(int m=0; mgetPrimSkillLevel(static_cast(m)); + auto value = heroInst[leftRight]->getPrimSkillLevel(static_cast(m)); primSkillValues[leftRight][m]->setText(std::to_string(value)); } diff --git a/client/windows/GUIClasses.h b/client/windows/GUIClasses.h index 16edc5808..2e6f2e6df 100644 --- a/client/windows/GUIClasses.h +++ b/client/windows/GUIClasses.h @@ -145,7 +145,7 @@ class CLevelWindow : public CWindowObject void selectionChanged(unsigned to); public: - CLevelWindow(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector &skills, std::function callback); + CLevelWindow(const CGHeroInstance *hero, PrimarySkill pskill, std::vector &skills, std::function callback); ~CLevelWindow(); }; diff --git a/include/vcmi/FactionMember.h b/include/vcmi/FactionMember.h index 508d1092f..77c95f78e 100644 --- a/include/vcmi/FactionMember.h +++ b/include/vcmi/FactionMember.h @@ -15,11 +15,7 @@ VCMI_LIB_NAMESPACE_BEGIN class BonusList; - -namespace PrimarySkill -{ - enum PrimarySkill : int8_t; -} +enum class PrimarySkill : int32_t; class DLL_LINKAGE AFactionMember: public IConstBonusProvider, public INativeTerrainProvider { @@ -51,7 +47,7 @@ public: /** Returns primskill of creature or hero. */ - int getPrimSkillLevel(PrimarySkill::PrimarySkill id) const; + int getPrimSkillLevel(PrimarySkill id) const; /** Returns morale of creature or hero. Taking absolute bonuses into account. For now, uses range from EGameSettings diff --git a/lib/BasicTypes.cpp b/lib/BasicTypes.cpp index 37579a53f..f2edcdf9a 100644 --- a/lib/BasicTypes.cpp +++ b/lib/BasicTypes.cpp @@ -54,7 +54,7 @@ int AFactionMember::getAttack(bool ranged) const { const std::string cachingStr = "type_PRIMARY_SKILLs_ATTACK"; - static const auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK); + static const auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::ATTACK)); return getBonusBearer()->valOfBonuses(selector, cachingStr); } @@ -63,7 +63,7 @@ int AFactionMember::getDefense(bool ranged) const { const std::string cachingStr = "type_PRIMARY_SKILLs_DEFENSE"; - static const auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE); + static const auto selector = Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::DEFENSE)); return getBonusBearer()->valOfBonuses(selector, cachingStr); } @@ -82,12 +82,12 @@ int AFactionMember::getMaxDamage(bool ranged) const return getBonusBearer()->valOfBonuses(selector, cachingStr); } -int AFactionMember::getPrimSkillLevel(PrimarySkill::PrimarySkill id) const +int AFactionMember::getPrimSkillLevel(PrimarySkill id) const { static const CSelector selectorAllSkills = Selector::type()(BonusType::PRIMARY_SKILL); static const std::string keyAllSkills = "type_PRIMARY_SKILL"; auto allSkills = getBonusBearer()->getBonuses(selectorAllSkills, keyAllSkills); - auto ret = allSkills->valOfBonuses(Selector::subtype()(id)); + auto ret = allSkills->valOfBonuses(Selector::subtype()(static_cast(id))); auto minSkillValue = (id == PrimarySkill::SPELL_POWER || id == PrimarySkill::KNOWLEDGE) ? 1 : 0; return std::max(ret, minSkillValue); //otherwise, some artifacts may cause negative skill value effect, sp=0 works in old saves } @@ -183,4 +183,4 @@ bool ACreature::isLiving() const //TODO: theoreticaly there exists "LIVING" bonu } -VCMI_LIB_NAMESPACE_END \ No newline at end of file +VCMI_LIB_NAMESPACE_END diff --git a/lib/CCreatureHandler.cpp b/lib/CCreatureHandler.cpp index 78de10cdf..205aa1ccf 100644 --- a/lib/CCreatureHandler.cpp +++ b/lib/CCreatureHandler.cpp @@ -113,13 +113,13 @@ FactionID CCreature::getFaction() const int32_t CCreature::getBaseAttack() const { - static const auto SELECTOR = Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY)); + static const auto SELECTOR = Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::ATTACK)).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY)); return getExportedBonusList().valOfBonuses(SELECTOR); } int32_t CCreature::getBaseDefense() const { - static const auto SELECTOR = Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY)); + static const auto SELECTOR = Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::DEFENSE)).And(Selector::sourceTypeSel(BonusSource::CREATURE_ABILITY)); return getExportedBonusList().valOfBonuses(SELECTOR); } @@ -345,10 +345,10 @@ void CCreature::updateFrom(const JsonNode & data) addBonus(configNode["speed"].Integer(), BonusType::STACKS_SPEED); if(!configNode["attack"].isNull()) - addBonus(configNode["attack"].Integer(), BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK); + addBonus(configNode["attack"].Integer(), BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::ATTACK)); if(!configNode["defense"].isNull()) - addBonus(configNode["defense"].Integer(), BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE); + addBonus(configNode["defense"].Integer(), BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::DEFENSE)); if(!configNode["damage"]["min"].isNull()) addBonus(configNode["damage"]["min"].Integer(), BonusType::CREATURE_DAMAGE, 1); @@ -603,8 +603,8 @@ CCreature * CCreatureHandler::loadFromJson(const std::string & scope, const Json cre->addBonus(node["hitPoints"].Integer(), BonusType::STACK_HEALTH); cre->addBonus(node["speed"].Integer(), BonusType::STACKS_SPEED); - cre->addBonus(node["attack"].Integer(), BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK); - cre->addBonus(node["defense"].Integer(), BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE); + cre->addBonus(node["attack"].Integer(), BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::ATTACK)); + cre->addBonus(node["defense"].Integer(), BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::DEFENSE)); cre->addBonus(node["damage"]["min"].Integer(), BonusType::CREATURE_DAMAGE, 1); cre->addBonus(node["damage"]["max"].Integer(), BonusType::CREATURE_DAMAGE, 2); @@ -1030,11 +1030,11 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars break; case 'A': b.type = BonusType::PRIMARY_SKILL; - b.subtype = PrimarySkill::ATTACK; + b.subtype = static_cast(PrimarySkill::ATTACK); break; case 'D': b.type = BonusType::PRIMARY_SKILL; - b.subtype = PrimarySkill::DEFENSE; + b.subtype = static_cast(PrimarySkill::DEFENSE); break; case 'M': //Max damage b.type = BonusType::CREATURE_DAMAGE; diff --git a/lib/CGameInfoCallback.cpp b/lib/CGameInfoCallback.cpp index e430d2249..7a89fcf4c 100644 --- a/lib/CGameInfoCallback.cpp +++ b/lib/CGameInfoCallback.cpp @@ -631,7 +631,7 @@ bool CGameInfoCallback::hasAccess(std::optional playerId) const return !player || player->isSpectator() || gs->getPlayerRelations(*playerId, *player) != PlayerRelations::ENEMIES; } -EPlayerStatus::EStatus CGameInfoCallback::getPlayerStatus(PlayerColor player, bool verbose) const +EPlayerStatus CGameInfoCallback::getPlayerStatus(PlayerColor player, bool verbose) const { const PlayerState *ps = gs->getPlayerState(player, verbose); ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!ps, verbose, "No such player!", EPlayerStatus::WRONG); @@ -670,7 +670,7 @@ std::string CGameInfoCallback::getTavernRumor(const CGObjectInstance * townOrTav return text; } -PlayerRelations::PlayerRelations CGameInfoCallback::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const +PlayerRelations CGameInfoCallback::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const { return gs->getPlayerRelations(color1, color2); } diff --git a/lib/CGameInfoCallback.h b/lib/CGameInfoCallback.h index 9808a318d..caebb235a 100644 --- a/lib/CGameInfoCallback.h +++ b/lib/CGameInfoCallback.h @@ -60,9 +60,9 @@ public: virtual const Player * getPlayer(PlayerColor color) const = 0; // virtual int getResource(PlayerColor Player, EGameResID which) const = 0; // bool isVisible(int3 pos) const; -// PlayerRelations::PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const; +// PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const; // void getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj); //get thieves' guild info obtainable while visiting given object -// EPlayerStatus::EStatus getPlayerStatus(PlayerColor player, bool verbose = true) const; //-1 if no such player +// EPlayerStatus getPlayerStatus(PlayerColor player, bool verbose = true) const; //-1 if no such player // PlayerColor getCurrentPlayer() const; //player that currently makes move // TODO synchronous turns virtual PlayerColor getLocalPlayer() const = 0; //player that is currently owning given client (if not a client, then returns current player) // const PlayerSettings * getPlayerSettings(PlayerColor color) const; @@ -148,9 +148,9 @@ public: const Player * getPlayer(PlayerColor color) const override; virtual const PlayerState * getPlayerState(PlayerColor color, bool verbose = true) const; virtual int getResource(PlayerColor Player, GameResID which) const; - virtual PlayerRelations::PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const; + virtual PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const; virtual void getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj); //get thieves' guild info obtainable while visiting given object - virtual EPlayerStatus::EStatus getPlayerStatus(PlayerColor player, bool verbose = true) const; //-1 if no such player + virtual EPlayerStatus getPlayerStatus(PlayerColor player, bool verbose = true) const; //-1 if no such player virtual PlayerColor getCurrentPlayer() const; //player that currently makes move // TODO synchronous turns PlayerColor getLocalPlayer() const override; //player that is currently owning given client (if not a client, then returns current player) virtual const PlayerSettings * getPlayerSettings(PlayerColor color) const; diff --git a/lib/CGameInterface.h b/lib/CGameInterface.h index 089dc2e5f..8d9e1b284 100644 --- a/lib/CGameInterface.h +++ b/lib/CGameInterface.h @@ -91,7 +91,7 @@ public: virtual void yourTurn(){}; //called AFTER playerStartsTurn(player) //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id - virtual void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector &skills, QueryID queryID)=0; + virtual void heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector &skills, QueryID queryID)=0; virtual void commanderGotLevel (const CCommanderInstance * commander, std::vector skills, QueryID queryID)=0; // Show a dialog, player must take decision. If selection then he has to choose between one of given components, diff --git a/lib/CHeroHandler.cpp b/lib/CHeroHandler.cpp index 5bda9995d..c60023ad4 100644 --- a/lib/CHeroHandler.cpp +++ b/lib/CHeroHandler.cpp @@ -207,9 +207,9 @@ CHeroClass::CHeroClass(): { } -void CHeroClassHandler::fillPrimarySkillData(const JsonNode & node, CHeroClass * heroClass, PrimarySkill::PrimarySkill pSkill) const +void CHeroClassHandler::fillPrimarySkillData(const JsonNode & node, CHeroClass * heroClass, PrimarySkill pSkill) const { - const auto & skillName = PrimarySkill::names[pSkill]; + const auto & skillName = NPrimarySkill::names[static_cast(pSkill)]; auto currentPrimarySkillValue = static_cast(node["primarySkills"][skillName].Integer()); //minimal value is 0 for attack and defense and 1 for spell power and knowledge auto primarySkillLegalMinimum = (pSkill == PrimarySkill::ATTACK || pSkill == PrimarySkill::DEFENSE) ? 0 : 1; @@ -333,13 +333,13 @@ std::vector CHeroClassHandler::loadLegacyData() parser.readNumber(); // unused aggression - for(const auto & name : PrimarySkill::names) + for(const auto & name : NPrimarySkill::names) entry["primarySkills"][name].Float() = parser.readNumber(); - for(const auto & name : PrimarySkill::names) + for(const auto & name : NPrimarySkill::names) entry["lowLevelChance"][name].Float() = parser.readNumber(); - for(const auto & name : PrimarySkill::names) + for(const auto & name : NPrimarySkill::names) entry["highLevelChance"][name].Float() = parser.readNumber(); for(const auto & name : NSecondarySkill::names) @@ -547,7 +547,7 @@ static std::vector> createCreatureSpecialty(CreatureID ba { std::shared_ptr bonus = std::make_shared(); bonus->type = BonusType::PRIMARY_SKILL; - bonus->subtype = PrimarySkill::ATTACK; + bonus->subtype = static_cast(PrimarySkill::ATTACK); bonus->val = 0; bonus->limiter.reset(new CCreatureTypeLimiter(specCreature, false)); bonus->updater.reset(new GrowsWithLevelUpdater(specCreature.getAttack(false), stepSize)); @@ -557,7 +557,7 @@ static std::vector> createCreatureSpecialty(CreatureID ba { std::shared_ptr bonus = std::make_shared(); bonus->type = BonusType::PRIMARY_SKILL; - bonus->subtype = PrimarySkill::DEFENSE; + bonus->subtype = static_cast(PrimarySkill::DEFENSE); bonus->val = 0; bonus->limiter.reset(new CCreatureTypeLimiter(specCreature, false)); bonus->updater.reset(new GrowsWithLevelUpdater(specCreature.getDefense(false), stepSize)); diff --git a/lib/CHeroHandler.h b/lib/CHeroHandler.h index 3f11968fb..2e9c5df84 100644 --- a/lib/CHeroHandler.h +++ b/lib/CHeroHandler.h @@ -212,7 +212,7 @@ public: class DLL_LINKAGE CHeroClassHandler : public CHandlerBase { - void fillPrimarySkillData(const JsonNode & node, CHeroClass * heroClass, PrimarySkill::PrimarySkill pSkill) const; + void fillPrimarySkillData(const JsonNode & node, CHeroClass * heroClass, PrimarySkill pSkill) const; public: std::vector loadLegacyData() override; diff --git a/lib/CPlayerState.h b/lib/CPlayerState.h index fa1ab5a1e..1b304eebc 100644 --- a/lib/CPlayerState.h +++ b/lib/CPlayerState.h @@ -38,7 +38,7 @@ public: std::vector quests; //store info about all received quests bool enteredWinningCheatCode, enteredLosingCheatCode; //if true, this player has entered cheat codes for loss / victory - EPlayerStatus::EStatus status; + EPlayerStatus status; std::optional daysWithoutCastle; TurnTimerInfo turnTimer; diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index 85471ec32..04a928ffb 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -527,13 +527,13 @@ void CTownHandler::addBonusesForVanilaBuilding(CBuilding * building) const b = createBonus(building, BonusType::LUCK, +2); break; case BuildingSubID::SPELL_POWER_GARRISON_BONUS: - b = createBonus(building, BonusType::PRIMARY_SKILL, +2, PrimarySkill::SPELL_POWER); + b = createBonus(building, BonusType::PRIMARY_SKILL, +2, static_cast(PrimarySkill::SPELL_POWER)); break; case BuildingSubID::ATTACK_GARRISON_BONUS: - b = createBonus(building, BonusType::PRIMARY_SKILL, +2, PrimarySkill::ATTACK); + b = createBonus(building, BonusType::PRIMARY_SKILL, +2, static_cast(PrimarySkill::ATTACK)); break; case BuildingSubID::DEFENSE_GARRISON_BONUS: - b = createBonus(building, BonusType::PRIMARY_SKILL, +2, PrimarySkill::DEFENSE); + b = createBonus(building, BonusType::PRIMARY_SKILL, +2, static_cast(PrimarySkill::DEFENSE)); break; case BuildingSubID::LIGHTHOUSE: b = createBonus(building, BonusType::MOVEMENT, +500, playerPropagator, 0); diff --git a/lib/GameConstants.h b/lib/GameConstants.h index e22ffb2f5..d9667dd56 100644 --- a/lib/GameConstants.h +++ b/lib/GameConstants.h @@ -412,11 +412,15 @@ class TeleportChannelID : public BaseForID }; // Enum declarations -namespace PrimarySkill +enum class PrimarySkill : int32_t { - enum PrimarySkill : int8_t { NONE = -1, ATTACK, DEFENSE, SPELL_POWER, KNOWLEDGE, - EXPERIENCE = 4}; //for some reason changePrimSkill uses it -} + NONE = -1, + ATTACK, + DEFENSE, + SPELL_POWER, + KNOWLEDGE, + EXPERIENCE = 4 //for some reason changePrimSkill uses it +}; class SecondarySkillBase : public EntityBase { @@ -599,15 +603,12 @@ namespace BuildingSubID }; } -namespace EMarketMode +enum class EMarketMode : int32_t { - enum EMarketMode - { - RESOURCE_RESOURCE, RESOURCE_PLAYER, CREATURE_RESOURCE, RESOURCE_ARTIFACT, - ARTIFACT_RESOURCE, ARTIFACT_EXP, CREATURE_EXP, CREATURE_UNDEAD, RESOURCE_SKILL, - MARTKET_AFTER_LAST_PLACEHOLDER - }; -} + RESOURCE_RESOURCE, RESOURCE_PLAYER, CREATURE_RESOURCE, RESOURCE_ARTIFACT, + ARTIFACT_RESOURCE, ARTIFACT_EXP, CREATURE_EXP, CREATURE_UNDEAD, RESOURCE_SKILL, + MARTKET_AFTER_LAST_PLACEHOLDER +}; namespace MappedKeys { @@ -686,7 +687,7 @@ namespace MappedKeys { "treasury", BuildingSubID::TREASURY } }; - static const std::map MARKET_NAMES_TO_TYPES = + static const std::map MARKET_NAMES_TO_TYPES = { { "resource-resource", EMarketMode::RESOURCE_RESOURCE }, { "resource-player", EMarketMode::RESOURCE_PLAYER }, @@ -1040,29 +1041,16 @@ enum class EActionType : int8_t DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const EActionType actionType); -class DLL_LINKAGE EDiggingStatus +enum class EDiggingStatus : int32_t { -public: - enum EEDiggingStatus - { - UNKNOWN = -1, - CAN_DIG = 0, - LACK_OF_MOVEMENT, - WRONG_TERRAIN, - TILE_OCCUPIED, - BACKPACK_IS_FULL - }; - - EDiggingStatus(EEDiggingStatus _num = UNKNOWN) : num(_num) - {} - - ID_LIKE_CLASS_COMMON(EDiggingStatus, EEDiggingStatus) - - EEDiggingStatus num; + UNKNOWN = -1, + CAN_DIG = 0, + LACK_OF_MOVEMENT, + WRONG_TERRAIN, + TILE_OCCUPIED, + BACKPACK_IS_FULL }; -ID_LIKE_OPERATORS(EDiggingStatus, EDiggingStatus::EEDiggingStatus) - class DLL_LINKAGE EPathfindingLayer { public: @@ -1083,15 +1071,20 @@ DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const EPathfindingLayer ID_LIKE_OPERATORS(EPathfindingLayer, EPathfindingLayer::EEPathfindingLayer) -namespace EPlayerStatus +enum class EPlayerStatus { - enum EStatus {WRONG = -1, INGAME, LOSER, WINNER}; -} + WRONG = -1, + INGAME, + LOSER, + WINNER +}; -namespace PlayerRelations +enum class PlayerRelations { - enum PlayerRelations {ENEMIES, ALLIES, SAME_PLAYER}; -} + ENEMIES, + ALLIES, + SAME_PLAYER +}; class ArtifactPosition { diff --git a/lib/IGameCallback.h b/lib/IGameCallback.h index 747d71d72..30bed8824 100644 --- a/lib/IGameCallback.h +++ b/lib/IGameCallback.h @@ -92,7 +92,7 @@ public: virtual bool removeObject(const CGObjectInstance * obj)=0; virtual void createObject(const int3 & visitablePosition, Obj type, int32_t subtype = 0) = 0; virtual void setOwner(const CGObjectInstance * objid, PlayerColor owner)=0; - virtual void changePrimSkill(const CGHeroInstance * hero, PrimarySkill::PrimarySkill which, si64 val, bool abs=false)=0; + virtual void changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs=false)=0; virtual void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false)=0; virtual void showBlockingDialog(BlockingDialog *iw) =0; virtual void showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits) =0; //cb will be called when player closes garrison window diff --git a/lib/IGameEventsReceiver.h b/lib/IGameEventsReceiver.h index 8d85df35e..a19c9f11e 100644 --- a/lib/IGameEventsReceiver.h +++ b/lib/IGameEventsReceiver.h @@ -98,7 +98,7 @@ public: virtual void heroCreated(const CGHeroInstance*){}; virtual void heroInGarrisonChange(const CGTownInstance *town){}; virtual void heroMoved(const TryMoveHero & details, bool verbose = true){}; - virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val){}; + virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val){}; virtual void heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val){}; virtual void heroManaPointsChanged(const CGHeroInstance * hero){} //not called at the beginning of turn and after spell casts virtual void heroMovePointsChanged(const CGHeroInstance * hero){} //not called at the beginning of turn and after movement diff --git a/lib/JsonRandom.cpp b/lib/JsonRandom.cpp index a883bd904..e5f14a03d 100644 --- a/lib/JsonRandom.cpp +++ b/lib/JsonRandom.cpp @@ -119,7 +119,7 @@ namespace JsonRandom std::vector ret; if(value.isStruct()) { - for(const auto & name : PrimarySkill::names) + for(const auto & name : NPrimarySkill::names) { ret.push_back(loadValue(value[name], rng)); } @@ -127,12 +127,12 @@ namespace JsonRandom if(value.isVector()) { ret.resize(GameConstants::PRIMARY_SKILLS, 0); - std::set defaultStats(std::begin(PrimarySkill::names), std::end(PrimarySkill::names)); + std::set defaultStats(std::begin(NPrimarySkill::names), std::end(NPrimarySkill::names)); for(const auto & element : value.Vector()) { auto key = loadKey(element, rng, defaultStats); defaultStats.erase(key); - int id = vstd::find_pos(PrimarySkill::names, key); + int id = vstd::find_pos(NPrimarySkill::names, key); if(id != -1) ret[id] += loadValue(element, rng); } diff --git a/lib/NetPacks.h b/lib/NetPacks.h index afcbe16c4..a958e9606 100644 --- a/lib/NetPacks.h +++ b/lib/NetPacks.h @@ -232,7 +232,7 @@ struct DLL_LINKAGE SetPrimSkill : public CPackForClient ui8 abs = 0; //0 - changes by value; 1 - sets to value ObjectInstanceID id; - PrimarySkill::PrimarySkill which = PrimarySkill::ATTACK; + PrimarySkill which = PrimarySkill::ATTACK; si64 val = 0; template void serialize(Handler & h, const int version) @@ -1318,7 +1318,7 @@ struct DLL_LINKAGE HeroLevelUp : public Query PlayerColor player; ObjectInstanceID heroId; - PrimarySkill::PrimarySkill primskill = PrimarySkill::ATTACK; + PrimarySkill primskill = PrimarySkill::ATTACK; std::vector skills; void applyGs(CGameState * gs) const; @@ -2425,7 +2425,7 @@ struct DLL_LINKAGE TradeOnMarketplace : public CPackForServer ObjectInstanceID marketId; ObjectInstanceID heroId; - EMarketMode::EMarketMode mode = EMarketMode::RESOURCE_RESOURCE; + EMarketMode mode = EMarketMode::RESOURCE_RESOURCE; std::vector r1, r2; //mode 0: r1 - sold resource, r2 - bought res (exception: when sacrificing art r1 is art id [todo: make r2 preferred slot?] std::vector val; //units of sold resource diff --git a/lib/StringConstants.h b/lib/StringConstants.h index 7a8013330..e6190f756 100644 --- a/lib/StringConstants.h +++ b/lib/StringConstants.h @@ -29,7 +29,7 @@ namespace GameConstants const std::string ALIGNMENT_NAMES [3] = {"good", "evil", "neutral"}; } -namespace PrimarySkill +namespace NPrimarySkill { const std::string names [GameConstants::PRIMARY_SKILLS] = { "attack", "defence", "spellpower", "knowledge" }; } diff --git a/lib/battle/BattleInfo.cpp b/lib/battle/BattleInfo.cpp index b2d5cd3a8..eb6cd3627 100644 --- a/lib/battle/BattleInfo.cpp +++ b/lib/battle/BattleInfo.cpp @@ -475,8 +475,8 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const static auto nativeTerrain = std::make_shared(); curB->addNewBonus(std::make_shared(BonusDuration::ONE_BATTLE, BonusType::STACKS_SPEED, BonusSource::TERRAIN_NATIVE, 1, 0, 0)->addLimiter(nativeTerrain)); - curB->addNewBonus(std::make_shared(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, 0, PrimarySkill::ATTACK)->addLimiter(nativeTerrain)); - curB->addNewBonus(std::make_shared(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, 0, PrimarySkill::DEFENSE)->addLimiter(nativeTerrain)); + curB->addNewBonus(std::make_shared(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, 0, static_cast(PrimarySkill::ATTACK))->addLimiter(nativeTerrain)); + curB->addNewBonus(std::make_shared(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, 0, static_cast(PrimarySkill::DEFENSE))->addLimiter(nativeTerrain)); ////////////////////////////////////////////////////////////////////////// //tactics diff --git a/lib/battle/CUnitState.cpp b/lib/battle/CUnitState.cpp index f317d429d..098b4e746 100644 --- a/lib/battle/CUnitState.cpp +++ b/lib/battle/CUnitState.cpp @@ -342,8 +342,8 @@ CUnitState::CUnitState(): totalAttacks(this, Selector::type()(BonusType::ADDITIONAL_ATTACK), 1), minDamage(this, Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 0).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 1)), 0), maxDamage(this, Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 0).Or(Selector::typeSubtype(BonusType::CREATURE_DAMAGE, 2)), 0), - attack(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::ATTACK), 0), - defence(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE), 0), + attack(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::ATTACK)), 0), + defence(this, Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::DEFENSE)), 0), inFrenzy(this, Selector::type()(BonusType::IN_FRENZY)), cloneLifetimeMarker(this, Selector::type()(BonusType::NONE).And(Selector::source(BonusSource::SPELL_EFFECT, SpellID::CLONE))), cloneID(-1) diff --git a/lib/battle/DamageCalculator.cpp b/lib/battle/DamageCalculator.cpp index 5ef8c7bed..b9c7cedb7 100644 --- a/lib/battle/DamageCalculator.cpp +++ b/lib/battle/DamageCalculator.cpp @@ -50,9 +50,9 @@ DamageRange DamageCalculator::getBaseDamageSingle() const if(info.attacker->hasBonus(selectorSiedgeWeapon, cachingStrSiedgeWeapon) && info.attacker->creatureIndex() != CreatureID::ARROW_TOWERS) { - auto retrieveHeroPrimSkill = [&](int skill) -> int + auto retrieveHeroPrimSkill = [&](PrimarySkill skill) -> int { - std::shared_ptr b = info.attacker->getBonus(Selector::sourceTypeSel(BonusSource::HERO_BASE_SKILL).And(Selector::typeSubtype(BonusType::PRIMARY_SKILL, skill))); + std::shared_ptr b = info.attacker->getBonus(Selector::sourceTypeSel(BonusSource::HERO_BASE_SKILL).And(Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast(skill)))); return b ? b->val : 0; }; diff --git a/lib/bonuses/Bonus.cpp b/lib/bonuses/Bonus.cpp index 6a24f983e..cd493b17b 100644 --- a/lib/bonuses/Bonus.cpp +++ b/lib/bonuses/Bonus.cpp @@ -139,7 +139,7 @@ static JsonNode subtypeToJson(BonusType type, int subtype) switch(type) { case BonusType::PRIMARY_SKILL: - return JsonUtils::stringNode("primSkill." + PrimarySkill::names[subtype]); + return JsonUtils::stringNode("primSkill." + NPrimarySkill::names[subtype]); case BonusType::SPECIAL_SPELL_LEV: case BonusType::SPECIFIC_SPELL_DAMAGE: case BonusType::SPELL: diff --git a/lib/gameState/CGameState.cpp b/lib/gameState/CGameState.cpp index 9b5e78cd6..2e6e15c2e 100644 --- a/lib/gameState/CGameState.cpp +++ b/lib/gameState/CGameState.cpp @@ -1297,7 +1297,7 @@ UpgradeInfo CGameState::fillUpgradeInfo(const CStackInstance &stack) const return ret; } -PlayerRelations::PlayerRelations CGameState::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const +PlayerRelations CGameState::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const { if ( color1 == color2 ) return PlayerRelations::SAME_PLAYER; diff --git a/lib/gameState/CGameState.h b/lib/gameState/CGameState.h index ca906f6ff..d151e91d3 100644 --- a/lib/gameState/CGameState.h +++ b/lib/gameState/CGameState.h @@ -113,7 +113,7 @@ public: BattleField battleGetBattlefieldType(int3 tile, CRandomGenerator & rand); void fillUpgradeInfo(const CArmedInstance *obj, SlotID stackPos, UpgradeInfo &out) const override; - PlayerRelations::PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const override; + PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2) const override; bool checkForVisitableDir(const int3 & src, const int3 & dst) const; //check if src tile is visitable from dst tile void calculatePaths(const CGHeroInstance *hero, CPathsInfo &out) override; //calculates possible paths for hero, by default uses current hero position and movement left; returns pointer to newly allocated CPath or nullptr if path does not exists void calculatePaths(const std::shared_ptr & config) override; diff --git a/lib/gameState/InfoAboutArmy.cpp b/lib/gameState/InfoAboutArmy.cpp index 21531787e..12d6fd81c 100644 --- a/lib/gameState/InfoAboutArmy.cpp +++ b/lib/gameState/InfoAboutArmy.cpp @@ -125,7 +125,7 @@ void InfoAboutHero::initFromHero(const CGHeroInstance *h, InfoAboutHero::EInfoLe for (int i = 0; i < GameConstants::PRIMARY_SKILLS ; i++) { - details->primskills[i] = h->getPrimSkillLevel(static_cast(i)); + details->primskills[i] = h->getPrimSkillLevel(static_cast(i)); } if (infoLevel == EInfoLevel::INBATTLE) details->manaLimit = h->manaLimit(); diff --git a/lib/mapObjectConstructors/CommonConstructors.h b/lib/mapObjectConstructors/CommonConstructors.h index 53e73d8d8..58ea22ca7 100644 --- a/lib/mapObjectConstructors/CommonConstructors.h +++ b/lib/mapObjectConstructors/CommonConstructors.h @@ -141,7 +141,7 @@ class MarketInstanceConstructor : public CDefaultObjectTypeHandler protected: void initTypeData(const JsonNode & config) override; - std::set marketModes; + std::set marketModes; JsonNode predefinedOffer; int marketEfficiency; diff --git a/lib/mapObjects/CGDwelling.cpp b/lib/mapObjects/CGDwelling.cpp index 3253e3e36..8f4b2d982 100644 --- a/lib/mapObjects/CGDwelling.cpp +++ b/lib/mapObjects/CGDwelling.cpp @@ -173,12 +173,12 @@ void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const return; } - PlayerRelations::PlayerRelations relations = cb->gameState()->getPlayerRelations( h->tempOwner, tempOwner ); + PlayerRelations relations = cb->gameState()->getPlayerRelations( h->tempOwner, tempOwner ); if ( relations == PlayerRelations::ALLIES ) return;//do not allow recruiting or capturing - if( !relations && stacksCount() > 0) //object is guarded, owned by enemy + if(relations == PlayerRelations::ENEMIES && stacksCount() > 0) //object is guarded, owned by enemy { BlockingDialog bd(true,false); bd.player = h->tempOwner; @@ -194,7 +194,7 @@ void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const } // TODO this shouldn't be hardcoded - if(!relations && ID != Obj::WAR_MACHINE_FACTORY && ID != Obj::REFUGEE_CAMP) + if(relations == PlayerRelations::ENEMIES && ID != Obj::WAR_MACHINE_FACTORY && ID != Obj::REFUGEE_CAMP) { cb->setOwner(this, h->tempOwner); } diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 309b65468..a52d5940e 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -315,7 +315,7 @@ void CGHeroInstance::initHero(CRandomGenerator & rand) { for(int g=0; g(g), type->heroClass->primarySkillInitial[g]); + pushPrimSkill(static_cast(g), type->heroClass->primarySkillInitial[g]); } } if(secSkills.size() == 1 && secSkills[0] == std::pair(SecondarySkill::DEFAULT, -1)) //set secondary skills to default @@ -456,7 +456,7 @@ void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const if (ID == Obj::HERO) { - if( cb->gameState()->getPlayerRelations(tempOwner, h->tempOwner)) //our or ally hero + if( cb->gameState()->getPlayerRelations(tempOwner, h->tempOwner) != PlayerRelations::ENEMIES) { //exchange cb->heroExchange(h->id, id); @@ -997,11 +997,11 @@ int32_t CGHeroInstance::getSpellCost(const spells::Spell * sp) const return sp->getCost(getSpellSchoolLevel(sp)); } -void CGHeroInstance::pushPrimSkill( PrimarySkill::PrimarySkill which, int val ) +void CGHeroInstance::pushPrimSkill( PrimarySkill which, int val ) { - assert(!hasBonus(Selector::typeSubtype(BonusType::PRIMARY_SKILL, which) + assert(!hasBonus(Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast(which)) .And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL)))); - addNewBonus(std::make_shared(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::HERO_BASE_SKILL, val, id.getNum(), which)); + addNewBonus(std::make_shared(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::HERO_BASE_SKILL, val, id.getNum(), static_cast(which))); } EAlignment CGHeroInstance::getAlignment() const @@ -1314,7 +1314,7 @@ std::vector CGHeroInstance::getLevelUpProposedSecondarySkills() return skills; } -PrimarySkill::PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & rand) const +PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & rand) const { assert(gainsLevel()); int randomValue = rand.nextInt(99); @@ -1338,7 +1338,7 @@ PrimarySkill::PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & r randomValue = 100 / GameConstants::PRIMARY_SKILLS; } logGlobal->trace("The hero gets the primary skill %d with a probability of %d %%.", primarySkill, randomValue); - return static_cast(primarySkill); + return static_cast(primarySkill); } std::optional CGHeroInstance::nextSecondarySkill(CRandomGenerator & rand) const @@ -1372,12 +1372,12 @@ std::optional CGHeroInstance::nextSecondarySkill(CRandomGenerato return chosenSecondarySkill; } -void CGHeroInstance::setPrimarySkill(PrimarySkill::PrimarySkill primarySkill, si64 value, ui8 abs) +void CGHeroInstance::setPrimarySkill(PrimarySkill primarySkill, si64 value, ui8 abs) { if(primarySkill < PrimarySkill::EXPERIENCE) { auto skill = getBonusLocalFirst(Selector::type()(BonusType::PRIMARY_SKILL) - .And(Selector::subtype()(primarySkill)) + .And(Selector::subtype()(static_cast(primarySkill))) .And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL))); assert(skill); @@ -1578,7 +1578,7 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler) { int value = valOfBonuses(Selector::typeSubtype(BonusType::PRIMARY_SKILL, i).And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL))); - handler.serializeInt(PrimarySkill::names[i], value, 0); + handler.serializeInt(NPrimarySkill::names[i], value, 0); } } } @@ -1591,8 +1591,8 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler) for(int i = 0; i < GameConstants::PRIMARY_SKILLS; ++i) { int value = 0; - handler.serializeInt(PrimarySkill::names[i], value, 0); - pushPrimSkill(static_cast(i), value); + handler.serializeInt(NPrimarySkill::names[i], value, 0); + pushPrimSkill(static_cast(i), value); } } } diff --git a/lib/mapObjects/CGHeroInstance.h b/lib/mapObjects/CGHeroInstance.h index a2ca01d81..65be37cef 100644 --- a/lib/mapObjects/CGHeroInstance.h +++ b/lib/mapObjects/CGHeroInstance.h @@ -181,7 +181,7 @@ public: bool gainsLevel() const; /// Returns the next primary skill on level up. Can only be called if hero can gain a level up. - PrimarySkill::PrimarySkill nextPrimarySkill(CRandomGenerator & rand) const; + PrimarySkill nextPrimarySkill(CRandomGenerator & rand) const; /// Returns the next secondary skill randomly on level up. Can only be called if hero can gain a level up. std::optional nextSecondarySkill(CRandomGenerator & rand) const; @@ -195,7 +195,7 @@ public: bool canLearnSkill() const; bool canLearnSkill(const SecondarySkill & which) const; - void setPrimarySkill(PrimarySkill::PrimarySkill primarySkill, si64 value, ui8 abs); + void setPrimarySkill(PrimarySkill primarySkill, si64 value, ui8 abs); void setSecSkillLevel(const SecondarySkill & which, int val, bool abs); // abs == 0 - changes by value; 1 - sets to value void levelUp(const std::vector & skills); @@ -233,7 +233,7 @@ public: void removeArtifact(ArtifactPosition pos) override; void initExp(CRandomGenerator & rand); void initArmy(CRandomGenerator & rand, IArmyDescriptor *dst = nullptr); - void pushPrimSkill(PrimarySkill::PrimarySkill which, int val); + void pushPrimSkill(PrimarySkill which, int val); ui8 maxlevelsToMagicSchool() const; ui8 maxlevelsToWisdom() const; void recreateSecondarySkillsBonuses(); diff --git a/lib/mapObjects/CGMarket.cpp b/lib/mapObjects/CGMarket.cpp index 2d182cfc8..747c925f4 100644 --- a/lib/mapObjects/CGMarket.cpp +++ b/lib/mapObjects/CGMarket.cpp @@ -38,17 +38,17 @@ int CGMarket::getMarketEfficiency() const return marketEfficiency; } -bool CGMarket::allowsTrade(EMarketMode::EMarketMode mode) const +bool CGMarket::allowsTrade(EMarketMode mode) const { return marketModes.count(mode); } -int CGMarket::availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const +int CGMarket::availableUnits(EMarketMode mode, int marketItemSerial) const { return -1; } -std::vector CGMarket::availableItemsIds(EMarketMode::EMarketMode mode) const +std::vector CGMarket::availableItemsIds(EMarketMode mode) const { if(allowsTrade(mode)) return IMarket::availableItemsIds(mode); @@ -59,7 +59,7 @@ CGMarket::CGMarket() { } -std::vector CGBlackMarket::availableItemsIds(EMarketMode::EMarketMode mode) const +std::vector CGBlackMarket::availableItemsIds(EMarketMode mode) const { switch(mode) { @@ -110,7 +110,7 @@ void CGUniversity::initObj(CRandomGenerator & rand) } } -std::vector CGUniversity::availableItemsIds(EMarketMode::EMarketMode mode) const +std::vector CGUniversity::availableItemsIds(EMarketMode mode) const { switch (mode) { diff --git a/lib/mapObjects/CGMarket.h b/lib/mapObjects/CGMarket.h index d9e98f975..aff11ce56 100644 --- a/lib/mapObjects/CGMarket.h +++ b/lib/mapObjects/CGMarket.h @@ -18,7 +18,7 @@ class DLL_LINKAGE CGMarket : public CGObjectInstance, public IMarket { public: - std::set marketModes; + std::set marketModes; int marketEfficiency; //window variables @@ -32,9 +32,9 @@ public: ///IMarket int getMarketEfficiency() const override; - bool allowsTrade(EMarketMode::EMarketMode mode) const override; - int availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const override; //-1 if unlimited - std::vector availableItemsIds(EMarketMode::EMarketMode mode) const override; + bool allowsTrade(EMarketMode mode) const override; + int availableUnits(EMarketMode mode, int marketItemSerial) const override; //-1 if unlimited + std::vector availableItemsIds(EMarketMode mode) const override; template void serialize(Handler &h, const int version) { @@ -52,7 +52,7 @@ public: std::vector artifacts; //available artifacts void newTurn(CRandomGenerator & rand) const override; //reset artifacts for black market every month - std::vector availableItemsIds(EMarketMode::EMarketMode mode) const override; + std::vector availableItemsIds(EMarketMode mode) const override; template void serialize(Handler &h, const int version) { @@ -66,7 +66,7 @@ class DLL_LINKAGE CGUniversity : public CGMarket public: std::vector skills; //available skills - std::vector availableItemsIds(EMarketMode::EMarketMode mode) const override; + std::vector availableItemsIds(EMarketMode mode) const override; void initObj(CRandomGenerator & rand) override;//set skills for trade void onHeroVisit(const CGHeroInstance * h) const override; //open window diff --git a/lib/mapObjects/CGPandoraBox.cpp b/lib/mapObjects/CGPandoraBox.cpp index 40de75105..f7bc248f2 100644 --- a/lib/mapObjects/CGPandoraBox.cpp +++ b/lib/mapObjects/CGPandoraBox.cpp @@ -103,7 +103,7 @@ void CGPandoraBox::giveContentsUpToExp(const CGHeroInstance *h) const //give prim skills for(int i=0; ichangePrimSkill(h,static_cast(i),primskills[i],false); + cb->changePrimSkill(h,static_cast(i),primskills[i],false); assert(!cb->isVisitCoveredByAnotherQuery(this, h)); @@ -385,7 +385,7 @@ void CGPandoraBox::serializeJsonOptions(JsonSerializeFormat & handler) { auto s = handler.enterStruct("primarySkills"); for(int idx = 0; idx < primskills.size(); idx ++) - handler.serializeInt(PrimarySkill::names[idx], primskills[idx], 0); + handler.serializeInt(NPrimarySkill::names[idx], primskills[idx], 0); } } diff --git a/lib/mapObjects/CGTownBuilding.cpp b/lib/mapObjects/CGTownBuilding.cpp index 556bc91cb..098b519d5 100644 --- a/lib/mapObjects/CGTownBuilding.cpp +++ b/lib/mapObjects/CGTownBuilding.cpp @@ -199,7 +199,7 @@ void CTownBonus::onHeroVisit (const CGHeroInstance * h) const { si64 val = 0; InfoWindow iw; - PrimarySkill::PrimarySkill what = PrimarySkill::NONE; + PrimarySkill what = PrimarySkill::NONE; switch(bType) { diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 0472e809a..3ad5f2948 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -270,7 +270,7 @@ void CGTownInstance::blockingDialogAnswered(const CGHeroInstance *hero, ui32 ans void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const { - if(!cb->gameState()->getPlayerRelations( getOwner(), h->getOwner() ))//if this is enemy + if(cb->gameState()->getPlayerRelations( getOwner(), h->getOwner() ) == PlayerRelations::ENEMIES) { if(armedGarrison() || visitingHero) { @@ -701,7 +701,7 @@ int CGTownInstance::getMarketEfficiency() const return marketCount; } -bool CGTownInstance::allowsTrade(EMarketMode::EMarketMode mode) const +bool CGTownInstance::allowsTrade(EMarketMode mode) const { switch(mode) { @@ -727,7 +727,7 @@ bool CGTownInstance::allowsTrade(EMarketMode::EMarketMode mode) const } } -std::vector CGTownInstance::availableItemsIds(EMarketMode::EMarketMode mode) const +std::vector CGTownInstance::availableItemsIds(EMarketMode mode) const { if(mode == EMarketMode::RESOURCE_ARTIFACT) { diff --git a/lib/mapObjects/CGTownInstance.h b/lib/mapObjects/CGTownInstance.h index 1e914df89..6f8298143 100644 --- a/lib/mapObjects/CGTownInstance.h +++ b/lib/mapObjects/CGTownInstance.h @@ -138,8 +138,8 @@ public: EGeneratorState shipyardStatus() const override; const IObjectInterface * getObject() const override; int getMarketEfficiency() const override; //=market count - bool allowsTrade(EMarketMode::EMarketMode mode) const override; - std::vector availableItemsIds(EMarketMode::EMarketMode mode) const override; + bool allowsTrade(EMarketMode mode) const override; + std::vector availableItemsIds(EMarketMode mode) const override; void setType(si32 ID, si32 subID) override; void updateAppearance(); diff --git a/lib/mapObjects/CQuest.cpp b/lib/mapObjects/CQuest.cpp index b935e3edc..90eb106b2 100644 --- a/lib/mapObjects/CQuest.cpp +++ b/lib/mapObjects/CQuest.cpp @@ -131,7 +131,7 @@ bool CQuest::checkQuest(const CGHeroInstance * h) const case MISSION_PRIMARY_STAT: for(int i = 0; i < GameConstants::PRIMARY_SKILLS; ++i) { - if(h->getPrimSkillLevel(static_cast(i)) < static_cast(m2stats[i])) + if(h->getPrimSkillLevel(static_cast(i)) < static_cast(m2stats[i])) return false; } return true; @@ -503,7 +503,7 @@ void CQuest::serializeJson(JsonSerializeFormat & handler, const std::string & fi m2stats.resize(GameConstants::PRIMARY_SKILLS); for(int i = 0; i < GameConstants::PRIMARY_SKILLS; ++i) - handler.serializeInt(PrimarySkill::names[i], m2stats[i], 0); + handler.serializeInt(NPrimarySkill::names[i], m2stats[i], 0); } break; case MISSION_KILL_HERO: @@ -865,7 +865,7 @@ void CGSeerHut::completeQuest (const CGHeroInstance * h) const //reward cb->giveResource(h->getOwner(), static_cast(rID), rVal); break; case PRIMARY_SKILL: - cb->changePrimSkill(h, static_cast(rID), rVal, false); + cb->changePrimSkill(h, static_cast(rID), rVal, false); break; case SECONDARY_SKILL: cb->changeSecSkill(h, SecondarySkill(rID), rVal, false); @@ -982,7 +982,7 @@ void CGSeerHut::serializeJsonOptions(JsonSerializeFormat & handler) identifier = GameConstants::RESOURCE_NAMES[rID]; break; case PRIMARY_SKILL: - identifier = PrimarySkill::names[rID]; + identifier = NPrimarySkill::names[rID]; break; case SECONDARY_SKILL: identifier = CSkillHandler::encodeSkill(rID); diff --git a/lib/mapObjects/IMarket.cpp b/lib/mapObjects/IMarket.cpp index a6c8528a9..bf38c954f 100644 --- a/lib/mapObjects/IMarket.cpp +++ b/lib/mapObjects/IMarket.cpp @@ -20,7 +20,7 @@ VCMI_LIB_NAMESPACE_BEGIN -bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMarketMode mode) const +bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) const { switch(mode) { @@ -122,12 +122,12 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMar return true; } -bool IMarket::allowsTrade(EMarketMode::EMarketMode mode) const +bool IMarket::allowsTrade(EMarketMode mode) const { return false; } -int IMarket::availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const +int IMarket::availableUnits(EMarketMode mode, int marketItemSerial) const { switch(mode) { @@ -140,7 +140,7 @@ int IMarket::availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) } } -std::vector IMarket::availableItemsIds(EMarketMode::EMarketMode mode) const +std::vector IMarket::availableItemsIds(EMarketMode mode) const { std::vector ret; switch(mode) @@ -166,12 +166,12 @@ IMarket::IMarket() { } -std::vector IMarket::availableModes() const +std::vector IMarket::availableModes() const { - std::vector ret; - for (int i = 0; i < EMarketMode::MARTKET_AFTER_LAST_PLACEHOLDER; i++) - if(allowsTrade(static_cast(i))) - ret.push_back(static_cast(i)); + std::vector ret; + for (EMarketMode i = static_cast(0); i < EMarketMode::MARTKET_AFTER_LAST_PLACEHOLDER; vstd::next(i, 1)) + if(allowsTrade(i)) + ret.push_back(i); return ret; } diff --git a/lib/mapObjects/IMarket.h b/lib/mapObjects/IMarket.h index 7e9d79359..f279ffe6d 100644 --- a/lib/mapObjects/IMarket.h +++ b/lib/mapObjects/IMarket.h @@ -22,12 +22,12 @@ public: virtual ~IMarket() {} virtual int getMarketEfficiency() const = 0; - virtual bool allowsTrade(EMarketMode::EMarketMode mode) const; - virtual int availableUnits(EMarketMode::EMarketMode mode, int marketItemSerial) const; //-1 if unlimited - virtual std::vector availableItemsIds(EMarketMode::EMarketMode mode) const; + virtual bool allowsTrade(EMarketMode mode) const; + virtual int availableUnits(EMarketMode mode, int marketItemSerial) const; //-1 if unlimited + virtual std::vector availableItemsIds(EMarketMode mode) const; - bool getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMarketMode mode) const; //val1 - how many units of id1 player has to give to receive val2 units - std::vector availableModes() const; + bool getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) const; //val1 - how many units of id1 player has to give to receive val2 units + std::vector availableModes() const; static const IMarket *castFrom(const CGObjectInstance *obj, bool verbose = true); }; diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index b0d0434e6..0cc036acd 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -68,14 +68,14 @@ bool CTeamVisited::wasVisited(const TeamID & team) const //CGMine void CGMine::onHeroVisit( const CGHeroInstance * h ) const { - int relations = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner); + auto relations = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner); - if(relations == 2) //we're visiting our mine + if(relations == PlayerRelations::SAME_PLAYER) //we're visiting our mine { cb->showGarrisonDialog(id,h->id,true); return; } - else if (relations == 1)//ally + else if (relations == PlayerRelations::ALLIES)//ally return; if(stacksCount()) //Mine is guarded @@ -1088,7 +1088,7 @@ void CGScholar::onHeroVisit( const CGHeroInstance * h ) const switch (type) { case PRIM_SKILL: - cb->changePrimSkill(h,static_cast(bid),+1); + cb->changePrimSkill(h,static_cast(bid),+1); iw.components.emplace_back(Component::EComponentType::PRIM_SKILL, bid, +1, 0); break; case SECONDARY_SKILL: @@ -1143,7 +1143,7 @@ void CGScholar::serializeJsonOptions(JsonSerializeFormat & handler) switch(bonusType) { case PRIM_SKILL: - value = PrimarySkill::names[bonusID]; + value = NPrimarySkill::names[bonusID]; handler.serializeString("rewardPrimSkill", value); break; case SECONDARY_SKILL: @@ -1195,15 +1195,15 @@ void CGScholar::serializeJsonOptions(JsonSerializeFormat & handler) void CGGarrison::onHeroVisit (const CGHeroInstance *h) const { - int ally = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner); - if (!ally && stacksCount() > 0) { + auto relations = cb->gameState()->getPlayerRelations(h->tempOwner, tempOwner); + if (relations == PlayerRelations::ENEMIES && stacksCount() > 0) { //TODO: Find a way to apply magic garrison effects in battle. cb->startBattleI(h, this); return; } //New owner. - if (!ally) + if (relations == PlayerRelations::ENEMIES) cb->setOwner(this, h->tempOwner); cb->showGarrisonDialog(id, h->id, removableUnits); diff --git a/lib/mapping/MapFormatH3M.cpp b/lib/mapping/MapFormatH3M.cpp index 7bc802a06..2c03c42c6 100644 --- a/lib/mapping/MapFormatH3M.cpp +++ b/lib/mapping/MapFormatH3M.cpp @@ -861,7 +861,7 @@ void CMapLoaderH3M::readPredefinedHeroes() { for(int skillID = 0; skillID < GameConstants::PRIMARY_SKILLS; skillID++) { - hero->pushPrimSkill(static_cast(skillID), reader->readUInt8()); + hero->pushPrimSkill(static_cast(skillID), reader->readUInt8()); } } map->predefinedHeroes.emplace_back(hero); @@ -1029,7 +1029,7 @@ void CMapLoaderH3M::readBoxContent(CGPandoraBox * object, const int3 & mapPositi object->primskills.resize(GameConstants::PRIMARY_SKILLS); for(int x = 0; x < GameConstants::PRIMARY_SKILLS; ++x) - object->primskills[x] = static_cast(reader->readUInt8()); + object->primskills[x] = reader->readUInt8(); int gabn = reader->readUInt8(); //number of gained abilities for(int oo = 0; oo < gabn; ++oo) @@ -1768,7 +1768,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(const int3 & mapPosition, const Objec for(int xx = 0; xx < GameConstants::PRIMARY_SKILLS; ++xx) { - object->pushPrimSkill(static_cast(xx), reader->readUInt8()); + object->pushPrimSkill(static_cast(xx), reader->readUInt8()); } } } diff --git a/lib/modding/CModHandler.cpp b/lib/modding/CModHandler.cpp index 010a9a4b5..bed4f0805 100644 --- a/lib/modding/CModHandler.cpp +++ b/lib/modding/CModHandler.cpp @@ -57,8 +57,8 @@ CModHandler::CModHandler() for(int i=0; iregisterObject(ModScope::scopeBuiltin(), "primSkill", PrimarySkill::names[i], i); - identifiers->registerObject(ModScope::scopeBuiltin(), "primarySkill", PrimarySkill::names[i], i); + identifiers->registerObject(ModScope::scopeBuiltin(), "primSkill", NPrimarySkill::names[i], i); + identifiers->registerObject(ModScope::scopeBuiltin(), "primarySkill", NPrimarySkill::names[i], i); } } diff --git a/lib/pathfinder/CGPathNode.h b/lib/pathfinder/CGPathNode.h index 77effdfcb..db570be15 100644 --- a/lib/pathfinder/CGPathNode.h +++ b/lib/pathfinder/CGPathNode.h @@ -190,8 +190,8 @@ struct DLL_LINKAGE PathNodeInfo const TerrainTile * tile; int3 coord; bool guarded; - PlayerRelations::PlayerRelations objectRelations; - PlayerRelations::PlayerRelations heroRelations; + PlayerRelations objectRelations; + PlayerRelations heroRelations; bool isInitialPosition; PathNodeInfo(); diff --git a/lib/rewardable/Interface.cpp b/lib/rewardable/Interface.cpp index f34aa8055..d8ac6d99c 100644 --- a/lib/rewardable/Interface.cpp +++ b/lib/rewardable/Interface.cpp @@ -57,7 +57,7 @@ void Rewardable::Interface::grantRewardBeforeLevelup(IGameCallback * cb, const R } for(int i=0; i< info.reward.primary.size(); i++) - cb->changePrimSkill(hero, static_cast(i), info.reward.primary[i], false); + cb->changePrimSkill(hero, static_cast(i), info.reward.primary[i], false); si64 expToGive = 0; diff --git a/lib/rewardable/Limiter.cpp b/lib/rewardable/Limiter.cpp index 2f5e25049..bf3195edb 100644 --- a/lib/rewardable/Limiter.cpp +++ b/lib/rewardable/Limiter.cpp @@ -74,7 +74,7 @@ bool Rewardable::Limiter::heroAllowed(const CGHeroInstance * hero) const for(size_t i=0; i hero->getPrimSkillLevel(static_cast(i))) + if(primary[i] > hero->getPrimSkillLevel(static_cast(i))) return false; } diff --git a/mapeditor/inspector/questwidget.cpp b/mapeditor/inspector/questwidget.cpp index bd1329f46..f9e2ddcb1 100644 --- a/mapeditor/inspector/questwidget.cpp +++ b/mapeditor/inspector/questwidget.cpp @@ -46,7 +46,7 @@ void QuestWidget::obtainData() case CQuest::Emission::MISSION_PRIMARY_STAT: activeId = true; activeAmount = true; - for(auto s : PrimarySkill::names) + for(auto s : NPrimarySkill::names) ui->targetId->addItem(QString::fromStdString(s)); for(int i = 0; i < seerhut.quest->m2stats.size(); ++i) { @@ -123,7 +123,7 @@ QString QuestWidget::commitChanges() seerhut.quest->m13489val = ui->targetAmount->text().toInt(); return QString("Reach lvl ").append(ui->targetAmount->text()); case CQuest::Emission::MISSION_PRIMARY_STAT: - seerhut.quest->m2stats.resize(sizeof(PrimarySkill::names), 0); + seerhut.quest->m2stats.resize(sizeof(NPrimarySkill::names), 0); seerhut.quest->m2stats[ui->targetId->currentIndex()] = ui->targetAmount->text().toInt(); //TODO: support multiple stats return ui->targetId->currentText().append(ui->targetAmount->text()); diff --git a/mapeditor/inspector/rewardswidget.cpp b/mapeditor/inspector/rewardswidget.cpp index ea2b94e9e..f131ae6a9 100644 --- a/mapeditor/inspector/rewardswidget.cpp +++ b/mapeditor/inspector/rewardswidget.cpp @@ -67,7 +67,7 @@ QList RewardsWidget::getListForType(RewardType typeId) break; case RewardType::PRIMARY_SKILL: - for(auto s : PrimarySkill::names) + for(auto s : NPrimarySkill::names) result.append(QString::fromStdString(s)); break; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index d9d17f78c..7ed103c5e 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -248,11 +248,11 @@ void CGameHandler::levelUpCommander (const CCommanderInstance * c, int skill) { case ECommander::ATTACK: scp.accumulatedBonus.type = BonusType::PRIMARY_SKILL; - scp.accumulatedBonus.subtype = PrimarySkill::ATTACK; + scp.accumulatedBonus.subtype = static_cast(PrimarySkill::ATTACK); break; case ECommander::DEFENSE: scp.accumulatedBonus.type = BonusType::PRIMARY_SKILL; - scp.accumulatedBonus.subtype = PrimarySkill::DEFENSE; + scp.accumulatedBonus.subtype = static_cast(PrimarySkill::DEFENSE); break; case ECommander::HEALTH: scp.accumulatedBonus.type = BonusType::STACK_HEALTH; @@ -368,7 +368,7 @@ void CGameHandler::expGiven(const CGHeroInstance *hero) // levelUpHero(hero); } -void CGameHandler::changePrimSkill(const CGHeroInstance * hero, PrimarySkill::PrimarySkill which, si64 val, bool abs) +void CGameHandler::changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs) { if (which == PrimarySkill::EXPERIENCE) // Check if scenario limit reached { @@ -1612,7 +1612,7 @@ void CGameHandler::heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2) { auto h1 = getHero(hero1), h2 = getHero(hero2); - if (getPlayerRelations(h1->getOwner(), h2->getOwner())) + if (getPlayerRelations(h1->getOwner(), h2->getOwner()) != PlayerRelations::ENEMIES) { auto exchange = std::make_shared(this, h1, h2); ExchangeDialog hex; @@ -3590,7 +3590,7 @@ void CGameHandler::getVictoryLossMessage(PlayerColor player, const EVictoryLossC bool CGameHandler::dig(const CGHeroInstance *h) { if (h->diggingStatus() != EDiggingStatus::CAN_DIG) //checks for terrain and movement - COMPLAIN_RETF("Hero cannot dig (error code %d)!", h->diggingStatus()); + COMPLAIN_RETF("Hero cannot dig (error code %d)!", static_cast(h->diggingStatus())); createObject(h->visitablePos(), Obj::HOLE, 0 ); diff --git a/server/CGameHandler.h b/server/CGameHandler.h index 555257537..64b29bfd2 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -106,7 +106,7 @@ public: bool removeObject(const CGObjectInstance * obj) override; void createObject(const int3 & visitablePosition, Obj type, int32_t subtype ) override; void setOwner(const CGObjectInstance * obj, PlayerColor owner) override; - void changePrimSkill(const CGHeroInstance * hero, PrimarySkill::PrimarySkill which, si64 val, bool abs=false) override; + void changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs=false) override; void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false) override; void showBlockingDialog(BlockingDialog *iw) override; diff --git a/server/battles/BattleActionProcessor.cpp b/server/battles/BattleActionProcessor.cpp index e438c1ea3..42581078f 100644 --- a/server/battles/BattleActionProcessor.cpp +++ b/server/battles/BattleActionProcessor.cpp @@ -159,11 +159,11 @@ bool BattleActionProcessor::doDefendAction(const BattleAction & ba) //defensive stance, TODO: filter out spell boosts from bonus (stone skin etc.) SetStackEffect sse; - Bonus defenseBonusToAdd(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 20, -1, PrimarySkill::DEFENSE, BonusValueType::PERCENT_TO_ALL); - Bonus bonus2(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, stack->valOfBonuses(BonusType::DEFENSIVE_STANCE), -1, PrimarySkill::DEFENSE, BonusValueType::ADDITIVE_VALUE); - Bonus alternativeWeakCreatureBonus(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 1, -1, PrimarySkill::DEFENSE, BonusValueType::ADDITIVE_VALUE); + Bonus defenseBonusToAdd(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 20, -1, static_cast(PrimarySkill::DEFENSE), BonusValueType::PERCENT_TO_ALL); + Bonus bonus2(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, stack->valOfBonuses(BonusType::DEFENSIVE_STANCE), -1, static_cast(PrimarySkill::DEFENSE), BonusValueType::ADDITIVE_VALUE); + Bonus alternativeWeakCreatureBonus(BonusDuration::STACK_GETS_TURN, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 1, -1, static_cast(PrimarySkill::DEFENSE), BonusValueType::ADDITIVE_VALUE); - BonusList defence = *stack->getBonuses(Selector::typeSubtype(BonusType::PRIMARY_SKILL, PrimarySkill::DEFENSE)); + BonusList defence = *stack->getBonuses(Selector::typeSubtype(BonusType::PRIMARY_SKILL, static_cast(PrimarySkill::DEFENSE))); int oldDefenceValue = defence.totalValue(); defence.push_back(std::make_shared(defenseBonusToAdd)); diff --git a/test/battle/CUnitStateTest.cpp b/test/battle/CUnitStateTest.cpp index 79b5ce357..52b20ad34 100644 --- a/test/battle/CUnitStateTest.cpp +++ b/test/battle/CUnitStateTest.cpp @@ -53,8 +53,8 @@ public: { bonusMock.addNewBonus(std::make_shared(BonusDuration::PERMANENT, BonusType::STACKS_SPEED, BonusSource::CREATURE_ABILITY, DEFAULT_SPEED, 0)); - bonusMock.addNewBonus(std::make_shared(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CREATURE_ABILITY, DEFAULT_ATTACK, 0, PrimarySkill::ATTACK)); - bonusMock.addNewBonus(std::make_shared(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CREATURE_ABILITY, DEFAULT_DEFENCE, 0, PrimarySkill::DEFENSE)); + bonusMock.addNewBonus(std::make_shared(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CREATURE_ABILITY, DEFAULT_ATTACK, 0, static_cast(PrimarySkill::ATTACK))); + bonusMock.addNewBonus(std::make_shared(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::CREATURE_ABILITY, DEFAULT_DEFENCE, 0, static_cast(PrimarySkill::DEFENSE))); bonusMock.addNewBonus(std::make_shared(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, DEFAULT_HP, 0)); diff --git a/test/mock/mock_IGameCallback.h b/test/mock/mock_IGameCallback.h index f6ed9e856..6ec37e5c1 100644 --- a/test/mock/mock_IGameCallback.h +++ b/test/mock/mock_IGameCallback.h @@ -43,7 +43,7 @@ public: bool removeObject(const CGObjectInstance * obj) override {return false;} void createObject(const int3 & visitablePosition, Obj type, int32_t subtype = 0) override {}; void setOwner(const CGObjectInstance * objid, PlayerColor owner) override {} - void changePrimSkill(const CGHeroInstance * hero, PrimarySkill::PrimarySkill which, si64 val, bool abs=false) override {} + void changePrimSkill(const CGHeroInstance * hero, PrimarySkill which, si64 val, bool abs=false) override {} void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false) override {} void showBlockingDialog(BlockingDialog *iw) override {} void showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits) override {} //cb will be called when player closes garrison window diff --git a/test/spells/effects/TimedTest.cpp b/test/spells/effects/TimedTest.cpp index b5bddc269..d9205f4c5 100644 --- a/test/spells/effects/TimedTest.cpp +++ b/test/spells/effects/TimedTest.cpp @@ -71,9 +71,9 @@ protected: TEST_P(TimedApplyTest, ChangesBonuses) { - Bonus testBonus1(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, 0, PrimarySkill::KNOWLEDGE); + Bonus testBonus1(BonusDuration::PERMANENT, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, 0, static_cast(PrimarySkill::KNOWLEDGE)); - Bonus testBonus2(BonusDuration::N_TURNS, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, 0, PrimarySkill::KNOWLEDGE); + Bonus testBonus2(BonusDuration::N_TURNS, BonusType::PRIMARY_SKILL, BonusSource::OTHER, 3, 0, static_cast(PrimarySkill::KNOWLEDGE)); testBonus2.turnsRemain = 4; JsonNode options(JsonNode::JsonType::DATA_STRUCT);