Merge pull request #909 from jfhumann/fixes
Bug fixes and optimizations. We need to visit the API functions and check that they return only those values expected. `cWorld::CreateProjectile()` seems affected, too, by the same issue of ToLua returning extra values. In the cleanest form, these functions will need moving to ManualBindings.cpp
This commit is contained in:
+20
-16
@@ -200,13 +200,14 @@ void cCaveTunnel::Randomize(cNoise & a_Noise)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
// For each already present point, insert a point in between it and its predecessor, shifted randomly.
|
||||
int PrevX = m_Points.front().m_BlockX;
|
||||
int PrevY = m_Points.front().m_BlockY;
|
||||
int PrevZ = m_Points.front().m_BlockZ;
|
||||
int PrevR = m_Points.front().m_Radius;
|
||||
cCaveDefPoint & Point = m_Points.front();
|
||||
int PrevX = Point.m_BlockX;
|
||||
int PrevY = Point.m_BlockY;
|
||||
int PrevZ = Point.m_BlockZ;
|
||||
int PrevR = Point.m_Radius;
|
||||
cCaveDefPoints Pts;
|
||||
Pts.reserve(m_Points.size() * 2 + 1);
|
||||
Pts.push_back(m_Points.front());
|
||||
Pts.push_back(Point);
|
||||
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;
|
||||
@@ -244,11 +245,12 @@ bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints &
|
||||
a_Dst.clear();
|
||||
a_Dst.reserve(Num * 2 + 2);
|
||||
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;
|
||||
int PrevZ = a_Src.front().m_BlockZ;
|
||||
int PrevR = a_Src.front().m_Radius;
|
||||
const cCaveDefPoint & Source = a_Src.front();
|
||||
a_Dst.push_back(Source);
|
||||
int PrevX = Source.m_BlockX;
|
||||
int PrevY = Source.m_BlockY;
|
||||
int PrevZ = Source.m_BlockZ;
|
||||
int PrevR = Source.m_Radius;
|
||||
for (int i = 0; i <= Num; ++i, ++itr)
|
||||
{
|
||||
int dx = itr->m_BlockX - PrevX;
|
||||
@@ -310,9 +312,10 @@ void cCaveTunnel::FinishLinear(void)
|
||||
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;
|
||||
cCaveDefPoint & PrevPoint = Pts.front();
|
||||
int PrevX = PrevPoint.m_BlockX;
|
||||
int PrevY = PrevPoint.m_BlockY;
|
||||
int PrevZ = PrevPoint.m_BlockZ;
|
||||
for (cCaveDefPoints::const_iterator itr = Pts.begin() + 1, end = Pts.end(); itr != end; ++itr)
|
||||
{
|
||||
int x1 = itr->m_BlockX;
|
||||
@@ -433,9 +436,10 @@ void cCaveTunnel::FinishLinear(void)
|
||||
|
||||
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;
|
||||
cCaveDefPoint & Point = m_Points.front();
|
||||
m_MinBlockX = m_MaxBlockX = Point.m_BlockX;
|
||||
m_MinBlockY = m_MaxBlockY = Point.m_BlockY;
|
||||
m_MinBlockZ = m_MaxBlockZ = Point.m_BlockZ;
|
||||
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);
|
||||
|
||||
@@ -269,7 +269,7 @@ void cStructGenRavines::cRavine::GenerateBaseDefPoints(int a_BlockX, int a_Block
|
||||
int CenterZ = a_BlockZ + OffsetZ;
|
||||
|
||||
// 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 * 3.141592653);
|
||||
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);
|
||||
|
||||
@@ -311,12 +311,13 @@ void cStructGenRavines::cRavine::RefineDefPoints(const cRavDefPoints & a_Src, cR
|
||||
a_Dst.clear();
|
||||
a_Dst.reserve(Num * 2 + 2);
|
||||
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;
|
||||
int PrevR = a_Src.front().m_Radius;
|
||||
int PrevT = a_Src.front().m_Top;
|
||||
int PrevB = a_Src.front().m_Bottom;
|
||||
const cRavDefPoint & Source = a_Src.front();
|
||||
a_Dst.push_back(Source);
|
||||
int PrevX = Source.m_BlockX;
|
||||
int PrevZ = Source.m_BlockZ;
|
||||
int PrevR = Source.m_Radius;
|
||||
int PrevT = Source.m_Top;
|
||||
int PrevB = Source.m_Bottom;
|
||||
for (int i = 0; i <= Num; ++i, ++itr)
|
||||
{
|
||||
int dx = itr->m_BlockX - PrevX;
|
||||
|
||||
Reference in New Issue
Block a user