|
@@ -19,31 +19,24 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|
//("allowedTerrain"\s*:\s*\[.*)9(.*\],\n)
|
|
//("allowedTerrain"\s*:\s*\[.*)9(.*\],\n)
|
|
//\1"rock"\2
|
|
//\1"rock"\2
|
|
|
|
|
|
-const Terrain Terrain::ANY("ANY");
|
|
|
|
-
|
|
|
|
-Terrain Terrain::createTerrainTypeH3M(int tId)
|
|
|
|
|
|
+TerrainTypeHandler::TerrainTypeHandler()
|
|
{
|
|
{
|
|
- static std::array<std::string, 10> terrainsH3M
|
|
|
|
- {
|
|
|
|
- "dirt", "sand", "grass", "snow", "swamp", "rough", "subterra", "lava", "water", "rock"
|
|
|
|
- };
|
|
|
|
- return Terrain(terrainsH3M.at(tId));
|
|
|
|
-}
|
|
|
|
|
|
+ auto allConfigs = VLC->modh->getActiveMods();
|
|
|
|
+ allConfigs.insert(allConfigs.begin(), "core");
|
|
|
|
|
|
-Terrain Terrain::createTerrainByCode(const std::string & typeCode)
|
|
|
|
-{
|
|
|
|
- for(const auto & terrain : Manager::terrains())
|
|
|
|
- {
|
|
|
|
- if(Manager::getInfo(terrain).typeCode == typeCode)
|
|
|
|
- return terrain;
|
|
|
|
- }
|
|
|
|
- return Terrain::ANY;
|
|
|
|
|
|
+ initRivers(allConfigs);
|
|
|
|
+ recreateRiverMaps();
|
|
|
|
+ initRoads(allConfigs);
|
|
|
|
+ recreateRoadMaps();
|
|
|
|
+ initTerrains(allConfigs); //maps will be populated inside
|
|
}
|
|
}
|
|
|
|
|
|
-Terrain::Manager::Manager()
|
|
|
|
|
|
+void TerrainTypeHandler::initTerrains(const std::vector<std::string> & allConfigs)
|
|
{
|
|
{
|
|
- auto allConfigs = VLC->modh->getActiveMods();
|
|
|
|
- allConfigs.insert(allConfigs.begin(), "core");
|
|
|
|
|
|
+ std::vector<std::function<void()>> resolveLater;
|
|
|
|
+
|
|
|
|
+ objects.resize(Terrain::ORIGINAL_TERRAIN_COUNT); //make space for original terrains
|
|
|
|
+
|
|
for(auto & mod : allConfigs)
|
|
for(auto & mod : allConfigs)
|
|
{
|
|
{
|
|
if(!CResourceHandler::get(mod)->existsResource(ResourceID("config/terrains.json")))
|
|
if(!CResourceHandler::get(mod)->existsResource(ResourceID("config/terrains.json")))
|
|
@@ -52,8 +45,9 @@ Terrain::Manager::Manager()
|
|
JsonNode terrs(mod, ResourceID("config/terrains.json"));
|
|
JsonNode terrs(mod, ResourceID("config/terrains.json"));
|
|
for(auto & terr : terrs.Struct())
|
|
for(auto & terr : terrs.Struct())
|
|
{
|
|
{
|
|
- Terrain::Info info;
|
|
|
|
- info.moveCost = terr.second["moveCost"].Integer();
|
|
|
|
|
|
+ TerrainType info(terr.first); //set name
|
|
|
|
+
|
|
|
|
+ info.moveCost = static_cast<int>(terr.second["moveCost"].Integer());
|
|
const JsonVector &unblockedVec = terr.second["minimapUnblocked"].Vector();
|
|
const JsonVector &unblockedVec = terr.second["minimapUnblocked"].Vector();
|
|
info.minimapUnblocked =
|
|
info.minimapUnblocked =
|
|
{
|
|
{
|
|
@@ -74,42 +68,47 @@ Terrain::Manager::Manager()
|
|
|
|
|
|
if(terr.second["type"].isNull())
|
|
if(terr.second["type"].isNull())
|
|
{
|
|
{
|
|
- info.type = Terrain::Info::Type::Land;
|
|
|
|
|
|
+ info.passabilityType = TerrainType::PassabilityType::LAND | TerrainType::PassabilityType::SURFACE;
|
|
}
|
|
}
|
|
- else
|
|
|
|
|
|
+ else if (terr.second["type"].getType() == JsonNode::JsonType::DATA_VECTOR)
|
|
{
|
|
{
|
|
- auto s = terr.second["type"].String();
|
|
|
|
- if(s == "LAND") info.type = Terrain::Info::Type::Land;
|
|
|
|
- if(s == "WATER") info.type = Terrain::Info::Type::Water;
|
|
|
|
- if(s == "ROCK") info.type = Terrain::Info::Type::Rock;
|
|
|
|
- if(s == "SUB") info.type = Terrain::Info::Type::Subterranean;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if(terr.second["rockTerrain"].isNull())
|
|
|
|
- {
|
|
|
|
- info.rockTerrain = "rock";
|
|
|
|
|
|
+ for(const auto& node : terr.second["type"].Vector())
|
|
|
|
+ {
|
|
|
|
+ //Set bits
|
|
|
|
+ auto s = node.String();
|
|
|
|
+ if (s == "LAND") info.passabilityType |= TerrainType::PassabilityType::LAND;
|
|
|
|
+ if (s == "WATER") info.passabilityType |= TerrainType::PassabilityType::WATER;
|
|
|
|
+ if (s == "ROCK") info.passabilityType |= TerrainType::PassabilityType::ROCK;
|
|
|
|
+ if (s == "SURFACE") info.passabilityType |= TerrainType::PassabilityType::SURFACE;
|
|
|
|
+ if (s == "SUB") info.passabilityType |= TerrainType::PassabilityType::SUBTERRANEAN;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- else
|
|
|
|
|
|
+ else //should be string - one option only
|
|
{
|
|
{
|
|
- info.rockTerrain = terr.second["rockTerrain"].String();
|
|
|
|
|
|
+ auto s = terr.second["type"].String();
|
|
|
|
+ if (s == "LAND") info.passabilityType = TerrainType::PassabilityType::LAND;
|
|
|
|
+ if (s == "WATER") info.passabilityType = TerrainType::PassabilityType::WATER;
|
|
|
|
+ if (s == "ROCK") info.passabilityType = TerrainType::PassabilityType::ROCK;
|
|
|
|
+ if (s == "SURFACE") info.passabilityType = TerrainType::PassabilityType::SURFACE;
|
|
|
|
+ if (s == "SUB") info.passabilityType = TerrainType::PassabilityType::SUBTERRANEAN;
|
|
}
|
|
}
|
|
|
|
|
|
if(terr.second["river"].isNull())
|
|
if(terr.second["river"].isNull())
|
|
{
|
|
{
|
|
- info.river = RIVER_NAMES[0];
|
|
|
|
|
|
+ info.river = River::NO_RIVER;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- info.river = terr.second["river"].String();
|
|
|
|
|
|
+ info.river = getRiverByCode(terr.second["river"].String())->id;
|
|
}
|
|
}
|
|
|
|
|
|
if(terr.second["horseSoundId"].isNull())
|
|
if(terr.second["horseSoundId"].isNull())
|
|
{
|
|
{
|
|
- info.horseSoundId = 9; //rock sound as default
|
|
|
|
|
|
+ info.horseSoundId = Terrain::ROCK; //rock sound as default
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- info.horseSoundId = terr.second["horseSoundId"].Integer();
|
|
|
|
|
|
+ info.horseSoundId = static_cast<int>(terr.second["horseSoundId"].Float());
|
|
}
|
|
}
|
|
|
|
|
|
if(!terr.second["text"].isNull())
|
|
if(!terr.second["text"].isNull())
|
|
@@ -135,14 +134,6 @@ Terrain::Manager::Manager()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if(!terr.second["prohibitTransitions"].isNull())
|
|
|
|
- {
|
|
|
|
- for(auto & t : terr.second["prohibitTransitions"].Vector())
|
|
|
|
- {
|
|
|
|
- info.prohibitTransitions.emplace_back(t.String());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
info.transitionRequired = false;
|
|
info.transitionRequired = false;
|
|
if(!terr.second["transitionRequired"].isNull())
|
|
if(!terr.second["transitionRequired"].isNull())
|
|
{
|
|
{
|
|
@@ -154,104 +145,361 @@ Terrain::Manager::Manager()
|
|
{
|
|
{
|
|
info.terrainViewPatterns = terr.second["terrainViewPatterns"].String();
|
|
info.terrainViewPatterns = terr.second["terrainViewPatterns"].String();
|
|
}
|
|
}
|
|
-
|
|
|
|
- terrainInfo[terr.first] = info;
|
|
|
|
- if(!terrainId.count(terr.first))
|
|
|
|
|
|
+
|
|
|
|
+ if(!terr.second["originalTerrainId"].isNull())
|
|
|
|
+ {
|
|
|
|
+ //place in reserved slot
|
|
|
|
+ info.id = (TerrainId)(terr.second["originalTerrainId"].Float());
|
|
|
|
+ objects[info.id] = info;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //append at the end
|
|
|
|
+ info.id = static_cast<TerrainId>(objects.size());
|
|
|
|
+ objects.push_back(info);
|
|
|
|
+ }
|
|
|
|
+ TerrainId id = info.id;
|
|
|
|
+
|
|
|
|
+ //Update terrain with this id in the future, after all terrain types are populated
|
|
|
|
+
|
|
|
|
+ if(!terr.second["prohibitTransitions"].isNull())
|
|
|
|
+ {
|
|
|
|
+ for(auto & t : terr.second["prohibitTransitions"].Vector())
|
|
|
|
+ {
|
|
|
|
+ std::string prohibitedTerrainName = t.String();
|
|
|
|
+ resolveLater.push_back([this, prohibitedTerrainName, id]()
|
|
|
|
+ {
|
|
|
|
+ //FIXME: is that reference to the element in vector?
|
|
|
|
+ objects[id].prohibitTransitions.emplace_back(getInfoByName(prohibitedTerrainName)->id);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(terr.second["rockTerrain"].isNull())
|
|
|
|
+ {
|
|
|
|
+ objects[id].rockTerrain = Terrain::ROCK;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ auto rockTerrainName = terr.second["rockTerrain"].String();
|
|
|
|
+ resolveLater.push_back([this, rockTerrainName, id]()
|
|
|
|
+ {
|
|
|
|
+ //FIXME: is that reference to the element in vector?
|
|
|
|
+ objects[id].rockTerrain = getInfoByName(rockTerrainName)->id;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(size_t i = Terrain::FIRST_REGULAR_TERRAIN; i < Terrain::ORIGINAL_TERRAIN_COUNT; i++)
|
|
|
|
+ {
|
|
|
|
+ //Make sure that original terrains are loaded
|
|
|
|
+ assert(objects(i).id != Terrain::WRONG);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ recreateTerrainMaps();
|
|
|
|
+
|
|
|
|
+ for(auto& functor : resolveLater)
|
|
|
|
+ {
|
|
|
|
+ functor();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void TerrainTypeHandler::initRivers(const std::vector<std::string> & allConfigs)
|
|
|
|
+{
|
|
|
|
+ riverTypes.resize(River::ORIGINAL_RIVER_COUNT); //make space for original rivers
|
|
|
|
+ //First object will be default NO_RIVER
|
|
|
|
+
|
|
|
|
+ for(auto & mod : allConfigs)
|
|
|
|
+ {
|
|
|
|
+ if (!CResourceHandler::get(mod)->existsResource(ResourceID("config/rivers.json")))
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ JsonNode rivs(mod, ResourceID("config/rivers.json"));
|
|
|
|
+ for(auto & river : rivs.Struct())
|
|
|
|
+ {
|
|
|
|
+ RiverType info;
|
|
|
|
+
|
|
|
|
+ info.fileName = river.second["animation"].String();
|
|
|
|
+ info.code = river.second["code"].String();
|
|
|
|
+ info.deltaName = river.second["delta"].String();
|
|
|
|
+
|
|
|
|
+ if (!river.second["originalRiverId"].isNull())
|
|
|
|
+ {
|
|
|
|
+ info.id = static_cast<RiverId>(river.second["originalRiverId"].Float());
|
|
|
|
+ riverTypes[info.id] = info;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ info.id = static_cast<RiverId>(riverTypes.size());
|
|
|
|
+ riverTypes.push_back(info);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ recreateRiverMaps();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void TerrainTypeHandler::initRoads(const std::vector<std::string> & allConfigs)
|
|
|
|
+{
|
|
|
|
+ roadTypes.resize(Road::ORIGINAL_ROAD_COUNT); //make space for original rivers
|
|
|
|
+ //first object will be default NO_ROAD
|
|
|
|
+
|
|
|
|
+ for(auto & mod : allConfigs)
|
|
|
|
+ {
|
|
|
|
+ if (!CResourceHandler::get(mod)->existsResource(ResourceID("config/roads.json")))
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ JsonNode rds(mod, ResourceID("config/roads.json"));
|
|
|
|
+ for(auto & road : rds.Struct())
|
|
|
|
+ {
|
|
|
|
+ RoadType info;
|
|
|
|
+
|
|
|
|
+ info.fileName = road.second["animation"].String();
|
|
|
|
+ info.code = road.second["code"].String();
|
|
|
|
+ info.movementCost = static_cast<ui8>(road.second["moveCost"].Float());
|
|
|
|
+
|
|
|
|
+ if (!road.second["originalRoadId"].isNull())
|
|
{
|
|
{
|
|
- terrainId[terr.first] = terrainVault.size();
|
|
|
|
- terrainVault.push_back(terr.first);
|
|
|
|
|
|
+ info.id = static_cast<RoadId>(road.second["originalRoadId"].Float());
|
|
|
|
+ roadTypes[info.id] = info;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ info.id = static_cast<RoadId>(roadTypes.size());
|
|
|
|
+ roadTypes.push_back(info);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ recreateRoadMaps();
|
|
}
|
|
}
|
|
|
|
|
|
-Terrain::Manager & Terrain::Manager::get()
|
|
|
|
|
|
+void TerrainTypeHandler::recreateTerrainMaps()
|
|
{
|
|
{
|
|
- static Terrain::Manager manager;
|
|
|
|
- return manager;
|
|
|
|
|
|
+ //This assumes the vector will never be updated or reallocated in the future
|
|
|
|
+
|
|
|
|
+ for(size_t i = 0; i < objects.size(); i++)
|
|
|
|
+ {
|
|
|
|
+ const auto * terrainInfo = &objects[i];
|
|
|
|
+
|
|
|
|
+ terrainInfoByName[terrainInfo->name] = terrainInfo;
|
|
|
|
+ terrainInfoByCode[terrainInfo->typeCode] = terrainInfo;
|
|
|
|
+ terrainInfoById[terrainInfo->id] = terrainInfo;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
-const std::vector<Terrain> & Terrain::Manager::terrains()
|
|
|
|
|
|
+void TerrainTypeHandler::recreateRiverMaps()
|
|
{
|
|
{
|
|
- return Terrain::Manager::get().terrainVault;
|
|
|
|
|
|
+ for(size_t i = River::FIRST_REGULAR_RIVER ; i < riverTypes.size(); i++)
|
|
|
|
+ {
|
|
|
|
+ const auto * riverInfo = &riverTypes[i];
|
|
|
|
+
|
|
|
|
+ riverInfoByName[riverInfo->fileName] = riverInfo;
|
|
|
|
+ riverInfoByCode[riverInfo->code] = riverInfo;
|
|
|
|
+ riverInfoById[riverInfo->id] = riverInfo;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
-int Terrain::Manager::id(const Terrain & terrain)
|
|
|
|
|
|
+void TerrainTypeHandler::recreateRoadMaps()
|
|
{
|
|
{
|
|
- if(terrain.name == "ANY") return -3;
|
|
|
|
- if(terrain.name == "WRONG") return -2;
|
|
|
|
- if(terrain.name == "BORDER") return -1;
|
|
|
|
-
|
|
|
|
- return Terrain::Manager::get().terrainId.at(terrain);
|
|
|
|
|
|
+ for(size_t i = Road::FIRST_REGULAR_ROAD ; i < roadTypes.size(); i++)
|
|
|
|
+ {
|
|
|
|
+ const auto * roadInfo = &roadTypes[i];
|
|
|
|
+
|
|
|
|
+ roadInfoByName[roadInfo->fileName] = roadInfo;
|
|
|
|
+ roadInfoByCode[roadInfo->code] = roadInfo;
|
|
|
|
+ roadInfoById[roadInfo->id] = roadInfo;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const std::vector<TerrainType> & TerrainTypeHandler::terrains() const
|
|
|
|
+{
|
|
|
|
+ //FIXME: somehow make it non-copyable? Pointers must point to original data and not its copy
|
|
|
|
+ return objects;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const std::vector<RiverType>& TerrainTypeHandler::rivers() const
|
|
|
|
+{
|
|
|
|
+ return riverTypes;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const std::vector<RoadType>& TerrainTypeHandler::roads() const
|
|
|
|
+{
|
|
|
|
+ return roadTypes;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const TerrainType* TerrainTypeHandler::getInfoByName(const std::string& terrainName) const
|
|
|
|
+{
|
|
|
|
+ return terrainInfoByName.at(terrainName);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const TerrainType* TerrainTypeHandler::getInfoByCode(const std::string& terrainCode) const
|
|
|
|
+{
|
|
|
|
+ return terrainInfoByCode.at(terrainCode);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const TerrainType* TerrainTypeHandler::getInfoById(TerrainId id) const
|
|
|
|
+{
|
|
|
|
+ return terrainInfoById.at(id);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const RiverType* TerrainTypeHandler::getRiverByName(const std::string& riverName) const
|
|
|
|
+{
|
|
|
|
+ return riverInfoByName.at(riverName);
|
|
}
|
|
}
|
|
|
|
|
|
-const Terrain::Info & Terrain::Manager::getInfo(const Terrain & terrain)
|
|
|
|
|
|
+const RiverType* TerrainTypeHandler::getRiverByCode(const std::string& riverCode) const
|
|
{
|
|
{
|
|
- return Terrain::Manager::get().terrainInfo.at(static_cast<std::string>(terrain));
|
|
|
|
|
|
+ return riverInfoByCode.at(riverCode);
|
|
}
|
|
}
|
|
|
|
|
|
-std::ostream & operator<<(std::ostream & os, const Terrain terrainType)
|
|
|
|
|
|
+const RiverType* TerrainTypeHandler::getRiverById(RiverId id) const
|
|
|
|
+{
|
|
|
|
+ return riverInfoById.at(id);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const RoadType* TerrainTypeHandler::getRoadByName(const std::string& roadName) const
|
|
|
|
+{
|
|
|
|
+ return roadInfoByName.at(roadName);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const RoadType* TerrainTypeHandler::getRoadByCode(const std::string& roadCode) const
|
|
|
|
+{
|
|
|
|
+ return roadInfoByCode.at(roadCode);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const RoadType* TerrainTypeHandler::getRoadById(RoadId id) const
|
|
|
|
+{
|
|
|
|
+ return roadInfoById.at(id);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+std::ostream & operator<<(std::ostream & os, const TerrainType & terrainType)
|
|
{
|
|
{
|
|
return os << static_cast<const std::string &>(terrainType);
|
|
return os << static_cast<const std::string &>(terrainType);
|
|
}
|
|
}
|
|
|
|
|
|
-Terrain::operator std::string() const
|
|
|
|
|
|
+TerrainType::operator std::string() const
|
|
{
|
|
{
|
|
return name;
|
|
return name;
|
|
}
|
|
}
|
|
-
|
|
|
|
-Terrain::Terrain(const std::string & _name) : name(_name)
|
|
|
|
-{}
|
|
|
|
|
|
|
|
-Terrain& Terrain::operator=(const std::string & _name)
|
|
|
|
|
|
+TerrainType::TerrainType(const std::string& _name):
|
|
|
|
+ minimapBlocked({0,0,0}), //black
|
|
|
|
+ minimapUnblocked({ 128,128,128 }), //grey
|
|
|
|
+ name(_name),
|
|
|
|
+ river(River::NO_RIVER),
|
|
|
|
+ id(Terrain::WRONG),
|
|
|
|
+ rockTerrain(Terrain::ROCK),
|
|
|
|
+ moveCost(GameConstants::BASE_MOVEMENT_COST),
|
|
|
|
+ horseSoundId(0),
|
|
|
|
+ passabilityType(0),
|
|
|
|
+ transitionRequired(false)
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TerrainType& TerrainType::operator=(const TerrainType & other)
|
|
{
|
|
{
|
|
- name = _name;
|
|
|
|
|
|
+ battleFields = other.battleFields;
|
|
|
|
+ prohibitTransitions = other.prohibitTransitions;
|
|
|
|
+ minimapBlocked = other.minimapBlocked;
|
|
|
|
+ minimapUnblocked = other.minimapUnblocked;
|
|
|
|
+ name = other.name;
|
|
|
|
+ musicFilename = other.musicFilename;
|
|
|
|
+ tilesFilename = other.tilesFilename;
|
|
|
|
+ terrainText = other.terrainText;
|
|
|
|
+ typeCode = other.typeCode;
|
|
|
|
+ terrainViewPatterns = other.terrainViewPatterns;
|
|
|
|
+ rockTerrain = other.rockTerrain;
|
|
|
|
+ river = other.river;
|
|
|
|
+
|
|
|
|
+ id = other.id;
|
|
|
|
+ moveCost = other.moveCost;
|
|
|
|
+ horseSoundId = other.horseSoundId;
|
|
|
|
+ passabilityType = other.passabilityType;
|
|
|
|
+ transitionRequired = other.transitionRequired;
|
|
|
|
+
|
|
return *this;
|
|
return *this;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+bool TerrainType::operator==(const TerrainType& other)
|
|
|
|
+{
|
|
|
|
+ return id == other.id;
|
|
|
|
+}
|
|
|
|
|
|
-bool operator==(const Terrain & l, const Terrain & r)
|
|
|
|
|
|
+bool TerrainType::operator!=(const TerrainType& other)
|
|
{
|
|
{
|
|
- return l.name == r.name;
|
|
|
|
|
|
+ return id != other.id;
|
|
}
|
|
}
|
|
|
|
|
|
-bool operator!=(const Terrain & l, const Terrain & r)
|
|
|
|
|
|
+bool TerrainType::operator<(const TerrainType& other)
|
|
{
|
|
{
|
|
- return l.name != r.name;
|
|
|
|
|
|
+ return id < other.id;
|
|
}
|
|
}
|
|
|
|
|
|
-bool operator<(const Terrain & l, const Terrain & r)
|
|
|
|
|
|
+bool TerrainType::isLand() const
|
|
{
|
|
{
|
|
- return l.name < r.name;
|
|
|
|
|
|
+ return !isWater();
|
|
}
|
|
}
|
|
-
|
|
|
|
-int Terrain::id() const
|
|
|
|
|
|
+
|
|
|
|
+bool TerrainType::isWater() const
|
|
{
|
|
{
|
|
- return Terrain::Manager::id(*this);
|
|
|
|
|
|
+ return passabilityType & PassabilityType::WATER;
|
|
}
|
|
}
|
|
-
|
|
|
|
-bool Terrain::isLand() const
|
|
|
|
|
|
+
|
|
|
|
+bool TerrainType::isPassable() const
|
|
{
|
|
{
|
|
- return !isWater();
|
|
|
|
|
|
+ return !(passabilityType & PassabilityType::ROCK);
|
|
}
|
|
}
|
|
-bool Terrain::isWater() const
|
|
|
|
|
|
+
|
|
|
|
+bool TerrainType::isSurface() const
|
|
{
|
|
{
|
|
- return Terrain::Manager::getInfo(*this).type == Terrain::Info::Type::Water;
|
|
|
|
|
|
+ return passabilityType & PassabilityType::SURFACE;
|
|
}
|
|
}
|
|
-bool Terrain::isPassable() const
|
|
|
|
|
|
+
|
|
|
|
+bool TerrainType::isUnderground() const
|
|
{
|
|
{
|
|
- return Terrain::Manager::getInfo(*this).type != Terrain::Info::Type::Rock;
|
|
|
|
|
|
+ return passabilityType & PassabilityType::SUBTERRANEAN;
|
|
}
|
|
}
|
|
-bool Terrain::isUnderground() const
|
|
|
|
|
|
+
|
|
|
|
+bool TerrainType::isTransitionRequired() const
|
|
{
|
|
{
|
|
- return Terrain::Manager::getInfo(*this).type == Terrain::Info::Type::Subterranean;
|
|
|
|
|
|
+ return transitionRequired;
|
|
}
|
|
}
|
|
-bool Terrain::isNative() const
|
|
|
|
|
|
+
|
|
|
|
+RiverType::RiverType(const std::string & fileName, const std::string & code, RiverId id):
|
|
|
|
+ fileName(fileName),
|
|
|
|
+ code(code),
|
|
|
|
+ id(id)
|
|
{
|
|
{
|
|
- return name.empty();
|
|
|
|
}
|
|
}
|
|
-bool Terrain::isTransitionRequired() const
|
|
|
|
|
|
+
|
|
|
|
+RiverType& RiverType::operator=(const RiverType& other)
|
|
{
|
|
{
|
|
- return Terrain::Manager::getInfo(*this).transitionRequired;
|
|
|
|
|
|
+ fileName = other.fileName;
|
|
|
|
+ code = other.code;
|
|
|
|
+ deltaName = other.deltaName;
|
|
|
|
+ id = other.id;
|
|
|
|
+
|
|
|
|
+ return *this;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+RoadType::RoadType(const std::string& fileName, const std::string& code, RoadId id):
|
|
|
|
+ fileName(fileName),
|
|
|
|
+ code(code),
|
|
|
|
+ id(id),
|
|
|
|
+ movementCost(GameConstants::BASE_MOVEMENT_COST)
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+RoadType& RoadType::operator=(const RoadType& other)
|
|
|
|
+{
|
|
|
|
+ fileName = other.fileName;
|
|
|
|
+ code = other.code;
|
|
|
|
+ id = other.id;
|
|
|
|
+ movementCost = other.movementCost;
|
|
|
|
+
|
|
|
|
+ return *this;
|
|
}
|
|
}
|
|
|
|
|
|
-VCMI_LIB_NAMESPACE_END
|
|
|
|
|
|
+VCMI_LIB_NAMESPACE_END
|