From b88a70963cedda7b4a0da81d6083ca59b71790ec Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 11 Oct 2013 12:53:05 +0200 Subject: Updated BiomeVisualiser to compile again. --- Tools/BiomeVisualiser/.gitignore | 3 +++ Tools/BiomeVisualiser/BiomeViewWnd.cpp | 2 +- Tools/BiomeVisualiser/BiomeVisualiser.vcproj | 28 ++++++++++++++++++++-------- 3 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 Tools/BiomeVisualiser/.gitignore (limited to 'Tools/BiomeVisualiser') diff --git a/Tools/BiomeVisualiser/.gitignore b/Tools/BiomeVisualiser/.gitignore new file mode 100644 index 000000000..b4e15dc3c --- /dev/null +++ b/Tools/BiomeVisualiser/.gitignore @@ -0,0 +1,3 @@ +Debug/ +logs/ +Release/ diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.cpp b/Tools/BiomeVisualiser/BiomeViewWnd.cpp index 3dd1bb4e0..7d4db58c0 100644 --- a/Tools/BiomeVisualiser/BiomeViewWnd.cpp +++ b/Tools/BiomeVisualiser/BiomeViewWnd.cpp @@ -45,7 +45,7 @@ bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title) cIniFile IniFile; cBiomeGen * BioGen = new cBioGenMultiStepMap(2); - BioGen->Initialize(IniFile); + BioGen->InitializeBiomeGen(IniFile); m_Renderer.SetSource(new cGeneratorBiomeSource(BioGen)); return true; diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj index 522606d60..5f840129d 100644 --- a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj +++ b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj @@ -331,6 +331,22 @@ RelativePath="..\..\source\ChunkDef.h" > + + + + + + + + @@ -363,6 +379,10 @@ RelativePath="..\..\source\Globals.h" > + + @@ -434,14 +454,6 @@ RelativePath="..\..\source\OSSupport\IsThread.h" > - - - - -- cgit v1.2.3 From 4fdb1c1aafcede34bb496bdc8425d300fe619df6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Oct 2013 11:27:06 +0200 Subject: BiomeVisualiser: fixed crash at shutdown caused by bad logging --- Tools/BiomeVisualiser/BiomeVisualiser.cpp | 4 ++-- Tools/BiomeVisualiser/BiomeVisualiser.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Tools/BiomeVisualiser') diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.cpp b/Tools/BiomeVisualiser/BiomeVisualiser.cpp index e1d379f83..a36111d77 100644 --- a/Tools/BiomeVisualiser/BiomeVisualiser.cpp +++ b/Tools/BiomeVisualiser/BiomeVisualiser.cpp @@ -21,8 +21,8 @@ int WINAPI WinMain(HINSTANCE a_Instance, HINSTANCE a_PrevInstance, LPSTR a_CmdLi -cBiomeVisualiser::cBiomeVisualiser(void) - // : m_Logger(Printf("BiomeVisualiser_%08x", time(NULL))) +cBiomeVisualiser::cBiomeVisualiser(void) : + m_Logger(new cMCLogger(Printf("BiomeVisualiser_%08x.log", time(NULL)))) { } diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.h b/Tools/BiomeVisualiser/BiomeVisualiser.h index 3fa90646b..4f8ce7513 100644 --- a/Tools/BiomeVisualiser/BiomeVisualiser.h +++ b/Tools/BiomeVisualiser/BiomeVisualiser.h @@ -23,7 +23,7 @@ public: protected: cBiomeViewWnd m_MainWnd; - cMCLogger m_Logger; + cMCLogger * m_Logger; } ; -- cgit v1.2.3 From 274bdc40ff84af8042173d11ccd4f4db418e3033 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 24 Nov 2013 17:49:04 +0100 Subject: BiomeVisualiser: Added 1.7 biomes, recolored using AMIDST colors. --- Tools/BiomeVisualiser/BiomeColors.cpp | 114 +++++++++++++++++++++++++++ Tools/BiomeVisualiser/BiomeColors.h | 15 ++++ Tools/BiomeVisualiser/BiomeRenderer.cpp | 36 +-------- Tools/BiomeVisualiser/BiomeVisualiser.vcproj | 8 ++ 4 files changed, 141 insertions(+), 32 deletions(-) create mode 100644 Tools/BiomeVisualiser/BiomeColors.cpp create mode 100644 Tools/BiomeVisualiser/BiomeColors.h (limited to 'Tools/BiomeVisualiser') diff --git a/Tools/BiomeVisualiser/BiomeColors.cpp b/Tools/BiomeVisualiser/BiomeColors.cpp new file mode 100644 index 000000000..1fd0cb7a0 --- /dev/null +++ b/Tools/BiomeVisualiser/BiomeColors.cpp @@ -0,0 +1,114 @@ + +// BiomeColors.cpp + +// Implements the g_BiomeColors[] array preparation based on a stored biome-to-color map + +#include "Globals.h" +#include "BiomeColors.h" + + + + + +int g_BiomeColors[256]; + + + + + +static struct +{ + EMCSBiome Biome; + int Color; +} g_BiomeColorMap[] = +{ + { biOcean, 0x000070 }, + { biPlains, 0x8db360 }, + { biDesert, 0xfa9418 }, + { biExtremeHills, 0x606060 }, + { biForest, 0x056621 }, + { biTaiga, 0x0b6659 }, + { biSwampland, 0x2fffda }, + { biRiver, 0x3030af }, + { biHell, 0x7f0000 }, + { biSky, 0x007fff }, + { biFrozenOcean, 0xa0a0df }, + { biFrozenRiver, 0xa0a0ff }, + { biIcePlains, 0xffffff }, + { biIceMountains, 0xa0a0a0 }, + { biMushroomIsland, 0xff00ff }, + { biMushroomShore, 0xa000ff }, + { biBeach, 0xfade55 }, + { biDesertHills, 0xd25f12 }, + { biForestHills, 0x22551c }, + { biTaigaHills, 0x163933 }, + { biExtremeHillsEdge, 0x7f8f7f }, + { biJungle, 0x537b09 }, + { biJungleHills, 0x2c4205 }, + + { biJungleEdge, 0x628b17 }, + { biDeepOcean, 0x000030 }, + { biStoneBeach, 0xa2a284 }, + { biColdBeach, 0xfaf0c0 }, + { biBirchForest, 0x307444 }, + { biBirchForestHills, 0x1f5f32 }, + { biRoofedForest, 0x40511a }, + { biColdTaiga, 0x31554a }, + { biColdTaigaHills, 0x597d72 }, + { biMegaTaiga, 0x596651 }, + { biMegaTaigaHills, 0x596659 }, + { biExtremeHillsPlus, 0x507050 }, + { biSavanna, 0xbdb25f }, + { biSavannaPlateau, 0xa79d64 }, + { biMesa, 0xd94515 }, + { biMesaPlateauF, 0xb09765 }, + { biMesaPlateau, 0xca8c65 }, + + // M variants: + { biSunflowerPlains, 0xb5db88 }, + { biDesertM, 0xffbc40 }, + { biExtremeHillsM, 0x888888 }, + { biFlowerForest, 0x2d8e49 }, + { biTaigaM, 0x338e81 }, + { biSwamplandM, 0x07f9b2 }, + { biIcePlainsSpikes, 0xb4dcdc }, + { biJungleM, 0x7ba331 }, + { biJungleEdgeM, 0x628b17 }, + { biBirchForestM, 0x589c6c }, + { biBirchForestHillsM, 0x47875a }, + { biRoofedForestM, 0x687942 }, + { biColdTaigaM, 0x243f36 }, + { biMegaSpruceTaiga, 0x454f3e }, + { biMegaSpruceTaigaHills, 0x454f4e }, + { biExtremeHillsPlusM, 0x789878 }, + { biSavannaM, 0xe5da87 }, + { biSavannaPlateauM, 0xa79d74 }, + { biMesaBryce, 0xff6d3d }, + { biMesaPlateauFM, 0xd8bf8d }, + { biMesaPlateauM, 0xf2b48d }, +} ; + + + + + +static class cBiomeColorsInitializer +{ +public: + cBiomeColorsInitializer(void) + { + // Reset all colors to gray: + for (size_t i = 0; i < ARRAYCOUNT(g_BiomeColors); i++) + { + g_BiomeColors[i] = 0x7f7f7f; + } + for (size_t i = 0; i < ARRAYCOUNT(g_BiomeColorMap); i++) + { + g_BiomeColors[g_BiomeColorMap[i].Biome] = g_BiomeColorMap[i].Color; + } + } +} g_Initializer; + + + + diff --git a/Tools/BiomeVisualiser/BiomeColors.h b/Tools/BiomeVisualiser/BiomeColors.h new file mode 100644 index 000000000..0cb0f578c --- /dev/null +++ b/Tools/BiomeVisualiser/BiomeColors.h @@ -0,0 +1,15 @@ + +// BiomeColors.h + +// Declares the g_BiomeColors[] array used for biome color lookup + + + + + +extern int g_BiomeColors[256]; + + + + + diff --git a/Tools/BiomeVisualiser/BiomeRenderer.cpp b/Tools/BiomeVisualiser/BiomeRenderer.cpp index 98548179c..758eb4b48 100644 --- a/Tools/BiomeVisualiser/BiomeRenderer.cpp +++ b/Tools/BiomeVisualiser/BiomeRenderer.cpp @@ -7,6 +7,7 @@ #include "BiomeRenderer.h" #include "Pixmap.h" #include "Timer.h" +#include "BiomeColors.h" @@ -96,40 +97,11 @@ bool cBiomeRenderer::Render(cPixmap & a_Pixmap) int cBiomeRenderer::GetBiomeColor(EMCSBiome a_Biome) { - if ((a_Biome < 0) || (a_Biome > biMaxBiome)) + if ((a_Biome < 0) || (a_Biome >= ARRAYCOUNT(g_BiomeColors))) { - return 0xcfcfcf; // LtGray for unknown biomes + return 0xff0000; } - - static int BiomeColor[] = - { - // RGB: - 0x0000ff, /* Ocean */ - 0x00cf3f, /* Plains */ - 0xffff00, /* Desert */ - 0x7f7f7f, /* Extreme Hills */ - 0x00cf00, /* Forest */ - 0x007f3f, /* Taiga */ - 0x3f7f00, /* Swampland */ - 0x003fff, /* River */ - 0x7f0000, /* Hell */ - 0x007fff, /* Sky */ - 0x3f3fff, /* Frozen Ocean */ - 0x3f3fff, /* Frozen River */ - 0x7fffcf, /* Ice Plains */ - 0x3fcf7f, /* Ice Mountains */ - 0xcf00cf, /* Mushroom Island */ - 0x7f00ff, /* Mushroom Island Shore */ - 0xffff3f, /* Beach */ - 0xcfcf00, /* Desert Hills */ - 0x00cf3f, /* Forest Hills */ - 0x006f1f, /* Taiga Hills */ - 0x7f8f7f, /* Extreme Hills Edge */ - 0x004f00, /* Jungle */ - 0x003f00, /* Jungle Hills */ - } ; - - return BiomeColor[a_Biome]; + return g_BiomeColors[a_Biome]; } diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj index 5f840129d..2616313a2 100644 --- a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj +++ b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj @@ -268,6 +268,10 @@ RelativePath=".\BiomeCache.h" > + + @@ -489,6 +493,10 @@ + + -- cgit v1.2.3 From afd94a0b11ae1e5c98efb378a14ecca140bf310b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 28 Nov 2013 10:09:45 +0100 Subject: Fixed BiomeVisualiser after folder move. --- Tools/BiomeVisualiser/BiomeCache.h | 2 +- Tools/BiomeVisualiser/BiomeViewWnd.cpp | 2 +- Tools/BiomeVisualiser/BiomeVisualiser.vcproj | 80 +++++++++++++++------------- Tools/BiomeVisualiser/GeneratorBiomeSource.h | 2 +- 4 files changed, 47 insertions(+), 39 deletions(-) (limited to 'Tools/BiomeVisualiser') diff --git a/Tools/BiomeVisualiser/BiomeCache.h b/Tools/BiomeVisualiser/BiomeCache.h index bf1503d4c..da4d6c761 100644 --- a/Tools/BiomeVisualiser/BiomeCache.h +++ b/Tools/BiomeVisualiser/BiomeCache.h @@ -17,7 +17,7 @@ While the area is being filled, requests for biomes may already come, such reque #include "BiomeSource.h" -#include "../source/OSSupport/IsThread.h" +#include "../src/OSSupport/IsThread.h" diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.cpp b/Tools/BiomeVisualiser/BiomeViewWnd.cpp index 7d4db58c0..0658e3810 100644 --- a/Tools/BiomeVisualiser/BiomeViewWnd.cpp +++ b/Tools/BiomeVisualiser/BiomeViewWnd.cpp @@ -7,7 +7,7 @@ #include "BiomeViewWnd.h" #include "BiomeCache.h" #include "GeneratorBiomeSource.h" -#include "../iniFile/iniFile.h" +#include "iniFile/iniFile.h" diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj index 2616313a2..e42870b13 100644 --- a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj +++ b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj @@ -41,7 +41,7 @@ + + + + @@ -467,15 +475,15 @@ Name="Generating" > @@ -483,11 +491,11 @@ Name="iniFile" > diff --git a/Tools/BiomeVisualiser/GeneratorBiomeSource.h b/Tools/BiomeVisualiser/GeneratorBiomeSource.h index 0b47e5f93..751aed245 100644 --- a/Tools/BiomeVisualiser/GeneratorBiomeSource.h +++ b/Tools/BiomeVisualiser/GeneratorBiomeSource.h @@ -3,7 +3,7 @@ // Declares the cGeneratorBiomeSource that adapts a cBiomeGen into a cBiomeSource -#include "../source/Generating/BioGen.h" +#include "../src/Generating/BioGen.h" #include "BiomeSource.h" -- cgit v1.2.3 From 8acf0129e10f2b7ce3ec377df4b5cb95d8d93a62 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 28 Nov 2013 15:57:34 +0100 Subject: BiomeVisualiser: The biome settings are read from a file. --- Tools/BiomeVisualiser/BiomeCache.cpp | 5 ++ Tools/BiomeVisualiser/BiomeViewWnd.cpp | 83 ++++++++++++++++++++++++++++++++-- Tools/BiomeVisualiser/BiomeViewWnd.h | 19 ++++++++ 3 files changed, 102 insertions(+), 5 deletions(-) (limited to 'Tools/BiomeVisualiser') diff --git a/Tools/BiomeVisualiser/BiomeCache.cpp b/Tools/BiomeVisualiser/BiomeCache.cpp index b3c308422..7d9301d8f 100644 --- a/Tools/BiomeVisualiser/BiomeCache.cpp +++ b/Tools/BiomeVisualiser/BiomeCache.cpp @@ -258,6 +258,11 @@ void cBiomeCache::FilterOutItems(cItems & a_Items, int a_MinChunkX, int a_MaxChu void cBiomeCache::thrProcessQueueItem(void) { + if (m_Source == NULL) + { + return; + } + cItem * Item = NULL; { cCSLock Lock(m_CS); diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.cpp b/Tools/BiomeVisualiser/BiomeViewWnd.cpp index 0658e3810..459a4323c 100644 --- a/Tools/BiomeVisualiser/BiomeViewWnd.cpp +++ b/Tools/BiomeVisualiser/BiomeViewWnd.cpp @@ -34,6 +34,8 @@ bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title) { ASSERT(m_Wnd == NULL); + InitBiomeView(); + // Create a regular STATIC window, then override its window procedure with our own. No need for obnoxious RegisterWindowClass() stuff. m_Wnd = CreateWindow("STATIC", a_Title, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 400, 300, a_ParentWnd, NULL, GetModuleHandle(NULL), NULL); if (m_Wnd == NULL) @@ -43,11 +45,6 @@ bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title) } SetWindowLongPtr(m_Wnd, GWLP_WNDPROC, m_Thunk); - cIniFile IniFile; - cBiomeGen * BioGen = new cBioGenMultiStepMap(2); - BioGen->InitializeBiomeGen(IniFile); - m_Renderer.SetSource(new cGeneratorBiomeSource(BioGen)); - return true; } @@ -55,6 +52,82 @@ bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title) +void cBiomeViewWnd::InitBiomeView(void) +{ + cIniFile IniFile; + IniFile.ReadFile("world.ini"); + AString BiomeGenName = IniFile.GetValueSet("Generator", "BiomeGen", ""); + if (BiomeGenName.empty()) + { + LOGWARN("[Generator] BiomeGen value not set in world.ini, using \"MultiStepMap\"."); + BiomeGenName = "MultiStepMap"; + } + + int Seed = IniFile.GetValueSetI("Generator", "Seed", 0); + + bool CacheOffByDefault = false; + if (NoCaseCompare(BiomeGenName, "constant") == 0) + { + m_BiomeGen = new cBioGenConstant; + CacheOffByDefault = true; // we're generating faster than a cache would retrieve data :) + } + else if (NoCaseCompare(BiomeGenName, "checkerboard") == 0) + { + m_BiomeGen = new cBioGenCheckerboard; + CacheOffByDefault = true; // we're (probably) generating faster than a cache would retrieve data + } + else if (NoCaseCompare(BiomeGenName, "voronoi") == 0) + { + m_BiomeGen = new cBioGenVoronoi(Seed); + } + else if (NoCaseCompare(BiomeGenName, "distortedvoronoi") == 0) + { + m_BiomeGen = new cBioGenDistortedVoronoi(Seed); + } + else + { + if (NoCaseCompare(BiomeGenName, "multistepmap") != 0) + { + LOGWARNING("Unknown BiomeGen \"%s\", using \"MultiStepMap\" instead.", BiomeGenName.c_str()); + } + m_BiomeGen = new cBioGenMultiStepMap(Seed); + + /* + // Performance-testing: + LOGINFO("Measuring performance of cBioGenMultiStepMap..."); + clock_t BeginTick = clock(); + for (int x = 0; x < 5000; x++) + { + cChunkDef::BiomeMap Biomes; + m_BiomeGen->GenBiomes(x * 5, x * 5, Biomes); + } + clock_t Duration = clock() - BeginTick; + LOGINFO("cBioGenMultiStepMap for 5000 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC); + //*/ + } + + // Add a cache, if requested: + int CacheSize = IniFile.GetValueSetI("Generator", "BiomeGenCacheSize", CacheOffByDefault ? 0 : 64); + if (CacheSize > 0) + { + if (CacheSize < 4) + { + LOGWARNING("Biomegen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d", + CacheSize, 4 + ); + CacheSize = 4; + } + LOGD("Using a cache for biomegen of size %d.", CacheSize); + m_BiomeGen = new cBioGenCache(m_BiomeGen, CacheSize); + } + m_BiomeGen->InitializeBiomeGen(IniFile); + m_Renderer.SetSource(new cGeneratorBiomeSource(m_BiomeGen)); + IniFile.WriteFile("world.ini"); +} + + + + LRESULT cBiomeViewWnd::WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam) { diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.h b/Tools/BiomeVisualiser/BiomeViewWnd.h index 88e808ab3..e3f70c7e6 100644 --- a/Tools/BiomeVisualiser/BiomeViewWnd.h +++ b/Tools/BiomeVisualiser/BiomeViewWnd.h @@ -3,6 +3,12 @@ // Declares the cBiomeViewWnd class representing the window that displays biomes + + + + +#pragma once + #include "WndProcThunk.h" #include "BiomeRenderer.h" #include "BiomeCache.h" @@ -12,6 +18,13 @@ +// fwd: +class cBiomeGen; + + + + + class cBiomeViewWnd { public: @@ -26,9 +39,15 @@ protected: cBiomeRenderer m_Renderer; cPixmap m_Pixmap; + /// The generator that is to be visualised + cBiomeGen * m_BiomeGen; + bool m_IsLButtonDown; POINT m_MouseDown; + + void InitBiomeView(void); + LRESULT WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam); // Message handlers: -- cgit v1.2.3 From bdd86d7934e95ee1db54531b51431554d5b91796 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 28 Nov 2013 19:58:20 +0100 Subject: BiomeVisualiser: Added the TwoLevel biome generator. --- Tools/BiomeVisualiser/BiomeViewWnd.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Tools/BiomeVisualiser') diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.cpp b/Tools/BiomeVisualiser/BiomeViewWnd.cpp index 459a4323c..8f8849663 100644 --- a/Tools/BiomeVisualiser/BiomeViewWnd.cpp +++ b/Tools/BiomeVisualiser/BiomeViewWnd.cpp @@ -84,6 +84,10 @@ void cBiomeViewWnd::InitBiomeView(void) { m_BiomeGen = new cBioGenDistortedVoronoi(Seed); } + else if (NoCaseCompare(BiomeGenName, "twolevel") == 0) + { + m_BiomeGen = new cBioGenTwoLevel(Seed); + } else { if (NoCaseCompare(BiomeGenName, "multistepmap") != 0) -- cgit v1.2.3 From 41175b5549522482e94c91dbfcea9602acb20ee4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 28 Nov 2013 20:19:10 +0100 Subject: BiomeVisualiser: Using the common BiomeGen creation code. --- Tools/BiomeVisualiser/BiomeViewWnd.cpp | 68 +--------------------------------- 1 file changed, 1 insertion(+), 67 deletions(-) (limited to 'Tools/BiomeVisualiser') diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.cpp b/Tools/BiomeVisualiser/BiomeViewWnd.cpp index 8f8849663..5c1240bc7 100644 --- a/Tools/BiomeVisualiser/BiomeViewWnd.cpp +++ b/Tools/BiomeVisualiser/BiomeViewWnd.cpp @@ -56,75 +56,9 @@ void cBiomeViewWnd::InitBiomeView(void) { cIniFile IniFile; IniFile.ReadFile("world.ini"); - AString BiomeGenName = IniFile.GetValueSet("Generator", "BiomeGen", ""); - if (BiomeGenName.empty()) - { - LOGWARN("[Generator] BiomeGen value not set in world.ini, using \"MultiStepMap\"."); - BiomeGenName = "MultiStepMap"; - } - int Seed = IniFile.GetValueSetI("Generator", "Seed", 0); - bool CacheOffByDefault = false; - if (NoCaseCompare(BiomeGenName, "constant") == 0) - { - m_BiomeGen = new cBioGenConstant; - CacheOffByDefault = true; // we're generating faster than a cache would retrieve data :) - } - else if (NoCaseCompare(BiomeGenName, "checkerboard") == 0) - { - m_BiomeGen = new cBioGenCheckerboard; - CacheOffByDefault = true; // we're (probably) generating faster than a cache would retrieve data - } - else if (NoCaseCompare(BiomeGenName, "voronoi") == 0) - { - m_BiomeGen = new cBioGenVoronoi(Seed); - } - else if (NoCaseCompare(BiomeGenName, "distortedvoronoi") == 0) - { - m_BiomeGen = new cBioGenDistortedVoronoi(Seed); - } - else if (NoCaseCompare(BiomeGenName, "twolevel") == 0) - { - m_BiomeGen = new cBioGenTwoLevel(Seed); - } - else - { - if (NoCaseCompare(BiomeGenName, "multistepmap") != 0) - { - LOGWARNING("Unknown BiomeGen \"%s\", using \"MultiStepMap\" instead.", BiomeGenName.c_str()); - } - m_BiomeGen = new cBioGenMultiStepMap(Seed); - - /* - // Performance-testing: - LOGINFO("Measuring performance of cBioGenMultiStepMap..."); - clock_t BeginTick = clock(); - for (int x = 0; x < 5000; x++) - { - cChunkDef::BiomeMap Biomes; - m_BiomeGen->GenBiomes(x * 5, x * 5, Biomes); - } - clock_t Duration = clock() - BeginTick; - LOGINFO("cBioGenMultiStepMap for 5000 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC); - //*/ - } - - // Add a cache, if requested: - int CacheSize = IniFile.GetValueSetI("Generator", "BiomeGenCacheSize", CacheOffByDefault ? 0 : 64); - if (CacheSize > 0) - { - if (CacheSize < 4) - { - LOGWARNING("Biomegen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d", - CacheSize, 4 - ); - CacheSize = 4; - } - LOGD("Using a cache for biomegen of size %d.", CacheSize); - m_BiomeGen = new cBioGenCache(m_BiomeGen, CacheSize); - } - m_BiomeGen->InitializeBiomeGen(IniFile); + m_BiomeGen = cBiomeGen::CreateBiomeGen(IniFile, Seed, CacheOffByDefault); m_Renderer.SetSource(new cGeneratorBiomeSource(m_BiomeGen)); IniFile.WriteFile("world.ini"); } -- cgit v1.2.3