diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-06-10 21:43:27 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-06-10 21:43:27 +0200 |
commit | 35b79e5d710862f957bc494638a8d8906992665d (patch) | |
tree | 1c8945ad44eed86c5c572e99b277152b2d6e90e1 /src/BlockID.cpp | |
parent | Capitalising (diff) | |
download | cuberite-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 'src/BlockID.cpp')
-rw-r--r-- | src/BlockID.cpp | 35 |
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) { |