Core/PacketIO: Convert all leftover packets to use packet classes

Port From (https://github.com/TrinityCore/TrinityCore/commit/661470c6587c11e3fa94d2e8b57c92d8be2e297b)
This commit is contained in:
hondacrx
2020-07-14 23:00:31 -04:00
parent 4bb9823456
commit baa9ab6558
15 changed files with 251 additions and 186 deletions
@@ -442,6 +442,19 @@ namespace Game.Networking.Packets
public override void Read() { }
}
class RatedBattlefieldInfo : ServerPacket
{
public RatedBattlefieldInfo() : base(ServerOpcodes.RatedBattlefieldInfo) { }
public override void Write()
{
foreach (BracketInfo bracket in Bracket)
bracket.Write(_worldPacket);
}
BracketInfo[] Bracket = new BracketInfo[6];
}
class PVPMatchInit : ServerPacket
{
public PVPMatchInit() : base(ServerOpcodes.PvpMatchInit, ConnectionType.Instance) { }
@@ -497,6 +510,43 @@ namespace Game.Networking.Packets
}
//Structs
class BracketInfo
{
public int PersonalRating;
public int Ranking;
public int SeasonPlayed;
public int SeasonWon;
public int Unused1;
public int Unused2;
public int WeeklyPlayed;
public int WeeklyWon;
public int BestWeeklyRating;
public int LastWeeksBestRating;
public int BestSeasonRating;
public int PvpTierID;
public int Unused3;
public bool Unused4;
public void Write(WorldPacket data)
{
data.WriteInt32(PersonalRating);
data.WriteInt32(Ranking);
data.WriteInt32(SeasonPlayed);
data.WriteInt32(SeasonWon);
data.WriteInt32(Unused1);
data.WriteInt32(Unused2);
data.WriteInt32(WeeklyPlayed);
data.WriteInt32(WeeklyWon);
data.WriteInt32(BestWeeklyRating);
data.WriteInt32(LastWeeksBestRating);
data.WriteInt32(BestSeasonRating);
data.WriteInt32(PvpTierID);
data.WriteInt32(Unused3);
data.WriteBit(Unused4);
data.FlushBits();
}
}
public class PVPLogData
{
public List<PVPMatchPlayerStatistics> Statistics = new List<PVPMatchPlayerStatistics>();
@@ -525,24 +525,24 @@ namespace Game.Networking.Packets
class EnchantmentLog : ServerPacket
{
public EnchantmentLog() : base(ServerOpcodes.EnchantmentLog) { }
public EnchantmentLog() : base(ServerOpcodes.EnchantmentLog, ConnectionType.Instance) { }
public override void Write()
{
_worldPacket.WritePackedGuid(Caster);
{
_worldPacket.WritePackedGuid(Owner);
_worldPacket.WritePackedGuid(Caster);
_worldPacket.WritePackedGuid(ItemGUID);
_worldPacket.WriteUInt32(ItemID);
_worldPacket.WriteUInt32(Enchantment);
_worldPacket.WriteUInt32(EnchantSlot);
}
public ObjectGuid Caster;
public ObjectGuid Owner;
public ObjectGuid Caster;
public ObjectGuid ItemGUID;
public uint ItemID;
public uint EnchantSlot;
public uint Enchantment;
public uint EnchantSlot;
}
class CancelTempEnchantment : ClientPacket
@@ -572,7 +572,7 @@ namespace Game.Networking.Packets
public uint SpellID;
public uint Cooldown;
}
class ItemEnchantTimeUpdate : ServerPacket
{
public ItemEnchantTimeUpdate() : base(ServerOpcodes.ItemEnchantTimeUpdate, ConnectionType.Instance) { }
+37 -15
View File
@@ -102,6 +102,28 @@ namespace Game.Networking.Packets
public List<LootRequest> Loot = new List<LootRequest>();
}
class MasterLootItem : ClientPacket
{
public MasterLootItem(WorldPacket packet) : base(packet) { }
public override void Read()
{
uint Count = _worldPacket.ReadUInt32();
Target = _worldPacket.ReadPackedGuid();
for (uint i = 0; i < Count; ++i)
{
LootRequest lootRequest = new LootRequest();
lootRequest.Object = _worldPacket.ReadPackedGuid();
lootRequest.LootListID = _worldPacket.ReadUInt8();
Loot.Add(lootRequest);
}
}
public Array<LootRequest> Loot = new Array<LootRequest>(1000);
public ObjectGuid Target;
}
class LootRemoved : ServerPacket
{
public LootRemoved() : base(ServerOpcodes.LootRemoved, ConnectionType.Instance) { }
@@ -337,6 +359,21 @@ namespace Game.Networking.Packets
public byte LootListID;
}
class MasterLootCandidateList : ServerPacket
{
public MasterLootCandidateList() : base(ServerOpcodes.MasterLootCandidateList, ConnectionType.Instance) { }
public override void Write()
{
_worldPacket.WritePackedGuid(LootObj);
_worldPacket.WriteInt32(Players.Count);
Players.ForEach(guid => _worldPacket.WritePackedGuid(guid));
}
public List<ObjectGuid> Players = new List<ObjectGuid>();
public ObjectGuid LootObj;
}
class AELootTargets : ServerPacket
{
public AELootTargets(uint count) : base(ServerOpcodes.AeLootTargets, ConnectionType.Instance)
@@ -359,21 +396,6 @@ namespace Game.Networking.Packets
public override void Write() { }
}
class MasterLootCandidateList : ServerPacket
{
public MasterLootCandidateList() : base(ServerOpcodes.MasterLootCandidateList) { }
public override void Write()
{
_worldPacket.WritePackedGuid(LootObj);
_worldPacket.WriteInt32(Players.Count);
Players.ForEach(guid => _worldPacket.WritePackedGuid(guid));
}
public List<ObjectGuid> Players = new List<ObjectGuid>();
public ObjectGuid LootObj;
}
//Structs
public class LootItemData
{
@@ -105,6 +105,13 @@ namespace Game.Networking.Packets
public int GameTimeHolidayOffset;
}
public class ResetWeeklyCurrency : ServerPacket
{
public ResetWeeklyCurrency() : base(ServerOpcodes.ResetWeeklyCurrency, ConnectionType.Instance) { }
public override void Write() { }
}
public class SetCurrency : ServerPacket
{
public SetCurrency() : base(ServerOpcodes.SetCurrency, ConnectionType.Instance) { }
@@ -168,13 +175,6 @@ namespace Game.Networking.Packets
public uint Type;
}
public class ResetWeeklyCurrency : ServerPacket
{
public ResetWeeklyCurrency() : base(ServerOpcodes.ResetWeeklyCurrency, ConnectionType.Instance) { }
public override void Write() { }
}
public class SetSelection : ClientPacket
{
public SetSelection(WorldPacket packet) : base(packet) { }
+40 -44
View File
@@ -164,6 +164,18 @@ namespace Game.Networking.Packets
public List<PetStableInfo> Pets = new List<PetStableInfo>();
}
class PetStableResult : ServerPacket
{
public PetStableResult() : base(ServerOpcodes.PetStableResult, ConnectionType.Instance) { }
public override void Write()
{
_worldPacket.WriteUInt8((byte)Result);
}
public StableResult Result;
}
class PetLearnedSpells : ServerPacket
{
public PetLearnedSpells() : base(ServerOpcodes.PetLearnedSpells, ConnectionType.Instance) { }
@@ -288,34 +300,6 @@ namespace Game.Networking.Packets
public uint Action;
}
class PetActionSound : ServerPacket
{
public PetActionSound() : base(ServerOpcodes.PetStableResult) { }
public override void Write()
{
_worldPacket.WritePackedGuid(UnitGUID);
_worldPacket.WriteUInt32((uint)Action);
}
public ObjectGuid UnitGUID;
public PetTalk Action;
}
class PetActionFeedback : ServerPacket
{
public PetActionFeedback() : base(ServerOpcodes.PetStableResult) { }
public override void Write()
{
_worldPacket.WriteUInt32(SpellID);
_worldPacket.WriteUInt8((byte)Response);
}
public uint SpellID;
public ActionFeedback Response;
}
class PetCancelAura : ClientPacket
{
public PetCancelAura(WorldPacket packet) : base(packet) { }
@@ -330,22 +314,6 @@ namespace Game.Networking.Packets
public uint SpellID;
}
class PetStableResult : ServerPacket
{
public PetStableResult(byte result) : base(ServerOpcodes.PetStableResult)
{
Result = result;
}
public override void Write()
{
_worldPacket.WriteUInt8(Result);
}
public byte Result;
}
class SetPetSpecialization : ServerPacket
{
public SetPetSpecialization() : base(ServerOpcodes.SetPetSpecialization) { }
@@ -358,6 +326,34 @@ namespace Game.Networking.Packets
public ushort SpecID;
}
class PetActionFeedbackPacket : ServerPacket
{
public PetActionFeedbackPacket() : base(ServerOpcodes.PetStableResult) { }
public override void Write()
{
_worldPacket.WriteUInt32(SpellID);
_worldPacket.WriteUInt8((byte)Response);
}
public uint SpellID;
public PetActionFeedback Response;
}
class PetActionSound : ServerPacket
{
public PetActionSound() : base(ServerOpcodes.PetStableResult) { }
public override void Write()
{
_worldPacket.WritePackedGuid(UnitGUID);
_worldPacket.WriteUInt32((uint)Action);
}
public ObjectGuid UnitGUID;
public PetTalk Action;
}
//Structs
public class PetSpellCooldown
{