fix a mem leak and some other "potential issues" clang found

This commit is contained in:
DarthArgus
2018-07-14 15:35:06 +00:00
parent 5ce8921f80
commit de42edc6cc
3 changed files with 29 additions and 26 deletions
@@ -424,12 +424,12 @@ bool CityPathNode::sanityCheck ( bool doWarnings ) const
{
DEBUG_WARNING(doWarnings,("CityPathNode::sanityCheck - Node has an edge to a non-existent node\n"));
insaneCount++;
}
if(!neighborNode->hasEdge(getIndex()))
{
DEBUG_WARNING(doWarnings,("CityPathNode::sanityCheck - Node has a one-way edge to another node\n"));
insaneCount++;
} else {
if(!neighborNode->hasEdge(getIndex()))
{
DEBUG_WARNING(doWarnings,("CityPathNode::sanityCheck - Node has a one-way edge to another node\n"));
insaneCount++;
}
}
}
@@ -1141,30 +1141,31 @@ void ServerPathBuilder::addPathNode ( CellProperty const * cell, PathNode const
float dist2 = REAL_MAX;
if(m_path && !m_path->empty()) dist2 = m_path->back().getPosition_w().magnitudeBetweenSquared(loc.getPosition_w());
if(m_path && !m_path->empty()) {
dist2 = m_path->back().getPosition_w().magnitudeBetweenSquared(loc.getPosition_w());
if(dist2 > 0.01)
{
// jitter the node if it's a city waypoint
if(m_enableJitter && (node->getType() == PNT_CityWaypoint))
if(dist2 > 0.01)
{
Vector offset = Vector::zero;
do
// jitter the node if it's a city waypoint
if(m_enableJitter && (node->getType() == PNT_CityWaypoint))
{
offset = Vector( Random::randomReal(-1.0f,1.0f), 0.0f, Random::randomReal(-1.0f,1.0f) );
Vector offset = Vector::zero;
do
{
offset = Vector( Random::randomReal(-1.0f,1.0f), 0.0f, Random::randomReal(-1.0f,1.0f) );
}
while(offset.magnitudeSquared() > 1.0f);
static float tweakValue = 1.0f;
offset *= tweakValue;
loc.setPosition_p( loc.getPosition_p() + offset );
}
while(offset.magnitudeSquared() > 1.0f);
static float tweakValue = 1.0f;
offset *= tweakValue;
loc.setPosition_p( loc.getPosition_p() + offset );
m_path->push_back(loc);
}
m_path->push_back(loc);
}
}
@@ -1942,8 +1942,10 @@ std::string name;
{
// we need to read the next line to continue parsing
line = goToNextLine();
if (line == CHAR_ERROR)
if (line == CHAR_ERROR) {
delete newData;
return line;
}
}
line = parseDynamicVariableParameterList(*newData, line);
}