mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-25 21:38:59 +02:00
Cleanup
This commit is contained in:
parent
305e2bdf2f
commit
b0cff23c37
@ -151,9 +151,6 @@ void ObstacleSetHandler::addObstacleSet(const ObstacleSet &os)
|
||||
|
||||
TObstacleTypes ObstacleSetHandler::getObstacles( const ObstacleSetFilter &filter) const
|
||||
{
|
||||
// TODO: Handle multiple terrains for one obstacle set?
|
||||
auto terrainType = filter.getTerrain();
|
||||
|
||||
TObstacleTypes result;
|
||||
|
||||
for (const auto &allowedType : filter.getAllowedTypes())
|
||||
@ -173,24 +170,5 @@ TObstacleTypes ObstacleSetHandler::getObstacles( const ObstacleSetFilter &filter
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
ObstacleSet ObstacleSetHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
|
||||
{
|
||||
// TODO: Merge by name with existing obstacle sets?
|
||||
|
||||
|
||||
const JsonNode & biome = json["biome"];
|
||||
auto objectType = ObstacleSet::typeFromString(biome["objectType"].String());
|
||||
|
||||
for (const JsonNode & type : data["types"])
|
||||
{
|
||||
for (const JsonNode & obstacle : type["templates"])
|
||||
{
|
||||
// TODO: Reuse templates (pointers) parsed by CObjectClassesHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
|
@ -37,6 +37,11 @@ void ObstacleProxy::collectPossibleObstacles(TerrainId terrain)
|
||||
}
|
||||
}
|
||||
}
|
||||
sortObstacles();
|
||||
}
|
||||
|
||||
void ObstacleProxy::sortObstacles()
|
||||
{
|
||||
for(const auto & o : obstaclesBySize)
|
||||
{
|
||||
possibleObstacles.emplace_back(o);
|
||||
@ -51,12 +56,8 @@ bool ObstacleProxy::prepareBiome(TerrainId terrain, CRandomGenerator & rand)
|
||||
{
|
||||
// FIXME: All the mountains have same ID and mostly same subID, how to differentiate them?
|
||||
|
||||
bool isPrepared = false;
|
||||
|
||||
possibleObstacles.clear();
|
||||
|
||||
// TODO: Where to parse these sets?
|
||||
|
||||
std::vector<ObstacleSet> obstacleSets;
|
||||
|
||||
size_t selectedSets = 0;
|
||||
@ -176,8 +177,6 @@ bool ObstacleProxy::prepareBiome(TerrainId terrain, CRandomGenerator & rand)
|
||||
}
|
||||
|
||||
// Copy this set to our possible obstacles
|
||||
|
||||
// if (selectedSets >= MINIMUM_SETS)
|
||||
|
||||
if (selectedSets >= MINIMUM_SETS ||
|
||||
(terrain == TerrainId::WATER && selectedSets > 0))
|
||||
@ -194,24 +193,14 @@ bool ObstacleProxy::prepareBiome(TerrainId terrain, CRandomGenerator & rand)
|
||||
}
|
||||
}
|
||||
|
||||
for(const auto & o : obstaclesBySize)
|
||||
{
|
||||
possibleObstacles.emplace_back(o);
|
||||
}
|
||||
|
||||
boost::sort(possibleObstacles, [](const ObstaclePair &p1, const ObstaclePair &p2) -> bool
|
||||
{
|
||||
return p1.first > p2.first; //bigger obstacles first
|
||||
});
|
||||
sortObstacles();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false; // Proceed with old method
|
||||
return false; // Proceed with old method
|
||||
}
|
||||
|
||||
return isPrepared;
|
||||
}
|
||||
|
||||
void ObstacleProxy::addBlockedTile(const int3& tile)
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
|
||||
protected:
|
||||
int getWeightedObjects(const int3& tile, CRandomGenerator& rand, IGameCallback * cb, std::list<rmg::Object>& allObjects, std::vector<std::pair<rmg::Object*, int3>>& weightedObjects);
|
||||
void ObstacleProxy::sortObstacles();
|
||||
|
||||
rmg::Area blockedArea;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user