From 68cb3f1724dd53b72b22dfcb84d741aa898b1e55 Mon Sep 17 00:00:00 2001 From: AlexDereka Date: Sun, 26 Apr 2009 18:49:00 +0400 Subject: [PATCH] [7716] Fixed some typos and possible crashes. --- src/game/AchievementMgr.cpp | 22 ++-- src/game/BattleGroundHandler.cpp | 8 +- src/game/BattleGroundMgr.cpp | 23 ++-- src/game/Channel.cpp | 14 ++- src/game/CreatureEventAI.cpp | 6 +- src/game/GameEventMgr.cpp | 12 +- src/game/Group.cpp | 4 +- src/game/GuildHandler.cpp | 2 +- src/game/InstanceSaveMgr.cpp | 16 +-- src/game/ItemHandler.cpp | 2 +- src/game/Level2.cpp | 4 +- src/game/MapInstanced.cpp | 2 +- src/game/MiscHandler.cpp | 5 +- src/game/ObjectMgr.cpp | 26 ++--- src/game/Pet.cpp | 18 +-- src/game/PetHandler.cpp | 17 ++- src/game/PetitionsHandler.cpp | 8 +- src/game/Player.cpp | 229 +++++++++++++++++++-------------------- src/game/SpellAuras.cpp | 5 +- src/game/SpellEffects.cpp | 37 ++++--- src/game/SpellMgr.h | 12 +- src/game/Unit.cpp | 12 +- src/game/debugcmds.cpp | 40 +++---- src/shared/ServiceWin32.cpp | 6 +- src/shared/revision_nr.h | 2 +- 25 files changed, 275 insertions(+), 257 deletions(-) diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index 03083a60..f3a352c6 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -720,12 +720,12 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // skip wrong arena achievements, if not achievIdByArenaSlot then normal total death counter bool notfit = false; - for(int i = 0; i < MAX_ARENA_SLOT; ++i) + for(int j = 0; j < MAX_ARENA_SLOT; ++j) { - if(achievIdByArenaSlot[i] == achievement->ID) + if(achievIdByArenaSlot[j] == achievement->ID) { BattleGround* bg = GetPlayer()->GetBattleGround(); - if(!bg || !bg->isArena() || ArenaTeam::GetSlotByType(bg->GetArenaType()) != i) + if(!bg || !bg->isArena() || ArenaTeam::GetSlotByType(bg->GetArenaType()) != j) notfit = true; break; @@ -749,26 +749,26 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui // search case bool found = false; - for(int i = 0; achievIdForDangeon[i][0]; ++i) + for(int j = 0; achievIdForDangeon[j][0]; ++j) { - if(achievIdForDangeon[i][0] == achievement->ID) + if(achievIdForDangeon[j][0] == achievement->ID) { if(map->IsRaid()) { // if raid accepted (ignore difficulty) - if(!achievIdForDangeon[i][2]) + if(!achievIdForDangeon[j][2]) break; // for } else if(GetPlayer()->GetDifficulty()==DIFFICULTY_NORMAL) { // dungeon in normal mode accepted - if(!achievIdForDangeon[i][1]) + if(!achievIdForDangeon[j][1]) break; // for } else { // dungeon in heroic mode accepted - if(!achievIdForDangeon[i][3]) + if(!achievIdForDangeon[j][3]) break; // for } @@ -890,9 +890,9 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui break; bool matchFound = false; - for (int i = 0; i < 3; ++i) + for (int j = 0; j < 3; ++j) { - int32 exploreFlag = GetAreaFlagByAreaID(worldOverlayEntry->areatableID[i]); + int32 exploreFlag = GetAreaFlagByAreaID(worldOverlayEntry->areatableID[j]); if(exploreFlag < 0) break; @@ -1392,7 +1392,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry, { progress = &iter->second; - uint32 newValue; + uint32 newValue = 0; switch(ptype) { case PROGRESS_SET: diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index 06435bd3..f5cf3bf4 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -110,9 +110,9 @@ void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data ) return; // get bg instance or bg template if instance not found - BattleGround * bg = NULL; + BattleGround *bg = NULL; if (instanceId) - BattleGround *bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId)); + bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId)); if (!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId))) { @@ -357,7 +357,7 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data ) else { // get the bg we're invited to - BattleGround * bg = sBattleGroundMgr.GetBattleGround(itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID, bgTypeId); + bg = sBattleGroundMgr.GetBattleGround(itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID, bgTypeId); status = STATUS_WAIT_JOIN; } @@ -571,7 +571,7 @@ void WorldSession::HandleBattlefieldStatusOpcode( WorldPacket & /*recv_data*/ ) } else { - BattleGround *bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); + bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); if (!bg) continue; uint32 avgTime = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].GetAverageQueueWaitTime(itrPlayerStatus->second.GroupInfo, _player->GetBattleGroundQueueIdFromLevel(bgTypeId)); diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index 4f62ebc9..098b7557 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -761,10 +761,10 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve FillPlayersToBG(bg, queue_id); // now everything is set, invite players - for(GroupsQueueType::const_iterator itr = m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.begin(); itr != m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.end(); ++itr) - InviteGroupToBG((*itr), bg, (*itr)->Team); - for(GroupsQueueType::const_iterator itr = m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.begin(); itr != m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.end(); ++itr) - InviteGroupToBG((*itr), bg, (*itr)->Team); + for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.end(); ++citr) + InviteGroupToBG((*citr), bg, (*citr)->Team); + for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.end(); ++citr) + InviteGroupToBG((*citr), bg, (*citr)->Team); if (!bg->HasFreeSlots()) { @@ -834,8 +834,8 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve } //invite those selection pools for(uint32 i = 0; i < BG_TEAMS_COUNT; i++) - for(GroupsQueueType::const_iterator itr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); itr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++itr) - InviteGroupToBG((*itr), bg2, (*itr)->Team); + for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr) + InviteGroupToBG((*citr), bg2, (*citr)->Team); //start bg bg2->StartBattleGround(); //clear structures @@ -861,8 +861,8 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve // invite those selection pools for(uint32 i = 0; i < BG_TEAMS_COUNT; i++) - for(GroupsQueueType::const_iterator itr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); itr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++itr) - InviteGroupToBG((*itr), bg2, (*itr)->Team); + for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr) + InviteGroupToBG((*citr), bg2, (*citr)->Team); // start bg bg2->StartBattleGround(); } @@ -1824,10 +1824,11 @@ void BattleGroundMgr::DistributeArenaPoints() void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint64& guid, Player* plr, BattleGroundTypeId bgTypeId) { - uint32 PlayerLevel = 10; + if (!plr) + return; - if (plr) - PlayerLevel = plr->getLevel(); + uint32 PlayerLevel = 10; + PlayerLevel = plr->getLevel(); data->Initialize(SMSG_BATTLEFIELD_LIST); *data << uint64(guid); // battlemaster guid diff --git a/src/game/Channel.cpp b/src/game/Channel.cpp index c38c5592..f5710b9f 100644 --- a/src/game/Channel.cpp +++ b/src/game/Channel.cpp @@ -298,10 +298,11 @@ void Channel::Password(uint64 p, const char *pass) void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) { - uint32 sec = 0; Player *plr = objmgr.GetPlayer(p); - if(plr) - sec = plr->GetSession()->GetSecurity(); + if (!plr) + return; + + uint32 sec = plr->GetSession()->GetSecurity(); if(!IsOn(p)) { @@ -366,10 +367,11 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) void Channel::SetOwner(uint64 p, const char *newname) { - uint32 sec = 0; Player *plr = objmgr.GetPlayer(p); - if(plr) - sec = plr->GetSession()->GetSecurity(); + if (!plr) + return; + + uint32 sec = plr->GetSession()->GetSecurity(); if(!IsOn(p)) { diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 3717f674..bf898664 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -622,7 +622,7 @@ void CreatureEventAI::ProcessAction(uint16 type, uint32 param1, uint32 param2, u } //Allowed to cast only if not casting (unless we interrupt ourself) or if spell is triggered - bool canCast = !(caster->IsNonMeleeSpellCasted(false) && (param3 & CAST_TRIGGERED | CAST_INTURRUPT_PREVIOUS)); + bool canCast = !(caster->IsNonMeleeSpellCasted(false) && (param3 & (CAST_TRIGGERED | CAST_INTURRUPT_PREVIOUS))); // If cast flag CAST_AURA_NOT_PRESENT is active, check if target already has aura on them if(param3 & CAST_AURA_NOT_PRESENT) @@ -912,8 +912,8 @@ void CreatureEventAI::ProcessAction(uint16 type, uint32 param1, uint32 param2, u //if not available, use pActionInvoker if (Unit* pTarget = GetTargetByType(param2, pActionInvoker)) { - if (Player* pPlayer = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself()) - pPlayer->RewardPlayerAndGroupAtEvent(param1, m_creature); + if (Player* pPlayer2 = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself()) + pPlayer2->RewardPlayerAndGroupAtEvent(param1, m_creature); } } } diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp index e2b7386a..2ad481e8 100644 --- a/src/game/GameEventMgr.cpp +++ b/src/game/GameEventMgr.cpp @@ -683,17 +683,17 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate) } else // If not spawned { - CreatureData const* data = objmgr.GetCreatureData(itr->first); - if (data && activate) + CreatureData const* data2 = objmgr.GetCreatureData(itr->first); + if (data2 && activate) { - CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(data->id); - uint32 display_id = objmgr.ChooseDisplayId(0,cinfo,data); + CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(data2->id); + uint32 display_id = objmgr.ChooseDisplayId(0,cinfo,data2); CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id); if (minfo) display_id = minfo->modelid; - if (data->equipmentId == 0) + if (data2->equipmentId == 0) itr->second.equipement_id_prev = cinfo->equipmentId; - else if (data->equipmentId != -1) + else if (data2->equipmentId != -1) itr->second.equipement_id_prev = data->equipmentId; itr->second.modelid_prev = display_id; } diff --git a/src/game/Group.cpp b/src/game/Group.cpp index e6e01aa1..c2e81576 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -70,8 +70,8 @@ Group::~Group() // will be unloaded first so we must be prepared for both cases // this may unload some instance saves for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) - for(BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) - itr->second.save->RemoveGroup(this); + for(BoundInstancesMap::iterator itr2 = m_boundInstances[i].begin(); itr2 != m_boundInstances[i].end(); ++itr2) + itr2->second.save->RemoveGroup(this); // Sub group counters clean up if (m_subGroupsCounts) diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp index 934a77b7..607d469a 100644 --- a/src/game/GuildHandler.cpp +++ b/src/game/GuildHandler.cpp @@ -1193,7 +1193,7 @@ void WorldSession::HandleGuildBankDepositItem( WorldPacket & recv_data ) else // swap { gDest.clear(); - uint8 msg = pGuild->CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(),pItemSrc,true); + msg = pGuild->CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(),pItemSrc,true); if( msg != EQUIP_ERR_OK ) { pl->SendEquipError( msg, pItemSrc, NULL ); diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp index f3fb36a6..223620d8 100644 --- a/src/game/InstanceSaveMgr.cpp +++ b/src/game/InstanceSaveMgr.cpp @@ -52,16 +52,16 @@ InstanceSaveManager::~InstanceSaveManager() for (InstanceSaveHashMap::iterator itr = m_instanceSaveById.begin(); itr != m_instanceSaveById.end(); ++itr) { InstanceSave *save = itr->second; - for(InstanceSave::PlayerListType::iterator itr = save->m_playerList.begin(), next = itr; itr != save->m_playerList.end(); itr = next) + for(InstanceSave::PlayerListType::iterator itr2 = save->m_playerList.begin(), next = itr2; itr2 != save->m_playerList.end(); itr2 = next) { ++next; - (*itr)->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true); + (*itr2)->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true); } save->m_playerList.clear(); - for(InstanceSave::GroupListType::iterator itr = save->m_groupList.begin(), next = itr; itr != save->m_groupList.end(); itr = next) + for(InstanceSave::GroupListType::iterator itr2 = save->m_groupList.begin(), next = itr2; itr2 != save->m_groupList.end(); itr2 = next) { ++next; - (*itr)->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true); + (*itr2)->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true); } save->m_groupList.clear(); delete save; @@ -617,10 +617,10 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeLe MapInstanced::InstancedMaps::iterator mitr; for(mitr = instMaps.begin(); mitr != instMaps.end(); ++mitr) { - Map *map = mitr->second; - if(!map->IsDungeon()) continue; - if(warn) ((InstanceMap*)map)->SendResetWarnings(timeLeft); - else ((InstanceMap*)map)->Reset(INSTANCE_RESET_GLOBAL); + Map *map2 = mitr->second; + if(!map2->IsDungeon()) continue; + if(warn) ((InstanceMap*)map2)->SendResetWarnings(timeLeft); + else ((InstanceMap*)map2)->Reset(INSTANCE_RESET_GLOBAL); } // TODO: delete creature/gameobject respawn times even if the maps are not loaded diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index 1c982fc1..ee629649 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -199,7 +199,7 @@ void WorldSession::HandleAutoEquipItemOpcode( WorldPacket & recv_data ) // check dest->src move possibility ItemPosCountVec sSrc; - uint16 eSrc; + uint16 eSrc = 0; if( _player->IsInventoryPos( src ) ) { msg = _player->CanStoreItem( srcbag, srcslot, sSrc, pDstItem, true ); diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 1237ef02..cc4117c1 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -553,7 +553,7 @@ bool ChatHandler::HandleGameObjectDeleteCommand(const char* args) if(owner_guid) { Unit* owner = ObjectAccessor::GetUnit(*m_session->GetPlayer(),owner_guid); - if(!owner && !IS_PLAYER_GUID(owner_guid)) + if(!owner || !IS_PLAYER_GUID(owner_guid)) { PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow()); SetSentErrorMessage(true); @@ -1375,7 +1375,7 @@ bool ChatHandler::HandleNpcMoveCommand(const char* args) if(!cId) return false; - uint32 lowguid = atoi(cId); + lowguid = atoi(cId); /* FIXME: impossibel without entry if(lowguid) diff --git a/src/game/MapInstanced.cpp b/src/game/MapInstanced.cpp index a89238ff..e6eaa629 100644 --- a/src/game/MapInstanced.cpp +++ b/src/game/MapInstanced.cpp @@ -208,7 +208,7 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave *save, } // some instances only have one difficulty - if(!entry->SupportsHeroicMode()) difficulty = DIFFICULTY_NORMAL; + if (entry && !entry->SupportsHeroicMode()) difficulty = DIFFICULTY_NORMAL; sLog.outDebug("MapInstanced::CreateInstance: %smap instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal"); diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 59097b3c..cc40850c 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -1380,7 +1380,10 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data ) uint8 spam_type; // 0 - mail, 1 - chat uint64 spammer_guid; - uint32 unk1, unk2, unk3, unk4 = 0; + uint32 unk1 = 0; + uint32 unk2 = 0; + uint32 unk3 = 0; + uint32 unk4 = 0; std::string description = ""; recv_data >> spam_type; // unk 0x01 const, may be spam type (mail/chat) recv_data >> spammer_guid; // player guid diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index af0767a8..fc32e21e 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -600,12 +600,12 @@ void ObjectMgr::LoadCreatureTemplates() sLog.outErrorDb("Creature (Entry: %u) has non-existing PetSpellDataId (%u)", cInfo->Entry, cInfo->PetSpellDataId); } - for(int i = 0; i < CREATURE_MAX_SPELLS; ++i) + for(int j = 0; j < CREATURE_MAX_SPELLS; ++j) { - if(cInfo->spells[i] && !sSpellStore.LookupEntry(cInfo->spells[i])) + if(cInfo->spells[j] && !sSpellStore.LookupEntry(cInfo->spells[j])) { - sLog.outErrorDb("Creature (Entry: %u) has non-existing Spell%d (%u), set to 0", cInfo->Entry, i+1,cInfo->spells[i]); - const_cast(cInfo)->spells[i] = 0; + sLog.outErrorDb("Creature (Entry: %u) has non-existing Spell%d (%u), set to 0", cInfo->Entry, j+1,cInfo->spells[j]); + const_cast(cInfo)->spells[j] = 0; } } @@ -2694,15 +2694,15 @@ void ObjectMgr::LoadGroups() result = CharacterDatabase.Query("SELECT memberGuid, assistant, subgroup, leaderGuid FROM group_member ORDER BY leaderGuid"); if(!result) { - barGoLink bar( 1 ); - bar.step(); + barGoLink bar2( 1 ); + bar2.step(); } else { - barGoLink bar( result->GetRowCount() ); + barGoLink bar2( result->GetRowCount() ); do { - bar.step(); + bar2.step(); Field *fields = result->Fetch(); count++; leaderGuid = MAKE_NEW_GUID(fields[3].GetUInt32(), 0, HIGHGUID_PLAYER); @@ -2754,15 +2754,15 @@ void ObjectMgr::LoadGroups() if(!result) { - barGoLink bar( 1 ); - bar.step(); + barGoLink bar2( 1 ); + bar2.step(); } else { - barGoLink bar( result->GetRowCount() ); + barGoLink bar2( result->GetRowCount() ); do { - bar.step(); + bar2.step(); Field *fields = result->Fetch(); count++; leaderGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); @@ -3149,7 +3149,7 @@ void ObjectMgr::LoadQuests() { sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u but spell %u does not exist, quest can't be done.", qinfo->GetQuestId(),j+1,id,id); - // no changes, quest can't be done for this requirement + continue; } if(!qinfo->ReqCreatureOrGOId[j]) diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 8d22a9a3..38ca2a20 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -339,10 +339,10 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool delete m_declinedname; m_declinedname = new DeclinedName; - Field *fields = result->Fetch(); + Field *fields2 = result->Fetch(); for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) { - m_declinedname->name[i] = fields[i].GetCppString(); + m_declinedname->name[i] = fields2[i].GetCppString(); } } } @@ -1321,19 +1321,19 @@ bool Pet::addSpell(uint32 spell_id, uint16 active, PetSpellState state, PetSpell } else if(uint32 chainstart = spellmgr.GetFirstSpellInChain(spell_id)) { - for (PetSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) + for (PetSpellMap::iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2) { - if(itr->second->state == PETSPELL_REMOVED) continue; + if(itr2->second->state == PETSPELL_REMOVED) continue; - if(spellmgr.GetFirstSpellInChain(itr->first) == chainstart) + if(spellmgr.GetFirstSpellInChain(itr2->first) == chainstart) { - newspell->active = itr->second->active; + newspell->active = itr2->second->active; if(newspell->active == ACT_ENABLED) - ToggleAutocast(itr->first, false); + ToggleAutocast(itr2->first, false); - oldspell_id = itr->first; - unlearnSpell(itr->first); + oldspell_id = itr2->first; + unlearnSpell(itr2->first); break; } } diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index 562b8915..5d2f5d6e 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -194,10 +194,19 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) //auto turn to target unless possessed if(result == SPELL_FAILED_UNIT_NOT_INFRONT && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS)) { - pet->SetInFront(unit_target); - if( unit_target->GetTypeId() == TYPEID_PLAYER ) - pet->SendUpdateToPlayer( (Player*)unit_target ); - if(Unit* powner = pet->GetCharmerOrOwner()) + if(unit_target) + { + pet->SetInFront(unit_target); + if (unit_target->GetTypeId() == TYPEID_PLAYER) + pet->SendUpdateToPlayer( (Player*)unit_target ); + } + else if(Unit *unit_target2 = spell->m_targets.getUnitTarget()) + { + pet->SetInFront(unit_target2); + if (unit_target2->GetTypeId() == TYPEID_PLAYER) + pet->SendUpdateToPlayer( (Player*)unit_target2 ); + } + if (Unit* powner = pet->GetCharmerOrOwner()) if(powner->GetTypeId() == TYPEID_PLAYER) pet->SendUpdateToPlayer((Player*)powner); result = SPELL_CAST_OK; diff --git a/src/game/PetitionsHandler.cpp b/src/game/PetitionsHandler.cpp index 0087253a..2dc05079 100644 --- a/src/game/PetitionsHandler.cpp +++ b/src/game/PetitionsHandler.cpp @@ -279,8 +279,8 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data) for(uint8 i = 1; i <= signs; i++) { - Field *fields = result->Fetch(); - uint64 plguid = fields[0].GetUInt64(); + Field *fields2 = result->Fetch(); + uint64 plguid = fields2[0].GetUInt64(); data << plguid; // Player GUID data << (uint32)0; // there 0 ... @@ -690,8 +690,8 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) for(uint8 i = 1; i <= signs; i++) { - Field *fields = result->Fetch(); - uint64 plguid = fields[0].GetUInt64(); + Field *fields2 = result->Fetch(); + plguid = fields2[0].GetUInt64(); data << plguid; // Player GUID data << (uint32)0; // there 0 ... diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 114786b4..3dc6df4d 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -759,7 +759,7 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 } // if this is ammo then use it - uint8 msg = CanUseAmmo( pItem->GetEntry() ); + msg = CanUseAmmo( pItem->GetEntry() ); if( msg == EQUIP_ERR_OK ) SetAmmo( pItem->GetEntry() ); } @@ -863,8 +863,8 @@ void Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) DEBUG_LOG("We are fall to death, loosing 10 percents durability"); DurabilityLossAll(0.10f,false); // durability lost message - WorldPacket data(SMSG_DURABILITY_DAMAGE_DEATH, 0); - GetSession()->SendPacket(&data); + WorldPacket data2(SMSG_DURABILITY_DAMAGE_DEATH, 0); + GetSession()->SendPacket(&data2); } GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM, 1, type); @@ -2802,22 +2802,22 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen // replace spells in action bars and spellbook to bigger rank if only one spell rank must be accessible if(newspell->active && !newspell->disabled && !SpellMgr::canStackSpellRanks(spellInfo) && spellmgr.GetSpellRank(spellInfo->Id) != 0) { - for( PlayerSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr ) + for( PlayerSpellMap::iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2 ) { - if(itr->second->state == PLAYERSPELL_REMOVED) continue; - SpellEntry const *i_spellInfo = sSpellStore.LookupEntry(itr->first); + if(itr2->second->state == PLAYERSPELL_REMOVED) continue; + SpellEntry const *i_spellInfo = sSpellStore.LookupEntry(itr2->first); if(!i_spellInfo) continue; - if( spellmgr.IsRankSpellDueToSpell(spellInfo,itr->first) ) + if( spellmgr.IsRankSpellDueToSpell(spellInfo,itr2->first) ) { - if(itr->second->active) + if(itr2->second->active) { - if(spellmgr.IsHighRankOfSpell(spell_id,itr->first)) + if(spellmgr.IsHighRankOfSpell(spell_id,itr2->first)) { if(IsInWorld()) // not send spell (re-/over-)learn packets at loading { WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); - data << uint16(itr->first); + data << uint16(itr2->first); data << uint16(spell_id); GetSession()->SendPacket( &data ); } @@ -2828,13 +2828,13 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen itr->second->state = PLAYERSPELL_CHANGED; superceded_old = true; // new spell replace old in action bars and spell book. } - else if(spellmgr.IsHighRankOfSpell(itr->first,spell_id)) + else if(spellmgr.IsHighRankOfSpell(itr2->first,spell_id)) { if(IsInWorld()) // not send spell (re-/over-)learn packets at loading { WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); data << uint16(spell_id); - data << uint16(itr->first); + data << uint16(itr2->first); GetSession()->SendPacket( &data ); } @@ -2947,14 +2947,14 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen SpellLearnSpellMap::const_iterator spell_begin = spellmgr.GetBeginSpellLearnSpell(spell_id); SpellLearnSpellMap::const_iterator spell_end = spellmgr.GetEndSpellLearnSpell(spell_id); - for(SpellLearnSpellMap::const_iterator itr = spell_begin; itr != spell_end; ++itr) + for(SpellLearnSpellMap::const_iterator itr2 = spell_begin; itr2 != spell_end; ++itr2) { - if(!itr->second.autoLearned) + if(!itr2->second.autoLearned) { - if(!IsInWorld() || !itr->second.active) // at spells loading, no output, but allow save - addSpell(itr->second.spell,itr->second.active,true,true,false); + if(!IsInWorld() || !itr2->second.active) // at spells loading, no output, but allow save + addSpell(itr2->second.spell,itr2->second.active,true,true,false); else // at normal learning - learnSpell(itr->second.spell,true); + learnSpell(itr2->second.spell,true); } } @@ -5226,15 +5226,15 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal) // temporary bonuses AuraList const& mModSkill = GetAurasByType(SPELL_AURA_MOD_SKILL); - for(AuraList::const_iterator i = mModSkill.begin(); i != mModSkill.end(); ++i) - if ((*i)->GetModifier()->m_miscvalue == int32(id)) - (*i)->ApplyModifier(true); + for(AuraList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j) + if ((*j)->GetModifier()->m_miscvalue == int32(id)) + (*j)->ApplyModifier(true); // permanent bonuses AuraList const& mModSkillTalent = GetAurasByType(SPELL_AURA_MOD_SKILL_TALENT); - for(AuraList::const_iterator i = mModSkillTalent.begin(); i != mModSkillTalent.end(); ++i) - if ((*i)->GetModifier()->m_miscvalue == int32(id)) - (*i)->ApplyModifier(true); + for(AuraList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j) + if ((*j)->GetModifier()->m_miscvalue == int32(id)) + (*j)->ApplyModifier(true); // Learn all spells for skill learnSkillRewardedSpells(id, currVal); @@ -5685,11 +5685,11 @@ void Player::RewardReputation(Unit *pVictim, float rate) donerep1 = int32(donerep1*rate); FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1); uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1); - if(factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1) + if (factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1) GetReputationMgr().ModifyReputation(factionEntry1, donerep1); // Wiki: Team factions value divided by 2 - if(Rep->is_teamaward1) + if (factionEntry1 && Rep->is_teamaward1) { FactionEntry const *team1_factionEntry = sFactionStore.LookupEntry(factionEntry1->team); if(team1_factionEntry) @@ -5703,11 +5703,11 @@ void Player::RewardReputation(Unit *pVictim, float rate) donerep2 = int32(donerep2*rate); FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2); uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2); - if(factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2) + if (factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2) GetReputationMgr().ModifyReputation(factionEntry2, donerep2); // Wiki: Team factions value divided by 2 - if(Rep->is_teamaward2) + if (factionEntry2 && Rep->is_teamaward2) { FactionEntry const *team2_factionEntry = sFactionStore.LookupEntry(factionEntry2->team); if(team2_factionEntry) @@ -9556,8 +9556,8 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo return EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE; // if swap ignore item (equipped also) - if(uint8 res = CanEquipUniqueItem(pItem, swap ? eslot : NULL_SLOT)) - return res; + if(uint8 res2 = CanEquipUniqueItem(pItem, swap ? eslot : NULL_SLOT)) + return res2; // check unique-equipped special item classes if (pProto->Class == ITEM_CLASS_QUIVER) @@ -10148,97 +10148,96 @@ Item* Player::EquipNewItem( uint16 pos, uint32 item, bool update ) Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) { - if( pItem ) - { - AddEnchantmentDurations(pItem); - AddItemDurations(pItem); - uint8 bag = pos >> 8; - uint8 slot = pos & 255; + AddEnchantmentDurations(pItem); + AddItemDurations(pItem); - Item *pItem2 = GetItemByPos( bag, slot ); + uint8 bag = pos >> 8; + uint8 slot = pos & 255; - if( !pItem2 ) + Item *pItem2 = GetItemByPos( bag, slot ); + + if( !pItem2 ) + { + VisualizeItem( slot, pItem); + + if(isAlive()) { - VisualizeItem( slot, pItem); + ItemPrototype const *pProto = pItem->GetProto(); - if(isAlive()) - { - ItemPrototype const *pProto = pItem->GetProto(); + // item set bonuses applied only at equip and removed at unequip, and still active for broken items + if(pProto && pProto->ItemSet) + AddItemsSetItem(this,pItem); - // item set bonuses applied only at equip and removed at unequip, and still active for broken items - if(pProto && pProto->ItemSet) - AddItemsSetItem(this,pItem); + _ApplyItemMods(pItem, slot, true); - _ApplyItemMods(pItem, slot, true); + if(pProto && isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer == 0) + { + uint32 cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_5s; - if(pProto && isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer == 0) - { - uint32 cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_5s; + if (getClass() == CLASS_ROGUE) + cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_0s; - if (getClass() == CLASS_ROGUE) - cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_0s; + SpellEntry const* spellProto = sSpellStore.LookupEntry(cooldownSpell); - SpellEntry const* spellProto = sSpellStore.LookupEntry(cooldownSpell); + if (!spellProto) + sLog.outError("Weapon switch cooldown spell %u couldn't be found in Spell.dbc", cooldownSpell); + else + { + m_weaponChangeTimer = spellProto->StartRecoveryTime; - if (!spellProto) - sLog.outError("Weapon switch cooldown spell %u couldn't be found in Spell.dbc", cooldownSpell); - else - { - m_weaponChangeTimer = spellProto->StartRecoveryTime; - - WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4); - data << uint64(GetGUID()); - data << uint8(1); - data << uint32(cooldownSpell); - data << uint32(0); - GetSession()->SendPacket(&data); - } + WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4); + data << uint64(GetGUID()); + data << uint8(1); + data << uint32(cooldownSpell); + data << uint32(0); + GetSession()->SendPacket(&data); } } + } - if( IsInWorld() && update ) - { - pItem->AddToWorld(); - pItem->SendUpdateToPlayer( this ); - } + if( IsInWorld() && update ) + { + pItem->AddToWorld(); + pItem->SendUpdateToPlayer( this ); + } - ApplyEquipCooldown(pItem); + ApplyEquipCooldown(pItem); - if( slot == EQUIPMENT_SLOT_MAINHAND ) - UpdateExpertise(BASE_ATTACK); - else if( slot == EQUIPMENT_SLOT_OFFHAND ) - UpdateExpertise(OFF_ATTACK); - } - else - { - pItem2->SetCount( pItem2->GetCount() + pItem->GetCount() ); - if( IsInWorld() && update ) - pItem2->SendUpdateToPlayer( this ); + if( slot == EQUIPMENT_SLOT_MAINHAND ) + UpdateExpertise(BASE_ATTACK); + else if( slot == EQUIPMENT_SLOT_OFFHAND ) + UpdateExpertise(OFF_ATTACK); + } + else + { + pItem2->SetCount( pItem2->GetCount() + pItem->GetCount() ); + if( IsInWorld() && update ) + pItem2->SendUpdateToPlayer( this ); - // delete item (it not in any slot currently) - //pItem->DeleteFromDB(); - if( IsInWorld() && update ) - { - pItem->RemoveFromWorld(); - pItem->DestroyForPlayer( this ); - } + // delete item (it not in any slot currently) + //pItem->DeleteFromDB(); + if( IsInWorld() && update ) + { + pItem->RemoveFromWorld(); + pItem->DestroyForPlayer( this ); + } - RemoveEnchantmentDurations(pItem); - RemoveItemDurations(pItem); + RemoveEnchantmentDurations(pItem); + RemoveItemDurations(pItem); - pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor - pItem->SetState(ITEM_REMOVED, this); - pItem2->SetState(ITEM_CHANGED, this); + pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor + pItem->SetState(ITEM_REMOVED, this); + pItem2->SetState(ITEM_CHANGED, this); - ApplyEquipCooldown(pItem2); + ApplyEquipCooldown(pItem2); - return pItem2; - } + return pItem2; } // only for full equip instead adding to stack GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry()); + return pItem; } @@ -11006,7 +11005,7 @@ void Player::SwapItem( uint16 src, uint16 dst ) // check src->dest move possibility ItemPosCountVec sDest; - uint16 eDest; + uint16 eDest = 0; if( IsInventoryPos( dst ) ) msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, true ); else if( IsBankPos( dst ) ) @@ -11026,7 +11025,7 @@ void Player::SwapItem( uint16 src, uint16 dst ) // check dest->src move possibility ItemPosCountVec sDest2; - uint16 eDest2; + uint16 eDest2 = 0; if( IsInventoryPos( src ) ) msg = CanStoreItem( srcbag, srcslot, sDest2, pDstItem, true ); else if( IsBankPos( src ) ) @@ -12054,14 +12053,14 @@ bool Player::CanAddQuest( Quest const *pQuest, bool msg ) { uint32 count = pQuest->GetSrcItemCount(); ItemPosCountVec dest; - uint8 msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count ); + uint8 msg2 = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count ); // player already have max number (in most case 1) source item, no additional item needed and quest can be added. - if( msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS ) + if( msg2 == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS ) return true; - else if( msg != EQUIP_ERR_OK ) + else if( msg2 != EQUIP_ERR_OK ) { - SendEquipError( msg, NULL, NULL ); + SendEquipError( msg2, NULL, NULL ); return false; } } @@ -12662,14 +12661,14 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) // each-from-all exclusive group ( < 0) // can be start if only all quests in prev quest exclusive group completed and rewarded - ObjectMgr::ExclusiveQuestGroups::iterator iter = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup()); + ObjectMgr::ExclusiveQuestGroups::iterator iter2 = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup()); ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup()); - assert(iter!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0 + assert(iter2!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0 - for(; iter != end; ++iter) + for(; iter2 != end; ++iter2) { - uint32 exclude_Id = iter->second; + uint32 exclude_Id = iter2->second; // skip checked quest id, only state of other quests in group is interesting if(exclude_Id == prevId) @@ -12697,14 +12696,14 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) // each-from-all exclusive group ( < 0) // can be start if only all quests in prev quest exclusive group active - ObjectMgr::ExclusiveQuestGroups::iterator iter = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup()); + ObjectMgr::ExclusiveQuestGroups::iterator iter2 = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup()); ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup()); - assert(iter!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0 + assert(iter2!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0 - for(; iter != end; ++iter) + for(; iter2 != end; ++iter2) { - uint32 exclude_Id = iter->second; + uint32 exclude_Id = iter2->second; // skip checked quest id, only state of other quests in group is interesting if(exclude_Id == prevId) @@ -17782,8 +17781,8 @@ void Player::AddComboPoints(Unit* target, int8 count) else { if(m_comboTarget) - if(Unit* target = ObjectAccessor::GetUnit(*this,m_comboTarget)) - target->RemoveComboPointHolder(GetGUIDLow()); + if(Unit* target2 = ObjectAccessor::GetUnit(*this,m_comboTarget)) + target2->RemoveComboPointHolder(GetGUIDLow()); m_comboTarget = target->GetGUID(); m_comboPoints = count; @@ -17909,10 +17908,10 @@ void Player::SendInitialPacketsAfterAddToMap() // manual send package (have code in ApplyModifier(true,true); that don't must be re-applied. if(HasAuraType(SPELL_AURA_MOD_ROOT)) { - WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10); - data.append(GetPackGUID()); - data << (uint32)2; - SendMessageToSet(&data,true); + WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10); + data2.append(GetPackGUID()); + data2 << (uint32)2; + SendMessageToSet(&data2,true); } SendAurasForTarget(this); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 939dbcbc..836547b8 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -2180,11 +2180,12 @@ void Aura::HandleAuraDummy(bool apply, bool Real) if( GetId()==24658 ) { uint32 spellId = 24659; - if (apply) + if (apply && caster) { const SpellEntry *spell = sSpellStore.LookupEntry(spellId); if (!spell) return; + for (int i=0; i < spell->StackAmount; ++i) caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID()); return; @@ -2196,7 +2197,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) if( GetId()==24661 ) { uint32 spellId = 24662; - if (apply) + if (apply && caster) { const SpellEntry *spell = sSpellStore.LookupEntry(spellId); if (!spell) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index f68cb4b1..7fc3a851 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -885,7 +885,7 @@ void Spell::EffectDummy(uint32 i) // return; -- implemented at client side case 28006: // Arcane Cloaking { - if( unitTarget->GetTypeId() == TYPEID_PLAYER ) + if (unitTarget && unitTarget->GetTypeId() == TYPEID_PLAYER ) m_caster->CastSpell(unitTarget,29294,true); return; } @@ -1289,7 +1289,7 @@ void Spell::EffectDummy(uint32 i) } // Think its not need (also need remove Life Tap from SpellDamageBonus or add new value) // damage = m_caster->SpellDamageBonus(m_caster, m_spellInfo,uint32(damage > 0 ? damage : 0), SPELL_DIRECT_DAMAGE); - if(int32(unitTarget->GetHealth()) > damage) + if(unitTarget && (int32(unitTarget->GetHealth()) > damage)) { // Shouldn't Appear in Combat Log unitTarget->ModifyHealth(-damage); @@ -1678,9 +1678,9 @@ void Spell::EffectDummy(uint32 i) if(m_caster->GetTypeId() != TYPEID_PLAYER) return; - for(int i = BASE_ATTACK; i <= OFF_ATTACK; ++i) + for(int j = BASE_ATTACK; j <= OFF_ATTACK; ++j) { - if(Item* item = ((Player*)m_caster)->GetWeaponForAttack(WeaponAttackType(i))) + if(Item* item = ((Player*)m_caster)->GetWeaponForAttack(WeaponAttackType(j))) { if(item->IsFitToSpellRequirements(m_spellInfo)) { @@ -1909,7 +1909,7 @@ void Spell::EffectTriggerSpell(uint32 i) if (!spell) return; - for (int i=0; i < spell->StackAmount; ++i) + for (int j=0; j < spell->StackAmount; ++j) m_caster->CastSpell(unitTarget,spell->Id, true, m_CastItem, NULL, m_originalCasterGUID); return; } @@ -1920,7 +1920,7 @@ void Spell::EffectTriggerSpell(uint32 i) if (!spell) return; - for (int i=0; i < spell->StackAmount; ++i) + for (int j=0; j < spell->StackAmount; ++j) m_caster->CastSpell(unitTarget,spell->Id, true, m_CastItem, NULL, m_originalCasterGUID); return; } @@ -3041,10 +3041,10 @@ void Spell::EffectSummonChangeItem(uint32 i) if( !pNewItem ) return; - for(uint8 i= PERM_ENCHANTMENT_SLOT; i<=TEMP_ENCHANTMENT_SLOT; ++i) + for(uint8 j= PERM_ENCHANTMENT_SLOT; j<=TEMP_ENCHANTMENT_SLOT; ++j) { - if(m_CastItem->GetEnchantmentId(EnchantmentSlot(i))) - pNewItem->SetEnchantment(EnchantmentSlot(i), m_CastItem->GetEnchantmentId(EnchantmentSlot(i)), m_CastItem->GetEnchantmentDuration(EnchantmentSlot(i)), m_CastItem->GetEnchantmentCharges(EnchantmentSlot(i))); + if(m_CastItem->GetEnchantmentId(EnchantmentSlot(j))) + pNewItem->SetEnchantment(EnchantmentSlot(j), m_CastItem->GetEnchantmentId(EnchantmentSlot(j)), m_CastItem->GetEnchantmentDuration(EnchantmentSlot(j)), m_CastItem->GetEnchantmentCharges(EnchantmentSlot(j))); } if(m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) < m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)) @@ -4248,11 +4248,14 @@ void Spell::EffectLearnPetSpell(uint32 i) void Spell::EffectTaunt(uint32 /*i*/) { + if (!unitTarget) + return; + // this effect use before aura Taunt apply for prevent taunt already attacking target // for spell as marked "non effective at already attacking target" - if(unitTarget && unitTarget->GetTypeId() != TYPEID_PLAYER) + if (unitTarget->GetTypeId() != TYPEID_PLAYER) { - if(unitTarget->getVictim()==m_caster) + if (unitTarget->getVictim()==m_caster) { SendCastResult(SPELL_FAILED_DONT_REPORT); return; @@ -4260,7 +4263,7 @@ void Spell::EffectTaunt(uint32 /*i*/) } // Also use this effect to set the taunter's threat to the taunted creature's highest value - if(unitTarget->CanHaveThreatList() && unitTarget->getThreatManager().getCurrentVictim()) + if (unitTarget->CanHaveThreatList() && unitTarget->getThreatManager().getCurrentVictim()) unitTarget->getThreatManager().addThreat(m_caster,unitTarget->getThreatManager().getCurrentVictim()->getThreat()); } @@ -4374,12 +4377,12 @@ void Spell::EffectWeaponDmg(uint32 i) if(m_spellInfo->SpellFamilyFlags & 0x001000000000LL) { Unit::AuraList const& m_OverrideClassScript = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(Unit::AuraList::const_iterator i = m_OverrideClassScript.begin(); i != m_OverrideClassScript.end(); ++i) + for(Unit::AuraList::const_iterator citr = m_OverrideClassScript.begin(); citr != m_OverrideClassScript.end(); ++citr) { // Stormstrike AP Buff - if ( (*i)->GetModifier()->m_miscvalue == 5634 ) + if ( (*citr)->GetModifier()->m_miscvalue == 5634 ) { - m_caster->CastSpell(m_caster,38430,true,NULL,*i); + m_caster->CastSpell(m_caster,38430,true,NULL,*citr); break; } } @@ -4829,7 +4832,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) if(!unitTarget) return; - uint32 spellId; + uint32 spellId = 0; switch(rand()%4) { case 0: spellId = 46740; break; @@ -6256,7 +6259,7 @@ void Spell::EffectTransmitted(uint32 effIndex) // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo)) // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME) - int32 lastSec; + int32 lastSec = 0; switch(urand(0, 3)) { case 0: lastSec = 3; break; diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index ae0820ca..8061dbee 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -470,9 +470,9 @@ class PetAura return itr->second; else { - std::map::const_iterator itr = auras.find(0); - if(itr != auras.end()) - return itr->second; + std::map::const_iterator itr2 = auras.find(0); + if(itr2 != auras.end()) + return itr2->second; else return 0; } @@ -649,9 +649,9 @@ class SpellMgr // Not found, try lookup for 1 spell rank if exist if (uint32 rank_1 = GetFirstSpellInChain(spellId)) { - SpellBonusMap::const_iterator itr = mSpellBonusMap.find(rank_1); - if( itr != mSpellBonusMap.end( ) ) - return &itr->second; + SpellBonusMap::const_iterator itr2 = mSpellBonusMap.find(rank_1); + if( itr2 != mSpellBonusMap.end( ) ) + return &itr2->second; } return NULL; } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 62a3f875..f8469a39 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -2103,12 +2103,12 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack if(pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY) ) { - int32 tmp = int32(parry_chance); - if ( (tmp > 0) // check if unit _can_ parry - && ((tmp -= skillBonus) > 0) - && (roll < (sum += tmp))) + int32 tmp2 = int32(parry_chance); + if ( (tmp2 > 0) // check if unit _can_ parry + && ((tmp2 -= skillBonus) > 0) + && (roll < (sum += tmp2))) { - DEBUG_LOG ("RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum-tmp, sum); + DEBUG_LOG ("RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum-tmp2, sum); return MELEE_HIT_PARRY; } } @@ -2989,7 +2989,7 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell ) { assert(pSpell); // NULL may be never passed here, use InterruptSpell or InterruptNonMeleeSpells - uint32 CSpellType = pSpell->GetCurrentContainer(); + CurrentSpellTypes CSpellType = pSpell->GetCurrentContainer(); if (pSpell == m_currentSpells[CSpellType]) return; // avoid breaking self diff --git a/src/game/debugcmds.cpp b/src/game/debugcmds.cpp index fa20d243..a6ac22fd 100644 --- a/src/game/debugcmds.cpp +++ b/src/game/debugcmds.cpp @@ -395,9 +395,9 @@ bool ChatHandler::HandleDebugGetItemState(const char* args) Bag *bag = (Bag*)item; for (uint8 j = 0; j < bag->GetBagSize(); ++j) { - Item* item = bag->GetItemByPos(j); - if (item && item->GetState() == state) - PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID())); + Item* item2 = bag->GetItemByPos(j); + if (item2 && item2->GetState() == state) + PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID())); } } } @@ -491,58 +491,58 @@ bool ChatHandler::HandleDebugGetItemState(const char* args) Bag *bag = (Bag*)item; for (uint8 j = 0; j < bag->GetBagSize(); ++j) { - Item* item = bag->GetItemByPos(j); - if (!item) continue; + Item* item2 = bag->GetItemByPos(j); + if (!item2) continue; - if (item->GetSlot() != j) + if (item2->GetSlot() != j) { - PSendSysMessage("the item in bag %d slot %d, guid %d has an incorrect slot value: %d", bag->GetSlot(), j, item->GetGUIDLow(), item->GetSlot()); + PSendSysMessage("the item in bag %d slot %d, guid %d has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUIDLow(), item2->GetSlot()); error = true; continue; } - if (item->GetOwnerGUID() != player->GetGUID()) + if (item2->GetOwnerGUID() != player->GetGUID()) { - PSendSysMessage("for the item in bag %d at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); + PSendSysMessage("for the item in bag %d at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()), player->GetGUIDLow()); error = true; continue; } - Bag *container = item->GetContainer(); + Bag *container = item2->GetContainer(); if (!container) { - PSendSysMessage("the item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow()); + PSendSysMessage("the item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow()); error = true; continue; } if (container != bag) { - PSendSysMessage("the item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); + PSendSysMessage("the item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); error = true; continue; } - if (item->IsInUpdateQueue()) + if (item2->IsInUpdateQueue()) { - uint16 qp = item->GetQueuePos(); + uint16 qp = item2->GetQueuePos(); if (qp > updateQueue.size()) { - PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), qp); + PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); error = true; continue; } if (updateQueue[qp] == NULL) { - PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), qp); + PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); error = true; continue; } - if (updateQueue[qp] != item) + if (updateQueue[qp] != item2) { - PSendSysMessage("item in bag: %d at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); + PSendSysMessage("item in bag: %d at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); error = true; continue; } } - else if (item->GetState() != ITEM_UNCHANGED) + else if (item2->GetState() != ITEM_UNCHANGED) { - PSendSysMessage("item in bag: %d at slot: %d guid: %d is not in queue but should be (state: %d)!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), item->GetState()); + PSendSysMessage("item in bag: %d at slot: %d guid: %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), item2->GetState()); error = true; continue; } } diff --git a/src/shared/ServiceWin32.cpp b/src/shared/ServiceWin32.cpp index 0b5e446a..82b51652 100644 --- a/src/shared/ServiceWin32.cpp +++ b/src/shared/ServiceWin32.cpp @@ -129,10 +129,10 @@ bool WinServiceUninstall() serviceName, SERVICE_QUERY_STATUS | DELETE); if (service) { - SERVICE_STATUS serviceStatus; - if (QueryServiceStatus(service, &serviceStatus)) + SERVICE_STATUS serviceStatus2; + if (QueryServiceStatus(service, &serviceStatus2)) { - if (serviceStatus.dwCurrentState == SERVICE_STOPPED) + if (serviceStatus2.dwCurrentState == SERVICE_STOPPED) DeleteService(service); } CloseServiceHandle(service); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3be8dae7..ecd5f8f9 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7715" + #define REVISION_NR "7716" #endif // __REVISION_NR_H__ -- 2.11.4.GIT