diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-05-04 12:50:02 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-05-04 14:29:56 +0200 |
commit | eb3ca16921080b1496d2e71de95ce533929241e1 (patch) | |
tree | e1dc67df2493c8e36ea34f473f4184e0576c0440 /src/Generating/VerticalStrategy.cpp | |
parent | Fix incorrect formatter invocation (diff) | |
download | cuberite-eb3ca16921080b1496d2e71de95ce533929241e1.tar cuberite-eb3ca16921080b1496d2e71de95ce533929241e1.tar.gz cuberite-eb3ca16921080b1496d2e71de95ce533929241e1.tar.bz2 cuberite-eb3ca16921080b1496d2e71de95ce533929241e1.tar.lz cuberite-eb3ca16921080b1496d2e71de95ce533929241e1.tar.xz cuberite-eb3ca16921080b1496d2e71de95ce533929241e1.tar.zst cuberite-eb3ca16921080b1496d2e71de95ce533929241e1.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Generating/VerticalStrategy.cpp | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/src/Generating/VerticalStrategy.cpp b/src/Generating/VerticalStrategy.cpp index 6ca7cec9d..0651958f9 100644 --- a/src/Generating/VerticalStrategy.cpp +++ b/src/Generating/VerticalStrategy.cpp @@ -38,37 +38,40 @@ static const int SEED_OFFSET = 135; Returns true if successful, false on failure. If a_LogWarnings is true, outputs failure reasons to console. The range is returned in a_Min and a_Range, they are left unchanged if the range value is not present in the string. */ -static bool ParseRange(const AString & a_Params, int & a_Min, int & a_Range, bool a_LogWarnings) +namespace VerticalStrategy { - auto params = StringSplitAndTrim(a_Params, "|"); - if (params.size() == 0) + static bool ParseRange(const AString & a_Params, int & a_Min, int & a_Range, bool a_LogWarnings) { - // No params, generate directly on top: - return true; - } - if (!StringToInteger(params[0], a_Min)) - { - // Failed to parse the min rel height: - CONDWARNING(a_LogWarnings, "Cannot parse minimum height from string \"%s\"!", params[0].c_str()); - return false; - } - if (params.size() == 1) - { - // Only one param was given, there's no range + auto params = StringSplitAndTrim(a_Params, "|"); + if (params.size() == 0) + { + // No params, generate directly on top: + return true; + } + if (!StringToInteger(params[0], a_Min)) + { + // Failed to parse the min rel height: + CONDWARNING(a_LogWarnings, "Cannot parse minimum height from string \"%s\"!", params[0].c_str()); + return false; + } + if (params.size() == 1) + { + // Only one param was given, there's no range + return true; + } + int maxHeight = a_Min; + if (!StringToInteger(params[1], maxHeight)) + { + CONDWARNING(a_LogWarnings, "Cannot parse maximum height from string \"%s\"!", params[1].c_str()); + return false; + } + if (maxHeight < a_Min) + { + std::swap(maxHeight, a_Min); + } + a_Range = maxHeight - a_Min + 1; return true; } - int maxHeight = a_Min; - if (!StringToInteger(params[1], maxHeight)) - { - CONDWARNING(a_LogWarnings, "Cannot parse maximum height from string \"%s\"!", params[1].c_str()); - return false; - } - if (maxHeight < a_Min) - { - std::swap(maxHeight, a_Min); - } - a_Range = maxHeight - a_Min + 1; - return true; } @@ -202,7 +205,7 @@ public: // Params: "<MinRelativeHeight>|<MaxRelativeHeight>", all optional m_MinRelHeight = 0; m_RelHeightRange = 1; - return ParseRange(a_Params, m_MinRelHeight, m_RelHeightRange, a_LogWarnings); + return VerticalStrategy::ParseRange(a_Params, m_MinRelHeight, m_RelHeightRange, a_LogWarnings); } @@ -258,7 +261,7 @@ public: // Params: "<MinRelativeHeight>|<MaxRelativeHeight>", all optional m_MinRelHeight = 0; m_RelHeightRange = 1; - return ParseRange(a_Params, m_MinRelHeight, m_RelHeightRange, a_LogWarnings); + return VerticalStrategy::ParseRange(a_Params, m_MinRelHeight, m_RelHeightRange, a_LogWarnings); } |