diff options
author | ariel- <ariel-@users.noreply.github.com> | 2017-06-19 23:20:06 -0300 |
---|---|---|
committer | ariel- <ariel-@users.noreply.github.com> | 2017-06-19 23:20:06 -0300 |
commit | 85a7d5ce9ac68b30da2277cc91d4b70358f1880d (patch) | |
tree | df3d2084ee2e35008903c03178039b9c986e2d08 /src/server/game/Groups/Group.cpp | |
parent | 052fc24315ace866ea1cf610e85df119b68100c9 (diff) |
Core: ported headers cleanup from master branch
Diffstat (limited to 'src/server/game/Groups/Group.cpp')
-rw-r--r-- | src/server/game/Groups/Group.cpp | 161 |
1 files changed, 85 insertions, 76 deletions
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index dffe6250444..76b7de68ea9 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -16,26 +16,32 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "CharacterCache.h" -#include "Common.h" -#include "Opcodes.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "Player.h" -#include "World.h" -#include "ObjectMgr.h" -#include "GroupMgr.h" #include "Group.h" -#include "Formulas.h" -#include "ObjectAccessor.h" #include "Battleground.h" #include "BattlegroundMgr.h" -#include "MapManager.h" +#include "Common.h" +#include "CharacterCache.h" +#include "DatabaseEnv.h" +#include "Formulas.h" +#include "GameObject.h" +#include "GroupMgr.h" #include "InstanceSaveMgr.h" -#include "Util.h" +#include "LootMgr.h" +#include "ObjectAccessor.h" +#include "ObjectMgr.h" +#include "Opcodes.h" +#include "Player.h" +#include "MapManager.h" +#include "Log.h" #include "LFGMgr.h" -#include "UpdateFieldFlags.h" +#include "Random.h" #include "SpellAuras.h" +#include "UpdateData.h" +#include "UpdateFieldFlags.h" +#include "Util.h" +#include "World.h" +#include "WorldPacket.h" +#include "WorldSession.h" Roll::Roll(ObjectGuid _guid, LootItem const& li) : itemGUID(_guid), itemid(li.itemid), itemRandomPropId(li.randomPropertyId), itemRandomSuffix(li.randomSuffix), itemCount(li.count), @@ -56,8 +62,8 @@ Loot* Roll::getLoot() Group::Group() : m_leaderGuid(), m_leaderName(""), m_groupType(GROUPTYPE_NORMAL), m_dungeonDifficulty(DUNGEON_DIFFICULTY_NORMAL), m_raidDifficulty(RAID_DIFFICULTY_10MAN_NORMAL), -m_bgGroup(NULL), m_bfGroup(NULL), m_lootMethod(FREE_FOR_ALL), m_lootThreshold(ITEM_QUALITY_UNCOMMON), m_looterGuid(), -m_masterLooterGuid(), m_subGroupsCounts(NULL), m_guid(), m_counter(0), m_maxEnchantingLevel(0), m_dbStoreId(0) +m_bgGroup(nullptr), m_bfGroup(nullptr), m_lootMethod(FREE_FOR_ALL), m_lootThreshold(ITEM_QUALITY_UNCOMMON), m_looterGuid(), +m_masterLooterGuid(), m_subGroupsCounts(nullptr), m_guid(), m_counter(0), m_maxEnchantingLevel(0), m_dbStoreId(0) { for (uint8 i = 0; i < TARGETICONCOUNT; ++i) m_targetIcons[i].Clear(); @@ -68,9 +74,12 @@ Group::~Group() if (m_bgGroup) { TC_LOG_DEBUG("bg.battleground", "Group::~Group: battleground group being deleted."); - if (m_bgGroup->GetBgRaid(ALLIANCE) == this) m_bgGroup->SetBgRaid(ALLIANCE, NULL); - else if (m_bgGroup->GetBgRaid(HORDE) == this) m_bgGroup->SetBgRaid(HORDE, NULL); - else TC_LOG_ERROR("misc", "Group::~Group: battleground group is not linked to the correct battleground."); + if (m_bgGroup->GetBgRaid(ALLIANCE) == this) + m_bgGroup->SetBgRaid(ALLIANCE, nullptr); + else if (m_bgGroup->GetBgRaid(HORDE) == this) + m_bgGroup->SetBgRaid(HORDE, nullptr); + else + TC_LOG_ERROR("misc", "Group::~Group: battleground group is not linked to the correct battleground."); } Rolls::iterator itr; while (!RollId.empty()) @@ -301,15 +310,15 @@ void Group::RemoveInvite(Player* player) if (player) { m_invitees.erase(player); - player->SetGroupInvite(NULL); + player->SetGroupInvite(nullptr); } } void Group::RemoveAllInvites() { - for (InvitesList::iterator itr=m_invitees.begin(); itr != m_invitees.end(); ++itr) + for (InvitesList::iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr) if (*itr) - (*itr)->SetGroupInvite(NULL); + (*itr)->SetGroupInvite(nullptr); m_invitees.clear(); } @@ -321,7 +330,7 @@ Player* Group::GetInvited(ObjectGuid guid) const if ((*itr) && (*itr)->GetGUID() == guid) return (*itr); } - return NULL; + return nullptr; } Player* Group::GetInvited(const std::string& name) const @@ -331,7 +340,7 @@ Player* Group::GetInvited(const std::string& name) const if ((*itr) && (*itr)->GetName() == name) return (*itr); } - return NULL; + return nullptr; } bool Group::AddMember(Player* player) @@ -364,7 +373,7 @@ bool Group::AddMember(Player* player) SubGroupCounterIncrease(subGroup); - player->SetGroupInvite(NULL); + player->SetGroupInvite(nullptr); if (player->GetGroup()) { if (isBGGroup() || isBFGroup()) // if player is in group and he is being added to BG raid group, then call SetBattlegroundRaid() @@ -437,7 +446,7 @@ bool Group::AddMember(Player* player) WorldPacket groupDataPacket; // Broadcast group members' fields to player - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { if (itr->GetSource() == player) continue; @@ -480,7 +489,7 @@ bool Group::AddMember(Player* player) return true; } -bool Group::RemoveMember(ObjectGuid guid, const RemoveMethod& method /*= GROUP_REMOVEMETHOD_DEFAULT*/, ObjectGuid kicker /*= 0*/, const char* reason /*= NULL*/) +bool Group::RemoveMember(ObjectGuid guid, RemoveMethod const& method /*= GROUP_REMOVEMETHOD_DEFAULT*/, ObjectGuid kicker /*= ObjectGuid::Empty*/, char const* reason /*= nullptr*/) { BroadcastGroupUpdate(); @@ -518,9 +527,9 @@ bool Group::RemoveMember(ObjectGuid guid, const RemoveMethod& method /*= GROUP_R // Regular group { if (player->GetOriginalGroup() == this) - player->SetOriginalGroup(NULL); + player->SetOriginalGroup(nullptr); else - player->SetGroup(NULL); + player->SetGroup(nullptr); // quest related GO state dependent from raid membership player->UpdateForQuestWorldObjects(); @@ -531,14 +540,14 @@ bool Group::RemoveMember(ObjectGuid guid, const RemoveMethod& method /*= GROUP_R if (method == GROUP_REMOVEMETHOD_KICK || method == GROUP_REMOVEMETHOD_KICK_LFG) { data.Initialize(SMSG_GROUP_UNINVITE, 0); - player->GetSession()->SendPacket(&data); + player->SendDirectMessage(&data); } // Do we really need to send this opcode? data.Initialize(SMSG_GROUP_LIST, 1+1+1+1+8+4+4+8); data << uint8(0x10) << uint8(0) << uint8(0) << uint8(0); data << uint64(m_guid) << uint32(m_counter) << uint32(0) << uint64(0); - player->GetSession()->SendPacket(&data); + player->SendDirectMessage(&data); _homebindIfInstance(player); } @@ -750,9 +759,9 @@ void Group::Disband(bool hideDestroy /* = false */) { //we can remove player who is in battleground from his original group if (player->GetOriginalGroup() == this) - player->SetOriginalGroup(NULL); + player->SetOriginalGroup(nullptr); else - player->SetGroup(NULL); + player->SetGroup(nullptr); } // quest related GO state dependent from raid membership @@ -766,7 +775,7 @@ void Group::Disband(bool hideDestroy /* = false */) if (!hideDestroy) { data.Initialize(SMSG_GROUP_DESTROYED, 0); - player->GetSession()->SendPacket(&data); + player->SendDirectMessage(&data); } //we already removed player from group and in player->GetGroup() is his original group, send update @@ -779,7 +788,7 @@ void Group::Disband(bool hideDestroy /* = false */) data.Initialize(SMSG_GROUP_LIST, 1+1+1+1+8+4+4+8); data << uint8(0x10) << uint8(0) << uint8(0) << uint8(0); data << uint64(m_guid) << uint32(m_counter) << uint32(0) << uint64(0); - player->GetSession()->SendPacket(&data); + player->SendDirectMessage(&data); } _homebindIfInstance(player); @@ -803,8 +812,8 @@ void Group::Disband(bool hideDestroy /* = false */) CharacterDatabase.CommitTransaction(trans); - ResetInstances(INSTANCE_RESET_GROUP_DISBAND, false, NULL); - ResetInstances(INSTANCE_RESET_GROUP_DISBAND, true, NULL); + ResetInstances(INSTANCE_RESET_GROUP_DISBAND, false, nullptr); + ResetInstances(INSTANCE_RESET_GROUP_DISBAND, true, nullptr); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA); stmt->setUInt32(0, m_dbStoreId); @@ -821,7 +830,7 @@ void Group::Disband(bool hideDestroy /* = false */) /*** LOOT SYSTEM ***/ /*********************************************************/ -void Group::SendLootStartRoll(uint32 countDown, uint32 mapid, const Roll &r) +void Group::SendLootStartRoll(uint32 countDown, uint32 mapid, Roll const& r) { WorldPacket data(SMSG_LOOT_START_ROLL, (8+4+4+4+4+4+4+1)); data << uint64(r.itemGUID); // guid of rolled item @@ -841,7 +850,7 @@ void Group::SendLootStartRoll(uint32 countDown, uint32 mapid, const Roll &r) continue; if (itr->second == NOT_EMITED_YET) - p->GetSession()->SendPacket(&data); + p->SendDirectMessage(&data); } } @@ -864,7 +873,7 @@ void Group::SendLootStartRollToPlayer(uint32 countDown, uint32 mapId, Player* p, voteMask &= ~ROLL_FLAG_TYPE_NEED; data << uint8(voteMask); // roll type mask - p->GetSession()->SendPacket(&data); + p->SendDirectMessage(&data); } void Group::SendLootRoll(ObjectGuid sourceGuid, ObjectGuid targetGuid, uint8 rollNumber, uint8 rollType, Roll const& roll) @@ -887,7 +896,7 @@ void Group::SendLootRoll(ObjectGuid sourceGuid, ObjectGuid targetGuid, uint8 rol continue; if (itr->second != NOT_VALID) - p->GetSession()->SendPacket(&data); + p->SendDirectMessage(&data); } } @@ -910,7 +919,7 @@ void Group::SendLootRollWon(ObjectGuid sourceGuid, ObjectGuid targetGuid, uint8 continue; if (itr->second != NOT_VALID) - p->GetSession()->SendPacket(&data); + p->SendDirectMessage(&data); } } @@ -930,7 +939,7 @@ void Group::SendLootAllPassed(Roll const& roll) continue; if (itr->second != NOT_VALID) - player->GetSession()->SendPacket(&data); + player->SendDirectMessage(&data); } } @@ -981,7 +990,7 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject) Roll* r = new Roll(newitemGUID, *i); //a vector is filled with only near party members - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { Player* member = itr->GetSource(); if (!member || !member->GetSession()) @@ -1063,7 +1072,7 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject) Roll* r = new Roll(newitemGUID, *i); //a vector is filled with only near party members - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { Player* member = itr->GetSource(); if (!member || !member->GetSession()) @@ -1121,7 +1130,7 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject) Roll* r = new Roll(newitemGUID, *i); - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { Player* playerToRoll = itr->GetSource(); if (!playerToRoll || !playerToRoll->GetSession()) @@ -1196,7 +1205,7 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject) Roll* r = new Roll(newitemGUID, *i); - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { Player* playerToRoll = itr->GetSource(); if (!playerToRoll || !playerToRoll->GetSession()) @@ -1272,7 +1281,7 @@ void Group::MasterLoot(Loot* loot, WorldObject* pLootedObject) WorldPacket data(SMSG_LOOT_MASTER_LIST, 1 + GetMembersCount() * 8); data << uint8(GetMembersCount()); - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { Player* looter = itr->GetSource(); if (!looter->IsInWorld()) @@ -1287,11 +1296,11 @@ void Group::MasterLoot(Loot* loot, WorldObject* pLootedObject) data.put<uint8>(0, real_count); - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { Player* looter = itr->GetSource(); if (looter->IsAtGroupRewardDistance(pLootedObject)) - looter->GetSession()->SendPacket(&data); + looter->SendDirectMessage(&data); } } @@ -1372,7 +1381,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) ObjectGuid maxguid = ObjectGuid::Empty; Player* player = nullptr; - for (Roll::PlayerVote::const_iterator itr=roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr) + for (Roll::PlayerVote::const_iterator itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr) { if (itr->second != NEED) continue; @@ -1416,7 +1425,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) { item->is_blocked = false; item->rollWinnerGUID = player->GetGUID(); - player->SendEquipError(msg, NULL, NULL, roll->itemid); + player->SendEquipError(msg, nullptr, nullptr, roll->itemid); } } } @@ -1441,7 +1450,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) continue; player = ObjectAccessor::FindPlayer(itr->first); - if (!player || (allowedMap != NULL && player->FindMap() != allowedMap)) + if (!player || (allowedMap != nullptr && player->FindMap() != allowedMap)) { --roll->totalGreed; continue; @@ -1483,7 +1492,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) { item->is_blocked = false; item->rollWinnerGUID = player->GetGUID(); - player->SendEquipError(msg, NULL, NULL, roll->itemid); + player->SendEquipError(msg, nullptr, nullptr, roll->itemid); } } else if (rollvote == DISENCHANT) @@ -1507,7 +1516,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) for (uint32 i = 0; i < max_slot; ++i) { LootItem* lootItem = loot.LootItemInSlot(i, player); - player->SendEquipError(msg, NULL, NULL, lootItem->itemid); + player->SendEquipError(msg, nullptr, nullptr, lootItem->itemid); player->SendItemRetrievalMail(lootItem->itemid, lootItem->count); } } @@ -1647,7 +1656,7 @@ void Group::SendUpdateToPlayer(ObjectGuid playerGUID, MemberSlot* slot) data << uint8(m_raidDifficulty >= RAID_DIFFICULTY_10MAN_HEROIC); // 3.3 Dynamic Raid Difficulty - 0 normal/1 heroic } - player->GetSession()->SendPacket(&data); + player->SendDirectMessage(&data); } void Group::UpdatePlayerOutOfRange(Player* player) @@ -1659,35 +1668,35 @@ void Group::UpdatePlayerOutOfRange(Player* player) player->GetSession()->BuildPartyMemberStatsChangedPacket(player, &data); Player* member; - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { member = itr->GetSource(); if (member && member != player && (!member->IsInMap(player) || !member->IsWithinDist(player, member->GetSightRange(), false))) - member->GetSession()->SendPacket(&data); + member->SendDirectMessage(&data); } } void Group::BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int group /*= -1*/, ObjectGuid ignoredPlayer /*= ObjectGuid::Empty*/) { - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { Player* player = itr->GetSource(); if (!player || (!ignoredPlayer.IsEmpty() && player->GetGUID() == ignoredPlayer) || (ignorePlayersInBGRaid && player->GetGroup() != this)) continue; if (player->GetSession() && (group == -1 || itr->getSubGroup() == group)) - player->GetSession()->SendPacket(packet); + player->SendDirectMessage(packet); } } void Group::BroadcastReadyCheck(WorldPacket* packet) { - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { Player* player = itr->GetSource(); if (player && player->GetSession()) if (IsLeader(player->GetGUID()) || IsAssistant(player->GetGUID())) - player->GetSession()->SendPacket(packet); + player->SendDirectMessage(packet); } } @@ -1827,7 +1836,7 @@ void Group::UpdateLooterGuid(WorldObject* pLootedObject, bool ifneed) } // search next after current - Player* pNewLooter = NULL; + Player* pNewLooter = nullptr; for (member_citerator itr = guid_itr; itr != m_memberSlots.end(); ++itr) { if (Player* player = ObjectAccessor::FindPlayer(itr->guid)) @@ -1900,7 +1909,7 @@ GroupJoinBattlegroundResult Group::CanJoinBattlegroundQueue(Battleground const* // check every member of the group to be able to join memberscount = 0; - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next(), ++memberscount) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next(), ++memberscount) { Player* member = itr->GetSource(); // offline member? don't let join @@ -1969,7 +1978,7 @@ void Group::SetDungeonDifficulty(Difficulty difficulty) CharacterDatabase.Execute(stmt); } - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { Player* player = itr->GetSource(); if (!player->GetSession()) @@ -1993,7 +2002,7 @@ void Group::SetRaidDifficulty(Difficulty difficulty) CharacterDatabase.Execute(stmt); } - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { Player* player = itr->GetSource(); if (!player->GetSession()) @@ -2006,7 +2015,7 @@ void Group::SetRaidDifficulty(Difficulty difficulty) bool Group::InCombatToInstance(uint32 instanceId) { - for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) { Player* player = itr->GetSource(); if (player && player->GetInstanceId() == instanceId && !player->getAttackers().empty() && (player->GetMap()->IsRaidOrHeroicDungeon())) @@ -2030,7 +2039,7 @@ void Group::ResetInstances(uint8 method, bool isRaid, Player* SendMsgTo) for (BoundInstancesMap::iterator itr = m_boundInstances[diff].begin(); itr != m_boundInstances[diff].end();) { InstanceSave* instanceSave = itr->second.save; - const MapEntry* entry = sMapStore.LookupEntry(itr->first); + MapEntry const* entry = sMapStore.LookupEntry(itr->first); if (!entry || entry->IsRaid() != isRaid || (!instanceSave->CanReset() && method != INSTANCE_RESET_GROUP_DISBAND)) { ++itr; @@ -2066,7 +2075,7 @@ void Group::ResetInstances(uint8 method, bool isRaid, Player* SendMsgTo) { if (Group* group = SendMsgTo->GetGroup()) { - for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next()) + for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next()) if (Player* player = groupRef->GetSource()) player->SendResetInstanceSuccess(instanceSave->GetMapId()); } @@ -2122,7 +2131,7 @@ InstanceGroupBind* Group::GetBoundInstance(Map* aMap) InstanceGroupBind* Group::GetBoundInstance(MapEntry const* mapEntry) { if (!mapEntry || !mapEntry->IsDungeon()) - return NULL; + return nullptr; Difficulty difficulty = GetDifficulty(mapEntry->IsRaid()); return GetBoundInstance(difficulty, mapEntry->MapID); @@ -2137,13 +2146,13 @@ InstanceGroupBind* Group::GetBoundInstance(Difficulty difficulty, uint32 mapId) if (itr != m_boundInstances[difficulty].end()) return &itr->second; else - return NULL; + return nullptr; } InstanceGroupBind* Group::BindToInstance(InstanceSave* save, bool permanent, bool load) { if (!save || isBGGroup() || isBFGroup()) - return NULL; + return nullptr; InstanceGroupBind& bind = m_boundInstances[save->GetDifficulty()][save->GetMapId()]; if (!load && (!bind.save || permanent != bind.perm || save != bind.save)) @@ -2218,7 +2227,7 @@ void Group::BroadcastGroupUpdate(void) void Group::ResetMaxEnchantingLevel() { m_maxEnchantingLevel = 0; - Player* member = NULL; + Player* member = nullptr; for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr) { member = ObjectAccessor::FindPlayer(citr->guid); @@ -2274,12 +2283,12 @@ bool Group::isRaidGroup() const bool Group::isBGGroup() const { - return m_bgGroup != NULL; + return m_bgGroup != nullptr; } bool Group::isBFGroup() const { - return m_bfGroup != NULL; + return m_bfGroup != nullptr; } bool Group::IsCreated() const @@ -2459,7 +2468,7 @@ bool Group::isRollLootActive() const Group::Rolls::iterator Group::GetRoll(ObjectGuid Guid) { Rolls::iterator iter; - for (iter=RollId.begin(); iter != RollId.end(); ++iter) + for (iter = RollId.begin(); iter != RollId.end(); ++iter) if ((*iter)->itemGUID == Guid && (*iter)->isValid()) return iter; return RollId.end(); |