diff --git a/client/Client.cpp b/client/Client.cpp index 09e0610eb..54f2563f3 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -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(n)->name = t["village"].String(); - map->defy.push_back(const_cast(n)); - - idx++; - } - - idx = 0; - BOOST_FOREACH(const JsonNode &t, config["town_defnames"].Vector()) { - const CGDefInfo *n = CGI->state->capitols[idx]; - const_cast(n)->name = t["capitol"].String(); - map->defy.push_back(const_cast(n)); - - idx++; - } -} - void CClient::endGame( bool closeConnection /*= true*/ ) { // Game is ending @@ -279,7 +252,6 @@ void CClient::loadGame( const std::string & fname ) const_cast(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: "<(CGI)->mh = new CMapHandler(); CGI->mh->map = gs->map; tlog0 <<"Creating mapHandler: "<map); CGI->mh->init(); pathInfo = new CPathsInfo(int3(gs->map->width, gs->map->height, gs->map->twoLevel+1)); tlog0 <<"Initializing mapHandler (together): "<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 &vec, const boost::logic::tribool &onLand, bool limitCoastSailing)