1
0

Merge pull request #1569 from mc-server/GrownBiomes

Grown biomes
This commit is contained in:
Mattes D 2014-11-02 17:01:51 +01:00
commit 325e94709e
9 changed files with 3139 additions and 77 deletions

View File

@ -14,6 +14,8 @@ static const QString s_GeneratorNames[] =
QString("Checkerboard"),
QString("Constant"),
QString("DistortedVoronoi"),
QString("Grown"),
QString("GrownProt"),
QString("MultiStepMap"),
QString("TwoLevel"),
QString("Voronoi"),

View File

@ -32,7 +32,8 @@ const double MainWindow::m_ViewZooms[] =
MainWindow::MainWindow(QWidget * parent) :
QMainWindow(parent),
m_GeneratorSetup(nullptr),
m_LineSeparator(nullptr)
m_LineSeparator(nullptr),
m_CurrentZoomLevel(2)
{
initMinecraftPath();
@ -41,6 +42,7 @@ MainWindow::MainWindow(QWidget * parent) :
connect(m_BiomeView, SIGNAL(decreaseZoom()), this, SLOT(decreaseZoom()));
connect(m_BiomeView, SIGNAL(wheelUp()), this, SLOT(increaseZoom()));
connect(m_BiomeView, SIGNAL(wheelDown()), this, SLOT(decreaseZoom()));
m_BiomeView->setZoomLevel(m_ViewZooms[m_CurrentZoomLevel]);
m_StatusBar = new QStatusBar();
this->setStatusBar(m_StatusBar);
@ -286,15 +288,11 @@ void MainWindow::createActions()
{
m_actViewZoom[i] = new QAction(tr("&Zoom %1%").arg(std::floor(m_ViewZooms[i] * 100)), this);
m_actViewZoom[i]->setCheckable(true);
if ((int)(m_ViewZooms[i] * 16) == 16)
{
m_actViewZoom[i]->setChecked(true);
m_CurrentZoomLevel = i;
}
m_actViewZoom[i]->setData(QVariant(i));
zoomGroup->addAction(m_actViewZoom[i]);
connect(m_actViewZoom[i], SIGNAL(triggered()), this, SLOT(setViewZoom()));
}
m_actViewZoom[m_CurrentZoomLevel]->setChecked(true);
}

View File

