19 static bool ParseRange(
const AString & a_Params,
int & a_Min,
int & a_Max,
bool a_LogWarnings)
22 if (params.size() == 0)
30 CONDWARNING(a_LogWarnings,
"Cannot parse minimum height from string \"%s\"!", params[0].c_str());
33 if (params.size() == 1)
41 CONDWARNING(a_LogWarnings,
"Cannot parse maximum height from string \"%s\"!", params[1].c_str());
46 std::swap(a_Max, a_Min);
62 virtual bool CanBeAtHeight(
int a_BlockX,
int a_BlockZ,
int a_Height)
override
86 virtual bool CanBeAtHeight(
int a_BlockX,
int a_BlockZ,
int a_Height)
override
97 CONDWARNING(a_LogWarnings,
"Cannot parse the minimum height from string \"%s\"!", a_Params.c_str());
118 virtual bool CanBeAtHeight(
int a_BlockX,
int a_BlockZ,
int a_Height)
override
122 int compareHeight = a_Height - terrainHeight;
165 virtual bool CanBeAtHeight(
int a_BlockX,
int a_BlockZ,
int a_Height)
override
169 int compareHeight = a_Height - std::max(terrainHeight,
m_SeaLevel);
217 virtual bool CanBeAtHeight(
int a_BlockX,
int a_BlockZ,
int a_Height)
override
228 CONDWARNING(a_LogWarnings,
"Cannot parse the maximum height from string \"%s\"!", a_Params.c_str());
250 virtual bool CanBeAtHeight(
int a_BlockX,
int a_BlockZ,
int a_Height)
override
253 auto compareHeight = terrainHeight - a_Height;
296 virtual bool CanBeAtHeight(
int a_BlockX,
int a_BlockZ,
int a_Height)
override
299 auto compareHeight = std::max(terrainHeight,
m_SeaLevel) - a_Height;
346 auto idxPipe = a_LimitDesc.find(
'|');
347 if (idxPipe == AString::npos)
349 idxPipe = a_LimitDesc.length();
351 AString LimitClass = a_LimitDesc.substr(0, idxPipe);
355 if ((LimitClass ==
"") || (
NoCaseCompare(LimitClass,
"None") == 0))
357 Limit = std::make_shared<cVerticalLimitNone>();
361 Limit = std::make_shared<cVerticalLimitAbove>();
365 Limit = std::make_shared<cVerticalLimitAboveTerrain>();
367 else if (
NoCaseCompare(LimitClass,
"AboveTerrainAndOcean") == 0)
369 Limit = std::make_shared<cVerticalLimitAboveTerrainAndOcean>();
373 Limit = std::make_shared<cVerticalLimitBelow>();
377 Limit = std::make_shared<cVerticalLimitBelowTerrain>();
379 else if (
NoCaseCompare(LimitClass,
"BelowTerrainOrOcean") == 0)
381 Limit = std::make_shared<cVerticalLimitBelowTerrainOrOcean>();
390 if (idxPipe < a_LimitDesc.length())
392 Params = a_LimitDesc.substr(idxPipe + 1);
394 if (!Limit->InitializeFromString(Params, a_LogWarnings))
cPiece::cVerticalLimitPtr CreateVerticalLimitFromString(const AString &a_LimitDesc, bool a_LogWarnings)
Returns a new cPiece::cVerticalLimit descendant based on the specified description.
#define CONDWARNING(ShouldLog,...)
AStringVector StringSplitAndTrim(const AString &str, const AString &delim)
Split the string at any of the listed delimiters and trim each value.
int NoCaseCompare(const AString &s1, const AString &s2)
Case-insensitive string comparison.
bool StringToInteger(const AString &a_str, T &a_Num)
Parses any integer type.
Parses a string containing a range in which both values are optional ("<MinHeight>|<MaxHeight>") into...
static bool ParseRange(const AString &a_Params, int &a_Min, int &a_Max, bool a_LogWarnings)
The interface that a biome generator must implement A biome generator takes chunk coords on input and...
The interface that is used to query terrain height from the shape generator.
virtual HEIGHTTYPE GetHeightAt(int a_BlockX, int a_BlockZ)
Returns the height at the specified column.
std::shared_ptr< cVerticalLimit > cVerticalLimitPtr
Base class (interface) for the vertical limit of piece placement.
Limit that accepts any height.
virtual bool InitializeFromString(const AString &a_Params, bool a_LogWarnings) override
Initializes the limit's parameters from the string representation.
virtual bool CanBeAtHeight(int a_BlockX, int a_BlockZ, int a_Height) override
Called to inquire whether the specified piece can be placed at the specified height.
Limit that accepts heights above the specified minimum fixed height.
int m_MinHeight
The minimum accepted height.
virtual bool InitializeFromString(const AString &a_Params, bool a_LogWarnings) override
Initializes the limit's parameters from the string representation.
virtual bool CanBeAtHeight(int a_BlockX, int a_BlockZ, int a_Height) override
Called to inquire whether the specified piece can be placed at the specified height.
Limit that accepts heights that are a specified number of blocks above terrain.
virtual bool CanBeAtHeight(int a_BlockX, int a_BlockZ, int a_Height) override
Called to inquire whether the specified piece can be placed at the specified height.
int m_MinBlocksAbove
How many blocks above the terrain level do we accept on minimum.
cTerrainHeightGen * m_TerrainHeightGen
The underlying height generator.
virtual bool InitializeFromString(const AString &a_Params, bool a_LogWarnings) override
Initializes the limit's parameters from the string representation.
int m_MaxBlocksAbove
How many blocks above the terrain level do we accept on maximum.
virtual void AssignGens(int a_Seed, cBiomeGen &a_BiomeGen, cTerrainHeightGen &a_TerrainHeightGen, int a_SeaLevel) override
Called when the piece pool is assigned to a generator, so that the limits may bind to the underlying ...
Limit that accepts heights that are a specified number of blocks above terrain and sealevel,...
virtual bool InitializeFromString(const AString &a_Params, bool a_LogWarnings) override
Initializes the limit's parameters from the string representation.
int m_MinBlocksAbove
How many blocks above the terrain level / ocean do we accept on minimum.
virtual void AssignGens(int a_Seed, cBiomeGen &a_BiomeGen, cTerrainHeightGen &a_TerrainHeightGen, int a_SeaLevel) override
Called when the piece pool is assigned to a generator, so that the limits may bind to the underlying ...
int m_MaxBlocksAbove
How many blocks above the terrain level / ocean do we accept on maximum.
int m_SeaLevel
The sealevel for the current world.
cTerrainHeightGen * m_TerrainHeightGen
The underlying height generator.
virtual bool CanBeAtHeight(int a_BlockX, int a_BlockZ, int a_Height) override
Called to inquire whether the specified piece can be placed at the specified height.
Limit that accepts heights below the specified fixed height.
virtual bool CanBeAtHeight(int a_BlockX, int a_BlockZ, int a_Height) override
Called to inquire whether the specified piece can be placed at the specified height.
virtual bool InitializeFromString(const AString &a_Params, bool a_LogWarnings) override
Initializes the limit's parameters from the string representation.
int m_MaxHeight
The maximum accepted height.
Limit that accepts heights that are within a specified range below terrain.
cTerrainHeightGen * m_TerrainHeightGen
The underlying height generator.
virtual bool CanBeAtHeight(int a_BlockX, int a_BlockZ, int a_Height) override
Called to inquire whether the specified piece can be placed at the specified height.
int m_MinBlocksBelow
How many blocks below the terrain level do we accept on minimum.
virtual bool InitializeFromString(const AString &a_Params, bool a_LogWarnings) override
Initializes the limit's parameters from the string representation.
virtual void AssignGens(int a_Seed, cBiomeGen &a_BiomeGen, cTerrainHeightGen &a_TerrainHeightGen, int a_SeaLevel) override
Called when the piece pool is assigned to a generator, so that the limits may bind to the underlying ...
int m_MaxBlocksBelow
How many blocks below the terrain level do we accept on maximum.
Limit that accepts heights that are a specified number of blocks below terrain or sealevel,...
int m_MaxBlocksBelow
How many blocks below the terrain level do we accept on maximum.
cTerrainHeightGen * m_TerrainHeightGen
The underlying height generator.
int m_SeaLevel
The sealevel for the current world.
virtual bool InitializeFromString(const AString &a_Params, bool a_LogWarnings) override
Initializes the limit's parameters from the string representation.
virtual bool CanBeAtHeight(int a_BlockX, int a_BlockZ, int a_Height) override
Called to inquire whether the specified piece can be placed at the specified height.
virtual void AssignGens(int a_Seed, cBiomeGen &a_BiomeGen, cTerrainHeightGen &a_TerrainHeightGen, int a_SeaLevel) override
Called when the piece pool is assigned to a generator, so that the limits may bind to the underlying ...
int m_MinBlocksBelow
How many blocks below the terrain level do we accept on minimum.