a little cleanup

fixed pvs-studio generated warnings
fixed makefile
remove vc debug symbols
This commit is contained in:
jeefo 2011-01-05 23:28:48 +04:00
commit 7d5d5ce81a
7 changed files with 29 additions and 57 deletions

View file

@ -1015,9 +1015,6 @@ public:
{ {
T *entry = new T (); T *entry = new T ();
if (entry == NULL)
return NULL;
return Link (entry, next); return Link (entry, next);
} }
@ -1167,8 +1164,7 @@ public:
// //
void Destory (void) void Destory (void)
{ {
if (m_elements != NULL) delete [] m_elements;
delete [] m_elements;
m_elements = NULL; m_elements = NULL;
m_itemSize = 0; m_itemSize = 0;
@ -1216,9 +1212,6 @@ public:
T *buffer = new T[checkSize]; T *buffer = new T[checkSize];
if (buffer == NULL)
return false;
if (keepData && m_elements != NULL) if (keepData && m_elements != NULL)
{ {
if (checkSize < m_itemCount) if (checkSize < m_itemCount)
@ -1571,17 +1564,12 @@ public:
T *buffer = new T[m_itemCount]; T *buffer = new T[m_itemCount];
if (buffer == NULL)
return;
if (m_elements != NULL) if (m_elements != NULL)
{ {
for (int i = 0; i < m_itemCount; i++) for (int i = 0; i < m_itemCount; i++)
buffer[i] = m_elements[i]; buffer[i] = m_elements[i];
} }
delete [] m_elements;
if (m_elements != NULL)
delete [] m_elements;
m_elements = buffer; m_elements = buffer;
m_itemSize = m_itemCount; m_itemSize = m_itemCount;
@ -2498,21 +2486,6 @@ public:
return &m_bufferPtr[0]; return &m_bufferPtr[0];
} }
//
// Function: ToString
// Gets the string buffer.
//
// Returns:
// Pointer to buffer.
//
const char *ToString (void)
{
if (m_bufferPtr == NULL || *m_bufferPtr == 0x0)
return "";
return &m_bufferPtr[0];
}
// //
// Function: ToString // Function: ToString
// Gets the string buffer (constant). // Gets the string buffer (constant).
@ -3761,9 +3734,9 @@ public:
// Returns: // Returns:
// True if operation succeeded, false otherwise. // True if operation succeeded, false otherwise.
// //
bool Open (String fileName, String mode) bool Open (const String &fileName, const String &mode)
{ {
if ((m_handle = fopen (fileName, mode)) == NULL) if ((m_handle = fopen (fileName.GetBuffer (), mode.GetBuffer ())) == NULL)
return false; return false;
fseek (m_handle, 0L, SEEK_END); fseek (m_handle, 0L, SEEK_END);

Binary file not shown.

View file

@ -36,7 +36,7 @@ OBJ = ${SYSTEM}/basecode.o \
${SYSTEM}/support.o \ ${SYSTEM}/support.o \
${SYSTEM}/waypoint.o \ ${SYSTEM}/waypoint.o \
CCOPT = -w -O3 -m32 -s -DNDEBUG=1 -fno-exceptions -fno-rtti -funroll-loops -fomit-frame-pointer -pipe -fvisibility-inlines-hidden -fvisibility=hidden CCOPT = -w -O3 -m32 -s -DNDEBUG=1 -ffast-math -fno-exceptions -fno-rtti -funroll-loops -fomit-frame-pointer -pipe -fvisibility-inlines-hidden -fvisibility=hidden
CCDEBUG = -ggdb -w -DDEBUG=1 -fpermissive CCDEBUG = -ggdb -w -DDEBUG=1 -fpermissive
CFLAGS = $(CCOPT) -I../include/engine -I../include CFLAGS = $(CCOPT) -I../include/engine -I../include

View file

@ -26,7 +26,7 @@
#include <../include/resource.h> #include <../include/resource.h>
// generated by update tool -- do not edit -- // generated by update tool -- do not edit --
#define PRODUCT_BUILD_TOOL 3850 #define PRODUCT_BUILD_TOOL 2542
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION PRODUCT_VERSION_DWORD, PRODUCT_BUILD_TOOL FILEVERSION PRODUCT_VERSION_DWORD, PRODUCT_BUILD_TOOL

View file

@ -220,7 +220,6 @@
<InterproceduralOptimization>SingleFile</InterproceduralOptimization> <InterproceduralOptimization>SingleFile</InterproceduralOptimization>
<FlushDenormalResultsToZero>true</FlushDenormalResultsToZero> <FlushDenormalResultsToZero>true</FlushDenormalResultsToZero>
<Parallelization>false</Parallelization> <Parallelization>false</Parallelization>
<Optimization>MaxSpeedHighLevel</Optimization>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View file

@ -442,13 +442,13 @@ void BotManager::FillServer (int selection, int personality, int skill, int numT
if (skill >= 0 && skill <= 20) if (skill >= 0 && skill <= 20)
randomizedSkill = g_randGen.Long (0, 20); randomizedSkill = g_randGen.Long (0, 20);
else if (skill >= 20 && skill <= 40) else if (skill > 20 && skill <= 40)
randomizedSkill = g_randGen.Long (20, 40); randomizedSkill = g_randGen.Long (20, 40);
else if (skill >= 40 && skill <= 60) else if (skill > 40 && skill <= 60)
randomizedSkill = g_randGen.Long (40, 60); randomizedSkill = g_randGen.Long (40, 60);
else if (skill >= 60 && skill <= 80) else if (skill > 60 && skill <= 80)
randomizedSkill = g_randGen.Long (60, 80); randomizedSkill = g_randGen.Long (60, 80);
else if (skill >= 80 && skill <= 99) else if (skill > 80 && skill <= 99)
randomizedSkill = g_randGen.Long (80, 99); randomizedSkill = g_randGen.Long (80, 99);
else if (skill == 100) else if (skill == 100)
randomizedSkill = skill; randomizedSkill = skill;

View file

@ -1052,7 +1052,7 @@ int gfunctionKillsDistT (int currentIndex, int parentIndex)
cost *= 2; cost *= 2;
if (parentIndex < 0 || parentIndex > g_numWaypoints || parentIndex == currentIndex) if (parentIndex < 0 || parentIndex > g_numWaypoints || parentIndex == currentIndex)
return cost * ((yb_danger_factor.GetInt () * 20 / (2 * g_highestDamageT))); return cost * (yb_danger_factor.GetInt () * 20 / (2 * g_highestDamageT));
return g_waypoint->GetPathDistance (parentIndex, currentIndex) + (cost * 10 * yb_danger_factor.GetInt ()); return g_waypoint->GetPathDistance (parentIndex, currentIndex) + (cost * 10 * yb_danger_factor.GetInt ());
} }
@ -1079,7 +1079,7 @@ int gfunctionKillsDistCT (int currentIndex, int parentIndex)
cost *= 2; cost *= 2;
if (parentIndex < 0 || parentIndex > g_numWaypoints || parentIndex == currentIndex) if (parentIndex < 0 || parentIndex > g_numWaypoints || parentIndex == currentIndex)
return cost * ((yb_danger_factor.GetInt () * 20 / (2 * g_highestDamageCT))); return cost * (yb_danger_factor.GetInt () * 20 / (2 * g_highestDamageCT));
return g_waypoint->GetPathDistance (parentIndex, currentIndex) + (cost * 10 * yb_danger_factor.GetInt ()); return g_waypoint->GetPathDistance (parentIndex, currentIndex) + (cost * 10 * yb_danger_factor.GetInt ());
} }
@ -1091,7 +1091,7 @@ int gfunctionKillsDistCTWithHostage (int currentIndex, int parentIndex)
Path *current = g_waypoint->GetPath (currentIndex); Path *current = g_waypoint->GetPath (currentIndex);
if (current->flags & FLAG_NOHOSTAGE) if (current->flags & FLAG_NOHOSTAGE)
return 65536; return 65355;
else if (current->flags & (FLAG_CROUCH | FLAG_LADDER)) else if (current->flags & (FLAG_CROUCH | FLAG_LADDER))
return gfunctionKillsDistCT (currentIndex, parentIndex) * 500; return gfunctionKillsDistCT (currentIndex, parentIndex) * 500;
@ -1192,38 +1192,38 @@ int gfunctionPathDistWithHostage (int currentIndex, int parentIndex)
return gfunctionPathDist (currentIndex, parentIndex); return gfunctionPathDist (currentIndex, parentIndex);
} }
int hfunctionSquareDist (int startIndex, int goalIndex) int hfunctionSquareDist (int index, int, int goalIndex)
{ {
// square distance heuristic // square distance heuristic
Path *start = g_waypoint->GetPath (startIndex); Path *start = g_waypoint->GetPath (index);
Path *goal = g_waypoint->GetPath (goalIndex); Path *goal = g_waypoint->GetPath (goalIndex);
float deltaX = fabsf (goal->origin.x - start->origin.x); float deltaX = fabsf (start->origin.x - goal->origin.x);
float deltaY = fabsf (goal->origin.y - start->origin.y); float deltaY = fabsf (start->origin.y - goal->origin.y);
float deltaZ = fabsf (goal->origin.z - start->origin.z); float deltaZ = fabsf (start->origin.z - goal->origin.z);
return static_cast <int> (deltaX + deltaY + deltaZ); return static_cast <int> (deltaX + deltaY + deltaZ);
} }
int hfunctionSquareDistWithHostage (int startIndex, int goalIndex) int hfunctionSquareDistWithHostage (int index, int startIndex, int goalIndex)
{ {
// square distance heuristic with hostages // square distance heuristic with hostages
if (g_waypoint->GetPath (startIndex)->flags & FLAG_NOHOSTAGE) if (g_waypoint->GetPath (startIndex)->flags & FLAG_NOHOSTAGE)
return 65536; return 65536;
return hfunctionSquareDist (startIndex, goalIndex); return hfunctionSquareDist (index, startIndex, goalIndex);
} }
int hfunctionNone (int startIndex, int goalIndex) int hfunctionNone (int index, int startIndex, int goalIndex)
{ {
return hfunctionSquareDist (startIndex, goalIndex) / (128 * 10); return hfunctionSquareDist (index, startIndex, goalIndex) / (128 * 10);
} }
int hfunctionNumberNodes (int startIndex, int goalIndex) int hfunctionNumberNodes (int index, int startIndex, int goalIndex)
{ {
return hfunctionSquareDist (startIndex, goalIndex) / 128 * g_highestKills; return hfunctionSquareDist (index, startIndex, goalIndex) / 128 * g_highestKills;
} }
@ -1270,7 +1270,7 @@ void Bot::FindPath (int srcIndex, int destIndex, unsigned char pathType)
} }
int (*gcalc) (int, int) = NULL; int (*gcalc) (int, int) = NULL;
int (*hcalc) (int, int) = NULL; int (*hcalc) (int, int, int) = NULL;
switch (pathType) switch (pathType)
{ {
@ -1326,7 +1326,7 @@ void Bot::FindPath (int srcIndex, int destIndex, unsigned char pathType)
// put start node into open list // put start node into open list
astar[srcIndex].g = gcalc (srcIndex, -1); astar[srcIndex].g = gcalc (srcIndex, -1);
astar[srcIndex].f = astar[srcIndex].g + hcalc (srcIndex, destIndex); astar[srcIndex].f = astar[srcIndex].g + hcalc (srcIndex, srcIndex, destIndex);
astar[srcIndex].state = OPEN; astar[srcIndex].state = OPEN;
openList.Insert (srcIndex, astar[srcIndex].g); openList.Insert (srcIndex, astar[srcIndex].g);
@ -1374,7 +1374,7 @@ void Bot::FindPath (int srcIndex, int destIndex, unsigned char pathType)
// calculate the F value as F = G + H // calculate the F value as F = G + H
int g = astar[currentIndex].g + gcalc (currentChild, currentIndex); int g = astar[currentIndex].g + gcalc (currentChild, currentIndex);
int h = hcalc (srcIndex, destIndex); int h = hcalc (currentChild, srcIndex, destIndex);
int f = g + h; int f = g + h;
if (astar[currentChild].state == NEW || astar[currentChild].f > f) if (astar[currentChild].state == NEW || astar[currentChild].f > f)
@ -1989,7 +1989,7 @@ bool Bot::HeadTowardWaypoint (void)
m_campButtons = 0; m_campButtons = 0;
int waypoint = m_navNode->next->index; int waypoint = m_navNode->next->index;
int kills = 0; float kills = 0;
if (GetTeam (GetEntity ()) == TEAM_TF) if (GetTeam (GetEntity ()) == TEAM_TF)
kills = (g_experienceData + (waypoint * g_numWaypoints) + waypoint)->team0Damage / g_highestDamageT; kills = (g_experienceData + (waypoint * g_numWaypoints) + waypoint)->team0Damage / g_highestDamageT;
@ -2010,7 +2010,7 @@ bool Bot::HeadTowardWaypoint (void)
break; break;
} }
if (m_baseAgressionLevel < static_cast <float> (kills) && GetTaskId () != TASK_MOVETOPOSITION && HasPrimaryWeapon ()) if (m_baseAgressionLevel < kills && GetTaskId () != TASK_MOVETOPOSITION && HasPrimaryWeapon ())
{ {
StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + (m_fearLevel * (g_timeRoundMid - GetWorldTime ()) * 0.5), true); // push camp task on to stack StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + (m_fearLevel * (g_timeRoundMid - GetWorldTime ()) * 0.5), true); // push camp task on to stack