Move biome definition to separate files
parent
00af5d4d6e
commit
cee76f1ace
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Version="9.00"
|
||||
Name="MCServer"
|
||||
ProjectGUID="{32012054-0C96-4C43-AB27-174FF8E72D66}"
|
||||
RootNamespace="MCServer"
|
||||
|
@ -442,6 +442,10 @@
|
|||
RelativePath="..\src\Authenticator.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\BiomeDef.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\BlockArea.cpp"
|
||||
>
|
||||
|
|
|
@ -14,6 +14,7 @@ typedef unsigned short UInt16;
|
|||
|
||||
|
||||
$cfile "../ChunkDef.h"
|
||||
$cfile "../BiomeDef.h"
|
||||
|
||||
$cfile "../../lib/inifile/iniFile.h"
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
|
||||
// BiomeDef.h
|
||||
|
||||
// Defines relevant information and methods related to biomes
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// tolua_begin
|
||||
/** Biome IDs
|
||||
The first batch corresponds to the clientside biomes, used by MineCraft.
|
||||
BiomeIDs over 255 are used by MCServer internally and are translated to MC biomes before sending them to client
|
||||
*/
|
||||
enum EMCSBiome
|
||||
{
|
||||
biOcean = 0,
|
||||
biPlains = 1,
|
||||
biDesert = 2,
|
||||
biExtremeHills = 3,
|
||||
biForest = 4,
|
||||
biTaiga = 5,
|
||||
biSwampland = 6,
|
||||
biRiver = 7,
|
||||
biHell = 8, // same as Nether
|
||||
biNether = 8,
|
||||
biSky = 9, // same as biEnd
|
||||
biEnd = 9,
|
||||
biFrozenOcean = 10,
|
||||
biFrozenRiver = 11,
|
||||
biIcePlains = 12,
|
||||
biTundra = 12, // same as Ice Plains
|
||||
biIceMountains = 13,
|
||||
biMushroomIsland = 14,
|
||||
biMushroomShore = 15,
|
||||
biBeach = 16,
|
||||
biDesertHills = 17,
|
||||
biForestHills = 18,
|
||||
biTaigaHills = 19,
|
||||
biExtremeHillsEdge = 20,
|
||||
biJungle = 21,
|
||||
biJungleHills = 22,
|
||||
|
||||
// Release 1.7 biomes:
|
||||
biJungleEdge = 23,
|
||||
biDeepOcean = 24,
|
||||
biStoneBeach = 25,
|
||||
biColdBeach = 26,
|
||||
biBirchForest = 27,
|
||||
biBirchForestHills = 28,
|
||||
biRoofedForest = 29,
|
||||
biColdTaiga = 30,
|
||||
biColdTaigaHills = 31,
|
||||
biMegaTaiga = 32,
|
||||
biMegaTaigaHills = 33,
|
||||
biExtremeHillsPlus = 34,
|
||||
biSavanna = 35,
|
||||
biSavannaPlateau = 36,
|
||||
biMesa = 37,
|
||||
biMesaPlateauF = 38,
|
||||
biMesaPlateau = 39,
|
||||
|
||||
// Automatically capture the maximum consecutive biome value into biMaxBiome:
|
||||
biNumBiomes, // True number of biomes, since they are zero-based
|
||||
biMaxBiome = biNumBiomes - 1, // The maximum biome value
|
||||
|
||||
// Add this number to the biomes to get the variant
|
||||
biVariant = 128,
|
||||
|
||||
// Release 1.7 biome variants:
|
||||
biSunflowerPlains = 129,
|
||||
biDesertM = 130,
|
||||
biExtremeHillsM = 131,
|
||||
biFlowerForest = 132,
|
||||
biTaigaM = 133,
|
||||
biSwamplandM = 134,
|
||||
biIcePlainsSpikes = 140,
|
||||
biJungleM = 149,
|
||||
biJungleEdgeM = 151,
|
||||
biBirchForestM = 155,
|
||||
biBirchForestHillsM = 156,
|
||||
biRoofedForestM = 157,
|
||||
biColdTaigaM = 158,
|
||||
biMegaSpruceTaiga = 160,
|
||||
biMegaSpruceTaigaHills = 161,
|
||||
biExtremeHillsPlusM = 162,
|
||||
biSavannaM = 163,
|
||||
biSavannaPlateauM = 164,
|
||||
biMesaBryce = 165,
|
||||
biMesaPlateauFM = 166,
|
||||
biMesaPlateauM = 167,
|
||||
} ;
|
||||
|
||||
/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns -1 on failure.
|
||||
extern EMCSBiome StringToBiome(const AString & a_BiomeString);
|
||||
|
||||
/// Returns true if the biome has no downfall - deserts and savannas
|
||||
extern bool IsBiomeNoDownfall(EMCSBiome a_Biome);
|
||||
|
||||
|
||||
// tolua_end
|
100
src/BlockID.cpp
100
src/BlockID.cpp
|
@ -267,106 +267,6 @@ AString ItemToFullString(const cItem & a_Item)
|
|||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int StringToMobType(const AString & a_MobString)
|
||||
{
|
||||
static struct {
|
||||
|
|
|
@ -876,9 +876,6 @@ extern AString ItemTypeToString(short a_ItemType);
|
|||
/// Translates a full item into a fully-specified string (including meta and count). If the ItemType is not recognized, the ItemType number is output into the string.
|
||||
extern AString ItemToFullString(const cItem & a_Item);
|
||||
|
||||
/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns -1 on failure.
|
||||
extern EMCSBiome StringToBiome(const AString & a_BiomeString);
|
||||
|
||||
/// Translates a mob string ("ocelot") to mobtype (E_ENTITY_TYPE_OCELOT)
|
||||
extern int StringToMobType(const AString & a_MobString);
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ class cBlockEntity;
|
|||
typedef std::list<cEntity *> cEntityList;
|
||||
typedef std::list<cBlockEntity *> cBlockEntityList;
|
||||
|
||||
enum EMCSBiome;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -57,97 +59,6 @@ typedef unsigned char HEIGHTTYPE;
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
// tolua_begin
|
||||
/** Biome IDs
|
||||
The first batch corresponds to the clientside biomes, used by MineCraft.
|
||||
BiomeIDs over 255 are used by MCServer internally and are translated to MC biomes before sending them to client
|
||||
*/
|
||||
enum EMCSBiome
|
||||
{
|
||||
biOcean = 0,
|
||||
biPlains = 1,
|
||||
biDesert = 2,
|
||||
biExtremeHills = 3,
|
||||
biForest = 4,
|
||||
biTaiga = 5,
|
||||
biSwampland = 6,
|
||||
biRiver = 7,
|
||||
biHell = 8, // same as Nether
|
||||
biNether = 8,
|
||||
biSky = 9, // same as biEnd
|
||||
biEnd = 9,
|
||||
biFrozenOcean = 10,
|
||||
biFrozenRiver = 11,
|
||||
biIcePlains = 12,
|
||||
biTundra = 12, // same as Ice Plains
|
||||
biIceMountains = 13,
|
||||
biMushroomIsland = 14,
|
||||
biMushroomShore = 15,
|
||||
biBeach = 16,
|
||||
biDesertHills = 17,
|
||||
biForestHills = 18,
|
||||
biTaigaHills = 19,
|
||||
biExtremeHillsEdge = 20,
|
||||
biJungle = 21,
|
||||
biJungleHills = 22,
|
||||
|
||||
// Release 1.7 biomes:
|
||||
biJungleEdge = 23,
|
||||
biDeepOcean = 24,
|
||||
biStoneBeach = 25,
|
||||
biColdBeach = 26,
|
||||
biBirchForest = 27,
|
||||
biBirchForestHills = 28,
|
||||
biRoofedForest = 29,
|
||||
biColdTaiga = 30,
|
||||
biColdTaigaHills = 31,
|
||||
biMegaTaiga = 32,
|
||||
biMegaTaigaHills = 33,
|
||||
biExtremeHillsPlus = 34,
|
||||
biSavanna = 35,
|
||||
biSavannaPlateau = 36,
|
||||
biMesa = 37,
|
||||
biMesaPlateauF = 38,
|
||||
biMesaPlateau = 39,
|
||||
|
||||
// Automatically capture the maximum consecutive biome value into biMaxBiome:
|
||||
biNumBiomes, // True number of biomes, since they are zero-based
|
||||
biMaxBiome = biNumBiomes - 1, // The maximum biome value
|
||||
|
||||
// Add this number to the biomes to get the variant
|
||||
biVariant = 128,
|
||||
|
||||
// Release 1.7 biome variants:
|
||||
biSunflowerPlains = 129,
|
||||
biDesertM = 130,
|
||||
biExtremeHillsM = 131,
|
||||
biFlowerForest = 132,
|
||||
biTaigaM = 133,
|
||||
biSwamplandM = 134,
|
||||
biIcePlainsSpikes = 140,
|
||||
biJungleM = 149,
|
||||
biJungleEdgeM = 151,
|
||||
biBirchForestM = 155,
|
||||
biBirchForestHillsM = 156,
|
||||
biRoofedForestM = 157,
|
||||
biColdTaigaM = 158,
|
||||
biMegaSpruceTaiga = 160,
|
||||
biMegaSpruceTaigaHills = 161,
|
||||
biExtremeHillsPlusM = 162,
|
||||
biSavannaM = 163,
|
||||
biSavannaPlateauM = 164,
|
||||
biMesaBryce = 165,
|
||||
biMesaPlateauFM = 166,
|
||||
biMesaPlateauM = 167,
|
||||
} ;
|
||||
|
||||
// tolua_end
|
||||
|
||||
|
||||
|
||||
|
||||
/// Constants used throughout the code, useful typedefs and utility functions
|
||||
class cChunkDef
|
||||
{
|
||||
|
|
|
@ -563,34 +563,6 @@ namespace ItemCategory
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// Returns true if the biome has no downfall - deserts and savannas
|
||||
inline 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tolua_end
|
||||
|
||||
|
||||
|
|
|
@ -233,6 +233,7 @@ public:
|
|||
|
||||
// Common headers (part 2, with macros):
|
||||
#include "ChunkDef.h"
|
||||
#include "BiomeDef.h"
|
||||
#include "BlockID.h"
|
||||
#include "Entities/Effects.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue