public static void HandleLearnTalents(ref PacketReader packet, ref WorldClass session) { var pChar = session.Character; var talentSpells = new List<uint>(); BitUnpack BitUnpack = new BitUnpack(packet); uint talentCount = BitUnpack.GetBits<uint>(23); for (int i = 0; i < talentCount; i++) { var talentId = packet.Read<ushort>(); SpecializationMgr.AddTalent(pChar, pChar.ActiveSpecGroup, talentId, true); talentSpells.Add(CliDB.Talent.Single(talent => talent.Id == talentId).SpellId); } HandleUpdateTalentData(ref session); pChar.SetUpdateField<Int32>((int)PlayerFields.SpellCritPercentage + 0, SpecializationMgr.GetUnspentTalentRowCount(pChar), 0); ObjectHandler.HandleUpdateObjectValues(ref session); foreach (var talentSpell in talentSpells) SpellHandler.HandleLearnedSpells(ref session, new List<uint>(1) { talentSpell }); Log.Message(LogType.Debug, "Character (Guid: {0}) learned {1} talents.", pChar.Guid, talentCount); }
public static void HandlePlayerLogin(ref PacketReader packet, ref WorldClass session) { byte[] guidMask = { 5, 7, 6, 1, 2, 3, 4, 0 }; byte[] guidBytes = { 6, 4, 3, 5, 0, 2, 7, 1 }; BitUnpack GuidUnpacker = new BitUnpack(packet); ulong guid = GuidUnpacker.GetGuid(guidMask, guidBytes); Log.Message(LogType.DEBUG, "Character with Guid: {0}, AccountId: {1} tried to enter the world.", guid, session.Account.Id); session.Character = new Character(guid); WorldMgr.AddSession(guid, ref session); WorldMgr.WriteAccountData(AccountDataMasks.CharacterCacheMask, ref session); MiscHandler.HandleMessageOfTheDay(ref session); SpellHandler.HandleSendKnownSpells(ref session); if (session.Character.LoginCinematic) { CinematicHandler.HandleStartCinematic(ref session); } ObjectHandler.HandleUpdateObject(ref session); }
public static void HandleLearnTalents(ref PacketReader packet, ref WorldClass session) { var pChar = session.Character; var talentSpells = new List <uint>(); BitUnpack BitUnpack = new BitUnpack(packet); uint talentCount = BitUnpack.GetBits <uint>(23); for (int i = 0; i < talentCount; i++) { var talentId = packet.Read <ushort>(); SpecializationMgr.AddTalent(pChar, pChar.ActiveSpecGroup, talentId, true); talentSpells.Add(CliDB.Talent.Single(talent => talent.Id == talentId).SpellId); } HandleUpdateTalentData(ref session); pChar.SetUpdateField <Int32>((int)PlayerFields.SpellCritPercentage + 0, SpecializationMgr.GetUnspentTalentRowCount(pChar), 0); ObjectHandler.HandleUpdateObjectValues(ref session); foreach (var talentSpell in talentSpells) { SpellHandler.HandleLearnedSpells(ref session, new List <uint>(1) { talentSpell }); } Log.Message(LogType.DEBUG, "Character (Guid: {0}) learned {1} talents.", pChar.Guid, talentCount); }
public static void HandleSetSelection(ref PacketReader packet, ref WorldClass session) { byte[] guidMask = { 2, 6, 1, 7, 4, 5, 3, 0 }; byte[] guidBytes = { 0, 6, 3, 2, 1, 4, 7, 5 }; BitUnpack GuidUnpacker = new BitUnpack(packet); ulong fullGuid = GuidUnpacker.GetPackedValue(guidMask, guidBytes); ulong guid = SmartGuid.GetGuid(fullGuid); if (session.Character != null) { var sess = WorldMgr.GetSession(session.Character.Guid); if (sess != null) { sess.Character.TargetGuid = fullGuid; } if (guid == 0) { Log.Message(LogType.DEBUG, "Character (Guid: {0}) removed current selection.", session.Character.Guid); } else { Log.Message(LogType.DEBUG, "Character (Guid: {0}) selected a {1} (Guid: {2}, Id: {3}).", session.Character.Guid, SmartGuid.GetGuidType(fullGuid), guid, SmartGuid.GetId(fullGuid)); } } }
public static void HandlePlayerLogin(ref PacketReader packet, WorldClass session) { byte[] guidMask = { 1, 0, 7, 2, 5, 6, 4, 3 }; byte[] guidBytes = { 7, 6, 0, 1, 4, 3, 2, 5 }; BitUnpack GuidUnpacker = new BitUnpack(packet); var unknown = packet.Read <float>(); var guid = GuidUnpacker.GetPackedValue(guidMask, guidBytes); Log.Message(LogType.Debug, "Character with Guid: {0}, AccountId: {1} tried to enter the world.", guid, session.Account.Id); session.Character = new Character(guid); if (!WorldMgr.AddSession(guid, ref session)) { Log.Message(LogType.Error, "A Character with Guid: {0} is already logged in", guid); return; } WorldMgr.WriteAccountDataTimes(AccountDataMasks.CharacterCacheMask, ref session); MiscHandler.HandleMessageOfTheDay(ref session); TimeHandler.HandleLoginSetTimeSpeed(ref session); SpecializationHandler.HandleUpdateTalentData(ref session); SpellHandler.HandleSendKnownSpells(ref session); MiscHandler.HandleUpdateActionButtons(ref session); if (session.Character.LoginCinematic) { CinematicHandler.HandleStartCinematic(ref session); } ObjectHandler.HandleUpdateObjectCreate(ref session); }
public static void HandleChatMessageWhisper(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); var language = packet.Read <int>(); var nameLength = BitUnpack.GetBits <byte>(9); var messageLength = BitUnpack.GetBits <byte>(8); string message = packet.ReadString(messageLength); string receiverName = packet.ReadString(nameLength); WorldClass rSession = WorldMgr.GetSession(receiverName); if (rSession == null) { return; } ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageWhisperInform, message, false, true); SendMessage(ref session, chatMessage, rSession); chatMessage = new ChatMessageValues(MessageType.ChatMessageWhisper, message, false, true); SendMessage(ref rSession, chatMessage, session); }
//[Opcode(ClientMessage.LearnTalents, "16357")] public static void HandleLearnTalents(ref PacketReader packet, ref WorldClass session) { var pChar = session.Character; var talentSpells = new List<uint>(); BitUnpack BitUnpack = new BitUnpack(packet); uint talentCount = BitUnpack.GetBits<uint>(25); for (int i = 0; i < talentCount; i++) { var talentId = packet.ReadUInt16(); SpecializationMgr.AddTalent(pChar, pChar.ActiveSpecGroup, talentId, true); talentSpells.Add(DBCStorage.TalentStorage.LookupByKey(talentId).SpellId); } HandleTalentUpdate(ref session); pChar.SetUpdateField<Int32>((int)PlayerFields.SpellCritPercentage + 0, SpecializationMgr.GetUnspentTalentRowCount(pChar), 0); ObjectHandler.HandleUpdateObjectValues(ref session); // we need to send a single packet for every talent spell - stupid blizz foreach (var talentSpell in talentSpells) SpellHandler.HandleLearnedSpells(ref session, new List<uint>(1) { talentSpell }); Log.Message(LogType.DEBUG, "Character (Guid: {0}) learned {1} talents.", pChar.Guid, talentCount); }
public static void HandleSetActionButton(ref PacketReader packet, ref WorldClass session) { var pChar = session.Character; byte[] actionMask = { 5, 2, 6, 7, 1, 4, 0, 3 }; byte[] actionBytes = { 4, 3, 2, 0, 5, 7, 6, 1 }; var slotId = packet.ReadByte(); BitUnpack actionUnpacker = new BitUnpack(packet); var actionId = actionUnpacker.GetPackedValue(actionMask, actionBytes); if (actionId == 0) { var action = pChar.ActionButtons.Where(button => button.SlotId == slotId && button.SpecGroup == pChar.ActiveSpecGroup).Select(button => button).First(); ActionMgr.RemoveActionButton(pChar, action, true); Log.Message(LogType.DEBUG, "Character (Guid: {0}) removed action button {1} from slot {2}.", pChar.Guid, actionId, slotId); return; } var newAction = new ActionButton { Action = actionId, SlotId = slotId, SpecGroup = pChar.ActiveSpecGroup }; ActionMgr.AddActionButton(pChar, newAction, true); Log.Message(LogType.DEBUG, "Character (Guid: {0}) added action button {1} to slot {2}.", pChar.Guid, actionId, slotId); }
public static void HandlePlayerLogin(ref PacketReader packet, ref WorldClass session) { byte[] guidMask = { 6, 3, 0, 5, 7, 2, 1, 4 }; byte[] guidBytes = { 1, 0, 3, 2, 4, 7, 5, 6 }; BitUnpack GuidUnpacker = new BitUnpack(packet); ulong guid = GuidUnpacker.GetGuid(guidMask, guidBytes); Log.Message(LogType.DEBUG, "Character with Guid: {0}, AccountId: {1} tried to enter the world.", guid, session.Account.Id); session.Character = new Character(guid, ref session); WorldMgr.Session = session; SpellMgr.LoadSpells(); WorldMgr.WriteAccountData(AccountDataMasks.CharacterCacheMask, ref session); PacketWriter motd = new PacketWriter(LegacyMessage.MessageOfTheDay); motd.WriteUInt32(3); motd.WriteCString("Arctium MoP test"); motd.WriteCString("Welcome to our MoP server test."); motd.WriteCString("Your development team =)"); session.Send(motd); SpellHandler.SendSendKnownSpells(); UpdateHandler.HandleUpdateObject(ref packet, ref session); }
public static void HandleCreateCharacter(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); packet.Skip(1); var facialHair = packet.ReadByte(); var skin = packet.ReadByte(); var race = packet.ReadByte(); var hairStyle = packet.ReadByte(); var pClass = packet.ReadByte(); var face = packet.ReadByte(); var gender = packet.ReadByte(); var hairColor = packet.ReadByte(); var nameLength = BitUnpack.GetBits<uint>(6); var hasUnknown = BitUnpack.GetBit(); var name = Character.NormalizeName(packet.ReadString(nameLength)); if (hasUnknown) packet.ReadUInt32(); var result = DB.Characters.Select("SELECT * from characters WHERE name = ?", name); var createChar = new PacketWriter(ServerMessage.CreateChar); if (result.Count != 0) { // Name already in use createChar.WriteUInt8(0x32); session.Send(ref createChar); return; } result = DB.Characters.Select("SELECT map, zone, posX, posY, posZ, posO FROM character_creation_data WHERE race = ? AND class = ?", race, pClass); if (result.Count == 0) { createChar.WriteUInt8(0x31); session.Send(ref createChar); return; } var map = result.Read<uint>(0, "map"); var zone = result.Read<uint>(0, "zone"); var posX = result.Read<float>(0, "posX"); var posY = result.Read<float>(0, "posY"); var posZ = result.Read<float>(0, "posZ"); var posO = result.Read<float>(0, "posO"); // Allow declined names for now var characterFlags = CharacterFlag.Decline; DB.Characters.Execute("INSERT INTO characters (name, accountid, realmId, race, class, gender, skin, zone, map, x, y, z, o, face, hairstyle, haircolor, facialhair, characterFlags) VALUES (" + "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", name, session.Account.Id, WorldConfig.RealmId, race, pClass, gender, skin, zone, map, posX, posY, posZ, posO, face, hairStyle, hairColor, facialHair, characterFlags); // Success createChar.WriteUInt8(0x2F); session.Send(ref createChar); }
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 HandleLoadingScreenNotify(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); uint mapId = packet.Read<uint>(); bool loadingScreenState = BitUnpack.GetBit(); Log.Message(LogType.Debug, "Loading screen for map '{0}' is {1}.", mapId, loadingScreenState ? "enabled" : "disabled"); }
public static void HandleLoadingScreenNotify(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); uint mapId = packet.Read <uint>(); bool loadingScreenState = BitUnpack.GetBit(); Log.Message(LogType.DEBUG, "Loading screen for map '{0}' is {1}.", mapId, loadingScreenState ? "enabled" : "disabled"); }
public static void HandleObjectUpdateFailed(ref PacketReader packet, ref WorldClass session) { byte[] guidMask = { 6, 1, 7, 5, 0, 4, 2, 3 }; byte[] guidBytes = { 2, 3, 7, 4, 5, 1, 0, 6 }; BitUnpack GuidUnpacker = new BitUnpack(packet); ulong guid = GuidUnpacker.GetGuid(guidMask, guidBytes); Log.Message(LogType.DEBUG, "ObjectUpdate failed for object with Guid {0}", guid); }
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 HandleObjectUpdateFailed(ref PacketReader packet, WorldClass session) { byte[] guidMask = { 7, 0, 2, 3, 1, 4, 6, 5 }; byte[] guidBytes = { 1, 2, 5, 0, 3, 4, 6, 7 }; BitUnpack GuidUnpacker = new BitUnpack(packet); ulong guid = GuidUnpacker.GetPackedValue(guidMask, guidBytes); Log.Message(LogType.Debug, "ObjectUpdate failed for object with Guid {0}", guid); }
public static void HandleCreateCharacter(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); var hairStyle = packet.ReadByte(); var gender = packet.ReadByte(); var race = packet.ReadByte(); var hairColor = packet.ReadByte(); var pClass = packet.ReadByte(); var facialHair = packet.ReadByte(); packet.ReadByte(); // Always 0 var skin = packet.ReadByte(); var face = packet.ReadByte(); var nameLength = BitUnpack.GetBits <uint>(7); var name = Character.NormalizeName(packet.ReadString(nameLength)); var result = DB.Characters.Select("SELECT * from characters WHERE name = ?", name); var createChar = new PacketWriter(ServerMessage.CreateChar); if (result.Count != 0) { // Name already in use createChar.WriteUInt8(0x32); session.Send(ref createChar); return; } result = DB.Characters.Select("SELECT map, zone, posX, posY, posZ, posO FROM character_creation_data WHERE race = ? AND class = ?", race, pClass); if (result.Count == 0) { createChar.WriteUInt8(0x31); session.Send(ref createChar); return; } var map = result.Read <uint>(0, "map"); var zone = result.Read <uint>(0, "zone"); var posX = result.Read <float>(0, "posX"); var posY = result.Read <float>(0, "posY"); var posZ = result.Read <float>(0, "posZ"); var posO = result.Read <float>(0, "posO"); // Allow declined names for now var characterFlags = CharacterFlag.Decline; DB.Characters.Execute("INSERT INTO characters (name, accountid, realmId, race, class, gender, skin, zone, map, x, y, z, o, face, hairstyle, haircolor, facialhair, characterFlags) VALUES (" + "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", name, session.Account.Id, WorldConfig.RealmId, race, pClass, gender, skin, zone, map, posX, posY, posZ, posO, face, hairStyle, hairColor, facialHair, characterFlags); // Success createChar.WriteUInt8(0x2F); session.Send(ref createChar); }
public static void HandleTalkToGossip(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); byte[] guidMask = { 3, 1, 7, 4, 6, 0, 2, 5 }; byte[] guidBytes = { 0, 1, 7, 6, 5, 2, 4, 3 }; var guid = BitUnpack.GetPackedValue(guidMask, guidBytes); var gossipData = GossipMgr.GetGossip<Creature>(SmartGuid.GetGuid(guid)); if (gossipData != null) { PacketWriter gossipMessage = new PacketWriter(ServerMessage.GossipMessage); BitPack BitPack = new BitPack(gossipMessage, guid); BitPack.WriteGuidMask(0, 1); BitPack.Write(0, 19); // gossipData.QuestsCount BitPack.WriteGuidMask(2); BitPack.Write(0, 20); // gossipData.OptionsCount // QuestsCount not supported. // for (int i = 0; i < gossipData.QuestsCount; i++) BitPack.WriteGuidMask(3); // OptionsCount not supported. // for (int i = 0; i < gossipData.OptionsCount; i++) BitPack.WriteGuidMask(5, 4, 6, 7); BitPack.Flush(); BitPack.WriteGuidBytes(6); // OptionsCount not supported. // for (int i = 0; i < gossipData.OptionsCount; i++) BitPack.WriteGuidBytes(0); // QuestsCount not supported. // for (int i = 0; i < gossipData.QuestsCount; i++) gossipMessage.WriteInt32(gossipData.Id); BitPack.WriteGuidBytes(4, 3); gossipMessage.WriteInt32(gossipData.FriendshipFactionID); gossipMessage.WriteInt32(gossipData.TextID); BitPack.WriteGuidBytes(7, 1, 5, 1); session.Send(ref gossipMessage); } }
public static void HandleTalkToGossip(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); byte[] guidMask = { 3, 1, 7, 4, 6, 0, 2, 5 }; byte[] guidBytes = { 0, 1, 7, 6, 5, 2, 4, 3 }; var guid = BitUnpack.GetPackedValue(guidMask, guidBytes); var gossipData = GossipMgr.GetGossip <Creature>(SmartGuid.GetGuid(guid)); if (gossipData != null) { PacketWriter gossipMessage = new PacketWriter(ServerMessage.GossipMessage); BitPack BitPack = new BitPack(gossipMessage, guid); BitPack.WriteGuidMask(0, 1); BitPack.Write(0, 19); // gossipData.QuestsCount BitPack.WriteGuidMask(2); BitPack.Write(0, 20); // gossipData.OptionsCount // QuestsCount not supported. // for (int i = 0; i < gossipData.QuestsCount; i++) BitPack.WriteGuidMask(3); // OptionsCount not supported. // for (int i = 0; i < gossipData.OptionsCount; i++) BitPack.WriteGuidMask(5, 4, 6, 7); BitPack.Flush(); BitPack.WriteGuidBytes(6); // OptionsCount not supported. // for (int i = 0; i < gossipData.OptionsCount; i++) BitPack.WriteGuidBytes(0); // QuestsCount not supported. // for (int i = 0; i < gossipData.QuestsCount; i++) gossipMessage.WriteInt32(gossipData.Id); BitPack.WriteGuidBytes(4, 3); gossipMessage.WriteInt32(gossipData.FriendshipFactionID); gossipMessage.WriteInt32(gossipData.TextID); BitPack.WriteGuidBytes(7, 1, 5, 1); session.Send(ref gossipMessage); } }
public static void HandleObjectUpdateFailed(ref PacketReader packet, ref WorldClass session) { byte[] guidMask = { 6, 1, 7, 5, 0, 4, 2, 3 }; byte[] guidBytes = { 2, 3, 7, 4, 5, 1, 0, 6 }; BitUnpack GuidUnpacker = new BitUnpack(packet); ulong guid = GuidUnpacker.GetPackedValue(guidMask, guidBytes); Log.Message(LogType.DEBUG, "ObjectUpdate failed for object with Guid {0}", guid); }
public static void HandleRequestCharCreate(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); byte gender = packet.ReadByte(); byte hairColor = packet.ReadByte(); packet.ReadByte(); // Always 0 byte race = packet.ReadByte(); byte pClass = packet.ReadByte(); byte face = packet.ReadByte(); byte facialHair = packet.ReadByte(); byte skin = packet.ReadByte(); byte hairStyle = packet.ReadByte(); uint nameLength = BitUnpack.GetNameLength <uint>(7); string name = packet.ReadString(nameLength); SQLResult result = DB.Characters.Select("SELECT * from characters WHERE name = '{0}'", name); PacketWriter writer = new PacketWriter(LegacyMessage.ResponseCharacterCreate); if (result.Count != 0) { // Name already in use writer.WriteUInt8(0x32); session.Send(writer); return; } result = DB.Characters.Select("SELECT map, zone, posX, posY, posZ, posO FROM character_creation_data WHERE race = {0} AND class = {1}", race, pClass); if (result.Count == 0) { writer.WriteUInt8(0x31); session.Send(writer); return; } uint map = result.Read <uint>(0, "map"); uint zone = result.Read <uint>(0, "zone"); float posX = result.Read <float>(0, "posX"); float posY = result.Read <float>(0, "posY"); float posZ = result.Read <float>(0, "posZ"); float posO = result.Read <float>(0, "posO"); DB.Characters.Execute("INSERT INTO characters (name, accountid, race, class, gender, skin, zone, map, x, y, z, o, face, hairstyle, haircolor, facialhair) VALUES (" + "'{0}', {1}, {2}, {3}, {4}, {5}, {6}, {7}, '{8}', '{9}', '{10}', '{11}', {12}, {13}, {14}, {15})", name, session.Account.Id, race, pClass, gender, skin, zone, map, posX, posY, posZ, posO, face, hairStyle, hairColor, facialHair); // Success writer.WriteUInt8(0x2F); session.Send(writer); }
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 HandleChatMessageYell(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); var language = packet.Read<int>(); 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 HandleQueryPlayerName(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); byte[] guidMask = { 2, 1, 5, 7, 4, 3, 6, 0 }; byte[] guidBytes = { 3, 2, 6, 1, 0, 4, 5, 7 }; uint realmId = packet.Read <uint>(); ulong guid = BitUnpack.GetPackedValue(guidMask, guidBytes); var pSession = WorldMgr.GetSession(guid); if (pSession != null) { var pChar = pSession.Character; if (pChar != null) { PacketWriter queryPlayerNameResponse = new PacketWriter(ServerMessage.QueryPlayerNameResponse); BitPack BitPack = new BitPack(queryPlayerNameResponse, guid); BitPack.WriteGuidMask(7, 3, 0, 2, 1, 6); BitPack.Write(pChar.Name.Length, 6); BitPack.WriteGuidMask(4); BitPack.Write(0); BitPack.WriteGuidMask(5); BitPack.Write(0); BitPack.Flush(); BitPack.WriteGuidBytes(2, 7); queryPlayerNameResponse.WriteUInt8(0); BitPack.WriteGuidBytes(5, 6, 4, 1); queryPlayerNameResponse.WriteUInt8(pChar.Gender); queryPlayerNameResponse.WriteUInt8(pChar.Race); queryPlayerNameResponse.WriteUInt32(realmId); queryPlayerNameResponse.WriteUInt8(pChar.Class); BitPack.WriteGuidBytes(3, 0); queryPlayerNameResponse.WriteString(pChar.Name); session.Send(ref queryPlayerNameResponse); } } }
public static void HandleObjectUpdateFailed(ref PacketReader packet, WorldClass session) { byte[] expr_06 = new byte[8]; ObjectHandler.smethod_5(expr_06, fieldof(< PrivateImplementationDetails >.F33CCE85FC4963E786F0E3E51BF6D41F7DF910C5).FieldHandle); byte[] mask = expr_06; while (true) { IL_A7: uint arg_87_0 = 1795528629u; while (true) { uint num; switch ((num = (arg_87_0 ^ 1171644517u)) % 5u) { case 0u: goto IL_A7; case 1u: { byte[] expr_69 = new byte[8]; ObjectHandler.smethod_5(expr_69, fieldof(< PrivateImplementationDetails >.F194F7A523191120A0E0795F84A21254E1B48C5F).FieldHandle); byte[] bytes = expr_69; arg_87_0 = (num * 2480489431u ^ 3809568048u); continue; } case 2u: { byte[] bytes; ulong packedValue = new BitUnpack(packet).GetPackedValue(mask, bytes); arg_87_0 = (num * 2972380924u ^ 2047378812u); continue; } case 4u: { ulong packedValue; Log.Message(LogType.Debug, Module.smethod_33 <string>(2827741252u), new object[] { packedValue }); arg_87_0 = (num * 1499607034u ^ 1240785080u); continue; } } return; } } }
public static void HandleChatMessageYell(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); var language = packet.Read <int>(); 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 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, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); var language = packet.Read<int>(); var messageLength = BitUnpack.GetBits<byte>(8); 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 HandleCharDelete(ref PacketReader packet, WorldClass session) { byte[] guidMask = { 7, 0, 4, 1, 6, 5, 3, 2 }; byte[] guidBytes = { 6, 7, 5, 0, 4, 2, 3, 1 }; var GuidUnpacker = new BitUnpack(packet); var guid = GuidUnpacker.GetPackedValue(guidMask, guidBytes); PacketWriter deleteChar = new PacketWriter(ServerMessage.DeleteChar); deleteChar.WriteUInt8(0x48); session.Send(ref deleteChar); DB.Characters.Execute("DELETE FROM characters WHERE guid = ?", guid); DB.Characters.Execute("DELETE FROM character_spells WHERE guid = ?", guid); DB.Characters.Execute("DELETE FROM character_skills WHERE guid = ?", guid); }
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 (chatMessage.StartsWith("!")) { WorldMgr.Session = session; ChatCommandParser.ExecuteChatHandler(chatMessage); } else { SendMessageByType(ref session, MessageType.ChatMessageSay, language, chatMessage); } }
public static void HandleCharDelete(ref PacketReader packet, WorldClass session) { byte[] guidMask = { 5, 6, 1, 0, 3, 4, 2, 7 }; byte[] guidBytes = { 2, 0, 4, 1, 5, 3, 7, 6 }; var GuidUnpacker = new BitUnpack(packet); var guid = GuidUnpacker.GetPackedValue(guidMask, guidBytes); PacketWriter deleteChar = new PacketWriter(ServerMessage.DeleteChar); deleteChar.WriteUInt8(0x47); session.Send(ref deleteChar); DB.Characters.Execute("DELETE FROM characters WHERE guid = ?", guid); DB.Characters.Execute("DELETE FROM character_spells WHERE guid = ?", guid); DB.Characters.Execute("DELETE FROM character_skills WHERE guid = ?", guid); }
public static void HandleCliQueryNPCText(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); byte[] guidMask = { 5, 2, 7, 3, 4, 0, 6, 1 }; byte[] guidBytes = { 0, 7, 1, 4, 3, 5, 2, 6 }; var gossipTextId = packet.Read <int>(); var guid = BitUnpack.GetPackedValue(guidMask, guidBytes); var gossipData = GossipMgr.GetGossip <Creature>(SmartGuid.GetGuid(guid)); if (gossipData != null) { PacketWriter queryNPCTextResponse = new PacketWriter(ServerMessage.QueryNPCTextResponse); BitPack BitPack = new BitPack(queryNPCTextResponse); BitPack.Write(1); BitPack.Flush(); 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); } var size = (uint)queryNPCTextResponse.BaseStream.Length - 13; queryNPCTextResponse.WriteUInt32Pos(size, 9); session.Send(ref queryNPCTextResponse); } }
public static void HandleTalkToGossip(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); byte[] guidMask = { 7, 3, 6, 5, 2, 1, 4, 0 }; byte[] guidBytes = { 3, 4, 6, 1, 0, 2, 7, 5 }; var guid = BitUnpack.GetPackedValue(guidMask, guidBytes); var gossipData = GossipMgr.GetGossip<Creature>(SmartGuid.GetGuid(guid)); if (gossipData != null) { PacketWriter gossipMessage = new PacketWriter(ServerMessage.GossipMessage); BitPack BitPack = new BitPack(gossipMessage, guid); BitPack.WriteGuidMask(7, 6, 0); BitPack.Write(0, 19); // gossipData.QuestsCount BitPack.WriteGuidMask(4, 3, 2); BitPack.Write(0, 20); // gossipData.OptionsCount BitPack.WriteGuidMask(1, 5); BitPack.Flush(); BitPack.WriteGuidBytes(2, 7); gossipMessage.WriteInt32(gossipData.FriendshipFactionID); BitPack.WriteGuidBytes(3, 1); gossipMessage.WriteInt32(gossipData.TextID); BitPack.WriteGuidBytes(5); gossipMessage.WriteInt32(gossipData.Id); BitPack.WriteGuidBytes(6, 4, 0); session.Send(ref gossipMessage); } }
public static void HandleCharDelete(ref PacketReader packet, ref WorldClass session) { bool[] guidMask = new bool[8]; byte[] guidBytes = new byte[8]; BitUnpack BitUnpack = new BitUnpack(packet); guidMask[2] = BitUnpack.GetBit(); guidMask[1] = BitUnpack.GetBit(); guidMask[5] = BitUnpack.GetBit(); guidMask[7] = BitUnpack.GetBit(); guidMask[6] = BitUnpack.GetBit(); var unknown = BitUnpack.GetBit(); guidMask[3] = BitUnpack.GetBit(); guidMask[0] = BitUnpack.GetBit(); guidMask[4] = BitUnpack.GetBit(); if (guidMask[1]) guidBytes[1] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[3]) guidBytes[3] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[4]) guidBytes[4] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[0]) guidBytes[0] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[7]) guidBytes[7] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[2]) guidBytes[2] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[5]) guidBytes[5] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[6]) guidBytes[6] = (byte)(packet.Read<byte>() ^ 1); var guid = BitConverter.ToUInt64(guidBytes, 0); PacketWriter deleteChar = new PacketWriter(ServerMessage.DeleteChar); deleteChar.WriteUInt8(0x47); session.Send(ref deleteChar); DB.Characters.Execute("DELETE FROM characters WHERE guid = ?", guid); DB.Characters.Execute("DELETE FROM character_spells WHERE guid = ?", guid); DB.Characters.Execute("DELETE FROM character_skills WHERE guid = ?", guid); }
public static void HandleCliQueryNPCText(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); byte[] guidMask = { 5, 1, 4, 3, 2, 0, 7, 6 }; byte[] guidBytes = { 3, 1, 4, 6, 2, 0, 5, 7 }; var gossipTextId = packet.Read<int>(); var guid = BitUnpack.GetPackedValue(guidMask, guidBytes); var gossipData = GossipMgr.GetGossip<Creature>(SmartGuid.GetGuid(guid)); if (gossipData != null) { PacketWriter queryNPCTextResponse = new PacketWriter(ServerMessage.QueryNPCTextResponse); BitPack BitPack = new BitPack(queryNPCTextResponse); 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); var size = (uint)queryNPCTextResponse.BaseStream.Length - 8; queryNPCTextResponse.WriteUInt32Pos(size, 4); queryNPCTextResponse.WriteInt8(0); queryNPCTextResponse.WriteInt32(gossipTextId); BitPack.Write(1); BitPack.Flush(); session.Send(ref queryNPCTextResponse); } }
public static void HandleTalkToGossip(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); byte[] guidMask = { 7, 3, 6, 5, 2, 1, 4, 0 }; byte[] guidBytes = { 3, 4, 6, 1, 0, 2, 7, 5 }; var guid = BitUnpack.GetPackedValue(guidMask, guidBytes); var gossipData = GossipMgr.GetGossip <Creature>(SmartGuid.GetGuid(guid)); if (gossipData != null) { PacketWriter gossipMessage = new PacketWriter(ServerMessage.GossipMessage); BitPack BitPack = new BitPack(gossipMessage, guid); BitPack.WriteGuidMask(7, 6, 0); BitPack.Write(0, 19); // gossipData.QuestsCount BitPack.WriteGuidMask(4, 3, 2); BitPack.Write(0, 20); // gossipData.OptionsCount BitPack.WriteGuidMask(1, 5); BitPack.Flush(); BitPack.WriteGuidBytes(2, 7); gossipMessage.WriteInt32(gossipData.FriendshipFactionID); BitPack.WriteGuidBytes(3, 1); gossipMessage.WriteInt32(gossipData.TextID); BitPack.WriteGuidBytes(5); gossipMessage.WriteInt32(gossipData.Id); BitPack.WriteGuidBytes(6, 4, 0); session.Send(ref gossipMessage); } }
public static void HandleChatMessageSay(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); var language = packet.Read <int>(); var messageLength = BitUnpack.GetBits <byte>(8); 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 HandleChatMessageWhisper(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); var language = packet.Read<int>(); var nameLength = BitUnpack.GetBits<byte>(9); var messageLength = BitUnpack.GetBits<byte>(8); string receiverName = packet.ReadString(nameLength); string message = packet.ReadString(messageLength); WorldClass rSession = WorldMgr.GetSession(receiverName); if (rSession == null) return; ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageWhisperInform, message, false, true); SendMessage(ref session, chatMessage, rSession); chatMessage = new ChatMessageValues(MessageType.ChatMessageWhisper, message, false, true); SendMessage(ref rSession, chatMessage, session); }
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 HandleMoveSetFly(ref PacketReader packet, WorldClass session) { ObjectMovementValues movementValues = new ObjectMovementValues(); BitUnpack BitUnpack = new BitUnpack(packet); var guidMask = new bool[8]; var guidBytes = new byte[8]; Vector4 vector = new Vector4() { Y = packet.Read<float>(), X = packet.Read<float>(), Z = packet.Read<float>(), }; movementValues.IsFallingOrJumping = BitUnpack.GetBit(); guidMask[0] = BitUnpack.GetBit(); movementValues.HasMovementFlags2 = !BitUnpack.GetBit(); guidMask[6] = BitUnpack.GetBit(); movementValues.HasMovementFlags = !BitUnpack.GetBit(); var Unknown = BitUnpack.GetBit(); guidMask[2] = BitUnpack.GetBit(); movementValues.HasRotation = !BitUnpack.GetBit(); var Unknown2 = !BitUnpack.GetBit(); var HasSplineElevation = !BitUnpack.GetBit(); movementValues.IsTransport = BitUnpack.GetBit(); guidMask[1] = BitUnpack.GetBit(); guidMask[5] = BitUnpack.GetBit(); var HasPitch = !BitUnpack.GetBit(); var Unknown4 = BitUnpack.GetBit(); guidMask[4] = BitUnpack.GetBit(); var HasTime = !BitUnpack.GetBit(); var counter = BitUnpack.GetBits<uint>(22); var Unknown3 = BitUnpack.GetBit(); guidMask[7] = BitUnpack.GetBit(); guidMask[3] = BitUnpack.GetBit(); if (movementValues.IsFallingOrJumping) movementValues.HasJumpData = BitUnpack.GetBit(); if (movementValues.HasMovementFlags) movementValues.MovementFlags = (MovementFlag)BitUnpack.GetBits<uint>(30); if (movementValues.HasMovementFlags2) movementValues.MovementFlags2 = (MovementFlag2)BitUnpack.GetBits<uint>(13); for (int i = 0; i < counter; i++) packet.Read<uint>(); if (guidMask[4]) guidBytes[4] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[2]) guidBytes[2] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[6]) guidBytes[6] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[3]) guidBytes[3] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[0]) guidBytes[0] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[7]) guidBytes[7] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[1]) guidBytes[1] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[5]) guidBytes[5] = (byte)(packet.Read<byte>() ^ 1); if (Unknown2) packet.Read<uint>(); if (movementValues.IsFallingOrJumping) { if (movementValues.HasJumpData) { movementValues.Sin = packet.Read<float>(); movementValues.CurrentSpeed = packet.Read<float>(); movementValues.Cos = packet.Read<float>(); } movementValues.FallTime = packet.Read<uint>(); movementValues.JumpVelocity = packet.Read<float>(); } if (HasSplineElevation) packet.Read<float>(); if (movementValues.HasRotation) vector.O = packet.Read<float>(); if (HasTime) movementValues.Time = packet.Read<uint>(); if (HasPitch) packet.Read<float>(); var guid = BitConverter.ToUInt64(guidBytes, 0); HandleMoveUpdate(guid, movementValues, vector); }
public static void HandleChatMessageSay(ref PacketReader packet, WorldClass session) { BitUnpack arg_0F_0 = new BitUnpack(packet); int num = packet.Read <int>(); int num2 = (int)arg_0F_0.GetBits <byte>(8) << 1; bool bit = arg_0F_0.GetBit(); ChatMessageValues chatMessageValues; while (true) { IL_10D: uint arg_E0_0 = 325641967u; while (true) { uint num3; switch ((num3 = (arg_E0_0 ^ 1114592966u)) % 8u) { case 0u: goto IL_10D; case 1u: { string text = packet.ReadString((uint)(bit ? ((byte)num2 + 1) : ((byte)num2))); arg_E0_0 = 1695780296u; continue; } case 2u: return; case 3u: { string text; arg_E0_0 = ((ChatCommandParser.CheckForCommand(text) ? 3993131816u : 2950447498u) ^ num3 * 3295186339u); continue; } case 4u: { string text; ChatCommandParser.ExecuteChatHandler2(text, Manager.WorldMgr.GetSession2(session.Character.Guid)); arg_E0_0 = (num3 * 451064634u ^ 332353724u); continue; } case 6u: { string text; chatMessageValues = new ChatMessageValues(MessageType.ChatMessageSay, text, true, true, session.Character.Name); chatMessageValues.Language = (byte)num; arg_E0_0 = (num3 * 3671775661u ^ 3376883115u); continue; } case 7u: { string text; ChatCommandParser.ExecuteChatHandler(text, session); arg_E0_0 = (num3 * 3654367289u ^ 3353498485u); continue; } } goto Block_3; } } Block_3: ChatHandler.SendMessage(ref session, chatMessageValues, null); }
public static void HandlePlayerMove(ref PacketReader packet, WorldClass session) { ObjectMovementValues movementValues = new ObjectMovementValues(); BitUnpack BitUnpack = new BitUnpack(packet); var guidMask = new bool[8]; var guidBytes = new byte[8]; Vector4 vector = new Vector4() { Y = packet.Read <float>(), Z = packet.Read <float>(), X = packet.Read <float>() }; guidMask[3] = BitUnpack.GetBit(); var HasPitch = !BitUnpack.GetBit(); guidMask[0] = BitUnpack.GetBit(); var counter = BitUnpack.GetBits <uint>(22); guidMask[2] = BitUnpack.GetBit(); var HasSplineElevation = !BitUnpack.GetBit(); movementValues.HasRotation = !BitUnpack.GetBit(); var Unknown = BitUnpack.GetBit(); var Unknown2 = BitUnpack.GetBit(); guidMask[7] = BitUnpack.GetBit(); var HasTime = !BitUnpack.GetBit(); movementValues.IsFallingOrJumping = BitUnpack.GetBit(); movementValues.HasMovementFlags2 = !BitUnpack.GetBit(); movementValues.HasMovementFlags = !BitUnpack.GetBit(); var Unknown3 = !BitUnpack.GetBit(); var Unknown4 = BitUnpack.GetBit(); guidMask[6] = BitUnpack.GetBit(); guidMask[1] = BitUnpack.GetBit(); movementValues.IsTransport = BitUnpack.GetBit(); guidMask[4] = BitUnpack.GetBit(); guidMask[5] = BitUnpack.GetBit(); if (movementValues.HasMovementFlags) { movementValues.MovementFlags = (MovementFlag)BitUnpack.GetBits <uint>(30); } if (movementValues.IsFallingOrJumping) { movementValues.HasJumpData = BitUnpack.GetBit(); } if (movementValues.HasMovementFlags2) { movementValues.MovementFlags2 = (MovementFlag2)BitUnpack.GetBits <uint>(13); } if (guidMask[0]) { guidBytes[0] = (byte)(packet.Read <byte>() ^ 1); } for (int i = 0; i < counter; i++) { packet.Read <uint>(); } if (guidMask[4]) { guidBytes[4] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[1]) { guidBytes[1] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[5]) { guidBytes[5] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[6]) { guidBytes[6] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[2]) { guidBytes[2] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[3]) { guidBytes[3] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[7]) { guidBytes[7] = (byte)(packet.Read <byte>() ^ 1); } if (HasPitch) { packet.Read <float>(); } if (movementValues.HasRotation) { vector.O = packet.Read <float>(); } if (movementValues.IsFallingOrJumping) { movementValues.JumpVelocity = packet.Read <float>(); if (movementValues.HasJumpData) { movementValues.CurrentSpeed = packet.Read <float>(); movementValues.Sin = packet.Read <float>(); movementValues.Cos = packet.Read <float>(); } movementValues.FallTime = packet.Read <uint>(); } if (Unknown3) { packet.Read <uint>(); } if (HasSplineElevation) { packet.Read <float>(); } if (HasTime) { movementValues.Time = packet.Read <uint>(); } var guid = BitConverter.ToUInt64(guidBytes, 0); HandleMoveUpdate(guid, movementValues, vector); }
public static void HandleQueryGameObject(ref PacketReader packet, WorldClass session) { byte[] guidMask = { 6, 4, 0, 5, 1, 7, 3, 2 }; byte[] guidBytes = { 5, 0, 6, 7, 3, 4, 2, 1 }; BitUnpack BitUnpack = new BitUnpack(packet); var id = packet.Read <int>(); var guid = BitUnpack.GetPackedValue(guidMask, guidBytes); PacketWriter queryGameObjectResponse = new PacketWriter(ServerMessage.QueryGameObjectResponse); BitPack BitPack = new BitPack(queryGameObjectResponse); var gObject = DataMgr.FindGameObject(id); var hasData = (gObject != null); queryGameObjectResponse.WriteInt32(id); queryGameObjectResponse.WriteInt32(0); if (hasData) { var stats = gObject.Stats; queryGameObjectResponse.WriteInt32((int)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); } else { Log.Message(LogType.Debug, "Gameobject (Id: {0}) not found.", id); } BitPack.Write(hasData); BitPack.Flush(); session.Send(ref queryGameObjectResponse); }
public static void HandleAuthResponse(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); packet.Skip(54); int addonSize = packet.Read<int>(); packet.Skip(addonSize); uint nameLength = BitUnpack.GetBits<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(ServerMessage.AuthResponse); BitPack BitPack = new BitPack(authResponse); BitPack.Write(IsInQueue); if (IsInQueue) BitPack.Write(1); // Unknown BitPack.Write(HasAccountData); if (HasAccountData) { BitPack.Write(0); // Unknown, 5.0.4 BitPack.Write(0); // Unknown, 5.3.0 BitPack.Write(realmRaceResult.Count, 23); // Activation count for races BitPack.Write(0); // Unknown, 5.1.0 BitPack.Write(0, 21); // Activate character template windows/button //if (HasCharacterTemplate) //Write bits for char templates... BitPack.Write(realmClassResult.Count, 23); // Activation count for classes BitPack.Write(0, 22); // Unknown, 5.3.0 BitPack.Write(0); // Unknown2, 5.3.0 } BitPack.Flush(); if (HasAccountData) { authResponse.WriteUInt8(0); for (int c = 0; c < realmClassResult.Count; c++) { authResponse.WriteUInt8(realmClassResult.Read<byte>(c, "expansion")); authResponse.WriteUInt8(realmClassResult.Read<byte>(c, "class")); } //if (Unknown2) // authResponse.WriteUInt16(0); //if (HasCharacterTemplate) //Write data for char templates... //if (Unknown) // authResponse.WriteUInt16(0); 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.WriteUInt32(0); authResponse.WriteUInt8(session.Account.Expansion); // Unknown Counter // Write UInt32... authResponse.WriteUInt8(session.Account.Expansion); } authResponse.WriteUInt8((byte)AuthCodes.AUTH_OK); if (IsInQueue) authResponse.WriteUInt32(0); session.Send(ref authResponse); MiscHandler.HandleCacheVersion(ref session); TutorialHandler.HandleTutorialFlags(ref session); }
public static void HandleQueryPlayerName(ref PacketReader packet, ref WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); byte[] guidMask = { 2, 1, 5, 7, 4, 3, 6, 0 }; byte[] guidBytes = { 3, 2, 6, 1, 0, 4, 5, 7 }; uint realmId = packet.Read<uint>(); ulong guid = BitUnpack.GetPackedValue(guidMask, guidBytes); var pSession = WorldMgr.GetSession(guid); if (pSession != null) { var pChar = pSession.Character; if (pChar != null) { PacketWriter queryPlayerNameResponse = new PacketWriter(ServerMessage.QueryPlayerNameResponse); BitPack BitPack = new BitPack(queryPlayerNameResponse, guid); BitPack.WriteGuidMask(7, 3, 0, 2, 1, 6); BitPack.Write(pChar.Name.Length, 6); BitPack.WriteGuidMask(4); BitPack.Write(0); BitPack.WriteGuidMask(5); BitPack.Write(0); BitPack.Flush(); BitPack.WriteGuidBytes(2, 7); queryPlayerNameResponse.WriteUInt8(0); BitPack.WriteGuidBytes(5, 6, 4, 1); queryPlayerNameResponse.WriteUInt8(pChar.Gender); queryPlayerNameResponse.WriteUInt8(pChar.Race); queryPlayerNameResponse.WriteUInt32(realmId); queryPlayerNameResponse.WriteUInt8(pChar.Class); BitPack.WriteGuidBytes(3, 0); queryPlayerNameResponse.WriteString(pChar.Name); session.Send(ref queryPlayerNameResponse); } } }
public static void HandleDBQueryBulk(ref PacketReader packet, WorldClass session) { List <int> IdList = new List <int>(); BitUnpack BitUnpack = new BitUnpack(packet); var type = (DBTypes)packet.Read <uint>(); 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][1] = BitUnpack.GetBit(); Mask[i][7] = BitUnpack.GetBit(); Mask[i][2] = BitUnpack.GetBit(); Mask[i][5] = BitUnpack.GetBit(); Mask[i][0] = BitUnpack.GetBit(); Mask[i][6] = BitUnpack.GetBit(); Mask[i][3] = BitUnpack.GetBit(); Mask[i][4] = BitUnpack.GetBit(); } for (int i = 0; i < count; i++) { if (Mask[i][4]) { Bytes[i][4] = (byte)(packet.Read <byte>() ^ 1); } if (Mask[i][7]) { Bytes[i][7] = (byte)(packet.ReadByte() ^ 1); } if (Mask[i][6]) { Bytes[i][6] = (byte)(packet.ReadByte() ^ 1); } if (Mask[i][0]) { Bytes[i][0] = (byte)(packet.ReadByte() ^ 1); } if (Mask[i][2]) { Bytes[i][2] = (byte)(packet.ReadByte() ^ 1); } if (Mask[i][3]) { Bytes[i][3] = (byte)(packet.ReadByte() ^ 1); } IdList.Add(packet.Read <int>()); if (Mask[i][5]) { Bytes[i][5] = (byte)(packet.ReadByte() ^ 1); } if (Mask[i][1]) { Bytes[i][1] = (byte)(packet.ReadByte() ^ 1); } } switch (type) { case DBTypes.BroadcastText: { foreach (var id in IdList) { HandleBroadcastText(ref session, id); } break; } default: break; } }
public static void HandleSetSelection(ref PacketReader packet, ref WorldClass session) { byte[] guidMask = { 3, 1, 7, 2, 6, 4, 0, 5 }; byte[] guidBytes = { 4, 1, 5, 2, 6, 7, 0, 3 }; BitUnpack GuidUnpacker = new BitUnpack(packet); ulong fullGuid = GuidUnpacker.GetGuid(guidMask, guidBytes); ulong guid = ObjectGuid.GetGuid(fullGuid); var sess = WorldMgr.GetSession(session.Character.Guid); sess.Character.TargetGuid = fullGuid; if (guid == 0) Log.Message(LogType.DEBUG, "Character (Guid: {0}) removed current selection.", session.Character.Guid); else Log.Message(LogType.DEBUG, "Character (Guid: {0}) selected a {1} (Guid: {2}, Id: {3}).", session.Character.Guid, ObjectGuid.GetGuidType(fullGuid), guid, ObjectGuid.GetId(fullGuid)); }
public static void HandleSetSelection(ref PacketReader packet, WorldClass session) { byte[] guidMask = { 7, 2, 1, 3, 5, 4, 0, 6 }; byte[] guidBytes = { 1, 2, 3, 0, 7, 5, 4, 6 }; BitUnpack GuidUnpacker = new BitUnpack(packet); ulong fullGuid = GuidUnpacker.GetPackedValue(guidMask, guidBytes); ulong guid = SmartGuid.GetGuid(fullGuid); if (session.Character != null) { var sess = WorldMgr.GetSession(session.Character.Guid); if (sess != null) sess.Character.TargetGuid = fullGuid; if (guid == 0) Log.Message(LogType.Debug, "Character (Guid: {0}) removed current selection.", session.Character.Guid); else Log.Message(LogType.Debug, "Character (Guid: {0}) selected a {1} (Guid: {2}, Id: {3}).", session.Character.Guid, SmartGuid.GetGuidType(fullGuid), guid, SmartGuid.GetId(fullGuid)); } }
public static void HandleSetActionButton(ref PacketReader packet, WorldClass session) { var pChar = session.Character; byte[] actionMask = { 5, 0, 3, 1, 4, 7, 6, 2 }; byte[] actionBytes = { 3, 4, 6, 7, 1, 2, 0, 5 }; BitUnpack actionUnpacker = new BitUnpack(packet); var slotId = packet.Read<byte>(); var actionId = actionUnpacker.GetPackedValue(actionMask, actionBytes); if (actionId == 0) { var action = pChar.ActionButtons.Where(button => button.SlotId == slotId && button.SpecGroup == pChar.ActiveSpecGroup).Select(button => button).First(); ActionMgr.RemoveActionButton(pChar, action, true); Log.Message(LogType.Debug, "Character (Guid: {0}) removed action button {1} from slot {2}.", pChar.Guid, actionId, slotId); return; } var newAction = new ActionButton { Action = actionId, SlotId = slotId, SpecGroup = pChar.ActiveSpecGroup }; ActionMgr.AddActionButton(pChar, newAction, true); Log.Message(LogType.Debug, "Character (Guid: {0}) added action button {1} to slot {2}.", pChar.Guid, actionId, slotId); }
public static void HandleQueryPlayerName(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); var guidMask = new bool[8]; var guidBytes = new byte[8]; guidMask[1] = BitUnpack.GetBit(); guidMask[3] = BitUnpack.GetBit(); guidMask[6] = BitUnpack.GetBit(); guidMask[7] = BitUnpack.GetBit(); guidMask[2] = BitUnpack.GetBit(); guidMask[5] = BitUnpack.GetBit(); var hasUnknown = BitUnpack.GetBit(); guidMask[0] = BitUnpack.GetBit(); var hasUnknown2 = BitUnpack.GetBit(); guidMask[4] = BitUnpack.GetBit(); if (guidMask[4]) guidBytes[4] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[6]) guidBytes[6] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[7]) guidBytes[7] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[1]) guidBytes[1] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[2]) guidBytes[2] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[5]) guidBytes[5] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[0]) guidBytes[0] = (byte)(packet.Read<byte>() ^ 1); if (guidMask[3]) guidBytes[3] = (byte)(packet.Read<byte>() ^ 1); if (hasUnknown) packet.Read<uint>(); if (hasUnknown2) packet.Read<uint>(); var guid = BitConverter.ToUInt64(guidBytes, 0); var pSession = WorldMgr.GetSession(guid); if (pSession != null) { var pChar = pSession.Character; if (pChar != null) { PacketWriter queryPlayerNameResponse = new PacketWriter(ServerMessage.QueryPlayerNameResponse); BitPack BitPack = new BitPack(queryPlayerNameResponse, guid); BitPack.WriteGuidMask(3, 2, 6, 0, 4, 1, 5, 7); BitPack.Flush(); BitPack.WriteGuidBytes(7, 1, 2, 6, 3, 5); queryPlayerNameResponse.WriteUInt8(0); queryPlayerNameResponse.WriteUInt8(pChar.Gender); queryPlayerNameResponse.WriteUInt8(pChar.Class); queryPlayerNameResponse.WriteUInt8(pChar.Level); queryPlayerNameResponse.WriteUInt32(1); queryPlayerNameResponse.WriteUInt8(pChar.Race); queryPlayerNameResponse.WriteUInt32(0); BitPack.WriteGuidBytes(4, 0); BitPack.WriteGuidMask(5); BitPack.Write(0); BitPack.Write(0); BitPack.Write(0); BitPack.WriteGuidMask(3, 7, 0, 6); BitPack.Write(0); BitPack.Write(0); BitPack.WriteGuidMask(1); BitPack.Write(0); for (int i = 0; i < 5; i++) BitPack.Write(0, 7); BitPack.WriteGuidMask(2); BitPack.Write(0); BitPack.WriteGuidMask(4); BitPack.Write(0); BitPack.Write(pChar.Name.Length, 6); BitPack.Write(0); BitPack.Flush(); BitPack.WriteGuidBytes(0, 7, 5, 2); queryPlayerNameResponse.WriteString(pChar.Name); BitPack.WriteGuidBytes(4, 1, 3, 6); session.Send(ref queryPlayerNameResponse); } } }
public static void HandleAuthResponse(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); ushort skipBytes; uint[] UnknownInt = new uint[5]; ushort clientBuild; byte[] authChallenge = new byte[20]; byte[] UnknownByte = new byte[2]; ulong unknownLong; int addonPackedSize; int addonUnpackedSize; skipBytes = packet.Read<ushort>(); UnknownInt[4] = packet.Read<uint>(); authChallenge[14] = packet.Read<byte>(); authChallenge[8] = packet.Read<byte>(); UnknownInt[0] = packet.Read<uint>(); authChallenge[10] = packet.Read<byte>(); authChallenge[19] = packet.Read<byte>(); authChallenge[16] = packet.Read<byte>(); authChallenge[13] = packet.Read<byte>(); authChallenge[4] = packet.Read<byte>(); UnknownByte[1] = packet.Read<byte>(); authChallenge[9] = packet.Read<byte>(); authChallenge[0] = packet.Read<byte>(); UnknownInt[2] = packet.Read<uint>(); authChallenge[5] = packet.Read<byte>(); authChallenge[2] = packet.Read<byte>(); clientBuild = packet.Read<ushort>(); authChallenge[12] = packet.Read<byte>(); UnknownInt[3] = packet.Read<uint>(); authChallenge[18] = packet.Read<byte>(); authChallenge[17] = packet.Read<byte>(); authChallenge[11] = packet.Read<byte>(); unknownLong = packet.Read<ulong>(); authChallenge[7] = packet.Read<byte>(); authChallenge[1] = packet.Read<byte>(); authChallenge[3] = packet.Read<byte>(); UnknownByte[0] = packet.Read<byte>(); authChallenge[6] = packet.Read<byte>(); UnknownInt[1] = packet.Read<uint>(); authChallenge[15] = packet.Read<byte>(); addonPackedSize = packet.Read<int>(); addonUnpackedSize = packet.Read<int>(); byte[] packedAddon = packet.ReadBytes(addonPackedSize - 4); AddonHandler.ReadAddonData(packedAddon, addonUnpackedSize, session); uint nameLength = BitUnpack.GetBits<uint>(11); bool aBit = BitUnpack.GetBit(); // BitUnpack.Flush(); 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); var HasAccountData = true; var IsInQueue = false; PacketWriter authResponse = new PacketWriter(ServerMessage.AuthResponse); BitPack BitPack = new BitPack(authResponse); authResponse.WriteUInt8((byte)AuthCodes.AUTH_OK); BitPack.Write(IsInQueue); if (IsInQueue) BitPack.Write(1); // Unknown BitPack.Write(HasAccountData); if (HasAccountData) { BitPack.Write(0); BitPack.Write(0, 21); BitPack.Write(0, 21); BitPack.Write(realmRaceResult.Count, 23); BitPack.Write(0); BitPack.Write(0); BitPack.Write(0); BitPack.Write(realmClassResult.Count, 23); } BitPack.Flush(); if (HasAccountData) { authResponse.WriteUInt32(0); authResponse.WriteUInt32(0); authResponse.WriteUInt8(session.Account.Expansion); for (int r = 0; r < realmRaceResult.Count; r++) { authResponse.WriteUInt8(realmRaceResult.Read<byte>(r, "expansion")); authResponse.WriteUInt8(realmRaceResult.Read<byte>(r, "race")); } authResponse.WriteUInt8(session.Account.Expansion); authResponse.WriteUInt32(0); 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.WriteUInt32(0); } if (IsInQueue) authResponse.WriteUInt32(0); session.Send(ref authResponse); MiscHandler.HandleCacheVersion(ref session); TutorialHandler.HandleTutorialFlags(ref session); }
public static void HandleMoveStopTurn(ref PacketReader packet, ref WorldClass session) { ObjectMovementValues movementValues = new ObjectMovementValues(); BitUnpack BitUnpack = new BitUnpack(packet); bool[] guidMask = new bool[8]; byte[] guidBytes = new byte[8]; Vector4 vector = new Vector4() { X = packet.ReadFloat(), Z = packet.ReadFloat(), Y = packet.ReadFloat() }; bool HasTime = !BitUnpack.GetBit(); guidMask[5] = BitUnpack.GetBit(); bool Unknown = BitUnpack.GetBit(); movementValues.IsTransport = BitUnpack.GetBit(); bool Unknown2 = BitUnpack.GetBit(); guidMask[3] = BitUnpack.GetBit(); bool HasSplineElevation = !BitUnpack.GetBit(); guidMask[0] = BitUnpack.GetBit(); bool HasPitch = !BitUnpack.GetBit(); uint counter = BitUnpack.GetBits<uint>(24); guidMask[1] = BitUnpack.GetBit(); guidMask[7] = BitUnpack.GetBit(); movementValues.HasMovementFlags = !BitUnpack.GetBit(); movementValues.IsAlive = !BitUnpack.GetBit(); guidMask[2] = BitUnpack.GetBit(); guidMask[6] = BitUnpack.GetBit(); movementValues.HasRotation = !BitUnpack.GetBit(); bool Unknown3 = BitUnpack.GetBit(); movementValues.HasMovementFlags2 = !BitUnpack.GetBit(); bool Unknown4 = BitUnpack.GetBit(); guidMask[4] = BitUnpack.GetBit(); /*if (movementValues.IsTransport) { } if (IsInterpolated) { }*/ if (movementValues.HasMovementFlags) movementValues.MovementFlags = (MovementFlag)BitUnpack.GetBits<uint>(30); if (movementValues.HasMovementFlags2) movementValues.MovementFlags2 = (MovementFlag2)BitUnpack.GetBits<uint>(13); if (guidMask[6]) guidBytes[6] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[0]) guidBytes[0] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[5]) guidBytes[5] = (byte)(packet.ReadUInt8() ^ 1); for (int i = 0; i < counter; i++) packet.ReadUInt32(); if (guidMask[1]) guidBytes[1] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[7]) guidBytes[7] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[3]) guidBytes[3] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[4]) guidBytes[4] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[2]) guidBytes[2] = (byte)(packet.ReadUInt8() ^ 1); /*if (movementValues.IsTransport) { }*/ if (movementValues.HasRotation) vector.W = packet.ReadFloat(); if (movementValues.IsAlive) movementValues.Time = packet.ReadUInt32(); /*if (IsInterpolated) { }*/ if (HasPitch) packet.ReadFloat(); if (HasSplineElevation) packet.ReadFloat(); if (HasTime) movementValues.Time = packet.ReadUInt32(); var guid = BitConverter.ToUInt64(guidBytes, 0); HandleMoveUpdate(guid, movementValues, vector); }
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.Read<uint>(); 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.Read<byte>() ^ 1); IdList.Add(packet.Read<int>()); 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 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.Read<int>(); 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 HandlePlayerLogin(ref PacketReader packet, WorldClass session) { byte[] guidMask = { 0, 7, 2, 5, 4, 6, 1, 3 }; byte[] guidBytes = { 7, 1, 5, 0, 3, 6, 2, 4 }; BitUnpack GuidUnpacker = new BitUnpack(packet); var unknown = packet.Read<float>(); var guid = GuidUnpacker.GetPackedValue(guidMask, guidBytes); Log.Message(LogType.Debug, "Character with Guid: {0}, AccountId: {1} tried to enter the world.", guid, session.Account.Id); session.Character = new Character(guid); if (!WorldMgr.AddSession(guid, ref session)) { Log.Message(LogType.Error, "A Character with Guid: {0} is already logged in", guid); return; } WorldMgr.WriteAccountDataTimes(AccountDataMasks.CharacterCacheMask, ref session); MiscHandler.HandleMessageOfTheDay(ref session); TimeHandler.HandleLoginSetTimeSpeed(ref session); SpecializationHandler.HandleUpdateTalentData(ref session); SpellHandler.HandleSendKnownSpells(ref session); MiscHandler.HandleUpdateActionButtons(ref session); if (session.Character.LoginCinematic) CinematicHandler.HandleStartCinematic(ref session); ObjectHandler.HandleUpdateObjectCreate(ref session); }
public static void HandleQueryPlayerName(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); var guidMask = new bool[8]; var guidBytes = new byte[8]; guidMask[1] = BitUnpack.GetBit(); guidMask[3] = BitUnpack.GetBit(); guidMask[6] = BitUnpack.GetBit(); guidMask[7] = BitUnpack.GetBit(); guidMask[2] = BitUnpack.GetBit(); guidMask[5] = BitUnpack.GetBit(); var hasUnknown = BitUnpack.GetBit(); guidMask[0] = BitUnpack.GetBit(); var hasUnknown2 = BitUnpack.GetBit(); guidMask[4] = BitUnpack.GetBit(); if (guidMask[4]) { guidBytes[4] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[6]) { guidBytes[6] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[7]) { guidBytes[7] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[1]) { guidBytes[1] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[2]) { guidBytes[2] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[5]) { guidBytes[5] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[0]) { guidBytes[0] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[3]) { guidBytes[3] = (byte)(packet.Read <byte>() ^ 1); } if (hasUnknown) { packet.Read <uint>(); } if (hasUnknown2) { packet.Read <uint>(); } var guid = BitConverter.ToUInt64(guidBytes, 0); var pSession = WorldMgr.GetSession(guid); if (pSession != null) { var pChar = pSession.Character; if (pChar != null) { PacketWriter queryPlayerNameResponse = new PacketWriter(ServerMessage.QueryPlayerNameResponse); BitPack BitPack = new BitPack(queryPlayerNameResponse, guid); BitPack.WriteGuidMask(3, 2, 6, 0, 4, 1, 5, 7); BitPack.Flush(); BitPack.WriteGuidBytes(7, 1, 2, 6, 3, 5); queryPlayerNameResponse.WriteUInt8(0); queryPlayerNameResponse.WriteUInt8(pChar.Gender); queryPlayerNameResponse.WriteUInt8(pChar.Class); queryPlayerNameResponse.WriteUInt8(pChar.Level); queryPlayerNameResponse.WriteUInt32(1); queryPlayerNameResponse.WriteUInt8(pChar.Race); queryPlayerNameResponse.WriteUInt32(0); BitPack.WriteGuidBytes(4, 0); BitPack.WriteGuidMask(5); BitPack.Write(0); BitPack.Write(0); BitPack.Write(0); BitPack.WriteGuidMask(3, 7, 0, 6); BitPack.Write(0); BitPack.Write(0); BitPack.WriteGuidMask(1); BitPack.Write(0); for (int i = 0; i < 5; i++) { BitPack.Write(0, 7); } BitPack.WriteGuidMask(2); BitPack.Write(0); BitPack.WriteGuidMask(4); BitPack.Write(0); BitPack.Write(pChar.Name.Length, 6); BitPack.Write(0); BitPack.Flush(); BitPack.WriteGuidBytes(0, 7, 5, 2); queryPlayerNameResponse.WriteString(pChar.Name); BitPack.WriteGuidBytes(4, 1, 3, 6); session.Send(ref queryPlayerNameResponse); } } }
public static void HandleAuthResponse(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); packet.Skip(54); int addonSize = packet.Read <int>(); packet.Skip(addonSize); uint nameLength = BitUnpack.GetBits <uint>(11); 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); var HasAccountData = true; var IsInQueue = false; PacketWriter authResponse = new PacketWriter(ServerMessage.AuthResponse); BitPack BitPack = new BitPack(authResponse); BitPack.Write(HasAccountData); if (HasAccountData) { BitPack.Write(0, 21); BitPack.Write(0); BitPack.Write(realmRaceResult.Count, 23); BitPack.Write(0, 21); BitPack.Write(0); BitPack.Write(realmClassResult.Count, 23); BitPack.Write(0); BitPack.Write(0); BitPack.Write(0); } BitPack.Write(IsInQueue); if (IsInQueue) { BitPack.Write(1); // Unknown } BitPack.Flush(); if (IsInQueue) { authResponse.WriteUInt32(0); } if (HasAccountData) { for (int c = 0; c < realmClassResult.Count; c++) { authResponse.WriteUInt8(realmClassResult.Read <byte>(c, "expansion")); authResponse.WriteUInt8(realmClassResult.Read <byte>(c, "class")); } authResponse.WriteUInt8(session.Account.Expansion); 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.WriteUInt32(0); authResponse.WriteUInt32(0); authResponse.WriteUInt32(0); authResponse.WriteUInt8(session.Account.Expansion); authResponse.WriteUInt32(0); } authResponse.WriteUInt8((byte)AuthCodes.AUTH_OK); session.Send(ref authResponse); MiscHandler.HandleCacheVersion(ref session); TutorialHandler.HandleTutorialFlags(ref session); } }