1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Reorganize namespaces

This commit is contained in:
Tomasz Zieliński 2023-07-07 16:32:17 +02:00
parent 8463fe200c
commit 3889193a48
4 changed files with 34 additions and 40 deletions

View File

@ -439,8 +439,8 @@ ZoneConnection::ZoneConnection():
zoneA(-1), zoneA(-1),
zoneB(-1), zoneB(-1),
guardStrength(0), guardStrength(0),
connectionType(EConnectionType::EConnectionType::GUARDED), connectionType(rmg::EConnectionType::GUARDED),
hasRoad(ERoadOption::ERoadOption::ROAD_TRUE) hasRoad(rmg::ERoadOption::ROAD_TRUE)
{ {
} }
@ -476,12 +476,12 @@ int ZoneConnection::getGuardStrength() const
return guardStrength; return guardStrength;
} }
EConnectionType::EConnectionType ZoneConnection::getConnectionType() const rmg::EConnectionType ZoneConnection::getConnectionType() const
{ {
return connectionType; return connectionType;
} }
ERoadOption::ERoadOption ZoneConnection::getRoadOption() const rmg::ERoadOption ZoneConnection::getRoadOption() const
{ {
return hasRoad; return hasRoad;
} }

View File

@ -67,30 +67,24 @@ public:
void serializeJson(JsonSerializeFormat & handler); void serializeJson(JsonSerializeFormat & handler);
}; };
namespace EConnectionType
{
enum class EConnectionType
{
GUARDED = 0, //default
FICTIVE,
REPULSIVE,
WIDE
};
}
namespace ERoadOption
{
enum class ERoadOption
{
ROAD_TRUE,
ROAD_FALSE,
ROAD_RANDOM
};
}
namespace rmg namespace rmg
{ {
enum class EConnectionType
{
GUARDED = 0, //default
FICTIVE,
REPULSIVE,
WIDE
};
enum class ERoadOption
{
ROAD_TRUE,
ROAD_FALSE,
ROAD_RANDOM
};
class DLL_LINKAGE ZoneConnection class DLL_LINKAGE ZoneConnection
{ {
public: public:
@ -101,8 +95,8 @@ public:
TRmgTemplateZoneId getZoneB() const; TRmgTemplateZoneId getZoneB() const;
TRmgTemplateZoneId getOtherZoneId(TRmgTemplateZoneId id) const; TRmgTemplateZoneId getOtherZoneId(TRmgTemplateZoneId id) const;
int getGuardStrength() const; int getGuardStrength() const;
EConnectionType::EConnectionType getConnectionType() const; rmg::EConnectionType getConnectionType() const;
ERoadOption::ERoadOption getRoadOption() const; rmg::ERoadOption getRoadOption() const;
void serializeJson(JsonSerializeFormat & handler); void serializeJson(JsonSerializeFormat & handler);
@ -111,8 +105,8 @@ private:
TRmgTemplateZoneId zoneA; TRmgTemplateZoneId zoneA;
TRmgTemplateZoneId zoneB; TRmgTemplateZoneId zoneB;
int guardStrength; int guardStrength;
EConnectionType::EConnectionType connectionType; rmg::EConnectionType connectionType;
ERoadOption::ERoadOption hasRoad; rmg::ERoadOption hasRoad;
}; };
class DLL_LINKAGE ZoneOptions class DLL_LINKAGE ZoneOptions

View File

@ -75,7 +75,7 @@ void CZonePlacer::findPathsBetweenZones()
for (auto & connection : connectedZoneIds) for (auto & connection : connectedZoneIds)
{ {
if (connection.getConnectionType() == EConnectionType::EConnectionType::REPULSIVE) if (connection.getConnectionType() == rmg::EConnectionType::REPULSIVE)
{ {
//Do not consider virtual connections for graph distance //Do not consider virtual connections for graph distance
continue; continue;
@ -536,7 +536,7 @@ void CZonePlacer::attractConnectedZones(TZoneMap & zones, TForceVector & forces,
for (const auto & connection : zone.second->getConnections()) for (const auto & connection : zone.second->getConnections())
{ {
if (connection.getConnectionType() == EConnectionType::EConnectionType::REPULSIVE) if (connection.getConnectionType() == rmg::EConnectionType::REPULSIVE)
{ {
continue; continue;
} }
@ -625,7 +625,7 @@ void CZonePlacer::separateOverlappingZones(TZoneMap &zones, TForceVector &forces
//TODO: Consider z plane? //TODO: Consider z plane?
for (auto& connection : zone.second->getConnections()) for (auto& connection : zone.second->getConnections())
{ {
if (connection.getConnectionType() == EConnectionType::EConnectionType::REPULSIVE) if (connection.getConnectionType() == rmg::EConnectionType::REPULSIVE)
{ {
auto & otherZone = zones[connection.getOtherZoneId(zone.second->getId())]; auto & otherZone = zones[connection.getOtherZoneId(zone.second->getId())];
float3 otherZoneCenter = otherZone->getCenter(); float3 otherZoneCenter = otherZone->getCenter();
@ -693,7 +693,7 @@ void CZonePlacer::moveOneZone(TZoneMap& zones, TForceVector& totalForces, TDista
for (const auto& connection : firstZone->getConnections()) for (const auto& connection : firstZone->getConnections())
{ {
//FIXME: Should we also exclude fictive connections? //FIXME: Should we also exclude fictive connections?
if (connection.getConnectionType() != EConnectionType::EConnectionType::REPULSIVE) if (connection.getConnectionType() != rmg::EConnectionType::REPULSIVE)
{ {
connectedZones.insert(connection.getOtherZoneId(firstZone->getId())); connectedZones.insert(connection.getOtherZoneId(firstZone->getId()));
} }
@ -740,7 +740,7 @@ void CZonePlacer::moveOneZone(TZoneMap& zones, TForceVector& totalForces, TDista
float maxDistance = 0; float maxDistance = 0;
for (auto con : misplacedZone->getConnections()) for (auto con : misplacedZone->getConnections())
{ {
if (con.getConnectionType() == EConnectionType::EConnectionType::REPULSIVE) if (con.getConnectionType() == rmg::EConnectionType::REPULSIVE)
{ {
continue; continue;
} }

View File

@ -110,7 +110,7 @@ void ConnectionsPlacer::selfSideDirectConnection(const rmg::ZoneConnection & con
if (directConnectionIterator != dNeighbourZones.end()) if (directConnectionIterator != dNeighbourZones.end())
{ {
if (connection.getConnectionType() == EConnectionType::EConnectionType::WIDE) if (connection.getConnectionType() == rmg::EConnectionType::WIDE)
{ {
for (auto borderPos : directConnectionIterator->second) for (auto borderPos : directConnectionIterator->second)
{ {
@ -159,8 +159,8 @@ void ConnectionsPlacer::selfSideDirectConnection(const rmg::ZoneConnection & con
} }
} }
if (connection.getConnectionType() == EConnectionType::EConnectionType::FICTIVE || if (connection.getConnectionType() == rmg::EConnectionType::FICTIVE ||
connection.getConnectionType() == EConnectionType::EConnectionType::REPULSIVE) connection.getConnectionType() == rmg::EConnectionType::REPULSIVE)
{ {
//Fictive or repulsive connections are not real, take no action //Fictive or repulsive connections are not real, take no action
dCompleted.push_back(connection); dCompleted.push_back(connection);
@ -396,8 +396,8 @@ void ConnectionsPlacer::collectNeighbourZones()
bool ConnectionsPlacer::shouldGenerateRoad(const rmg::ZoneConnection& connection) const bool ConnectionsPlacer::shouldGenerateRoad(const rmg::ZoneConnection& connection) const
{ {
return connection.getRoadOption() == ERoadOption::ERoadOption::ROAD_TRUE || return connection.getRoadOption() == rmg::ERoadOption::ROAD_TRUE ||
(connection.getRoadOption() == ERoadOption::ERoadOption::ROAD_RANDOM && zone.getRand().nextDouble() >= 0.5f); (connection.getRoadOption() == rmg::ERoadOption::ROAD_RANDOM && zone.getRand().nextDouble() >= 0.5f);
} }
void ConnectionsPlacer::createBorder() void ConnectionsPlacer::createBorder()
@ -415,7 +415,7 @@ void ConnectionsPlacer::createBorder()
{ {
auto otherZone = connection.getOtherZoneId(zone.getId()); auto otherZone = connection.getOtherZoneId(zone.getId());
if (connection.getConnectionType() == EConnectionType::EConnectionType::WIDE) if (connection.getConnectionType() == rmg::EConnectionType::WIDE)
{ {
auto sharedBorder = borderArea.getSubarea([this, otherZone, &borderOutsideArea](const int3 & t) auto sharedBorder = borderArea.getSubarea([this, otherZone, &borderOutsideArea](const int3 & t)
{ {