mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Removed duplicate function initVillagesCapitols(), and simplified its clone loadTownDInfos().
This commit is contained in:
parent
34698eee4d
commit
2ae53395d7
@ -177,33 +177,6 @@ void CClient::save(const std::string & fname)
|
||||
*serv << &save_game;
|
||||
}
|
||||
|
||||
void initVillagesCapitols(Mapa * map)
|
||||
{
|
||||
const JsonNode config(DATA_DIR "/config/towns_defs.json");
|
||||
int idx;
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::endGame( bool closeConnection /*= true*/ )
|
||||
{
|
||||
// Game is ending
|
||||
@ -279,7 +252,6 @@ void CClient::loadGame( const std::string & fname )
|
||||
const_cast<CGameInfo*>(CGI)->mh->map = gs->map;
|
||||
pathInfo = new CPathsInfo(int3(gs->map->width, gs->map->height, gs->map->twoLevel+1));
|
||||
CGI->mh->init();
|
||||
initVillagesCapitols(gs->map);
|
||||
|
||||
tlog0 <<"Initing maphandler: "<<tmh.getDif()<<std::endl;
|
||||
}
|
||||
@ -378,7 +350,6 @@ void CClient::newGame( CConnection *con, StartInfo *si )
|
||||
const_cast<CGameInfo*>(CGI)->mh = new CMapHandler();
|
||||
CGI->mh->map = gs->map;
|
||||
tlog0 <<"Creating mapHandler: "<<tmh.getDif()<<std::endl;
|
||||
initVillagesCapitols(gs->map);
|
||||
CGI->mh->init();
|
||||
pathInfo = new CPathsInfo(int3(gs->map->width, gs->map->height, gs->map->twoLevel+1));
|
||||
tlog0 <<"Initializing mapHandler (together): "<<tmh.getDif()<<std::endl;
|
||||
|
@ -1739,23 +1739,25 @@ void CGameState::loadTownDInfos()
|
||||
{
|
||||
int i;
|
||||
const JsonNode config(DATA_DIR "/config/towns_defs.json");
|
||||
JsonVector vec = config["town_defnames"].Vector();
|
||||
assert(vec.size() == F_NUMBER);
|
||||
for (i = 0; i < vec.size(); ++i) {
|
||||
villages[i] = new CGDefInfo(*VLC->dobjinfo->castles[i]);
|
||||
forts[i] = VLC->dobjinfo->castles[i];
|
||||
map->defy.push_back(forts[i]);
|
||||
capitols[i] = new CGDefInfo(*VLC->dobjinfo->castles[i]);
|
||||
}
|
||||
|
||||
assert(config["town_defnames"].Vector().size() == F_NUMBER);
|
||||
|
||||
i = 0;
|
||||
BOOST_FOREACH(const JsonNode &t, vec) {
|
||||
BOOST_FOREACH(const JsonNode &t, config["town_defnames"].Vector())
|
||||
{
|
||||
villages[i] = new CGDefInfo(*VLC->dobjinfo->castles[i]);
|
||||
villages[i]->name = t["village"].String();
|
||||
map->defy.push_back(villages[i]);
|
||||
|
||||
forts[i] = VLC->dobjinfo->castles[i];
|
||||
map->defy.push_back(forts[i]);
|
||||
|
||||
capitols[i] = new CGDefInfo(*VLC->dobjinfo->castles[i]);
|
||||
capitols[i]->name = t["capitol"].String();
|
||||
++i;
|
||||
map->defy.push_back(capitols[i]);
|
||||
|
||||
++i;
|
||||
}
|
||||
for (i = 0; i < vec.size(); ++i) map->defy.push_back(villages[i]);
|
||||
for (i = 0; i < vec.size(); ++i) map->defy.push_back(capitols[i]);
|
||||
}
|
||||
|
||||
void CGameState::getNeighbours(const TerrainTile &srct, int3 tile, std::vector<int3> &vec, const boost::logic::tribool &onLand, bool limitCoastSailing)
|
||||
|
Loading…
x
Reference in New Issue
Block a user