Local variable reassigned prior to reading

Local variable is reassigned in all paths prior to being read.
This commit is contained in:
Wolverine 2017-08-24 13:38:39 -06:00 committed by MadMax
parent 38ab864468
commit 021aa8cfac
23 changed files with 59 additions and 91 deletions

View File

@ -1171,7 +1171,7 @@ bool ChatHandler::HandleModifyMountCommand(char* args)
if (!*args)
{ return false; }
uint16 mId = 1147;
uint16 mId;
float speed = (float)15;
uint32 num = atoi(args);
switch (num)

View File

@ -1976,12 +1976,9 @@ bool ChatHandler::HandleNpcSpawnDistCommand(char* args)
{ mtype = RANDOM_MOTION_TYPE; }
Creature* pCreature = getSelectedCreature();
uint32 u_guidlow = 0;
if (pCreature)
{ u_guidlow = pCreature->GetGUIDLow(); }
else
{ return false; }
if (!pCreature)
{ return false; }
pCreature->SetRespawnRadius((float)option);
pCreature->SetDefaultMovementType(mtype);
@ -1992,7 +1989,7 @@ bool ChatHandler::HandleNpcSpawnDistCommand(char* args)
pCreature->Respawn();
}
WorldDatabase.PExecuteLog("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u", option, mtype, u_guidlow);
WorldDatabase.PExecuteLog("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u", option, mtype, pCreature->GetGUIDLow());
PSendSysMessage(LANG_COMMAND_SPAWNDIST, option);
return true;
}
@ -2339,10 +2336,10 @@ bool ChatHandler::HandlePInfoCommand(char* args)
if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name))
{ return false; }
uint32 accId = 0;
uint32 money = 0;
uint32 total_player_time = 0;
uint32 level = 0;
uint32 accId;
uint32 money;
uint32 total_player_time;
uint32 level;
uint32 latency = 0;
// get additional information from Player object
@ -2910,7 +2907,7 @@ bool ChatHandler::HandleWpAddCommand(char* args)
WaypointPathOrigin wpDestination = PATH_NO_PATH; ///< into which storage
int32 wpPathId = 0; ///< along which path
uint32 wpPointId = 0; ///< pointId if a waypoint was selected, in this case insert after
Creature* wpOwner = NULL;
Creature* wpOwner;
if (targetCreature)
{
@ -3104,7 +3101,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
// Did user provide a GUID or did the user select a creature?
Creature* targetCreature = getSelectedCreature(); // Expect a visual waypoint to be selected
Creature* wpOwner = NULL; // Who moves along the waypoint
Creature* wpOwner; // Who moves along the waypoint
uint32 wpId = 0;
WaypointPathOrigin wpSource = PATH_NO_PATH;
int32 wpPathId = 0;
@ -3357,7 +3354,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
}
}
Creature* wpOwner = NULL; ///< Npc that is moving
Creature* wpOwner; ///< Npc that is moving
TemporarySummonWaypoint* wpTarget = NULL; // Define here for wp-info command
// Show info for the selected waypoint (Step one: get moving npc)
@ -3508,7 +3505,7 @@ bool ChatHandler::HandleWpExportCommand(char* args)
if (!*args)
return false;
Creature* wpOwner = NULL;
Creature* wpOwner;
WaypointPathOrigin wpOrigin = PATH_NO_PATH;
int32 wpPathId = 0;

View File

