|
@@ -19,21 +19,11 @@
|
|
|
|
|
|
const std::string & CBuilding::Name() const
|
|
|
{
|
|
|
- if(name.length())
|
|
|
- return name;
|
|
|
- else if(vstd::contains(VLC->generaltexth->buildings,tid) && vstd::contains(VLC->generaltexth->buildings[tid],bid))
|
|
|
- return VLC->generaltexth->buildings[tid][bid].first;
|
|
|
- tlog2 << "Warning: Cannot find name text for building " << bid << "for " << tid << "town.\n";
|
|
|
return name;
|
|
|
}
|
|
|
|
|
|
const std::string & CBuilding::Description() const
|
|
|
{
|
|
|
- if(description.length())
|
|
|
- return description;
|
|
|
- else if(vstd::contains(VLC->generaltexth->buildings,tid) && vstd::contains(VLC->generaltexth->buildings[tid],bid))
|
|
|
- return VLC->generaltexth->buildings[tid][bid].second;
|
|
|
- tlog2 << "Warning: Cannot find description text for building " << bid << "for " << tid << "town.\n";
|
|
|
return description;
|
|
|
}
|
|
|
|
|
@@ -60,22 +50,6 @@ si32 CBuilding::getDistance(CBuilding::BuildingType buildID) const
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
-const std::string & CTown::Name() const
|
|
|
-{
|
|
|
- if(name.length())
|
|
|
- return name;
|
|
|
- else
|
|
|
- return VLC->generaltexth->townTypes[typeID];
|
|
|
-}
|
|
|
-
|
|
|
-const std::vector<std::string> & CTown::Names() const
|
|
|
-{
|
|
|
- if(names.size())
|
|
|
- return names;
|
|
|
- else
|
|
|
- return VLC->generaltexth->townNames[typeID];
|
|
|
-}
|
|
|
-
|
|
|
CTownHandler::CTownHandler()
|
|
|
{
|
|
|
VLC->townh = this;
|
|
@@ -105,7 +79,7 @@ void CTownHandler::loadLegacyData(JsonNode & dest)
|
|
|
//Unique buildings
|
|
|
for (size_t town=0; town<GameConstants::F_NUMBER; town++)
|
|
|
{
|
|
|
- JsonVector & buildList = dest.Vector()[town].Vector();
|
|
|
+ JsonVector & buildList = dest.Vector()[town]["buildings"].Vector();
|
|
|
|
|
|
buildList.resize( 30 ); //prepare vector for first set of buildings
|
|
|
|
|
@@ -132,7 +106,7 @@ void CTownHandler::loadLegacyData(JsonNode & dest)
|
|
|
JsonNode building = readBuilding(parser);
|
|
|
|
|
|
for (size_t town=0; town<GameConstants::F_NUMBER; town++)
|
|
|
- dest.Vector()[town].Vector()[buildID] = building;
|
|
|
+ dest.Vector()[town]["buildings"].Vector()[buildID] = building;
|
|
|
|
|
|
buildID++;
|
|
|
}
|
|
@@ -149,10 +123,108 @@ void CTownHandler::loadLegacyData(JsonNode & dest)
|
|
|
|
|
|
do
|
|
|
{
|
|
|
- dest.Vector()[town].Vector().push_back(readBuilding(parser));
|
|
|
+ dest.Vector()[town]["buildings"].Vector().push_back(readBuilding(parser));
|
|
|
}
|
|
|
while (!parser.isNextEntryEmpty());
|
|
|
}
|
|
|
+ {
|
|
|
+ CLegacyConfigParser parser("DATA/BLDGNEUT.TXT");
|
|
|
+
|
|
|
+ for(int building=0; building<15; building++)
|
|
|
+ {
|
|
|
+ std::string name = parser.readString();
|
|
|
+ std::string descr = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+
|
|
|
+ for(int j=0; j<GameConstants::F_NUMBER; j++)
|
|
|
+ {
|
|
|
+ JsonVector & buildings = dest.Vector()[j]["buildings"].Vector();
|
|
|
+ buildings[building]["name"].String() = name;
|
|
|
+ buildings[building]["description"].String() = descr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ parser.endLine(); // silo
|
|
|
+ parser.endLine(); // blacksmith //unused entries
|
|
|
+ parser.endLine(); // moat
|
|
|
+
|
|
|
+ //shipyard with the ship
|
|
|
+ std::string name = parser.readString();
|
|
|
+ std::string descr = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+
|
|
|
+ for(int town=0; town<GameConstants::F_NUMBER; town++)
|
|
|
+ {
|
|
|
+ JsonVector & buildings = dest.Vector()[town]["buildings"].Vector();
|
|
|
+ buildings[20]["name"].String() = name;
|
|
|
+ buildings[20]["description"].String() = descr;
|
|
|
+ }
|
|
|
+
|
|
|
+ //blacksmith
|
|
|
+ for(int town=0; town<GameConstants::F_NUMBER; town++)
|
|
|
+ {
|
|
|
+ JsonVector & buildings = dest.Vector()[town]["buildings"].Vector();
|
|
|
+ buildings[16]["name"].String() = parser.readString();
|
|
|
+ buildings[16]["description"].String() = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ {
|
|
|
+ CLegacyConfigParser parser("DATA/BLDGSPEC.TXT");
|
|
|
+
|
|
|
+ for(int town=0; town<GameConstants::F_NUMBER; town++)
|
|
|
+ {
|
|
|
+ JsonVector & buildings = dest.Vector()[town]["buildings"].Vector();
|
|
|
+ for(int build=0; build<9; build++)
|
|
|
+ {
|
|
|
+ buildings[17+build]["name"].String() = parser.readString();
|
|
|
+ buildings[17+build]["description"].String() = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+ }
|
|
|
+ buildings[26]["name"].String() = parser.readString(); // Grail
|
|
|
+ buildings[26]["description"].String() = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+
|
|
|
+ buildings[15]["name"].String() = parser.readString(); // Resource silo
|
|
|
+ buildings[15]["description"].String() = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ {
|
|
|
+ CLegacyConfigParser parser("DATA/DWELLING.TXT");
|
|
|
+
|
|
|
+ for(int town=0; town<GameConstants::F_NUMBER; town++)
|
|
|
+ {
|
|
|
+ JsonVector & buildings = dest.Vector()[town]["buildings"].Vector();
|
|
|
+ for(int build=0; build<14; build++)
|
|
|
+ {
|
|
|
+ buildings[30+build]["name"].String() = parser.readString();
|
|
|
+ buildings[30+build]["description"].String() = parser.readString();
|
|
|
+ parser.endLine();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ {
|
|
|
+ CLegacyConfigParser typeParser("DATA/TOWNTYPE.TXT");
|
|
|
+ CLegacyConfigParser nameParser("DATA/TOWNNAME.TXT");
|
|
|
+ size_t townID=0;
|
|
|
+ do
|
|
|
+ {
|
|
|
+ JsonNode & town = dest.Vector()[townID];
|
|
|
+
|
|
|
+ town["name"].String() = typeParser.readString();
|
|
|
+
|
|
|
+
|
|
|
+ for (int i=0; i<GameConstants::NAMES_PER_TOWN; i++)
|
|
|
+ {
|
|
|
+ JsonNode name;
|
|
|
+ name.String() = nameParser.readString();
|
|
|
+ town["names"].Vector().push_back(name);
|
|
|
+ nameParser.endLine();
|
|
|
+ }
|
|
|
+ townID++;
|
|
|
+ }
|
|
|
+ while (typeParser.endLine());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void CTownHandler::loadBuilding(CTown &town, const JsonNode & source)
|
|
@@ -269,13 +341,10 @@ void CTownHandler::loadClientData(CTown &town, const JsonNode & source)
|
|
|
|
|
|
void CTownHandler::loadTown(CTown &town, const JsonNode & source)
|
|
|
{
|
|
|
- town.bonus = town.typeID;
|
|
|
- if (town.bonus==8)
|
|
|
- town.bonus=3;
|
|
|
-
|
|
|
town.mageLevel = source["mageGuild"].Float();
|
|
|
town.primaryRes = source["primaryResource"].Float();
|
|
|
town.warMachine = source["warMachine"].Float();
|
|
|
+ town.names = source["names"].StdVector<std::string>();
|
|
|
|
|
|
// Horde building creature level
|
|
|
BOOST_FOREACH(const JsonNode &node, source["horde"].Vector())
|
|
@@ -331,18 +400,17 @@ void CTownHandler::loadFactions(const JsonNode &source)
|
|
|
CFaction & faction = factions[id];
|
|
|
|
|
|
faction.factionID = id;
|
|
|
- faction.name = node.first;
|
|
|
+ faction.name = node.second["name"].String();
|
|
|
|
|
|
faction.creatureBg120 = node.second["creatureBackground"]["120px"].String();
|
|
|
faction.creatureBg130 = node.second["creatureBackground"]["130px"].String();
|
|
|
|
|
|
- if (!node.second["nativeTerrain"].isNull())
|
|
|
- {
|
|
|
- //get terrain as string and converto to numeric ID
|
|
|
- faction.nativeTerrain = boost::find(GameConstants::TERRAIN_NAMES, node.second["nativeTerrain"].String()) - GameConstants::TERRAIN_NAMES;
|
|
|
- }
|
|
|
+ faction.nativeTerrain = vstd::find_pos(GameConstants::TERRAIN_NAMES, node.second["nativeTerrain"].String());
|
|
|
+ int alignment = vstd::find_pos(EAlignment::names, node.second["alignment"].String());
|
|
|
+ if (alignment == -1)
|
|
|
+ faction.alignment = EAlignment::NEUTRAL;
|
|
|
else
|
|
|
- faction.nativeTerrain = -1;
|
|
|
+ faction.alignment = alignment;
|
|
|
|
|
|
if (!node.second["town"].isNull())
|
|
|
{
|
|
@@ -361,7 +429,7 @@ void CTownHandler::load()
|
|
|
JsonNode legacyConfig;
|
|
|
loadLegacyData(legacyConfig);
|
|
|
|
|
|
- //hardocoded list of H3 factions. Should be only used to convert H3 configs
|
|
|
+ //hardcoded list of H3 factions. Should be only used to convert H3 configs
|
|
|
static const std::string factionName [GameConstants::F_NUMBER] =
|
|
|
{
|
|
|
"castle", "rampart", "tower",
|
|
@@ -370,24 +438,35 @@ void CTownHandler::load()
|
|
|
};
|
|
|
|
|
|
// semi-manually merge legacy config with towns json
|
|
|
- // legacy config have only one item: town buildings stored in 2d vector
|
|
|
|
|
|
for (size_t i=0; i< legacyConfig.Vector().size(); i++)
|
|
|
{
|
|
|
- JsonNode & buildings = buildingsConf[factionName[i]]["town"]["buildings"];
|
|
|
- BOOST_FOREACH(JsonNode & building, buildings.Vector())
|
|
|
+ JsonNode & legacyFaction = legacyConfig.Vector()[i];
|
|
|
+ JsonNode & outputFaction = buildingsConf[factionName[i]];
|
|
|
+
|
|
|
+ if (outputFaction["name"].isNull())
|
|
|
+ outputFaction["name"] = legacyFaction["name"];
|
|
|
+
|
|
|
+ if (!outputFaction["town"].isNull())
|
|
|
{
|
|
|
- JsonNode & legacyFaction = legacyConfig.Vector()[i];
|
|
|
- if (vstd::contains(building.Struct(), "id"))
|
|
|
- {
|
|
|
- //find same buildings in legacy and json configs
|
|
|
- JsonNode & legacyBuilding = legacyFaction.Vector()[building["id"].Float()];
|
|
|
+ if (outputFaction["town"]["names"].isNull())
|
|
|
+ outputFaction["town"]["names"] = legacyFaction["names"];
|
|
|
|
|
|
- if (!legacyBuilding.isNull()) //merge if h3 config was found for this building
|
|
|
- JsonNode::merge(building, legacyBuilding);
|
|
|
+ JsonNode & outputBuildings = outputFaction["town"]["buildings"];
|
|
|
+ JsonVector & legacyBuildings = legacyFaction["buildings"].Vector();
|
|
|
+ BOOST_FOREACH(JsonNode & building, outputBuildings.Vector())
|
|
|
+ {
|
|
|
+ if (vstd::contains(building.Struct(), "id") &&
|
|
|
+ legacyBuildings.size() > building["id"].Float() )
|
|
|
+ {
|
|
|
+ //find same buildings in legacy and json configs
|
|
|
+ JsonNode & legacyBuilding = legacyBuildings[building["id"].Float()];
|
|
|
+
|
|
|
+ if (!legacyBuilding.isNull()) //merge if h3 config was found for this building
|
|
|
+ JsonNode::merge(building, legacyBuilding);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
loadFactions(buildingsConf);
|
|
|
}
|