diff options
48 files changed, 651 insertions, 618 deletions
diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index b00b3a2c9c5..f2356970327 100644 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -166,7 +166,17 @@ void PlayerSocial::SendSocialList(Player* player, uint32 flags) SocialMgr::GetFriendInfo(player, v.first, v.second); - contactList.Contacts.emplace_back(v.first, v.second); + WorldPackets::Social::ContactInfo& contact = contactList.Contacts.emplace_back(); + contact.Guid = v.first; + contact.WowAccountGuid = v.second.WowAccountGuid; + contact.VirtualRealmAddr = GetVirtualRealmAddress(); + contact.NativeRealmAddr = GetVirtualRealmAddress(); + contact.TypeFlags = v.second.Flags; + contact.Notes = v.second.Note; + contact.Status = v.second.Status; + contact.AreaID = v.second.Area; + contact.Level = v.second.Level; + contact.ClassID = v.second.Class; } player->SendDirectMessage(contactList.Write()); @@ -252,7 +262,15 @@ void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, ObjectGui GetFriendInfo(player, friendGuid, fi); WorldPackets::Social::FriendStatus friendStatus; - friendStatus.Initialize(friendGuid, result, fi); + friendStatus.VirtualRealmAddress = GetVirtualRealmAddress(); + friendStatus.Notes = fi.Note; + friendStatus.ClassID = fi.Class; + friendStatus.Status = fi.Status; + friendStatus.Guid = friendGuid; + friendStatus.WowAccountGuid = fi.WowAccountGuid; + friendStatus.Level = fi.Level; + friendStatus.AreaID = fi.Area; + friendStatus.FriendResult = result; if (broadcast) BroadcastToFriendListers(player, friendStatus.Write()); diff --git a/src/server/game/Server/Packets/CalendarPackets.h b/src/server/game/Server/Packets/CalendarPackets.h index 2c23d07f44d..f2457e803eb 100644 --- a/src/server/game/Server/Packets/CalendarPackets.h +++ b/src/server/game/Server/Packets/CalendarPackets.h @@ -587,4 +587,4 @@ namespace WorldPackets } } -#endif // CalendarPackets_h__ +#endif // TRINITYCORE_CALENDAR_PACKETS_H diff --git a/src/server/game/Server/Packets/MiscPackets.cpp b/src/server/game/Server/Packets/MiscPackets.cpp index 1b6d7436084..29a1a7ed5ae 100644 --- a/src/server/game/Server/Packets/MiscPackets.cpp +++ b/src/server/game/Server/Packets/MiscPackets.cpp @@ -535,7 +535,7 @@ void FarSight::Read() void SaveCUFProfiles::Read() { - CUFProfiles.resize(_worldPacket.read<uint32>()); + _worldPacket >> Size<uint32>(CUFProfiles); for (std::unique_ptr<CUFProfile>& cufProfile : CUFProfiles) { cufProfile = std::make_unique<CUFProfile>(); diff --git a/src/server/game/Server/Packets/MovementPackets.cpp b/src/server/game/Server/Packets/MovementPackets.cpp index ac1532ef21f..443c458339e 100644 --- a/src/server/game/Server/Packets/MovementPackets.cpp +++ b/src/server/game/Server/Packets/MovementPackets.cpp @@ -278,7 +278,8 @@ ByteBuffer& operator<<(ByteBuffer& data, MonsterSplineFilter const& monsterSplin data << int16(monsterSplineFilter.AddedToStart); for (MonsterSplineFilterKey const& filterKey : monsterSplineFilter.FilterKeys) data << filterKey; - data.WriteBits(monsterSplineFilter.FilterFlags, 2); + + data << Bits<2>(monsterSplineFilter.FilterFlags); data.FlushBits(); return data; @@ -753,8 +754,8 @@ WorldPacket const* TransferAborted::Write() ByteBuffer& operator<<(ByteBuffer& data, TeleportLocation const& teleportLocation) { data << teleportLocation.Pos; - data << int32(teleportLocation.Unused901_1); - data << int32(teleportLocation.Unused901_2); + data << int32(teleportLocation.FloorDifficulty); + data << int32(teleportLocation.FloorIndex); return data; } diff --git a/src/server/game/Server/Packets/MovementPackets.h b/src/server/game/Server/Packets/MovementPackets.h index 550e92b4e89..cbfba392381 100644 --- a/src/server/game/Server/Packets/MovementPackets.h +++ b/src/server/game/Server/Packets/MovementPackets.h @@ -294,8 +294,8 @@ namespace WorldPackets struct TeleportLocation { TaggedPosition<Position::XYZO> Pos; - int32 Unused901_1 = -1; - int32 Unused901_2 = -1; + int32 FloorDifficulty = -1; + int32 FloorIndex = -1; }; class NewWorld final : public ServerPacket diff --git a/src/server/game/Server/Packets/PacketUtilities.h b/src/server/game/Server/Packets/PacketUtilities.h index 5431d091345..99c8ddaaac1 100644 --- a/src/server/game/Server/Packets/PacketUtilities.h +++ b/src/server/game/Server/Packets/PacketUtilities.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef PacketUtilities_h__ -#define PacketUtilities_h__ +#ifndef TRINITYCORE_PACKET_UTILITIES_H +#define TRINITYCORE_PACKET_UTILITIES_H #include "ByteBuffer.h" #include "Duration.h" @@ -648,4 +648,4 @@ namespace WorldPackets } } -#endif // PacketUtilities_h__ +#endif // TRINITYCORE_PACKET_UTILITIES_H diff --git a/src/server/game/Server/Packets/QueryPackets.cpp b/src/server/game/Server/Packets/QueryPackets.cpp index 42ca4b623d2..046bc7755c8 100644 --- a/src/server/game/Server/Packets/QueryPackets.cpp +++ b/src/server/game/Server/Packets/QueryPackets.cpp @@ -422,7 +422,7 @@ WorldPacket const* QuestPOIQueryResponse::Write() void QueryQuestCompletionNPCs::Read() { - QuestCompletionNPCs.resize(_worldPacket.read<uint32>()); + _worldPacket >> Size<uint32>(QuestCompletionNPCs); if (!QuestCompletionNPCs.empty()) _worldPacket.read(QuestCompletionNPCs.data(), QuestCompletionNPCs.size()); } diff --git a/src/server/game/Server/Packets/ScenarioPackets.cpp b/src/server/game/Server/Packets/ScenarioPackets.cpp index 0e361a6ea42..47ffbe95696 100644 --- a/src/server/game/Server/Packets/ScenarioPackets.cpp +++ b/src/server/game/Server/Packets/ScenarioPackets.cpp @@ -23,16 +23,18 @@ namespace WorldPackets::Scenario ByteBuffer& operator<<(ByteBuffer& data, BonusObjectiveData const& bonusObjective) { data << int32(bonusObjective.BonusObjectiveID); - data.WriteBit(bonusObjective.ObjectiveComplete); + data << Bits<1>(bonusObjective.ObjectiveComplete); data.FlushBits(); + return data; } ByteBuffer& operator<<(ByteBuffer& data, ScenarioSpellUpdate const& spell) { data << uint32(spell.SpellID); - data.WriteBit(spell.Usable); + data << Bits<1>(spell.Usable); data.FlushBits(); + return data; } @@ -45,16 +47,16 @@ WorldPacket const* ScenarioState::Write() _worldPacket << uint32(WaveCurrent); _worldPacket << uint32(WaveMax); _worldPacket << uint32(TimerDuration); - _worldPacket << uint32(CriteriaProgress.size()); - _worldPacket << uint32(BonusObjectives.size()); - _worldPacket << uint32(PickedSteps.size()); - _worldPacket << uint32(Spells.size()); + _worldPacket << Size<uint32>(CriteriaProgress); + _worldPacket << Size<uint32>(BonusObjectives); + _worldPacket << Size<uint32>(PickedSteps); + _worldPacket << Size<uint32>(Spells); _worldPacket << PlayerGUID; if (!PickedSteps.empty()) _worldPacket.append(PickedSteps.data(), PickedSteps.size()); - _worldPacket.WriteBit(ScenarioComplete); + _worldPacket << Bits<1>(ScenarioComplete); _worldPacket.FlushBits(); for (Achievement::CriteriaProgress const& progress : CriteriaProgress) @@ -88,7 +90,7 @@ WorldPacket const* ScenarioVacate::Write() _worldPacket << ScenarioGUID; _worldPacket << int32(ScenarioID); _worldPacket << int32(TimeRemain); - _worldPacket.WriteBits(Reason, 2); + _worldPacket << Bits<2>(Reason); _worldPacket.FlushBits(); return &_worldPacket; @@ -96,19 +98,19 @@ WorldPacket const* ScenarioVacate::Write() void QueryScenarioPOI::Read() { - MissingScenarioPOIs.resize(_worldPacket.read<uint32>()); + _worldPacket >> Size<uint32>(MissingScenarioPOIs); for (int32& scenarioPOI : MissingScenarioPOIs) _worldPacket >> scenarioPOI; } WorldPacket const* ScenarioPOIs::Write() { - _worldPacket << uint32(ScenarioPOIDataStats.size()); + _worldPacket << Size<uint32>(ScenarioPOIDataStats); for (ScenarioPOIData const& scenarioPOIData : ScenarioPOIDataStats) { _worldPacket << int32(scenarioPOIData.CriteriaTreeID); - _worldPacket << uint32(scenarioPOIData.ScenarioPOIs->size()); + _worldPacket << Size<uint32>(*scenarioPOIData.ScenarioPOIs); for (ScenarioPOI const& scenarioPOI : *scenarioPOIData.ScenarioPOIs) { @@ -120,7 +122,7 @@ WorldPacket const* ScenarioPOIs::Write() _worldPacket << int32(scenarioPOI.WorldEffectID); _worldPacket << int32(scenarioPOI.PlayerConditionID); _worldPacket << int32(scenarioPOI.NavigationPlayerConditionID); - _worldPacket << uint32(scenarioPOI.Points.size()); + _worldPacket << Size<uint32>(scenarioPOI.Points); for (ScenarioPOIPoint const& scenarioPOIBlobPoint : scenarioPOI.Points) { diff --git a/src/server/game/Server/Packets/ScenarioPackets.h b/src/server/game/Server/Packets/ScenarioPackets.h index 671d25f225b..5f38dd18be7 100644 --- a/src/server/game/Server/Packets/ScenarioPackets.h +++ b/src/server/game/Server/Packets/ScenarioPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef ScenarioPackets_h__ -#define ScenarioPackets_h__ +#ifndef TRINITYCORE_SCENARIO_PACKETS_H +#define TRINITYCORE_SCENARIO_PACKETS_H #include "Packet.h" #include "PacketUtilities.h" @@ -43,7 +43,7 @@ struct ScenarioSpellUpdate class ScenarioState final : public ServerPacket { public: - ScenarioState() : ServerPacket(SMSG_SCENARIO_STATE) { } + explicit ScenarioState() : ServerPacket(SMSG_SCENARIO_STATE) { } WorldPacket const* Write() override; @@ -65,7 +65,7 @@ public: class ScenarioProgressUpdate final : public ServerPacket { public: - ScenarioProgressUpdate() : ServerPacket(SMSG_SCENARIO_PROGRESS_UPDATE) { } + explicit ScenarioProgressUpdate() : ServerPacket(SMSG_SCENARIO_PROGRESS_UPDATE) { } WorldPacket const* Write() override; @@ -75,7 +75,7 @@ public: class ScenarioCompleted final : public ServerPacket { public: - ScenarioCompleted(uint32 scenarioId) : ServerPacket(SMSG_SCENARIO_COMPLETED, 4), ScenarioID(scenarioId) { } + explicit ScenarioCompleted(uint32 scenarioId) : ServerPacket(SMSG_SCENARIO_COMPLETED, 4), ScenarioID(scenarioId) { } WorldPacket const* Write() override; @@ -85,7 +85,7 @@ public: class ScenarioVacate final : public ServerPacket { public: - ScenarioVacate() : ServerPacket(SMSG_SCENARIO_VACATE, 4 + 4 + 1) { } + explicit ScenarioVacate() : ServerPacket(SMSG_SCENARIO_VACATE, 4 + 4 + 1) { } WorldPacket const* Write() override; @@ -98,7 +98,7 @@ public: class QueryScenarioPOI final : public ClientPacket { public: - QueryScenarioPOI(WorldPacket&& packet) : ClientPacket(CMSG_QUERY_SCENARIO_POI, std::move(packet)) { } + explicit QueryScenarioPOI(WorldPacket&& packet) : ClientPacket(CMSG_QUERY_SCENARIO_POI, std::move(packet)) { } void Read() override; @@ -114,7 +114,7 @@ struct ScenarioPOIData class ScenarioPOIs final : public ServerPacket { public: - ScenarioPOIs() : ServerPacket(SMSG_SCENARIO_POIS) { } + explicit ScenarioPOIs() : ServerPacket(SMSG_SCENARIO_POIS) { } WorldPacket const* Write() override; @@ -122,4 +122,4 @@ public: }; } -#endif // ScenarioPackets_h__ +#endif // TRINITYCORE_SCENARIO_PACKETS_H diff --git a/src/server/game/Server/Packets/ScenePackets.cpp b/src/server/game/Server/Packets/ScenePackets.cpp index bab779d2fb0..5076031a8ac 100644 --- a/src/server/game/Server/Packets/ScenePackets.cpp +++ b/src/server/game/Server/Packets/ScenePackets.cpp @@ -18,7 +18,9 @@ #include "ScenePackets.h" #include "PacketUtilities.h" -WorldPacket const* WorldPackets::Scenes::PlayScene::Write() +namespace WorldPackets::Scenes +{ +WorldPacket const* PlayScene::Write() { _worldPacket << int32(SceneID); _worldPacket << uint32(PlaybackFlags); @@ -33,28 +35,30 @@ WorldPacket const* WorldPackets::Scenes::PlayScene::Write() return &_worldPacket; } -WorldPacket const* WorldPackets::Scenes::CancelScene::Write() +WorldPacket const* CancelScene::Write() { _worldPacket << int32(SceneInstanceID); return &_worldPacket; } -void WorldPackets::Scenes::SceneTriggerEvent::Read() +void SceneTriggerEvent::Read() { - uint32 len = _worldPacket.ReadBits(6); + _worldPacket >> SizedString::BitsSize<6>(Event); _worldPacket >> SceneInstanceID; - Event = _worldPacket.ReadString(len); + + _worldPacket >> SizedString::Data(Event); } -void WorldPackets::Scenes::ScenePlaybackComplete::Read() +void ScenePlaybackComplete::Read() { _worldPacket >> SceneInstanceID; _worldPacket >> TimePassed; } -void WorldPackets::Scenes::ScenePlaybackCanceled::Read() +void ScenePlaybackCanceled::Read() { _worldPacket >> SceneInstanceID; _worldPacket >> TimePassed; } +} diff --git a/src/server/game/Server/Packets/ScenePackets.h b/src/server/game/Server/Packets/ScenePackets.h index f5c091d6803..64f79c06d14 100644 --- a/src/server/game/Server/Packets/ScenePackets.h +++ b/src/server/game/Server/Packets/ScenePackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef ScenePackets_h__ -#define ScenePackets_h__ +#ifndef TRINITYCORE_SCENE_PACKETS_H +#define TRINITYCORE_SCENE_PACKETS_H #include "ObjectGuid.h" #include "Packet.h" @@ -29,7 +29,7 @@ namespace WorldPackets class TC_GAME_API PlayScene final : public ServerPacket { public: - PlayScene() : ServerPacket(SMSG_PLAY_SCENE, 34) { } + explicit PlayScene() : ServerPacket(SMSG_PLAY_SCENE, 4 + 4 + 4 + 4 + 4 + 16 + 16 + 1) { } WorldPacket const* Write() override; @@ -46,7 +46,7 @@ namespace WorldPackets class TC_GAME_API CancelScene final : public ServerPacket { public: - CancelScene() : ServerPacket(SMSG_CANCEL_SCENE, 4) { } + explicit CancelScene() : ServerPacket(SMSG_CANCEL_SCENE, 4) { } WorldPacket const* Write() override; @@ -56,7 +56,7 @@ namespace WorldPackets class SceneTriggerEvent final : public ClientPacket { public: - SceneTriggerEvent(WorldPacket&& packet) : ClientPacket(CMSG_SCENE_TRIGGER_EVENT, std::move(packet)) { } + explicit SceneTriggerEvent(WorldPacket&& packet) : ClientPacket(CMSG_SCENE_TRIGGER_EVENT, std::move(packet)) { } void Read() override; @@ -67,7 +67,7 @@ namespace WorldPackets class ScenePlaybackComplete final : public ClientPacket { public: - ScenePlaybackComplete(WorldPacket&& packet) : ClientPacket(CMSG_SCENE_PLAYBACK_COMPLETE, std::move(packet)) { } + explicit ScenePlaybackComplete(WorldPacket&& packet) : ClientPacket(CMSG_SCENE_PLAYBACK_COMPLETE, std::move(packet)) { } void Read() override; @@ -78,7 +78,7 @@ namespace WorldPackets class ScenePlaybackCanceled final : public ClientPacket { public: - ScenePlaybackCanceled(WorldPacket&& packet) : ClientPacket(CMSG_SCENE_PLAYBACK_CANCELED, std::move(packet)) { } + explicit ScenePlaybackCanceled(WorldPacket&& packet) : ClientPacket(CMSG_SCENE_PLAYBACK_CANCELED, std::move(packet)) { } void Read() override; @@ -88,4 +88,4 @@ namespace WorldPackets } } -#endif // ScenePackets_h__ +#endif // TRINITYCORE_SCENE_PACKETS_H diff --git a/src/server/game/Server/Packets/SocialPackets.cpp b/src/server/game/Server/Packets/SocialPackets.cpp index db96d09ef00..a2f3c6eebe9 100644 --- a/src/server/game/Server/Packets/SocialPackets.cpp +++ b/src/server/game/Server/Packets/SocialPackets.cpp @@ -17,8 +17,6 @@ #include "SocialPackets.h" #include "PacketUtilities.h" -#include "SocialMgr.h" -#include "World.h" namespace WorldPackets::Social { @@ -27,20 +25,6 @@ void SendContactList::Read() _worldPacket >> Flags; } -ContactInfo::ContactInfo(ObjectGuid const& guid, FriendInfo const& friendInfo) -{ - Guid = guid; - WowAccountGuid = friendInfo.WowAccountGuid; - VirtualRealmAddr = GetVirtualRealmAddress(); - NativeRealmAddr = GetVirtualRealmAddress(); - TypeFlags = friendInfo.Flags; - Notes = friendInfo.Note; - Status = friendInfo.Status; - AreaID = friendInfo.Area; - Level = friendInfo.Level; - ClassID = friendInfo.Class; -} - ByteBuffer& operator<<(ByteBuffer& data, ContactInfo const& contact) { data << contact.Guid; @@ -72,19 +56,6 @@ WorldPacket const* ContactList::Write() return &_worldPacket; } -void FriendStatus::Initialize(ObjectGuid const& guid, FriendsResult result, FriendInfo const& friendInfo) -{ - VirtualRealmAddress = GetVirtualRealmAddress(); - Notes = friendInfo.Note; - ClassID = friendInfo.Class; - Status = friendInfo.Status; - Guid = guid; - WowAccountGuid = friendInfo.WowAccountGuid; - Level = friendInfo.Level; - AreaID = friendInfo.Area; - FriendResult = result; -} - WorldPacket const* FriendStatus::Write() { _worldPacket << uint8(FriendResult); @@ -143,7 +114,7 @@ void DelIgnore::Read() _worldPacket >> Player; } -WorldPacket const* WorldPackets::Social::SocialContractRequestResponse::Write() +WorldPacket const* SocialContractRequestResponse::Write() { _worldPacket << Bits<1>(ShowSocialContract); _worldPacket.FlushBits(); diff --git a/src/server/game/Server/Packets/SocialPackets.h b/src/server/game/Server/Packets/SocialPackets.h index ff18b0de565..15f8e74f41a 100644 --- a/src/server/game/Server/Packets/SocialPackets.h +++ b/src/server/game/Server/Packets/SocialPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef SocialPackets_h__ -#define SocialPackets_h__ +#ifndef TRINITYCORE_SOCIAL_PACKETS_H +#define TRINITYCORE_SOCIAL_PACKETS_H #include "Packet.h" #include "ObjectGuid.h" @@ -32,7 +32,7 @@ namespace WorldPackets class SendContactList final : public ClientPacket { public: - SendContactList(WorldPacket&& packet) : ClientPacket(CMSG_SEND_CONTACT_LIST, std::move(packet)) { } + explicit SendContactList(WorldPacket&& packet) : ClientPacket(CMSG_SEND_CONTACT_LIST, std::move(packet)) { } void Read() override; @@ -41,8 +41,6 @@ namespace WorldPackets struct ContactInfo { - ContactInfo(ObjectGuid const& guid, FriendInfo const& friendInfo); - ObjectGuid Guid; ObjectGuid WowAccountGuid; uint32 VirtualRealmAddr = 0; @@ -58,7 +56,7 @@ namespace WorldPackets class ContactList final : public ServerPacket { public: - ContactList() : ServerPacket(SMSG_CONTACT_LIST, 8) { } + explicit ContactList() : ServerPacket(SMSG_CONTACT_LIST) { } WorldPacket const* Write() override; @@ -69,9 +67,7 @@ namespace WorldPackets class FriendStatus final : public ServerPacket { public: - FriendStatus() : ServerPacket(SMSG_FRIEND_STATUS, 38) { } - - void Initialize(ObjectGuid const& guid, FriendsResult result, FriendInfo const& friendInfo); + explicit FriendStatus() : ServerPacket(SMSG_FRIEND_STATUS) { } WorldPacket const* Write() override; @@ -95,7 +91,7 @@ namespace WorldPackets class AddFriend final : public ClientPacket { public: - AddFriend(WorldPacket&& packet) : ClientPacket(CMSG_ADD_FRIEND, std::move(packet)) { } + explicit AddFriend(WorldPacket&& packet) : ClientPacket(CMSG_ADD_FRIEND, std::move(packet)) { } void Read() override; @@ -106,7 +102,7 @@ namespace WorldPackets class DelFriend final : public ClientPacket { public: - DelFriend(WorldPacket&& packet) : ClientPacket(CMSG_DEL_FRIEND, std::move(packet)) { } + explicit DelFriend(WorldPacket&& packet) : ClientPacket(CMSG_DEL_FRIEND, std::move(packet)) { } void Read() override; @@ -116,7 +112,7 @@ namespace WorldPackets class SetContactNotes final : public ClientPacket { public: - SetContactNotes(WorldPacket&& packet) : ClientPacket(CMSG_SET_CONTACT_NOTES, std::move(packet)) { } + explicit SetContactNotes(WorldPacket&& packet) : ClientPacket(CMSG_SET_CONTACT_NOTES, std::move(packet)) { } void Read() override; @@ -127,7 +123,7 @@ namespace WorldPackets class AddIgnore final : public ClientPacket { public: - AddIgnore(WorldPacket&& packet) : ClientPacket(CMSG_ADD_IGNORE, std::move(packet)) { } + explicit AddIgnore(WorldPacket&& packet) : ClientPacket(CMSG_ADD_IGNORE, std::move(packet)) { } void Read() override; @@ -138,7 +134,7 @@ namespace WorldPackets class DelIgnore final : public ClientPacket { public: - DelIgnore(WorldPacket&& packet) : ClientPacket(CMSG_DEL_IGNORE, std::move(packet)) { } + explicit DelIgnore(WorldPacket&& packet) : ClientPacket(CMSG_DEL_IGNORE, std::move(packet)) { } void Read() override; @@ -148,7 +144,7 @@ namespace WorldPackets class SocialContractRequest final : public ClientPacket { public: - SocialContractRequest(WorldPacket&& packet) : ClientPacket(CMSG_SOCIAL_CONTRACT_REQUEST, std::move(packet)) { } + explicit SocialContractRequest(WorldPacket&& packet) : ClientPacket(CMSG_SOCIAL_CONTRACT_REQUEST, std::move(packet)) { } void Read() override { } }; @@ -156,7 +152,7 @@ namespace WorldPackets class SocialContractRequestResponse final : public ServerPacket { public: - SocialContractRequestResponse() : ServerPacket(SMSG_SOCIAL_CONTRACT_REQUEST_RESPONSE, 1) { } + explicit SocialContractRequestResponse() : ServerPacket(SMSG_SOCIAL_CONTRACT_REQUEST_RESPONSE, 1) { } WorldPacket const* Write() override; @@ -165,4 +161,4 @@ namespace WorldPackets } } -#endif // SocialPackets_h__ +#endif // TRINITYCORE_SOCIAL_PACKETS_H diff --git a/src/server/game/Server/Packets/SpellPackets.cpp b/src/server/game/Server/Packets/SpellPackets.cpp index 4c4c359f0b9..b3580eeff70 100644 --- a/src/server/game/Server/Packets/SpellPackets.cpp +++ b/src/server/game/Server/Packets/SpellPackets.cpp @@ -15,9 +15,9 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "MovementPackets.h" -#include "CharacterPackets.h" #include "SpellPackets.h" +#include "CharacterPackets.h" +#include "MovementPackets.h" namespace WorldPackets::Spells { @@ -49,8 +49,8 @@ WorldPacket const* SendKnownSpells::Write() _worldPacket.reserve(1 + 4 * KnownSpells.size() + 4 * FavoriteSpells.size()); _worldPacket << Bits<1>(InitialLogin); - _worldPacket << uint32(KnownSpells.size()); - _worldPacket << uint32(FavoriteSpells.size()); + _worldPacket << Size<uint32>(KnownSpells); + _worldPacket << Size<uint32>(FavoriteSpells); for (uint32 spellId : KnownSpells) _worldPacket << uint32(spellId); @@ -77,7 +77,7 @@ void SetActionButton::Read() WorldPacket const* SendUnlearnSpells::Write() { - _worldPacket << uint32(Spells.size()); + _worldPacket << Size<uint32>(Spells); for (uint32 spellId : Spells) _worldPacket << uint32(spellId); @@ -155,6 +155,7 @@ ByteBuffer& operator>>(ByteBuffer& buffer, TargetLocation& location) { buffer >> location.Transport; buffer >> location.Location; + return buffer; } @@ -185,6 +186,7 @@ ByteBuffer& operator>>(ByteBuffer& buffer, SpellTargetData& targetData) buffer >> *targetData.MapID; buffer >> SizedString::Data(targetData.Name); + return buffer; } @@ -192,6 +194,7 @@ ByteBuffer& operator>>(ByteBuffer& buffer, MissileTrajectoryRequest& trajectory) { buffer >> trajectory.Pitch; buffer >> trajectory.Speed; + return buffer; } @@ -211,6 +214,7 @@ ByteBuffer& operator>>(ByteBuffer& data, SpellExtraCurrencyCost& extraCurrencyCo { data >> extraCurrencyCost.CurrencyID; data >> extraCurrencyCost.Count; + return data; } @@ -223,9 +227,9 @@ ByteBuffer& operator>>(ByteBuffer& buffer, SpellCastRequest& request) buffer >> request.Visual; buffer >> request.MissileTrajectory; buffer >> request.CraftingNPC; - request.OptionalCurrencies.resize(buffer.read<uint32>()); - request.OptionalReagents.resize(buffer.read<uint32>()); - request.RemovedModifications.resize(buffer.read<uint32>()); + buffer >> Size<uint32>(request.OptionalCurrencies); + buffer >> Size<uint32>(request.OptionalReagents); + buffer >> Size<uint32>(request.RemovedModifications); buffer >> request.CraftingFlags; for (SpellExtraCurrencyCost& optionalCurrency : request.OptionalCurrencies) @@ -291,6 +295,7 @@ ByteBuffer& operator<<(ByteBuffer& data, TargetLocation const& targetLocation) { data << targetLocation.Transport; data << targetLocation.Location; + return data; } @@ -320,6 +325,7 @@ ByteBuffer& operator<<(ByteBuffer& data, SpellTargetData const& spellTargetData) data << int32(*spellTargetData.MapID); data << SizedString::Data(spellTargetData.Name); + return data; } @@ -349,7 +355,7 @@ ByteBuffer& operator<<(ByteBuffer& data, RuneData const& runeData) { data << uint8(runeData.Start); data << uint8(runeData.Count); - data << uint32(runeData.Cooldowns.size()); + data << Size<uint32>(runeData.Cooldowns); if (!runeData.Cooldowns.empty()) data.append(runeData.Cooldowns.data(), runeData.Cooldowns.size()); @@ -360,6 +366,7 @@ ByteBuffer& operator<<(ByteBuffer& data, MissileTrajectoryResult const& missileT { data << uint32(missileTrajectory.TravelTime); data << float(missileTrajectory.Pitch); + return data; } @@ -367,6 +374,7 @@ ByteBuffer& operator<<(ByteBuffer& data, CreatureImmunities const& immunities) { data << int32(immunities.School); data << int32(immunities.Value); + return data; } @@ -375,6 +383,7 @@ ByteBuffer& operator<<(ByteBuffer& data, SpellHealPrediction const& spellPred) data << int32(spellPred.Points); data << uint8(spellPred.Type); data << spellPred.BeaconGUID; + return data; } @@ -472,7 +481,7 @@ ByteBuffer& operator<<(ByteBuffer& data, LearnedSpellInfo const& learnedSpellInf WorldPacket const* LearnedSpells::Write() { - _worldPacket << uint32(ClientLearnedSpellData.size()); + _worldPacket << Size<uint32>(ClientLearnedSpellData); _worldPacket << uint32(SpecializationID); _worldPacket << Bits<1>(SuppressMessaging); _worldPacket.FlushBits(); @@ -485,7 +494,7 @@ WorldPacket const* LearnedSpells::Write() WorldPacket const* SupercededSpells::Write() { - _worldPacket << uint32(ClientLearnedSpellData.size()); + _worldPacket << Size<uint32>(ClientLearnedSpellData); for (LearnedSpellInfo const& spell : ClientLearnedSpellData) _worldPacket << spell; @@ -549,7 +558,7 @@ ByteBuffer& operator<<(ByteBuffer& data, SpellModifierData const& spellModifierD ByteBuffer& operator<<(ByteBuffer& data, SpellModifier const& spellModifier) { data << uint8(spellModifier.ModIndex); - data << uint32(spellModifier.ModifierData.size()); + data << Size<uint32>(spellModifier.ModifierData); for (SpellModifierData const& modData : spellModifier.ModifierData) data << modData; @@ -558,7 +567,7 @@ ByteBuffer& operator<<(ByteBuffer& data, SpellModifier const& spellModifier) WorldPacket const* SetSpellModifier::Write() { - _worldPacket << uint32(Modifiers.size()); + _worldPacket << Size<uint32>(Modifiers); for (SpellModifier const& spellMod : Modifiers) _worldPacket << spellMod; @@ -567,7 +576,7 @@ WorldPacket const* SetSpellModifier::Write() WorldPacket const* UnlearnedSpells::Write() { - _worldPacket << uint32(SpellID.size()); + _worldPacket << Size<uint32>(SpellID); for (uint32 spellId : SpellID) _worldPacket << uint32(spellId); @@ -588,7 +597,7 @@ WorldPacket const* CooldownEvent::Write() WorldPacket const* ClearCooldowns::Write() { - _worldPacket << uint32(SpellID.size()); + _worldPacket << Size<uint32>(SpellID); if (!SpellID.empty()) _worldPacket.append(SpellID.data(), SpellID.size()); @@ -633,6 +642,7 @@ ByteBuffer& operator<<(ByteBuffer& data, SpellCooldownStruct const& cooldown) data << uint32(cooldown.SrecID); data << uint32(cooldown.ForcedCooldown); data << float(cooldown.ModRate); + return data; } @@ -640,7 +650,7 @@ WorldPacket const* SpellCooldown::Write() { _worldPacket << Caster; _worldPacket << uint8(Flags); - _worldPacket << uint32(SpellCooldowns.size()); + _worldPacket << Size<uint32>(SpellCooldowns); for (SpellCooldownStruct const& cooldown : SpellCooldowns) _worldPacket << cooldown; @@ -658,18 +668,20 @@ ByteBuffer& operator<<(ByteBuffer& data, SpellHistoryEntry const& historyEntry) data << OptionalInit(historyEntry.RecoveryTimeStartOffset); data << OptionalInit(historyEntry.CategoryRecoveryTimeStartOffset); data << Bits<1>(historyEntry.OnHold); + data.FlushBits(); + if (historyEntry.RecoveryTimeStartOffset) data << uint32(*historyEntry.RecoveryTimeStartOffset); + if (historyEntry.CategoryRecoveryTimeStartOffset) data << uint32(*historyEntry.CategoryRecoveryTimeStartOffset); - data.FlushBits(); return data; } WorldPacket const* SendSpellHistory::Write() { - _worldPacket << uint32(Entries.size()); + _worldPacket << Size<uint32>(Entries); for (SpellHistoryEntry const& historyEntry : Entries) _worldPacket << historyEntry; @@ -722,12 +734,13 @@ ByteBuffer& operator<<(ByteBuffer& data, SpellChargeEntry const& chargeEntry) data << uint32(chargeEntry.NextRecoveryTime); data << float(chargeEntry.ChargeModRate); data << uint8(chargeEntry.ConsumedCharges); + return data; } WorldPacket const* SendSpellCharges::Write() { - _worldPacket << uint32(Entries.size()); + _worldPacket << Size<uint32>(Entries); for (SpellChargeEntry const& chargeEntry : Entries) _worldPacket << chargeEntry; @@ -838,6 +851,7 @@ ByteBuffer& operator<<(ByteBuffer& data, SpellChannelStartInterruptImmunities co { data << int32(interruptImmunities.SchoolImmunities); data << int32(interruptImmunities.Immunities); + return data; } @@ -845,6 +859,7 @@ ByteBuffer& operator<<(ByteBuffer& data, SpellTargetedHealPrediction const& targ { data << targetedHealPrediction.TargetGUID; data << targetedHealPrediction.Predict; + return data; } @@ -878,13 +893,13 @@ WorldPacket const* SpellEmpowerStart::Write() { _worldPacket << CastID; _worldPacket << CasterGUID; - _worldPacket << uint32(Targets.size()); + _worldPacket << Size<uint32>(Targets); _worldPacket << int32(SpellID); _worldPacket << Visual; _worldPacket << EmpowerDuration; _worldPacket << MinHoldTime; _worldPacket << HoldAtMaxTime; - _worldPacket << uint32(StageDurations.size()); + _worldPacket << Size<uint32>(StageDurations); for (ObjectGuid const& target : Targets) _worldPacket << target; @@ -910,7 +925,7 @@ WorldPacket const* SpellEmpowerUpdate::Write() _worldPacket << CastID; _worldPacket << CasterGUID; _worldPacket << TimeRemaining; - _worldPacket << uint32(StageDurations.size()); + _worldPacket << Size<uint32>(StageDurations); _worldPacket << uint8(Status); _worldPacket.FlushBits(); @@ -989,9 +1004,9 @@ WorldPacket const* MirrorImageComponentedData::Write() _worldPacket << uint8(RaceID); _worldPacket << uint8(Gender); _worldPacket << uint8(ClassID); - _worldPacket << uint32(Customizations.size()); + _worldPacket << Size<uint32>(Customizations); _worldPacket << GuildGUID; - _worldPacket << uint32(ItemDisplayID.size()); + _worldPacket << Size<uint32>(ItemDisplayID); _worldPacket << int32(SpellVisualKitID); _worldPacket << int32(Unused_1115); @@ -1087,7 +1102,7 @@ WorldPacket const* DispelFailed::Write() _worldPacket << CasterGUID; _worldPacket << VictimGUID; _worldPacket << uint32(SpellID); - _worldPacket << uint32(FailedSpells.size()); + _worldPacket << Size<uint32>(FailedSpells); if (!FailedSpells.empty()) _worldPacket.append(FailedSpells.data(), FailedSpells.size()); @@ -1098,6 +1113,7 @@ WorldPacket const* CustomLoadScreen::Write() { _worldPacket << uint32(TeleportSpellID); _worldPacket << uint32(LoadingScreenID); + return &_worldPacket; } diff --git a/src/server/game/Server/Packets/SpellPackets.h b/src/server/game/Server/Packets/SpellPackets.h index 8e0902bdf93..25576be7588 100644 --- a/src/server/game/Server/Packets/SpellPackets.h +++ b/src/server/game/Server/Packets/SpellPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef SpellPackets_h__ -#define SpellPackets_h__ +#ifndef TRINITYCORE_SPELL_PACKETS_H +#define TRINITYCORE_SPELL_PACKETS_H #include "CombatLogPacketsCommon.h" #include "MovementInfo.h" @@ -38,7 +38,7 @@ namespace WorldPackets class CancelAura final : public ClientPacket { public: - CancelAura(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_AURA, std::move(packet)) { } + explicit CancelAura(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_AURA, std::move(packet)) { } void Read() override; @@ -49,7 +49,7 @@ namespace WorldPackets class CancelAutoRepeatSpell final : public ClientPacket { public: - CancelAutoRepeatSpell(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_AUTO_REPEAT_SPELL, std::move(packet)) { } + explicit CancelAutoRepeatSpell(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_AUTO_REPEAT_SPELL, std::move(packet)) { } void Read() override { } }; @@ -57,7 +57,7 @@ namespace WorldPackets class CancelChannelling final : public ClientPacket { public: - CancelChannelling(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_CHANNELLING, std::move(packet)) { } + explicit CancelChannelling(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_CHANNELLING, std::move(packet)) { } void Read() override; @@ -69,7 +69,7 @@ namespace WorldPackets class CancelGrowthAura final : public ClientPacket { public: - CancelGrowthAura(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_GROWTH_AURA, std::move(packet)) { } + explicit CancelGrowthAura(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_GROWTH_AURA, std::move(packet)) { } void Read() override { } }; @@ -77,7 +77,7 @@ namespace WorldPackets class CancelMountAura final : public ClientPacket { public: - CancelMountAura(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_MOUNT_AURA, std::move(packet)) { } + explicit CancelMountAura(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_MOUNT_AURA, std::move(packet)) { } void Read() override { } }; @@ -85,7 +85,7 @@ namespace WorldPackets class CancelModSpeedNoControlAuras final : public ClientPacket { public: - CancelModSpeedNoControlAuras(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_MOD_SPEED_NO_CONTROL_AURAS, std::move(packet)) { } + explicit CancelModSpeedNoControlAuras(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_MOD_SPEED_NO_CONTROL_AURAS, std::move(packet)) { } void Read() override; @@ -95,7 +95,7 @@ namespace WorldPackets class PetCancelAura final : public ClientPacket { public: - PetCancelAura(WorldPacket&& packet) : ClientPacket(CMSG_PET_CANCEL_AURA, std::move(packet)) { } + explicit PetCancelAura(WorldPacket&& packet) : ClientPacket(CMSG_PET_CANCEL_AURA, std::move(packet)) { } void Read() override; @@ -106,7 +106,7 @@ namespace WorldPackets class SendKnownSpells final : public ServerPacket { public: - SendKnownSpells() : ServerPacket(SMSG_SEND_KNOWN_SPELLS, 5) { } + explicit SendKnownSpells() : ServerPacket(SMSG_SEND_KNOWN_SPELLS, 5) { } WorldPacket const* Write() override; @@ -120,7 +120,7 @@ namespace WorldPackets public: static std::size_t constexpr NumActionButtons = 180; - UpdateActionButtons() : ServerPacket(SMSG_UPDATE_ACTION_BUTTONS, NumActionButtons * 8 + 1) { } + explicit UpdateActionButtons() : ServerPacket(SMSG_UPDATE_ACTION_BUTTONS, NumActionButtons * 8 + 1) { } WorldPacket const* Write() override; @@ -137,7 +137,7 @@ namespace WorldPackets class SetActionButton final : public ClientPacket { public: - SetActionButton(WorldPacket&& packet) : ClientPacket(CMSG_SET_ACTION_BUTTON, std::move(packet)) {} + explicit SetActionButton(WorldPacket&& packet) : ClientPacket(CMSG_SET_ACTION_BUTTON, std::move(packet)) {} void Read() override; @@ -148,7 +148,7 @@ namespace WorldPackets class SendUnlearnSpells final : public ServerPacket { public: - SendUnlearnSpells() : ServerPacket(SMSG_SEND_UNLEARN_SPELLS, 4) { } + explicit SendUnlearnSpells() : ServerPacket(SMSG_SEND_UNLEARN_SPELLS, 4) { } WorldPacket const* Write() override; @@ -184,7 +184,7 @@ namespace WorldPackets class AuraUpdate final : public ServerPacket { public: - AuraUpdate() : ServerPacket(SMSG_AURA_UPDATE) { } + explicit AuraUpdate() : ServerPacket(SMSG_AURA_UPDATE) { } WorldPacket const* Write() override; @@ -260,7 +260,7 @@ namespace WorldPackets class CastSpell final : public ClientPacket { public: - CastSpell(WorldPacket&& packet) : ClientPacket(CMSG_CAST_SPELL, std::move(packet)) { } + explicit CastSpell(WorldPacket&& packet) : ClientPacket(CMSG_CAST_SPELL, std::move(packet)) { } void Read() override; @@ -270,7 +270,7 @@ namespace WorldPackets class PetCastSpell final : public ClientPacket { public: - PetCastSpell(WorldPacket&& packet) : ClientPacket(CMSG_PET_CAST_SPELL, std::move(packet)) { } + explicit PetCastSpell(WorldPacket&& packet) : ClientPacket(CMSG_PET_CAST_SPELL, std::move(packet)) { } void Read() override; @@ -281,7 +281,7 @@ namespace WorldPackets class UseItem final : public ClientPacket { public: - UseItem(WorldPacket&& packet) : ClientPacket(CMSG_USE_ITEM, std::move(packet)) { } + explicit UseItem(WorldPacket&& packet) : ClientPacket(CMSG_USE_ITEM, std::move(packet)) { } void Read() override; @@ -294,7 +294,7 @@ namespace WorldPackets class SpellPrepare final : public ServerPacket { public: - SpellPrepare() : ServerPacket(SMSG_SPELL_PREPARE, 16 + 16) { } + explicit SpellPrepare() : ServerPacket(SMSG_SPELL_PREPARE, 16 + 16) { } WorldPacket const* Write() override; @@ -381,7 +381,7 @@ namespace WorldPackets class SpellStart final : public ServerPacket { public: - SpellStart() : ServerPacket(SMSG_SPELL_START) { } + explicit SpellStart() : ServerPacket(SMSG_SPELL_START) { } WorldPacket const* Write() override; @@ -391,7 +391,7 @@ namespace WorldPackets class SpellGo final : public CombatLog::CombatLogServerPacket { public: - SpellGo() : CombatLog::CombatLogServerPacket(SMSG_SPELL_GO) { } + explicit SpellGo() : CombatLog::CombatLogServerPacket(SMSG_SPELL_GO) { } WorldPacket const* Write() override; @@ -410,7 +410,7 @@ namespace WorldPackets class LearnedSpells final : public ServerPacket { public: - LearnedSpells() : ServerPacket(SMSG_LEARNED_SPELLS, 9) { } + explicit LearnedSpells() : ServerPacket(SMSG_LEARNED_SPELLS, 9) { } WorldPacket const* Write() override; @@ -422,7 +422,7 @@ namespace WorldPackets class SupercededSpells final : public ServerPacket { public: - SupercededSpells() : ServerPacket(SMSG_SUPERCEDED_SPELLS, 4 + 4 + 4 + 4) { } + explicit SupercededSpells() : ServerPacket(SMSG_SUPERCEDED_SPELLS, 4 + 4 + 4 + 4) { } WorldPacket const* Write() override; @@ -432,7 +432,7 @@ namespace WorldPackets class SpellFailure final : public ServerPacket { public: - SpellFailure() : ServerPacket(SMSG_SPELL_FAILURE, 16 + 4 + 8 + 2 + 16) { } + explicit SpellFailure() : ServerPacket(SMSG_SPELL_FAILURE, 16 + 4 + 8 + 2 + 16) { } WorldPacket const* Write() override; @@ -446,7 +446,7 @@ namespace WorldPackets class SpellFailedOther final : public ServerPacket { public: - SpellFailedOther() : ServerPacket(SMSG_SPELL_FAILED_OTHER, 16 + 4 + 8 + 1 + 16) { } + explicit SpellFailedOther() : ServerPacket(SMSG_SPELL_FAILED_OTHER, 16 + 4 + 8 + 1 + 16) { } WorldPacket const* Write() override; @@ -460,7 +460,7 @@ namespace WorldPackets class TC_GAME_API CastFailed final : public ServerPacket { public: - CastFailed() : ServerPacket(SMSG_CAST_FAILED, 4 + 4 + 4 + 4 + 1) { } + explicit CastFailed() : ServerPacket(SMSG_CAST_FAILED, 4 + 4 + 4 + 4 + 1) { } WorldPacket const* Write() override; @@ -475,7 +475,7 @@ namespace WorldPackets class TC_GAME_API PetCastFailed final : public ServerPacket { public: - PetCastFailed() : ServerPacket(SMSG_PET_CAST_FAILED, 4 + 4 + 4 + 1) { } + explicit PetCastFailed() : ServerPacket(SMSG_PET_CAST_FAILED, 4 + 4 + 4 + 1) { } WorldPacket const* Write() override; @@ -501,7 +501,7 @@ namespace WorldPackets class TC_GAME_API SetSpellModifier final : public ServerPacket { public: - SetSpellModifier(OpcodeServer opcode) : ServerPacket(opcode, 20) { } + explicit SetSpellModifier(OpcodeServer opcode) : ServerPacket(opcode, 20) { } WorldPacket const* Write() override; @@ -511,7 +511,7 @@ namespace WorldPackets class UnlearnedSpells final : public ServerPacket { public: - UnlearnedSpells() : ServerPacket(SMSG_UNLEARNED_SPELLS, 4) { } + explicit UnlearnedSpells() : ServerPacket(SMSG_UNLEARNED_SPELLS, 4) { } WorldPacket const* Write() override; @@ -522,8 +522,8 @@ namespace WorldPackets class CooldownEvent final : public ServerPacket { public: - CooldownEvent() : ServerPacket(SMSG_COOLDOWN_EVENT, 1 + 4) { } - CooldownEvent(bool isPet, int32 spellId) : ServerPacket(SMSG_COOLDOWN_EVENT, 16 + 4), IsPet(isPet), SpellID(spellId) { } + explicit CooldownEvent() : ServerPacket(SMSG_COOLDOWN_EVENT, 1 + 4) { } + explicit CooldownEvent(bool isPet, int32 spellId) : ServerPacket(SMSG_COOLDOWN_EVENT, 1 + 4), IsPet(isPet), SpellID(spellId) { } WorldPacket const* Write() override; @@ -534,7 +534,7 @@ namespace WorldPackets class ClearCooldowns final : public ServerPacket { public: - ClearCooldowns() : ServerPacket(SMSG_CLEAR_COOLDOWNS, 4 + 1) { } + explicit ClearCooldowns() : ServerPacket(SMSG_CLEAR_COOLDOWNS, 4 + 1) { } WorldPacket const* Write() override; @@ -545,7 +545,7 @@ namespace WorldPackets class ClearCooldown final : public ServerPacket { public: - ClearCooldown() : ServerPacket(SMSG_CLEAR_COOLDOWN, 1 + 4 + 1) { } + explicit ClearCooldown() : ServerPacket(SMSG_CLEAR_COOLDOWN, 1 + 4 + 1) { } WorldPacket const* Write() override; @@ -557,7 +557,7 @@ namespace WorldPackets class ModifyCooldown final : public ServerPacket { public: - ModifyCooldown() : ServerPacket(SMSG_MODIFY_COOLDOWN, 1 + 4 + 4) { } + explicit ModifyCooldown() : ServerPacket(SMSG_MODIFY_COOLDOWN, 1 + 4 + 4) { } WorldPacket const* Write() override; @@ -570,7 +570,7 @@ namespace WorldPackets class UpdateCooldown final : public ServerPacket { public: - UpdateCooldown() : ServerPacket(SMSG_UPDATE_COOLDOWN, 4 + 4 + 4) { } + explicit UpdateCooldown() : ServerPacket(SMSG_UPDATE_COOLDOWN, 4 + 4 + 4) { } WorldPacket const* Write() override; @@ -592,7 +592,7 @@ namespace WorldPackets class TC_GAME_API SpellCooldown : public ServerPacket { public: - SpellCooldown() : ServerPacket(SMSG_SPELL_COOLDOWN, 4 + 16 + 1) { } + explicit SpellCooldown() : ServerPacket(SMSG_SPELL_COOLDOWN, 4 + 16 + 1) { } WorldPacket const* Write() override; @@ -617,7 +617,7 @@ namespace WorldPackets class SendSpellHistory final : public ServerPacket { public: - SendSpellHistory() : ServerPacket(SMSG_SEND_SPELL_HISTORY, 4) { } + explicit SendSpellHistory() : ServerPacket(SMSG_SEND_SPELL_HISTORY, 4) { } WorldPacket const* Write() override; @@ -627,7 +627,7 @@ namespace WorldPackets class ClearAllSpellCharges final : public ServerPacket { public: - ClearAllSpellCharges() : ServerPacket(SMSG_CLEAR_ALL_SPELL_CHARGES, 1) { } + explicit ClearAllSpellCharges() : ServerPacket(SMSG_CLEAR_ALL_SPELL_CHARGES, 1) { } WorldPacket const* Write() override; @@ -637,7 +637,7 @@ namespace WorldPackets class ClearSpellCharges final : public ServerPacket { public: - ClearSpellCharges() : ServerPacket(SMSG_CLEAR_SPELL_CHARGES, 1 + 4) { } + explicit ClearSpellCharges() : ServerPacket(SMSG_CLEAR_SPELL_CHARGES, 1 + 4) { } WorldPacket const* Write() override; @@ -648,7 +648,7 @@ namespace WorldPackets class SetSpellCharges final : public ServerPacket { public: - SetSpellCharges() : ServerPacket(SMSG_SET_SPELL_CHARGES, 4 + 4 + 1 + 4 + 1) { } + explicit SetSpellCharges() : ServerPacket(SMSG_SET_SPELL_CHARGES, 4 + 4 + 1 + 4 + 1) { } WorldPacket const* Write() override; @@ -662,7 +662,7 @@ namespace WorldPackets class UpdateChargeCategoryCooldown final : public ServerPacket { public: - UpdateChargeCategoryCooldown() : ServerPacket(SMSG_UPDATE_CHARGE_CATEGORY_COOLDOWN, 4 + 4 + 4 + 1) { } + explicit UpdateChargeCategoryCooldown() : ServerPacket(SMSG_UPDATE_CHARGE_CATEGORY_COOLDOWN, 4 + 4 + 4 + 1) { } WorldPacket const* Write() override; @@ -683,7 +683,7 @@ namespace WorldPackets class SendSpellCharges final : public ServerPacket { public: - SendSpellCharges() : ServerPacket(SMSG_SEND_SPELL_CHARGES, 4) { } + explicit SendSpellCharges() : ServerPacket(SMSG_SEND_SPELL_CHARGES, 4) { } WorldPacket const* Write() override; @@ -693,7 +693,7 @@ namespace WorldPackets class ClearTarget final : public ServerPacket { public: - ClearTarget() : ServerPacket(SMSG_CLEAR_TARGET, 8) { } + explicit ClearTarget() : ServerPacket(SMSG_CLEAR_TARGET, 8) { } WorldPacket const* Write() override; @@ -703,7 +703,7 @@ namespace WorldPackets class CancelOrphanSpellVisual final : public ServerPacket { public: - CancelOrphanSpellVisual() : ServerPacket(SMSG_CANCEL_ORPHAN_SPELL_VISUAL, 4) { } + explicit CancelOrphanSpellVisual() : ServerPacket(SMSG_CANCEL_ORPHAN_SPELL_VISUAL, 4) { } WorldPacket const* Write() override; @@ -713,7 +713,7 @@ namespace WorldPackets class CancelSpellVisual final : public ServerPacket { public: - CancelSpellVisual() : ServerPacket(SMSG_CANCEL_SPELL_VISUAL, 16 + 4) { } + explicit CancelSpellVisual() : ServerPacket(SMSG_CANCEL_SPELL_VISUAL, 16 + 4) { } WorldPacket const* Write() override; @@ -724,7 +724,7 @@ namespace WorldPackets class CancelSpellVisualKit final : public ServerPacket { public: - CancelSpellVisualKit() : ServerPacket(SMSG_CANCEL_SPELL_VISUAL_KIT, 16 + 4) { } + explicit CancelSpellVisualKit() : ServerPacket(SMSG_CANCEL_SPELL_VISUAL_KIT, 16 + 4) { } WorldPacket const* Write() override; @@ -736,7 +736,7 @@ namespace WorldPackets class PlayOrphanSpellVisual final : public ServerPacket { public: - PlayOrphanSpellVisual() : ServerPacket(SMSG_PLAY_ORPHAN_SPELL_VISUAL, 16 + 3 * 4 + 4 + 1 + 4 + 3 * 4 + 3 * 4) { } + explicit PlayOrphanSpellVisual() : ServerPacket(SMSG_PLAY_ORPHAN_SPELL_VISUAL, 16 + 3 * 4 + 4 + 1 + 4 + 3 * 4 + 3 * 4) { } WorldPacket const* Write() override; @@ -755,7 +755,7 @@ namespace WorldPackets class PlaySpellVisual final : public ServerPacket { public: - PlaySpellVisual() : ServerPacket(SMSG_PLAY_SPELL_VISUAL, 16 + 16 + 2 + 4 + 1 + 2 + 4 + 4 * 4) { } + explicit PlaySpellVisual() : ServerPacket(SMSG_PLAY_SPELL_VISUAL, 16 + 16 + 2 + 4 + 1 + 2 + 4 + 4 * 4) { } WorldPacket const* Write() override; @@ -776,7 +776,7 @@ namespace WorldPackets class PlaySpellVisualKit final : public ServerPacket { public: - PlaySpellVisualKit() : ServerPacket(SMSG_PLAY_SPELL_VISUAL_KIT, 16 + 4 + 4 + 4) { } + explicit PlaySpellVisualKit() : ServerPacket(SMSG_PLAY_SPELL_VISUAL_KIT, 16 + 4 + 4 + 4) { } WorldPacket const* Write() override; @@ -790,7 +790,7 @@ namespace WorldPackets class SpellVisualLoadScreen final : public ServerPacket { public: - SpellVisualLoadScreen(int32 spellVisualKitId, int32 delay) : ServerPacket(SMSG_SPELL_VISUAL_LOAD_SCREEN, 4 + 4), + explicit SpellVisualLoadScreen(int32 spellVisualKitId, int32 delay) : ServerPacket(SMSG_SPELL_VISUAL_LOAD_SCREEN, 4 + 4), SpellVisualKitID(spellVisualKitId), Delay(delay) { } WorldPacket const* Write() override; @@ -802,7 +802,7 @@ namespace WorldPackets class CancelCast final : public ClientPacket { public: - CancelCast(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_CAST, std::move(packet)) { } + explicit CancelCast(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_CAST, std::move(packet)) { } void Read() override; @@ -813,7 +813,7 @@ namespace WorldPackets class OpenItem final : public ClientPacket { public: - OpenItem(WorldPacket&& packet) : ClientPacket(CMSG_OPEN_ITEM, std::move(packet)) { } + explicit OpenItem(WorldPacket&& packet) : ClientPacket(CMSG_OPEN_ITEM, std::move(packet)) { } void Read() override; @@ -836,7 +836,7 @@ namespace WorldPackets class SpellChannelStart final : public ServerPacket { public: - SpellChannelStart() : ServerPacket(SMSG_SPELL_CHANNEL_START, 4 + 16 + 4) { } + explicit SpellChannelStart() : ServerPacket(SMSG_SPELL_CHANNEL_START, 4 + 16 + 4) { } WorldPacket const* Write() override; @@ -851,7 +851,7 @@ namespace WorldPackets class SpellChannelUpdate final : public ServerPacket { public: - SpellChannelUpdate() : ServerPacket(SMSG_SPELL_CHANNEL_UPDATE, 16 + 4) { } + explicit SpellChannelUpdate() : ServerPacket(SMSG_SPELL_CHANNEL_UPDATE, 16 + 4) { } WorldPacket const* Write() override; @@ -862,7 +862,7 @@ namespace WorldPackets class SpellEmpowerStart final : public ServerPacket { public: - SpellEmpowerStart() : ServerPacket(SMSG_SPELL_EMPOWER_START, 16 + 16 + 4 + 8 + 4 + 4 + 4 + 1) { } + explicit SpellEmpowerStart() : ServerPacket(SMSG_SPELL_EMPOWER_START, 16 + 16 + 4 + 8 + 4 + 4 + 4 + 1) { } WorldPacket const* Write() override; @@ -882,7 +882,7 @@ namespace WorldPackets class SpellEmpowerUpdate final : public ServerPacket { public: - SpellEmpowerUpdate() : ServerPacket(SMSG_SPELL_EMPOWER_UPDATE, 16 + 16 + 4 + 4 + 1) { } + explicit SpellEmpowerUpdate() : ServerPacket(SMSG_SPELL_EMPOWER_UPDATE, 16 + 16 + 4 + 4 + 1) { } WorldPacket const* Write() override; @@ -896,7 +896,7 @@ namespace WorldPackets class SetEmpowerMinHoldStagePercent final : public ClientPacket { public: - SetEmpowerMinHoldStagePercent(WorldPacket&& packet) : ClientPacket(CMSG_SET_EMPOWER_MIN_HOLD_STAGE_PERCENT, std::move(packet)) { } + explicit SetEmpowerMinHoldStagePercent(WorldPacket&& packet) : ClientPacket(CMSG_SET_EMPOWER_MIN_HOLD_STAGE_PERCENT, std::move(packet)) { } void Read() override; @@ -906,7 +906,7 @@ namespace WorldPackets class SpellEmpowerRelease final : public ClientPacket { public: - SpellEmpowerRelease(WorldPacket&& packet) : ClientPacket(CMSG_SPELL_EMPOWER_RELEASE, std::move(packet)) { } + explicit SpellEmpowerRelease(WorldPacket&& packet) : ClientPacket(CMSG_SPELL_EMPOWER_RELEASE, std::move(packet)) { } void Read() override; @@ -916,7 +916,7 @@ namespace WorldPackets class SpellEmpowerRestart final : public ClientPacket { public: - SpellEmpowerRestart(WorldPacket&& packet) : ClientPacket(CMSG_SPELL_EMPOWER_RESTART, std::move(packet)) { } + explicit SpellEmpowerRestart(WorldPacket&& packet) : ClientPacket(CMSG_SPELL_EMPOWER_RESTART, std::move(packet)) { } void Read() override; @@ -926,7 +926,7 @@ namespace WorldPackets class SpellEmpowerSetStage final : public ServerPacket { public: - SpellEmpowerSetStage() : ServerPacket(SMSG_SPELL_EMPOWER_SET_STAGE, 16 + 16 + 4) { } + explicit SpellEmpowerSetStage() : ServerPacket(SMSG_SPELL_EMPOWER_SET_STAGE, 16 + 16 + 4) { } WorldPacket const* Write() override; @@ -938,7 +938,7 @@ namespace WorldPackets class ResurrectRequest final : public ServerPacket { public: - ResurrectRequest() : ServerPacket(SMSG_RESURRECT_REQUEST, 16 + 4 + 4 + 4 + 1) { } + explicit ResurrectRequest() : ServerPacket(SMSG_RESURRECT_REQUEST, 16 + 4 + 4 + 4 + 1) { } WorldPacket const* Write() override; @@ -954,7 +954,7 @@ namespace WorldPackets class UnlearnSkill final : public ClientPacket { public: - UnlearnSkill(WorldPacket&& packet) : ClientPacket(CMSG_UNLEARN_SKILL, std::move(packet)) { } + explicit UnlearnSkill(WorldPacket&& packet) : ClientPacket(CMSG_UNLEARN_SKILL, std::move(packet)) { } void Read() override; @@ -964,7 +964,7 @@ namespace WorldPackets class SelfRes final : public ClientPacket { public: - SelfRes(WorldPacket&& packet) : ClientPacket(CMSG_SELF_RES, std::move(packet)) { } + explicit SelfRes(WorldPacket&& packet) : ClientPacket(CMSG_SELF_RES, std::move(packet)) { } void Read() override; @@ -974,7 +974,7 @@ namespace WorldPackets class GetMirrorImageData final : public ClientPacket { public: - GetMirrorImageData(WorldPacket&& packet) : ClientPacket(CMSG_GET_MIRROR_IMAGE_DATA, std::move(packet)) {} + explicit GetMirrorImageData(WorldPacket&& packet) : ClientPacket(CMSG_GET_MIRROR_IMAGE_DATA, std::move(packet)) {} void Read() override; @@ -984,7 +984,7 @@ namespace WorldPackets class MirrorImageComponentedData final : public ServerPacket { public: - MirrorImageComponentedData(); + explicit MirrorImageComponentedData(); ~MirrorImageComponentedData(); WorldPacket const* Write() override; @@ -1005,7 +1005,7 @@ namespace WorldPackets class MirrorImageCreatureData final : public ServerPacket { public: - MirrorImageCreatureData() : ServerPacket(SMSG_MIRROR_IMAGE_CREATURE_DATA, 8 + 4) { } + explicit MirrorImageCreatureData() : ServerPacket(SMSG_MIRROR_IMAGE_CREATURE_DATA, 8 + 4) { } WorldPacket const* Write() override; @@ -1017,7 +1017,7 @@ namespace WorldPackets class SpellClick final : public ClientPacket { public: - SpellClick(WorldPacket&& packet) : ClientPacket(CMSG_SPELL_CLICK, std::move(packet)) { } + explicit SpellClick(WorldPacket&& packet) : ClientPacket(CMSG_SPELL_CLICK, std::move(packet)) { } void Read() override; @@ -1028,7 +1028,7 @@ namespace WorldPackets class ResyncRunes final : public ServerPacket { public: - ResyncRunes(size_t size) : ServerPacket(SMSG_RESYNC_RUNES, 1 + 1 + 4 + size) { } + explicit ResyncRunes(size_t size) : ServerPacket(SMSG_RESYNC_RUNES, 1 + 1 + 4 + size) { } WorldPacket const* Write() override; @@ -1038,7 +1038,7 @@ namespace WorldPackets class AddRunePower final : public ServerPacket { public: - AddRunePower() : ServerPacket(SMSG_ADD_RUNE_POWER, 4) { } + explicit AddRunePower() : ServerPacket(SMSG_ADD_RUNE_POWER, 4) { } WorldPacket const* Write() override; @@ -1048,7 +1048,7 @@ namespace WorldPackets class MissileTrajectoryCollision final : public ClientPacket { public: - MissileTrajectoryCollision(WorldPacket&& packet) : ClientPacket(CMSG_MISSILE_TRAJECTORY_COLLISION, std::move(packet)) { } + explicit MissileTrajectoryCollision(WorldPacket&& packet) : ClientPacket(CMSG_MISSILE_TRAJECTORY_COLLISION, std::move(packet)) { } void Read() override; @@ -1061,7 +1061,7 @@ namespace WorldPackets class NotifyMissileTrajectoryCollision final : public ServerPacket { public: - NotifyMissileTrajectoryCollision() : ServerPacket(SMSG_NOTIFY_MISSILE_TRAJECTORY_COLLISION, 8 + 1 + 12) { } + explicit NotifyMissileTrajectoryCollision() : ServerPacket(SMSG_NOTIFY_MISSILE_TRAJECTORY_COLLISION, 8 + 1 + 12) { } WorldPacket const* Write() override; @@ -1073,7 +1073,7 @@ namespace WorldPackets class UpdateMissileTrajectory final : public ClientPacket { public: - UpdateMissileTrajectory(WorldPacket&& packet) : ClientPacket(CMSG_UPDATE_MISSILE_TRAJECTORY, std::move(packet)) { } + explicit UpdateMissileTrajectory(WorldPacket&& packet) : ClientPacket(CMSG_UPDATE_MISSILE_TRAJECTORY, std::move(packet)) { } void Read() override; @@ -1103,7 +1103,7 @@ namespace WorldPackets class SpellDelayed final : public ServerPacket { public: - SpellDelayed() : ServerPacket(SMSG_SPELL_DELAYED, sizeof(ObjectGuid) + 4) { } + explicit SpellDelayed() : ServerPacket(SMSG_SPELL_DELAYED, sizeof(ObjectGuid) + 4) { } WorldPacket const* Write() override; @@ -1114,7 +1114,7 @@ namespace WorldPackets class DispelFailed final : public ServerPacket { public: - DispelFailed() : ServerPacket(SMSG_DISPEL_FAILED, 16 + 16 + 4 + 4 + 4 /* predict a single failure on average */) { } + explicit DispelFailed() : ServerPacket(SMSG_DISPEL_FAILED, 16 + 16 + 4 + 4 + 4 /* predict a single failure on average */) { } WorldPacket const* Write() override; @@ -1127,7 +1127,8 @@ namespace WorldPackets class CustomLoadScreen final : public ServerPacket { public: - CustomLoadScreen(uint32 teleportSpellId, uint32 loadingScreenId) : ServerPacket(SMSG_CUSTOM_LOAD_SCREEN), TeleportSpellID(teleportSpellId), LoadingScreenID(loadingScreenId) { } + explicit CustomLoadScreen(uint32 teleportSpellId, uint32 loadingScreenId) : ServerPacket(SMSG_CUSTOM_LOAD_SCREEN, 4 + 4), + TeleportSpellID(teleportSpellId), LoadingScreenID(loadingScreenId) { } WorldPacket const* Write() override; @@ -1138,7 +1139,7 @@ namespace WorldPackets class MountResult final : public ServerPacket { public: - MountResult() : ServerPacket(SMSG_MOUNT_RESULT, 4) { } + explicit MountResult() : ServerPacket(SMSG_MOUNT_RESULT, 4) { } WorldPacket const* Write() override; @@ -1154,7 +1155,7 @@ namespace WorldPackets Failure = 1 }; - ApplyMountEquipmentResult() : ServerPacket(SMSG_APPLY_MOUNT_EQUIPMENT_RESULT, 16 + 4 + 1) { } + explicit ApplyMountEquipmentResult() : ServerPacket(SMSG_APPLY_MOUNT_EQUIPMENT_RESULT, 16 + 4 + 1) { } WorldPacket const* Write() override; @@ -1166,7 +1167,7 @@ namespace WorldPackets class MissileCancel final : public ServerPacket { public: - MissileCancel() : ServerPacket(SMSG_MISSILE_CANCEL, 21) { } + explicit MissileCancel() : ServerPacket(SMSG_MISSILE_CANCEL, 21) { } WorldPacket const* Write() override; @@ -1178,7 +1179,7 @@ namespace WorldPackets class TradeSkillSetFavorite final : public ClientPacket { public: - TradeSkillSetFavorite(WorldPacket&& packet) : ClientPacket(CMSG_TRADE_SKILL_SET_FAVORITE, std::move(packet)) { } + explicit TradeSkillSetFavorite(WorldPacket&& packet) : ClientPacket(CMSG_TRADE_SKILL_SET_FAVORITE, std::move(packet)) { } void Read() override; @@ -1189,7 +1190,7 @@ namespace WorldPackets class KeyboundOverride final : public ClientPacket { public: - KeyboundOverride(WorldPacket&& packet) : ClientPacket(CMSG_KEYBOUND_OVERRIDE, std::move(packet)) { } + explicit KeyboundOverride(WorldPacket&& packet) : ClientPacket(CMSG_KEYBOUND_OVERRIDE, std::move(packet)) { } void Read() override; @@ -1199,7 +1200,7 @@ namespace WorldPackets class CancelQueuedSpell final : public ClientPacket { public: - CancelQueuedSpell(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_QUEUED_SPELL, std::move(packet)) { } + explicit CancelQueuedSpell(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_QUEUED_SPELL, std::move(packet)) { } void Read() override { } }; @@ -1208,4 +1209,4 @@ namespace WorldPackets } } -#endif // SpellPackets_h__ +#endif // TRINITYCORE_SPELL_PACKETS_H diff --git a/src/server/game/Server/Packets/SystemPackets.cpp b/src/server/game/Server/Packets/SystemPackets.cpp index 43631b60dcd..0afe471b740 100644 --- a/src/server/game/Server/Packets/SystemPackets.cpp +++ b/src/server/game/Server/Packets/SystemPackets.cpp @@ -25,6 +25,7 @@ ByteBuffer& operator<<(ByteBuffer& data, SavedThrottleObjectState const& throttl data << uint32(throttleState.PerMilliseconds); data << uint32(throttleState.TryCount); data << uint32(throttleState.LastResetTimeBeforeNow); + return data; } @@ -45,16 +46,17 @@ ByteBuffer& operator<<(ByteBuffer& data, GameRuleValuePair const& gameRuleValue) data << int32(gameRuleValue.Rule); data << int32(gameRuleValue.Value); data << float(gameRuleValue.ValueF); + return data; } ByteBuffer& operator<<(ByteBuffer& data, DebugTimeEventInfo const& debugTimeEventInfo) { data << uint32(debugTimeEventInfo.TimeEvent); - data << BitsSize<7>(debugTimeEventInfo.Text); + data << SizedString::BitsSize<7>(debugTimeEventInfo.Text); data.FlushBits(); - data.WriteString(debugTimeEventInfo.Text); + data << SizedString::Data(debugTimeEventInfo.Text); return data; } @@ -82,7 +84,7 @@ WorldPacket const* FeatureSystemStatus::Write() _worldPacket << uint32(ClubPresenceUnsubscribeDelay); _worldPacket << int32(ContentSetID); - _worldPacket << uint32(GameRules.size()); + _worldPacket << Size<uint32>(GameRules); _worldPacket << int32(ActiveTimerunningSeasonID); _worldPacket << int32(RemainingTimerunningSeasonSeconds); @@ -166,7 +168,7 @@ WorldPacket const* FeatureSystemStatus::Write() _worldPacket.FlushBits(); { - _worldPacket.WriteBit(QuickJoinConfig.ToastsDisabled); + _worldPacket << Bits<1>(QuickJoinConfig.ToastsDisabled); _worldPacket << float(QuickJoinConfig.ToastDuration); _worldPacket << float(QuickJoinConfig.DelayDuration); _worldPacket << float(QuickJoinConfig.QueueMultiplier); @@ -246,7 +248,7 @@ WorldPacket const* FeatureSystemStatusGlueScreen::Write() _worldPacket << Bits<1>(AccountExportEnabled); _worldPacket << Bits<1>(AccountLockedPostExport); - _worldPacket << Bits<11>(RealmHiddenAlert.length() + 1); + _worldPacket << SizedCString::BitsSize<11>(RealmHiddenAlert); _worldPacket << Bits<1>(BNSendWhisperUseV2Services); @@ -262,28 +264,27 @@ WorldPacket const* FeatureSystemStatusGlueScreen::Write() _worldPacket << uint32(KioskSessionDurationMinutes); _worldPacket << int64(RedeemForBalanceAmount); _worldPacket << int32(MaxCharactersOnThisRealm); - _worldPacket << uint32(LiveRegionCharacterCopySourceRegions.size()); + _worldPacket << Size<uint32>(LiveRegionCharacterCopySourceRegions); _worldPacket << uint32(BpayStorePurchaseTimeout); _worldPacket << int32(ActiveBoostType); _worldPacket << int32(TrialBoostType); _worldPacket << int32(MinimumExpansionLevel); _worldPacket << int32(MaximumExpansionLevel); _worldPacket << int32(ContentSetID); - _worldPacket << uint32(GameRules.size()); + _worldPacket << Size<uint32>(GameRules); _worldPacket << int32(ActiveTimerunningSeasonID); _worldPacket << int32(RemainingTimerunningSeasonSeconds); _worldPacket << int16(MaxPlayerGuidLookupsPerRequest); _worldPacket << int16(NameLookupTelemetryInterval); _worldPacket << NotFoundCacheTimeSeconds; - _worldPacket << uint32(DebugTimeEvents.size()); + _worldPacket << Size<uint32>(DebugTimeEvents); _worldPacket << int32(MostRecentTimeEventID); _worldPacket << uint32(EventRealmQueues); if (LaunchDurationETA) _worldPacket << int32(*LaunchDurationETA); - if (!RealmHiddenAlert.empty()) - _worldPacket << RealmHiddenAlert; + _worldPacket << SizedCString::Data(RealmHiddenAlert); if (!LiveRegionCharacterCopySourceRegions.empty()) _worldPacket.append(LiveRegionCharacterCopySourceRegions.data(), LiveRegionCharacterCopySourceRegions.size()); @@ -299,14 +300,14 @@ WorldPacket const* FeatureSystemStatusGlueScreen::Write() WorldPacket const* SetTimeZoneInformation::Write() { - _worldPacket << BitsSize<7>(ServerTimeTZ); - _worldPacket << BitsSize<7>(GameTimeTZ); - _worldPacket << BitsSize<7>(ServerRegionalTimeTZ); + _worldPacket << SizedString::BitsSize<7>(ServerTimeTZ); + _worldPacket << SizedString::BitsSize<7>(GameTimeTZ); + _worldPacket << SizedString::BitsSize<7>(ServerRegionalTimeTZ); _worldPacket.FlushBits(); - _worldPacket.WriteString(ServerTimeTZ); - _worldPacket.WriteString(GameTimeTZ); - _worldPacket.WriteString(ServerRegionalTimeTZ); + _worldPacket << SizedString::Data(ServerTimeTZ); + _worldPacket << SizedString::Data(GameTimeTZ); + _worldPacket << SizedString::Data(ServerRegionalTimeTZ); return &_worldPacket; } diff --git a/src/server/game/Server/Packets/SystemPackets.h b/src/server/game/Server/Packets/SystemPackets.h index 468a3588fde..1d17c83ab6d 100644 --- a/src/server/game/Server/Packets/SystemPackets.h +++ b/src/server/game/Server/Packets/SystemPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef SystemPackets_h__ -#define SystemPackets_h__ +#ifndef TRINITYCORE_SYSTEM_PACKETS_H +#define TRINITYCORE_SYSTEM_PACKETS_H #include "Packet.h" #include "ObjectGuid.h" @@ -114,7 +114,7 @@ namespace WorldPackets int32 UsedTriesPerMessage = 0; }; - FeatureSystemStatus() : ServerPacket(SMSG_FEATURE_SYSTEM_STATUS, 200) { } + explicit FeatureSystemStatus() : ServerPacket(SMSG_FEATURE_SYSTEM_STATUS, 200) { } WorldPacket const* Write() override; @@ -204,7 +204,7 @@ namespace WorldPackets class FeatureSystemStatusGlueScreen final : public ServerPacket { public: - FeatureSystemStatusGlueScreen() : ServerPacket(SMSG_FEATURE_SYSTEM_STATUS_GLUE_SCREEN, 64) { } + explicit FeatureSystemStatusGlueScreen() : ServerPacket(SMSG_FEATURE_SYSTEM_STATUS_GLUE_SCREEN, 64) { } WorldPacket const* Write() override; @@ -265,7 +265,7 @@ namespace WorldPackets class SetTimeZoneInformation final : public ServerPacket { public: - SetTimeZoneInformation() : ServerPacket(SMSG_SET_TIME_ZONE_INFORMATION) { } + explicit SetTimeZoneInformation() : ServerPacket(SMSG_SET_TIME_ZONE_INFORMATION) { } WorldPacket const* Write() override; @@ -276,4 +276,4 @@ namespace WorldPackets } } -#endif // SystemPackets_h__ +#endif // TRINITYCORE_SYSTEM_PACKETS_H diff --git a/src/server/game/Server/Packets/TalentPackets.cpp b/src/server/game/Server/Packets/TalentPackets.cpp index 57aa6c6d430..39368fd5789 100644 --- a/src/server/game/Server/Packets/TalentPackets.cpp +++ b/src/server/game/Server/Packets/TalentPackets.cpp @@ -17,31 +17,35 @@ #include "TalentPackets.h" -ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Talent::PvPTalent& pvpTalent) +namespace WorldPackets::Talent +{ +ByteBuffer& operator>>(ByteBuffer& data, PvPTalent& pvpTalent) { data >> pvpTalent.PvPTalentID; data >> pvpTalent.Slot; + return data; } -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Talent::PvPTalent const& pvpTalent) +ByteBuffer& operator<<(ByteBuffer& data, PvPTalent const& pvpTalent) { data << uint16(pvpTalent.PvPTalentID); data << uint8(pvpTalent.Slot); + return data; } -WorldPacket const* WorldPackets::Talent::UpdateTalentData::Write() +WorldPacket const* UpdateTalentData::Write() { _worldPacket << uint8(Info.ActiveGroup); _worldPacket << uint32(Info.PrimarySpecialization); - _worldPacket << uint32(Info.TalentGroups.size()); + _worldPacket << Size<uint32>(Info.TalentGroups); - for (auto& talentGroupInfo : Info.TalentGroups) + for (TalentGroupInfo& talentGroupInfo : Info.TalentGroups) { _worldPacket << uint32(talentGroupInfo.SpecID); - _worldPacket << uint32(talentGroupInfo.TalentIDs.size()); - _worldPacket << uint32(talentGroupInfo.PvPTalents.size()); + _worldPacket << Size<uint32>(talentGroupInfo.TalentIDs); + _worldPacket << Size<uint32>(talentGroupInfo.PvPTalents); for (uint16 talent : talentGroupInfo.TalentIDs) _worldPacket << uint16(talent); @@ -53,71 +57,74 @@ WorldPacket const* WorldPackets::Talent::UpdateTalentData::Write() return &_worldPacket; } -void WorldPackets::Talent::LearnTalents::Read() +void LearnTalents::Read() { - Talents.resize(_worldPacket.ReadBits(6)); - for (uint32 i = 0; i < Talents.size(); ++i) - _worldPacket >> Talents[i]; + _worldPacket >> BitsSize<6>(Talents); + for (uint16& talent : Talents) + _worldPacket >> talent; } -WorldPacket const* WorldPackets::Talent::RespecWipeConfirm::Write() +WorldPacket const* RespecWipeConfirm::Write() { _worldPacket << int8(RespecType); _worldPacket << uint32(Cost); _worldPacket << RespecMaster; + return &_worldPacket; } -void WorldPackets::Talent::ConfirmRespecWipe::Read() +void ConfirmRespecWipe::Read() { _worldPacket >> RespecMaster; _worldPacket >> RespecType; } -WorldPacket const* WorldPackets::Talent::LearnTalentFailed::Write() +WorldPacket const* LearnTalentFailed::Write() { - _worldPacket.WriteBits(Reason, 4); + _worldPacket << Bits<4>(Reason); _worldPacket << int32(SpellID); - _worldPacket << uint32(Talents.size()); + _worldPacket << Size<uint32>(Talents); if (!Talents.empty()) _worldPacket.append(Talents.data(), Talents.size()); return &_worldPacket; } -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Talent::GlyphBinding const& glyphBinding) +ByteBuffer& operator<<(ByteBuffer& data, GlyphBinding const& glyphBinding) { data << uint32(glyphBinding.SpellID); data << uint16(glyphBinding.GlyphID); + return data; } -WorldPacket const* WorldPackets::Talent::ActiveGlyphs::Write() +WorldPacket const* ActiveGlyphs::Write() { - _worldPacket << uint32(Glyphs.size()); + _worldPacket << Size<uint32>(Glyphs); for (GlyphBinding const& glyph : Glyphs) _worldPacket << glyph; - _worldPacket.WriteBit(IsFullUpdate); + _worldPacket << Bits<1>(IsFullUpdate); _worldPacket.FlushBits(); return &_worldPacket; } -void WorldPackets::Talent::LearnPvpTalents::Read() +void LearnPvpTalents::Read() { - Talents.resize(_worldPacket.read<uint32>()); - for (uint32 i = 0; i < Talents.size(); ++i) - _worldPacket >> Talents[i]; + _worldPacket >> Size<uint32>(Talents); + for (PvPTalent& pvpTalent : Talents) + _worldPacket >> pvpTalent; } -WorldPacket const* WorldPackets::Talent::LearnPvpTalentFailed::Write() +WorldPacket const* LearnPvpTalentFailed::Write() { - _worldPacket.WriteBits(Reason, 4); + _worldPacket << Bits<4>(Reason); _worldPacket << int32(SpellID); - _worldPacket << uint32(Talents.size()); + _worldPacket << Size<uint32>(Talents); for (PvPTalent pvpTalent : Talents) _worldPacket << pvpTalent; return &_worldPacket; } +} diff --git a/src/server/game/Server/Packets/TalentPackets.h b/src/server/game/Server/Packets/TalentPackets.h index 702b26be149..8b342345109 100644 --- a/src/server/game/Server/Packets/TalentPackets.h +++ b/src/server/game/Server/Packets/TalentPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef TalentPackets_h__ -#define TalentPackets_h__ +#ifndef TRINITYCORE_TALENT_PACKETS_H +#define TRINITYCORE_TALENT_PACKETS_H #include "Packet.h" #include "DBCEnums.h" @@ -50,7 +50,7 @@ namespace WorldPackets class UpdateTalentData final : public ServerPacket { public: - UpdateTalentData() : ServerPacket(SMSG_UPDATE_TALENT_DATA, 2+4+4+4+12) { } + explicit UpdateTalentData() : ServerPacket(SMSG_UPDATE_TALENT_DATA, 2+4+4+4+12) { } WorldPacket const* Write() override; @@ -60,7 +60,7 @@ namespace WorldPackets class LearnTalents final : public ClientPacket { public: - LearnTalents(WorldPacket&& packet) : ClientPacket(CMSG_LEARN_TALENTS, std::move(packet)) { } + explicit LearnTalents(WorldPacket&& packet) : ClientPacket(CMSG_LEARN_TALENTS, std::move(packet)) { } void Read() override; Array<uint16, MAX_TALENT_TIERS> Talents; @@ -69,7 +69,7 @@ namespace WorldPackets class RespecWipeConfirm final : public ServerPacket { public: - RespecWipeConfirm() : ServerPacket(SMSG_RESPEC_WIPE_CONFIRM, 16 + 4 +1) { } + explicit RespecWipeConfirm() : ServerPacket(SMSG_RESPEC_WIPE_CONFIRM, 16 + 4 +1) { } WorldPacket const* Write() override; @@ -81,7 +81,7 @@ namespace WorldPackets class ConfirmRespecWipe final : public ClientPacket { public: - ConfirmRespecWipe(WorldPacket&& packet) : ClientPacket(CMSG_CONFIRM_RESPEC_WIPE, std::move(packet)) { } + explicit ConfirmRespecWipe(WorldPacket&& packet) : ClientPacket(CMSG_CONFIRM_RESPEC_WIPE, std::move(packet)) { } void Read() override; @@ -92,7 +92,7 @@ namespace WorldPackets class LearnTalentFailed final : public ServerPacket { public: - LearnTalentFailed() : ServerPacket(SMSG_LEARN_TALENT_FAILED, 1 + 4 + 4 + 2 * MAX_TALENT_TIERS) { } + explicit LearnTalentFailed() : ServerPacket(SMSG_LEARN_TALENT_FAILED, 1 + 4 + 4 + 2 * MAX_TALENT_TIERS) { } WorldPacket const* Write() override; @@ -112,7 +112,7 @@ namespace WorldPackets class ActiveGlyphs final : public ServerPacket { public: - ActiveGlyphs() : ServerPacket(SMSG_ACTIVE_GLYPHS) { } + explicit ActiveGlyphs() : ServerPacket(SMSG_ACTIVE_GLYPHS) { } WorldPacket const* Write() override; @@ -123,7 +123,7 @@ namespace WorldPackets class LearnPvpTalents final : public ClientPacket { public: - LearnPvpTalents(WorldPacket&& packet) : ClientPacket(CMSG_LEARN_PVP_TALENTS, std::move(packet)) { } + explicit LearnPvpTalents(WorldPacket&& packet) : ClientPacket(CMSG_LEARN_PVP_TALENTS, std::move(packet)) { } void Read() override; @@ -133,7 +133,7 @@ namespace WorldPackets class LearnPvpTalentFailed final : public ServerPacket { public: - LearnPvpTalentFailed() : ServerPacket(SMSG_LEARN_PVP_TALENT_FAILED, 1 + 4 + 4 + (2 + 1) * MAX_PVP_TALENT_SLOTS) { } + explicit LearnPvpTalentFailed() : ServerPacket(SMSG_LEARN_PVP_TALENT_FAILED, 1 + 4 + 4 + (2 + 1) * MAX_PVP_TALENT_SLOTS) { } WorldPacket const* Write() override; @@ -144,4 +144,4 @@ namespace WorldPackets } } -#endif // TalentPackets_h__ +#endif // TRINITYCORE_TALENT_PACKETS_H diff --git a/src/server/game/Server/Packets/TaxiPackets.cpp b/src/server/game/Server/Packets/TaxiPackets.cpp index f11519b5c9c..95b02065aa9 100644 --- a/src/server/game/Server/Packets/TaxiPackets.cpp +++ b/src/server/game/Server/Packets/TaxiPackets.cpp @@ -16,30 +16,33 @@ */ #include "TaxiPackets.h" +#include "PacketUtilities.h" -void WorldPackets::Taxi::TaxiNodeStatusQuery::Read() +namespace WorldPackets::Taxi +{ +void TaxiNodeStatusQuery::Read() { _worldPacket >> UnitGUID; } -WorldPacket const* WorldPackets::Taxi::TaxiNodeStatus::Write() +WorldPacket const* TaxiNodeStatus::Write() { _worldPacket << Unit; - _worldPacket.WriteBits(Status, 2); + _worldPacket << Bits<2>(Status); _worldPacket.FlushBits(); return &_worldPacket; } -WorldPacket const* WorldPackets::Taxi::ShowTaxiNodes::Write() +WorldPacket const* ShowTaxiNodes::Write() { - _worldPacket.WriteBit(WindowInfo.has_value()); + _worldPacket << OptionalInit(WindowInfo); _worldPacket.FlushBits(); _worldPacket << uint32(CanLandNodes.size() / 8); // client reads this in uint64 blocks, size is ensured to be divisible by 8 in TaxiMask constructor _worldPacket << uint32(CanUseNodes.size() / 8); // client reads this in uint64 blocks, size is ensured to be divisible by 8 in TaxiMask constructor - if (WindowInfo.has_value()) + if (WindowInfo) { _worldPacket << WindowInfo->UnitGUID; _worldPacket << uint32(WindowInfo->CurrentNode); @@ -51,17 +54,17 @@ WorldPacket const* WorldPackets::Taxi::ShowTaxiNodes::Write() return &_worldPacket; } -void WorldPackets::Taxi::EnableTaxiNode::Read() +void EnableTaxiNode::Read() { _worldPacket >> Unit; } -void WorldPackets::Taxi::TaxiQueryAvailableNodes::Read() +void TaxiQueryAvailableNodes::Read() { _worldPacket >> Unit; } -void WorldPackets::Taxi::ActivateTaxi::Read() +void ActivateTaxi::Read() { _worldPacket >> Vendor; _worldPacket >> Node; @@ -69,17 +72,18 @@ void WorldPackets::Taxi::ActivateTaxi::Read() _worldPacket >> FlyingMountID; } -WorldPacket const* WorldPackets::Taxi::NewTaxiPath::Write() +WorldPacket const* NewTaxiPath::Write() { _worldPacket << int32(TaxiNodesID); return &_worldPacket; } -WorldPacket const* WorldPackets::Taxi::ActivateTaxiReply::Write() +WorldPacket const* ActivateTaxiReply::Write() { - _worldPacket.WriteBits(Reply, 4); + _worldPacket << Bits<4>(Reply); _worldPacket.FlushBits(); return &_worldPacket; } +} diff --git a/src/server/game/Server/Packets/TaxiPackets.h b/src/server/game/Server/Packets/TaxiPackets.h index 0f80a7b2020..fefeaa9278a 100644 --- a/src/server/game/Server/Packets/TaxiPackets.h +++ b/src/server/game/Server/Packets/TaxiPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef TaxiPackets_h__ -#define TaxiPackets_h__ +#ifndef TRINITYCORE_TAXI_PACKETS_H +#define TRINITYCORE_TAXI_PACKETS_H #include "Packet.h" #include "ObjectGuid.h" @@ -30,7 +30,7 @@ namespace WorldPackets class TaxiNodeStatusQuery final : public ClientPacket { public: - TaxiNodeStatusQuery(WorldPacket&& packet) : ClientPacket(CMSG_TAXI_NODE_STATUS_QUERY, std::move(packet)) { } + explicit TaxiNodeStatusQuery(WorldPacket&& packet) : ClientPacket(CMSG_TAXI_NODE_STATUS_QUERY, std::move(packet)) { } void Read() override; @@ -40,7 +40,7 @@ namespace WorldPackets class TaxiNodeStatus final : public ServerPacket { public: - TaxiNodeStatus() : ServerPacket(SMSG_TAXI_NODE_STATUS, 16 + 1) { } + explicit TaxiNodeStatus() : ServerPacket(SMSG_TAXI_NODE_STATUS, 16 + 1) { } WorldPacket const* Write() override; @@ -57,7 +57,7 @@ namespace WorldPackets class ShowTaxiNodes final : public ServerPacket { public: - ShowTaxiNodes() : ServerPacket(SMSG_SHOW_TAXI_NODES) { } + explicit ShowTaxiNodes() : ServerPacket(SMSG_SHOW_TAXI_NODES) { } WorldPacket const* Write() override; @@ -69,7 +69,7 @@ namespace WorldPackets class EnableTaxiNode final : public ClientPacket { public: - EnableTaxiNode(WorldPacket&& packet) : ClientPacket(CMSG_ENABLE_TAXI_NODE, std::move(packet)) { } + explicit EnableTaxiNode(WorldPacket&& packet) : ClientPacket(CMSG_ENABLE_TAXI_NODE, std::move(packet)) { } void Read() override; @@ -79,7 +79,7 @@ namespace WorldPackets class TaxiQueryAvailableNodes final : public ClientPacket { public: - TaxiQueryAvailableNodes(WorldPacket&& packet) : ClientPacket(CMSG_TAXI_QUERY_AVAILABLE_NODES, std::move(packet)) { } + explicit TaxiQueryAvailableNodes(WorldPacket&& packet) : ClientPacket(CMSG_TAXI_QUERY_AVAILABLE_NODES, std::move(packet)) { } void Read() override; @@ -89,7 +89,7 @@ namespace WorldPackets class ActivateTaxi final : public ClientPacket { public: - ActivateTaxi(WorldPacket&& packet) : ClientPacket(CMSG_ACTIVATE_TAXI, std::move(packet)) { } + explicit ActivateTaxi(WorldPacket&& packet) : ClientPacket(CMSG_ACTIVATE_TAXI, std::move(packet)) { } void Read() override; @@ -112,7 +112,7 @@ namespace WorldPackets class ActivateTaxiReply final : public ServerPacket { public: - ActivateTaxiReply() : ServerPacket(SMSG_ACTIVATE_TAXI_REPLY, 1) { } + explicit ActivateTaxiReply() : ServerPacket(SMSG_ACTIVATE_TAXI_REPLY, 1) { } WorldPacket const* Write() override; @@ -122,11 +122,11 @@ namespace WorldPackets class TaxiRequestEarlyLanding final : public ClientPacket { public: - TaxiRequestEarlyLanding(WorldPacket&& packet) : ClientPacket(CMSG_TAXI_REQUEST_EARLY_LANDING, std::move(packet)) { } + explicit TaxiRequestEarlyLanding(WorldPacket&& packet) : ClientPacket(CMSG_TAXI_REQUEST_EARLY_LANDING, std::move(packet)) { } void Read() override { } }; } } -#endif // TaxiPackets_h__ +#endif // TRINITYCORE_TAXI_PACKETS_H diff --git a/src/server/game/Server/Packets/TicketPackets.cpp b/src/server/game/Server/Packets/TicketPackets.cpp index dea6083375c..0f993b354f0 100644 --- a/src/server/game/Server/Packets/TicketPackets.cpp +++ b/src/server/game/Server/Packets/TicketPackets.cpp @@ -40,7 +40,7 @@ WorldPacket const* GMTicketSystemStatus::Write() WorldPacket const* GMTicketCaseStatus::Write() { - _worldPacket << int32(Cases.size()); + _worldPacket << Size<int32>(Cases); for (GMTicketCase const& c : Cases) { @@ -81,34 +81,28 @@ void SubmitUserFeedback::Read() _worldPacket >> SizedCString::Data(Note); } -SupportTicketChatLine::SupportTicketChatLine(time_t timestamp, std::string const& text) : - Timestamp(timestamp), Text(text) -{ } +SupportTicketChatLine::SupportTicketChatLine(time_t timestamp, std::string_view text) + : Timestamp(timestamp), Text(text) { } ByteBuffer& operator>>(ByteBuffer& data, SupportTicketChatLine& line) { data >> line.Timestamp; - line.Text = data.ReadString(data.ReadBits(12)); + data >> SizedString::BitsSize<12>(line.Text); + data >> SizedString::Data(line.Text); return data; } -SupportTicketChatLine::SupportTicketChatLine(ByteBuffer& data) -{ - data >> *this; -} - ByteBuffer& operator>>(ByteBuffer& data, SupportTicketChatLog& chatlog) { - uint32 linesCount = data.read<uint32>(); - bool hasReportLineIndex = data.ReadBit(); - data.ResetBitPos(); + data >> Size<uint32>(chatlog.Lines); + data >> OptionalInit(chatlog.ReportLineIndex); - for (uint32 i = 0; i < linesCount; i++) - chatlog.Lines.emplace_back(data); + for (SupportTicketChatLine& line : chatlog.Lines) + data >> line; - if (hasReportLineIndex) - chatlog.ReportLineIndex = data.read<uint32>(); + if (chatlog.ReportLineIndex) + data >> *chatlog.ReportLineIndex; return data; } @@ -122,7 +116,7 @@ ByteBuffer& operator>>(ByteBuffer& data, SupportTicketHorusChatLine& line) data >> OptionalInit(line.ChannelGuid); data >> OptionalInit(line.WorldServer); data >> OptionalInit(line.Cmd); - uint32 textLength = data.ReadBits(12); + data >> SizedString::BitsSize<12>(line.Text); if (line.ClubID) data >> *line.ClubID; @@ -140,125 +134,118 @@ ByteBuffer& operator>>(ByteBuffer& data, SupportTicketHorusChatLine& line) if (line.Cmd) data >> *line.Cmd; - line.Text = data.ReadString(textLength); + data >> SizedString::Data(line.Text); return data; } -SupportTicketHorusChatLine::SupportTicketHorusChatLine(ByteBuffer& data) -{ - data >> *this; -} - ByteBuffer& operator>>(ByteBuffer& data, SupportTicketHorusChatLog& chatlog) { - uint32 linesCount = data.read<uint32>(); - data.ResetBitPos(); + data >> Size<uint32>(chatlog.Lines); - for (uint32 i = 0; i < linesCount; i++) - chatlog.Lines.emplace_back(data); + for (SupportTicketHorusChatLine& line : chatlog.Lines) + data >> line; return data; } -ByteBuffer& operator>>(ByteBuffer& data, Optional<SupportTicketMailInfo>& mail) +ByteBuffer& operator>>(ByteBuffer& data, SupportTicketMailInfo& mail) { - mail.emplace(); + data >> mail.MailID; + data >> SizedString::BitsSize<13>(mail.MailBody); + data >> SizedString::BitsSize<9>(mail.MailSubject); - data >> mail->MailID; - uint32 bodyLength = data.ReadBits(13); - uint32 subjectLength = data.ReadBits(9); - mail->MailBody = data.ReadString(bodyLength); - mail->MailSubject = data.ReadString(subjectLength); + data >> SizedString::Data(mail.MailBody); + data >> SizedString::Data(mail.MailSubject); return data; } -ByteBuffer& operator>>(ByteBuffer& data, Optional<SupportTicketCalendarEventInfo>& event) +ByteBuffer& operator>>(ByteBuffer& data, SupportTicketCalendarEventInfo& event) { - event.emplace(); + data >> event.EventID; + data >> event.InviteID; + data >> SizedString::BitsSize<8>(event.EventTitle); - data >> event->EventID; - data >> event->InviteID; - event->EventTitle = data.ReadString(data.ReadBits(8)); + data >> SizedString::Data(event.EventTitle); return data; } -ByteBuffer& operator>>(ByteBuffer& data, Optional<SupportTicketPetInfo>& pet) +ByteBuffer& operator>>(ByteBuffer& data, SupportTicketPetInfo& pet) { - pet.emplace(); + data >> pet.PetID; + data >> SizedString::BitsSize<8>(pet.PetName); - data >> pet->PetID; - pet->PetName = data.ReadString(data.ReadBits(8)); + data >> SizedString::Data(pet.PetName); return data; } -ByteBuffer& operator>>(ByteBuffer& data, Optional<SupportTicketGuildInfo>& guild) +ByteBuffer& operator>>(ByteBuffer& data, SupportTicketGuildInfo& guild) { - guild.emplace(); + data.ResetBitPos(); + + data >> SizedString::BitsSize<7>(guild.GuildName); + data >> guild.GuildID; - uint32 nameLength = data.ReadBits(7); - data >> guild->GuildID; - guild->GuildName = data.ReadString(nameLength); + data >> SizedString::Data(guild.GuildName); return data; } -ByteBuffer& operator>>(ByteBuffer& data, Optional<SupportTicketLFGListEntryInfo>& lfgListSearchResult) +ByteBuffer& operator>>(ByteBuffer& data, SupportTicketLFGListEntryInfo& lfgListSearchResult) { - lfgListSearchResult.emplace(); - - data >> lfgListSearchResult->Ticket; - data >> lfgListSearchResult->ActivityID; - data >> lfgListSearchResult->FactionID; - data >> lfgListSearchResult->LastTouchedName; - data >> lfgListSearchResult->LastTouchedComment; - data >> lfgListSearchResult->LastTouchedVoiceChat; - data >> lfgListSearchResult->LastTouchedAny; - data >> lfgListSearchResult->PartyGuid; - - uint32 nameLength = data.ReadBits(10); - uint32 commentLength = data.ReadBits(11); - uint32 voiceChatLength = data.ReadBits(8); - - lfgListSearchResult->Name = data.ReadString(nameLength); - lfgListSearchResult->Comment = data.ReadString(commentLength); - lfgListSearchResult->VoiceChat = data.ReadString(voiceChatLength); + data >> lfgListSearchResult.Ticket; + data >> lfgListSearchResult.ActivityID; + data >> lfgListSearchResult.FactionID; + data >> lfgListSearchResult.LastTouchedName; + data >> lfgListSearchResult.LastTouchedComment; + data >> lfgListSearchResult.LastTouchedVoiceChat; + data >> lfgListSearchResult.LastTouchedAny; + data >> lfgListSearchResult.PartyGuid; + + data >> SizedString::BitsSize<10>(lfgListSearchResult.Name); + data >> SizedString::BitsSize<11>(lfgListSearchResult.Comment); + data >> SizedString::BitsSize<8>(lfgListSearchResult.VoiceChat); + + data >> SizedString::Data(lfgListSearchResult.Name); + data >> SizedString::Data(lfgListSearchResult.Comment); + data >> SizedString::Data(lfgListSearchResult.VoiceChat); return data; } -ByteBuffer& operator>>(ByteBuffer& data, Optional<SupportTicketLFGListApplicant>& lfgListApplicant) +ByteBuffer& operator>>(ByteBuffer& data, SupportTicketLFGListApplicant& lfgListApplicant) { - lfgListApplicant.emplace(); + data >> lfgListApplicant.Ticket; + data >> SizedString::BitsSize<9>(lfgListApplicant.Comment); - data >> lfgListApplicant->Ticket; - lfgListApplicant->Comment = data.ReadString(data.ReadBits(9)); + data >> SizedString::Data(lfgListApplicant.Comment); return data; } -ByteBuffer& operator>>(ByteBuffer& data, Optional<SupportTicketClubFinderInfo>& clubInfo) +ByteBuffer& operator>>(ByteBuffer& data, SupportTicketClubFinderInfo& clubInfo) { - clubInfo.emplace(); + data >> clubInfo.PostingID; + data >> clubInfo.ClubID; + data >> clubInfo.GuildID; + data >> SizedString::BitsSize<12>(clubInfo.PostingDescription); - data >> clubInfo->PostingID; - data >> clubInfo->ClubID; - data >> clubInfo->GuildID; - clubInfo->PostingDescription = data.ReadString(data.ReadBits(12)); + data >> SizedString::Data(clubInfo.PostingDescription); return data; } -ByteBuffer& operator>>(ByteBuffer& data, Optional<SupportTicketArenaTeamInfo>& arenaTeam) +ByteBuffer& operator>>(ByteBuffer& data, SupportTicketArenaTeamInfo& arenaTeam) { - arenaTeam.emplace(); + data.ResetBitPos(); + + data >> SizedString::BitsSize<7>(arenaTeam.ArenaTeamName); + data >> arenaTeam.ArenaTeamID; - uint32 arenaTeamNameLength = data.ReadBits(7); - data >> arenaTeam->ArenaTeamID; - arenaTeam->ArenaTeamName = data.ReadString(arenaTeamNameLength); + data >> SizedString::Data(arenaTeam.ArenaTeamName); return data; } @@ -272,53 +259,50 @@ void SupportTicketSubmitComplaint::Read() _worldPacket >> MinorCategoryFlags; _worldPacket >> ChatLog; - uint32 noteLength = _worldPacket.ReadBits(10); - bool hasMailInfo = _worldPacket.ReadBit(); - bool hasCalendarInfo = _worldPacket.ReadBit(); - bool hasPetInfo = _worldPacket.ReadBit(); - bool hasGuildInfo = _worldPacket.ReadBit(); - bool hasLfgListEntryInfo = _worldPacket.ReadBit(); - bool hasLfgListAppInfo = _worldPacket.ReadBit(); - bool hasVoiceChatInfo = _worldPacket.ReadBit(); - bool hasClubFinderResult = _worldPacket.ReadBit(); - bool hasArenaTeamInfo = _worldPacket.ReadBit(); - - _worldPacket.ResetBitPos(); - - if (hasVoiceChatInfo) + _worldPacket >> SizedString::BitsSize<10>(Note); + _worldPacket >> OptionalInit(MailInfo); + _worldPacket >> OptionalInit(CalenderInfo); + _worldPacket >> OptionalInit(PetInfo); + _worldPacket >> OptionalInit(GuildInfo); + _worldPacket >> OptionalInit(LfgListEntryInfo); + _worldPacket >> OptionalInit(LfgListAppInfo); + _worldPacket >> OptionalInit(VoiceChatInfo); + _worldPacket >> OptionalInit(ClubFinderInfo); + _worldPacket >> OptionalInit(ArenaTeamInfo); + + if (VoiceChatInfo) { - VoiceChatInfo.emplace(); - VoiceChatInfo->TargetIsCurrentlyInVoiceChatWithPlayer = _worldPacket.ReadBit(); _worldPacket.ResetBitPos(); + _worldPacket >> Bits<1>(VoiceChatInfo->TargetIsCurrentlyInVoiceChatWithPlayer); } _worldPacket >> HorusChatLog; - Note = _worldPacket.ReadString(noteLength); + _worldPacket >> SizedString::Data(Note); - if (hasMailInfo) - _worldPacket >> MailInfo; + if (MailInfo) + _worldPacket >> *MailInfo; - if (hasCalendarInfo) - _worldPacket >> CalenderInfo; + if (CalenderInfo) + _worldPacket >> *CalenderInfo; - if (hasPetInfo) - _worldPacket >> PetInfo; + if (PetInfo) + _worldPacket >> *PetInfo; - if (hasGuildInfo) - _worldPacket >> GuildInfo; + if (GuildInfo) + _worldPacket >> *GuildInfo; - if (hasLfgListEntryInfo) - _worldPacket >> LfgListEntryInfo; + if (LfgListEntryInfo) + _worldPacket >> *LfgListEntryInfo; - if (hasLfgListAppInfo) - _worldPacket >> LfgListAppInfo; + if (LfgListAppInfo) + _worldPacket >> *LfgListAppInfo; - if (hasClubFinderResult) - _worldPacket >> ClubFinderInfo; + if (ClubFinderInfo) + _worldPacket >> *ClubFinderInfo; - if (hasArenaTeamInfo) - _worldPacket >> ArenaTeamInfo; + if (ArenaTeamInfo) + _worldPacket >> *ArenaTeamInfo; } ByteBuffer& operator>>(ByteBuffer& data, Complaint::ComplaintOffender& complaintOffender) @@ -334,7 +318,9 @@ ByteBuffer& operator>>(ByteBuffer& data, Complaint::ComplaintChat& chat) { data >> chat.Command; data >> chat.ChannelID; - chat.MessageLog = data.ReadString(data.ReadBits(12)); + data >> SizedString::BitsSize<12>(chat.MessageLog); + + data >> SizedString::Data(chat.MessageLog); return data; } @@ -371,10 +357,11 @@ WorldPacket const* ComplaintResult::Write() void BugReport::Read() { - Type = _worldPacket.ReadBit(); - uint32 diagLen = _worldPacket.ReadBits(12); - uint32 textLen = _worldPacket.ReadBits(10); - DiagInfo = _worldPacket.ReadString(diagLen); - Text = _worldPacket.ReadString(textLen); + _worldPacket >> Bits<1>(Type); + _worldPacket >> SizedString::BitsSize<12>(DiagInfo); + _worldPacket >> SizedString::BitsSize<10>(Text); + + _worldPacket >> SizedString::Data(DiagInfo); + _worldPacket >> SizedString::Data(Text); } } diff --git a/src/server/game/Server/Packets/TicketPackets.h b/src/server/game/Server/Packets/TicketPackets.h index f8560ce5e91..d00dcb8e13b 100644 --- a/src/server/game/Server/Packets/TicketPackets.h +++ b/src/server/game/Server/Packets/TicketPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef TicketPackets_h__ -#define TicketPackets_h__ +#ifndef TRINITYCORE_TICKET_PACKETS_H +#define TRINITYCORE_TICKET_PACKETS_H #include "Packet.h" #include "LFGPacketsCommon.h" @@ -38,7 +38,7 @@ namespace WorldPackets class GMTicketGetSystemStatus final : public ClientPacket { public: - GMTicketGetSystemStatus(WorldPacket&& packet) : ClientPacket(CMSG_GM_TICKET_GET_SYSTEM_STATUS, std::move(packet)) { } + explicit GMTicketGetSystemStatus(WorldPacket&& packet) : ClientPacket(CMSG_GM_TICKET_GET_SYSTEM_STATUS, std::move(packet)) { } void Read() override { } }; @@ -46,7 +46,7 @@ namespace WorldPackets class GMTicketSystemStatus final : public ServerPacket { public: - GMTicketSystemStatus() : ServerPacket(SMSG_GM_TICKET_SYSTEM_STATUS, 4) { } + explicit GMTicketSystemStatus() : ServerPacket(SMSG_GM_TICKET_SYSTEM_STATUS, 4) { } WorldPacket const* Write() override; @@ -56,7 +56,7 @@ namespace WorldPackets class GMTicketGetCaseStatus final : public ClientPacket { public: - GMTicketGetCaseStatus(WorldPacket&& packet) : ClientPacket(CMSG_GM_TICKET_GET_CASE_STATUS, std::move(packet)) { } + explicit GMTicketGetCaseStatus(WorldPacket&& packet) : ClientPacket(CMSG_GM_TICKET_GET_CASE_STATUS, std::move(packet)) { } void Read() override { } }; @@ -88,7 +88,7 @@ namespace WorldPackets class GMTicketAcknowledgeSurvey final : public ClientPacket { public: - GMTicketAcknowledgeSurvey(WorldPacket&& packet) : ClientPacket(CMSG_GM_TICKET_ACKNOWLEDGE_SURVEY, std::move(packet)) { } + explicit GMTicketAcknowledgeSurvey(WorldPacket&& packet) : ClientPacket(CMSG_GM_TICKET_ACKNOWLEDGE_SURVEY, std::move(packet)) { } void Read() override; @@ -98,7 +98,7 @@ namespace WorldPackets class SubmitUserFeedback final : public ClientPacket { public: - SubmitUserFeedback(WorldPacket&& packet) : ClientPacket(CMSG_SUBMIT_USER_FEEDBACK, std::move(packet)) { } + explicit SubmitUserFeedback(WorldPacket&& packet) : ClientPacket(CMSG_SUBMIT_USER_FEEDBACK, std::move(packet)) { } void Read() override; @@ -109,8 +109,8 @@ namespace WorldPackets struct SupportTicketChatLine { - SupportTicketChatLine(ByteBuffer& data); - SupportTicketChatLine(time_t timestamp, std::string const& text); + SupportTicketChatLine() { } + SupportTicketChatLine(time_t timestamp, std::string_view text); WorldPackets::Timestamp<> Timestamp; std::string Text; @@ -124,8 +124,6 @@ namespace WorldPackets struct SupportTicketHorusChatLine { - SupportTicketHorusChatLine(ByteBuffer& data); - struct ServerSpec { uint32 Realm; @@ -216,7 +214,7 @@ namespace WorldPackets class SupportTicketSubmitComplaint final : public ClientPacket { public: - SupportTicketSubmitComplaint(WorldPacket&& packet) : ClientPacket(CMSG_SUPPORT_TICKET_SUBMIT_COMPLAINT, std::move(packet)) { } + explicit SupportTicketSubmitComplaint(WorldPacket&& packet) : ClientPacket(CMSG_SUPPORT_TICKET_SUBMIT_COMPLAINT, std::move(packet)) { } void Read() override; @@ -256,7 +254,7 @@ namespace WorldPackets std::string MessageLog; }; - Complaint(WorldPacket&& packet) : ClientPacket(CMSG_COMPLAINT, std::move(packet)) { } + explicit Complaint(WorldPacket&& packet) : ClientPacket(CMSG_COMPLAINT, std::move(packet)) { } void Read() override; @@ -271,7 +269,7 @@ namespace WorldPackets class ComplaintResult final : public ServerPacket { public: - ComplaintResult() : ServerPacket(SMSG_COMPLAINT_RESULT, 9) { } + explicit ComplaintResult() : ServerPacket(SMSG_COMPLAINT_RESULT, 9) { } WorldPacket const* Write() override; @@ -282,7 +280,7 @@ namespace WorldPackets class BugReport final : public ClientPacket { public: - BugReport(WorldPacket&& packet) : ClientPacket(CMSG_BUG_REPORT, std::move(packet)) { } + explicit BugReport(WorldPacket&& packet) : ClientPacket(CMSG_BUG_REPORT, std::move(packet)) { } void Read() override; @@ -293,4 +291,4 @@ namespace WorldPackets } } -#endif // TicketPackets_h__ +#endif // TRINITYCORE_TICKET_PACKETS_H diff --git a/src/server/game/Server/Packets/TokenPackets.cpp b/src/server/game/Server/Packets/TokenPackets.cpp index f7ba5e76494..126af73ba3d 100644 --- a/src/server/game/Server/Packets/TokenPackets.cpp +++ b/src/server/game/Server/Packets/TokenPackets.cpp @@ -17,16 +17,18 @@ #include "TokenPackets.h" -void WorldPackets::Token::CommerceTokenGetLog::Read() +namespace WorldPackets::Token +{ +void CommerceTokenGetLog::Read() { _worldPacket >> ClientToken; } -WorldPacket const* WorldPackets::Token::CommerceTokenGetLogResponse::Write() +WorldPacket const* CommerceTokenGetLogResponse::Write() { _worldPacket << ClientToken; _worldPacket << Result; - _worldPacket << uint32(AuctionableTokens.size()); + _worldPacket << Size<uint32>(AuctionableTokens); for (AuctionableTokenInfo const& auctionableTokenAuctionable : AuctionableTokens) { _worldPacket << auctionableTokenAuctionable.Id; @@ -39,12 +41,12 @@ WorldPacket const* WorldPackets::Token::CommerceTokenGetLogResponse::Write() return &_worldPacket; } -void WorldPackets::Token::CommerceTokenGetMarketPrice::Read() +void CommerceTokenGetMarketPrice::Read() { _worldPacket >> ClientToken; } -WorldPacket const* WorldPackets::Token::CommerceTokenGetMarketPriceResponse::Write() +WorldPacket const* CommerceTokenGetMarketPriceResponse::Write() { _worldPacket << PriceGuarantee; _worldPacket << ClientToken; @@ -53,3 +55,4 @@ WorldPacket const* WorldPackets::Token::CommerceTokenGetMarketPriceResponse::Wri return &_worldPacket; } +} diff --git a/src/server/game/Server/Packets/TokenPackets.h b/src/server/game/Server/Packets/TokenPackets.h index 60b36e78fbe..a31e4390094 100644 --- a/src/server/game/Server/Packets/TokenPackets.h +++ b/src/server/game/Server/Packets/TokenPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef TokenPackets_h__ -#define TokenPackets_h__ +#ifndef TRINITYCORE_TOKEN_PACKETS_H +#define TRINITYCORE_TOKEN_PACKETS_H #include "Packet.h" #include "PacketUtilities.h" @@ -28,7 +28,7 @@ namespace WorldPackets class CommerceTokenGetLog final : public ClientPacket { public: - CommerceTokenGetLog(WorldPacket&& packet) : ClientPacket(CMSG_COMMERCE_TOKEN_GET_LOG, std::move(packet)) { } + explicit CommerceTokenGetLog(WorldPacket&& packet) : ClientPacket(CMSG_COMMERCE_TOKEN_GET_LOG, std::move(packet)) { } void Read() override; @@ -38,7 +38,7 @@ namespace WorldPackets class CommerceTokenGetLogResponse final : public ServerPacket { public: - CommerceTokenGetLogResponse() : ServerPacket(SMSG_COMMERCE_TOKEN_GET_LOG_RESPONSE, 12) { } + explicit CommerceTokenGetLogResponse() : ServerPacket(SMSG_COMMERCE_TOKEN_GET_LOG_RESPONSE, 12) { } WorldPacket const* Write() override; @@ -59,7 +59,7 @@ namespace WorldPackets class CommerceTokenGetMarketPrice final : public ClientPacket { public: - CommerceTokenGetMarketPrice(WorldPacket&& packet) : ClientPacket(CMSG_COMMERCE_TOKEN_GET_MARKET_PRICE, std::move(packet)) { } + explicit CommerceTokenGetMarketPrice(WorldPacket&& packet) : ClientPacket(CMSG_COMMERCE_TOKEN_GET_MARKET_PRICE, std::move(packet)) { } void Read() override; @@ -69,7 +69,7 @@ namespace WorldPackets class CommerceTokenGetMarketPriceResponse final : public ServerPacket { public: - CommerceTokenGetMarketPriceResponse() : ServerPacket(SMSG_COMMERCE_TOKEN_GET_MARKET_PRICE_RESPONSE, 20) { } + explicit CommerceTokenGetMarketPriceResponse() : ServerPacket(SMSG_COMMERCE_TOKEN_GET_MARKET_PRICE_RESPONSE, 20) { } WorldPacket const* Write() override; @@ -81,4 +81,4 @@ namespace WorldPackets } } -#endif // TokenPackets_h__ +#endif // TRINITYCORE_TOKEN_PACKETS_H diff --git a/src/server/game/Server/Packets/TotemPackets.cpp b/src/server/game/Server/Packets/TotemPackets.cpp index e193c6ffdb7..441d0aa97a7 100644 --- a/src/server/game/Server/Packets/TotemPackets.cpp +++ b/src/server/game/Server/Packets/TotemPackets.cpp @@ -17,26 +17,28 @@ #include "TotemPackets.h" -void WorldPackets::Totem::TotemDestroyed::Read() +namespace WorldPackets::Totem +{ +void TotemDestroyed::Read() { _worldPacket >> Slot; _worldPacket >> TotemGUID; } -WorldPacket const* WorldPackets::Totem::TotemCreated::Write() +WorldPacket const* TotemCreated::Write() { _worldPacket << uint8(Slot); _worldPacket << Totem; _worldPacket << Duration; _worldPacket << int32(SpellID); _worldPacket << float(TimeMod); - _worldPacket.WriteBit(CannotDismiss); + _worldPacket << Bits<1>(CannotDismiss); _worldPacket.FlushBits(); return &_worldPacket; } -WorldPacket const* WorldPackets::Totem::TotemMoved::Write() +WorldPacket const* TotemMoved::Write() { _worldPacket << uint8(Slot); _worldPacket << uint8(NewSlot); @@ -44,3 +46,4 @@ WorldPacket const* WorldPackets::Totem::TotemMoved::Write() return &_worldPacket; } +} diff --git a/src/server/game/Server/Packets/TotemPackets.h b/src/server/game/Server/Packets/TotemPackets.h index 5ddc739ad08..a1aa2d9e5f4 100644 --- a/src/server/game/Server/Packets/TotemPackets.h +++ b/src/server/game/Server/Packets/TotemPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef TotemPackets_h__ -#define TotemPackets_h__ +#ifndef TRINITYCORE_TOTEM_PACKETS_H +#define TRINITYCORE_TOTEM_PACKETS_H #include "ObjectGuid.h" #include "Packet.h" @@ -29,7 +29,7 @@ namespace WorldPackets class TotemDestroyed final : public ClientPacket { public: - TotemDestroyed(WorldPacket&& packet) : ClientPacket(CMSG_TOTEM_DESTROYED, std::move(packet)) { } + explicit TotemDestroyed(WorldPacket&& packet) : ClientPacket(CMSG_TOTEM_DESTROYED, std::move(packet)) { } void Read() override; @@ -40,7 +40,7 @@ namespace WorldPackets class TotemCreated final : public ServerPacket { public: - TotemCreated() : ServerPacket(SMSG_TOTEM_CREATED, 25) { } + explicit TotemCreated() : ServerPacket(SMSG_TOTEM_CREATED, 25) { } WorldPacket const* Write() override; @@ -55,7 +55,7 @@ namespace WorldPackets class TotemMoved final : public ServerPacket { public: - TotemMoved() : ServerPacket(SMSG_TOTEM_MOVED, 18) { } + explicit TotemMoved() : ServerPacket(SMSG_TOTEM_MOVED, 18) { } WorldPacket const* Write() override; @@ -66,4 +66,4 @@ namespace WorldPackets } } -#endif // TotemPackets_h__ +#endif // TRINITYCORE_TOTEM_PACKETS_H diff --git a/src/server/game/Server/Packets/ToyPackets.cpp b/src/server/game/Server/Packets/ToyPackets.cpp index 0b02338312a..53d9a0e8e78 100644 --- a/src/server/game/Server/Packets/ToyPackets.cpp +++ b/src/server/game/Server/Packets/ToyPackets.cpp @@ -17,41 +17,44 @@ #include "ToyPackets.h" -void WorldPackets::Toy::AddToy::Read() +namespace WorldPackets::Toy +{ +void AddToy::Read() { _worldPacket >> Guid; } -void WorldPackets::Toy::UseToy::Read() +void UseToy::Read() { _worldPacket >> Cast; } -WorldPacket const* WorldPackets::Toy::AccountToyUpdate::Write() +WorldPacket const* AccountToyUpdate::Write() { - _worldPacket.WriteBit(IsFullUpdate); + _worldPacket << Bits<1>(IsFullUpdate); _worldPacket.FlushBits(); // all lists have to have the same size - _worldPacket << int32(Toys->size()); // ids - _worldPacket << int32(Toys->size()); // favorites - _worldPacket << int32(Toys->size()); // fanfare + _worldPacket << Size<uint32>(*Toys); // ids + _worldPacket << Size<uint32>(*Toys); // favorites + _worldPacket << Size<uint32>(*Toys); // fanfare - for (auto const& toy : *Toys) - _worldPacket << uint32(toy.first); + for (auto const& [itemId, _] : *Toys) + _worldPacket << uint32(itemId); - for (auto const& toy : *Toys) - _worldPacket.WriteBit(toy.second.HasFlag(ToyFlags::Favorite)); + for (auto const& [_, flags] : *Toys) + _worldPacket << Bits<1>(flags.HasFlag(ToyFlags::Favorite)); - for (auto const& toy : *Toys) - _worldPacket.WriteBit(toy.second.HasFlag(ToyFlags::HasFanfare)); + for (auto const& [_, flags] : *Toys) + _worldPacket << Bits<1>(flags.HasFlag(ToyFlags::HasFanfare)); _worldPacket.FlushBits(); return &_worldPacket; } -void WorldPackets::Toy::ToyClearFanfare::Read() +void ToyClearFanfare::Read() { _worldPacket >> ItemID; } +} diff --git a/src/server/game/Server/Packets/ToyPackets.h b/src/server/game/Server/Packets/ToyPackets.h index 8d37934ab3a..4b338ec800b 100644 --- a/src/server/game/Server/Packets/ToyPackets.h +++ b/src/server/game/Server/Packets/ToyPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef ToyPackets_h__ -#define ToyPackets_h__ +#ifndef TRINITYCORE_TOY_PACKETS_H +#define TRINITYCORE_TOY_PACKETS_H #include "SpellPackets.h" #include "CollectionMgr.h" @@ -28,7 +28,7 @@ namespace WorldPackets class AddToy final : public ClientPacket { public: - AddToy(WorldPacket&& packet) : ClientPacket(CMSG_ADD_TOY, std::move(packet)) { } + explicit AddToy(WorldPacket&& packet) : ClientPacket(CMSG_ADD_TOY, std::move(packet)) { } void Read() override; @@ -38,7 +38,7 @@ namespace WorldPackets class UseToy final : public ClientPacket { public: - UseToy(WorldPacket&& packet) : ClientPacket(CMSG_USE_TOY, std::move(packet)) { } + explicit UseToy(WorldPacket&& packet) : ClientPacket(CMSG_USE_TOY, std::move(packet)) { } void Read() override; @@ -48,7 +48,7 @@ namespace WorldPackets class AccountToyUpdate final : public ServerPacket { public: - AccountToyUpdate() : ServerPacket(SMSG_ACCOUNT_TOY_UPDATE, 1 + 4 + 1) { } + explicit AccountToyUpdate() : ServerPacket(SMSG_ACCOUNT_TOY_UPDATE, 1 + 4 + 1) { } WorldPacket const* Write() override; @@ -59,7 +59,7 @@ namespace WorldPackets class ToyClearFanfare final : public ClientPacket { public: - ToyClearFanfare(WorldPacket&& packet) : ClientPacket(CMSG_TOY_CLEAR_FANFARE, std::move(packet)) { } + explicit ToyClearFanfare(WorldPacket&& packet) : ClientPacket(CMSG_TOY_CLEAR_FANFARE, std::move(packet)) { } void Read() override; @@ -68,4 +68,4 @@ namespace WorldPackets } } -#endif // ToyPackets_h__ +#endif // TRINITYCORE_TOY_PACKETS_H diff --git a/src/server/game/Server/Packets/TradePackets.cpp b/src/server/game/Server/Packets/TradePackets.cpp index 7a92246ab68..09ecb19cadf 100644 --- a/src/server/game/Server/Packets/TradePackets.cpp +++ b/src/server/game/Server/Packets/TradePackets.cpp @@ -17,44 +17,46 @@ #include "TradePackets.h" -void WorldPackets::Trade::AcceptTrade::Read() +namespace WorldPackets::Trade +{ +void AcceptTrade::Read() { _worldPacket >> StateIndex; } -void WorldPackets::Trade::ClearTradeItem::Read() +void ClearTradeItem::Read() { _worldPacket >> TradeSlot; } -void WorldPackets::Trade::InitiateTrade::Read() +void InitiateTrade::Read() { _worldPacket >> Guid; } -void WorldPackets::Trade::SetTradeCurrency::Read() +void SetTradeCurrency::Read() { _worldPacket >> Type >> Quantity; } -void WorldPackets::Trade::SetTradeGold::Read() +void SetTradeGold::Read() { _worldPacket >> Coinage; } -void WorldPackets::Trade::SetTradeItem::Read() +void SetTradeItem::Read() { _worldPacket >> TradeSlot >> PackSlot >> ItemSlotInPack; } -WorldPacket const* WorldPackets::Trade::TradeStatus::Write() +WorldPacket const* TradeStatus::Write() { - _worldPacket.WriteBit(PartnerIsSameBnetAccount); - _worldPacket.WriteBits(Status, 5); + _worldPacket << Bits<1>(PartnerIsSameBnetAccount); + _worldPacket << Bits<5>(Status); switch (Status) { case TRADE_STATUS_FAILED: - _worldPacket.WriteBit(FailureForYou); + _worldPacket << Bits<1>(FailureForYou); _worldPacket << int32(BagResult); _worldPacket << int32(ItemID); break; @@ -82,7 +84,7 @@ WorldPacket const* WorldPackets::Trade::TradeStatus::Write() return &_worldPacket; } -ByteBuffer& operator<<(ByteBuffer& buffer, WorldPackets::Trade::UnwrappedTradeItem const& unwrappedTradeItem) +ByteBuffer& operator<<(ByteBuffer& buffer, UnwrappedTradeItem const& unwrappedTradeItem) { buffer << int32(unwrappedTradeItem.EnchantID); buffer << int32(unwrappedTradeItem.OnUseEnchantmentID); @@ -90,23 +92,23 @@ ByteBuffer& operator<<(ByteBuffer& buffer, WorldPackets::Trade::UnwrappedTradeIt buffer << int32(unwrappedTradeItem.Charges); buffer << uint32(unwrappedTradeItem.MaxDurability); buffer << uint32(unwrappedTradeItem.Durability); - buffer.WriteBits(unwrappedTradeItem.Gems.size(), 2); - buffer.WriteBit(unwrappedTradeItem.Lock); + buffer << BitsSize<2>(unwrappedTradeItem.Gems); + buffer << Bits<1>(unwrappedTradeItem.Lock); buffer.FlushBits(); - for (WorldPackets::Item::ItemGemData const& gem : unwrappedTradeItem.Gems) + for (Item::ItemGemData const& gem : unwrappedTradeItem.Gems) buffer << gem; return buffer; } -ByteBuffer& operator<<(ByteBuffer& buffer, WorldPackets::Trade::TradeItem const& tradeItem) +ByteBuffer& operator<<(ByteBuffer& buffer, TradeItem const& tradeItem) { buffer << uint8(tradeItem.Slot); buffer << uint32(tradeItem.StackCount); buffer << tradeItem.GiftCreator; buffer << tradeItem.Item; - buffer.WriteBit(tradeItem.Unwrapped.has_value()); + buffer << OptionalInit(tradeItem.Unwrapped); buffer.FlushBits(); if (tradeItem.Unwrapped) buffer << *tradeItem.Unwrapped; @@ -114,7 +116,7 @@ ByteBuffer& operator<<(ByteBuffer& buffer, WorldPackets::Trade::TradeItem const& return buffer; } -WorldPacket const* WorldPackets::Trade::TradeUpdated::Write() +WorldPacket const* TradeUpdated::Write() { _worldPacket << uint8(WhichPlayer); _worldPacket << uint32(ID); @@ -124,10 +126,11 @@ WorldPacket const* WorldPackets::Trade::TradeUpdated::Write() _worldPacket << int32(CurrencyType); _worldPacket << int32(CurrencyQuantity); _worldPacket << int32(ProposedEnchantment); - _worldPacket << uint32(Items.size()); + _worldPacket << Size<uint32>(Items); for (TradeItem const& item : Items) _worldPacket << item; return &_worldPacket; } +} diff --git a/src/server/game/Server/Packets/TradePackets.h b/src/server/game/Server/Packets/TradePackets.h index db4caa1135d..1f3c028b744 100644 --- a/src/server/game/Server/Packets/TradePackets.h +++ b/src/server/game/Server/Packets/TradePackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef TradePackets_h__ -#define TradePackets_h__ +#ifndef TRINITYCORE_TRADE_PACKETS_H +#define TRINITYCORE_TRADE_PACKETS_H #include "Packet.h" #include "ItemPacketsCommon.h" @@ -30,7 +30,7 @@ namespace WorldPackets class AcceptTrade final : public ClientPacket { public: - AcceptTrade(WorldPacket&& packet) : ClientPacket(CMSG_ACCEPT_TRADE, std::move(packet)) { } + explicit AcceptTrade(WorldPacket&& packet) : ClientPacket(CMSG_ACCEPT_TRADE, std::move(packet)) { } void Read() override; @@ -40,7 +40,7 @@ namespace WorldPackets class BeginTrade final : public ClientPacket { public: - BeginTrade(WorldPacket&& packet) : ClientPacket(CMSG_BEGIN_TRADE, std::move(packet)) { } + explicit BeginTrade(WorldPacket&& packet) : ClientPacket(CMSG_BEGIN_TRADE, std::move(packet)) { } void Read() override { } }; @@ -48,7 +48,7 @@ namespace WorldPackets class BusyTrade final : public ClientPacket { public: - BusyTrade(WorldPacket&& packet) : ClientPacket(CMSG_BUSY_TRADE, std::move(packet)) { } + explicit BusyTrade(WorldPacket&& packet) : ClientPacket(CMSG_BUSY_TRADE, std::move(packet)) { } void Read() override { } }; @@ -56,7 +56,7 @@ namespace WorldPackets class CancelTrade final : public ClientPacket { public: - CancelTrade(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_TRADE, std::move(packet)) { } + explicit CancelTrade(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_TRADE, std::move(packet)) { } void Read() override { } }; @@ -64,7 +64,7 @@ namespace WorldPackets class ClearTradeItem final : public ClientPacket { public: - ClearTradeItem(WorldPacket&& packet) : ClientPacket(CMSG_CLEAR_TRADE_ITEM, std::move(packet)) { } + explicit ClearTradeItem(WorldPacket&& packet) : ClientPacket(CMSG_CLEAR_TRADE_ITEM, std::move(packet)) { } void Read() override; @@ -74,7 +74,7 @@ namespace WorldPackets class IgnoreTrade final : public ClientPacket { public: - IgnoreTrade(WorldPacket&& packet) : ClientPacket(CMSG_IGNORE_TRADE, std::move(packet)) { } + explicit IgnoreTrade(WorldPacket&& packet) : ClientPacket(CMSG_IGNORE_TRADE, std::move(packet)) { } void Read() override { } }; @@ -82,7 +82,7 @@ namespace WorldPackets class InitiateTrade final : public ClientPacket { public: - InitiateTrade(WorldPacket&& packet) : ClientPacket(CMSG_INITIATE_TRADE, std::move(packet)) { } + explicit InitiateTrade(WorldPacket&& packet) : ClientPacket(CMSG_INITIATE_TRADE, std::move(packet)) { } void Read() override; @@ -92,7 +92,7 @@ namespace WorldPackets class SetTradeCurrency final : public ClientPacket { public: - SetTradeCurrency(WorldPacket&& packet) : ClientPacket(CMSG_SET_TRADE_CURRENCY, std::move(packet)) { } + explicit SetTradeCurrency(WorldPacket&& packet) : ClientPacket(CMSG_SET_TRADE_CURRENCY, std::move(packet)) { } void Read() override; @@ -103,7 +103,7 @@ namespace WorldPackets class SetTradeGold final : public ClientPacket { public: - SetTradeGold(WorldPacket&& packet) : ClientPacket(CMSG_SET_TRADE_GOLD, std::move(packet)) { } + explicit SetTradeGold(WorldPacket&& packet) : ClientPacket(CMSG_SET_TRADE_GOLD, std::move(packet)) { } void Read() override; @@ -113,7 +113,7 @@ namespace WorldPackets class SetTradeItem final : public ClientPacket { public: - SetTradeItem(WorldPacket&& packet) : ClientPacket(CMSG_SET_TRADE_ITEM, std::move(packet)) { } + explicit SetTradeItem(WorldPacket&& packet) : ClientPacket(CMSG_SET_TRADE_ITEM, std::move(packet)) { } void Read() override; @@ -125,7 +125,7 @@ namespace WorldPackets class UnacceptTrade final : public ClientPacket { public: - UnacceptTrade(WorldPacket&& packet) : ClientPacket(CMSG_UNACCEPT_TRADE, std::move(packet)) { } + explicit UnacceptTrade(WorldPacket&& packet) : ClientPacket(CMSG_UNACCEPT_TRADE, std::move(packet)) { } void Read() override { } }; @@ -133,7 +133,7 @@ namespace WorldPackets class TradeStatus final : public ServerPacket { public: - TradeStatus() : ServerPacket(SMSG_TRADE_STATUS, 1 + 1 + 16 + 4 + 4 + 1 + 4 + 4 + 4 + 1) { } + explicit TradeStatus() : ServerPacket(SMSG_TRADE_STATUS, 1 + 1 + 16 + 4 + 4 + 1 + 4 + 4 + 4 + 1) { } WorldPacket const* Write() override; @@ -174,7 +174,7 @@ namespace WorldPackets class TradeUpdated final : public ServerPacket { public: - TradeUpdated() : ServerPacket(SMSG_TRADE_UPDATED, 8 + 4 + 1 + 4 + 7 * sizeof(UnwrappedTradeItem) + 4 + 4 + 4 + 4) { } + explicit TradeUpdated() : ServerPacket(SMSG_TRADE_UPDATED, 8 + 4 + 1 + 4 + 7 * sizeof(UnwrappedTradeItem) + 4 + 4 + 4 + 4) { } WorldPacket const* Write() override; @@ -191,4 +191,4 @@ namespace WorldPackets } } -#endif // TradePackets_h__ +#endif // TRINITYCORE_TRADE_PACKETS_H diff --git a/src/server/game/Server/Packets/TraitPackets.cpp b/src/server/game/Server/Packets/TraitPackets.cpp index 2c1770f6aaa..f67b5e54e4a 100644 --- a/src/server/game/Server/Packets/TraitPackets.cpp +++ b/src/server/game/Server/Packets/TraitPackets.cpp @@ -30,7 +30,7 @@ WorldPacket const* TraitConfigCommitFailed::Write() { _worldPacket << int32(ConfigID); _worldPacket << int32(SpellID); - _worldPacket.WriteBits(Reason, 4); + _worldPacket << Bits<4>(Reason); _worldPacket.FlushBits(); return &_worldPacket; @@ -44,8 +44,9 @@ void ClassTalentsRequestNewConfig::Read() void ClassTalentsRenameConfig::Read() { _worldPacket >> ConfigID; - uint32 nameLength = _worldPacket.ReadBits(9); - Name = _worldPacket.ReadString(nameLength, false); + _worldPacket >> SizedString::BitsSize<9>(Name); + + _worldPacket >> SizedString::Data<Strings::DontValidateUtf8>(Name); } void ClassTalentsDeleteConfig::Read() @@ -56,13 +57,13 @@ void ClassTalentsDeleteConfig::Read() void ClassTalentsSetStarterBuildActive::Read() { _worldPacket >> ConfigID; - Active = _worldPacket.ReadBit(); + _worldPacket >> Bits<1>(Active); } void ClassTalentsSetUsesSharedActionBars::Read() { _worldPacket >> ConfigID; - UsesShared = _worldPacket.ReadBit(); - IsLastSelectedSavedConfig = _worldPacket.ReadBit(); + _worldPacket >> Bits<1>(UsesShared); + _worldPacket >> Bits<1>(IsLastSelectedSavedConfig); } } diff --git a/src/server/game/Server/Packets/TraitPackets.h b/src/server/game/Server/Packets/TraitPackets.h index 88c2ae43637..dc35ebfdd22 100644 --- a/src/server/game/Server/Packets/TraitPackets.h +++ b/src/server/game/Server/Packets/TraitPackets.h @@ -38,7 +38,7 @@ public: class TraitConfigCommitFailed final : public ServerPacket { public: - TraitConfigCommitFailed(int32 configId = 0, int32 spellId = 0, int32 reason = 0) : ServerPacket(SMSG_TRAIT_CONFIG_COMMIT_FAILED, 4 + 4 + 1), + explicit TraitConfigCommitFailed(int32 configId = 0, int32 spellId = 0, int32 reason = 0) : ServerPacket(SMSG_TRAIT_CONFIG_COMMIT_FAILED, 4 + 4 + 1), ConfigID(configId), SpellID(spellId), Reason(reason) { } WorldPacket const* Write() override; diff --git a/src/server/game/Server/Packets/TraitPacketsCommon.cpp b/src/server/game/Server/Packets/TraitPacketsCommon.cpp index 67d100bc50a..aaacc02d53b 100644 --- a/src/server/game/Server/Packets/TraitPacketsCommon.cpp +++ b/src/server/game/Server/Packets/TraitPacketsCommon.cpp @@ -86,6 +86,7 @@ ByteBuffer& operator>>(ByteBuffer& data, TraitSubTreeCache& traitSubTreeCache) if (entriesSize > 100) throw PacketArrayMaxCapacityException(entriesSize, 100); + traitSubTreeCache.Entries.resize(entriesSize); for (TraitEntry& traitEntry : traitSubTreeCache.Entries) data >> traitEntry; @@ -97,7 +98,7 @@ ByteBuffer& operator>>(ByteBuffer& data, TraitSubTreeCache& traitSubTreeCache) ByteBuffer& operator<<(ByteBuffer& data, TraitSubTreeCache const& traitSubTreeCache) { data << int32(traitSubTreeCache.TraitSubTreeID); - data << uint32(traitSubTreeCache.Entries.size()); + data << Size<uint32>(traitSubTreeCache.Entries); for (TraitEntry const& traitEntry : traitSubTreeCache.Entries) data << traitEntry; @@ -144,12 +145,12 @@ ByteBuffer& operator>>(ByteBuffer& data, TraitConfig& traitConfig) for (TraitEntry& traitEntry : traitConfig.Entries) data >> traitEntry; - uint32 nameLength = data.ReadBits(9); + data >> SizedString::BitsSize<9>(traitConfig.Name); for (TraitSubTreeCache& traitSubTreeCache : traitConfig.SubTrees) data >> traitSubTreeCache; - traitConfig.Name = data.ReadString(nameLength, false); + data >> SizedString::Data<Strings::DontValidateUtf8>(traitConfig.Name); return data; } @@ -158,8 +159,8 @@ ByteBuffer& operator<<(ByteBuffer& data, TraitConfig const& traitConfig) { data << int32(traitConfig.ID); data << int32(traitConfig.Type); - data << uint32(traitConfig.Entries.size()); - data << uint32(traitConfig.SubTrees.size()); + data << Size<uint32>(traitConfig.Entries); + data << Size<uint32>(traitConfig.SubTrees); switch (traitConfig.Type) { case TraitConfigType::Combat: @@ -180,14 +181,14 @@ ByteBuffer& operator<<(ByteBuffer& data, TraitConfig const& traitConfig) for (TraitEntry const& traitEntry : traitConfig.Entries) data << traitEntry; - data.WriteBits(traitConfig.Name.length(), 9); + data << SizedString::BitsSize<9>(traitConfig.Name); for (TraitSubTreeCache const& traitSubTreeCache : traitConfig.SubTrees) data << traitSubTreeCache; data.FlushBits(); - data.WriteString(static_cast<std::string const&>(traitConfig.Name)); + data << SizedString::Data(static_cast<std::string const&>(traitConfig.Name)); return data; } diff --git a/src/server/game/Server/Packets/TransmogrificationPackets.cpp b/src/server/game/Server/Packets/TransmogrificationPackets.cpp index 5a856fc4805..f6c34569bb5 100644 --- a/src/server/game/Server/Packets/TransmogrificationPackets.cpp +++ b/src/server/game/Server/Packets/TransmogrificationPackets.cpp @@ -17,7 +17,9 @@ #include "TransmogrificationPackets.h" -ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Transmogrification::TransmogrifyItem& transmogItem) +namespace WorldPackets::Transmogrification +{ +ByteBuffer& operator>>(ByteBuffer& data, TransmogrifyItem& transmogItem) { data >> transmogItem.ItemModifiedAppearanceID; data >> transmogItem.Slot; @@ -27,22 +29,22 @@ ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Transmogrification::Trans return data; } -void WorldPackets::Transmogrification::TransmogrifyItems::Read() +void TransmogrifyItems::Read() { - Items.resize(_worldPacket.read<uint32>()); + _worldPacket >> Size<uint32>(Items); _worldPacket >> Npc; for (TransmogrifyItem& item : Items) _worldPacket >> item; - CurrentSpecOnly = _worldPacket.ReadBit(); + _worldPacket >> Bits<1>(CurrentSpecOnly); } -WorldPacket const* WorldPackets::Transmogrification::AccountTransmogUpdate::Write() +WorldPacket const* AccountTransmogUpdate::Write() { - _worldPacket.WriteBit(IsFullUpdate); - _worldPacket.WriteBit(IsSetFavorite); - _worldPacket << uint32(FavoriteAppearances.size()); - _worldPacket << uint32(NewAppearances.size()); + _worldPacket << Bits<1>(IsFullUpdate); + _worldPacket << Bits<1>(IsSetFavorite); + _worldPacket << Size<uint32>(FavoriteAppearances); + _worldPacket << Size<uint32>(NewAppearances); if (!FavoriteAppearances.empty()) _worldPacket.append(FavoriteAppearances.data(), FavoriteAppearances.size()); @@ -51,3 +53,4 @@ WorldPacket const* WorldPackets::Transmogrification::AccountTransmogUpdate::Writ return &_worldPacket; } +} diff --git a/src/server/game/Server/Packets/TransmogrificationPackets.h b/src/server/game/Server/Packets/TransmogrificationPackets.h index 4ad6b3adbff..b8a496f594d 100644 --- a/src/server/game/Server/Packets/TransmogrificationPackets.h +++ b/src/server/game/Server/Packets/TransmogrificationPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef TransmogrificationPackets_h__ -#define TransmogrificationPackets_h__ +#ifndef TRINITYCORE_TRANSMOGRIFICATION_PACKETS_H +#define TRINITYCORE_TRANSMOGRIFICATION_PACKETS_H #include "Packet.h" #include "ObjectGuid.h" @@ -42,7 +42,7 @@ namespace WorldPackets MAX_TRANSMOGRIFY_ITEMS = 13 }; - TransmogrifyItems(WorldPacket&& packet) : ClientPacket(CMSG_TRANSMOGRIFY_ITEMS, std::move(packet)) { } + explicit TransmogrifyItems(WorldPacket&& packet) : ClientPacket(CMSG_TRANSMOGRIFY_ITEMS, std::move(packet)) { } void Read() override; @@ -54,7 +54,7 @@ namespace WorldPackets class AccountTransmogUpdate final : public ServerPacket { public: - AccountTransmogUpdate() : ServerPacket(SMSG_ACCOUNT_TRANSMOG_UPDATE) { } + explicit AccountTransmogUpdate() : ServerPacket(SMSG_ACCOUNT_TRANSMOG_UPDATE) { } WorldPacket const* Write() override; @@ -66,4 +66,4 @@ namespace WorldPackets } } -#endif // TransmogrificationPackets_h__ +#endif // TRINITYCORE_TRANSMOGRIFICATION_PACKETS_H diff --git a/src/server/game/Server/Packets/VehiclePackets.cpp b/src/server/game/Server/Packets/VehiclePackets.cpp index 16268156d86..a38a7346994 100644 --- a/src/server/game/Server/Packets/VehiclePackets.cpp +++ b/src/server/game/Server/Packets/VehiclePackets.cpp @@ -17,7 +17,9 @@ #include "VehiclePackets.h" -WorldPacket const* WorldPackets::Vehicle::MoveSetVehicleRecID::Write() +namespace WorldPackets::Vehicle +{ +WorldPacket const* MoveSetVehicleRecID::Write() { _worldPacket << MoverGUID; _worldPacket << uint32(SequenceIndex); @@ -26,13 +28,13 @@ WorldPacket const* WorldPackets::Vehicle::MoveSetVehicleRecID::Write() return &_worldPacket; } -void WorldPackets::Vehicle::MoveSetVehicleRecIdAck::Read() +void MoveSetVehicleRecIdAck::Read() { _worldPacket >> Data; _worldPacket >> VehicleRecID; } -WorldPacket const* WorldPackets::Vehicle::SetVehicleRecID::Write() +WorldPacket const* SetVehicleRecID::Write() { _worldPacket << VehicleGUID; _worldPacket << int32(VehicleRecID); @@ -40,30 +42,31 @@ WorldPacket const* WorldPackets::Vehicle::SetVehicleRecID::Write() return &_worldPacket; } -void WorldPackets::Vehicle::MoveDismissVehicle::Read() +void MoveDismissVehicle::Read() { _worldPacket >> Status; } -void WorldPackets::Vehicle::MoveChangeVehicleSeats::Read() +void MoveChangeVehicleSeats::Read() { _worldPacket >> Status; _worldPacket >> DstVehicle; _worldPacket >> DstSeatIndex; } -void WorldPackets::Vehicle::RequestVehicleSwitchSeat::Read() +void RequestVehicleSwitchSeat::Read() { _worldPacket >> Vehicle; _worldPacket >> SeatIndex; } -void WorldPackets::Vehicle::RideVehicleInteract::Read() +void RideVehicleInteract::Read() { _worldPacket >> Vehicle; } -void WorldPackets::Vehicle::EjectPassenger::Read() +void EjectPassenger::Read() { _worldPacket >> Passenger; } +} diff --git a/src/server/game/Server/Packets/VehiclePackets.h b/src/server/game/Server/Packets/VehiclePackets.h index 2ac1501eae0..6ea84b761ce 100644 --- a/src/server/game/Server/Packets/VehiclePackets.h +++ b/src/server/game/Server/Packets/VehiclePackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef VehiclePackets_h__ -#define VehiclePackets_h__ +#ifndef TRINITYCORE_VEHICLE_PACKETS_H +#define TRINITYCORE_VEHICLE_PACKETS_H #include "Packet.h" #include "MovementPackets.h" @@ -28,7 +28,7 @@ namespace WorldPackets class MoveSetVehicleRecID final : public ServerPacket { public: - MoveSetVehicleRecID() : ServerPacket(SMSG_MOVE_SET_VEHICLE_REC_ID, 16 + 4 + 4) { } + explicit MoveSetVehicleRecID() : ServerPacket(SMSG_MOVE_SET_VEHICLE_REC_ID, 16 + 4 + 4) { } WorldPacket const* Write() override; @@ -40,7 +40,7 @@ namespace WorldPackets class MoveSetVehicleRecIdAck final : public ClientPacket { public: - MoveSetVehicleRecIdAck(WorldPacket&& packet) : ClientPacket(CMSG_MOVE_SET_VEHICLE_REC_ID_ACK, std::move(packet)) { } + explicit MoveSetVehicleRecIdAck(WorldPacket&& packet) : ClientPacket(CMSG_MOVE_SET_VEHICLE_REC_ID_ACK, std::move(packet)) { } void Read() override; @@ -51,7 +51,7 @@ namespace WorldPackets class SetVehicleRecID final : public ServerPacket { public: - SetVehicleRecID() : ServerPacket(SMSG_SET_VEHICLE_REC_ID, 16 + 4) { } + explicit SetVehicleRecID() : ServerPacket(SMSG_SET_VEHICLE_REC_ID, 16 + 4) { } WorldPacket const* Write() override; @@ -62,7 +62,7 @@ namespace WorldPackets class OnCancelExpectedRideVehicleAura final : public ServerPacket { public: - OnCancelExpectedRideVehicleAura() : ServerPacket(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0) { } + explicit OnCancelExpectedRideVehicleAura() : ServerPacket(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0) { } WorldPacket const* Write() override { return &_worldPacket; } }; @@ -70,7 +70,7 @@ namespace WorldPackets class MoveDismissVehicle final : public ClientPacket { public: - MoveDismissVehicle(WorldPacket&& packet) : ClientPacket(CMSG_MOVE_DISMISS_VEHICLE, std::move(packet)) { } + explicit MoveDismissVehicle(WorldPacket&& packet) : ClientPacket(CMSG_MOVE_DISMISS_VEHICLE, std::move(packet)) { } void Read() override; @@ -80,7 +80,7 @@ namespace WorldPackets class RequestVehiclePrevSeat final : public ClientPacket { public: - RequestVehiclePrevSeat(WorldPacket&& packet) : ClientPacket(CMSG_REQUEST_VEHICLE_PREV_SEAT, std::move(packet)) { } + explicit RequestVehiclePrevSeat(WorldPacket&& packet) : ClientPacket(CMSG_REQUEST_VEHICLE_PREV_SEAT, std::move(packet)) { } void Read() override { } }; @@ -88,7 +88,7 @@ namespace WorldPackets class RequestVehicleNextSeat final : public ClientPacket { public: - RequestVehicleNextSeat(WorldPacket&& packet) : ClientPacket(CMSG_REQUEST_VEHICLE_NEXT_SEAT, std::move(packet)) { } + explicit RequestVehicleNextSeat(WorldPacket&& packet) : ClientPacket(CMSG_REQUEST_VEHICLE_NEXT_SEAT, std::move(packet)) { } void Read() override { } }; @@ -96,7 +96,7 @@ namespace WorldPackets class MoveChangeVehicleSeats final : public ClientPacket { public: - MoveChangeVehicleSeats(WorldPacket&& packet) : ClientPacket(CMSG_MOVE_CHANGE_VEHICLE_SEATS, std::move(packet)) { } + explicit MoveChangeVehicleSeats(WorldPacket&& packet) : ClientPacket(CMSG_MOVE_CHANGE_VEHICLE_SEATS, std::move(packet)) { } void Read() override; @@ -108,7 +108,7 @@ namespace WorldPackets class RequestVehicleSwitchSeat final : public ClientPacket { public: - RequestVehicleSwitchSeat(WorldPacket&& packet) : ClientPacket(CMSG_REQUEST_VEHICLE_SWITCH_SEAT, std::move(packet)) { } + explicit RequestVehicleSwitchSeat(WorldPacket&& packet) : ClientPacket(CMSG_REQUEST_VEHICLE_SWITCH_SEAT, std::move(packet)) { } void Read() override; @@ -119,7 +119,7 @@ namespace WorldPackets class RideVehicleInteract final : public ClientPacket { public: - RideVehicleInteract(WorldPacket&& packet) : ClientPacket(CMSG_RIDE_VEHICLE_INTERACT, std::move(packet)) { } + explicit RideVehicleInteract(WorldPacket&& packet) : ClientPacket(CMSG_RIDE_VEHICLE_INTERACT, std::move(packet)) { } void Read() override; @@ -129,7 +129,7 @@ namespace WorldPackets class EjectPassenger final : public ClientPacket { public: - EjectPassenger(WorldPacket&& packet) : ClientPacket(CMSG_EJECT_PASSENGER, std::move(packet)) { } + explicit EjectPassenger(WorldPacket&& packet) : ClientPacket(CMSG_EJECT_PASSENGER, std::move(packet)) { } void Read() override; @@ -139,11 +139,11 @@ namespace WorldPackets class RequestVehicleExit final : public ClientPacket { public: - RequestVehicleExit(WorldPacket&& packet) : ClientPacket(CMSG_REQUEST_VEHICLE_EXIT, std::move(packet)) { } + explicit RequestVehicleExit(WorldPacket&& packet) : ClientPacket(CMSG_REQUEST_VEHICLE_EXIT, std::move(packet)) { } void Read() override { } }; } } -#endif // VehiclePackets_h__ +#endif // TRINITYCORE_VEHICLE_PACKETS_H diff --git a/src/server/game/Server/Packets/VignettePackets.cpp b/src/server/game/Server/Packets/VignettePackets.cpp index 87975edd068..b9c10780fd3 100644 --- a/src/server/game/Server/Packets/VignettePackets.cpp +++ b/src/server/game/Server/Packets/VignettePackets.cpp @@ -16,6 +16,7 @@ */ #include "VignettePackets.h" +#include "PacketUtilities.h" namespace WorldPackets::Vignette { @@ -36,8 +37,8 @@ ByteBuffer& operator<<(ByteBuffer& data, VignetteData const& vignetteData) ByteBuffer& operator<<(ByteBuffer& data, VignetteDataSet const& vignetteDataSet) { - data << uint32(vignetteDataSet.IDs.size()); - data << uint32(vignetteDataSet.Data.size()); + data << Size<uint32>(vignetteDataSet.IDs); + data << Size<uint32>(vignetteDataSet.Data); for (ObjectGuid const& id : vignetteDataSet.IDs) data << id; @@ -49,9 +50,9 @@ ByteBuffer& operator<<(ByteBuffer& data, VignetteDataSet const& vignetteDataSet) WorldPacket const* VignetteUpdate::Write() { - _worldPacket.WriteBit(ForceUpdate); - _worldPacket.WriteBit(InFogOfWar); - _worldPacket << uint32(Removed.size()); + _worldPacket << Bits<1>(ForceUpdate); + _worldPacket << Bits<1>(InFogOfWar); + _worldPacket << Size<uint32>(Removed); _worldPacket << Added; _worldPacket << Updated; for (ObjectGuid const& removed : Removed) diff --git a/src/server/game/Server/Packets/VignettePackets.h b/src/server/game/Server/Packets/VignettePackets.h index 7fe4c079b46..709606c7a56 100644 --- a/src/server/game/Server/Packets/VignettePackets.h +++ b/src/server/game/Server/Packets/VignettePackets.h @@ -46,7 +46,7 @@ struct VignetteDataSet class VignetteUpdate final : public ServerPacket { public: - VignetteUpdate() : ServerPacket(SMSG_VIGNETTE_UPDATE, 200) { } + explicit VignetteUpdate() : ServerPacket(SMSG_VIGNETTE_UPDATE, 200) { } WorldPacket const* Write() override; diff --git a/src/server/game/Server/Packets/VoidStoragePackets.cpp b/src/server/game/Server/Packets/VoidStoragePackets.cpp index 5601060d5c4..21cabf9a678 100644 --- a/src/server/game/Server/Packets/VoidStoragePackets.cpp +++ b/src/server/game/Server/Packets/VoidStoragePackets.cpp @@ -17,42 +17,47 @@ #include "VoidStoragePackets.h" -WorldPacket const* WorldPackets::VoidStorage::VoidTransferResult::Write() +namespace WorldPackets::VoidStorage +{ +WorldPacket const* VoidTransferResult::Write() { _worldPacket << int32(Result); + return &_worldPacket; } -void WorldPackets::VoidStorage::UnlockVoidStorage::Read() +void UnlockVoidStorage::Read() { _worldPacket >> Npc; } -void WorldPackets::VoidStorage::QueryVoidStorage::Read() +void QueryVoidStorage::Read() { _worldPacket >> Npc; } -WorldPacket const* WorldPackets::VoidStorage::VoidStorageFailed::Write() +WorldPacket const* VoidStorageFailed::Write() { _worldPacket << uint8(Reason); + return &_worldPacket; } -ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::VoidStorage::VoidItem const& voidItem) +ByteBuffer& operator<<(ByteBuffer& data, VoidItem const& voidItem) { data << voidItem.Guid; data << voidItem.Creator; data << uint32(voidItem.Slot); data << voidItem.Item; + return data; } -WorldPacket const* WorldPackets::VoidStorage::VoidStorageContents::Write() +WorldPacket const* VoidStorageContents::Write() { _worldPacket.reserve(1 + Items.size() * sizeof(VoidItem)); - _worldPacket.WriteBits(Items.size(), 8); + _worldPacket << BitsSize<8>(Items); _worldPacket.FlushBits(); for (VoidItem const& voidItem : Items) @@ -61,11 +66,11 @@ WorldPacket const* WorldPackets::VoidStorage::VoidStorageContents::Write() return &_worldPacket; } -void WorldPackets::VoidStorage::VoidStorageTransfer::Read() +void VoidStorageTransfer::Read() { _worldPacket >> Npc; - Deposits.resize(_worldPacket.read<uint32>()); - Withdrawals.resize(_worldPacket.read<uint32>()); + _worldPacket >> Size<uint32>(Deposits); + _worldPacket >> Size<uint32>(Withdrawals); for (ObjectGuid& deposit : Deposits) _worldPacket >> deposit; @@ -74,12 +79,12 @@ void WorldPackets::VoidStorage::VoidStorageTransfer::Read() _worldPacket >> withdrawal; } -WorldPacket const* WorldPackets::VoidStorage::VoidStorageTransferChanges::Write() +WorldPacket const* VoidStorageTransferChanges::Write() { _worldPacket.reserve(1 + AddedItems.size() * sizeof(VoidItem) + RemovedItems.size() * 16); - _worldPacket.WriteBits(AddedItems.size(), 4); - _worldPacket.WriteBits(RemovedItems.size(), 4); + _worldPacket << BitsSize<4>(AddedItems); + _worldPacket << BitsSize<4>(RemovedItems); _worldPacket.FlushBits(); for (VoidItem const& addedItem : AddedItems) @@ -91,16 +96,18 @@ WorldPacket const* WorldPackets::VoidStorage::VoidStorageTransferChanges::Write( return &_worldPacket; } -void WorldPackets::VoidStorage::SwapVoidItem::Read() +void SwapVoidItem::Read() { _worldPacket >> Npc; _worldPacket >> VoidItemGuid; _worldPacket >> DstSlot; } -WorldPacket const* WorldPackets::VoidStorage::VoidItemSwapResponse::Write() +WorldPacket const* VoidItemSwapResponse::Write() { _worldPacket << VoidItemA << uint32(VoidItemSlotA); _worldPacket << VoidItemB << uint32(VoidItemSlotB); + return &_worldPacket; } +} diff --git a/src/server/game/Server/Packets/VoidStoragePackets.h b/src/server/game/Server/Packets/VoidStoragePackets.h index 41ed03aea51..c7a9793cd0b 100644 --- a/src/server/game/Server/Packets/VoidStoragePackets.h +++ b/src/server/game/Server/Packets/VoidStoragePackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef VoidStoragePackets_h__ -#define VoidStoragePackets_h__ +#ifndef TRINITYCORE_VOID_STORAGE_PACKETS_H +#define TRINITYCORE_VOID_STORAGE_PACKETS_H #include "Packet.h" #include "ItemPacketsCommon.h" @@ -30,7 +30,7 @@ namespace WorldPackets class VoidTransferResult final : public ServerPacket { public: - VoidTransferResult(int32 result) : ServerPacket(SMSG_VOID_TRANSFER_RESULT, 4), Result(result) { } + explicit VoidTransferResult(int32 result) : ServerPacket(SMSG_VOID_TRANSFER_RESULT, 4), Result(result) { } WorldPacket const* Write() override; @@ -40,7 +40,7 @@ namespace WorldPackets class UnlockVoidStorage final : public ClientPacket { public: - UnlockVoidStorage(WorldPacket&& packet) : ClientPacket(CMSG_UNLOCK_VOID_STORAGE, std::move(packet)) { } + explicit UnlockVoidStorage(WorldPacket&& packet) : ClientPacket(CMSG_UNLOCK_VOID_STORAGE, std::move(packet)) { } void Read() override; @@ -50,7 +50,7 @@ namespace WorldPackets class QueryVoidStorage final : public ClientPacket { public: - QueryVoidStorage(WorldPacket&& packet) : ClientPacket(CMSG_QUERY_VOID_STORAGE, std::move(packet)) { } + explicit QueryVoidStorage(WorldPacket&& packet) : ClientPacket(CMSG_QUERY_VOID_STORAGE, std::move(packet)) { } void Read() override; @@ -60,7 +60,7 @@ namespace WorldPackets class VoidStorageFailed final : public ServerPacket { public: - VoidStorageFailed() : ServerPacket(SMSG_VOID_STORAGE_FAILED, 1) { } + explicit VoidStorageFailed() : ServerPacket(SMSG_VOID_STORAGE_FAILED, 1) { } WorldPacket const* Write() override; @@ -78,7 +78,7 @@ namespace WorldPackets class VoidStorageContents final : public ServerPacket { public: - VoidStorageContents() : ServerPacket(SMSG_VOID_STORAGE_CONTENTS, 0) { } + explicit VoidStorageContents() : ServerPacket(SMSG_VOID_STORAGE_CONTENTS, 0) { } WorldPacket const* Write() override; @@ -88,7 +88,7 @@ namespace WorldPackets class VoidStorageTransfer final : public ClientPacket { public: - VoidStorageTransfer(WorldPacket&& packet) : ClientPacket(CMSG_VOID_STORAGE_TRANSFER, std::move(packet)) { } + explicit VoidStorageTransfer(WorldPacket&& packet) : ClientPacket(CMSG_VOID_STORAGE_TRANSFER, std::move(packet)) { } void Read() override; @@ -100,7 +100,7 @@ namespace WorldPackets class VoidStorageTransferChanges final : public ServerPacket { public: - VoidStorageTransferChanges() : ServerPacket(SMSG_VOID_STORAGE_TRANSFER_CHANGES, 0) { } + explicit VoidStorageTransferChanges() : ServerPacket(SMSG_VOID_STORAGE_TRANSFER_CHANGES, 0) { } WorldPacket const* Write() override; @@ -111,7 +111,7 @@ namespace WorldPackets class SwapVoidItem final : public ClientPacket { public: - SwapVoidItem(WorldPacket&& packet) : ClientPacket(CMSG_SWAP_VOID_ITEM, std::move(packet)) { } + explicit SwapVoidItem(WorldPacket&& packet) : ClientPacket(CMSG_SWAP_VOID_ITEM, std::move(packet)) { } void Read() override; @@ -123,7 +123,7 @@ namespace WorldPackets class VoidItemSwapResponse final : public ServerPacket { public: - VoidItemSwapResponse() : ServerPacket(SMSG_VOID_ITEM_SWAP_RESPONSE, 16 + 16 + 4 + 4) { } + explicit VoidItemSwapResponse() : ServerPacket(SMSG_VOID_ITEM_SWAP_RESPONSE, 16 + 16 + 4 + 4) { } WorldPacket const* Write() override; @@ -135,4 +135,4 @@ namespace WorldPackets } } -#endif // VoidStoragePackets_h__ +#endif // TRINITYCORE_VOID_STORAGE_PACKETS_H diff --git a/src/server/game/Server/Packets/WardenPackets.cpp b/src/server/game/Server/Packets/WardenPackets.cpp index b5fa70b1c78..1f092403be1 100644 --- a/src/server/game/Server/Packets/WardenPackets.cpp +++ b/src/server/game/Server/Packets/WardenPackets.cpp @@ -16,14 +16,15 @@ */ #include "WardenPackets.h" +#include "PacketUtilities.h" -void WorldPackets::Warden::WardenData::Read() +namespace WorldPackets::Warden { - uint32 size = _worldPacket.read<uint32>(); +void WardenData::Read() +{ + uint32 requestedSize = _worldPacket.read<uint32>(); - if (size) - { - Data.resize(size); - _worldPacket.read(Data.data(), size); - } + Data.resize(requestedSize); + _worldPacket.read(Data.data(), requestedSize); +} } diff --git a/src/server/game/Server/Packets/WardenPackets.h b/src/server/game/Server/Packets/WardenPackets.h index d3160e33ab4..938e345e806 100644 --- a/src/server/game/Server/Packets/WardenPackets.h +++ b/src/server/game/Server/Packets/WardenPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef WardenPackets_h__ -#define WardenPackets_h__ +#ifndef TRINITYCORE_WARDEN_PACKETS_H +#define TRINITYCORE_WARDEN_PACKETS_H #include "Packet.h" @@ -27,7 +27,7 @@ namespace WorldPackets class WardenData final : public ClientPacket { public: - WardenData(WorldPacket&& packet) : ClientPacket(CMSG_WARDEN3_DATA, std::move(packet)) { } + explicit WardenData(WorldPacket&& packet) : ClientPacket(CMSG_WARDEN3_DATA, std::move(packet)) { } void Read() override; @@ -36,4 +36,4 @@ namespace WorldPackets } } -#endif // WardenPackets_h__ +#endif // TRINITYCORE_WARDEN_PACKETS_H diff --git a/src/server/game/Server/Packets/WhoPackets.h b/src/server/game/Server/Packets/WhoPackets.h index 7f88393098b..d72ac195350 100644 --- a/src/server/game/Server/Packets/WhoPackets.h +++ b/src/server/game/Server/Packets/WhoPackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef WhoPackets_h__ -#define WhoPackets_h__ +#ifndef TRINITYCORE_WHO_PACKETS_H +#define TRINITYCORE_WHO_PACKETS_H #include "Packet.h" #include "ObjectGuid.h" @@ -30,7 +30,7 @@ namespace WorldPackets class WhoIsRequest final : public ClientPacket { public: - WhoIsRequest(WorldPacket&& packet) : ClientPacket(CMSG_WHO_IS, std::move(packet)) { } + explicit WhoIsRequest(WorldPacket&& packet) : ClientPacket(CMSG_WHO_IS, std::move(packet)) { } void Read() override; @@ -40,7 +40,7 @@ namespace WorldPackets class WhoIsResponse final : public ServerPacket { public: - WhoIsResponse() : ServerPacket(SMSG_WHO_IS, 2) { } + explicit WhoIsResponse() : ServerPacket(SMSG_WHO_IS, 2) { } WorldPacket const* Write() override; @@ -79,7 +79,7 @@ namespace WorldPackets class WhoRequestPkt final : public ClientPacket { public: - WhoRequestPkt(WorldPacket&& packet) : ClientPacket(CMSG_WHO, std::move(packet)) { } + explicit WhoRequestPkt(WorldPacket&& packet) : ClientPacket(CMSG_WHO, std::move(packet)) { } void Read() override; @@ -108,7 +108,7 @@ namespace WorldPackets class WhoResponsePkt final : public ServerPacket { public: - WhoResponsePkt() : ServerPacket(SMSG_WHO, 1) { } + explicit WhoResponsePkt() : ServerPacket(SMSG_WHO, 1) { } WorldPacket const* Write() override; @@ -118,4 +118,4 @@ namespace WorldPackets } } -#endif // WhoPackets_h__ +#endif // TRINITYCORE_WHO_PACKETS_H diff --git a/src/server/game/Server/Packets/WorldStatePackets.cpp b/src/server/game/Server/Packets/WorldStatePackets.cpp index 4528861bdb5..801e273a9fd 100644 --- a/src/server/game/Server/Packets/WorldStatePackets.cpp +++ b/src/server/game/Server/Packets/WorldStatePackets.cpp @@ -16,11 +16,11 @@ */ #include "WorldStatePackets.h" +#include "PacketUtilities.h" -WorldPackets::WorldState::InitWorldStates::InitWorldStates() - : ServerPacket(SMSG_INIT_WORLD_STATES, 16) { } - -WorldPacket const* WorldPackets::WorldState::InitWorldStates::Write() +namespace WorldPackets::WorldState +{ +WorldPacket const* InitWorldStates::Write() { _worldPacket.reserve(16 + Worldstates.size() * 8); @@ -28,7 +28,7 @@ WorldPacket const* WorldPackets::WorldState::InitWorldStates::Write() _worldPacket << int32(AreaID); _worldPacket << int32(SubareaID); - _worldPacket << uint32(Worldstates.size()); + _worldPacket << Size<uint32>(Worldstates); for (WorldStateInfo const& wsi : Worldstates) { _worldPacket << int32(wsi.VariableID); @@ -38,15 +38,13 @@ WorldPacket const* WorldPackets::WorldState::InitWorldStates::Write() return &_worldPacket; } -WorldPackets::WorldState::UpdateWorldState::UpdateWorldState() - : ServerPacket(SMSG_UPDATE_WORLD_STATE, 9) { } - -WorldPacket const* WorldPackets::WorldState::UpdateWorldState::Write() +WorldPacket const* UpdateWorldState::Write() { _worldPacket << uint32(VariableID); _worldPacket << int32(Value); - _worldPacket.WriteBit(Hidden); + _worldPacket << Bits<1>(Hidden); _worldPacket.FlushBits(); return &_worldPacket; } +} diff --git a/src/server/game/Server/Packets/WorldStatePackets.h b/src/server/game/Server/Packets/WorldStatePackets.h index edb94c2f4d2..3db039a2a49 100644 --- a/src/server/game/Server/Packets/WorldStatePackets.h +++ b/src/server/game/Server/Packets/WorldStatePackets.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef WorldStatePackets_h__ -#define WorldStatePackets_h__ +#ifndef TRINITYCORE_WORLD_STATE_PACKETS_H +#define TRINITYCORE_WORLD_STATE_PACKETS_H #include "Packet.h" @@ -36,7 +36,7 @@ namespace WorldPackets int32 Value; }; - InitWorldStates(); + explicit InitWorldStates() : ServerPacket(SMSG_INIT_WORLD_STATES, 16) { } WorldPacket const* Write() override; @@ -50,7 +50,7 @@ namespace WorldPackets class UpdateWorldState final : public ServerPacket { public: - UpdateWorldState(); + explicit UpdateWorldState() : ServerPacket(SMSG_UPDATE_WORLD_STATE, 4 + 1 + 4) { } WorldPacket const* Write() override; @@ -61,4 +61,4 @@ namespace WorldPackets } } -#endif // WorldStatePackets_h__ +#endif // TRINITYCORE_WORLD_STATE_PACKETS_H diff --git a/src/server/game/Support/SupportMgr.cpp b/src/server/game/Support/SupportMgr.cpp index 9d2e57f12fd..8b21ed669d1 100644 --- a/src/server/game/Support/SupportMgr.cpp +++ b/src/server/game/Support/SupportMgr.cpp @@ -227,7 +227,7 @@ void ComplaintTicket::LoadFromDB(Field* fields) void ComplaintTicket::LoadChatLineFromDB(Field* fields) { - _chatLog.Lines.emplace_back(fields[0].GetInt64(), fields[1].GetString()); + _chatLog.Lines.emplace_back(fields[0].GetInt64(), fields[1].GetStringView()); } void ComplaintTicket::SaveToDB() const |