From 9dd0486faf6f52eb40e47f003d4c02eefc28c8f9 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 22 Jun 2013 18:41:08 +0000 Subject: Added the End height and composition generators. Also made the dimension in world.ini specifiable by a string. Exported StringToDimension() and StringToBiome() to Lua API. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1621 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/BlockID.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'source/BlockID.cpp') diff --git a/source/BlockID.cpp b/source/BlockID.cpp index f9a76daa2..a3bb75cf4 100644 --- a/source/BlockID.cpp +++ b/source/BlockID.cpp @@ -290,6 +290,7 @@ EMCSBiome StringToBiome(const AString & a_BiomeString) {biHell, "Hell"}, {biHell, "Nether"}, {biSky, "Sky"}, + {biSky, "End"}, {biFrozenOcean, "FrozenOcean"}, {biFrozenRiver, "FrozenRiver"}, {biIcePlains, "IcePlains"}, @@ -320,6 +321,46 @@ EMCSBiome StringToBiome(const AString & a_BiomeString) +eDimension StringToDimension(const AString & a_DimensionString) +{ + int res = atoi(a_DimensionString.c_str()); + if ((res != 0) || (a_DimensionString == "0")) + { + // It was a valid number + return (eDimension)res; + } + + // Convert 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 End + { dimEnd, "End"}, + { dimEnd, "Sky"}, // Old name for End + } ; + for (int i = 0; i < ARRAYCOUNT(DimensionMap); i++) + { + if (NoCaseCompare(DimensionMap[i].m_String, a_DimensionString) == 0) + { + return DimensionMap[i].m_Dimension; + } + } // for i - DimensionMap[] + + // Not found + return (eDimension)-1000; +} + + + + + // This is actually just some code that needs to run at program startup, so it is wrapped into a global var's constructor: class cBlockPropertiesInitializer { -- cgit v1.2.3