mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Created terrains.json from native_terrains.txt and TERCOSTS.TXT.
This commit is contained in:
parent
f9b14ba282
commit
bcce343b6c
@ -1,10 +0,0 @@
|
||||
9
|
||||
10 100 150 100 150 175 125 100 100 100 -1
|
||||
10 100 150 100 150 175 125 100 100 100 -1
|
||||
10 100 150 100 100 175 125 100 100 100 -1
|
||||
10 100 150 100 150 175 125 100 100 100 -1
|
||||
10 100 150 100 150 175 125 100 100 100 -1
|
||||
10 100 150 100 150 175 125 100 100 100 -1
|
||||
10 100 150 100 150 175 100 100 100 100 -1
|
||||
10 100 150 100 150 100 125 100 100 100 -1
|
||||
10 100 150 100 150 175 125 100 100 100 -1
|
@ -1,11 +0,0 @@
|
||||
//list of native terrains of different factions
|
||||
//[faction ID] [terrain ID]
|
||||
0 2
|
||||
1 2
|
||||
2 3
|
||||
3 7
|
||||
4 0
|
||||
5 6
|
||||
6 5
|
||||
7 4
|
||||
8 2
|
52
config/terrains.json
Normal file
52
config/terrains.json
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
// Terrains properties related to heroes - ordered by faction (0 to 8)
|
||||
// cost: ??
|
||||
// native: native terrain for the faction
|
||||
|
||||
"terrains": [
|
||||
{
|
||||
"costs": [ 100, 150, 100, 150, 175, 125, 100, 100, 100, -1 ],
|
||||
"native": 2
|
||||
},
|
||||
|
||||
{
|
||||
"costs": [ 100, 150, 100, 150, 175, 125, 100, 100, 100, -1 ],
|
||||
"native": 2
|
||||
},
|
||||
|
||||
{
|
||||
"costs": [ 100, 150, 100, 100, 175, 125, 100, 100, 100, -1 ],
|
||||
"native": 3
|
||||
},
|
||||
|
||||
{
|
||||
"costs": [ 100, 150, 100, 150, 175, 125, 100, 100, 100, -1 ],
|
||||
"native": 7
|
||||
},
|
||||
|
||||
{
|
||||
"costs": [ 100, 150, 100, 150, 175, 125, 100, 100, 100, -1 ],
|
||||
"native": 0
|
||||
},
|
||||
|
||||
{
|
||||
"costs": [ 100, 150, 100, 150, 175, 125, 100, 100, 100, -1 ],
|
||||
"native": 6
|
||||
},
|
||||
|
||||
{
|
||||
"costs": [ 100, 150, 100, 150, 175, 100, 100, 100, 100, -1 ],
|
||||
"native": 5
|
||||
},
|
||||
|
||||
{
|
||||
"costs": [ 100, 150, 100, 150, 100, 125, 100, 100, 100, -1 ],
|
||||
"native": 4
|
||||
},
|
||||
|
||||
{
|
||||
"costs": [ 100, 150, 100, 150, 175, 125, 100, 100, 100, -1 ],
|
||||
"native": 2
|
||||
}
|
||||
]
|
||||
}
|
@ -421,8 +421,8 @@ void CHeroHandler::initHeroClasses()
|
||||
{
|
||||
heroes[gg]->heroClass = heroClasses[heroes[gg]->heroType];
|
||||
}
|
||||
initTerrainCosts();
|
||||
loadNativeTerrains();
|
||||
|
||||
loadTerrains();
|
||||
}
|
||||
|
||||
unsigned int CHeroHandler::level (ui64 experience) const
|
||||
@ -458,56 +458,28 @@ ui64 CHeroHandler::reqExp (unsigned int level) const
|
||||
}
|
||||
}
|
||||
|
||||
void CHeroHandler::initTerrainCosts()
|
||||
void CHeroHandler::loadTerrains()
|
||||
{
|
||||
std::ifstream inp;
|
||||
inp.open(DATA_DIR "/config/TERCOSTS.TXT", std::ios_base::in|std::ios_base::binary);
|
||||
|
||||
if(!inp.is_open())
|
||||
{
|
||||
tlog1 << "Error while opening config/TERCOSTS.TXT file!" << std::endl;
|
||||
}
|
||||
|
||||
int tynum;
|
||||
inp>>tynum;
|
||||
for(int i=0; i<2*tynum; i+=2)
|
||||
{
|
||||
int catNum;
|
||||
inp>>catNum;
|
||||
for(int k=0; k<catNum; ++k)
|
||||
{
|
||||
int curCost;
|
||||
inp>>curCost;
|
||||
heroClasses[i]->terrCosts.push_back(curCost);
|
||||
heroClasses[i+1]->terrCosts.push_back(curCost);
|
||||
}
|
||||
}
|
||||
inp.close();
|
||||
}
|
||||
|
||||
void CHeroHandler::loadNativeTerrains()
|
||||
{
|
||||
std::ifstream inp;
|
||||
inp.open(DATA_DIR "/config/native_terrains.txt", std::ios_base::in|std::ios_base::binary);
|
||||
|
||||
if(!inp.is_open())
|
||||
{
|
||||
tlog1 << "Error while opening config/native_terrains.txt file!" << std::endl;
|
||||
}
|
||||
const int MAX_ELEM = 1000;
|
||||
char buf[MAX_ELEM+1];
|
||||
inp.getline(buf, MAX_ELEM);
|
||||
inp.getline(buf, MAX_ELEM);
|
||||
int faction = 0;
|
||||
const JsonNode config(DATA_DIR "/config/terrains.json");
|
||||
|
||||
nativeTerrains.resize(F_NUMBER);
|
||||
for(int i=0; i<F_NUMBER; ++i)
|
||||
{
|
||||
int faction, terrain;
|
||||
inp >> faction;
|
||||
inp >> terrain;
|
||||
nativeTerrains[faction] = terrain;
|
||||
|
||||
BOOST_FOREACH(const JsonNode &terrain, config["terrains"].Vector()) {
|
||||
|
||||
BOOST_FOREACH(const JsonNode &cost, terrain["costs"].Vector()) {
|
||||
int curCost = cost.Float();
|
||||
|
||||
heroClasses[2*faction]->terrCosts.push_back(curCost);
|
||||
heroClasses[2*faction+1]->terrCosts.push_back(curCost);
|
||||
}
|
||||
|
||||
nativeTerrains[faction] = terrain["native"].Float();
|
||||
|
||||
faction ++;
|
||||
}
|
||||
inp.close();
|
||||
|
||||
assert(faction == F_NUMBER);
|
||||
}
|
||||
|
||||
CHero::CHero()
|
||||
|
@ -155,8 +155,7 @@ public:
|
||||
void loadHeroes();
|
||||
void loadHeroClasses();
|
||||
void initHeroClasses();
|
||||
void initTerrainCosts();
|
||||
void loadNativeTerrains();
|
||||
void loadTerrains();
|
||||
CHeroHandler(); //c-tor
|
||||
~CHeroHandler(); //d-tor
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user