From d441096d6229584cce4c76302537c59d89017612 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 31 Mar 2013 17:10:17 +0000 Subject: MineShafts: User-settable chance of individual pieces' occurence. Staircase-only mineshafts, yay :) git-svn-id: http://mc-server.googlecode.com/svn/trunk@1336 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Generating/ComposableGenerator.cpp | 12 +++++++--- source/Generating/MineShafts.cpp | 40 +++++++++++++++---------------- source/Generating/MineShafts.h | 12 +++++----- 3 files changed, 35 insertions(+), 29 deletions(-) (limited to 'source') diff --git a/source/Generating/ComposableGenerator.cpp b/source/Generating/ComposableGenerator.cpp index c8a96da05..f6b52bce7 100644 --- a/source/Generating/ComposableGenerator.cpp +++ b/source/Generating/ComposableGenerator.cpp @@ -326,9 +326,15 @@ void cComposableGenerator::InitStructureGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "MineShafts") == 0) { - int GridSize = a_IniFile.GetValueSetI("Generator", "MineShaftsGridSize", 256); - int MaxSystemSize = a_IniFile.GetValueSetI("Generator", "MineShaftsMaxSystemSize", 128); - m_StructureGens.push_back(new cStructGenMineShafts(Seed, GridSize, MaxSystemSize, 600, 200, 200)); + int GridSize = a_IniFile.GetValueSetI("Generator", "MineShaftsGridSize", 256); + int MaxSystemSize = a_IniFile.GetValueSetI("Generator", "MineShaftsMaxSystemSize", 128); + int ChanceCorridor = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCorridor", 600); + int ChanceCrossing = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCrossing", 200); + int ChanceStaircase = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceStaircase", 200); + m_StructureGens.push_back(new cStructGenMineShafts( + Seed, GridSize, MaxSystemSize, + ChanceCorridor, ChanceCrossing, ChanceStaircase + )); } else if (NoCaseCompare(*itr, "OreNests") == 0) { diff --git a/source/Generating/MineShafts.cpp b/source/Generating/MineShafts.cpp index 0055a7516..97a421bc8 100644 --- a/source/Generating/MineShafts.cpp +++ b/source/Generating/MineShafts.cpp @@ -219,18 +219,18 @@ protected: class cStructGenMineShafts::cMineShaftSystem { public: - int m_BlockX, m_BlockZ; ///< The pivot point on which the system is generated - int m_MaxSystemSize; ///< Maximum size of a system (initialized from cStructGenMineShafts::m_MaxSystemSize) - int m_MaxRecursion; ///< Maximum recursion level (initialized from cStructGenMineShafts::m_MaxRecursion) - int m_ChanceCorridor; ///< Chance (out of 1000) of the next branch object being the corridor - int m_ChanceCrossing; ///< Chance (out of 1000) of the next branch object being the crossing - int m_ChanceStaircase; ///< Chance (out of 1000) of the next branch object being the staircase - cMineShafts m_MineShafts; ///< List of cMineShaft descendants that comprise this system + int m_BlockX, m_BlockZ; ///< The pivot point on which the system is generated + int m_MaxSystemSize; ///< Maximum size of a system (initialized from cStructGenMineShafts::m_MaxSystemSize) + int m_MaxRecursion; ///< Maximum recursion level (initialized from cStructGenMineShafts::m_MaxRecursion) + int m_ProbLevelCorridor; ///< Probability level of a branch object being the corridor + int m_ProbLevelCrossing; ///< Probability level of a branch object being the crossing, minus Corridor + int m_ProbLevelStaircase; ///< Probability level of a branch object being the staircase, minus Crossing + cMineShafts m_MineShafts; ///< List of cMineShaft descendants that comprise this system /// Creates and generates the entire system cMineShaftSystem( int a_BlockX, int a_BlockZ, int a_MaxSystemSize, cNoise & a_Noise, - int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase + int a_ProbLevelCorridor, int a_ProbLevelCrossing, int a_ProbLevelStaircase ); ~cMineShaftSystem(); @@ -260,15 +260,15 @@ public: cStructGenMineShafts::cMineShaftSystem::cMineShaftSystem( int a_BlockX, int a_BlockZ, int a_MaxSystemSize, cNoise & a_Noise, - int a_ChanceCorridor, int a_ChanceCrossing, int a_ChanceStaircase + int a_ProbLevelCorridor, int a_ProbLevelCrossing, int a_ProbLevelStaircase ) : m_BlockX(a_BlockX), m_BlockZ(a_BlockZ), m_MaxSystemSize(a_MaxSystemSize), m_MaxRecursion(8), // TODO: settable - m_ChanceCorridor(a_ChanceCorridor), - m_ChanceCrossing(a_ChanceCrossing), - m_ChanceStaircase(a_ChanceStaircase) + m_ProbLevelCorridor(a_ProbLevelCorridor), + m_ProbLevelCrossing(a_ProbLevelCrossing), + m_ProbLevelStaircase(a_ProbLevelStaircase + 1) { m_MineShafts.reserve(100); @@ -323,16 +323,16 @@ void cStructGenMineShafts::cMineShaftSystem::AppendBranch( } cMineShaft * Next = NULL; - int rnd = (a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_RecursionLevel * 16, a_PivotZ) / 13) % 1000; - if (rnd < m_ChanceCorridor) + int rnd = (a_Noise.IntNoise3DInt(a_PivotX, a_PivotY + a_RecursionLevel * 16, a_PivotZ) / 13) % m_ProbLevelStaircase; + if (rnd < m_ProbLevelCorridor) { Next = cMineShaftCorridor::CreateAndFit(*this, a_PivotX, a_PivotY, a_PivotZ, a_Direction, a_Noise); } - else if (rnd < m_ChanceCrossing) + else if (rnd < m_ProbLevelCrossing) { Next = cMineShaftCrossing::CreateAndFit(*this, a_PivotX, a_PivotY, a_PivotZ, a_Direction, a_Noise); } - else if (rnd < m_ChanceStaircase) + else { Next = cMineShaftStaircase::CreateAndFit(*this, a_PivotX, a_PivotY, a_PivotZ, a_Direction, a_Noise); } @@ -1003,9 +1003,9 @@ cStructGenMineShafts::cStructGenMineShafts( m_Noise(a_Seed), m_GridSize(a_GridSize), m_MaxSystemSize(a_MaxSystemSize), - m_ChanceCorridor(a_ChanceCorridor), - m_ChanceCrossing(a_ChanceCorridor + a_ChanceCrossing), - m_ChanceStaircase(a_ChanceCorridor + a_ChanceCrossing + a_ChanceStaircase) + m_ProbLevelCorridor(std::max(0, a_ChanceCorridor)), + m_ProbLevelCrossing(std::max(0, a_ChanceCorridor + a_ChanceCrossing)), + m_ProbLevelStaircase(std::max(0, a_ChanceCorridor + a_ChanceCrossing + a_ChanceStaircase)) { } @@ -1093,7 +1093,7 @@ void cStructGenMineShafts::GetMineShaftSystemsForChunk( } // for itr - a_Mineshafts if (!Found) { - a_MineShafts.push_back(new cMineShaftSystem(RealX, RealZ, m_MaxSystemSize, m_Noise, m_ChanceCorridor, m_ChanceCrossing, m_ChanceStaircase)); + a_MineShafts.push_back(new cMineShaftSystem(RealX, RealZ, m_MaxSystemSize, m_Noise, m_ProbLevelCorridor, m_ProbLevelCrossing, m_ProbLevelStaircase)); } } // for z } // for x diff --git a/source/Generating/MineShafts.h b/source/Generating/MineShafts.h index a266231d3..a2191b665 100644 --- a/source/Generating/MineShafts.h +++ b/source/Generating/MineShafts.h @@ -37,12 +37,12 @@ protected: typedef std::list cMineShaftSystems; cNoise m_Noise; - int m_GridSize; ///< Average spacing of the systems - int m_MaxSystemSize; ///< Maximum blcok size of a mineshaft system - int m_ChanceCorridor; ///< Chance (out of 1000) of a branch object being the corridor - int m_ChanceCrossing; ///< Chance (out of 1000) of a branch object being the crossing - int m_ChanceStaircase; ///< Chance (out of 1000) of a branch object being the staircase - cMineShaftSystems m_Cache; ///< Cache of the most recently used systems. MoveToFront used. + int m_GridSize; ///< Average spacing of the systems + int m_MaxSystemSize; ///< Maximum blcok size of a mineshaft system + int m_ProbLevelCorridor; ///< Probability level of a branch object being the corridor + int m_ProbLevelCrossing; ///< Probability level of a branch object being the crossing, minus Corridor + int m_ProbLevelStaircase; ///< Probability level of a branch object being the staircase, minus Crossing + cMineShaftSystems m_Cache; ///< Cache of the most recently used systems. MoveToFront used. /// Clears everything from the cache void ClearCache(void); -- cgit v1.2.3