diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index c1f2dc53a..382f081bb 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -115,7 +115,7 @@ set(lib_SRCS CModHandler.cpp CPathfinder.cpp CRandomGenerator.cpp - CSkillHandler.cpp + CSkillHandler.cpp CStack.cpp CThreadHelper.cpp CTownHandler.cpp @@ -257,6 +257,7 @@ set(lib_HEADERS CPlayerState.h CRandomGenerator.h CScriptingModule.h + CSkillHandler.h CSoundBase.h CStack.h CStopWatch.h diff --git a/lib/CSkillHandler.cpp b/lib/CSkillHandler.cpp index cf86970a9..858f18c20 100644 --- a/lib/CSkillHandler.cpp +++ b/lib/CSkillHandler.cpp @@ -51,7 +51,7 @@ CSkill::~CSkill() { } -void CSkill::addNewBonus(const std::shared_ptr& b, int level) +void CSkill::addNewBonus(const std::shared_ptr & b, int level) { b->source = Bonus::SECONDARY_SKILL; b->sid = id; @@ -75,7 +75,7 @@ const std::string & CSkill::getDescription(int level) const return levels[level-1].description; } -DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const CSkill::LevelInfo &info) +DLL_LINKAGE std::ostream & operator<<(std::ostream & out, const CSkill::LevelInfo & info) { out << "(\"" << info.description << "\", ["; for(int i=0; i < info.effects.size(); i++) @@ -83,7 +83,7 @@ DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const CSkill::LevelInfo return out << "])"; } -DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const CSkill &skill) +DLL_LINKAGE std::ostream & operator<<(std::ostream & out, const CSkill & skill) { out << "Skill(" << (int)skill.id << "," << skill.identifier << "): ["; for(int i=0; i < skill.levels.size(); i++) @@ -141,7 +141,7 @@ const std::string CSkillHandler::getTypeName() const CSkill * CSkillHandler::loadFromJson(const JsonNode & json, const std::string & identifier) { - CSkill * skill = NULL; + CSkill * skill = nullptr; for(int id = 0; id < GameConstants::SKILL_QUANTITY; id++) { @@ -203,7 +203,7 @@ void CSkillHandler::loadObject(std::string scope, std::string name, const JsonNo assert(object->id == index); objects[index] = object; - registerObject(scope,type_name, name, object->id); + registerObject(scope, type_name, name, object->id); } @@ -251,22 +251,30 @@ std::vector> CSkillHandler::defaultBonus(SecondarySkill s switch(skill) { case SecondarySkill::PATHFINDING: - addBonus(25 * level); break; + addBonus(25 * level); + break; case SecondarySkill::ARCHERY: - addBonus(5 + 5 * level * level); break; + addBonus(5 + 5 * level * level); + break; case SecondarySkill::LOGISTICS: - addBonus(10 * level); break; + addBonus(10 * level); + break; case SecondarySkill::SCOUTING: - addBonus(level, Bonus::SIGHT_RADIOUS); break; + addBonus(level, Bonus::SIGHT_RADIOUS); + break; case SecondarySkill::DIPLOMACY: addBonus(level); - addBonus(20 * level, Bonus::SURRENDER_DISCOUNT); break; + addBonus(20 * level, Bonus::SURRENDER_DISCOUNT); + break; case SecondarySkill::NAVIGATION: - addBonus(50 * level); break; + addBonus(50 * level); + break; case SecondarySkill::LEADERSHIP: - addBonus(level, Bonus::MORALE); break; + addBonus(level, Bonus::MORALE); + break; case SecondarySkill::LUCK: - addBonus(level, Bonus::LUCK); break; + addBonus(level, Bonus::LUCK); + break; case SecondarySkill::BALLISTICS: addBonus(100, Bonus::MANUAL_CONTROL, CreatureID::CATAPULT); addBonus(level); @@ -276,18 +284,23 @@ std::vector> CSkillHandler::defaultBonus(SecondarySkill s addBonus(1 + level, Bonus::SECONDARY_SKILL_VAL2); break; case SecondarySkill::NECROMANCY: - addBonus(10 * level); break; + addBonus(10 * level); + break; case SecondarySkill::ESTATES: - addBonus(125 << (level-1)); break; + addBonus(125 << (level-1)); + break; case SecondarySkill::FIRE_MAGIC: case SecondarySkill::AIR_MAGIC: case SecondarySkill::WATER_MAGIC: case SecondarySkill::EARTH_MAGIC: - addBonus(level); break; + addBonus(level); + break; case SecondarySkill::SCHOLAR: - addBonus(1 + level); break; + addBonus(1 + level); + break; case SecondarySkill::TACTICS: - addBonus(1 + 2 * level); break; + addBonus(1 + 2 * level); + break; case SecondarySkill::ARTILLERY: addBonus(100, Bonus::MANUAL_CONTROL, CreatureID::BALLISTA); addBonus(25 + 25 * level); @@ -295,22 +308,30 @@ std::vector> CSkillHandler::defaultBonus(SecondarySkill s addBonus(1, Bonus::SECONDARY_SKILL_VAL2); break; case SecondarySkill::LEARNING: - addBonus(5 * level); break; + addBonus(5 * level); + break; case SecondarySkill::OFFENCE: - addBonus(10 * level); break; + addBonus(10 * level); + break; case SecondarySkill::ARMORER: - addBonus(5 * level); break; + addBonus(5 * level); + break; case SecondarySkill::INTELLIGENCE: - addBonus(25 << (level-1)); break; + addBonus(25 << (level-1)); + break; case SecondarySkill::SORCERY: - addBonus(5 * level); break; + addBonus(5 * level); + break; case SecondarySkill::RESISTANCE: - addBonus(5 << (level-1)); break; + addBonus(5 << (level-1)); + break; case SecondarySkill::FIRST_AID: addBonus(100, Bonus::MANUAL_CONTROL, CreatureID::FIRST_AID_TENT); - addBonus(25 + 25 * level); break; + addBonus(25 + 25 * level); + break; default: - addBonus(level); break; + addBonus(level); + break; } return result; diff --git a/lib/CSkillHandler.h b/lib/CSkillHandler.h index 56f448bb7..92b7b5c82 100644 --- a/lib/CSkillHandler.h +++ b/lib/CSkillHandler.h @@ -13,11 +13,6 @@ #include "GameConstants.h" #include "IHandlerBase.h" -class CSkillHandler; -class CGHeroInstance; -class CMap; -class JsonSerializeFormat; - class DLL_LINKAGE CSkill // secondary skill { protected: @@ -29,9 +24,10 @@ protected: LevelInfo(); ~LevelInfo(); - template void serialize(Handler &h, const int version) + template void serialize(Handler & h, const int version) { - h & description & effects; + h & description; + h & effects; } }; @@ -41,7 +37,7 @@ public: CSkill(SecondarySkill id = SecondarySkill::DEFAULT); ~CSkill(); - void addNewBonus(const std::shared_ptr& b, int level); + void addNewBonus(const std::shared_ptr & b, int level); void setDescription(const std::string & desc, int level); const std::vector> & getBonus(int level) const; const std::string & getDescription(int level) const; @@ -50,15 +46,16 @@ public: SecondarySkill id; std::string identifier; - template void serialize(Handler &h, const int version) + template void serialize(Handler & h, const int version) { - h & id & identifier; + h & id; + h & identifier; h & levels; } friend class CSkillHandler; - friend std::ostream & operator<<(std::ostream &out, const CSkill &skill); - friend std::ostream & operator<<(std::ostream &out, const CSkill::LevelInfo &info); + friend std::ostream & operator<<(std::ostream & out, const CSkill & skill); + friend std::ostream & operator<<(std::ostream & out, const CSkill::LevelInfo & info); }; class DLL_LINKAGE CSkillHandler: public CHandlerBase @@ -77,9 +74,9 @@ public: void loadObject(std::string scope, std::string name, const JsonNode & data) override; void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override; - template void serialize(Handler &h, const int version) + template void serialize(Handler & h, const int version) { - h & objects ; + h & objects; } protected: diff --git a/lib/filesystem/CFilesystemLoader.cpp b/lib/filesystem/CFilesystemLoader.cpp index 78b82b38c..0585c761b 100644 --- a/lib/filesystem/CFilesystemLoader.cpp +++ b/lib/filesystem/CFilesystemLoader.cpp @@ -26,7 +26,7 @@ CFilesystemLoader::CFilesystemLoader(std::string _mountPoint, bfs::path baseDire std::unique_ptr CFilesystemLoader::load(const ResourceID & resourceName) const { assert(fileList.count(resourceName)); - boost::filesystem::path file = baseDirectory / fileList.at(resourceName); + bfs::path file = baseDirectory / fileList.at(resourceName); logGlobal->trace("loading %s", file.string()); return make_unique(file); } diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 71882b5b7..2dfaacd75 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -2489,7 +2489,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t const CGHeroInstance * h1 = getHero(fromHero); const CGHeroInstance * h2 = getHero(toHero); int h1_scholarLevel = h1->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SCHOLAR); - int h2_scholarLevel = h1->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SCHOLAR); + int h2_scholarLevel = h2->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SCHOLAR); if (h1_scholarLevel < h2_scholarLevel) {