@ -12,78 +12,86 @@ TARGET = QtBiomeVisualiser
TEMPLATE = app
SOURCES +=\
MainWindow.cpp \
BiomeView.cpp \
../../src/Generating/BioGen.cpp \
../../src/VoronoiMap.cpp \
../../src/Noise.cpp \
../../src/StringUtils.cpp \
../../src/LoggerListeners.cpp \
../../src/Logger.cpp \
../../src/IniFile.cpp \
../../src/OSSupport/File.cpp \
../../src/OSSupport/CriticalSection.cpp \
../../src/OSSupport/IsThread.cpp \
../../src/BiomeDef.cpp \
../../src/StringCompression.cpp \
../../src/WorldStorage/FastNBT.cpp \
../../lib/zlib/adler32.c \
../../lib/zlib/compress.c \
../../lib/zlib/crc32.c \
../../lib/zlib/deflate.c \
../../lib/zlib/gzclose.c \
../../lib/zlib/gzlib.c \
../../lib/zlib/gzread.c \
../../lib/zlib/gzwrite.c \
../../lib/zlib/infback.c \
../../lib/zlib/inffast.c \
../../lib/zlib/inflate.c \
../../lib/zlib/inftrees.c \
../../lib/zlib/trees.c \
../../lib/zlib/uncompr.c \
../../lib/zlib/zutil.c \
GeneratorSetup.cpp \
QtBiomeVisualiser.cpp \
QtChunk.cpp \
RegionCache.cpp \
Region.cpp \
ChunkSource.cpp \
RegionLoader.cpp
SOURCES += \
MainWindow.cpp \
BiomeView.cpp \
../../src/Generating/BioGen.cpp \
../../src/VoronoiMap.cpp \
../../src/Noise.cpp \
../../src/StringUtils.cpp \
../../src/LoggerListeners.cpp \
../../src/Logger.cpp \
../../src/IniFile.cpp \
../../src/OSSupport/File.cpp \
../../src/OSSupport/CriticalSection.cpp \
../../src/OSSupport/IsThread.cpp \
../../src/BiomeDef.cpp \
../../src/StringCompression.cpp \
../../src/WorldStorage/FastNBT.cpp \
../../lib/zlib/adler32.c \
../../lib/zlib/compress.c \
../../lib/zlib/crc32.c \
../../lib/zlib/deflate.c \
../../lib/zlib/gzclose.c \
../../lib/zlib/gzlib.c \
../../lib/zlib/gzread.c \
../../lib/zlib/gzwrite.c \
../../lib/zlib/infback.c \
../../lib/zlib/inffast.c \
../../lib/zlib/inflate.c \
../../lib/zlib/inftrees.c \
../../lib/zlib/trees.c \
../../lib/zlib/uncompr.c \
../../lib/zlib/zutil.c \
GeneratorSetup.cpp \
QtBiomeVisualiser.cpp \
QtChunk.cpp \
RegionCache.cpp \
Region.cpp \
ChunkSource.cpp \
RegionLoader.cpp
HEADERS += \
MainWindow.h \
QtChunk.h \
Globals.h \
BiomeView.h \
../../src/Generating/BioGen.h \
../../src/Generating/IntGen.h \
../../src/Generating/ProtIntGen.h \
../../src/VoronoiMap.h \
../../src/Noise.h \
../../src/StringUtils.h \
../../src/LoggerListeners.h \
../../src/Logger.h \
../../src/IniFile.h \
../../src/OSSupport/File.h \
../../src/OSSupport/CriticalSection.h \
../../src/OSSupport/IsThread.h \
../../src/BiomeDef.h \
../../src/StringCompression.h \
../../src/WorldStorage/FastNBT.h \
../../lib/zlib/crc32.h \
../../lib/zlib/deflate.h \
../../lib/zlib/gzguts.h \
../../lib/zlib/inffast.h \
../../lib/zlib/inffixed.h \
../../lib/zlib/inflate.h \
../../lib/zlib/inftrees.h \
../../lib/zlib/trees.h \
../../lib/zlib/zconf.h \
../../lib/zlib/zlib.h \
../../lib/zlib/zutil.h \
GeneratorSetup.h \
QtChunk.h \
RegionCache.h \
Region.h \
ChunkSource.h \
RegionLoader.h
HEADERS += MainWindow.h \
Globals.h \
BiomeView.h \
../../src/Generating/BioGen.h \
../../src/VoronoiMap.h \
../../src/Noise.h \
../../src/StringUtils.h \
../../src/LoggerListeners.h \
../../src/Logger.h \
../../src/IniFile.h \
../../src/OSSupport/File.h \
../../src/OSSupport/CriticalSection.h \
../../src/OSSupport/IsThread.h \
../../src/BiomeDef.h \
../../src/StringCompression.h \
../../src/WorldStorage/FastNBT.h \
../../lib/zlib/crc32.h \
../../lib/zlib/deflate.h \
../../lib/zlib/gzguts.h \
../../lib/zlib/inffast.h \
../../lib/zlib/inffixed.h \
../../lib/zlib/inflate.h \
../../lib/zlib/inftrees.h \
../../lib/zlib/trees.h \
../../lib/zlib/zconf.h \
../../lib/zlib/zlib.h \
../../lib/zlib/zutil.h \
GeneratorSetup.h \
QtChunk.h \
RegionCache.h \
Region.h \
ChunkSource.h \
RegionLoader.h
INCLUDEPATH += $$_PRO_FILE_PWD_ \
$$_PRO_FILE_PWD_/../../lib \

View File

@ -160,3 +160,65 @@ bool IsBiomeNoDownfall(EMCSBiome a_Biome)
}
}
}
bool IsBiomeVeryCold(EMCSBiome a_Biome)
{
switch (a_Biome)
{
case biFrozenOcean:
case biFrozenRiver:
case biIcePlains:
case biIceMountains:
case biColdBeach:
case biColdTaiga:
case biColdTaigaHills:
case biIcePlainsSpikes:
case biColdTaigaM:
{
return true;
}
default:
{
return false;
}
}
}
bool IsBiomeCold(EMCSBiome a_Biome)
{
switch (a_Biome)
{
case biExtremeHills:
case biTaiga:
case biTaigaHills:
case biExtremeHillsEdge:
case biStoneBeach:
case biMegaTaiga:
case biMegaTaigaHills:
case biExtremeHillsPlus:
case biExtremeHillsM:
case biTaigaM:
case biColdTaigaM:
case biMegaSpruceTaiga:
case biMegaSpruceTaigaHills:
case biExtremeHillsPlusM:
{
return true;
}
default:
{
return false;
}
}
}

View File

