1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-28 23:06:24 +02:00

Created towns_defs.json from townsDefs.txt.

This commit is contained in:
Frank Zago 2011-09-01 00:11:34 +00:00
parent 35622913f9
commit d49058049e
3 changed files with 36 additions and 38 deletions

View File

@ -20,6 +20,7 @@
#include "../lib/NetPacks.h"
#include "../lib/VCMI_Lib.h"
#include "../lib/map.h"
#include "../lib/JsonNode.cpp"
#include "mapHandler.h"
#include "CConfigHandler.h"
#include "Client.h"
@ -176,28 +177,30 @@ void CClient::save(const std::string & fname)
*serv << &save_game;
}
#include <fstream>
void initVillagesCapitols(Mapa * map)
{
std::ifstream ifs(DATA_DIR "/config/townsDefs.txt");
int ccc;
ifs>>ccc;
for(int i=0;i<ccc*2;i++)
{
const CGDefInfo *n;
if(i<ccc)
{
n = CGI->state->villages[i];
map->defy.push_back(CGI->state->forts[i]);
}
else
n = CGI->state->capitols[i%ccc];
const JsonNode config(DATA_DIR "/config/towns_defs.json");
int idx;
ifs >> const_cast<CGDefInfo*>(n)->name;
if(!n)
tlog1 << "*HUGE* Warning - missing town def for " << i << std::endl;
else
map->defy.push_back(const_cast<CGDefInfo*>(n));
idx = 0;
BOOST_FOREACH(const JsonNode &t, config["town_defnames"].Vector()) {
map->defy.push_back(CGI->state->forts[idx]);
const CGDefInfo *n = CGI->state->villages[idx];
const_cast<CGDefInfo*>(n)->name = t["village"].String();
map->defy.push_back(const_cast<CGDefInfo*>(n));
idx++;
}
idx = 0;
BOOST_FOREACH(const JsonNode &t, config["town_defnames"].Vector()) {
const CGDefInfo *n = CGI->state->capitols[idx];
const_cast<CGDefInfo*>(n)->name = t["capitol"].String();
map->defy.push_back(const_cast<CGDefInfo*>(n));
idx++;
}
}

View File

@ -1,19 +0,0 @@
9
AVCCAST0.DEF
AVCRAMP0.DEF
AVCTOWR0.DEF
AVCINFT0.DEF
AVCNECR0.DEF
AVCDUNG0.DEF
AVCSTRO0.DEF
AVCFTRT0.DEF
AVCHFOR0.DEF
AVCCASZ0.DEF
AVCRAMZ0.DEF
AVCTOWZ0.DEF
AVCINFZ0.DEF
AVCNECZ0.DEF
AVCDUNZ0.DEF
AVCSTRZ0.DEF
AVCFORZ0.DEF
AVCHFORZ.DEF

14
config/towns_defs.json Normal file
View File

@ -0,0 +1,14 @@
{
// Graphics for villages and castles on the map, ordered by town id.
"town_defnames": [
{ "village": "AVCCAST0.DEF", "capitol": "AVCCASZ0.DEF" },
{ "village": "AVCRAMP0.DEF", "capitol": "AVCRAMZ0.DEF" },
{ "village": "AVCTOWR0.DEF", "capitol": "AVCTOWZ0.DEF" },
{ "village": "AVCINFT0.DEF", "capitol": "AVCINFZ0.DEF" },
{ "village": "AVCNECR0.DEF", "capitol": "AVCNECZ0.DEF" },
{ "village": "AVCDUNG0.DEF", "capitol": "AVCDUNZ0.DEF" },
{ "village": "AVCSTRO0.DEF", "capitol": "AVCSTRZ0.DEF" },
{ "village": "AVCFTRT0.DEF", "capitol": "AVCFORZ0.DEF" },
{ "village": "AVCHFOR0.DEF", "capitol": "AVCHFORZ.DEF" }
]
}