diff options
author | Mattes D <github@xoft.cz> | 2014-07-29 17:48:56 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-07-29 17:48:56 +0200 |
commit | 30e64ed4d82c9ef9ac0797a443d07c3f62649b54 (patch) | |
tree | 32ff101a034c0af7d8b4067744b367fcc08e5751 /src/BlockID.cpp | |
parent | Merge pull request #1254 from mc-server/SingleTopBlockFinisher (diff) | |
parent | Detrailed whitespace (diff) | |
download | cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.tar cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.tar.gz cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.tar.bz2 cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.tar.lz cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.tar.xz cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.tar.zst cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.zip |
Diffstat (limited to '')
-rw-r--r-- | src/BlockID.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/BlockID.cpp b/src/BlockID.cpp index af96b4414..d145a2e5b 100644 --- a/src/BlockID.cpp +++ b/src/BlockID.cpp @@ -346,6 +346,37 @@ eDimension StringToDimension(const AString & a_DimensionString) +AString DimensionToString(eDimension a_Dimension) +{ + // Decode using a built-in map: + static struct + { + eDimension m_Dimension; + const char * m_String; + } DimensionMap[] = + { + { dimOverworld, "Overworld" }, + { dimNether, "Nether" }, + { dimEnd, "End" }, + }; + + for (size_t i = 0; i < ARRAYCOUNT(DimensionMap); i++) + { + if (DimensionMap[i].m_Dimension == a_Dimension) + { + return DimensionMap[i].m_String; + } + } // for i - DimensionMap[] + + // Not found + LOGWARNING("Unknown dimension: \"%i\". Setting to Overworld", (int)a_Dimension); + return "Overworld"; +} + + + + + /// Translates damage type constant to a string representation (built-in). AString DamageTypeToString(eDamageType a_DamageType) { |