From 3884503031ba160a0f234984747122c303823c4a Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Mon, 6 Aug 2012 10:41:49 +0000 Subject: Fixed runtime crashes in generator on Raspberry Pi (damn picky gcc!) git-svn-id: http://mc-server.googlecode.com/svn/trunk@714 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Caves.cpp | 48 ++++++++++++++++++++++++------------------------ source/Ravines.cpp | 36 ++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/source/Caves.cpp b/source/Caves.cpp index 994e57c86..f334023ce 100644 --- a/source/Caves.cpp +++ b/source/Caves.cpp @@ -42,14 +42,14 @@ reduced in complexity in order for this generator to be useful, so the caves' sh -struct cDefPoint +struct cCaveDefPoint { int m_BlockX; int m_BlockY; int m_BlockZ; int m_Radius; - cDefPoint(int a_BlockX, int a_BlockY, int a_BlockZ, int a_Radius) : + cCaveDefPoint(int a_BlockX, int a_BlockY, int a_BlockZ, int a_Radius) : m_BlockX(a_BlockX), m_BlockY(a_BlockY), m_BlockZ(a_BlockZ), @@ -58,7 +58,7 @@ struct cDefPoint } } ; -typedef std::vector cDefPoints; +typedef std::vector cCaveDefPoints; @@ -76,7 +76,7 @@ class cCaveTunnel void Randomize(cNoise & a_Noise); /// Refines (adds and smooths) defpoints from a_Src into a_Dst; returns false if no refinement possible (segments too short) - bool RefineDefPoints(const cDefPoints & a_Src, cDefPoints & a_Dst); + bool RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & a_Dst); /// Does rounds of smoothing, two passes of RefineDefPoints(), as long as they return true void Smooth(void); @@ -88,7 +88,7 @@ class cCaveTunnel void CalcBoundingBox(void); public: - cDefPoints m_Points; + cCaveDefPoints m_Points; cCaveTunnel( int a_BlockStartX, int a_BlockStartY, int a_BlockStartZ, int a_StartRadius, @@ -162,8 +162,8 @@ cCaveTunnel::cCaveTunnel( cNoise & a_Noise ) { - m_Points.push_back(cDefPoint(a_BlockStartX, a_BlockStartY, a_BlockStartZ, a_StartRadius)); - m_Points.push_back(cDefPoint(a_BlockEndX, a_BlockEndY, a_BlockEndZ, a_EndRadius)); + m_Points.push_back(cCaveDefPoint(a_BlockStartX, a_BlockStartY, a_BlockStartZ, a_StartRadius)); + m_Points.push_back(cCaveDefPoint(a_BlockEndX, a_BlockEndY, a_BlockEndZ, a_EndRadius)); if ((a_BlockStartY <= 0) && (a_BlockEndY <= 0)) { @@ -194,10 +194,10 @@ void cCaveTunnel::Randomize(cNoise & a_Noise) int PrevY = m_Points.front().m_BlockY; int PrevZ = m_Points.front().m_BlockZ; int PrevR = m_Points.front().m_Radius; - cDefPoints Pts; + cCaveDefPoints Pts; Pts.reserve(m_Points.size() * 2 + 1); Pts.push_back(m_Points.front()); - for (cDefPoints::const_iterator itr = m_Points.begin() + 1, end = m_Points.end(); itr != end; ++itr) + for (cCaveDefPoints::const_iterator itr = m_Points.begin() + 1, end = m_Points.end(); itr != end; ++itr) { int Random = a_Noise.IntNoise3DInt(PrevX, PrevY, PrevZ + i) / 11; int len = (PrevX - itr->m_BlockX) * (PrevX - itr->m_BlockX); @@ -211,7 +211,7 @@ void cCaveTunnel::Randomize(cNoise & a_Noise) int y = (itr->m_BlockY + PrevY) / 2 + (Random % (len / 2 + 1) - len / 4); Random /= 256; int z = (itr->m_BlockZ + PrevZ) / 2 + (Random % (len + 1) - len / 2); - Pts.push_back(cDefPoint(x, y, z, Rad)); + Pts.push_back(cCaveDefPoint(x, y, z, Rad)); Pts.push_back(*itr); PrevX = itr->m_BlockX; PrevY = itr->m_BlockY; @@ -226,14 +226,14 @@ void cCaveTunnel::Randomize(cNoise & a_Noise) -bool cCaveTunnel::RefineDefPoints(const cDefPoints & a_Src, cDefPoints & a_Dst) +bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & a_Dst) { // Smoothing: for each line segment, add points on its 1/4 lengths bool res = false; int Num = a_Src.size() - 2; // this many intermediary points a_Dst.clear(); a_Dst.reserve(Num * 2 + 2); - cDefPoints::const_iterator itr = a_Src.begin() + 1; + cCaveDefPoints::const_iterator itr = a_Src.begin() + 1; a_Dst.push_back(a_Src.front()); int PrevX = a_Src.front().m_BlockX; int PrevY = a_Src.front().m_BlockY; @@ -256,8 +256,8 @@ bool cCaveTunnel::RefineDefPoints(const cDefPoints & a_Src, cDefPoints & a_Dst) int dr = itr->m_Radius - PrevR; int Rad1 = std::max(PrevR + 1 * dr / 4, 1); int Rad2 = std::max(PrevR + 3 * dr / 4, 1); - a_Dst.push_back(cDefPoint(PrevX + 1 * dx / 4, PrevY + 1 * dy / 4, PrevZ + 1 * dz / 4, Rad1)); - a_Dst.push_back(cDefPoint(PrevX + 3 * dx / 4, PrevY + 3 * dy / 4, PrevZ + 3 * dz / 4, Rad2)); + a_Dst.push_back(cCaveDefPoint(PrevX + 1 * dx / 4, PrevY + 1 * dy / 4, PrevZ + 1 * dz / 4, Rad1)); + a_Dst.push_back(cCaveDefPoint(PrevX + 3 * dx / 4, PrevY + 3 * dy / 4, PrevZ + 3 * dz / 4, Rad2)); PrevX = itr->m_BlockX; PrevY = itr->m_BlockY; PrevZ = itr->m_BlockZ; @@ -274,7 +274,7 @@ bool cCaveTunnel::RefineDefPoints(const cDefPoints & a_Src, cDefPoints & a_Dst) void cCaveTunnel::Smooth(void) { - cDefPoints Pts; + cCaveDefPoints Pts; while (true) { if (!RefineDefPoints(m_Points, Pts)) @@ -296,14 +296,14 @@ void cCaveTunnel::Smooth(void) void cCaveTunnel::FinishLinear(void) { // For each segment, use Bresenham's 3D line algorithm to draw a "line" of defpoints - cDefPoints Pts; + cCaveDefPoints Pts; std::swap(Pts, m_Points); m_Points.reserve(Pts.size() * 3); int PrevX = Pts.front().m_BlockX; int PrevY = Pts.front().m_BlockY; int PrevZ = Pts.front().m_BlockZ; - for (cDefPoints::const_iterator itr = Pts.begin() + 1, end = Pts.end(); itr != end; ++itr) + for (cCaveDefPoints::const_iterator itr = Pts.begin() + 1, end = Pts.end(); itr != end; ++itr) { int x1 = itr->m_BlockX; int y1 = itr->m_BlockY; @@ -324,7 +324,7 @@ void cCaveTunnel::FinishLinear(void) while (true) { - m_Points.push_back(cDefPoint(PrevX, PrevY, PrevZ, R)); + m_Points.push_back(cCaveDefPoint(PrevX, PrevY, PrevZ, R)); if (PrevX == x1) { @@ -356,7 +356,7 @@ void cCaveTunnel::FinishLinear(void) while (true) { - m_Points.push_back(cDefPoint(PrevX, PrevY, PrevZ, R)); + m_Points.push_back(cCaveDefPoint(PrevX, PrevY, PrevZ, R)); if (PrevY == y1) { @@ -390,7 +390,7 @@ void cCaveTunnel::FinishLinear(void) while (true) { - m_Points.push_back(cDefPoint(PrevX, PrevY, PrevZ, R)); + m_Points.push_back(cCaveDefPoint(PrevX, PrevY, PrevZ, R)); if (PrevZ == z1) { @@ -427,7 +427,7 @@ void cCaveTunnel::CalcBoundingBox(void) m_MinBlockX = m_MaxBlockX = m_Points.front().m_BlockX; m_MinBlockY = m_MaxBlockY = m_Points.front().m_BlockY; m_MinBlockZ = m_MaxBlockZ = m_Points.front().m_BlockZ; - for (cDefPoints::const_iterator itr = m_Points.begin() + 1, end = m_Points.end(); itr != end; ++itr) + for (cCaveDefPoints::const_iterator itr = m_Points.begin() + 1, end = m_Points.end(); itr != end; ++itr) { m_MinBlockX = std::min(m_MinBlockX, itr->m_BlockX - itr->m_Radius); m_MaxBlockX = std::max(m_MaxBlockX, itr->m_BlockX + itr->m_Radius); @@ -463,7 +463,7 @@ void cCaveTunnel::ProcessChunk( int BlockStartZ = a_ChunkZ * cChunkDef::Width; int BlockEndX = BlockStartX + cChunkDef::Width; int BlockEndZ = BlockStartZ + cChunkDef::Width; - for (cDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr) + for (cCaveDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr) { if ( (itr->m_BlockX + itr->m_Radius < BlockStartX) || @@ -499,7 +499,7 @@ void cCaveTunnel::ProcessChunk( /* #ifdef _DEBUG // For debugging purposes, outline the shape of the cave using glowstone, *after* carving the entire cave: - for (cDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr) + for (cCaveDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr) { int DifX = itr->m_BlockX - BlockStartX; // substitution for faster calc int DifZ = itr->m_BlockZ - BlockStartZ; // substitution for faster calc @@ -527,7 +527,7 @@ AString cCaveTunnel::ExportAsSVG(int a_Color, int a_OffsetX, int a_OffsetZ) cons SVG.reserve(m_Points.size() * 20 + 200); AppendPrintf(SVG, "m_BlockX, a_OffsetZ + itr->m_BlockZ); Prefix = 'L'; diff --git a/source/Ravines.cpp b/source/Ravines.cpp index 332cf0889..c298033f9 100644 --- a/source/Ravines.cpp +++ b/source/Ravines.cpp @@ -18,7 +18,7 @@ static const int NUM_RAVINE_POINTS = 4; -struct cDefPoint +struct cRavDefPoint { int m_BlockX; int m_BlockZ; @@ -26,7 +26,7 @@ struct cDefPoint int m_Top; int m_Bottom; - cDefPoint(int a_BlockX, int a_BlockZ, int a_Radius, int a_Top, int a_Bottom) : + cRavDefPoint(int a_BlockX, int a_BlockZ, int a_Radius, int a_Top, int a_Bottom) : m_BlockX(a_BlockX), m_BlockZ(a_BlockZ), m_Radius(a_Radius), @@ -36,7 +36,7 @@ struct cDefPoint } } ; -typedef std::vector cDefPoints; +typedef std::vector cRavDefPoints; @@ -44,13 +44,13 @@ typedef std::vector cDefPoints; class cStructGenRavines::cRavine { - cDefPoints m_Points; + cRavDefPoints m_Points; /// Generates the shaping defpoints for the ravine, based on the ravine block coords and noise void GenerateBaseDefPoints(int a_BlockX, int a_BlockZ, int a_Size, cNoise & a_Noise); /// Refines (adds and smooths) defpoints from a_Src into a_Dst - void RefineDefPoints(const cDefPoints & a_Src, cDefPoints & a_Dst); + void RefineDefPoints(const cRavDefPoints & a_Src, cRavDefPoints & a_Dst); /// Does one round of smoothing, two passes of RefineDefPoints() void Smooth(void); @@ -285,7 +285,7 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block 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(cDefPoint(PointX, PointZ, 0, (Mid + Top) / 2, (Mid + Bottom) / 2)); + m_Points.push_back(cRavDefPoint(PointX, PointZ, 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); @@ -298,24 +298,24 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block int Radius = MaxRadius - abs(i - NUM_RAVINE_POINTS / 2); // TODO: better radius function int ThisTop = Top + ((a_Noise.IntNoise3DInt(7 * a_BlockX, 19 * a_BlockZ, i * 31) / 13) % 8) - 4; int ThisBottom = Bottom + ((a_Noise.IntNoise3DInt(19 * a_BlockX, 7 * a_BlockZ, i * 31) / 13) % 8) - 4; - m_Points.push_back(cDefPoint(PointX, PointZ, Radius, ThisTop, ThisBottom)); + 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(cDefPoint(PointX, PointZ, 0, Mid, Mid)); + m_Points.push_back(cRavDefPoint(PointX, PointZ, 0, Mid, Mid)); } -void cStructGenRavines::cRavine::RefineDefPoints(const cDefPoints & a_Src, cDefPoints & a_Dst) +void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cRavDefPoints & a_Dst) { // Smoothing: for each line segment, add points on its 1/4 lengths int Num = a_Src.size() - 2; // this many intermediary points a_Dst.clear(); a_Dst.reserve(Num * 2 + 2); - cDefPoints::const_iterator itr = a_Src.begin() + 1; + cRavDefPoints::const_iterator itr = a_Src.begin() + 1; a_Dst.push_back(a_Src.front()); int PrevX = a_Src.front().m_BlockX; int PrevZ = a_Src.front().m_BlockZ; @@ -336,8 +336,8 @@ void cStructGenRavines::cRavine::RefineDefPoints(const cDefPoints & a_Src, cDefP int db = itr->m_Bottom - PrevB; int Rad1 = std::max(PrevR + 1 * dr / 4, 1); int Rad2 = std::max(PrevR + 3 * dr / 4, 1); - a_Dst.push_back(cDefPoint(PrevX + 1 * dx / 4, PrevZ + 1 * dz / 4, Rad1, PrevT + 1 * dt / 4, PrevB + 1 * db / 4)); - a_Dst.push_back(cDefPoint(PrevX + 3 * dx / 4, PrevZ + 3 * dz / 4, Rad2, PrevT + 3 * dt / 4, PrevB + 3 * db / 4)); + a_Dst.push_back(cRavDefPoint(PrevX + 1 * dx / 4, PrevZ + 1 * dz / 4, Rad1, PrevT + 1 * dt / 4, PrevB + 1 * db / 4)); + a_Dst.push_back(cRavDefPoint(PrevX + 3 * dx / 4, PrevZ + 3 * dz / 4, Rad2, PrevT + 3 * dt / 4, PrevB + 3 * db / 4)); PrevX = itr->m_BlockX; PrevZ = itr->m_BlockZ; PrevR = itr->m_Radius; @@ -353,7 +353,7 @@ void cStructGenRavines::cRavine::RefineDefPoints(const cDefPoints & a_Src, cDefP void cStructGenRavines::cRavine::Smooth(void) { - cDefPoints Pts; + cRavDefPoints Pts; RefineDefPoints(m_Points, Pts); // Refine m_Points -> Pts RefineDefPoints(Pts, m_Points); // Refine Pts -> m_Points } @@ -368,13 +368,13 @@ void cStructGenRavines::cRavine::FinishLinear(void) // _X 2012_07_20: I tried modifying this algorithm to produce "thick" lines (only one coord change per point) // But the results were about the same as the original, so I disposed of it again - no need to use twice the count of points - cDefPoints Pts; + cRavDefPoints Pts; std::swap(Pts, m_Points); m_Points.reserve(Pts.size() * 3); int PrevX = Pts.front().m_BlockX; int PrevZ = Pts.front().m_BlockZ; - for (cDefPoints::const_iterator itr = Pts.begin() + 1, end = Pts.end(); itr != end; ++itr) + for (cRavDefPoints::const_iterator itr = Pts.begin() + 1, end = Pts.end(); itr != end; ++itr) { int x1 = itr->m_BlockX; int z1 = itr->m_BlockZ; @@ -388,7 +388,7 @@ void cStructGenRavines::cRavine::FinishLinear(void) int B = itr->m_Bottom; while (true) { - m_Points.push_back(cDefPoint(PrevX, PrevZ, R, T, B)); + m_Points.push_back(cRavDefPoint(PrevX, PrevZ, R, T, B)); if ((PrevX == x1) && (PrevZ == z1)) { break; @@ -418,7 +418,7 @@ AString cStructGenRavines::cRavine::ExportAsSVG(int a_Color, int a_OffsetX, int AString SVG; AppendPrintf(SVG, "m_BlockX, a_OffsetZ + itr->m_BlockZ); Prefix = 'L'; @@ -469,7 +469,7 @@ void cStructGenRavines::cRavine::ProcessChunk( int BlockStartZ = a_ChunkZ * cChunkDef::Width; int BlockEndX = BlockStartX + cChunkDef::Width; int BlockEndZ = BlockStartZ + cChunkDef::Width; - for (cDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr) + for (cRavDefPoints::const_iterator itr = m_Points.begin(), end = m_Points.end(); itr != end; ++itr) { if ( (itr->m_BlockX + itr->m_Radius < BlockStartX) || -- cgit v1.2.3