1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

fixed code format and other minor issues

This commit is contained in:
Henning Koehler 2017-08-30 19:19:54 +12:00
parent 36d671b093
commit 654ca96e9d
5 changed files with 62 additions and 43 deletions

View File

@ -115,7 +115,7 @@ set(lib_SRCS
CModHandler.cpp CModHandler.cpp
CPathfinder.cpp CPathfinder.cpp
CRandomGenerator.cpp CRandomGenerator.cpp
CSkillHandler.cpp CSkillHandler.cpp
CStack.cpp CStack.cpp
CThreadHelper.cpp CThreadHelper.cpp
CTownHandler.cpp CTownHandler.cpp
@ -257,6 +257,7 @@ set(lib_HEADERS
CPlayerState.h CPlayerState.h
CRandomGenerator.h CRandomGenerator.h
CScriptingModule.h CScriptingModule.h
CSkillHandler.h
CSoundBase.h CSoundBase.h
CStack.h CStack.h
CStopWatch.h CStopWatch.h

View File

@ -51,7 +51,7 @@ CSkill::~CSkill()
{ {
} }
void CSkill::addNewBonus(const std::shared_ptr<Bonus>& b, int level) void CSkill::addNewBonus(const std::shared_ptr<Bonus> & b, int level)
{ {
b->source = Bonus::SECONDARY_SKILL; b->source = Bonus::SECONDARY_SKILL;
b->sid = id; b->sid = id;
@ -75,7 +75,7 @@ const std::string & CSkill::getDescription(int level) const
return levels[level-1].description; 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 << "\", ["; out << "(\"" << info.description << "\", [";
for(int i=0; i < info.effects.size(); i++) 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 << "])"; 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 << "): ["; out << "Skill(" << (int)skill.id << "," << skill.identifier << "): [";
for(int i=0; i < skill.levels.size(); i++) 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 * CSkillHandler::loadFromJson(const JsonNode & json, const std::string & identifier)
{ {
CSkill * skill = NULL; CSkill * skill = nullptr;
for(int id = 0; id < GameConstants::SKILL_QUANTITY; id++) 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); assert(object->id == index);
objects[index] = object; objects[index] = object;
registerObject(scope,type_name, name, object->id); registerObject(scope, type_name, name, object->id);
} }
@ -251,22 +251,30 @@ std::vector<std::shared_ptr<Bonus>> CSkillHandler::defaultBonus(SecondarySkill s
switch(skill) switch(skill)
{ {
case SecondarySkill::PATHFINDING: case SecondarySkill::PATHFINDING:
addBonus(25 * level); break; addBonus(25 * level);
break;
case SecondarySkill::ARCHERY: case SecondarySkill::ARCHERY:
addBonus(5 + 5 * level * level); break; addBonus(5 + 5 * level * level);
break;
case SecondarySkill::LOGISTICS: case SecondarySkill::LOGISTICS:
addBonus(10 * level); break; addBonus(10 * level);
break;
case SecondarySkill::SCOUTING: case SecondarySkill::SCOUTING:
addBonus(level, Bonus::SIGHT_RADIOUS); break; addBonus(level, Bonus::SIGHT_RADIOUS);
break;
case SecondarySkill::DIPLOMACY: case SecondarySkill::DIPLOMACY:
addBonus(level); addBonus(level);
addBonus(20 * level, Bonus::SURRENDER_DISCOUNT); break; addBonus(20 * level, Bonus::SURRENDER_DISCOUNT);
break;
case SecondarySkill::NAVIGATION: case SecondarySkill::NAVIGATION:
addBonus(50 * level); break; addBonus(50 * level);
break;
case SecondarySkill::LEADERSHIP: case SecondarySkill::LEADERSHIP:
addBonus(level, Bonus::MORALE); break; addBonus(level, Bonus::MORALE);
break;
case SecondarySkill::LUCK: case SecondarySkill::LUCK:
addBonus(level, Bonus::LUCK); break; addBonus(level, Bonus::LUCK);
break;
case SecondarySkill::BALLISTICS: case SecondarySkill::BALLISTICS:
addBonus(100, Bonus::MANUAL_CONTROL, CreatureID::CATAPULT); addBonus(100, Bonus::MANUAL_CONTROL, CreatureID::CATAPULT);
addBonus(level); addBonus(level);
@ -276,18 +284,23 @@ std::vector<std::shared_ptr<Bonus>> CSkillHandler::defaultBonus(SecondarySkill s
addBonus(1 + level, Bonus::SECONDARY_SKILL_VAL2); addBonus(1 + level, Bonus::SECONDARY_SKILL_VAL2);
break; break;
case SecondarySkill::NECROMANCY: case SecondarySkill::NECROMANCY:
addBonus(10 * level); break; addBonus(10 * level);
break;
case SecondarySkill::ESTATES: case SecondarySkill::ESTATES:
addBonus(125 << (level-1)); break; addBonus(125 << (level-1));
break;
case SecondarySkill::FIRE_MAGIC: case SecondarySkill::FIRE_MAGIC:
case SecondarySkill::AIR_MAGIC: case SecondarySkill::AIR_MAGIC:
case SecondarySkill::WATER_MAGIC: case SecondarySkill::WATER_MAGIC:
case SecondarySkill::EARTH_MAGIC: case SecondarySkill::EARTH_MAGIC:
addBonus(level); break; addBonus(level);
break;
case SecondarySkill::SCHOLAR: case SecondarySkill::SCHOLAR:
addBonus(1 + level); break; addBonus(1 + level);
break;
case SecondarySkill::TACTICS: case SecondarySkill::TACTICS:
addBonus(1 + 2 * level); break; addBonus(1 + 2 * level);
break;
case SecondarySkill::ARTILLERY: case SecondarySkill::ARTILLERY:
addBonus(100, Bonus::MANUAL_CONTROL, CreatureID::BALLISTA); addBonus(100, Bonus::MANUAL_CONTROL, CreatureID::BALLISTA);
addBonus(25 + 25 * level); addBonus(25 + 25 * level);
@ -295,22 +308,30 @@ std::vector<std::shared_ptr<Bonus>> CSkillHandler::defaultBonus(SecondarySkill s
addBonus(1, Bonus::SECONDARY_SKILL_VAL2); addBonus(1, Bonus::SECONDARY_SKILL_VAL2);
break; break;
case SecondarySkill::LEARNING: case SecondarySkill::LEARNING:
addBonus(5 * level); break; addBonus(5 * level);
break;
case SecondarySkill::OFFENCE: case SecondarySkill::OFFENCE:
addBonus(10 * level); break; addBonus(10 * level);
break;
case SecondarySkill::ARMORER: case SecondarySkill::ARMORER:
addBonus(5 * level); break; addBonus(5 * level);
break;
case SecondarySkill::INTELLIGENCE: case SecondarySkill::INTELLIGENCE:
addBonus(25 << (level-1)); break; addBonus(25 << (level-1));
break;
case SecondarySkill::SORCERY: case SecondarySkill::SORCERY:
addBonus(5 * level); break; addBonus(5 * level);
break;
case SecondarySkill::RESISTANCE: case SecondarySkill::RESISTANCE:
addBonus(5 << (level-1)); break; addBonus(5 << (level-1));
break;
case SecondarySkill::FIRST_AID: case SecondarySkill::FIRST_AID:
addBonus(100, Bonus::MANUAL_CONTROL, CreatureID::FIRST_AID_TENT); addBonus(100, Bonus::MANUAL_CONTROL, CreatureID::FIRST_AID_TENT);
addBonus(25 + 25 * level); break; addBonus(25 + 25 * level);
break;
default: default:
addBonus(level); break; addBonus(level);
break;
} }
return result; return result;

View File

@ -13,11 +13,6 @@
#include "GameConstants.h" #include "GameConstants.h"
#include "IHandlerBase.h" #include "IHandlerBase.h"
class CSkillHandler;
class CGHeroInstance;
class CMap;
class JsonSerializeFormat;
class DLL_LINKAGE CSkill // secondary skill class DLL_LINKAGE CSkill // secondary skill
{ {
protected: protected:
@ -29,9 +24,10 @@ protected:
LevelInfo(); LevelInfo();
~LevelInfo(); ~LevelInfo();
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> 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(SecondarySkill id = SecondarySkill::DEFAULT);
~CSkill(); ~CSkill();
void addNewBonus(const std::shared_ptr<Bonus>& b, int level); void addNewBonus(const std::shared_ptr<Bonus> & b, int level);
void setDescription(const std::string & desc, int level); void setDescription(const std::string & desc, int level);
const std::vector<std::shared_ptr<Bonus>> & getBonus(int level) const; const std::vector<std::shared_ptr<Bonus>> & getBonus(int level) const;
const std::string & getDescription(int level) const; const std::string & getDescription(int level) const;
@ -50,15 +46,16 @@ public:
SecondarySkill id; SecondarySkill id;
std::string identifier; std::string identifier;
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler & h, const int version)
{ {
h & id & identifier; h & id;
h & identifier;
h & levels; h & levels;
} }
friend class CSkillHandler; friend class CSkillHandler;
friend std::ostream & operator<<(std::ostream &out, const CSkill &skill); 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::LevelInfo & info);
}; };
class DLL_LINKAGE CSkillHandler: public CHandlerBase<SecondarySkill, CSkill> class DLL_LINKAGE CSkillHandler: public CHandlerBase<SecondarySkill, CSkill>
@ -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) override;
void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override; void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler & h, const int version)
{ {
h & objects ; h & objects;
} }
protected: protected:

View File

@ -26,7 +26,7 @@ CFilesystemLoader::CFilesystemLoader(std::string _mountPoint, bfs::path baseDire
std::unique_ptr<CInputStream> CFilesystemLoader::load(const ResourceID & resourceName) const std::unique_ptr<CInputStream> CFilesystemLoader::load(const ResourceID & resourceName) const
{ {
assert(fileList.count(resourceName)); 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()); logGlobal->trace("loading %s", file.string());
return make_unique<CFileInputStream>(file); return make_unique<CFileInputStream>(file);
} }

View File

@ -2489,7 +2489,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
const CGHeroInstance * h1 = getHero(fromHero); const CGHeroInstance * h1 = getHero(fromHero);
const CGHeroInstance * h2 = getHero(toHero); const CGHeroInstance * h2 = getHero(toHero);
int h1_scholarLevel = h1->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::SCHOLAR); 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) if (h1_scholarLevel < h2_scholarLevel)
{ {