From bf2bb58f6d449fefec46d774e48bb2774c5e3d84 Mon Sep 17 00:00:00 2001 From: namreeb Date: Tue, 8 Nov 2016 12:58:39 -1000 Subject: [PATCH] Further WorldPacket pointers replaced with references --- src/game/AddonHandler.cpp | 26 ++-- src/game/AddonHandler.h | 2 +- src/game/Channel.cpp | 258 +++++++++++++++++----------------- src/game/Channel.h | 78 +++++----- src/game/CharacterHandler.cpp | 2 +- src/game/GridNotifiers.cpp | 2 +- src/game/Group.cpp | 2 +- src/game/GroupHandler.cpp | 70 ++++----- src/game/Map.cpp | 8 +- src/game/Object.cpp | 4 +- src/game/Player.cpp | 72 +++++----- src/game/Player.h | 2 +- src/game/SocialMgr.cpp | 10 +- src/game/SocialMgr.h | 2 +- src/game/Spell.cpp | 32 ++--- src/game/Spell.h | 4 +- src/game/Transports.cpp | 4 +- src/game/Unit.cpp | 4 +- src/game/Unit.h | 2 +- src/game/UpdateData.cpp | 18 +-- src/game/UpdateData.h | 2 +- src/game/WorldSession.cpp | 8 +- src/game/WorldSession.h | 8 +- src/game/WorldSocket.cpp | 2 +- 24 files changed, 311 insertions(+), 311 deletions(-) diff --git a/src/game/AddonHandler.cpp b/src/game/AddonHandler.cpp index ad161a22b5..04502411aa 100644 --- a/src/game/AddonHandler.cpp +++ b/src/game/AddonHandler.cpp @@ -33,7 +33,7 @@ AddonHandler::~AddonHandler() { } -bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target) +bool AddonHandler::BuildAddonPacket(WorldPacket& Source, WorldPacket& Target) { ByteBuffer AddOnPacked; uLongf AddonRealSize; @@ -61,10 +61,10 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target) }; // broken addon packet, can't be received from real client - if (Source->rpos() + 4 > Source->size()) + if (Source.rpos() + 4 > Source.size()) return false; - *Source >> TempValue; // get real size of the packed structure + Source >> TempValue; // get real size of the packed structure // empty addon packet, nothing process, can't be received from real client if (!TempValue) @@ -78,13 +78,13 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target) AddonRealSize = TempValue; // temp value because ZLIB only excepts uLongf - CurrentPosition = Source->rpos(); // get the position of the pointer in the structure + CurrentPosition = Source.rpos(); // get the position of the pointer in the structure AddOnPacked.resize(AddonRealSize); // resize target for zlib action - if (uncompress(const_cast(AddOnPacked.contents()), &AddonRealSize, const_cast((*Source).contents() + CurrentPosition), (*Source).size() - CurrentPosition) == Z_OK) + if (uncompress(const_cast(AddOnPacked.contents()), &AddonRealSize, const_cast(Source.contents() + CurrentPosition), Source.size() - CurrentPosition) == Z_OK) { - Target->Initialize(SMSG_ADDON_INFO); + Target.Initialize(SMSG_ADDON_INFO); while (AddOnPacked.rpos() < AddOnPacked.size()) { @@ -98,22 +98,22 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target) // sLog.outDebug("ADDON: Name:%s CRC:%x Unknown1 :%x Unknown2 :%x", AddonNames.c_str(), crc, unk7, unk6); - *Target << (uint8)2; + Target << (uint8)2; uint8 unk1 = 1; - *Target << (uint8)unk1; + Target << (uint8)unk1; if (unk1) { uint8 unk2 = crc != uint64(0x1c776d01); // If addon is Standard addon CRC - *Target << (uint8)unk2; + Target << (uint8)unk2; if (unk2) - Target->append(tdata, sizeof(tdata)); + Target.append(tdata, sizeof(tdata)); - *Target << (uint32)0; + Target << (uint32)0; } uint8 unk3 = 0; - *Target << (uint8)unk3; + Target << (uint8)unk3; if (unk3) { // String, 256 @@ -129,7 +129,7 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target) } /* Code use in 1.10.2 when client not ignore ban state sended for addons. Saved for reference if client switch to use server ban state information -void AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target, uint32 Packetoffset) +void AddonHandler::BuildAddonPacket(WorldPacket& Source, WorldPacket& Target, uint32 Packetoffset) { ByteBuffer AddOnPacked; uLongf AddonRealSize; diff --git a/src/game/AddonHandler.h b/src/game/AddonHandler.h index a9e97d5d8a..0cb4dfb9d2 100644 --- a/src/game/AddonHandler.h +++ b/src/game/AddonHandler.h @@ -30,7 +30,7 @@ class AddonHandler AddonHandler(); ~AddonHandler(); // built addon packet - bool BuildAddonPacket(WorldPacket* Source, WorldPacket* Target); + bool BuildAddonPacket(WorldPacket& Source, WorldPacket& Target); }; #define sAddOnHandler MaNGOS::Singleton::Instance() #endif diff --git a/src/game/Channel.cpp b/src/game/Channel.cpp index dfbd771d84..c85f973421 100644 --- a/src/game/Channel.cpp +++ b/src/game/Channel.cpp @@ -60,7 +60,7 @@ void Channel::Join(Player* player, const char* password) { if (!IsConstant()) // non send error message for built-in channels { - MakePlayerAlreadyMember(&data, guid); + MakePlayerAlreadyMember(data, guid); SendToOne(data, guid); } return; @@ -68,14 +68,14 @@ void Channel::Join(Player* player, const char* password) if (IsBanned(guid)) { - MakeBanned(&data); + MakeBanned(data); SendToOne(data, guid); return; } if (m_password.length() > 0 && strcmp(password, m_password.c_str())) { - MakeWrongPassword(&data); + MakeWrongPassword(data); SendToOne(data, guid); return; } @@ -83,7 +83,7 @@ void Channel::Join(Player* player, const char* password) if (HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL) && player->GetSession()->GetSecurity() == SEC_PLAYER && (player->GetGroup() || player->m_lookingForGroup.Empty())) { - MakeNotInLfg(&data); + MakeNotInLfg(data); SendToOne(data, guid); return; } @@ -96,7 +96,7 @@ void Channel::Join(Player* player, const char* password) if (m_announce && (player->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL))) { - MakeJoined(&data, guid); + MakeJoined(data, guid); SendToAll(data); } @@ -106,7 +106,7 @@ void Channel::Join(Player* player, const char* password) pinfo.player = guid; pinfo.flags = MEMBER_FLAG_NONE; - MakeYouJoined(&data); + MakeYouJoined(data); SendToOne(data, guid); JoinNotify(guid); @@ -128,7 +128,7 @@ void Channel::Leave(Player* player, bool send) if (send) { WorldPacket data; - MakeNotMember(&data); + MakeNotMember(data); SendToOne(data, guid); } return; @@ -138,7 +138,7 @@ void Channel::Leave(Player* player, bool send) if (send) { WorldPacket data; - MakeYouLeft(&data); + MakeYouLeft(data); SendToOne(data, guid); player->LeftChannel(this); data.clear(); @@ -150,7 +150,7 @@ void Channel::Leave(Player* player, bool send) if (m_announce && (player->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL))) { WorldPacket data; - MakeLeft(&data, guid); + MakeLeft(data, guid); SendToAll(data); } @@ -170,7 +170,7 @@ void Channel::KickOrBan(Player* player, const char* targetName, bool ban) if (!IsOn(guid)) { WorldPacket data; - MakeNotMember(&data); + MakeNotMember(data); SendToOne(data, guid); return; } @@ -178,7 +178,7 @@ void Channel::KickOrBan(Player* player, const char* targetName, bool ban) if (!m_players[guid].IsModerator() && player->GetSession()->GetSecurity() < SEC_GAMEMASTER) { WorldPacket data; - MakeNotModerator(&data); + MakeNotModerator(data); SendToOne(data, guid); return; } @@ -187,7 +187,7 @@ void Channel::KickOrBan(Player* player, const char* targetName, bool ban) if (!target) { WorldPacket data; - MakePlayerNotFound(&data, targetName); + MakePlayerNotFound(data, targetName); SendToOne(data, guid); return; } @@ -196,7 +196,7 @@ void Channel::KickOrBan(Player* player, const char* targetName, bool ban) if (!IsOn(targetGuid)) { WorldPacket data; - MakePlayerNotFound(&data, targetName); + MakePlayerNotFound(data, targetName); SendToOne(data, guid); return; } @@ -206,7 +206,7 @@ void Channel::KickOrBan(Player* player, const char* targetName, bool ban) if (player->GetSession()->GetSecurity() < SEC_GAMEMASTER && changeowner && guid != m_ownerGuid) { WorldPacket data; - MakeNotOwner(&data); + MakeNotOwner(data); SendToOne(data, guid); return; } @@ -217,10 +217,10 @@ void Channel::KickOrBan(Player* player, const char* targetName, bool ban) if (ban && !IsBanned(targetGuid)) { m_banned.insert(targetGuid); - MakePlayerBanned(&data, targetGuid, guid); + MakePlayerBanned(data, targetGuid, guid); } else - MakePlayerKicked(&data, targetGuid, guid); + MakePlayerKicked(data, targetGuid, guid); SendToAll(data); m_players.erase(targetGuid); @@ -240,7 +240,7 @@ void Channel::UnBan(Player* player, const char* targetName) if (!IsOn(guid)) { WorldPacket data; - MakeNotMember(&data); + MakeNotMember(data); SendToOne(data, guid); return; } @@ -248,7 +248,7 @@ void Channel::UnBan(Player* player, const char* targetName) if (!m_players[guid].IsModerator() && player->GetSession()->GetSecurity() < SEC_GAMEMASTER) { WorldPacket data; - MakeNotModerator(&data); + MakeNotModerator(data); SendToOne(data, guid); return; } @@ -257,7 +257,7 @@ void Channel::UnBan(Player* player, const char* targetName) if (!target) { WorldPacket data; - MakePlayerNotFound(&data, targetName); + MakePlayerNotFound(data, targetName); SendToOne(data, guid); return; } @@ -266,7 +266,7 @@ void Channel::UnBan(Player* player, const char* targetName) if (!IsBanned(targetGuid)) { WorldPacket data; - MakePlayerNotBanned(&data, targetName); + MakePlayerNotBanned(data, targetName); SendToOne(data, guid); return; } @@ -275,7 +275,7 @@ void Channel::UnBan(Player* player, const char* targetName) m_banned.erase(targetGuid); WorldPacket data; - MakePlayerUnbanned(&data, targetGuid, guid); + MakePlayerUnbanned(data, targetGuid, guid); SendToAll(data); } @@ -286,7 +286,7 @@ void Channel::Password(Player* player, const char* password) if (!IsOn(guid)) { WorldPacket data; - MakeNotMember(&data); + MakeNotMember(data); SendToOne(data, guid); return; } @@ -294,7 +294,7 @@ void Channel::Password(Player* player, const char* password) if (!m_players[guid].IsModerator() && player->GetSession()->GetSecurity() < SEC_GAMEMASTER) { WorldPacket data; - MakeNotModerator(&data); + MakeNotModerator(data); SendToOne(data, guid); return; } @@ -303,7 +303,7 @@ void Channel::Password(Player* player, const char* password) m_password = password; WorldPacket data; - MakePasswordChanged(&data, guid); + MakePasswordChanged(data, guid); SendToAll(data); } @@ -314,7 +314,7 @@ void Channel::SetMode(Player* player, const char* targetName, bool moderator, bo if (!IsOn(guid)) { WorldPacket data; - MakeNotMember(&data); + MakeNotMember(data); SendToOne(data, guid); return; } @@ -322,7 +322,7 @@ void Channel::SetMode(Player* player, const char* targetName, bool moderator, bo if (!m_players[guid].IsModerator() && player->GetSession()->GetSecurity() < SEC_GAMEMASTER) { WorldPacket data; - MakeNotModerator(&data); + MakeNotModerator(data); SendToOne(data, guid); return; } @@ -331,7 +331,7 @@ void Channel::SetMode(Player* player, const char* targetName, bool moderator, bo if (!target) { WorldPacket data; - MakePlayerNotFound(&data, targetName); + MakePlayerNotFound(data, targetName); SendToOne(data, guid); return; } @@ -343,7 +343,7 @@ void Channel::SetMode(Player* player, const char* targetName, bool moderator, bo if (!IsOn(targetGuid)) { WorldPacket data; - MakePlayerNotFound(&data, targetName); + MakePlayerNotFound(data, targetName); SendToOne(data, guid); return; } @@ -354,7 +354,7 @@ void Channel::SetMode(Player* player, const char* targetName, bool moderator, bo player->GetTeam() != target->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) { WorldPacket data; - MakePlayerNotFound(&data, targetName); + MakePlayerNotFound(data, targetName); SendToOne(data, guid); return; } @@ -362,7 +362,7 @@ void Channel::SetMode(Player* player, const char* targetName, bool moderator, bo if (m_ownerGuid == targetGuid && m_ownerGuid != guid) { WorldPacket data; - MakeNotOwner(&data); + MakeNotOwner(data); SendToOne(data, guid); return; } @@ -381,7 +381,7 @@ void Channel::SetOwner(Player* player, const char* targetName) if (!IsOn(guid)) { WorldPacket data; - MakeNotMember(&data); + MakeNotMember(data); SendToOne(data, guid); return; } @@ -389,7 +389,7 @@ void Channel::SetOwner(Player* player, const char* targetName) if (player->GetSession()->GetSecurity() < SEC_GAMEMASTER && guid != m_ownerGuid) { WorldPacket data; - MakeNotOwner(&data); + MakeNotOwner(data); SendToOne(data, guid); return; } @@ -398,7 +398,7 @@ void Channel::SetOwner(Player* player, const char* targetName) if (!target) { WorldPacket data; - MakePlayerNotFound(&data, targetName); + MakePlayerNotFound(data, targetName); SendToOne(data, guid); return; } @@ -407,7 +407,7 @@ void Channel::SetOwner(Player* player, const char* targetName) if (!IsOn(targetGuid)) { WorldPacket data; - MakePlayerNotFound(&data, targetName); + MakePlayerNotFound(data, targetName); SendToOne(data, guid); return; } @@ -415,7 +415,7 @@ void Channel::SetOwner(Player* player, const char* targetName) if (target->GetTeam() != player->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) { WorldPacket data; - MakePlayerNotFound(&data, targetName); + MakePlayerNotFound(data, targetName); SendToOne(data, guid); return; } @@ -432,14 +432,14 @@ void Channel::SendWhoOwner(Player* player) if (!IsOn(guid)) { WorldPacket data; - MakeNotMember(&data); + MakeNotMember(data); SendToOne(data, guid); return; } // send channel owner WorldPacket data; - MakeChannelOwner(&data); + MakeChannelOwner(data); SendToOne(data, guid); } @@ -450,7 +450,7 @@ void Channel::List(Player* player) if (!IsOn(guid)) { WorldPacket data; - MakeNotMember(&data); + MakeNotMember(data); SendToOne(data, guid); return; } @@ -494,7 +494,7 @@ void Channel::Announce(Player* player) if (!IsOn(guid)) { WorldPacket data; - MakeNotMember(&data); + MakeNotMember(data); SendToOne(data, guid); return; } @@ -502,7 +502,7 @@ void Channel::Announce(Player* player) if (!m_players[guid].IsModerator() && player->GetSession()->GetSecurity() < SEC_GAMEMASTER) { WorldPacket data; - MakeNotModerator(&data); + MakeNotModerator(data); SendToOne(data, guid); return; } @@ -512,9 +512,9 @@ void Channel::Announce(Player* player) WorldPacket data; if (m_announce) - MakeAnnouncementsOn(&data, guid); + MakeAnnouncementsOn(data, guid); else - MakeAnnouncementsOff(&data, guid); + MakeAnnouncementsOff(data, guid); SendToAll(data); } @@ -526,7 +526,7 @@ void Channel::Moderate(Player* player) if (!IsOn(guid)) { WorldPacket data; - MakeNotMember(&data); + MakeNotMember(data); SendToOne(data, guid); return; } @@ -534,7 +534,7 @@ void Channel::Moderate(Player* player) if (!m_players[guid].IsModerator() && player->GetSession()->GetSecurity() < SEC_GAMEMASTER) { WorldPacket data; - MakeNotModerator(&data); + MakeNotModerator(data); SendToOne(data, guid); return; } @@ -544,9 +544,9 @@ void Channel::Moderate(Player* player) WorldPacket data; if (m_moderate) - MakeModerationOn(&data, guid); + MakeModerationOn(data, guid); else - MakeModerationOff(&data, guid); + MakeModerationOff(data, guid); SendToAll(data); } @@ -561,7 +561,7 @@ void Channel::Say(Player* player, const char* text, uint32 lang) if (!IsOn(guid)) { WorldPacket data; - MakeNotMember(&data); + MakeNotMember(data); SendToOne(data, guid); return; } @@ -569,7 +569,7 @@ void Channel::Say(Player* player, const char* text, uint32 lang) if (m_players[guid].IsMuted()) { WorldPacket data; - MakeMuted(&data); + MakeMuted(data); SendToOne(data, guid); return; } @@ -577,7 +577,7 @@ void Channel::Say(Player* player, const char* text, uint32 lang) if (m_moderate && !m_players[guid].IsModerator() && player->GetSession()->GetSecurity() < SEC_GAMEMASTER) { WorldPacket data; - MakeNotModerator(&data); + MakeNotModerator(data); SendToOne(data, guid); return; } @@ -597,7 +597,7 @@ void Channel::Invite(Player* player, const char* targetName) if (!IsOn(guid)) { WorldPacket data; - MakeNotMember(&data); + MakeNotMember(data); SendToOne(data, guid); return; } @@ -606,7 +606,7 @@ void Channel::Invite(Player* player, const char* targetName) if (!target) { WorldPacket data; - MakePlayerNotFound(&data, targetName); + MakePlayerNotFound(data, targetName); SendToOne(data, guid); return; } @@ -615,7 +615,7 @@ void Channel::Invite(Player* player, const char* targetName) if (IsOn(targetGuid)) { WorldPacket data; - MakePlayerAlreadyMember(&data, targetGuid); + MakePlayerAlreadyMember(data, targetGuid); SendToOne(data, guid); return; } @@ -623,7 +623,7 @@ void Channel::Invite(Player* player, const char* targetName) if (IsBanned(targetGuid)) { WorldPacket data; - MakePlayerInviteBanned(&data, targetName); + MakePlayerInviteBanned(data, targetName); SendToOne(data, guid); return; } @@ -631,7 +631,7 @@ void Channel::Invite(Player* player, const char* targetName) if (target->GetTeam() != player->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) { WorldPacket data; - MakeInviteWrongFaction(&data); + MakeInviteWrongFaction(data); SendToOne(data, guid); return; } @@ -640,12 +640,12 @@ void Channel::Invite(Player* player, const char* targetName) WorldPacket data; if (!target->GetSocial()->HasIgnore(guid)) { - MakeInvite(&data, guid); + MakeInvite(data, guid); SendToOne(data, targetGuid); data.clear(); } - MakePlayerInvited(&data, targetName); + MakePlayerInvited(data, targetName); SendToOne(data, guid); } @@ -667,12 +667,12 @@ void Channel::SetOwner(ObjectGuid guid, bool exclaim) m_players[m_ownerGuid].SetOwner(true); WorldPacket data; - MakeModeChange(&data, m_ownerGuid, oldFlag); + MakeModeChange(data, m_ownerGuid, oldFlag); SendToAll(data); if (exclaim) { - MakeOwnerChanged(&data, m_ownerGuid); + MakeOwnerChanged(data, m_ownerGuid); SendToAll(data); } } @@ -700,79 +700,79 @@ void Channel::DeVoice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/) { } -void Channel::MakeNotifyPacket(WorldPacket* data, uint8 notify_type) +void Channel::MakeNotifyPacket(WorldPacket& data, uint8 notify_type) { - data->Initialize(SMSG_CHANNEL_NOTIFY, 1 + m_name.size() + 1); - *data << uint8(notify_type); - *data << m_name; + data.Initialize(SMSG_CHANNEL_NOTIFY, 1 + m_name.size() + 1); + data << uint8(notify_type); + data << m_name; } -void Channel::MakeJoined(WorldPacket* data, ObjectGuid guid) +void Channel::MakeJoined(WorldPacket& data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_JOINED_NOTICE); - *data << ObjectGuid(guid); + data << ObjectGuid(guid); } -void Channel::MakeLeft(WorldPacket* data, ObjectGuid guid) +void Channel::MakeLeft(WorldPacket& data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_LEFT_NOTICE); - *data << ObjectGuid(guid); + data << ObjectGuid(guid); } -void Channel::MakeYouJoined(WorldPacket* data) +void Channel::MakeYouJoined(WorldPacket& data) { MakeNotifyPacket(data, CHAT_YOU_JOINED_NOTICE); - *data << uint8(GetFlags()); - *data << uint32(GetChannelId()); - *data << uint32(0); + data << uint8(GetFlags()); + data << uint32(GetChannelId()); + data << uint32(0); } -void Channel::MakeYouLeft(WorldPacket* data) +void Channel::MakeYouLeft(WorldPacket& data) { MakeNotifyPacket(data, CHAT_YOU_LEFT_NOTICE); - *data << uint32(GetChannelId()); - *data << uint8(0); // can be 0x00 and 0x01 + data << uint32(GetChannelId()); + data << uint8(0); // can be 0x00 and 0x01 } -void Channel::MakeWrongPassword(WorldPacket* data) +void Channel::MakeWrongPassword(WorldPacket& data) { MakeNotifyPacket(data, CHAT_WRONG_PASSWORD_NOTICE); } -void Channel::MakeNotMember(WorldPacket* data) +void Channel::MakeNotMember(WorldPacket& data) { MakeNotifyPacket(data, CHAT_NOT_MEMBER_NOTICE); } -void Channel::MakeNotModerator(WorldPacket* data) +void Channel::MakeNotModerator(WorldPacket& data) { MakeNotifyPacket(data, CHAT_NOT_MODERATOR_NOTICE); } -void Channel::MakePasswordChanged(WorldPacket* data, ObjectGuid guid) +void Channel::MakePasswordChanged(WorldPacket& data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_PASSWORD_CHANGED_NOTICE); - *data << ObjectGuid(guid); + data << ObjectGuid(guid); } -void Channel::MakeOwnerChanged(WorldPacket* data, ObjectGuid guid) +void Channel::MakeOwnerChanged(WorldPacket& data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_OWNER_CHANGED_NOTICE); - *data << ObjectGuid(guid); + data << ObjectGuid(guid); } -void Channel::MakePlayerNotFound(WorldPacket* data, const std::string& name) +void Channel::MakePlayerNotFound(WorldPacket& data, const std::string& name) { MakeNotifyPacket(data, CHAT_PLAYER_NOT_FOUND_NOTICE); - *data << name; + data << name; } -void Channel::MakeNotOwner(WorldPacket* data) +void Channel::MakeNotOwner(WorldPacket& data) { MakeNotifyPacket(data, CHAT_NOT_OWNER_NOTICE); } -void Channel::MakeChannelOwner(WorldPacket* data) +void Channel::MakeChannelOwner(WorldPacket& data) { std::string name = ""; @@ -780,147 +780,147 @@ void Channel::MakeChannelOwner(WorldPacket* data) name = "PLAYER_NOT_FOUND"; MakeNotifyPacket(data, CHAT_CHANNEL_OWNER_NOTICE); - *data << ((IsConstant() || !m_ownerGuid) ? "Nobody" : name); + data << ((IsConstant() || !m_ownerGuid) ? "Nobody" : name); } -void Channel::MakeModeChange(WorldPacket* data, ObjectGuid guid, uint8 oldflags) +void Channel::MakeModeChange(WorldPacket& data, ObjectGuid guid, uint8 oldflags) { MakeNotifyPacket(data, CHAT_MODE_CHANGE_NOTICE); - *data << ObjectGuid(guid); - *data << uint8(oldflags); - *data << uint8(GetPlayerFlags(guid)); + data << ObjectGuid(guid); + data << uint8(oldflags); + data << uint8(GetPlayerFlags(guid)); } -void Channel::MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid) +void Channel::MakeAnnouncementsOn(WorldPacket& data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_ON_NOTICE); - *data << ObjectGuid(guid); + data << ObjectGuid(guid); } -void Channel::MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid) +void Channel::MakeAnnouncementsOff(WorldPacket& data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_OFF_NOTICE); - *data << ObjectGuid(guid); + data << ObjectGuid(guid); } -void Channel::MakeModerationOn(WorldPacket* data, ObjectGuid guid) +void Channel::MakeModerationOn(WorldPacket& data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_MODERATION_ON_NOTICE); - *data << ObjectGuid(guid); + data << ObjectGuid(guid); } -void Channel::MakeModerationOff(WorldPacket* data, ObjectGuid guid) +void Channel::MakeModerationOff(WorldPacket& data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_MODERATION_OFF_NOTICE); - *data << ObjectGuid(guid); + data << ObjectGuid(guid); } -void Channel::MakeMuted(WorldPacket* data) +void Channel::MakeMuted(WorldPacket& data) { MakeNotifyPacket(data, CHAT_MUTED_NOTICE); } -void Channel::MakePlayerKicked(WorldPacket* data, ObjectGuid target, ObjectGuid source) +void Channel::MakePlayerKicked(WorldPacket& data, ObjectGuid target, ObjectGuid source) { MakeNotifyPacket(data, CHAT_PLAYER_KICKED_NOTICE); - *data << ObjectGuid(target); - *data << ObjectGuid(source); + data << ObjectGuid(target); + data << ObjectGuid(source); } -void Channel::MakeBanned(WorldPacket* data) +void Channel::MakeBanned(WorldPacket& data) { MakeNotifyPacket(data, CHAT_BANNED_NOTICE); } -void Channel::MakePlayerBanned(WorldPacket* data, ObjectGuid target, ObjectGuid source) +void Channel::MakePlayerBanned(WorldPacket& data, ObjectGuid target, ObjectGuid source) { MakeNotifyPacket(data, CHAT_PLAYER_BANNED_NOTICE); - *data << ObjectGuid(target); - *data << ObjectGuid(source); + data << ObjectGuid(target); + data << ObjectGuid(source); } -void Channel::MakePlayerUnbanned(WorldPacket* data, ObjectGuid target, ObjectGuid source) +void Channel::MakePlayerUnbanned(WorldPacket& data, ObjectGuid target, ObjectGuid source) { MakeNotifyPacket(data, CHAT_PLAYER_UNBANNED_NOTICE); - *data << ObjectGuid(target); - *data << ObjectGuid(source); + data << ObjectGuid(target); + data << ObjectGuid(source); } -void Channel::MakePlayerNotBanned(WorldPacket* data, const std::string& name) +void Channel::MakePlayerNotBanned(WorldPacket& data, const std::string& name) { MakeNotifyPacket(data, CHAT_PLAYER_NOT_BANNED_NOTICE); - *data << name; + data << name; } -void Channel::MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid) +void Channel::MakePlayerAlreadyMember(WorldPacket& data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_PLAYER_ALREADY_MEMBER_NOTICE); - *data << ObjectGuid(guid); + data << ObjectGuid(guid); } -void Channel::MakeInvite(WorldPacket* data, ObjectGuid guid) +void Channel::MakeInvite(WorldPacket& data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_INVITE_NOTICE); - *data << ObjectGuid(guid); + data << ObjectGuid(guid); } -void Channel::MakeInviteWrongFaction(WorldPacket* data) +void Channel::MakeInviteWrongFaction(WorldPacket& data) { MakeNotifyPacket(data, CHAT_INVITE_WRONG_FACTION_NOTICE); } -void Channel::MakeWrongFaction(WorldPacket* data) +void Channel::MakeWrongFaction(WorldPacket& data) { MakeNotifyPacket(data, CHAT_WRONG_FACTION_NOTICE); } -void Channel::MakeInvalidName(WorldPacket* data) +void Channel::MakeInvalidName(WorldPacket& data) { MakeNotifyPacket(data, CHAT_INVALID_NAME_NOTICE); } -void Channel::MakeNotModerated(WorldPacket* data) +void Channel::MakeNotModerated(WorldPacket& data) { MakeNotifyPacket(data, CHAT_NOT_MODERATED_NOTICE); } -void Channel::MakePlayerInvited(WorldPacket* data, const std::string& name) +void Channel::MakePlayerInvited(WorldPacket& data, const std::string& name) { MakeNotifyPacket(data, CHAT_PLAYER_INVITED_NOTICE); - *data << name; + data << name; } -void Channel::MakePlayerInviteBanned(WorldPacket* data, const std::string& name) +void Channel::MakePlayerInviteBanned(WorldPacket& data, const std::string& name) { MakeNotifyPacket(data, CHAT_PLAYER_INVITE_BANNED_NOTICE); - *data << name; + data << name; } -void Channel::MakeThrottled(WorldPacket* data) +void Channel::MakeThrottled(WorldPacket& data) { MakeNotifyPacket(data, CHAT_THROTTLED_NOTICE); } -void Channel::MakeNotInArea(WorldPacket* data) +void Channel::MakeNotInArea(WorldPacket& data) { MakeNotifyPacket(data, CHAT_NOT_IN_AREA_NOTICE); } -void Channel::MakeNotInLfg(WorldPacket* data) +void Channel::MakeNotInLfg(WorldPacket& data) { MakeNotifyPacket(data, CHAT_NOT_IN_LFG_NOTICE); } -void Channel::MakeVoiceOn(WorldPacket* data, ObjectGuid guid) +void Channel::MakeVoiceOn(WorldPacket& data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_VOICE_ON_NOTICE); - *data << ObjectGuid(guid); + data << ObjectGuid(guid); } -void Channel::MakeVoiceOff(WorldPacket* data, ObjectGuid guid) +void Channel::MakeVoiceOff(WorldPacket& data, ObjectGuid guid) { MakeNotifyPacket(data, CHAT_VOICE_OFF_NOTICE); - *data << ObjectGuid(guid); + data << ObjectGuid(guid); } void Channel::JoinNotify(ObjectGuid guid) diff --git a/src/game/Channel.h b/src/game/Channel.h index df3753ecd0..5687de7151 100644 --- a/src/game/Channel.h +++ b/src/game/Channel.h @@ -184,44 +184,44 @@ class Channel private: // initial packet data (notify type and channel name) - void MakeNotifyPacket(WorldPacket* data, uint8 notify_type); + void MakeNotifyPacket(WorldPacket& data, uint8 notify_type); // type specific packet data - void MakeJoined(WorldPacket* data, ObjectGuid guid); //+ 0x00 - void MakeLeft(WorldPacket* data, ObjectGuid guid); //+ 0x01 - void MakeYouJoined(WorldPacket* data); //+ 0x02 - void MakeYouLeft(WorldPacket* data); //+ 0x03 - void MakeWrongPassword(WorldPacket* data); //? 0x04 - void MakeNotMember(WorldPacket* data); //? 0x05 - void MakeNotModerator(WorldPacket* data); //? 0x06 - void MakePasswordChanged(WorldPacket* data, ObjectGuid guid); //+ 0x07 - void MakeOwnerChanged(WorldPacket* data, ObjectGuid guid); //? 0x08 - void MakePlayerNotFound(WorldPacket* data, const std::string& name); //+ 0x09 - void MakeNotOwner(WorldPacket* data); //? 0x0A - void MakeChannelOwner(WorldPacket* data); //? 0x0B - void MakeModeChange(WorldPacket* data, ObjectGuid guid, uint8 oldflags);//+ 0x0C - void MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid); //+ 0x0D - void MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid); //+ 0x0E - void MakeModerationOn(WorldPacket* data, ObjectGuid guid); //+ 0x0F - void MakeModerationOff(WorldPacket* data, ObjectGuid guid); //+ 0x10 - void MakeMuted(WorldPacket* data); //? 0x11 - void MakePlayerKicked(WorldPacket* data, ObjectGuid target, ObjectGuid source);//? 0x12 - void MakeBanned(WorldPacket* data); //? 0x13 - void MakePlayerBanned(WorldPacket* data, ObjectGuid target, ObjectGuid source);//? 0x14 - void MakePlayerUnbanned(WorldPacket* data, ObjectGuid target, ObjectGuid source);//? 0x15 - void MakePlayerNotBanned(WorldPacket* data, const std::string& name); //? 0x16 - void MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid); //+ 0x17 - void MakeInvite(WorldPacket* data, ObjectGuid guid); //? 0x18 - void MakeInviteWrongFaction(WorldPacket* data); //? 0x19 - void MakeWrongFaction(WorldPacket* data); //? 0x1A - void MakeInvalidName(WorldPacket* data); //? 0x1B - void MakeNotModerated(WorldPacket* data); //? 0x1C - void MakePlayerInvited(WorldPacket* data, const std::string& name); //+ 0x1D - void MakePlayerInviteBanned(WorldPacket* data, const std::string& name);//? 0x1E - void MakeThrottled(WorldPacket* data); //? 0x1F - void MakeNotInArea(WorldPacket* data); //? 0x20 - void MakeNotInLfg(WorldPacket* data); //? 0x21 - void MakeVoiceOn(WorldPacket* data, ObjectGuid guid); //+ 0x22 - void MakeVoiceOff(WorldPacket* data, ObjectGuid guid); //+ 0x23 + void MakeJoined(WorldPacket& data, ObjectGuid guid); //+ 0x00 + void MakeLeft(WorldPacket& data, ObjectGuid guid); //+ 0x01 + void MakeYouJoined(WorldPacket& data); //+ 0x02 + void MakeYouLeft(WorldPacket& data); //+ 0x03 + void MakeWrongPassword(WorldPacket& data); //? 0x04 + void MakeNotMember(WorldPacket& data); //? 0x05 + void MakeNotModerator(WorldPacket& data); //? 0x06 + void MakePasswordChanged(WorldPacket& data, ObjectGuid guid); //+ 0x07 + void MakeOwnerChanged(WorldPacket& data, ObjectGuid guid); //? 0x08 + void MakePlayerNotFound(WorldPacket& data, const std::string& name); //+ 0x09 + void MakeNotOwner(WorldPacket& data); //? 0x0A + void MakeChannelOwner(WorldPacket& data); //? 0x0B + void MakeModeChange(WorldPacket& data, ObjectGuid guid, uint8 oldflags);//+ 0x0C + void MakeAnnouncementsOn(WorldPacket& data, ObjectGuid guid); //+ 0x0D + void MakeAnnouncementsOff(WorldPacket& data, ObjectGuid guid); //+ 0x0E + void MakeModerationOn(WorldPacket& data, ObjectGuid guid); //+ 0x0F + void MakeModerationOff(WorldPacket& data, ObjectGuid guid); //+ 0x10 + void MakeMuted(WorldPacket& data); //? 0x11 + void MakePlayerKicked(WorldPacket& data, ObjectGuid target, ObjectGuid source);//? 0x12 + void MakeBanned(WorldPacket& data); //? 0x13 + void MakePlayerBanned(WorldPacket& data, ObjectGuid target, ObjectGuid source);//? 0x14 + void MakePlayerUnbanned(WorldPacket& data, ObjectGuid target, ObjectGuid source);//? 0x15 + void MakePlayerNotBanned(WorldPacket& data, const std::string& name); //? 0x16 + void MakePlayerAlreadyMember(WorldPacket& data, ObjectGuid guid); //+ 0x17 + void MakeInvite(WorldPacket& data, ObjectGuid guid); //? 0x18 + void MakeInviteWrongFaction(WorldPacket& data); //? 0x19 + void MakeWrongFaction(WorldPacket& data); //? 0x1A + void MakeInvalidName(WorldPacket& data); //? 0x1B + void MakeNotModerated(WorldPacket& data); //? 0x1C + void MakePlayerInvited(WorldPacket& data, const std::string& name); //+ 0x1D + void MakePlayerInviteBanned(WorldPacket& data, const std::string& name);//? 0x1E + void MakeThrottled(WorldPacket& data); //? 0x1F + void MakeNotInArea(WorldPacket& data); //? 0x20 + void MakeNotInLfg(WorldPacket& data); //? 0x21 + void MakeVoiceOn(WorldPacket& data, ObjectGuid guid); //+ 0x22 + void MakeVoiceOff(WorldPacket& data, ObjectGuid guid); //+ 0x23 void SendToAll(WorldPacket const& data, ObjectGuid guid = ObjectGuid()) const; void SendToOne(WorldPacket const& data, ObjectGuid who) const; @@ -246,7 +246,7 @@ class Channel m_players[guid].SetModerator(set); WorldPacket data; - MakeModeChange(&data, guid, oldFlag); + MakeModeChange(data, guid, oldFlag); SendToAll(data); } } @@ -259,7 +259,7 @@ class Channel m_players[guid].SetMuted(set); WorldPacket data; - MakeModeChange(&data, guid, oldFlag); + MakeModeChange(data, guid, oldFlag); SendToAll(data); } } diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 3a38260589..22730d2edd 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -144,7 +144,7 @@ void WorldSession::HandleCharEnum(QueryResult* result) { uint32 guidlow = (*result)[0].GetUInt32(); DETAIL_LOG("Build enum data for char guid %u from account %u.", guidlow, GetAccountId()); - if (Player::BuildEnumData(result, &data)) + if (Player::BuildEnumData(result, data)) ++num; } while (result->NextRow()); diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp index 62122b28cd..1de781c64c 100644 --- a/src/game/GridNotifiers.cpp +++ b/src/game/GridNotifiers.cpp @@ -69,7 +69,7 @@ void VisibleNotifier::Notify() { // send create/outofrange packet to player (except player create updates that already sent using SendUpdateToPlayer) WorldPacket packet; - i_data.BuildPacket(&packet); + i_data.BuildPacket(packet); player.GetSession()->SendPacket(packet); // send out of range to other players if need diff --git a/src/game/Group.cpp b/src/game/Group.cpp index 2550c9d796..3cda01c4cd 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -575,7 +575,7 @@ void Group::UpdatePlayerOutOfRange(Player* pPlayer) return; WorldPacket data; - pPlayer->GetSession()->BuildPartyMemberStatsChangedPacket(pPlayer, &data); + pPlayer->GetSession()->BuildPartyMemberStatsChangedPacket(pPlayer, data); for (GroupReference* itr = GetFirstMember(); itr != nullptr; itr = itr->next()) if (Player* player = itr->getSource()) diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp index 41e79b5550..94cc6400de 100644 --- a/src/game/GroupHandler.cpp +++ b/src/game/GroupHandler.cpp @@ -585,7 +585,7 @@ void WorldSession::HandleRaidReadyCheckFinishedOpcode(WorldPacket& /*recv_data*/ group->BroadcastPacket(data, true, -1); } -void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacket* data) +void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacket& data) { uint32 mask = player->GetGroupUpdateFlag(); @@ -600,110 +600,110 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke if (mask & (1 << i)) byteCount += GroupUpdateLength[i]; - data->Initialize(SMSG_PARTY_MEMBER_STATS, 8 + 4 + byteCount); - *data << player->GetPackGUID(); - *data << uint32(mask); + data.Initialize(SMSG_PARTY_MEMBER_STATS, 8 + 4 + byteCount); + data << player->GetPackGUID(); + data << uint32(mask); if (mask & GROUP_UPDATE_FLAG_STATUS) - *data << uint16(GetGroupMemberStatus(player)); + data << uint16(GetGroupMemberStatus(player)); if (mask & GROUP_UPDATE_FLAG_CUR_HP) - *data << (uint16) player->GetHealth(); + data << (uint16) player->GetHealth(); if (mask & GROUP_UPDATE_FLAG_MAX_HP) - *data << (uint16) player->GetMaxHealth(); + data << (uint16) player->GetMaxHealth(); Powers powerType = player->GetPowerType(); if (mask & GROUP_UPDATE_FLAG_POWER_TYPE) - *data << uint8(powerType); + data << uint8(powerType); if (mask & GROUP_UPDATE_FLAG_CUR_POWER) - *data << uint16(player->GetPower(powerType)); + data << uint16(player->GetPower(powerType)); if (mask & GROUP_UPDATE_FLAG_MAX_POWER) - *data << uint16(player->GetMaxPower(powerType)); + data << uint16(player->GetMaxPower(powerType)); if (mask & GROUP_UPDATE_FLAG_LEVEL) - *data << uint16(player->getLevel()); + data << uint16(player->getLevel()); if (mask & GROUP_UPDATE_FLAG_ZONE) - *data << uint16(player->GetZoneId()); + data << uint16(player->GetZoneId()); if (mask & GROUP_UPDATE_FLAG_POSITION) - *data << uint16(player->GetPositionX()) << uint16(player->GetPositionY()); + data << uint16(player->GetPositionX()) << uint16(player->GetPositionY()); if (mask & GROUP_UPDATE_FLAG_AURAS) { const uint64& auramask = player->GetAuraUpdateMask(); - *data << uint64(auramask); + data << uint64(auramask); for (uint32 i = 0; i < MAX_AURAS; ++i) { if (auramask & (uint64(1) << i)) { - *data << uint16(player->GetUInt32Value(UNIT_FIELD_AURA + i)); - *data << uint8(1); + data << uint16(player->GetUInt32Value(UNIT_FIELD_AURA + i)); + data << uint8(1); } } } Pet* pet = player->GetPet(); if (mask & GROUP_UPDATE_FLAG_PET_GUID) - *data << (pet ? pet->GetObjectGuid() : ObjectGuid()); + data << (pet ? pet->GetObjectGuid() : ObjectGuid()); if (mask & GROUP_UPDATE_FLAG_PET_NAME) { if (pet) - *data << pet->GetName(); + data << pet->GetName(); else - *data << uint8(0); + data << uint8(0); } if (mask & GROUP_UPDATE_FLAG_PET_MODEL_ID) { if (pet) - *data << uint16(pet->GetDisplayId()); + data << uint16(pet->GetDisplayId()); else - *data << uint16(0); + data << uint16(0); } if (mask & GROUP_UPDATE_FLAG_PET_CUR_HP) { if (pet) - *data << uint16(pet->GetHealth()); + data << uint16(pet->GetHealth()); else - *data << uint16(0); + data << uint16(0); } if (mask & GROUP_UPDATE_FLAG_PET_MAX_HP) { if (pet) - *data << uint16(pet->GetMaxHealth()); + data << uint16(pet->GetMaxHealth()); else - *data << uint16(0); + data << uint16(0); } if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE) { if (pet) - *data << uint8(pet->GetPowerType()); + data << uint8(pet->GetPowerType()); else - *data << uint8(0); + data << uint8(0); } if (mask & GROUP_UPDATE_FLAG_PET_CUR_POWER) { if (pet) - *data << uint16(pet->GetPower(pet->GetPowerType())); + data << uint16(pet->GetPower(pet->GetPowerType())); else - *data << uint16(0); + data << uint16(0); } if (mask & GROUP_UPDATE_FLAG_PET_MAX_POWER) { if (pet) - *data << uint16(pet->GetMaxPower(pet->GetPowerType())); + data << uint16(pet->GetMaxPower(pet->GetPowerType())); else - *data << uint16(0); + data << uint16(0); } if (mask & GROUP_UPDATE_FLAG_PET_AURAS) @@ -711,18 +711,18 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke if (pet) { const uint64& auramask = pet->GetAuraUpdateMask(); - *data << uint64(auramask); + data << uint64(auramask); for (uint32 i = 0; i < MAX_AURAS; ++i) { if (auramask & (uint64(1) << i)) { - *data << uint16(pet->GetUInt32Value(UNIT_FIELD_AURA + i)); - *data << uint8(1); + data << uint16(pet->GetUInt32Value(UNIT_FIELD_AURA + i)); + data << uint8(1); } } } else - *data << uint64(0); + data << uint64(0); } } diff --git a/src/game/Map.cpp b/src/game/Map.cpp index ba00b2d7b5..bc42602157 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -913,7 +913,7 @@ void Map::SendInitSelf(Player* player) } WorldPacket packet; - data.BuildPacket(&packet, hasTransport); + data.BuildPacket(packet, hasTransport); player->GetSession()->SendPacket(packet); } @@ -943,7 +943,7 @@ void Map::SendInitTransports(Player* player) } WorldPacket packet; - transData.BuildPacket(&packet, hasTransport); + transData.BuildPacket(packet, hasTransport); player->GetSession()->SendPacket(packet); } @@ -966,7 +966,7 @@ void Map::SendRemoveTransports(Player* player) (*i)->BuildOutOfRangeUpdateBlock(&transData); WorldPacket packet; - transData.BuildPacket(&packet); + transData.BuildPacket(packet); player->GetSession()->SendPacket(packet); } @@ -1852,7 +1852,7 @@ void Map::SendObjectUpdates() WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) { - iter->second.BuildPacket(&packet); + iter->second.BuildPacket(packet); iter->first->GetSession()->SendPacket(packet); packet.clear(); // clean the string } diff --git a/src/game/Object.cpp b/src/game/Object.cpp index ae3da50b99..c2fd105e60 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -112,7 +112,7 @@ void Object::SendForcedObjectUpdate() WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) { - iter->second.BuildPacket(&packet); + iter->second.BuildPacket(packet); iter->first->GetSession()->SendPacket(packet); packet.clear(); // clean the string } @@ -188,7 +188,7 @@ void Object::SendCreateUpdateToPlayer(Player* player) WorldPacket packet; BuildCreateUpdateBlockForPlayer(&upd, player); - upd.BuildPacket(&packet); + upd.BuildPacket(packet); player->GetSession()->SendPacket(packet); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 52f3e0c5bf..17822ad9de 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1422,7 +1422,7 @@ void Player::SetDeathState(DeathState s) SetGroupUpdateFlag(GROUP_UPDATE_FLAG_STATUS); } -bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) +bool Player::BuildEnumData(QueryResult* result, WorldPacket& p_data) { // 0 1 2 3 4 5 6 7 // "SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.playerBytes, characters.playerBytes2, characters.level, " @@ -1444,30 +1444,30 @@ bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) return false; } - *p_data << ObjectGuid(HIGHGUID_PLAYER, guid); - *p_data << fields[1].GetString(); // name - *p_data << uint8(pRace); // race - *p_data << uint8(pClass); // class - *p_data << uint8(fields[4].GetUInt8()); // gender + p_data << ObjectGuid(HIGHGUID_PLAYER, guid); + p_data << fields[1].GetString(); // name + p_data << uint8(pRace); // race + p_data << uint8(pClass); // class + p_data << uint8(fields[4].GetUInt8()); // gender uint32 playerBytes = fields[5].GetUInt32(); - *p_data << uint8(playerBytes); // skin - *p_data << uint8(playerBytes >> 8); // face - *p_data << uint8(playerBytes >> 16); // hair style - *p_data << uint8(playerBytes >> 24); // hair color + p_data << uint8(playerBytes); // skin + p_data << uint8(playerBytes >> 8); // face + p_data << uint8(playerBytes >> 16); // hair style + p_data << uint8(playerBytes >> 24); // hair color uint32 playerBytes2 = fields[6].GetUInt32(); - *p_data << uint8(playerBytes2 & 0xFF); // facial hair + p_data << uint8(playerBytes2 & 0xFF); // facial hair - *p_data << uint8(fields[7].GetUInt8()); // level - *p_data << uint32(fields[8].GetUInt32()); // zone - *p_data << uint32(fields[9].GetUInt32()); // map + p_data << uint8(fields[7].GetUInt8()); // level + p_data << uint32(fields[8].GetUInt32()); // zone + p_data << uint32(fields[9].GetUInt32()); // map - *p_data << fields[10].GetFloat(); // x - *p_data << fields[11].GetFloat(); // y - *p_data << fields[12].GetFloat(); // z + p_data << fields[10].GetFloat(); // x + p_data << fields[11].GetFloat(); // y + p_data << fields[12].GetFloat(); // z - *p_data << uint32(fields[13].GetUInt32()); // guild id + p_data << uint32(fields[13].GetUInt32()); // guild id uint32 char_flags = 0; uint32 playerFlags = fields[14].GetUInt32(); @@ -1488,10 +1488,10 @@ bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) else char_flags |= CHARACTER_FLAG_DECLINED; - *p_data << uint32(char_flags); // character flags + p_data << uint32(char_flags); // character flags // First login - *p_data << uint8(atLoginFlags & AT_LOGIN_FIRST ? 1 : 0); + p_data << uint8(atLoginFlags & AT_LOGIN_FIRST ? 1 : 0); // Pets info { @@ -1512,9 +1512,9 @@ bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) } } - *p_data << uint32(petDisplayId); - *p_data << uint32(petLevel); - *p_data << uint32(petFamily); + p_data << uint32(petDisplayId); + p_data << uint32(petLevel); + p_data << uint32(petFamily); } @@ -1526,9 +1526,9 @@ bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) const ItemPrototype* proto = ObjectMgr::GetItemPrototype(item_id); if (!proto) { - *p_data << uint32(0); - *p_data << uint8(0); - *p_data << uint32(0); + p_data << uint32(0); + p_data << uint8(0); + p_data << uint32(0); continue; } @@ -1546,14 +1546,14 @@ bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) break; } - *p_data << uint32(proto->DisplayInfoID); - *p_data << uint8(proto->InventoryType); - *p_data << uint32(enchant ? enchant->aura_id : 0); + p_data << uint32(proto->DisplayInfoID); + p_data << uint8(proto->InventoryType); + p_data << uint32(enchant ? enchant->aura_id : 0); } - *p_data << uint32(0); // first bag display id - *p_data << uint8(0); // first bag inventory type - *p_data << uint32(0); // enchant? + p_data << uint32(0); // first bag display id + p_data << uint8(0); // first bag inventory type + p_data << uint32(0); // enchant? return true; } @@ -16920,7 +16920,7 @@ void Player::PetSpellInitialize() data << uint8(charmInfo->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0); // action bar loop - charmInfo->BuildActionBar(&data); + charmInfo->BuildActionBar(data); size_t spellsCountPos = data.wpos(); @@ -16991,7 +16991,7 @@ void Player::PossessSpellInitialize() data << uint32(0); data << uint32(0); - charmInfo->BuildActionBar(&data); + charmInfo->BuildActionBar(data); data << uint8(0); // spells count data << uint8(0); // cooldowns count @@ -17038,7 +17038,7 @@ void Player::CharmSpellInitialize() else data << uint8(0) << uint8(0) << uint16(0); - charmInfo->BuildActionBar(&data); + charmInfo->BuildActionBar(data); data << uint8(addlist); @@ -19181,7 +19181,7 @@ void Player::UpdateForQuestWorldObjects() obj->BuildValuesUpdateBlockForPlayer(&udata, this); } } - udata.BuildPacket(&packet); + udata.BuildPacket(packet); GetSession()->SendPacket(packet); } diff --git a/src/game/Player.h b/src/game/Player.h index 654ea87c82..babda6b4a3 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -952,7 +952,7 @@ class MANGOS_DLL_SPEC Player : public Unit void Update(uint32 update_diff, uint32 time) override; - static bool BuildEnumData(QueryResult* result, WorldPacket* p_data); + static bool BuildEnumData(QueryResult* result, WorldPacket& p_data); void SetInWater(bool apply); diff --git a/src/game/SocialMgr.cpp b/src/game/SocialMgr.cpp index d2c371c734..887d4b55a9 100644 --- a/src/game/SocialMgr.cpp +++ b/src/game/SocialMgr.cpp @@ -220,11 +220,11 @@ void SocialMgr::GetFriendInfo(Player* player, uint32 friend_lowguid, FriendInfo& } } -void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldPacket* data) +void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldPacket& data) { - data->Initialize(SMSG_FRIEND_STATUS, 5); - *data << uint8(result); - *data << ObjectGuid(HIGHGUID_PLAYER, guid); + data.Initialize(SMSG_FRIEND_STATUS, 5); + data << uint8(result); + data << ObjectGuid(HIGHGUID_PLAYER, guid); } void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, ObjectGuid friend_guid, bool broadcast) @@ -234,7 +234,7 @@ void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, ObjectGui FriendInfo fi; WorldPacket data; - MakeFriendStatusPacket(result, friend_lowguid, &data); + MakeFriendStatusPacket(result, friend_lowguid, data); GetFriendInfo(player, friend_lowguid, fi); switch (result) { diff --git a/src/game/SocialMgr.h b/src/game/SocialMgr.h index ebdc0bd5f1..2e6a71f4fe 100644 --- a/src/game/SocialMgr.h +++ b/src/game/SocialMgr.h @@ -140,7 +140,7 @@ class SocialMgr void GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo& friendInfo); // Packet management - void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket* data); + void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket& data); void SendFriendStatus(Player* player, FriendsResult result, ObjectGuid friend_guid, bool broadcast); void BroadcastToFriendListers(Player* player, WorldPacket const& packet) const; // Loading diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 7e4046ec3f..ada9dd0e6e 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -3531,7 +3531,7 @@ void Spell::SendSpellStart() data << m_targets; if (castFlags & CAST_FLAG_AMMO) // projectile info - WriteAmmoToPacket(&data); + WriteAmmoToPacket(data); m_caster->SendMessageToSet(data, true); } @@ -3560,17 +3560,17 @@ void Spell::SendSpellGo() data << uint16(castFlags); // cast flags data << uint32(WorldTimer::getMSTime()); // timestamp - WriteSpellGoTargets(&data); + WriteSpellGoTargets(data); data << m_targets; if (castFlags & CAST_FLAG_AMMO) // projectile info - WriteAmmoToPacket(&data); + WriteAmmoToPacket(data); m_caster->SendMessageToSet(data, true); } -void Spell::WriteAmmoToPacket(WorldPacket* data) +void Spell::WriteAmmoToPacket(WorldPacket& data) { uint32 ammoInventoryType = 0; uint32 ammoDisplayID = 0; @@ -3636,14 +3636,14 @@ void Spell::WriteAmmoToPacket(WorldPacket* data) } } - *data << uint32(ammoDisplayID); - *data << uint32(ammoInventoryType); + data << uint32(ammoDisplayID); + data << uint32(ammoInventoryType); } -void Spell::WriteSpellGoTargets(WorldPacket* data) +void Spell::WriteSpellGoTargets(WorldPacket& data) { - size_t count_pos = data->wpos(); - *data << uint8(0); // placeholder + size_t count_pos = data.wpos(); + data << uint8(0); // placeholder // This function also fill data for channeled spells: // m_needAliveTargetMask req for stop channeling if one target die @@ -3661,7 +3661,7 @@ void Spell::WriteSpellGoTargets(WorldPacket* data) else if (ihit->missCondition == SPELL_MISS_NONE) // Add only hits { ++hit; - *data << ihit->targetGUID; + data << ihit->targetGUID; m_needAliveTargetMask |= ihit->effectMask; } else @@ -3673,19 +3673,19 @@ void Spell::WriteSpellGoTargets(WorldPacket* data) } for (GOTargetList::const_iterator ighit = m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end(); ++ighit) - *data << ighit->targetGUID; // Always hits + data << ighit->targetGUID; // Always hits - data->put(count_pos, hit); + data.put(count_pos, hit); - *data << (uint8)miss; + data << (uint8)miss; for (TargetList::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { if (ihit->missCondition != SPELL_MISS_NONE) // Add only miss { - *data << ihit->targetGUID; - *data << uint8(ihit->missCondition); + data << ihit->targetGUID; + data << uint8(ihit->missCondition); if (ihit->missCondition == SPELL_MISS_REFLECT) - *data << uint8(ihit->reflectResult); + data << uint8(ihit->reflectResult); } } // Reset m_needAliveTargetMask for non channeled spell diff --git a/src/game/Spell.h b/src/game/Spell.h index d7613e3ce9..c2c25eed7d 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -375,8 +375,8 @@ class Spell bool DoSummonCritter(CreatureSummonPositions& list, SummonPropertiesEntry const* prop, SpellEffectIndex effIdx, uint32 level); bool DoSummonPossessed(CreatureSummonPositions& list, SummonPropertiesEntry const* prop, SpellEffectIndex effIdx, uint32 level); - void WriteSpellGoTargets(WorldPacket* data); - void WriteAmmoToPacket(WorldPacket* data); + void WriteSpellGoTargets(WorldPacket& data); + void WriteAmmoToPacket(WorldPacket& data); template WorldObject* FindCorpseUsing(); diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 215d9e6467..5e215d3304 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -551,7 +551,7 @@ void Transport::UpdateForMap(Map const* targetMap) UpdateData transData; BuildCreateUpdateBlockForPlayer(&transData, itr->getSource()); WorldPacket packet; - transData.BuildPacket(&packet, true); + transData.BuildPacket(packet, true); itr->getSource()->SendDirectMessage(packet); } } @@ -561,7 +561,7 @@ void Transport::UpdateForMap(Map const* targetMap) UpdateData transData; BuildOutOfRangeUpdateBlock(&transData); WorldPacket out_packet; - transData.BuildPacket(&out_packet, true); + transData.BuildPacket(out_packet, true); for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr) if (this != itr->getSource()->GetTransport()) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 44f0f9193e..a64cf323df 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8945,10 +8945,10 @@ void CharmInfo::LoadPetActionBar(const std::string& data) } } -void CharmInfo::BuildActionBar(WorldPacket* data) +void CharmInfo::BuildActionBar(WorldPacket& data) { for (uint32 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) - *data << uint32(PetActionBar[i].packedData); + data << uint32(PetActionBar[i].packedData); } void CharmInfo::SetSpellAutocast(uint32 spell_id, bool state) diff --git a/src/game/Unit.h b/src/game/Unit.h index 1a994ccf03..5936f350a4 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1010,7 +1010,7 @@ struct CharmInfo bool AddSpellToActionBar(uint32 spellId, ActiveStates newstate = ACT_DECIDE); bool RemoveSpellFromActionBar(uint32 spell_id); void LoadPetActionBar(const std::string& data); - void BuildActionBar(WorldPacket* data); + void BuildActionBar(WorldPacket& data); void SetSpellAutocast(uint32 spell_id, bool state); void SetActionBar(uint8 index, uint32 spellOrAction, ActiveStates type) { diff --git a/src/game/UpdateData.cpp b/src/game/UpdateData.cpp index 329ca1ade6..884efc2906 100644 --- a/src/game/UpdateData.cpp +++ b/src/game/UpdateData.cpp @@ -102,9 +102,9 @@ void UpdateData::Compress(void* dst, uint32* dst_size, void* src, int src_size) *dst_size = c_stream.total_out; } -bool UpdateData::BuildPacket(WorldPacket* packet, bool hasTransport) +bool UpdateData::BuildPacket(WorldPacket& packet, bool hasTransport) { - MANGOS_ASSERT(packet->empty()); // shouldn't happen + MANGOS_ASSERT(packet.empty()); // shouldn't happen ByteBuffer buf(4 + 1 + (m_outOfRangeGUIDs.empty() ? 0 : 1 + 4 + 9 * m_outOfRangeGUIDs.size()) + m_data.wpos()); @@ -127,20 +127,20 @@ bool UpdateData::BuildPacket(WorldPacket* packet, bool hasTransport) if (pSize > 100) // compress large packets { uint32 destsize = compressBound(pSize); - packet->resize(destsize + sizeof(uint32)); + packet.resize(destsize + sizeof(uint32)); - packet->put(0, pSize); - Compress(const_cast(packet->contents()) + sizeof(uint32), &destsize, (void*)buf.contents(), pSize); + packet.put(0, pSize); + Compress(const_cast(packet.contents()) + sizeof(uint32), &destsize, (void*)buf.contents(), pSize); if (destsize == 0) return false; - packet->resize(destsize + sizeof(uint32)); - packet->SetOpcode(SMSG_COMPRESSED_UPDATE_OBJECT); + packet.resize(destsize + sizeof(uint32)); + packet.SetOpcode(SMSG_COMPRESSED_UPDATE_OBJECT); } else // send small packets without compression { - packet->append(buf); - packet->SetOpcode(SMSG_UPDATE_OBJECT); + packet.append(buf); + packet.SetOpcode(SMSG_UPDATE_OBJECT); } return true; diff --git a/src/game/UpdateData.h b/src/game/UpdateData.h index b57d723094..91777dd0b7 100644 --- a/src/game/UpdateData.h +++ b/src/game/UpdateData.h @@ -54,7 +54,7 @@ class UpdateData void AddOutOfRangeGUID(GuidSet& guids); void AddOutOfRangeGUID(ObjectGuid const& guid); void AddUpdateBlock(const ByteBuffer& block); - bool BuildPacket(WorldPacket* packet, bool hasTransport = false); + bool BuildPacket(WorldPacket& packet, bool hasTransport = false); bool HasData() { return m_blockCount > 0 || !m_outOfRangeGUIDs.empty(); } void Clear(); diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 1a44aac9e5..b8aa6d6b5c 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -59,9 +59,9 @@ static bool MapSessionFilterHelper(WorldSession* session, OpcodeHandler const& o } -bool MapSessionFilter::Process(WorldPacket* packet) +bool MapSessionFilter::Process(WorldPacket const& packet) const { - OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()]; + OpcodeHandler const& opHandle = opcodeTable[packet.GetOpcode()]; if (opHandle.packetProcessing == PROCESS_INPLACE) return true; @@ -71,9 +71,9 @@ bool MapSessionFilter::Process(WorldPacket* packet) // we should process ALL packets when player is not in world/logged in // OR packet handler is not thread-safe! -bool WorldSessionFilter::Process(WorldPacket* packet) +bool WorldSessionFilter::Process(WorldPacket const& packet) const { - OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()]; + OpcodeHandler const& opHandle = opcodeTable[packet.GetOpcode()]; // check if packet handler is supposed to be safe if (opHandle.packetProcessing == PROCESS_INPLACE) return true; diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 5ac63cbc27..a2d9e52820 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -116,7 +116,7 @@ class PacketFilter explicit PacketFilter(WorldSession* pSession) : m_pSession(pSession) {} virtual ~PacketFilter() {} - virtual bool Process(WorldPacket* /*packet*/) { return true; } + virtual bool Process(WorldPacket const& /*packet*/) const { return true; } virtual bool ProcessLogout() const { return true; } protected: @@ -130,7 +130,7 @@ class MapSessionFilter : public PacketFilter explicit MapSessionFilter(WorldSession* pSession) : PacketFilter(pSession) {} ~MapSessionFilter() {} - virtual bool Process(WorldPacket* packet) override; + virtual bool Process(WorldPacket const& packet) const override; // in Map::Update() we do not process player logout! virtual bool ProcessLogout() const override { return false; } }; @@ -143,7 +143,7 @@ class WorldSessionFilter : public PacketFilter explicit WorldSessionFilter(WorldSession* pSession) : PacketFilter(pSession) {} ~WorldSessionFilter() {} - virtual bool Process(WorldPacket* packet) override; + virtual bool Process(WorldPacket const& packet) const override; }; /// Player session in the World @@ -295,7 +295,7 @@ class MANGOS_DLL_SPEC WorldSession bool LookingForGroup_auto_join; bool LookingForGroup_auto_add; - void BuildPartyMemberStatsChangedPacket(Player* player, WorldPacket* data); + void BuildPartyMemberStatsChangedPacket(Player* player, WorldPacket& data); // Account mute time time_t m_muteTime; diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index 7c96ddf2eb..867d1c3e6e 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -437,7 +437,7 @@ bool WorldSocket::HandleAuthSession(WorldPacket &recvPacket) sWorld.AddSession(m_session); // Create and send the Addon packet - if (sAddOnHandler.BuildAddonPacket(&recvPacket, &SendAddonPacked)) + if (sAddOnHandler.BuildAddonPacket(recvPacket, SendAddonPacked)) SendPacket(SendAddonPacked); return true;