From ba2f0c6229870fd7c1d0b0f530dd1567d43e4e03 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 27 May 2012 10:51:04 +0000 Subject: Added the CheckerBoardBiomes parameter for setting biomes that CheckerBoard generates (#179). Added string-to-biome conversion (#183). Added OreNests to default Structures configuration. git-svn-id: http://mc-server.googlecode.com/svn/trunk@506 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/BlockID.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'source/BlockID.cpp') diff --git a/source/BlockID.cpp b/source/BlockID.cpp index 2e2484f21..32f9bb96e 100644 --- a/source/BlockID.cpp +++ b/source/BlockID.cpp @@ -63,6 +63,62 @@ int BlockStringToType(const AString & a_BlockTypeString) +EMCSBiome StringToBiome(const AString & a_BiomeString) +{ + // If it is a number, return it: + int res = atoi(a_BiomeString.c_str()); + if ((res != 0) || (a_BiomeString.compare("0") == 0)) + { + // It was a valid number + return (EMCSBiome)res; + } + + // Convert using the built-in map: + static struct { + EMCSBiome m_Biome; + const char * m_String; + } BiomeMap[] = + { + {biOcean, "Ocean"} , + {biPlains, "Plains"}, + {biDesert, "Desert"}, + {biExtremeHills, "ExtremeHills"}, + {biForest, "Forest"}, + {biTaiga, "Taiga"}, + {biSwampland, "Swampland"}, + {biRiver, "River"}, + {biHell, "Hell"}, + {biHell, "Nether"}, + {biSky, "Sky"}, + {biFrozenOcean, "FrozenOcean"}, + {biFrozenRiver, "FrozenRiver"}, + {biIcePlains, "IcePlains"}, + {biIceMountains, "IceMountains"}, + {biMushroomIsland, "MushroomIsland"}, + {biMushroomShore, "MushroomShore"}, + {biBeach, "Beach"}, + {biDesertHills, "DesertHills"}, + {biForestHills, "ForestHills"}, + {biTaigaHills, "TaigaHills"}, + {biExtremeHillsEdge, "ExtremeHillsEdge "}, + {biJungle, "Jungle"}, + {biJungleHills, "JungleHills"}, + } ; + + for (int i = 0; i < ARRAYCOUNT(BiomeMap); i++) + { + if (NoCaseCompare(BiomeMap[i].m_String, a_BiomeString) == 0) + { + return BiomeMap[i].m_Biome; + } + } // for i - BiomeMap[] + return (EMCSBiome)-1; +} + + + + + // 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