2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
|
2012-09-23 16:14:04 -04:00
|
|
|
#include "ChunkGenerator.h"
|
2013-01-25 05:12:29 -05:00
|
|
|
#include "ChunkDesc.h"
|
|
|
|
#include "ComposableGenerator.h"
|
2013-04-27 09:38:40 -04:00
|
|
|
#include "Noise3DGenerator.h"
|
2018-08-28 20:51:25 -04:00
|
|
|
#include "../IniFile.h"
|
|
|
|
#include "../FastRandom.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-01 03:30:00 -04:00
|
|
|
void cChunkGenerator::Initialize(cIniFile & a_IniFile)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2014-09-03 17:02:00 -04:00
|
|
|
// Get the seed; create a new one and log it if not found in the INI file:
|
|
|
|
if (a_IniFile.HasValue("Seed", "Seed"))
|
|
|
|
{
|
|
|
|
m_Seed = a_IniFile.GetValueI("Seed", "Seed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-13 15:35:30 -04:00
|
|
|
m_Seed = GetRandomProvider().RandInt();
|
2014-09-03 17:02:00 -04:00
|
|
|
LOGINFO("Chosen a new random seed for world: %d", m_Seed);
|
|
|
|
a_IniFile.SetValueI("Seed", "Seed", m_Seed);
|
|
|
|
}
|
2019-09-01 15:47:03 -04:00
|
|
|
|
|
|
|
m_Dimension = StringToDimension(a_IniFile.GetValue("General", "Dimension", "Overworld"));
|
2019-09-01 03:30:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2019-09-01 03:30:00 -04:00
|
|
|
std::unique_ptr<cChunkGenerator> cChunkGenerator::CreateFromIniFile(cIniFile & a_IniFile)
|
|
|
|
{
|
2014-09-03 17:02:00 -04:00
|
|
|
// Get the generator engine based on the INI file settings:
|
2019-09-01 03:30:00 -04:00
|
|
|
std::unique_ptr<cChunkGenerator> res;
|
2013-01-25 05:12:29 -05:00
|
|
|
AString GeneratorName = a_IniFile.GetValueSet("Generator", "Generator", "Composable");
|
2013-04-27 09:38:40 -04:00
|
|
|
if (NoCaseCompare(GeneratorName, "Noise3D") == 0)
|
2013-01-24 07:15:36 -05:00
|
|
|
{
|
2019-09-01 03:30:00 -04:00
|
|
|
res.reset(new cNoise3DGenerator());
|
2013-01-24 07:15:36 -05:00
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
else
|
|
|
|
{
|
2013-01-25 05:12:29 -05:00
|
|
|
if (NoCaseCompare(GeneratorName, "composable") != 0)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-01-25 05:12:29 -05:00
|
|
|
LOGWARN("[Generator]::Generator value \"%s\" not recognized, using \"Composable\".", GeneratorName.c_str());
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
2019-09-01 03:30:00 -04:00
|
|
|
res.reset(new cComposableGenerator());
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
2019-09-01 03:30:00 -04:00
|
|
|
if (res == nullptr)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-01-25 05:12:29 -05:00
|
|
|
LOGERROR("Generator could not start, aborting the server");
|
2019-09-01 03:30:00 -04:00
|
|
|
return nullptr;
|
2012-09-01 17:37:41 -04:00
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2019-09-01 03:30:00 -04:00
|
|
|
res->Initialize(a_IniFile);
|
|
|
|
return res;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EMCSBiome cChunkGenerator::GetBiomeAt(int a_BlockX, int a_BlockZ)
|
2013-01-25 05:12:29 -05:00
|
|
|
{
|
|
|
|
cChunkDef::BiomeMap Biomes;
|
|
|
|
int Y = 0;
|
|
|
|
int ChunkX, ChunkZ;
|
2014-01-10 16:22:54 -05:00
|
|
|
cChunkDef::AbsoluteToRelative(a_BlockX, Y, a_BlockZ, ChunkX, ChunkZ);
|
2019-09-08 09:59:15 -04:00
|
|
|
GenerateBiomes({ChunkX, ChunkZ}, Biomes);
|
2013-01-25 05:12:29 -05:00
|
|
|
return cChunkDef::GetBiome(Biomes, a_BlockX, a_BlockZ);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|