@ -5677,7 +5677,7 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/)
case CHASE_MOTION_TYPE:
{
Unit* target = NULL;
Unit* target;
if (unit->GetTypeId() == TYPEID_PLAYER)
{ target = static_cast<ChaseMovementGenerator<Player> const*>(*itr)->GetTarget(); }
else
@ -5693,7 +5693,7 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/)
}
case FOLLOW_MOTION_TYPE:
{
Unit* target = NULL;
Unit* target;
if (unit->GetTypeId() == TYPEID_PLAYER)
{ target = static_cast<FollowMovementGenerator<Player> const*>(*itr)->GetTarget(); }
else
@ -5770,7 +5770,7 @@ bool ChatHandler::HandleServerPLimitCommand(char* args)
uint32 pLimit = sWorld.GetPlayerAmountLimit();
AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit();
char const* secName = "";
char const* secName;
switch (allowedAccountType)
{
case SEC_PLAYER: secName = "Player"; break;

View File

@ -409,7 +409,7 @@ void PathFinder::BuildPointPath(const float* startPoint, const float* endPoint)
{
float pathPoints[MAX_POINT_PATH_LENGTH * VERTEX_SIZE];
uint32 pointCount = 0;
dtStatus dtResult = DT_FAILURE;
dtStatus dtResult;
if (m_useStraightPath)
{
dtResult = m_navMeshQuery->findStraightPath(

View File

@ -988,7 +988,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
case ACTION_T_SUMMON_UNIQUE: //49
{
Creature* pCreature = NULL;
Creature* pCreature;
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_creature, action.summon_unique.creatureId, true, false, 100, true);
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pCreature, u_check);

View File

@ -1313,7 +1313,7 @@ namespace MaNGOS
: i_object(obj), i_msgtype(msgtype), i_textData(textData), i_language(language), i_target(target) {}
void operator()(WorldPacket& data, int32 loc_idx)
{
char const* text = NULL;
char const* text;
if ((int32)i_textData->Content.size() > loc_idx + 1 && !i_textData->Content[loc_idx + 1].empty())
{ text = i_textData->Content[loc_idx + 1].c_str(); }
else

View File

@ -13505,13 +13505,7 @@ void Player::TalkedToCreature(uint32 entry, ObjectGuid guid)
// skip spell casts and Gameobject objectives
if (qInfo->ReqSpell[j] > 0 || qInfo->ReqCreatureOrGOId[j] < 0)
{ continue; }
uint32 reqTarget = 0;
if (qInfo->ReqCreatureOrGOId[j] > 0) // creature activate objectives
// checked at quest_template loading
{ reqTarget = qInfo->ReqCreatureOrGOId[j]; }
else
uint32 reqTarget = qInfo->ReqCreatureOrGOId[j];
{ continue; }
if (reqTarget == entry)
@ -17059,13 +17053,12 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
uint32 totalcost = 0;
uint32 prevnode = sourcenode;
uint32 lastnode = 0;
for (uint32 i = 1; i < nodes.size(); ++i)
{
uint32 path, cost;
lastnode = nodes[i];
uint32 lastnode = nodes[i];
sObjectMgr.GetTaxiPath(prevnode, lastnode, path, cost);
if (!path)
@ -17162,7 +17155,6 @@ void Player::ContinueTaxiFlight()
TaxiPathNodeList const& nodeList = sTaxiPathNodesByPath[path];
float distPrev = MAP_SIZE * MAP_SIZE;
float distNext =
(nodeList[0].x - GetPositionX()) * (nodeList[0].x - GetPositionX()) +
(nodeList[0].y - GetPositionY()) * (nodeList[0].y - GetPositionY()) +
@ -17177,7 +17169,7 @@ void Player::ContinueTaxiFlight()
if (node.mapid != GetMapId())
{ continue; }
distPrev = distNext;
float distPrev = distNext;
distNext =
(node.x - GetPositionX()) * (node.x - GetPositionX()) +

View File

@ -332,9 +332,6 @@ PlayerSocial* SocialMgr::LoadFromDB(QueryResult* result, ObjectGuid guid)
if (!result)
{ return social; }
uint32 friend_guid = 0;
uint32 flags = 0;
// used to speed up check below. Using GetNumberOfSocialsWithFlag will cause unneeded iteration
uint32 friendCounter = 0, ignoreCounter = 0;
@ -342,8 +339,8 @@ PlayerSocial* SocialMgr::LoadFromDB(QueryResult* result, ObjectGuid guid)
{
Field* fields = result->Fetch();
friend_guid = fields[0].GetUInt32();
flags = fields[1].GetUInt32();
uint32 friend_guid = fields[0].GetUInt32();
uint32 flags = fields[1].GetUInt32();
if ((flags & SOCIAL_FLAG_IGNORED) && ignoreCounter >= SOCIALMGR_IGNORE_LIMIT)
{ continue; }

View File

@ -1619,7 +1619,6 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* damageInfo, Weapo
damageInfo->HitInfo |= HITINFO_GLANCING;
damageInfo->TargetState = VICTIMSTATE_NORMAL;
damageInfo->procEx |= PROC_EX_NORMAL_HIT;
float reducePercent = 1.0f; // damage factor
// calculate base values and mods
float baseLowEnd = 1.3f;
float baseHighEnd = 1.2f;
@ -1662,7 +1661,7 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* damageInfo, Weapo
if (lowEnd > highEnd) // prevent negative range size
{ lowEnd = highEnd; }
reducePercent = lowEnd + rand_norm_f() * (highEnd - lowEnd);
float reducePercent = lowEnd + rand_norm_f() * (highEnd - lowEnd);
damageInfo->cleanDamage += damageInfo->damage - uint32(reducePercent * damageInfo->damage);
damageInfo->damage = uint32(reducePercent * damageInfo->damage);
@ -1865,7 +1864,6 @@ void Unit::HandleEmote(uint32 emote_id)
uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage)
{
uint32 newdamage = 0;
float armor = (float)pVictim->GetArmor();
// Ignore enemy armor by SPELL_AURA_MOD_TARGET_RESISTANCE aura
@ -1884,7 +1882,7 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage)
if (tmpvalue > 0.75f)
{ tmpvalue = 0.75f; }
newdamage = uint32(damage - (damage * tmpvalue));
uint32 newdamage = uint32(damage - (damage * tmpvalue));
return (newdamage > 1) ? newdamage : 1;
}
@ -2944,7 +2942,7 @@ float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit* pVict
uint32 Unit::GetWeaponSkillValue(WeaponAttackType attType, Unit const* target) const
{
uint32 value = 0;
uint32 value;
if (GetTypeId() == TYPEID_PLAYER)
{
Item* item = ((Player*)this)->GetWeaponForAttack(attType, true, true);
@ -6621,8 +6619,6 @@ bool Unit::IsTargetableForAttack(bool inverseAlive /*=false*/) const
int32 Unit::ModifyHealth(int32 dVal)
{
int32 gain = 0;
if (dVal == 0)
{ return 0; }
@ -6637,7 +6633,8 @@ int32 Unit::ModifyHealth(int32 dVal)
int32 maxHealth = (int32)GetMaxHealth();
if (val < maxHealth)
int32 gain;
if (val < maxHealth)
{
SetHealth(val);
gain = val - curHealth;
@ -6653,8 +6650,6 @@ int32 Unit::ModifyHealth(int32 dVal)
int32 Unit::ModifyPower(Powers power, int32 dVal)
{
int32 gain = 0;
if (dVal == 0)
{ return 0; }
@ -6669,6 +6664,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
int32 maxPower = (int32)GetMaxPower(power);
int32 gain;
if (val < maxPower)
{
SetPower(power, val);
@ -7610,7 +7606,7 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f
return false;
}
float val = 1.0f;
float val;
switch (modifierType)
{

View File

@ -153,7 +153,7 @@ void OutdoorPvPEP::HandleGameObjectCreate(GameObject* go)
void OutdoorPvPEP::HandleObjectiveComplete(uint32 eventId, const std::list<Player*> &players, Team team)
{
uint32 credit = 0;
uint32 credit;
switch (eventId)
{

View File

@ -282,7 +282,7 @@ void StoreGUID(QueryResult* result, uint32 data, uint32 field, std::set<uint32>&
void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char const* tableFrom, char const* tableTo, DumpTableType type)
{
GUIDs const* guids = NULL;
char const* fieldname = NULL;
char const* fieldname;
switch (type)
{
@ -420,7 +420,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
if (!fin)
{ return DUMP_FILE_OPEN_ERROR; }
QueryResult* result = NULL;
QueryResult* result;
char newguid[20], chraccount[20], newpetid[20], currpetid[20], lastpetid[20];
// make sure the same guid doesn't already exist and is safe to use

View File

@ -2013,8 +2013,6 @@ void Group::RewardGroupAtKill(Unit* pVictim, Player* player_tap)
bool PvP = pVictim->IsCharmedOwnedByPlayerOrPlayer();
// prepare data for near group iteration (PvP and !PvP cases)
uint32 xp = 0;
uint32 count = 0;
uint32 sum_level = 0;
Player* member_with_max_level = NULL;
@ -2025,7 +2023,7 @@ void Group::RewardGroupAtKill(Unit* pVictim, Player* player_tap)
if (member_with_max_level)
{
/// not get Xp in PvP or no not gray players in group
xp = (PvP || !not_gray_member_with_max_level) ? 0 : MaNGOS::XP::Gain(not_gray_member_with_max_level, pVictim);
uint32 xp = (PvP || !not_gray_member_with_max_level) ? 0 : MaNGOS::XP::Gain(not_gray_member_with_max_level, pVictim);
/// skip in check PvP case (for speed, not used)
bool is_raid = PvP ? false : sMapStore.LookupEntry(pVictim->GetMapId())->IsRaid() && isRaidGroup();

View File

@ -2306,7 +2306,7 @@ bool Map::GetReachableRandomPointOnGround(float& x, float& y, float& z, float ra
if (delta > 0.0f) // check to avoid divide by 0
{
// compute slope
slope = atan(ac / delta);
float slope = atan(ac / delta);
if (slope < MAX_SLOPE_IN_RADIAN)
{
x = i_x;

View File

@ -102,13 +102,12 @@ Map* MapManager::CreateMap(uint32 id, const WorldObject* obj)
{
ACE_GUARD_RETURN(LOCK_TYPE, _guard, m_lock, NULL)
Map* m = NULL;
const MapEntry* entry = sMapStore.LookupEntry(id);
if (!entry)
{ return NULL; }
if (entry->Instanceable())
Map* m;
if (entry->Instanceable())
{
MANGOS_ASSERT(obj && obj->GetTypeId() == TYPEID_PLAYER);
// create DungeonMap object
@ -310,7 +309,7 @@ Map* MapManager::CreateInstance(uint32 id, Player* player)
{
Map* map = NULL;
Map* pNewMap = NULL;
uint32 NewInstanceId = 0; // instanceId of the resulting map
uint32 NewInstanceId; // instanceId of the resulting map
const MapEntry* entry = sMapStore.LookupEntry(id);
if (entry->IsBattleGround())

View File

@ -612,8 +612,6 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
for (GuidSet::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr)
{
uint8 dialogStatus = DIALOG_STATUS_NONE;
if (itr->IsAnyTypeCreature())
{
// need also pet quests case support
@ -625,7 +623,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))
{ continue; }
dialogStatus = sScriptMgr.GetDialogStatus(_player, questgiver);
uint8 dialogStatus = sScriptMgr.GetDialogStatus(_player, questgiver);
if (dialogStatus == DIALOG_STATUS_UNDEFINED)
{ dialogStatus = getDialogStatus(_player, questgiver, DIALOG_STATUS_NONE); }
@ -644,7 +642,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
if (questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER)
{ continue; }
dialogStatus = sScriptMgr.GetDialogStatus(_player, questgiver);
uint8 dialogStatus = sScriptMgr.GetDialogStatus(_player, questgiver);
if (dialogStatus == DIALOG_STATUS_UNDEFINED)
{ dialogStatus = getDialogStatus(_player, questgiver, DIALOG_STATUS_NONE); }

View File

@ -353,8 +353,7 @@ void ScriptMgr::LoadScripts(DBScriptType type)
}
case SCRIPT_COMMAND_RESPAWN_GO: // 9
{
uint32 goEntry = 0;
uint32 goEntry;
if (!tmp.GetGOGuid())
{
if (!tmp.buddyEntry)
@ -409,8 +408,7 @@ void ScriptMgr::LoadScripts(DBScriptType type)
case SCRIPT_COMMAND_OPEN_DOOR: // 11
case SCRIPT_COMMAND_CLOSE_DOOR: // 12
{
uint32 goEntry = 0;
uint32 goEntry;
if (!tmp.GetGOGuid())
{
if (!tmp.buddyEntry)
@ -1336,9 +1334,7 @@ bool ScriptAction::HandleScriptStep()
}
case SCRIPT_COMMAND_RESPAWN_GO: // 9
{
GameObject* pGo = NULL;
uint32 time_to_despawn = m_script->respawnGo.despawnDelay < 5 ? 5 : m_script->respawnGo.despawnDelay;
GameObject* pGo;
if (m_script->respawnGo.goGuid)
{
GameObjectData const* goData = sObjectMgr.GetGOData(m_script->respawnGo.goGuid);
@ -1371,6 +1367,8 @@ bool ScriptAction::HandleScriptStep()
if (pGo->isSpawned())
{ break; } // gameobject already spawned
uint32 time_to_despawn = m_script->respawnGo.despawnDelay < 5 ? 5 : m_script->respawnGo.despawnDelay;
pGo->SetLootState(GO_READY);
pGo->SetRespawnTime(time_to_despawn); // despawn object in ? seconds

View File

@ -787,7 +787,7 @@ void Spell::AddUnitTarget(Unit* pVictim, SpellEffectIndex effIndex)
if (speed > 0.0f && affectiveObject && (pVictim != affectiveObject || (m_targets.m_targetMask & (TARGET_FLAG_SOURCE_LOCATION | TARGET_FLAG_DEST_LOCATION))))
{
// calculate spell incoming interval
float dist = 0.0f; // distance to impact
float dist; // distance to impact
if (pVictim == affectiveObject) // Calculate dist to destination target also for self-cast spells
{
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
@ -4951,7 +4951,7 @@ SpellCastResult Spell::CheckCast(bool strict)
}
// get the lock entry
uint32 lockId = 0;
uint32 lockId;
if (GameObject* go = m_targets.getGOTarget())
{
// Prevent opening two times a chest in same time.

View File

@ -1187,8 +1187,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
case 28834: // Mark of Rivendare
case 28835: // Mark of Zeliek
{
int32 damage = 0;
int32 damage;
switch (GetStackAmount())
{
case 1:
@ -2458,8 +2457,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real)
if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
{ return; }
uint32 spell_id = 0;
uint32 spell_id;
switch (GetId())
{
case 19386: spell_id = 24131; break;

View File

@ -436,7 +436,7 @@ WaypointNode const* WaypointManager::AddNode(uint32 entry, uint32 dbGuid, uint32
// Prepare information
char const* const table = wpDest == PATH_FROM_GUID ? "creature_movement" : "creature_movement_template";
char const* const key_field = wpDest == PATH_FROM_GUID ? "id" : "entry";
uint32 const key = wpDest == PATH_FROM_GUID ? dbGuid : ((entry << 8) /*+ pathId*/);
uint32 key = wpDest == PATH_FROM_GUID ? dbGuid : ((entry << 8) /*+ pathId*/);
WaypointPathMap* wpMap = wpDest == PATH_FROM_GUID ? &m_pathMap : &m_pathTemplateMap;
WaypointPath& path = (*wpMap)[key];

View File

@ -1964,7 +1964,7 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_
std::string safe_author = author;
LoginDatabase.escape_string(safe_author);
QueryResult* resultAccounts = NULL; // used for kicking
QueryResult* resultAccounts; // used for kicking
///- Update the database with ban information
switch (mode)

View File

@ -49,8 +49,10 @@ void BIH::subdivide(int left, int right, std::vector<uint32>& tempTree, buildDat
}
// calculate extents
int axis = -1, rightOrig;
float clipL = G3D::fnan(), clipR = G3D::fnan(), prevClip = G3D::fnan();
float split = G3D::fnan();
float clipL;
float clipR;
float prevClip = G3D::fnan();
float split = G3D::fnan();
bool wasLeft = true;
while (true)
{

View File

@ -180,7 +180,6 @@ namespace VMAP
bool StaticMapTree::getObjectHitPos(const Vector3& pPos1, const Vector3& pPos2, Vector3& pResultHitPos, float pModifyDist) const
{
bool result = false;
float maxDist = (pPos2 - pPos1).magnitude();
// valid map coords should *never ever* produce float overflow, but this would produce NaNs too:
MANGOS_ASSERT(maxDist < std::numeric_limits<float>::max());
@ -211,14 +210,9 @@ namespace VMAP
{
pResultHitPos = pResultHitPos + dir * pModifyDist;
}
result = true;
}
else
{
pResultHitPos = pPos2;
result = false;
}
return result;
pResultHitPos = pPos2;
return false;
}
//=========================================================

View File

@ -216,14 +216,13 @@ namespace VMAP
return false;
}
printf("Read coordinate mapping...\n");
uint32 mapID, tileX, tileY, check = 0;
uint32 mapID, tileX, tileY;
G3D::Vector3 v1, v2;
ModelSpawn spawn;
while (!feof(dirf))
{
check = 0;
// read mapID, tileX, tileY, Flags, adtID, ID, Pos, Rot, Scale, Bound_lo, Bound_hi, name
check += fread(&mapID, sizeof(uint32), 1, dirf);
uint32 check = fread(&mapID, sizeof(uint32), 1, dirf);
if (check == 0) // EoF...
{ break; }
check += fread(&tileX, sizeof(uint32), 1, dirf);