From f3e583e0578ca9fd287f3024a22af3630044dd96 Mon Sep 17 00:00:00 2001 From: jeefo Date: Mon, 3 Aug 2015 12:36:57 +0300 Subject: [PATCH] another crash bug fix some code style fixes --- source/basecode.cpp | 6 +++--- source/combat.cpp | 2 +- source/waypoint.cpp | 13 ++++++------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/source/basecode.cpp b/source/basecode.cpp index 0ff0e5a..6f8f55c 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -5411,13 +5411,13 @@ void Bot::CollectExperienceData (edict_t *attacker, int damage) (g_experienceData + (victimIndex * g_numWaypoints) + victimIndex)->team1Damage = MAX_DAMAGE_VALUE; } - float fUpdate = IsValidBot (attacker) ? 10.0 : 7.0; + float updateDamage = IsValidBot (attacker) ? 10.0 : 7.0; // store away the damage done if (victimTeam == TEAM_TF) { int value = (g_experienceData + (victimIndex * g_numWaypoints) + attackerIndex)->team0Damage; - value += static_cast (damage / fUpdate); + value += static_cast (damage / updateDamage); if (value > MAX_DAMAGE_VALUE) value = MAX_DAMAGE_VALUE; @@ -5430,7 +5430,7 @@ void Bot::CollectExperienceData (edict_t *attacker, int damage) else { int value = (g_experienceData + (victimIndex * g_numWaypoints) + attackerIndex)->team1Damage; - value += static_cast (damage / fUpdate); + value += static_cast (damage / updateDamage); if (value > MAX_DAMAGE_VALUE) value = MAX_DAMAGE_VALUE; diff --git a/source/combat.cpp b/source/combat.cpp index 40995b4..5974712 100644 --- a/source/combat.cpp +++ b/source/combat.cpp @@ -1673,7 +1673,7 @@ void Bot::CheckReload (void) break; } - if (m_ammoInClip[weaponIndex] < (maxClip * 0.8) && m_ammo[g_weaponDefs[weaponIndex].ammo1] > 0) + if (m_ammoInClip[weaponIndex] < (maxClip * 0.8) && g_weaponDefs[m_currentWeapon].ammo1 != -1 && g_weaponDefs[m_currentWeapon].ammo1 < 32 && m_ammo[g_weaponDefs[weaponIndex].ammo1] > 0) { if (m_currentWeapon != weaponIndex) SelectWeaponByName (g_weaponDefs[weaponIndex].className); diff --git a/source/waypoint.cpp b/source/waypoint.cpp index 01a0ea8..76d3f5a 100644 --- a/source/waypoint.cpp +++ b/source/waypoint.cpp @@ -2016,11 +2016,12 @@ bool Waypoint::NodesValid (void) if (visited[outgoingPaths[current->index][p]]) continue; // skip this waypoint as it's already visited - PathNode *pNewNode = new PathNode; + PathNode *newNode = new PathNode; - pNewNode->next = stack; - pNewNode->index = outgoingPaths[current->index][p]; - stack = pNewNode; + newNode->next = stack; + newNode->index = outgoingPaths[current->index][p]; + + stack = newNode; } delete current; } @@ -2566,9 +2567,7 @@ WaypointDownloadError WaypointDownloader::DoDownload (void) timeout.tv_sec = 5; timeout.tv_usec = 0; - int result = 0; - - result = setsockopt (socketHandle, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof (timeout)); + int result = setsockopt (socketHandle, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof (timeout)); if (result < 0) {