@ -113,5 +113,20 @@ extern AString BiomeToString(int a_Biome);
/** Returns true if the biome has no downfall - deserts and savannas */
extern bool IsBiomeNoDownfall(EMCSBiome a_Biome);
/** Returns true if the biome is an ocean biome. */
inline bool IsBiomeOcean(int a_Biome)
{
return ((a_Biome == biOcean) || (a_Biome == biDeepOcean));
}
/** Returns true if the biome is very cold
(has snow on ground everywhere, turns top water to ice, has snowfall instead of rain everywhere).
Doesn't report mildly cold biomes (where it snows above certain elevation), use IsBiomeCold() for those. */
extern bool IsBiomeVeryCold(EMCSBiome a_Biome);
/** Returns true if the biome is cold
(has snow and snowfall at higher elevations but not at regular heights).
Doesn't report Very Cold biomes, use IsBiomeVeryCold() for those. */
extern bool IsBiomeCold(EMCSBiome a_Biome);
// tolua_end

View File

@ -5,6 +5,8 @@
#include "Globals.h"
#include "BioGen.h"
#include "IntGen.h"
#include "ProtIntGen.h"
#include "../IniFile.h"
#include "../LinearUpscale.h"
@ -916,6 +918,214 @@ void cBioGenTwoLevel::InitializeBiomeGen(cIniFile & a_IniFile)
////////////////////////////////////////////////////////////////////////////////
// cBioGenGrown:
class cBioGenGrown:
public cBiomeGen
{
public:
cBioGenGrown(int a_Seed)
{
auto FinalRivers =
std::make_shared<cIntGenSmooth<8>> (a_Seed + 1,
std::make_shared<cIntGenZoom <10>> (a_Seed + 2,
std::make_shared<cIntGenRiver <7>> (a_Seed + 3,
std::make_shared<cIntGenZoom <9>> (a_Seed + 4,
std::make_shared<cIntGenSmooth<6>> (a_Seed + 5,
std::make_shared<cIntGenZoom <8>> (a_Seed + 8,
std::make_shared<cIntGenSmooth<6>> (a_Seed + 5,
std::make_shared<cIntGenZoom <8>> (a_Seed + 9,
std::make_shared<cIntGenSmooth<6>> (a_Seed + 5,
std::make_shared<cIntGenZoom <8>> (a_Seed + 10,
std::make_shared<cIntGenSmooth<6>> (a_Seed + 5,
std::make_shared<cIntGenSmooth<8>> (a_Seed + 6,
std::make_shared<cIntGenZoom <10>> (a_Seed + 11,
std::make_shared<cIntGenChoice<2, 7>>(a_Seed + 12
))))))))))))));
auto alteration =
std::make_shared<cIntGenZoom <8>>(a_Seed,
std::make_shared<cIntGenLandOcean<6>>(a_Seed, 20
));
auto alteration2 =
std::make_shared<cIntGenZoom <8>>(a_Seed + 1,
std::make_shared<cIntGenZoom <6>>(a_Seed + 2,
std::make_shared<cIntGenZoom <5>>(a_Seed + 1,
std::make_shared<cIntGenZoom <4>>(a_Seed + 2,
std::make_shared<cIntGenLandOcean<4>>(a_Seed + 1, 10
)))));
auto FinalBiomes =
std::make_shared<cIntGenSmooth <8>> (a_Seed + 1,
std::make_shared<cIntGenZoom <10>>(a_Seed + 15,
std::make_shared<cIntGenSmooth <7>> (a_Seed + 1,
std::make_shared<cIntGenZoom <9>> (a_Seed + 16,
std::make_shared<cIntGenBeaches <6>> (
std::make_shared<cIntGenZoom <8>> (a_Seed + 1,
std::make_shared<cIntGenAddIslands <6>> (a_Seed + 2004, 10,
std::make_shared<cIntGenAddToOcean <6>> (a_Seed + 10, 500, biDeepOcean,
std::make_shared<cIntGenReplaceRandomly<8>> (a_Seed + 1, biPlains, biSunflowerPlains, 20,
std::make_shared<cIntGenMBiomes <8>> (a_Seed + 5, alteration2,
std::make_shared<cIntGenAlternateBiomes<8>> (a_Seed + 1, alteration,
std::make_shared<cIntGenBiomeEdges <8>> (a_Seed + 3,
std::make_shared<cIntGenZoom <10>>(a_Seed + 2,
std::make_shared<cIntGenZoom <7>> (a_Seed + 4,
std::make_shared<cIntGenReplaceRandomly<5>> (a_Seed + 99, biIcePlains, biIcePlainsSpikes, 50,
std::make_shared<cIntGenZoom <5>> (a_Seed + 8,
std::make_shared<cIntGenAddToOcean <4>> (a_Seed + 10, 300, biDeepOcean,
std::make_shared<cIntGenAddToOcean <6>> (a_Seed + 9, 8, biMushroomIsland,
std::make_shared<cIntGenBiomes <8>> (a_Seed + 3000,
std::make_shared<cIntGenAddIslands <8>> (a_Seed + 2000, 200,
std::make_shared<cIntGenZoom <8>> (a_Seed + 5,
std::make_shared<cIntGenRareBiomeGroups<6>> (a_Seed + 5, 50,
std::make_shared<cIntGenBiomeGroupEdges<6>> (
std::make_shared<cIntGenAddIslands <8>> (a_Seed + 2000, 200,
std::make_shared<cIntGenZoom <8>> (a_Seed + 7,
std::make_shared<cIntGenSetRandomly <6>> (a_Seed + 8, 50, bgOcean,
std::make_shared<cIntGenReplaceRandomly<6>> (a_Seed + 101, bgIce, bgTemperate, 150,
std::make_shared<cIntGenAddIslands <6>> (a_Seed + 2000, 200,
std::make_shared<cIntGenSetRandomly <6>> (a_Seed + 9, 50, bgOcean,
std::make_shared<cIntGenZoom <6>> (a_Seed + 10,
std::make_shared<cIntGenLandOcean <5>> (a_Seed + 100, 30
)))))))))))))))))))))))))))))));
m_Gen =
std::make_shared<cIntGenSmooth <16>>(a_Seed,
std::make_shared<cIntGenZoom <18>>(a_Seed,
std::make_shared<cIntGenSmooth <11>>(a_Seed,
std::make_shared<cIntGenZoom <13>>(a_Seed,
std::make_shared<cIntGenMixRivers<8>> (
FinalBiomes, FinalRivers
)))));
}
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_Biomes) override
{
cIntGen<16, 16>::Values vals;
m_Gen->GetInts(a_ChunkX * cChunkDef::Width, a_ChunkZ * cChunkDef::Width, vals);
for (int z = 0; z < cChunkDef::Width; z++)
{
for (int x = 0; x < cChunkDef::Width; x++)
{
cChunkDef::SetBiome(a_Biomes, x, z, (EMCSBiome)vals[x + cChunkDef::Width * z]);
}
}
}
protected:
std::shared_ptr<cIntGen<16, 16>> m_Gen;
};
////////////////////////////////////////////////////////////////////////////////
// cBioGenGrown:
class cBioGenProtGrown:
public cBiomeGen
{
public:
cBioGenProtGrown(int a_Seed)
{
auto FinalRivers =
std::make_shared<cProtIntGenSmooth>(a_Seed + 1,
std::make_shared<cProtIntGenZoom >(a_Seed + 2,
std::make_shared<cProtIntGenRiver >(a_Seed + 3,
std::make_shared<cProtIntGenZoom >(a_Seed + 4,
std::make_shared<cProtIntGenSmooth>(a_Seed + 5,
std::make_shared<cProtIntGenZoom >(a_Seed + 8,
std::make_shared<cProtIntGenSmooth>(a_Seed + 5,
std::make_shared<cProtIntGenZoom >(a_Seed + 9,
std::make_shared<cProtIntGenSmooth>(a_Seed + 5,
std::make_shared<cProtIntGenZoom >(a_Seed + 10,
std::make_shared<cProtIntGenSmooth>(a_Seed + 5,
std::make_shared<cProtIntGenSmooth>(a_Seed + 6,
std::make_shared<cProtIntGenZoom >(a_Seed + 11,
std::make_shared<cProtIntGenChoice>(a_Seed + 12, 2
))))))))))))));
auto alteration =
std::make_shared<cProtIntGenZoom >(a_Seed,
std::make_shared<cProtIntGenLandOcean>(a_Seed, 20
));
auto alteration2 =
std::make_shared<cProtIntGenZoom >(a_Seed + 1,
std::make_shared<cProtIntGenZoom >(a_Seed + 2,
std::make_shared<cProtIntGenZoom >(a_Seed + 1,
std::make_shared<cProtIntGenZoom >(a_Seed + 2,
std::make_shared<cProtIntGenLandOcean>(a_Seed + 1, 10
)))));
auto FinalBiomes =
std::make_shared<cProtIntGenSmooth >(a_Seed + 1,
std::make_shared<cProtIntGenZoom >(a_Seed + 15,
std::make_shared<cProtIntGenSmooth >(a_Seed + 1,
std::make_shared<cProtIntGenZoom >(a_Seed + 16,
std::make_shared<cProtIntGenBeaches >(
std::make_shared<cProtIntGenZoom >(a_Seed + 1,
std::make_shared<cProtIntGenAddIslands >(a_Seed + 2004, 10,
std::make_shared<cProtIntGenAddToOcean >(a_Seed + 10, 500, biDeepOcean,
std::make_shared<cProtIntGenReplaceRandomly>(a_Seed + 1, biPlains, biSunflowerPlains, 20,
std::make_shared<cProtIntGenMBiomes >(a_Seed + 5, alteration2,
std::make_shared<cProtIntGenAlternateBiomes>(a_Seed + 1, alteration,
std::make_shared<cProtIntGenBiomeEdges >(a_Seed + 3,
std::make_shared<cProtIntGenZoom >(a_Seed + 2,
std::make_shared<cProtIntGenZoom >(a_Seed + 4,
std::make_shared<cProtIntGenReplaceRandomly>(a_Seed + 99, biIcePlains, biIcePlainsSpikes, 50,
std::make_shared<cProtIntGenZoom >(a_Seed + 8,
std::make_shared<cProtIntGenAddToOcean >(a_Seed + 10, 300, biDeepOcean,
std::make_shared<cProtIntGenAddToOcean >(a_Seed + 9, 8, biMushroomIsland,
std::make_shared<cProtIntGenBiomes >(a_Seed + 3000,
std::make_shared<cProtIntGenAddIslands >(a_Seed + 2000, 200,
std::make_shared<cProtIntGenZoom >(a_Seed + 5,
std::make_shared<cProtIntGenRareBiomeGroups>(a_Seed + 5, 50,
std::make_shared<cProtIntGenBiomeGroupEdges>(
std::make_shared<cProtIntGenAddIslands >(a_Seed + 2000, 200,
std::make_shared<cProtIntGenZoom >(a_Seed + 7,
std::make_shared<cProtIntGenSetRandomly >(a_Seed + 8, 50, bgOcean,
std::make_shared<cProtIntGenReplaceRandomly>(a_Seed + 101, bgIce, bgTemperate, 150,
std::make_shared<cProtIntGenAddIslands >(a_Seed + 2000, 200,
std::make_shared<cProtIntGenSetRandomly >(a_Seed + 9, 50, bgOcean,
std::make_shared<cProtIntGenZoom >(a_Seed + 10,
std::make_shared<cProtIntGenLandOcean >(a_Seed + 100, 30
)))))))))))))))))))))))))))))));
m_Gen =
std::make_shared<cProtIntGenSmooth >(a_Seed,
std::make_shared<cProtIntGenZoom >(a_Seed,
std::make_shared<cProtIntGenSmooth >(a_Seed,
std::make_shared<cProtIntGenZoom >(a_Seed,
std::make_shared<cProtIntGenMixRivers>(
FinalBiomes, FinalRivers
)))));
}
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_Biomes) override
{
int vals[16 * 16];
m_Gen->GetInts(a_ChunkX * cChunkDef::Width, a_ChunkZ * cChunkDef::Width, 16, 16, vals);
for (int z = 0; z < cChunkDef::Width; z++)
{
for (int x = 0; x < cChunkDef::Width; x++)
{
cChunkDef::SetBiome(a_Biomes, x, z, (EMCSBiome)vals[x + cChunkDef::Width * z]);
}
}
}
protected:
std::shared_ptr<cProtIntGen> m_Gen;
};
////////////////////////////////////////////////////////////////////////////////
// cBiomeGen:
@ -952,6 +1162,14 @@ cBiomeGenPtr cBiomeGen::CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool &
{
res = new cBioGenTwoLevel(a_Seed);
}
else if (NoCaseCompare(BiomeGenName, "grown") == 0)
{
res = new cBioGenGrown(a_Seed);
}
else if (NoCaseCompare(BiomeGenName, "grownprot") == 0)
{
res = new cBioGenProtGrown(a_Seed);
}
else
{
if (NoCaseCompare(BiomeGenName, "multistepmap") != 0)

View File

@ -46,6 +46,7 @@ SET (HDRS
FinishGen.h
GridStructGen.h
HeiGen.h
IntGen.h
MineShafts.h
NetherFortGen.h
Noise3DGenerator.h
@ -53,6 +54,7 @@ SET (HDRS
PieceGenerator.h
Prefab.h
PrefabPiecePool.h
ProtIntGen.h
RainbowRoadsGen.h
Ravines.h
RoughRavines.h

1406
src/Generating/IntGen.h Normal file

File diff suppressed because it is too large Load Diff

1351
src/Generating/ProtIntGen.h Normal file

File diff suppressed because it is too large Load Diff