mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
A little refactoring
This commit is contained in:
parent
09931b6c9d
commit
f883395710
@ -19,12 +19,18 @@
|
|||||||
|
|
||||||
TerrainTypeHandler::TerrainTypeHandler()
|
TerrainTypeHandler::TerrainTypeHandler()
|
||||||
{
|
{
|
||||||
initRivers();
|
|
||||||
initRoads();
|
|
||||||
|
|
||||||
auto allConfigs = VLC->modh->getActiveMods();
|
auto allConfigs = VLC->modh->getActiveMods();
|
||||||
allConfigs.insert(allConfigs.begin(), "core");
|
allConfigs.insert(allConfigs.begin(), "core");
|
||||||
|
|
||||||
|
initRivers(allConfigs);
|
||||||
|
recreateRiverMaps();
|
||||||
|
initRoads(allConfigs);
|
||||||
|
recreateRoadMaps();
|
||||||
|
initTerrains(allConfigs); //maps will be populated inside
|
||||||
|
}
|
||||||
|
|
||||||
|
void TerrainTypeHandler::initTerrains(const std::vector<std::string> & allConfigs)
|
||||||
|
{
|
||||||
std::vector<std::function<void()>> resolveLater;
|
std::vector<std::function<void()>> resolveLater;
|
||||||
|
|
||||||
objects.resize(Terrain::ORIGINAL_TERRAIN_COUNT, nullptr); //make space for original terrains
|
objects.resize(Terrain::ORIGINAL_TERRAIN_COUNT, nullptr); //make space for original terrains
|
||||||
@ -194,11 +200,8 @@ TerrainTypeHandler::TerrainTypeHandler()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerrainTypeHandler::initRivers()
|
void TerrainTypeHandler::initRivers(const std::vector<std::string> & allConfigs)
|
||||||
{
|
{
|
||||||
auto allConfigs = VLC->modh->getActiveMods();
|
|
||||||
allConfigs.insert(allConfigs.begin(), "core");
|
|
||||||
|
|
||||||
riverTypes.resize(River::ORIGINAL_RIVER_COUNT, nullptr); //make space for original rivers
|
riverTypes.resize(River::ORIGINAL_RIVER_COUNT, nullptr); //make space for original rivers
|
||||||
riverTypes[River::NO_RIVER] = new RiverType(); //default
|
riverTypes[River::NO_RIVER] = new RiverType(); //default
|
||||||
|
|
||||||
@ -233,11 +236,8 @@ void TerrainTypeHandler::initRivers()
|
|||||||
recreateRiverMaps();
|
recreateRiverMaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerrainTypeHandler::initRoads()
|
void TerrainTypeHandler::initRoads(const std::vector<std::string> & allConfigs)
|
||||||
{
|
{
|
||||||
auto allConfigs = VLC->modh->getActiveMods();
|
|
||||||
allConfigs.insert(allConfigs.begin(), "core");
|
|
||||||
|
|
||||||
roadTypes.resize(Road::ORIGINAL_ROAD_COUNT, nullptr); //make space for original rivers
|
roadTypes.resize(Road::ORIGINAL_ROAD_COUNT, nullptr); //make space for original rivers
|
||||||
roadTypes[Road::NO_ROAD] = new RoadType(); //default
|
roadTypes[Road::NO_ROAD] = new RoadType(); //default
|
||||||
|
|
||||||
|
@ -133,8 +133,9 @@ class DLL_LINKAGE TerrainTypeHandler //TODO: public IHandlerBase ?
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
TerrainTypeHandler();
|
TerrainTypeHandler();
|
||||||
void initRivers();
|
void initTerrains(const std::vector<std::string> & allConfigs);
|
||||||
void initRoads();
|
void initRivers(const std::vector<std::string> & allConfigs);
|
||||||
|
void initRoads(const std::vector<std::string> & allConfigs);
|
||||||
|
|
||||||
const std::vector<TerrainType *> & terrains() const;
|
const std::vector<TerrainType *> & terrains() const;
|
||||||
const TerrainType * getInfoByName(const std::string & terrainName) const;
|
const TerrainType * getInfoByName(const std::string & terrainName) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user