public static void HandleDBQueryBulk(ref PacketReader packet, ref WorldClass session) { var type = (DBTypes)packet.ReadUInt32(); var unknown = packet.ReadInt32(); var id = packet.ReadInt32(); switch (type) { case DBTypes.BroadcastText: { var broadCastText = GossipMgr.GetBroadCastText<Creature>(id); PacketWriter dbReply = new PacketWriter(JAMCMessage.DBReply); BitPack BitPack = new BitPack(dbReply); var textLength = broadCastText.Text.Length; var alternativeTextLength = broadCastText.AlternativeText.Length; var size = 48; if (textLength == 0 || alternativeTextLength == 0) size += 1; size += textLength + alternativeTextLength; dbReply.WriteUInt32((uint)size); dbReply.WriteInt32(broadCastText.Id); dbReply.WriteInt32(broadCastText.Language); dbReply.WriteUInt16((ushort)broadCastText.Text.Length); dbReply.WriteString(broadCastText.Text); dbReply.WriteUInt16((ushort)broadCastText.AlternativeText.Length); dbReply.WriteString(broadCastText.AlternativeText); broadCastText.Emotes.ForEach(emote => dbReply.WriteInt32(emote)); dbReply.WriteUInt32(1); dbReply.WriteUInt32(0); // UnixTime, last change server side dbReply.WriteUInt32((uint)DBTypes.BroadcastText); dbReply.WriteInt32(broadCastText.Id); session.Send(ref dbReply); break; } } }
public static void HandleChatMessageYell(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); int language = packet.ReadInt32(); uint messageLength = BitUnpack.GetBits<uint>(9); string chatMessage = packet.ReadString(messageLength); SendMessageByType(ref session, MessageType.ChatMessageYell, language, chatMessage); }
public static void HandleChatMessageSay(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); int language = packet.ReadInt32(); uint messageLength = BitUnpack.GetBits<uint>(9); string chatMessage = packet.ReadString(messageLength); if (ChatCommandParser.CheckForCommand(chatMessage)) ChatCommandParser.ExecuteChatHandler(chatMessage, ref session); else SendMessageByType(ref session, MessageType.ChatMessageSay, language, chatMessage); }
public static void HandleCreatureStats(ref PacketReader packet, ref WorldClass session) { int id = packet.ReadInt32(); ulong guid = packet.ReadUInt64(); Creature creature = DataMgr.FindCreature(id); if (creature != null) { CreatureStats stats = creature.Stats; PacketWriter creatureStats = new PacketWriter(LegacyMessage.CreatureStats); creatureStats.WriteInt32(stats.Id); creatureStats.WriteCString(stats.Name); for (int i = 0; i < 7; i++) creatureStats.WriteCString(""); creatureStats.WriteCString(stats.SubName); creatureStats.WriteCString(""); creatureStats.WriteCString(stats.IconName); foreach (var v in stats.Flag) creatureStats.WriteInt32(v); creatureStats.WriteInt32(stats.Type); creatureStats.WriteInt32(stats.Family); creatureStats.WriteInt32(stats.Rank); foreach (var v in stats.QuestKillNpcId) creatureStats.WriteInt32(v); foreach (var v in stats.DisplayInfoId) creatureStats.WriteInt32(v); creatureStats.WriteFloat(stats.HealthModifier); creatureStats.WriteFloat(stats.PowerModifier); creatureStats.WriteUInt8(stats.RacialLeader); foreach (var v in stats.QuestItemId) creatureStats.WriteInt32(v); creatureStats.WriteInt32(stats.MovementInfoId); creatureStats.WriteInt32(stats.ExpansionRequired); session.Send(ref creatureStats); } else Log.Message(LogType.DEBUG, "Creature (Id: {0}) not found.", id); }
public static void HandleChatMessageYell(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); var language = packet.ReadInt32(); var messageLength = packet.ReadByte(); var message = packet.ReadString(messageLength); ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageYell, message, true, true); chatMessage.Language = (byte)language; SendMessage(ref session, chatMessage); }
public static void HandleChatMessageWhisper(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); int language = packet.ReadInt32(); uint messageLength = BitUnpack.GetBits<uint>(9); uint nameLength = BitUnpack.GetNameLength<uint>(9); string chatMessage = packet.ReadString(messageLength); string receiverName = packet.ReadString(nameLength); WorldClass rSession = WorldMgr.GetSession(receiverName); SendMessageByType(ref rSession, MessageType.ChatMessageWhisper, language, chatMessage); SendMessageByType(ref session, MessageType.ChatMessageWhisperInform, language, chatMessage); }
public static void HandleChatMessageSay(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); var language = packet.ReadInt32(); var messageLength = packet.ReadByte(); var message = packet.ReadString(messageLength); ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageSay, message, true, true); chatMessage.Language = (byte)language; if (ChatCommandParser.CheckForCommand(message)) ChatCommandParser.ExecuteChatHandler(message, session); else SendMessage(ref session, chatMessage); }
public static void HandleChatMessageSay(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); int language = packet.ReadInt32(); uint messageLength = BitUnpack.GetBits<uint>(9); string chatMessage = packet.ReadString(messageLength); PacketWriter messageChat = new PacketWriter(LegacyMessage.MessageChat); ulong guid = WorldMgr.Session.Character.Guid; messageChat.WriteUInt8(1); messageChat.WriteInt32(language); messageChat.WriteUInt64(guid); messageChat.WriteUInt32(0); messageChat.WriteUInt64(guid); messageChat.WriteUInt32(messageLength + 1); messageChat.WriteCString(chatMessage); messageChat.WriteUInt16(0); session.Send(messageChat); }
public static void HandleAuthResponse(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); packet.Skip(54); int addonSize = packet.ReadInt32(); packet.Skip(addonSize); uint nameLength = BitUnpack.GetNameLength<uint>(12); string accountName = packet.ReadString(nameLength); SQLResult result = DB.Realms.Select("SELECT * FROM accounts WHERE name = ?", accountName); if (result.Count == 0) session.clientSocket.Close(); else session.Account = new Account() { Id = result.Read<int>(0, "id"), Name = result.Read<String>(0, "name"), Password = result.Read<String>(0, "password"), SessionKey = result.Read<String>(0, "sessionkey"), Expansion = result.Read<byte>(0, "expansion"), GMLevel = result.Read<byte>(0, "gmlevel"), IP = result.Read<String>(0, "ip"), Language = result.Read<String>(0, "language") }; string K = session.Account.SessionKey; byte[] kBytes = new byte[K.Length / 2]; for (int i = 0; i < K.Length; i += 2) kBytes[i / 2] = Convert.ToByte(K.Substring(i, 2), 16); session.Crypt.Initialize(kBytes); uint realmId = WorldConfig.RealmId; SQLResult realmClassResult = DB.Realms.Select("SELECT class, expansion FROM realm_classes WHERE realmId = ?", realmId); SQLResult realmRaceResult = DB.Realms.Select("SELECT race, expansion FROM realm_races WHERE realmId = ?", realmId); bool HasAccountData = true; bool IsInQueue = false; PacketWriter authResponse = new PacketWriter(JAMCMessage.AuthResponse); BitPack BitPack = new BitPack(authResponse); BitPack.Write(1); // HasAccountData if (HasAccountData) { BitPack.Write(realmClassResult.Count, 25); // Activation count for classes BitPack.Write(0); // Unknown, 5.0.4 BitPack.Write(0); // Unknown, 5.1.0 BitPack.Write(0, 22); // Activate character template windows/button //if (HasCharacterTemplate) //Write bits for char templates... BitPack.Write(realmRaceResult.Count, 25); // Activation count for races BitPack.Write(IsInQueue); // IsInQueue } if (IsInQueue) { BitPack.Write(0); // Unknown BitPack.Flush(); authResponse.WriteUInt32(0); // QueuePosition } else BitPack.Flush(); if (HasAccountData) { //if (HasCharacterTemplate) //Write data for char templates... for (int r = 0; r < realmRaceResult.Count; r++) { authResponse.WriteUInt8(realmRaceResult.Read<byte>(r, "expansion")); authResponse.WriteUInt8(realmRaceResult.Read<byte>(r, "race")); } authResponse.WriteUInt32(0); authResponse.WriteUInt32(0); authResponse.WriteUInt8(0); authResponse.WriteUInt8(session.Account.Expansion); authResponse.WriteUInt8(session.Account.Expansion); for (int c = 0; c < realmClassResult.Count; c++) { authResponse.WriteUInt8(realmClassResult.Read<byte>(c, "class")); authResponse.WriteUInt8(realmClassResult.Read<byte>(c, "expansion")); } authResponse.WriteUInt32(0); } authResponse.WriteUInt8((byte)AuthCodes.AUTH_OK); session.Send(ref authResponse); MiscHandler.HandleUpdateClientCacheVersion(ref session); TutorialHandler.HandleTutorialFlags(ref session); }
public static void HandleGameObjectStats(ref PacketReader packet, ref WorldClass session) { int id = packet.ReadInt32(); ulong guid = packet.ReadUInt64(); GameObject gObject = DataMgr.FindGameObject(id); if (gObject != null) { GameObjectStats stats = gObject.Stats; PacketWriter gameObjectStats = new PacketWriter(LegacyMessage.GameObjectStats); gameObjectStats.WriteInt32(stats.Id); gameObjectStats.WriteInt32(stats.Type); gameObjectStats.WriteInt32(stats.DisplayInfoId); gameObjectStats.WriteCString(stats.Name); for (int i = 0; i < 3; i++) gameObjectStats.WriteCString(""); gameObjectStats.WriteCString(stats.IconName); gameObjectStats.WriteCString(stats.CastBarCaption); gameObjectStats.WriteCString(""); foreach (var v in stats.Data) gameObjectStats.WriteInt32(v); gameObjectStats.WriteFloat(stats.Size); foreach (var v in stats.QuestItemId) gameObjectStats.WriteInt32(v); gameObjectStats.WriteInt32(stats.ExpansionRequired); session.Send(ref gameObjectStats); } else Log.Message(LogType.DEBUG, "Gameobject (Id: {0}) not found.", id); }
public static void HandleCliQueryNPCText(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); byte[] guidMask = { 4, 7, 3, 6, 0, 1, 5, 2 }; byte[] guidBytes = { 5, 6, 7, 1, 2, 3, 0, 4 }; var gossipTextId = packet.ReadInt32(); var guid = BitUnpack.GetPackedValue(guidMask, guidBytes); var gossipData = GossipMgr.GetGossip<Creature>(ObjectGuid.GetGuid(guid)); if (gossipData != null) { PacketWriter queryNPCTextResponse = new PacketWriter(ServerMessage.QueryNPCTextResponse); BitPack BitPack = new BitPack(queryNPCTextResponse); queryNPCTextResponse.WriteInt32(gossipTextId); queryNPCTextResponse.WriteInt32(0); queryNPCTextResponse.WriteFloat(1); for (int i = 0; i < 7; i++) queryNPCTextResponse.WriteUInt32(0); queryNPCTextResponse.WriteInt32(gossipData.BroadCastText.Id); for (int i = 0; i < 7; i++) queryNPCTextResponse.WriteUInt32(0); BitPack.Write(1); BitPack.Flush(); var size = (uint)queryNPCTextResponse.BaseStream.Length - 13; queryNPCTextResponse.WriteUInt32Pos(size, 8); session.Send(ref queryNPCTextResponse); } }
public static void HandleQueryGameObject(ref PacketReader packet, ref WorldClass session) { byte[] guidMask = { 4, 6, 7, 5, 3, 2, 1, 0 }; byte[] guidBytes = { 0, 2, 3, 5, 6, 1, 4, 7 }; BitUnpack BitUnpack = new BitUnpack(packet); var hasData = false; var id = packet.ReadInt32(); var guid = BitUnpack.GetPackedValue(guidMask, guidBytes); PacketWriter queryGameObjectResponse = new PacketWriter(ServerMessage.QueryGameObjectResponse); BitPack BitPack = new BitPack(queryGameObjectResponse); GameObject gObject = DataMgr.FindGameObject(id); if (hasData = (gObject != null)) { GameObjectStats stats = gObject.Stats; BitPack.Write(hasData); BitPack.Flush(); queryGameObjectResponse.WriteInt32(stats.Id); queryGameObjectResponse.WriteInt32(0); queryGameObjectResponse.WriteInt32(stats.Type); queryGameObjectResponse.WriteInt32(stats.DisplayInfoId); queryGameObjectResponse.WriteCString(stats.Name); for (int i = 0; i < 3; i++) queryGameObjectResponse.WriteCString(""); queryGameObjectResponse.WriteCString(stats.IconName); queryGameObjectResponse.WriteCString(stats.CastBarCaption); queryGameObjectResponse.WriteCString(""); foreach (var v in stats.Data) queryGameObjectResponse.WriteInt32(v); queryGameObjectResponse.WriteFloat(stats.Size); queryGameObjectResponse.WriteUInt8((byte)stats.QuestItemId.Count); foreach (var v in stats.QuestItemId) queryGameObjectResponse.WriteInt32(v); queryGameObjectResponse.WriteInt32(stats.ExpansionRequired); var size = (uint)queryGameObjectResponse.BaseStream.Length - 13; queryGameObjectResponse.WriteUInt32Pos(size, 9); session.Send(ref queryGameObjectResponse); } else { BitPack.Write(hasData); Log.Message(LogType.DEBUG, "Gameobject (Id: {0}) not found.", id); } }
public static void HandleQueryCreature(ref PacketReader packet, ref WorldClass session) { var hasData = false; var id = packet.ReadInt32(); PacketWriter queryCreatureResponse = new PacketWriter(ServerMessage.QueryCreatureResponse); BitPack BitPack = new BitPack(queryCreatureResponse); queryCreatureResponse.WriteInt32(id); Creature creature = DataMgr.FindCreature(id); if (hasData = (creature != null)) { CreatureStats stats = creature.Stats; BitPack.Write(hasData); BitPack.Write(stats.QuestItemId.Count, 22); BitPack.Write(0, 11); BitPack.Write(stats.RacialLeader); BitPack.Write(stats.IconName.Length + 1, 6); for (int i = 0; i < 8; i++) { if (i == 1) BitPack.Write(stats.Name.Length + 1, 11); else BitPack.Write(0, 11); } BitPack.Write(stats.SubName.Length != 0 ? stats.SubName.Length + 1 : 0, 11); BitPack.Flush(); queryCreatureResponse.WriteInt32(stats.Rank); queryCreatureResponse.WriteInt32(stats.DisplayInfoId[2]); queryCreatureResponse.WriteInt32(stats.Type); foreach (var v in stats.Flag) queryCreatureResponse.WriteInt32(v); queryCreatureResponse.WriteFloat(stats.PowerModifier); queryCreatureResponse.WriteInt32(stats.DisplayInfoId[0]); queryCreatureResponse.WriteFloat(1); queryCreatureResponse.WriteCString(stats.Name); if (stats.IconName != "") queryCreatureResponse.WriteCString(stats.IconName); queryCreatureResponse.WriteInt32(stats.Family); queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[0]); if (stats.SubName != "") queryCreatureResponse.WriteCString(stats.SubName); queryCreatureResponse.WriteInt32(stats.MovementInfoId); queryCreatureResponse.WriteInt32(stats.DisplayInfoId[1]); queryCreatureResponse.WriteFloat(1); queryCreatureResponse.WriteFloat(stats.HealthModifier); queryCreatureResponse.WriteInt32(0); foreach (var v in stats.QuestItemId) queryCreatureResponse.WriteInt32(v); queryCreatureResponse.WriteInt32(stats.DisplayInfoId[3]); queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[1]); queryCreatureResponse.WriteInt32(stats.ExpansionRequired); session.Send(ref queryCreatureResponse); } else { BitPack.Write(hasData); Log.Message(LogType.DEBUG, "Creature (Id: {0}) not found.", id); } }
public static void HandleDBQueryBulk(ref PacketReader packet, ref WorldClass session) { List<int> IdList = new List<int>(); BitUnpack BitUnpack = new BitUnpack(packet); var type = (DBTypes)packet.ReadUInt32(); var count = BitUnpack.GetBits<uint>(21); bool[][] Mask = new bool[count][]; byte[][] Bytes = new byte[count][]; for (int i = 0; i < count; i++) { Mask[i] = new bool[8]; Bytes[i] = new byte[8]; } for (int i = 0; i < count; i++) { Mask[i][7] = BitUnpack.GetBit(); Mask[i][2] = BitUnpack.GetBit(); Mask[i][3] = BitUnpack.GetBit(); Mask[i][5] = BitUnpack.GetBit(); Mask[i][4] = BitUnpack.GetBit(); Mask[i][6] = BitUnpack.GetBit(); Mask[i][0] = BitUnpack.GetBit(); Mask[i][1] = BitUnpack.GetBit(); } for (int i = 0; i < count; i++) { if (Mask[i][5]) Bytes[i][5] = (byte)(packet.ReadUInt8() ^ 1); IdList.Add(packet.ReadInt32()); if (Mask[i][7]) Bytes[i][7] = (byte)(packet.ReadByte() ^ 1); if (Mask[i][3]) Bytes[i][3] = (byte)(packet.ReadByte() ^ 1); if (Mask[i][0]) Bytes[i][0] = (byte)(packet.ReadByte() ^ 1); if (Mask[i][1]) Bytes[i][1] = (byte)(packet.ReadByte() ^ 1); if (Mask[i][6]) Bytes[i][6] = (byte)(packet.ReadByte() ^ 1); if (Mask[i][2]) Bytes[i][2] = (byte)(packet.ReadByte() ^ 1); if (Mask[i][4]) Bytes[i][4] = (byte)(packet.ReadByte() ^ 1); } switch (type) { case DBTypes.BroadcastText: { foreach (var id in IdList) HandleBroadcastText(ref session, id); break; } default: break; } }
public static void HandleNPCText(ref PacketReader packet, ref WorldClass session) { var gossipTextId = packet.ReadInt32(); var guid = packet.ReadUInt64(); var gossipData = GossipMgr.GetGossip<Creature>(ObjectGuid.GetGuid(guid)); if (gossipData != null) { PacketWriter npcText = new PacketWriter(LegacyMessage.NPCText); npcText.WriteInt32(gossipTextId); npcText.WriteFloat(1); for (int i = 0; i < 7; i++) npcText.WriteUInt32(0); npcText.WriteInt32(gossipData.BroadCastText.Id); for (int i = 0; i < 7; i++) npcText.WriteUInt32(0); session.Send(ref npcText); } }