diff options
-rw-r--r-- | src/Generating/HeiGen.cpp | 5 | ||||
-rw-r--r-- | src/Generating/MineShafts.cpp | 12 | ||||
-rw-r--r-- | src/Generating/Noise3DGenerator.cpp | 7 | ||||
-rw-r--r-- | src/Generating/PieceGenerator.cpp | 12 | ||||
-rw-r--r-- | src/Generating/Ravines.cpp | 16 | ||||
-rw-r--r-- | src/Generating/RoughRavines.cpp | 16 |
6 files changed, 40 insertions, 28 deletions
diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index e44885135..6aa52c4a5 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -801,7 +801,10 @@ protected: case biTaiga: a_Min = 63; a_Max = 75; break; case biTaigaHills: a_Min = 63; a_Max = 90; break; case biTaigaM: a_Min = 63; a_Max = 80; break; - default: + case biInvalidBiome: + case biNumBiomes: + case biVariant: + case biNumVariantBiomes: { ASSERT(!"Unknown biome"); a_Min = 10; diff --git a/src/Generating/MineShafts.cpp b/src/Generating/MineShafts.cpp index 61f29b762..1482234f0 100644 --- a/src/Generating/MineShafts.cpp +++ b/src/Generating/MineShafts.cpp @@ -564,14 +564,14 @@ cMineShaft * cMineShaftCorridor::CreateAndFit( void cMineShaftCorridor::AppendBranches(int a_RecursionLevel, cNoise & a_Noise) { - int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 7; + int Outerrnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 7; // Prefer the same height, but allow for up to one block height displacement: - int Height = m_BoundingBox.p1.y + ((rnd % 4) + ((rnd >> 3) % 3)) / 2; + int OuterHeight = m_BoundingBox.p1.y + ((Outerrnd % 4) + ((Outerrnd >> 3) % 3)) / 2; switch (m_Direction) { case dirXM: { - m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, Height, m_BoundingBox.p1.z + 1, dirXM, a_Noise, a_RecursionLevel); + m_ParentSystem.AppendBranch(m_BoundingBox.p1.x - 1, OuterHeight, m_BoundingBox.p1.z + 1, dirXM, a_Noise, a_RecursionLevel); for (int i = m_NumSegments; i >= 0; i--) { int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11; @@ -586,7 +586,7 @@ void cMineShaftCorridor::AppendBranches(int a_RecursionLevel, cNoise & a_Noise) case dirXP: { - m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, Height, m_BoundingBox.p1.z + 1, dirXP, a_Noise, a_RecursionLevel); + m_ParentSystem.AppendBranch(m_BoundingBox.p2.x + 1, OuterHeight, m_BoundingBox.p1.z + 1, dirXP, a_Noise, a_RecursionLevel); for (int i = m_NumSegments; i >= 0; i--) { int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11; @@ -601,7 +601,7 @@ void cMineShaftCorridor::AppendBranches(int a_RecursionLevel, cNoise & a_Noise) case dirZM: { - m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel); + m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, OuterHeight, m_BoundingBox.p1.z - 1, dirZM, a_Noise, a_RecursionLevel); for (int i = m_NumSegments; i >= 0; i--) { int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11; @@ -616,7 +616,7 @@ void cMineShaftCorridor::AppendBranches(int a_RecursionLevel, cNoise & a_Noise) case dirZP: { - m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, Height, m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel); + m_ParentSystem.AppendBranch(m_BoundingBox.p1.x + 1, OuterHeight, m_BoundingBox.p2.z + 1, dirZP, a_Noise, a_RecursionLevel); for (int i = m_NumSegments; i >= 0; i--) { int rnd = a_Noise.IntNoise3DInt(m_BoundingBox.p1.x + i + 10, m_BoundingBox.p1.y + a_RecursionLevel, m_BoundingBox.p1.z) / 11; diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp index 63e88c2a8..8163746f8 100644 --- a/src/Generating/Noise3DGenerator.cpp +++ b/src/Generating/Noise3DGenerator.cpp @@ -305,7 +305,7 @@ void cNoise3DGenerator::UpdateHeightmap(cChunkDesc & a_ChunkDesc) { for (int x = 0; x < cChunkDef::Width; x++) { - for (int y = cChunkDef::Height - 1; y > 0; y--) + for (HEIGHTTYPE y = cChunkDef::Height - 1; y > 0; y--) { if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR) { @@ -790,7 +790,10 @@ void cBiomalNoise3DComposable::GetBiomeParams(EMCSBiome a_Biome, NOISE_DATATYPE case biTaiga: a_HeightAmp = 0.1f; a_MidPoint = 64; break; case biTaigaM: a_HeightAmp = 0.1f; a_MidPoint = 70; break; case biTaigaHills: a_HeightAmp = 0.075f; a_MidPoint = 68; break; - default: + case biInvalidBiome: + case biNumBiomes: + case biVariant: + case biNumVariantBiomes: { // Make a crazy terrain so that it stands out a_HeightAmp = 0.001f; diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index 97aa646fc..b58a5394d 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -385,7 +385,7 @@ cPlacedPiece * cPieceGenerator::PlaceStartingPiece(int a_BlockX, int a_BlockY, i else { // All pieces returned zero weight, but we need one to start. Choose with equal chance: - StartingPiece = StartingPieces[rnd % StartingPieces.size()]; + StartingPiece = StartingPieces[static_cast<size_t>(rnd) % StartingPieces.size()]; } rnd = rnd >> 16; @@ -561,7 +561,10 @@ void cPieceGenerator::DebugConnectorPool(const cPieceGenerator::cFreeConnectors { printf(" Connector pool: " SIZE_T_FMT " items\n", a_ConnectorPool.size() - a_NumProcessed); size_t idx = 0; - for (cPieceGenerator::cFreeConnectors::const_iterator itr = a_ConnectorPool.begin() + a_NumProcessed, end = a_ConnectorPool.end(); itr != end; ++itr, ++idx) + + typedef cPieceGenerator::cFreeConnectors::difference_type difType; + + for (auto itr = a_ConnectorPool.cbegin() + static_cast<difType>(a_NumProcessed), end = a_ConnectorPool.cend(); itr != end; ++itr, ++idx) { printf(" " SIZE_T_FMT ": {%d, %d, %d}, type %d, direction %s, depth %d\n", idx, @@ -672,7 +675,10 @@ void cBFSPieceGenerator::PlacePieces(int a_BlockX, int a_BlockY, int a_BlockZ, i NumProcessed++; if (NumProcessed > 1000) { - ConnectorPool.erase(ConnectorPool.begin(), ConnectorPool.begin() + NumProcessed); + + typedef cPieceGenerator::cFreeConnectors::difference_type difType; + + ConnectorPool.erase(ConnectorPool.begin(), ConnectorPool.begin() + static_cast<difType>(NumProcessed)); NumProcessed = 0; } } diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 9f8f69139..8c6316273 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -135,17 +135,17 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block // Get the base angle in which the ravine "axis" goes: float Angle = (float)(((float)((a_Noise.IntNoise3DInt(20 * a_BlockX, 70 * a_BlockZ, 6000) / 9) % 16384)) / 16384.0 * M_PI); - float xc = sin(Angle); - float zc = cos(Angle); + float xc = sinf(Angle); + float zc = cosf(Angle); // Calculate the definition points and radii: int MaxRadius = (int)(sqrt(12.0 + ((a_Noise.IntNoise2DInt(61 * a_BlockX, 97 * a_BlockZ) / 13) % a_Size) / 16)); int Top = 32 + ((a_Noise.IntNoise2DInt(13 * a_BlockX, 17 * a_BlockZ) / 23) % 32); int Bottom = 5 + ((a_Noise.IntNoise2DInt(17 * a_BlockX, 29 * a_BlockZ) / 13) % 32); int Mid = (Top + Bottom) / 2; - int PointX = CenterX - (int)(xc * a_Size / 2); - int PointZ = CenterZ - (int)(zc * a_Size / 2); - m_Points.push_back(cRavDefPoint(PointX, PointZ, 0, (Mid + Top) / 2, (Mid + Bottom) / 2)); + int DefinitionPointX = CenterX - (int)(xc * a_Size / 2); + int DefinitionPointZ = CenterZ - (int)(zc * a_Size / 2); + m_Points.push_back(cRavDefPoint(DefinitionPointX, DefinitionPointZ, 0, (Mid + Top) / 2, (Mid + Bottom) / 2)); for (int i = 1; i < NUM_RAVINE_POINTS - 1; i++) { int LineX = CenterX + (int)(xc * a_Size * (i - NUM_RAVINE_POINTS / 2) / NUM_RAVINE_POINTS); @@ -160,9 +160,9 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block int ThisBottom = Bottom + ((a_Noise.IntNoise3DInt(19 * a_BlockX, 7 * a_BlockZ, i * 31) / 13) % 8) - 4; m_Points.push_back(cRavDefPoint(PointX, PointZ, Radius, ThisTop, ThisBottom)); } // for i - m_Points[] - PointX = CenterX + (int)(xc * a_Size / 2); - PointZ = CenterZ + (int)(zc * a_Size / 2); - m_Points.push_back(cRavDefPoint(PointX, PointZ, 0, Mid, Mid)); + DefinitionPointX = CenterX + (int)(xc * a_Size / 2); + DefinitionPointZ = CenterZ + (int)(zc * a_Size / 2); + m_Points.push_back(cRavDefPoint(DefinitionPointX, DefinitionPointZ, 0, Mid, Mid)); } diff --git a/src/Generating/RoughRavines.cpp b/src/Generating/RoughRavines.cpp index 2ee3704b3..c0397ee26 100644 --- a/src/Generating/RoughRavines.cpp +++ b/src/Generating/RoughRavines.cpp @@ -21,7 +21,7 @@ class cRoughRavine : public: cRoughRavine( - int a_Seed, int a_Size, + int a_Seed, size_t a_Size, float a_CenterWidth, float a_Roughness, float a_FloorHeightEdge1, float a_FloorHeightEdge2, float a_FloorHeightCenter, float a_CeilingHeightEdge1, float a_CeilingHeightEdge2, float a_CeilingHeightCenter, @@ -33,14 +33,14 @@ public: m_Roughness(a_Roughness) { // Create the basic structure - 2 lines meeting at the centerpoint: - int Max = 2 * a_Size; - int Half = a_Size; // m_DefPoints[Half] will be the centerpoint + size_t Max = 2 * a_Size; + size_t Half = a_Size; // m_DefPoints[Half] will be the centerpoint m_DefPoints.resize(Max + 1); int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 7; float Len = (float)a_Size; float Angle = (float)rnd; // Angle is in radians, will be wrapped in the "sin" and "cos" operations - float OfsX = sin(Angle) * Len; - float OfsZ = cos(Angle) * Len; + float OfsX = sinf(Angle) * Len; + float OfsZ = cosf(Angle) * Len; m_DefPoints[0].Set (a_OriginX - OfsX, a_OriginZ - OfsZ, 1, a_CeilingHeightEdge1, a_FloorHeightEdge1); m_DefPoints[Half].Set((float)a_OriginX, (float)a_OriginZ, a_CenterWidth, a_CeilingHeightCenter, a_FloorHeightCenter); m_DefPoints[Max].Set (a_OriginX + OfsX, a_OriginZ + OfsZ, 1, a_CeilingHeightEdge2, a_FloorHeightEdge2); @@ -90,7 +90,7 @@ protected: /** Recursively subdivides the line between the points of the specified index. Sets the midpoint to the center of the line plus or minus a random offset, then calls itself for each half of the new line. */ - void SubdivideLine(int a_Idx1, int a_Idx2) + void SubdivideLine(size_t a_Idx1, size_t a_Idx2) { // Calculate the midpoint: const sRavineDefPoint & p1 = m_DefPoints[a_Idx1]; @@ -114,7 +114,7 @@ protected: MidX -= dz * m_Roughness; MidZ += dx * m_Roughness; } - int MidIdx = (a_Idx1 + a_Idx2) / 2; + size_t MidIdx = (a_Idx1 + a_Idx2) / 2; m_DefPoints[MidIdx].Set(MidX, MidZ, MidR, MidT, MidB); // Recurse the two halves, if they are worth recursing: @@ -275,7 +275,7 @@ cRoughRavines::cRoughRavines( cGridStructGen::cStructurePtr cRoughRavines::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) { // Pick a random value for each of the ravine's parameters: - int Size = m_MinSize + (m_Noise.IntNoise2DInt(a_GridX, a_GridZ) / 7) % (m_MaxSize - m_MinSize); // Random int from m_MinSize to m_MaxSize + size_t Size = static_cast<size_t>(m_MinSize + (m_Noise.IntNoise2DInt(a_GridX, a_GridZ) / 7) % (m_MaxSize - m_MinSize)); // Random int from m_MinSize to m_MaxSize float CenterWidth = m_Noise.IntNoise2DInRange(a_GridX + 10, a_GridZ, m_MinCenterWidth, m_MaxCenterWidth); float Roughness = m_Noise.IntNoise2DInRange(a_GridX + 20, a_GridZ, m_MinRoughness, m_MaxRoughness); float FloorHeightEdge1 = m_Noise.IntNoise2DInRange(a_GridX + 30, a_GridZ, m_MinFloorHeightEdge, m_MaxFloorHeightEdge); |