summaryrefslogtreecommitdiffstats
path: root/src/BlockID.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-10 21:43:27 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-10 21:43:27 +0200
commit35b79e5d710862f957bc494638a8d8906992665d (patch)
tree1c8945ad44eed86c5c572e99b277152b2d6e90e1 /src/BlockID.cpp
parentCapitalising (diff)
downloadcuberite-35b79e5d710862f957bc494638a8d8906992665d.tar
cuberite-35b79e5d710862f957bc494638a8d8906992665d.tar.gz
cuberite-35b79e5d710862f957bc494638a8d8906992665d.tar.bz2
cuberite-35b79e5d710862f957bc494638a8d8906992665d.tar.lz
cuberite-35b79e5d710862f957bc494638a8d8906992665d.tar.xz
cuberite-35b79e5d710862f957bc494638a8d8906992665d.tar.zst
cuberite-35b79e5d710862f957bc494638a8d8906992665d.zip
Diffstat (limited to '')
-rw-r--r--src/BlockID.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/BlockID.cpp b/src/BlockID.cpp
index bfe826f40..641a6a225 100644
--- a/src/BlockID.cpp
+++ b/src/BlockID.cpp
@@ -345,6 +345,41 @@ 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" },
+ { dimOverworld, "Normal" },
+ { dimOverworld, "World" },
+ { dimNether, "Nether" },
+ { dimNether, "Hell" }, // Alternate name for Nether
+ { dimEnd, "End" },
+ { dimEnd, "Sky" }, // Old name for 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)
{