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
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

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->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<std::shared_ptr<Bonus>> 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<std::shared_ptr<Bonus>> 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<std::shared_ptr<Bonus>> 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;

View File

@ -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 <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();
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);
const std::vector<std::shared_ptr<Bonus>> & getBonus(int level) const;
const std::string & getDescription(int level) const;
@ -50,15 +46,16 @@ public:
SecondarySkill id;
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;
}
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<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, 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:

View File

@ -26,7 +26,7 @@ CFilesystemLoader::CFilesystemLoader(std::string _mountPoint, bfs::path baseDire
std::unique_ptr<CInputStream> 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<CFileInputStream>(file);
}

View File

@ -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)
{