diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2017-02-20 18:08:40 -0300 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2017-02-21 03:03:58 -0300 |
| commit | dd1aa64563bfb726e1132a135927a02fbb765454 (patch) | |
| tree | 7b60326913feab118019a8c9e5bc3d8999882f7e /src/server/game/Entities | |
| parent | c274ea8a98e9751d50301e99eb55577ba19155f2 (diff) | |
Core/Packet: convert query packets into new system.
- Extra c++11-ification of existing code
- Refs #18637
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 62 | ||||
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 47 | ||||
| -rw-r--r-- | src/server/game/Entities/Item/ItemTemplate.cpp | 189 |
3 files changed, 144 insertions, 154 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 93345dee29e..c011325acff 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -49,6 +49,8 @@ #include "Transport.h" #include "ScriptedGossip.h" +#include "Packets/QueryPackets.h" + TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const { TrainerSpellMap::const_iterator itr = spellList.find(spell_id); @@ -158,7 +160,7 @@ void CreatureTemplate::InitializeQueryData() WorldPacket CreatureTemplate::BuildQueryData(LocaleConstant loc) const { - WorldPacket queryTemp(SMSG_CREATURE_QUERY_RESPONSE, 200); + WorldPackets::Query::QueryCreatureResponse queryTemp; std::string locName = Name, locTitle = Title; if (CreatureLocale const* cl = sObjectMgr->GetCreatureLocale(Entry)) @@ -167,39 +169,35 @@ WorldPacket CreatureTemplate::BuildQueryData(LocaleConstant loc) const ObjectMgr::GetLocaleString(cl->Title, loc, locTitle); } - queryTemp << uint32(Entry); // creature entry - queryTemp << locName; - queryTemp << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4, always empty - queryTemp << locTitle; - queryTemp << IconName; // "Directions" for guard, string for Icons 2.3.0 - queryTemp << uint32(type_flags); // flags - queryTemp << uint32(type); // CreatureType.dbc - queryTemp << uint32(family); // CreatureFamily.dbc - queryTemp << uint32(rank); // Creature Rank (elite, boss, etc) - queryTemp << uint32(KillCredit[0]); // new in 3.1, kill credit - queryTemp << uint32(KillCredit[1]); // new in 3.1, kill credit - queryTemp << uint32(Modelid1); // Modelid1 - queryTemp << uint32(Modelid2); // Modelid2 - queryTemp << uint32(Modelid3); // Modelid3 - queryTemp << uint32(Modelid4); // Modelid4 - queryTemp << float(ModHealth); // dmg/hp modifier - queryTemp << float(ModMana); // dmg/mana modifier - queryTemp << uint8(RacialLeader); - - CreatureQuestItemList const* items = sObjectMgr->GetCreatureQuestItemList(Entry); - if (items) - { + queryTemp.CreatureID = Entry; + queryTemp.Allow = true; + + queryTemp.Stats.Name = locName; + queryTemp.Stats.NameAlt = locTitle; + queryTemp.Stats.CursorName = IconName; + queryTemp.Stats.Flags = type_flags; + queryTemp.Stats.CreatureType = type; + queryTemp.Stats.CreatureFamily = family; + queryTemp.Stats.Classification = rank; + memcpy(queryTemp.Stats.ProxyCreatureID, KillCredit, sizeof(uint32) * MAX_KILL_CREDIT); + queryTemp.Stats.CreatureDisplayID[0] = Modelid1; + queryTemp.Stats.CreatureDisplayID[1] = Modelid2; + queryTemp.Stats.CreatureDisplayID[2] = Modelid3; + queryTemp.Stats.CreatureDisplayID[3] = Modelid4; + queryTemp.Stats.HpMulti = ModHealth; + queryTemp.Stats.EnergyMulti = ModMana; + queryTemp.Stats.Leader = RacialLeader; + + for (uint32 i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i) + queryTemp.Stats.QuestItems[i] = 0; + + if (CreatureQuestItemList const* items = sObjectMgr->GetCreatureQuestItemList(Entry)) for (uint32 i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i) - queryTemp << (i < items->size() ? uint32((*items)[i]) : uint32(0)); - } - else - { - for (uint32 i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i) - queryTemp << uint32(0); - } + if (i < items->size()) + queryTemp.Stats.QuestItems[i] = (*items)[i]; - queryTemp << uint32(movementId); // CreatureMovementInfo.dbc - return queryTemp; + queryTemp.Stats.CreatureMovementInfoID = movementId; + return *queryTemp.Write(); } bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 2fc2d44666b..851fdc5edca 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -33,6 +33,8 @@ #include "World.h" #include "Transport.h" +#include "Packets/QueryPackets.h" + void GameObjectTemplate::InitializeQueryData() { WorldPacket queryTemp; @@ -45,7 +47,7 @@ void GameObjectTemplate::InitializeQueryData() WorldPacket GameObjectTemplate::BuildQueryData(LocaleConstant loc) const { - WorldPacket queryTemp(SMSG_GAMEOBJECT_QUERY_RESPONSE, 200); + WorldPackets::Query::QueryGameObjectResponse queryTemp; std::string locName = name; std::string locIconName = IconName; @@ -57,30 +59,27 @@ WorldPacket GameObjectTemplate::BuildQueryData(LocaleConstant loc) const ObjectMgr::GetLocaleString(gameObjectLocale->CastBarCaption, loc, locCastBarCaption); } - queryTemp << uint32(entry); - queryTemp << uint32(type); - queryTemp << uint32(displayId); - queryTemp << locName; - queryTemp << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4 - queryTemp << locIconName; // 2.0.3, string. Icon name to use instead of default icon for go's (ex: "Attack" makes sword) - queryTemp << locCastBarCaption; // 2.0.3, string. Text will appear in Cast Bar when using GO (ex: "Collecting") - queryTemp << unk1; // 2.0.3, string - queryTemp.append(raw.data, MAX_GAMEOBJECT_DATA); - queryTemp << float(size); // go size - - GameObjectQuestItemList const* items = sObjectMgr->GetGameObjectQuestItemList(entry); - if (items) - { - for (size_t i = 0; i < MAX_GAMEOBJECT_QUEST_ITEMS; ++i) - queryTemp << (i < items->size() ? uint32((*items)[i]) : uint32(0)); - } - else - { - for (size_t i = 0; i < MAX_GAMEOBJECT_QUEST_ITEMS; ++i) - queryTemp << uint32(0); - } + queryTemp.GameObjectID = entry; + queryTemp.Allow = true; + + queryTemp.Stats.Type = type; + queryTemp.Stats.DisplayID = displayId; + queryTemp.Stats.Name = locName; + queryTemp.Stats.IconName = locIconName; + queryTemp.Stats.CastBarCaption = locCastBarCaption; + queryTemp.Stats.UnkString = unk1; + memcpy(queryTemp.Stats.Data, raw.data, sizeof(uint32) * MAX_GAMEOBJECT_DATA); + queryTemp.Stats.Size = size; + + for (uint32 i = 0; i < MAX_GAMEOBJECT_QUEST_ITEMS; ++i) + queryTemp.Stats.QuestItems[i] = 0; + + if (GameObjectQuestItemList const* items = sObjectMgr->GetGameObjectQuestItemList(entry)) + for (uint32 i = 0; i < MAX_GAMEOBJECT_QUEST_ITEMS; ++i) + if (i < items->size()) + queryTemp.Stats.QuestItems[i] = (*items)[i]; - return queryTemp; + return *queryTemp.Write(); } GameObject::GameObject() : WorldObject(false), MapObject(), diff --git a/src/server/game/Entities/Item/ItemTemplate.cpp b/src/server/game/Entities/Item/ItemTemplate.cpp index e55d0d73132..ee5b34831db 100644 --- a/src/server/game/Entities/Item/ItemTemplate.cpp +++ b/src/server/game/Entities/Item/ItemTemplate.cpp @@ -24,6 +24,8 @@ #include "SpellInfo.h" #include "SpellMgr.h" +#include "Packets/QueryPackets.h" + bool ItemTemplate::CanChangeEquipStateInCombat() const { switch (InventoryType) @@ -160,7 +162,7 @@ void ItemTemplate::InitializeQueryData() WorldPacket ItemTemplate::BuildQueryData(LocaleConstant loc) const { - WorldPacket queryTemp(SMSG_ITEM_QUERY_SINGLE_RESPONSE, 500); + WorldPackets::Query::QueryItemSingleResponse response; std::string locName = Name1; std::string locDescription = Description; @@ -171,114 +173,105 @@ WorldPacket ItemTemplate::BuildQueryData(LocaleConstant loc) const ObjectMgr::GetLocaleString(il->Description, loc, locDescription); } - queryTemp << ItemId; - queryTemp << Class; - queryTemp << SubClass; - queryTemp << SoundOverrideSubclass; - queryTemp << locName; - queryTemp << uint8(0x00); //Name2; // blizz not send name there, just uint8(0x00); <-- \0 = empty string = empty name... - queryTemp << uint8(0x00); //Name3; // blizz not send name there, just uint8(0x00); - queryTemp << uint8(0x00); //Name4; // blizz not send name there, just uint8(0x00); - queryTemp << DisplayInfoID; - queryTemp << Quality; - queryTemp << Flags; - queryTemp << Flags2; - queryTemp << BuyPrice; - queryTemp << SellPrice; - queryTemp << InventoryType; - queryTemp << AllowableClass; - queryTemp << AllowableRace; - queryTemp << ItemLevel; - queryTemp << RequiredLevel; - queryTemp << RequiredSkill; - queryTemp << RequiredSkillRank; - queryTemp << RequiredSpell; - queryTemp << RequiredHonorRank; - queryTemp << RequiredCityRank; - queryTemp << RequiredReputationFaction; - queryTemp << RequiredReputationRank; - queryTemp << int32(MaxCount); - queryTemp << int32(Stackable); - queryTemp << ContainerSlots; - queryTemp << StatsCount; // item stats count + response.ItemID = ItemId; + response.Allow = true; + + response.Stats.Class = Class; + response.Stats.SubClass = SubClass; + response.Stats.SoundOverrideSubclass = SoundOverrideSubclass; + response.Stats.Name = locName; + response.Stats.DisplayInfoID = DisplayInfoID; + response.Stats.Quality = Quality; + response.Stats.Flags = Flags; + response.Stats.Flags2 = Flags2; + response.Stats.BuyPrice = BuyPrice; + response.Stats.SellPrice = SellPrice; + response.Stats.InventoryType = InventoryType; + response.Stats.AllowableClass = AllowableClass; + response.Stats.AllowableRace = AllowableRace; + response.Stats.ItemLevel = ItemLevel; + response.Stats.RequiredLevel = RequiredLevel; + response.Stats.RequiredSkill = RequiredSkill; + response.Stats.RequiredSkillRank = RequiredSkillRank; + response.Stats.RequiredSpell = RequiredSpell; + response.Stats.RequiredHonorRank = RequiredHonorRank; + response.Stats.RequiredCityRank = RequiredCityRank; + response.Stats.RequiredReputationFaction = RequiredReputationFaction; + response.Stats.RequiredReputationRank = RequiredReputationRank; + response.Stats.MaxCount = MaxCount; + response.Stats.Stackable = Stackable; + response.Stats.ContainerSlots = ContainerSlots; + response.Stats.StatsCount = StatsCount; for (uint32 i = 0; i < StatsCount; ++i) { - queryTemp << ItemStat[i].ItemStatType; - queryTemp << ItemStat[i].ItemStatValue; + response.Stats.ItemStat[i].ItemStatType = ItemStat[i].ItemStatType; + response.Stats.ItemStat[i].ItemStatValue = ItemStat[i].ItemStatValue; } - queryTemp << ScalingStatDistribution; // scaling stats distribution - queryTemp << ScalingStatValue; // some kind of flags used to determine stat values column - for (int i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i) + + response.Stats.ScalingStatDistribution = ScalingStatDistribution; + response.Stats.ScalingStatValue = ScalingStatValue; + + for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i) { - queryTemp << Damage[i].DamageMin; - queryTemp << Damage[i].DamageMax; - queryTemp << Damage[i].DamageType; + response.Stats.Damage[i].DamageMin = Damage[i].DamageMin; + response.Stats.Damage[i].DamageMax = Damage[i].DamageMax; + response.Stats.Damage[i].DamageType = Damage[i].DamageType; } - // resistances (7) - queryTemp << Armor; - queryTemp << HolyRes; - queryTemp << FireRes; - queryTemp << NatureRes; - queryTemp << FrostRes; - queryTemp << ShadowRes; - queryTemp << ArcaneRes; + response.Stats.Resistance[SPELL_SCHOOL_NORMAL] = Armor; + response.Stats.Resistance[SPELL_SCHOOL_HOLY] = HolyRes; + response.Stats.Resistance[SPELL_SCHOOL_FIRE] = FireRes; + response.Stats.Resistance[SPELL_SCHOOL_NATURE] = NatureRes; + response.Stats.Resistance[SPELL_SCHOOL_FROST] = FrostRes; + response.Stats.Resistance[SPELL_SCHOOL_SHADOW] = ShadowRes; + response.Stats.Resistance[SPELL_SCHOOL_ARCANE] = ArcaneRes; - queryTemp << Delay; - queryTemp << AmmoType; - queryTemp << RangedModRange; + response.Stats.Delay = Delay; + response.Stats.AmmoType = AmmoType; + response.Stats.RangedModRange = RangedModRange; for (uint8 s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s) { - // spells are validated on template loading - if (Spells[s].SpellId > 0) - { - queryTemp << Spells[s].SpellId; - queryTemp << Spells[s].SpellTrigger; - queryTemp << uint32(-abs(Spells[s].SpellCharges)); - queryTemp << uint32(Spells[s].SpellCooldown); - queryTemp << uint32(Spells[s].SpellCategory); - queryTemp << uint32(Spells[s].SpellCategoryCooldown); - } - else - { - queryTemp << uint32(0); - queryTemp << uint32(0); - queryTemp << uint32(0); - queryTemp << uint32(-1); - queryTemp << uint32(0); - queryTemp << uint32(-1); - } + response.Stats.Spells[s].SpellId = Spells[s].SpellId; + response.Stats.Spells[s].SpellTrigger = Spells[s].SpellTrigger; + response.Stats.Spells[s].SpellCharges = Spells[s].SpellCharges; + response.Stats.Spells[s].SpellCooldown = Spells[s].SpellCooldown; + response.Stats.Spells[s].SpellCategory = Spells[s].SpellCategory; + response.Stats.Spells[s].SpellCategoryCooldown = Spells[s].SpellCategoryCooldown; } - queryTemp << Bonding; - queryTemp << locDescription; - queryTemp << PageText; - queryTemp << LanguageID; - queryTemp << PageMaterial; - queryTemp << StartQuest; - queryTemp << LockID; - queryTemp << int32(Material); - queryTemp << Sheath; - queryTemp << RandomProperty; - queryTemp << RandomSuffix; - queryTemp << Block; - queryTemp << ItemSet; - queryTemp << MaxDurability; - queryTemp << Area; - queryTemp << Map; // Added in 1.12.x & 2.0.1 client branch - queryTemp << BagFamily; - queryTemp << TotemCategory; - for (int s = 0; s < MAX_ITEM_PROTO_SOCKETS; ++s) + + response.Stats.Bonding = Bonding; + response.Stats.Description = locDescription; + response.Stats.PageText = PageText; + response.Stats.LanguageID = LanguageID; + response.Stats.PageMaterial = PageMaterial; + response.Stats.StartQuest = StartQuest; + response.Stats.LockID = LockID; + response.Stats.Material = Material; + response.Stats.Sheath = Sheath; + response.Stats.RandomProperty = RandomProperty; + response.Stats.RandomSuffix = RandomSuffix; + response.Stats.Block = Block; + response.Stats.ItemSet = ItemSet; + response.Stats.MaxDurability = MaxDurability; + response.Stats.Area = Area; + response.Stats.Map = Map; + response.Stats.BagFamily = BagFamily; + response.Stats.TotemCategory = TotemCategory; + + for (uint8 s = 0; s < MAX_ITEM_PROTO_SOCKETS; ++s) { - queryTemp << Socket[s].Color; - queryTemp << Socket[s].Content; + response.Stats.Socket[s].Color = Socket[s].Color; + response.Stats.Socket[s].Content = Socket[s].Content; } - queryTemp << socketBonus; - queryTemp << GemProperties; - queryTemp << RequiredDisenchantSkill; - queryTemp << ArmorDamageModifier; - queryTemp << Duration; // added in 2.4.2.8209, duration (seconds) - queryTemp << ItemLimitCategory; // WotLK, ItemLimitCategory - queryTemp << HolidayId; // Holiday.dbc? - return queryTemp; + + response.Stats.SocketBonus = socketBonus; + response.Stats.GemProperties = GemProperties; + response.Stats.RequiredDisenchantSkill = RequiredDisenchantSkill; + response.Stats.ArmorDamageModifier = ArmorDamageModifier; + response.Stats.Duration = Duration; + response.Stats.ItemLimitCategory = ItemLimitCategory; + response.Stats.HolidayId = HolidayId; + + return *response.Write(); } |
