public static void HandleServerChatMessage(Packet packet) { var text = new CreatureText(); var senderGUIDBytes = new byte[8]; var guildGUIDBytes = new byte[8]; var receiverGUIDBytes = new byte[8]; var groupGUIDBytes = new byte[8]; var hasLang = !packet.ReadBit(); var hasReceiver = !packet.ReadBit(); packet.ReadBit(); // fake bit packet.StartBitStream(groupGUIDBytes, 3, 7, 2, 6, 0, 4, 5, 1); var hasAchi = !packet.ReadBit(); var bit1495 = packet.ReadBit(); var hasPrefix = !packet.ReadBit(); packet.ReadBit(); // fake bit var bit43D = !packet.ReadBit(); packet.StartBitStream(guildGUIDBytes, 1, 6, 0, 5, 2, 4, 7, 3); packet.ReadBit(); // fake bit packet.StartBitStream(receiverGUIDBytes, 6, 1, 3, 5, 4, 2, 7, 0); var receiverLen = 0u; if (hasReceiver) receiverLen = packet.ReadBits(11); var hasChannel = !packet.ReadBit(); var bit1494 = packet.ReadBit(); var bit1490 = !packet.ReadBit(); var hasRealmId = !packet.ReadBit(); var bits43D = 0u; if (bit43D) bits43D = packet.ReadBits(11); var channelLen = 0u; if (hasChannel) channelLen = packet.ReadBits(7); var bit8CF = !packet.ReadBit(); var textLen = 0u; if (bit8CF) textLen = packet.ReadBits(12); packet.ReadBit(); // fake bit packet.StartBitStream(senderGUIDBytes, 4, 1, 3, 6, 2, 5, 0, 7); var bit148C = !packet.ReadBit(); var bits148C = 0u; if (bit148C) bits148C = packet.ReadBits(9); // TODO: missing sender name if (hasPrefix) { var prefixLen = packet.ReadBits(5); packet.ReadWoWString("Addon Message Prefix", prefixLen); } packet.ParseBitStream(groupGUIDBytes, 4, 2, 7, 3, 6, 1, 5, 0); if (hasReceiver) text.ReceiverName = packet.ReadWoWString("Receiver Name", receiverLen); packet.ParseBitStream(receiverGUIDBytes, 7, 4, 1, 3, 0, 6, 5, 2); packet.ParseBitStream(guildGUIDBytes, 5, 7, 3, 0, 4, 6, 1, 2); if (hasLang) text.Language = packet.ReadByteE<Language>("Language"); packet.ParseBitStream(senderGUIDBytes, 7, 4, 0, 6, 3, 2, 5, 1); if (hasChannel) packet.ReadWoWString("Channel Name", channelLen); text.Text = packet.ReadWoWString("Text", textLen); text.Type = (ChatMessageType)packet.ReadByteE<ChatMessageTypeNew>("SlashCmd"); if (hasAchi) packet.ReadInt32<AchievementId>("Achievement Id"); if (bit1490) packet.ReadSingle("Float1490"); if (hasRealmId) packet.ReadInt32("Realm Id"); text.SenderGUID = packet.WriteGuid("SenderGUID", senderGUIDBytes); text.ReceiverGUID = packet.WriteGuid("ReceiverGUID", receiverGUIDBytes); packet.WriteGuid("GuildGUID", guildGUIDBytes); packet.WriteGuid("GroupGUID", groupGUIDBytes); uint entry = 0; if (text.SenderGUID.GetObjectType() == ObjectType.Unit) entry = text.SenderGUID.GetEntry(); else if (text.ReceiverGUID.GetObjectType() == ObjectType.Unit) entry = text.ReceiverGUID.GetEntry(); if (entry != 0) Storage.CreatureTexts.Add(entry, text, packet.TimeSpan); }
public static void HandleServerChatMessage(Packet packet) { var text = new CreatureText { Type = (ChatMessageType) packet.ReadByte("Chat type"), Language = packet.ReadByteE<Language>("Language"), SenderGUID = packet.ReadPackedGuid128("SenderGUID") }; packet.ReadPackedGuid128("SenderGuildGUID"); packet.ReadPackedGuid128("WowAccountGUID"); text.ReceiverGUID = packet.ReadPackedGuid128("TargetGUID"); packet.ReadUInt32("TargetVirtualAddress"); packet.ReadUInt32("SenderVirtualAddress"); packet.ReadPackedGuid128("PartyGUID"); packet.ReadUInt32("AchievementID"); packet.ReadSingle("DisplayTime"); var bits24 = packet.ReadBits(11); var bits1121 = packet.ReadBits(11); var prefixLen = packet.ReadBits(5); var channelLen = packet.ReadBits(7); var textLen = packet.ReadBits(12); packet.ReadBits("ChatFlags", 10); packet.ReadBit("HideChatLog"); packet.ReadBit("FakeSenderName"); text.SenderName = packet.ReadWoWString("Sender Name", bits24); text.ReceiverName = packet.ReadWoWString("Receiver Name", bits1121); packet.ReadWoWString("Addon Message Prefix", prefixLen); packet.ReadWoWString("Channel Name", channelLen); text.Text = packet.ReadWoWString("Text", textLen); uint entry = 0; if (text.SenderGUID.GetObjectType() == ObjectType.Unit) entry = text.SenderGUID.GetEntry(); else if (text.ReceiverGUID.GetObjectType() == ObjectType.Unit) entry = text.ReceiverGUID.GetEntry(); if (entry != 0) Storage.CreatureTexts.Add(entry, text, packet.TimeSpan); }
public static void HandleServerChatMessage(Packet packet) { var text = new CreatureText(); var senderGUIDBytes = new byte[8]; var guildGUIDBytes = new byte[8]; var receiverGUIDBytes = new byte[8]; var groupGUIDBytes = new byte[8]; var hasSender = !packet.ReadBit(); packet.ReadBit("Show only in bubble"); // 0 Show in chat log, 1 for showing only in bubble var senderNameLen = 0u; if (hasSender) senderNameLen = packet.ReadBits(11); packet.ReadBit(); // fake bit var hasChannel = !packet.ReadBit(); var bit1499 = packet.ReadBit(); var bit1494 = !packet.ReadBit(); var bit1490 = !packet.ReadBit(); var hasRealmId1 = !packet.ReadBit(); packet.StartBitStream(groupGUIDBytes, 0, 1, 5, 4, 3, 2, 6, 7); var bits1490 = 0u; if (bit1490) bits1490 = packet.ReadBits(9); packet.ReadBit(); // fake bit packet.StartBitStream(receiverGUIDBytes, 7, 6, 1, 4, 0, 2, 3, 5); packet.ReadBit(); // fake bit var hasLang = !packet.ReadBit(); var hasPrefix = !packet.ReadBit(); packet.StartBitStream(senderGUIDBytes, 0, 3, 7, 2, 1, 5, 4, 6); var hasAchi = !packet.ReadBit(); var hasText = !packet.ReadBit(); var channelLen = 0u; if (hasChannel) channelLen = packet.ReadBits(7); var textLen = 0u; if (hasText) textLen = packet.ReadBits(12); var hasReceiver = !packet.ReadBit(); var prefixLen = 0u; if (hasPrefix) prefixLen = packet.ReadBits(5); var hasRealmId2 = !packet.ReadBit(); var receiverLen = 0u; if (hasReceiver) receiverLen = packet.ReadBits(11); packet.ReadBit(); // fake bit ?????? packet.StartBitStream(guildGUIDBytes, 2, 5, 7, 4, 0, 1, 3, 6); packet.ParseBitStream(guildGUIDBytes, 4, 5, 7, 3, 2, 6, 0, 1); if (hasChannel) packet.ReadWoWString("Channel Name", channelLen); if (hasPrefix) packet.ReadWoWString("Addon Message Prefix", prefixLen); if (bit1494) packet.ReadSingle("Float1494"); packet.ParseBitStream(senderGUIDBytes, 4, 7, 1, 5, 0, 6, 2, 3); text.Type = (ChatMessageType)packet.ReadEnum<ChatMessageType540>("Chat type", TypeCode.Byte); if (hasAchi) packet.ReadInt32("Achievement"); packet.ParseBitStream(groupGUIDBytes, 1, 3, 4, 6, 0, 2, 5, 7); packet.ParseBitStream(receiverGUIDBytes, 2, 5, 3, 6, 7, 4, 1, 0); if (hasLang) text.Language = packet.ReadEnum<Language>("Language", TypeCode.Byte); if (hasRealmId2) packet.ReadInt32("Realm Id 2"); if (hasText) text.Text = packet.ReadWoWString("Text", textLen); if (hasReceiver) text.ReceiverName = packet.ReadWoWString("Receiver Name", receiverLen); if (hasSender) text.SenderName = packet.ReadWoWString("Sender Name", senderNameLen); if (hasRealmId1) packet.ReadInt32("Realm Id"); text.SenderGUID = packet.WriteGuid("SenderGUID", senderGUIDBytes); text.ReceiverGUID = packet.WriteGuid("ReceiverGUID", receiverGUIDBytes); packet.WriteGuid("GuildGUID", guildGUIDBytes); packet.WriteGuid("GroupGUID", groupGUIDBytes); uint entry = 0; if (text.SenderGUID.GetObjectType() == ObjectType.Unit) entry = text.SenderGUID.GetEntry(); else if (text.ReceiverGUID.GetObjectType() == ObjectType.Unit) entry = text.ReceiverGUID.GetEntry(); if (entry != 0) Storage.CreatureTexts.Add(entry, text, packet.TimeSpan); }
public static void HandleServerChatMessage(Packet packet) { var text = new CreatureText(); text.Type = packet.ReadEnum<ChatMessageType>("Type", TypeCode.Byte); text.Language = packet.ReadEnum<Language>("Language", TypeCode.Int32); var guid = packet.ReadGuid("GUID"); uint entry = 0; if (guid.GetObjectType() == ObjectType.Unit) entry = guid.GetEntry(); packet.ReadInt32("Constant time"); switch (text.Type) { case ChatMessageType.Say: case ChatMessageType.Yell: case ChatMessageType.Party: case ChatMessageType.PartyLeader: case ChatMessageType.Raid: case ChatMessageType.RaidLeader: case ChatMessageType.RaidWarning: case ChatMessageType.Guild: case ChatMessageType.Officer: case ChatMessageType.Emote: case ChatMessageType.TextEmote: case ChatMessageType.Whisper: case ChatMessageType.WhisperInform: case ChatMessageType.System: case ChatMessageType.Channel: case ChatMessageType.Battleground: case ChatMessageType.BattlegroundLeader: case ChatMessageType.Achievement: case ChatMessageType.GuildAchievement: case ChatMessageType.Restricted: case ChatMessageType.Dnd: { if (text.Type == ChatMessageType.Channel) packet.ReadCString("Channel Name"); packet.ReadGuid("Sender GUID"); break; } case ChatMessageType.BattlegroundNeutral: case ChatMessageType.BattlegroundAlliance: case ChatMessageType.BattlegroundHorde: { var target = packet.ReadGuid("Sender GUID"); switch (target.GetHighType()) { case HighGuidType.Unit: case HighGuidType.Vehicle: case HighGuidType.GameObject: case HighGuidType.Transport: case HighGuidType.Pet: packet.ReadInt32("Sender Name Length"); packet.ReadCString("Sender Name"); break; } break; } case ChatMessageType.MonsterSay: case ChatMessageType.MonsterYell: case ChatMessageType.MonsterParty: case ChatMessageType.MonsterEmote: case ChatMessageType.MonsterWhisper: case ChatMessageType.RaidBossEmote: case ChatMessageType.RaidBossWhisper: case ChatMessageType.BattleNet: { packet.ReadInt32("Name Length"); text.Comment = packet.ReadCString("Name"); var target = packet.ReadGuid("Receiver GUID"); switch (target.GetHighType()) { case HighGuidType.Unit: case HighGuidType.Vehicle: case HighGuidType.GameObject: case HighGuidType.Transport: packet.ReadInt32("Receiver Name Length"); text.Comment += " to " + packet.ReadCString("Receiver Name"); break; } break; } } if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_1_0_13914) && text.Language == Language.Addon) packet.ReadCString("Addon Message Prefix"); packet.ReadInt32("Text Length"); text.Text = packet.ReadCString("Text"); packet.ReadEnum<ChatTag>("Chat Tag", TypeCode.Byte); if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_0_14333)) { if (text.Type == ChatMessageType.RaidBossEmote || text.Type == ChatMessageType.RaidBossWhisper) { packet.ReadSingle("Unk single"); packet.ReadByte("Unk byte"); } } if (text.Type == ChatMessageType.Achievement || text.Type == ChatMessageType.GuildAchievement) packet.ReadInt32("Achievement ID"); if (entry != 0) Storage.CreatureTexts.Add(entry, text, packet.TimeSpan); }
public static void HandleServerChatMessage(Packet packet) { var text = new CreatureText(); var GroupGUID = new byte[8]; var GuildGUID = new byte[8]; var ReceiverGUID = new byte[8]; var SenderGUID = new byte[8]; var bit1316 = !packet.ReadBit(); packet.ReadBit("bit5269"); packet.ReadBit(); // fake bit var hasSender = !packet.ReadBit(); packet.StartBitStream(GroupGUID, 6, 1, 7, 5, 4, 3, 2, 0); packet.ReadBit(); // fake bit var hasChannel = !packet.ReadBit(); packet.StartBitStream(ReceiverGUID, 1, 5, 7, 4, 2, 0, 6, 3); packet.ReadBit("bit5268"); var hasReceiver = !packet.ReadBit(); int receiverLen = 0; if (hasReceiver) receiverLen = (int)packet.ReadBits(11); packet.ReadBit(); // fake bit packet.StartBitStream(GuildGUID, 0, 6, 1, 5, 7, 3, 4, 2); var hasText = !packet.ReadBit(); var hasPrefix = !packet.ReadBit(); int senderName = 0; if (hasSender) senderName = (int)packet.ReadBits(11); int textLen = 0; if (hasText) textLen = (int)packet.ReadBits(12); var hasConstTime = !packet.ReadBit(); var hasAchi = !packet.ReadBit(); packet.ReadBit(); // fake bit packet.StartBitStream(SenderGUID, 5, 4, 1, 0, 6, 2, 7, 3); int channelLen = 0; if (hasChannel) channelLen = (int)packet.ReadBits(7); var bit2630 = !packet.ReadBit(); if (bit2630) packet.ReadEnum<ChatTag>("Chat Tag", 9); var hasLang = !packet.ReadBit(); int prefixLen = 0; if (hasPrefix) prefixLen = (int)packet.ReadBits(5); if (hasPrefix) packet.ReadWoWString("Addon Message Prefix", prefixLen); packet.ParseBitStream(GuildGUID, 3, 1, 5, 4, 6, 2, 0, 7); packet.ParseBitStream(ReceiverGUID, 7, 4, 2, 3, 1, 5, 6, 0); packet.ParseBitStream(SenderGUID, 5, 0, 7, 4, 3, 2, 1, 6); packet.ParseBitStream(GroupGUID, 3, 5, 2, 6, 4, 0, 1, 7); packet.WriteGuid("SenderGUID", SenderGUID); packet.WriteGuid("ReceiverGUID", ReceiverGUID); packet.WriteGuid("GroupGUID", GroupGUID); packet.WriteGuid("GuildGUID", GuildGUID); uint entry = 0; var guid = new Guid(BitConverter.ToUInt64(SenderGUID, 0)); if (guid.GetObjectType() == ObjectType.Unit) entry = guid.GetEntry(); if (hasAchi) packet.ReadInt32("Achievement"); if (hasReceiver) packet.ReadWoWString("Receiver Name", receiverLen); text.Type = (ChatMessageType)packet.ReadEnum<ChatMessageType530>("Chat type", TypeCode.Byte); if (hasText) text.Text = packet.ReadWoWString("Text", textLen); if (hasConstTime) packet.ReadInt32("Constant time"); if (bit1316) packet.ReadSingle("float1316"); if (hasChannel) packet.ReadWoWString("Channel Name", channelLen); if (hasSender) { if (entry != 0) text.Comment = packet.ReadWoWString("Sender Name", senderName); else packet.ReadWoWString("Sender Name", senderName); } if (hasLang) text.Language = packet.ReadEnum<Language>("Language", TypeCode.Byte); if (entry != 0) Storage.CreatureTexts.Add(entry, text, packet.TimeSpan); }
public static void HandleServerChatMessage(Packet packet) { var text = new CreatureText(); var groupGUIDBytes = new byte[8]; var guildGUIDBytes = new byte[8]; var receiverGUIDBytes = new byte[8]; var senderGUIDBytes = new byte[8]; var bit1316 = !packet.ReadBit(); packet.ReadBit("bit5269"); packet.ReadBit(); // fake bit var hasSender = !packet.ReadBit(); packet.StartBitStream(groupGUIDBytes, 6, 1, 7, 5, 4, 3, 2, 0); packet.ReadBit(); // fake bit var hasChannel = !packet.ReadBit(); packet.StartBitStream(receiverGUIDBytes, 1, 5, 7, 4, 2, 0, 6, 3); packet.ReadBit("bit5268"); var hasReceiver = !packet.ReadBit(); int receiverLen = 0; if (hasReceiver) receiverLen = (int)packet.ReadBits(11); packet.ReadBit(); // fake bit packet.StartBitStream(guildGUIDBytes, 0, 6, 1, 5, 7, 3, 4, 2); var hasText = !packet.ReadBit(); var hasPrefix = !packet.ReadBit(); int senderName = 0; if (hasSender) senderName = (int)packet.ReadBits(11); int textLen = 0; if (hasText) textLen = (int)packet.ReadBits(12); var hasConstTime = !packet.ReadBit(); var hasAchi = !packet.ReadBit(); packet.ReadBit(); // fake bit packet.StartBitStream(senderGUIDBytes, 5, 4, 1, 0, 6, 2, 7, 3); int channelLen = 0; if (hasChannel) channelLen = (int)packet.ReadBits(7); var bit2630 = !packet.ReadBit(); if (bit2630) packet.ReadBitsE<ChatTag>("Chat Tag", 9); var hasLang = !packet.ReadBit(); int prefixLen = 0; if (hasPrefix) prefixLen = (int)packet.ReadBits(5); if (hasPrefix) packet.ReadWoWString("Addon Message Prefix", prefixLen); packet.ParseBitStream(guildGUIDBytes, 3, 1, 5, 4, 6, 2, 0, 7); packet.ParseBitStream(receiverGUIDBytes, 7, 4, 2, 3, 1, 5, 6, 0); packet.ParseBitStream(senderGUIDBytes, 5, 0, 7, 4, 3, 2, 1, 6); packet.ParseBitStream(groupGUIDBytes, 3, 5, 2, 6, 4, 0, 1, 7); text.SenderGUID = packet.WriteGuid("SenderGUID", senderGUIDBytes); text.ReceiverGUID = packet.WriteGuid("ReceiverGUID", receiverGUIDBytes); packet.WriteGuid("GroupGUID", groupGUIDBytes); packet.WriteGuid("GuildGUID", guildGUIDBytes); if (hasAchi) packet.ReadInt32<AchievementId>("Achievement Id"); if (hasReceiver) text.ReceiverName = packet.ReadWoWString("Receiver Name", receiverLen); text.Type = (ChatMessageType)packet.ReadByteE<ChatMessageTypeNew>("Chat type"); if (hasText) text.Text = packet.ReadWoWString("Text", textLen); if (hasConstTime) packet.ReadInt32("Constant time"); if (bit1316) packet.ReadSingle("float1316"); if (hasChannel) packet.ReadWoWString("Channel Name", channelLen); if (hasSender) text.SenderName = packet.ReadWoWString("Sender Name", senderName); if (hasLang) text.Language = packet.ReadByteE<Language>("Language"); uint entry = 0; if (text.SenderGUID.GetObjectType() == ObjectType.Unit) entry = text.SenderGUID.GetEntry(); else if (text.ReceiverGUID.GetObjectType() == ObjectType.Unit) entry = text.ReceiverGUID.GetEntry(); if (entry != 0) Storage.CreatureTexts.Add(entry, text, packet.TimeSpan); }
public static void HandleServerChatMessage(Packet packet) { var text = new CreatureText(); var senderGUIDBytes = new byte[8]; var guildGUIDBytes = new byte[8]; var receiverGUIDBytes = new byte[8]; var groupGUIDBytes = new byte[8]; var bit1495 = packet.ReadBit(); var hasText = !packet.ReadBit(); var hasAchi = !packet.ReadBit(); var hasSender = !packet.ReadBit(); packet.ReadBit(); // fake bit packet.StartBitStream(senderGUIDBytes, 2, 4, 0, 6, 1, 3, 5, 7); packet.ReadBit(); // fake bit packet.StartBitStream(groupGUIDBytes, 6, 0, 4, 1, 2, 3, 7, 5); var hasPrefix = !packet.ReadBit(); var bit1494 = packet.ReadBit(); var hasRealmId = !packet.ReadBit(); var bit1490 = !packet.ReadBit(); int senderName = 0; if (hasSender) senderName = (int)packet.ReadBits(11); packet.ReadBit(); // fake bit packet.StartBitStream(receiverGUIDBytes, 4, 0, 6, 7, 5, 1, 3, 2); int prefixLen = 0; if (hasPrefix) prefixLen = (int)packet.ReadBits(5); var hasReceiver = !packet.ReadBit(); var bit148C = !packet.ReadBit(); int textLen = 0; if (hasText) textLen = (int)packet.ReadBits(12); var hasLang = !packet.ReadBit(); int countBits148C = 0; if (bit148C) countBits148C = (int)packet.ReadBits(9); packet.ReadBit(); // fake bit int receiverLen = 0; if (hasReceiver) receiverLen = (int)packet.ReadBits(11); packet.StartBitStream(guildGUIDBytes, 0, 2, 1, 4, 6, 7, 5, 3); var hasChannel = !packet.ReadBit(); if (hasChannel) { var channelLen = (int)packet.ReadBits(7); packet.ReadWoWString("Channel Name", channelLen); } if (hasSender) text.SenderName = packet.ReadWoWString("Sender Name", senderName); packet.ParseBitStream(groupGUIDBytes, 6, 7, 1, 2, 4, 3, 0, 5); packet.ParseBitStream(receiverGUIDBytes, 0, 4, 1, 3, 5, 7, 2, 6); text.Type = (ChatMessageType)packet.ReadEnum<ChatMessageType540>("Chat type", TypeCode.Byte); packet.ParseBitStream(senderGUIDBytes, 7, 6, 5, 4, 0, 2, 1, 3); if (hasPrefix) packet.ReadWoWString("Addon Message Prefix", prefixLen); if (hasRealmId) packet.ReadInt32("Realm Id"); packet.ParseBitStream(guildGUIDBytes, 1, 0, 3, 7, 6, 5, 2, 4); if (hasReceiver) text.ReceiverName = packet.ReadWoWString("Receiver Name", receiverLen); if (hasAchi) packet.ReadInt32("Achievement"); if (hasLang) text.Language = packet.ReadEnum<Language>("Language", TypeCode.Byte); if (hasText) text.Text = packet.ReadWoWString("Text", textLen); if (bit1490) packet.ReadSingle("Float1490"); text.SenderGUID = packet.WriteGuid("SenderGUID", senderGUIDBytes); text.ReceiverGUID = packet.WriteGuid("ReceiverGUID", receiverGUIDBytes); packet.WriteGuid("GuildGUID", guildGUIDBytes); packet.WriteGuid("GroupGUID", groupGUIDBytes); uint entry = 0; if (text.SenderGUID.GetObjectType() == ObjectType.Unit) entry = text.SenderGUID.GetEntry(); else if (text.ReceiverGUID.GetObjectType() == ObjectType.Unit) entry = text.ReceiverGUID.GetEntry(); if (entry != 0) Storage.CreatureTexts.Add(entry, text, packet.TimeSpan); }
public static void HandleMessageChat(Packet packet) { var text = new CreatureText(); uint entry = 0; //text.Language = packet.ReadEnum<Language>("Language", TypeCode.Int32); var hasSenderName = !packet.ReadBit("!hasSenderName"); packet.ReadBit("Show only in bubble"); // 0 Show in chat log, 1 for showing only in bubble var SenderLen = 0u; if (hasSenderName) SenderLen = packet.ReadBits("SenderLen", 11); packet.ReadBit("!unk48*4"); // unk52*4 = 0; var hasChannelName = !packet.ReadBit("!hasChannelName"); packet.ReadBit("unk5273*4"); var has1494 = !packet.ReadBit("!unk1494h"); // dword ptr [esi+1494h] = ("has unk1494h") ? 0 : ds:dword_D26EA8 var chatTag = !packet.ReadBit("!chatTag"); // 5264*2 var hasRealmID1 = !packet.ReadBit("!hasRealmID1"); // 56 var guid4 = packet.StartBitStream(0, 1, 5, 4, 3, 2, 6, 7); if (chatTag) packet.ReadBits("chatTag", 9); // 5264*2 packet.ReadBit("!unk40*4"); // unk44*4 = 0 var guid3 = packet.StartBitStream(7, 6, 1, 4, 0, 2, 3, 5); packet.ReadBit("!unk24*4"); // unk28*4 = 0 var hasLanguage = !packet.ReadBit("!hasLanguage"); // 17 var hasPrefix = !packet.ReadBit("!hasPrefix"); var guid = packet.StartBitStream(0, 3, 7, 2, 1, 5, 4, 6); var hasAchievementID = !packet.ReadBit("!hasAchievementID"); // 5260*4 var hasMessage = !packet.ReadBit("!hasMessage"); // 2259 var ChannelLen = 0u; if (hasChannelName) ChannelLen = packet.ReadBits("ChannelLen", 7); // 2134 var MessageLen = 0u; if (hasMessage) MessageLen = packet.ReadBits("MessageLen", 12); var hasReceiverName = !packet.ReadBit("!hasReceiverName"); // 1089 var PrefixLen = 0u; if (hasPrefix) PrefixLen = packet.ReadBits("PrefixLen", 5); // 2114*4 var hasRealmID2 = !packet.ReadBit("!hasRealmID2"); // 60 var ReceiverLen = 0u; if (hasReceiverName) ReceiverLen = packet.ReadBits("ReceiverLen", 11); packet.ReadBit("!unk32*4"); // unk36 = 0 var guid2 = packet.StartBitStream(2, 5, 7, 4, 0, 1, 3, 6); packet.ParseBitStream(guid2, 4, 5, 7, 3, 2, 6, 0, 1); if (hasChannelName) packet.ReadWoWString("ChannelName", ChannelLen); if (hasPrefix) packet.ReadWoWString("Prefix", PrefixLen); if (has1494) packet.ReadSingle("unk1494"); packet.ParseBitStream(guid, 4, 7, 1, 5, 0, 6, 2, 3); var unitGuid = new WowGuid64(BitConverter.ToUInt64(guid, 0)); if (unitGuid.GetObjectType() == ObjectType.Unit) entry = unitGuid.GetEntry(); text.Type = (ChatMessageType)packet.ReadByteE<ChatMessageType548>("Type"); if (hasAchievementID) packet.ReadUInt32("AchievementID"); packet.ParseBitStream(guid4, 1, 3, 4, 6, 0, 2, 5, 7); packet.ParseBitStream(guid3, 2, 5, 3, 6, 7, 4, 1, 0); if (hasLanguage) packet.ReadByte("Language"); if (hasRealmID2) packet.ReadInt32("RealmID2"); // 60 if (hasMessage) text.Text = packet.ReadWoWString("Message", MessageLen); if (hasReceiverName) text.ReceiverName = packet.ReadWoWString("Receiver Name", ReceiverLen); if (hasSenderName) text.SenderName = packet.ReadWoWString("Sender Name", SenderLen); if (hasRealmID1) packet.ReadInt32("RealmID1"); // 56 text.SenderGUID = packet.WriteGuid("SenderGUID", guid); text.ReceiverGUID = packet.WriteGuid("ReceiverGUID", guid3); packet.WriteGuid("GuildGUID", guid2); packet.WriteGuid("GroupGUID", guid4); if (text.SenderGUID.GetObjectType() == ObjectType.Unit) entry = text.SenderGUID.GetEntry(); else if (text.ReceiverGUID.GetObjectType() == ObjectType.Unit) entry = text.ReceiverGUID.GetEntry(); if (entry != 0) Storage.CreatureTexts.Add(entry, text, packet.TimeSpan); }
public static void HandleServerChatMessage(Packet packet) { var text = new CreatureText(); var SenderGUID = new byte[8]; var GuildGUID = new byte[8]; var ReceiverGUID = new byte[8]; var GroupGUID = new byte[8]; var hasLang = !packet.ReadBit(); var hasReceiver = !packet.ReadBit(); packet.ReadBit(); // fake bit packet.StartBitStream(GroupGUID, 3, 7, 2, 6, 0, 4, 5, 1); var hasAchi = !packet.ReadBit(); var bit1495 = packet.ReadBit(); var hasPrefix = !packet.ReadBit(); packet.ReadBit(); // fake bit var bit43D = !packet.ReadBit(); packet.StartBitStream(GuildGUID, 1, 6, 0, 5, 2, 4, 7, 3); packet.ReadBit(); // fake bit packet.StartBitStream(ReceiverGUID, 6, 1, 3, 5, 4, 2, 7, 0); var receiverLen = 0u; if (hasReceiver) receiverLen = packet.ReadBits(11); var hasChannel = !packet.ReadBit(); var bit1494 = packet.ReadBit(); var bit1490 = !packet.ReadBit(); var hasRealmId = !packet.ReadBit(); var bits43D = 0u; if (bit43D) bits43D = packet.ReadBits(11); var channelLen = 0u; if (hasChannel) channelLen = packet.ReadBits(7); var bit8CF = !packet.ReadBit(); var textLen = 0u; if (bit8CF) textLen = packet.ReadBits(12); packet.ReadBit(); // fake bit packet.StartBitStream(SenderGUID, 4, 1, 3, 6, 2, 5, 0, 7); var bit148C = !packet.ReadBit(); var bits148C = 0u; if (bit148C) bits148C = packet.ReadBits(9); var prefixLen = 0u; if (hasPrefix) { prefixLen = packet.ReadBits(5); packet.ReadWoWString("Addon Message Prefix", prefixLen); } packet.ParseBitStream(GroupGUID, 4, 2, 7, 3, 6, 1, 5, 0); if (hasReceiver) packet.ReadWoWString("Receiver Name", receiverLen); packet.ParseBitStream(ReceiverGUID, 7, 4, 1, 3, 0, 6, 5, 2); packet.ParseBitStream(GuildGUID, 5, 7, 3, 0, 4, 6, 1, 2); if (hasLang) text.Language = packet.ReadEnum<Language>("Language", TypeCode.Byte); packet.ParseBitStream(SenderGUID, 7, 4, 0, 6, 3, 2, 5, 1); if (hasChannel) packet.ReadWoWString("Channel Name", channelLen); text.Text = packet.ReadWoWString("Text", textLen); text.Type = (ChatMessageType)packet.ReadEnum<ChatMessageType540>("Chat type", TypeCode.Byte); if (hasAchi) packet.ReadInt32("Achievement"); if (bit1490) packet.ReadSingle("Float1490"); if (hasRealmId) packet.ReadInt32("Realm Id"); packet.WriteGuid("SenderGUID", SenderGUID); packet.WriteGuid("ReceiverGUID", ReceiverGUID); packet.WriteGuid("GuildGUID", GuildGUID); packet.WriteGuid("GroupGUID", GroupGUID); uint entry = 0; var guid = new Guid(BitConverter.ToUInt64(SenderGUID, 0)); if (guid.GetObjectType() == ObjectType.Unit) entry = guid.GetEntry(); if (entry != 0) Storage.CreatureTexts.Add(entry, text, packet.TimeSpan); }