mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- fix uninitialized cursor
- stubs for loading heroes and classes from mods (no real code yet) - heroes loading uses string IDs for secondary skills, some cleanup in HeroHandler
This commit is contained in:
parent
423a226e31
commit
d2ee602b29
@ -23,6 +23,7 @@ void CCursorHandler::initCursor()
|
||||
xpos = ypos = 0;
|
||||
type = ECursor::DEFAULT;
|
||||
dndObject = nullptr;
|
||||
currentCursor = nullptr;
|
||||
|
||||
help = CSDL_Ext::newSurface(40,40);
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
2750
config/heroes.json
2750
config/heroes.json
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,7 @@
|
||||
#include "StringConstants.h"
|
||||
#include "BattleHex.h"
|
||||
#include "CModHandler.h"
|
||||
#include "CTownHandler.h"
|
||||
|
||||
/*
|
||||
* CHeroHandler.cpp, part of VCMI engine
|
||||
@ -125,7 +126,7 @@ void CHeroClassHandler::load(const JsonNode & classes)
|
||||
//TODO
|
||||
}
|
||||
|
||||
void CHeroClassHandler::loadClass(const JsonNode & heroClass)
|
||||
CHeroClass *CHeroClassHandler::loadClass(const JsonNode & heroClass)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
@ -147,11 +148,49 @@ CHeroHandler::~CHeroHandler()
|
||||
CHeroHandler::CHeroHandler()
|
||||
{}
|
||||
|
||||
void CHeroHandler::load(const JsonNode & heroes)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
CHero * CHeroHandler::loadHero(const JsonNode & hero)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void CHeroHandler::load()
|
||||
{
|
||||
classes.load();
|
||||
loadHeroes();
|
||||
loadObstacles();
|
||||
loadTerrains();
|
||||
loadBallistics();
|
||||
loadExperience();
|
||||
}
|
||||
|
||||
void CHeroHandler::loadExperience()
|
||||
{
|
||||
expPerLevel.push_back(0);
|
||||
expPerLevel.push_back(1000);
|
||||
expPerLevel.push_back(2000);
|
||||
expPerLevel.push_back(3200);
|
||||
expPerLevel.push_back(4600);
|
||||
expPerLevel.push_back(6200);
|
||||
expPerLevel.push_back(8000);
|
||||
expPerLevel.push_back(10000);
|
||||
expPerLevel.push_back(12200);
|
||||
expPerLevel.push_back(14700);
|
||||
expPerLevel.push_back(17500);
|
||||
expPerLevel.push_back(20600);
|
||||
expPerLevel.push_back(24320);
|
||||
expPerLevel.push_back(28784);
|
||||
expPerLevel.push_back(34140);
|
||||
while (expPerLevel[expPerLevel.size() - 1] > expPerLevel[expPerLevel.size() - 2])
|
||||
{
|
||||
int i = expPerLevel.size() - 1;
|
||||
expPerLevel.push_back (expPerLevel[i] + (expPerLevel[i] - expPerLevel[i-1]) * 1.2);
|
||||
}
|
||||
expPerLevel.pop_back();//last value is broken
|
||||
}
|
||||
|
||||
void CHeroHandler::loadObstacles()
|
||||
@ -220,8 +259,11 @@ void CHeroHandler::loadHeroes()
|
||||
// sex: 0=male, 1=female
|
||||
currentHero->sex = !!hero["female"].Bool();
|
||||
|
||||
BOOST_FOREACH(const JsonNode &set, hero["skill_set"].Vector()) {
|
||||
currentHero->secSkillsInit.push_back(std::make_pair(set["skill"].Float(), set["level"].Float()));
|
||||
BOOST_FOREACH(const JsonNode &set, hero["skill_set"].Vector())
|
||||
{
|
||||
int skillID = boost::range::find(SecondarySkill::names, set["skill"].String()) - boost::begin(SecondarySkill::names);
|
||||
int skillLevel = boost::range::find(SecondarySkill::levels, set["level"].String()) - boost::begin(SecondarySkill::levels);
|
||||
currentHero->secSkillsInit.push_back(std::make_pair(skillID, skillLevel));
|
||||
}
|
||||
|
||||
value = &hero["spell"];
|
||||
@ -247,30 +289,10 @@ void CHeroHandler::loadHeroes()
|
||||
currentHero->heroClass = classes.heroClasses[classID];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
loadTerrains();
|
||||
expPerLevel.push_back(0);
|
||||
expPerLevel.push_back(1000);
|
||||
expPerLevel.push_back(2000);
|
||||
expPerLevel.push_back(3200);
|
||||
expPerLevel.push_back(4600);
|
||||
expPerLevel.push_back(6200);
|
||||
expPerLevel.push_back(8000);
|
||||
expPerLevel.push_back(10000);
|
||||
expPerLevel.push_back(12200);
|
||||
expPerLevel.push_back(14700);
|
||||
expPerLevel.push_back(17500);
|
||||
expPerLevel.push_back(20600);
|
||||
expPerLevel.push_back(24320);
|
||||
expPerLevel.push_back(28784);
|
||||
expPerLevel.push_back(34140);
|
||||
while (expPerLevel[expPerLevel.size() - 1] > expPerLevel[expPerLevel.size() - 2])
|
||||
{
|
||||
int i = expPerLevel.size() - 1;
|
||||
expPerLevel.push_back (expPerLevel[i] + (expPerLevel[i] - expPerLevel[i-1]) * 1.2);
|
||||
}
|
||||
expPerLevel.pop_back();//last value is broken
|
||||
|
||||
void CHeroHandler::loadBallistics()
|
||||
{
|
||||
CLegacyConfigParser ballParser("DATA/BALLIST.TXT");
|
||||
|
||||
ballParser.endLine(); //header
|
||||
|
@ -56,7 +56,6 @@ public:
|
||||
std::vector<SSpecialtyInfo> spec;
|
||||
si32 startingSpell; //-1 if none
|
||||
ui8 sex; // default sex: 0=male, 1=female
|
||||
//bool operator<(CHero& drugi){if (ID < drugi.ID) return true; else return false;}
|
||||
|
||||
CHero();
|
||||
~CHero();
|
||||
@ -131,7 +130,7 @@ public:
|
||||
void load(const JsonNode & classes);
|
||||
|
||||
/// load one class from json
|
||||
void loadClass(const JsonNode & heroClass);
|
||||
CHeroClass * loadClass(const JsonNode & heroClass);
|
||||
|
||||
~CHeroClassHandler();
|
||||
|
||||
@ -148,9 +147,9 @@ class DLL_LINKAGE CHeroHandler
|
||||
public:
|
||||
CHeroClassHandler classes;
|
||||
|
||||
std::vector< ConstTransitivePtr<CHero> > heroes; //changed from nodrze
|
||||
std::vector< ConstTransitivePtr<CHero> > heroes;
|
||||
|
||||
//default costs of going through terrains: dirt, sand, grass, snow, swamp, rough, subterranean, lava, water, rock; -1 means terrain is imapassable
|
||||
//default costs of going through terrains. -1 means terrain is impassable
|
||||
std::vector<int> terrCosts;
|
||||
|
||||
struct SBallisticsLevelInfo
|
||||
@ -169,14 +168,24 @@ public:
|
||||
std::map<int, CObstacleInfo> obstacles; //info about obstacles that may be placed on battlefield
|
||||
std::map<int, CObstacleInfo> absoluteObstacles; //info about obstacles that may be placed on battlefield
|
||||
|
||||
void loadObstacles(); //loads info about obstacles
|
||||
|
||||
ui32 level(ui64 experience) const; //calculates level corresponding to given experience amount
|
||||
ui64 reqExp(ui32 level) const; //calculates experience required for given level
|
||||
|
||||
/// Load multiple heroes from json
|
||||
void load(const JsonNode & heroes);
|
||||
|
||||
/// Load single hero from json
|
||||
CHero * loadHero(const JsonNode & hero);
|
||||
|
||||
/// Load everything (calls functions below + classes.load())
|
||||
void load();
|
||||
|
||||
void loadHeroes();
|
||||
void loadExperience();
|
||||
void loadBallistics();
|
||||
void loadTerrains();
|
||||
void loadObstacles();
|
||||
|
||||
CHeroHandler(); //c-tor
|
||||
~CHeroHandler(); //d-tor
|
||||
|
||||
|
@ -5,6 +5,11 @@
|
||||
#include "Filesystem/CResourceLoader.h"
|
||||
#include "Filesystem/ISimpleResourceLoader.h"
|
||||
|
||||
#include "CCreatureHandler.h"
|
||||
#include "CArtHandler.h"
|
||||
#include "CTownHandler.h"
|
||||
#include "CHeroHandler.h"
|
||||
|
||||
/*
|
||||
* CModHandler.h, part of VCMI engine
|
||||
*
|
||||
@ -131,6 +136,12 @@ std::vector<std::string> CModHandler::getActiveMods()
|
||||
return activeMods;
|
||||
}
|
||||
|
||||
template<typename Handler>
|
||||
void handleData(Handler handler, const JsonNode & config)
|
||||
{
|
||||
handler->load(JsonUtils::assembleFromFiles(config.convertTo<std::vector<std::string> >()));
|
||||
}
|
||||
|
||||
void CModHandler::loadActiveMods()
|
||||
{
|
||||
BOOST_FOREACH(std::string & modName, activeMods)
|
||||
@ -139,9 +150,12 @@ void CModHandler::loadActiveMods()
|
||||
|
||||
const JsonNode config = JsonNode(ResourceID(modFileName));
|
||||
|
||||
VLC->townh->load(JsonUtils::assembleFromFiles(config ["factions"].convertTo<std::vector<std::string> >()));
|
||||
VLC->creh->load( JsonUtils::assembleFromFiles(config["creatures"].convertTo<std::vector<std::string> >()));
|
||||
VLC->arth->load( JsonUtils::assembleFromFiles(config["artifacts"].convertTo<std::vector<std::string> >()));
|
||||
handleData(VLC->townh, config["factions"]);
|
||||
handleData(VLC->creh, config["creatures"]);
|
||||
handleData(VLC->arth, config["artifacts"]);
|
||||
|
||||
handleData(&VLC->heroh->classes, config["heroClasses"]);
|
||||
handleData(VLC->heroh, config["heroes"]);
|
||||
}
|
||||
|
||||
VLC->creh->buildBonusTreeForTiers(); //do that after all new creatures are loaded
|
||||
|
@ -3,9 +3,6 @@
|
||||
#include "Filesystem/CResourceLoader.h"
|
||||
|
||||
#include "VCMI_Lib.h"
|
||||
#include "CCreatureHandler.h"
|
||||
#include "CArtHandler.h"
|
||||
#include "CTownHandler.h"
|
||||
|
||||
/*
|
||||
* CModHandler.h, part of VCMI engine
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "JsonNode.h"
|
||||
#include "StringConstants.h"
|
||||
#include "CModHandler.h"
|
||||
#include "CArtHandler.h"
|
||||
#include "Filesystem/CResourceLoader.h"
|
||||
|
||||
/*
|
||||
|
@ -54,6 +54,11 @@ namespace SecondarySkill
|
||||
"artillery", "learning", "offence", "armorer", "intelligence", // 25
|
||||
"sorcery", "resistance", "firstAid"
|
||||
};
|
||||
|
||||
const std::string levels [4] =
|
||||
{
|
||||
"none", "basic", "advanced", "expert"
|
||||
};
|
||||
}
|
||||
|
||||
namespace ETownType
|
||||
|
Loading…
Reference in New Issue
Block a user