From cee76f1ace49fea1ed3a3ebd6476cca9b799c5b2 Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Thu, 9 Jan 2014 15:21:46 -0600 Subject: Move biome definition to separate files --- src/BiomeDef.cpp | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 src/BiomeDef.cpp (limited to 'src/BiomeDef.cpp') diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp new file mode 100644 index 000000000..06b48e9d0 --- /dev/null +++ b/src/BiomeDef.cpp @@ -0,0 +1,130 @@ + +// BiomeDef.cpp + +// Implements biome helper functions + + + + +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"}, + {biNether, "Hell"}, + {biNether, "Nether"}, + {biEnd, "Sky"}, + {biEnd, "End"}, + {biFrozenOcean, "FrozenOcean"}, + {biFrozenRiver, "FrozenRiver"}, + {biIcePlains, "IcePlains"}, + {biIcePlains, "Tundra"}, + {biIceMountains, "IceMountains"}, + {biMushroomIsland, "MushroomIsland"}, + {biMushroomShore, "MushroomShore"}, + {biBeach, "Beach"}, + {biDesertHills, "DesertHills"}, + {biForestHills, "ForestHills"}, + {biTaigaHills, "TaigaHills"}, + {biExtremeHillsEdge, "ExtremeHillsEdge"}, + {biJungle, "Jungle"}, + {biJungleHills, "JungleHills"}, + + // Release 1.7 biomes: + {biJungleEdge, "JungleEdge"}, + {biDeepOcean, "DeepOcean"}, + {biStoneBeach, "StoneBeach"}, + {biColdBeach, "ColdBeach"}, + {biBirchForest, "BirchForest"}, + {biBirchForestHills, "BirchForestHills"}, + {biRoofedForest, "RoofedForest"}, + {biColdTaiga, "ColdTaiga"}, + {biColdTaigaHills, "ColdTaigaHills"}, + {biMegaTaiga, "MegaTaiga"}, + {biMegaTaigaHills, "MegaTaigaHills"}, + {biExtremeHillsPlus, "ExtremeHillsPlus"}, + {biSavanna, "Savanna"}, + {biSavannaPlateau, "SavannaPlateau"}, + {biMesa, "Mesa"}, + {biMesaPlateauF, "MesaPlateauF"}, + {biMesaPlateau, "MesaPlateau"}, + + // Release 1.7 variants: + {biSunflowerPlains, "SunflowerPlains"}, + {biDesertM, "DesertM"}, + {biExtremeHillsM, "ExtremeHillsM"}, + {biFlowerForest, "FlowerForest"}, + {biTaigaM, "TaigaM"}, + {biSwamplandM, "SwamplandM"}, + {biIcePlainsSpikes, "IcePlainsSpikes"}, + {biJungleM, "JungleM"}, + {biJungleEdgeM, "JungleEdgeM"}, + {biBirchForestM, "BirchForestM"}, + {biBirchForestHillsM, "BirchForestHillsM"}, + {biRoofedForestM, "RoofedForestM"}, + {biColdTaigaM, "ColdTaigaM"}, + {biMegaSpruceTaiga, "MegaSpruceTaiga"}, + {biMegaSpruceTaigaHills, "MegaSpruceTaigaHills"}, + {biExtremeHillsPlusM, "ExtremeHillsPlusM"}, + {biSavannaM, "SavannaM"}, + {biSavannaPlateauM, "SavannaPlateauM"}, + {biMesaBryce, "MesaBryce"}, + {biMesaPlateauFM, "MesaPlateauFM"}, + {biMesaPlateauM, "MesaPlateauM"}, + } ; + + for (size_t 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; +} + + + + + +bool IsBiomeNoDownfall(EMCSBiome a_Biome) +{ + switch (a_Biome) + { + case biDesert: + case biDesertHills: + case biDesertM: + case biSavanna: + case biSavannaM: + case biSavannaPlateau: + case biSavannaPlateauM: + case biNether: + case biEnd: + { + return true; + } + default: + { + return false; + } + } +} \ No newline at end of file -- cgit v1.2.3 From 1c2004dfbbd520b929357bce13cdeb06d41ce0ff Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Fri, 10 Jan 2014 09:23:53 -0600 Subject: Fixed missing externals Turns out you actually have to include the .cpp in the project file --- src/BiomeDef.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/BiomeDef.cpp') diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index 06b48e9d0..f7f48db9f 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -3,7 +3,8 @@ // Implements biome helper functions - +#include "BiomeDef.h" +#include "Globals.h" EMCSBiome StringToBiome(const AString & a_BiomeString) -- cgit v1.2.3 From ee74411024f1ba21b6a23eafadc9ab13ec6b3685 Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Fri, 10 Jan 2014 10:10:24 -0600 Subject: Added newlines at ends of files --- src/BiomeDef.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/BiomeDef.cpp') diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index f7f48db9f..f41f4bce4 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -128,4 +128,4 @@ bool IsBiomeNoDownfall(EMCSBiome a_Biome) return false; } } -} \ No newline at end of file +} -- cgit v1.2.3 From af89794d760c04f1caf5f437de0f1dfa2803307c Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Fri, 10 Jan 2014 15:50:52 -0600 Subject: Globals.h needs to be first include --- src/BiomeDef.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/BiomeDef.cpp') diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index f41f4bce4..89a1cdefb 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -3,8 +3,8 @@ // Implements biome helper functions -#include "BiomeDef.h" #include "Globals.h" +#include "BiomeDef.h" EMCSBiome StringToBiome(const AString & a_BiomeString) -- cgit v1.2.3