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 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 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 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 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 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 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 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 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 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 HandleCreateCharacter(ref PacketReader packet, WorldClass session) { BitUnpack BitUnpack = new BitUnpack(packet); var hairStyle = packet.ReadByte(); var gender = packet.ReadByte(); var skin = packet.ReadByte(); var hairColor = packet.ReadByte(); var facialHair = packet.ReadByte(); var pClass = packet.ReadByte(); var race = packet.ReadByte(); var face = packet.ReadByte(); packet.ReadByte(); // Always 0 var HasUnknown = BitUnpack.GetBit(); var nameLength = BitUnpack.GetBits <uint>(6); 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 HandleMove(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.Read <float>(), Y = packet.Read <float>(), Z = packet.Read <float>() }; guidMask[0] = BitUnpack.GetBit(); guidMask[3] = BitUnpack.GetBit(); bool HasPitch = !BitUnpack.GetBit(); guidMask[2] = BitUnpack.GetBit(); bool HasSplineElevation = !BitUnpack.GetBit(); bool Unknown = BitUnpack.GetBit(); bool Unknown2 = BitUnpack.GetBit(); guidMask[6] = BitUnpack.GetBit(); guidMask[7] = BitUnpack.GetBit(); guidMask[5] = BitUnpack.GetBit(); movementValues.HasMovementFlags = !BitUnpack.GetBit(); movementValues.HasRotation = !BitUnpack.GetBit(); bool Unknown3 = BitUnpack.GetBit(); movementValues.HasMovementFlags2 = !BitUnpack.GetBit(); movementValues.IsAlive = !BitUnpack.GetBit(); guidMask[1] = BitUnpack.GetBit(); movementValues.IsTransport = BitUnpack.GetBit(); guidMask[4] = BitUnpack.GetBit(); movementValues.IsInterpolated = BitUnpack.GetBit(); bool HasTime = !BitUnpack.GetBit(); uint counter = BitUnpack.GetBits <uint>(22); if (movementValues.IsInterpolated) { movementValues.IsInterpolated2 = BitUnpack.GetBit(); } if (movementValues.HasMovementFlags) { movementValues.MovementFlags = (MovementFlag)BitUnpack.GetBits <uint>(30); } if (movementValues.HasMovementFlags2) { movementValues.MovementFlags2 = (MovementFlag2)BitUnpack.GetBits <uint>(13); } if (guidMask[0]) { guidBytes[0] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[2]) { guidBytes[2] = (byte)(packet.Read <byte>() ^ 1); } for (int i = 0; i < counter; i++) { packet.Read <uint>(); } if (guidMask[7]) { guidBytes[7] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[6]) { guidBytes[6] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[1]) { guidBytes[1] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[4]) { guidBytes[4] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[3]) { guidBytes[3] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[5]) { guidBytes[5] = (byte)(packet.Read <byte>() ^ 1); } if (HasSplineElevation) { packet.Read <float>(); } /*if (movementValues.IsTransport) * { * * }*/ if (movementValues.IsInterpolated) { if (movementValues.IsInterpolated2) { packet.Read <float>(); packet.Read <float>(); packet.Read <float>(); } packet.Read <uint>(); packet.Read <float>(); } if (HasPitch) { packet.Read <float>(); } if (movementValues.IsAlive) { movementValues.Time = packet.Read <uint>(); } if (movementValues.HasRotation) { vector.O = packet.Read <float>(); } if (HasTime) { movementValues.Time = packet.Read <uint>(); } var guid = BitConverter.ToUInt64(guidBytes, 0); HandleMoveUpdate(guid, movementValues, vector); }
public static void HandleMoveFallLand(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() { Y = packet.ReadFloat(), X = packet.ReadFloat(), Z = packet.ReadFloat() }; uint counter = BitUnpack.GetBits<uint>(24); guidMask[2] = BitUnpack.GetBit(); bool HasTime = !BitUnpack.GetBit(); bool HasSplineElevation = !BitUnpack.GetBit(); guidMask[6] = BitUnpack.GetBit(); guidMask[0] = BitUnpack.GetBit(); movementValues.IsTransport = BitUnpack.GetBit(); bool Unknown3 = BitUnpack.GetBit(); bool Unknown = BitUnpack.GetBit(); guidMask[4] = BitUnpack.GetBit(); movementValues.HasMovementFlags2 = !BitUnpack.GetBit(); bool HasPitch = !BitUnpack.GetBit(); movementValues.HasRotation = !BitUnpack.GetBit(); bool Unknown2 = BitUnpack.GetBit(); guidMask[1] = BitUnpack.GetBit(); movementValues.IsAlive = !BitUnpack.GetBit(); movementValues.HasMovementFlags = !BitUnpack.GetBit(); guidMask[5] = BitUnpack.GetBit(); guidMask[7] = BitUnpack.GetBit(); guidMask[3] = BitUnpack.GetBit(); bool Unknown4 = BitUnpack.GetBit(); /*if (movementValues.IsTransport) { vehicleGuidMask[4] = BitUnpack.GetBit(); vehicleGuidMask[1] = BitUnpack.GetBit(); bool vehicleUnknown2 = BitUnpack.GetBit(); vehicleGuidMask[2] = BitUnpack.GetBit(); vehicleGuidMask[3] = BitUnpack.GetBit(); vehicleGuidMask[7] = BitUnpack.GetBit(); vehicleGuidMask[0] = BitUnpack.GetBit(); bool vehicleUnknown1 = BitUnpack.GetBit(); vehicleGuidMask[5] = BitUnpack.GetBit(); vehicleGuidMask[6] = BitUnpack.GetBit(); } if (movementValues.IsInterpolated) movementValues.IsInterpolated2 = BitUnpack.GetBit();*/ if (movementValues.HasMovementFlags2) movementValues.MovementFlags2 = (MovementFlag2)BitUnpack.GetBits<uint>(13); if (movementValues.HasMovementFlags) movementValues.MovementFlags = (MovementFlag)BitUnpack.GetBits<uint>(30); if (guidMask[0]) guidBytes[0] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[2]) guidBytes[2] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[1]) guidBytes[1] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[4]) guidBytes[4] = (byte)(packet.ReadUInt8() ^ 1); for (int i = 0; i < counter; i++) packet.ReadUInt32(); if (guidMask[6]) guidBytes[6] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[5]) guidBytes[5] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[7]) guidBytes[7] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[3]) guidBytes[3] = (byte)(packet.ReadUInt8() ^ 1); /*if (movementValues.IsTransport) { Vector4 vehiclevector = new Vector4(); vehiclevector.X = packet.ReadFloat(); if (vehicleGuidMask[0]) vehicleGuidBytes[0] = (byte)(packet.ReadUInt8() ^ 1); if ( vehicleUnknown1 ) uint _25 = packet.ReadUInt32(); if (vehicleGuidMask[4]) vehicleGuidBytes[4] = (byte)(packet.ReadUInt8() ^ 1); if (vehicleGuidMask[5]) vehicleGuidBytes[5] = (byte)(packet.ReadUInt8() ^ 1); if (vehicleGuidMask[3]) vehicleGuidBytes[3] = (byte)(packet.ReadUInt8() ^ 1); byte _88 = packet.ReadUInt8(); if (vehicleGuidMask[7]) vehicleGuidBytes[7] = (byte)(packet.ReadUInt8() ^ 1); vehiclevector.O = packet.ReadFloat(); vehiclevector.Z = packet.ReadFloat(); vehiclevector.Y = packet.ReadFloat(); if (vehicleGuidMask[6]) vehicleGuidBytes[6] = (byte)(packet.ReadUInt8() ^ 1); uint _23 = packet.ReadUInt32(); if (vehicleGuidMask[2]) vehicleGuidBytes[2] = (byte)(packet.ReadUInt8() ^ 1); if ( vehicleUnknown2 ) uint _27 = packet.ReadUInt32(); if (vehicleGuidMask[1]) vehicleGuidBytes[1] = (byte)(packet.ReadUInt8() ^ 1); }*/ // return if (HasPitch) packet.ReadFloat(); // float _28 /*if (movementValues.IsInterpolated) { if (movementValues.IsInterpolated2) { float _33 = packet.ReadFloat(); float _34 = packet.ReadFloat(); float _35 = packet.ReadFloat(); } float _ 31 = packet.ReadFloat(); uint _30 = packet.ReadUInt32(); }*/ if (movementValues.HasRotation) vector.O = packet.ReadFloat(); if (HasTime) movementValues.Time = packet.ReadUInt32(); if (HasSplineElevation) packet.ReadFloat(); if (movementValues.IsAlive) movementValues.Time = packet.ReadUInt32(); var guid = BitConverter.ToUInt64(guidBytes, 0); HandleMoveUpdate(guid, movementValues, vector); }
public static void HandleForceWalkSpeedChangeAck(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() { Y = packet.ReadFloat(), Z = packet.ReadFloat(), X = packet.ReadFloat() }; uint zeroes = packet.ReadUInt32(); float walkspeed = packet.ReadFloat(); bool Unknown2 = BitUnpack.GetBit(); guidMask[6] = BitUnpack.GetBit(); bool HasPitch = !BitUnpack.GetBit(); movementValues.IsTransport = BitUnpack.GetBit(); bool Unknown3 = BitUnpack.GetBit(); guidMask[1] = BitUnpack.GetBit(); guidMask[2] = BitUnpack.GetBit(); movementValues.IsAlive = !BitUnpack.GetBit(); bool HasTime = !BitUnpack.GetBit(); uint counter = BitUnpack.GetBits<uint>(24); guidMask[0] = BitUnpack.GetBit(); movementValues.HasMovementFlags = !BitUnpack.GetBit(); guidMask[5] = BitUnpack.GetBit(); bool Unknown4 = BitUnpack.GetBit(); bool HasSplineElevation = !BitUnpack.GetBit(); guidMask[3] = BitUnpack.GetBit(); movementValues.HasRotation = !BitUnpack.GetBit(); movementValues.HasMovementFlags2 = !BitUnpack.GetBit(); guidMask[7] = BitUnpack.GetBit(); guidMask[4] = BitUnpack.GetBit(); bool Unknown = BitUnpack.GetBit(); /*if (movementValues.IsTransport) { vehicleGuidMask[2] = BitUnpack.GetBit(); vehicleGuidMask[5] = BitUnpack.GetBit(); vehicleGuidMask[4] = BitUnpack.GetBit(); vehicleGuidMask[1] = BitUnpack.GetBit(); vehicleGuidMask[0] = BitUnpack.GetBit(); vehicleGuidMask[3] = BitUnpack.GetBit(); vehicleGuidMask[7] = BitUnpack.GetBit(); vehicleGuidMask[6] = BitUnpack.GetBit(); bool vehicleUnknown1 = BitUnpack.GetBit(); bool vehicleUnknown2 = BitUnpack.GetBit(); }*/ if (movementValues.HasMovementFlags) movementValues.MovementFlags = (MovementFlag)BitUnpack.GetBits<uint>(30); /*if (movementValues.IsInterpolated) movementValues.IsInterpolated2 = BitUnpack.GetBit();*/ if (movementValues.HasMovementFlags2) movementValues.MovementFlags2 = (MovementFlag2)BitUnpack.GetBits<uint>(13); if (guidMask[3]) guidBytes[3] = (byte)(packet.ReadUInt8() ^ 1); for (int i = 0; i < counter; i++) packet.ReadUInt32(); if (guidMask[0]) guidBytes[0] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[4]) guidBytes[4] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[1]) guidBytes[1] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[2]) guidBytes[2] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[7]) guidBytes[7] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[6]) guidBytes[6] = (byte)(packet.ReadUInt8() ^ 1); if (guidMask[5]) guidBytes[5] = (byte)(packet.ReadUInt8() ^ 1); /*if (movementValues.IsTransport) { Vector4 vehiclevector = new Vector4(); if (vehicleGuidMask[7]) vehicleGuidBytes[7] = (byte)(packet.ReadUInt8() ^ 1); if (vehicleGuidMask[5]) vehicleGuidBytes[5] = (byte)(packet.ReadUInt8() ^ 1); vehiclevector.Z = packet.ReadFloat(); if (vehicleGuidMask[3]) vehicleGuidBytes[3] = (byte)(packet.ReadUInt8() ^ 1); byte _88 = packet.ReadUInt8(); // (BYTE)DATA[88] if (vehicleGuidMask[1]) vehicleGuidBytes[1] = (byte)(packet.ReadUInt8() ^ 1); if (vehicleGuidMask[0]) vehicleGuidBytes[0] = (byte)(packet.ReadUInt8() ^ 1); vehiclevector.X = packet.ReadFloat(); if (vehicleGuidMask[4]) vehicleGuidBytes[4] = (byte)(packet.ReadUInt8() ^ 1); if ( vehicleUnknown1 ) packet.ReadUInt32(); vehiclevector.Y = packet.ReadFloat(); if (vehicleGuidMask[6]) vehicleGuidBytes[6] = (byte)(packet.ReadUInt8() ^ 1); uint _23 = packet.ReadUInt32(); if (vehicleGuidMask[2]) vehicleGuidBytes[2] = (byte)(packet.ReadUInt8() ^ 1); if ( vehicleUnknown2 ) packet.ReadUInt32(); vehiclevector.O = packet.ReadFloat(); } if (movementValues.IsInterpolated) { float _31 = packet.ReadFloat(); if (movementValues.IsInterpolated2) { float _34 = packet.ReadFloat(); float _33 = packet.ReadFloat(); float _35 = packet.ReadFloat(); } uint _30 = packet.ReadUInt32(); }*/ if (HasTime) movementValues.Time = packet.ReadUInt32(); if (movementValues.IsAlive) movementValues.Time = packet.ReadUInt32(); if (HasPitch) packet.ReadFloat(); if (movementValues.HasRotation) vector.O = packet.ReadFloat(); if (HasSplineElevation) packet.ReadFloat(); var guid = BitConverter.ToUInt64(guidBytes, 0); HandleMoveUpdate(guid, movementValues, vector); Log.Message(LogType.DEBUG, "Character with Guid: {0}, AccountId: {1} changed walk speed to {2}", guid, session.Account.Id, walkspeed); }
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 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 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 HandleAuthResponse(ref PacketReader packet, WorldClass session) { BitUnpack arg_28_0 = new BitUnpack(packet); packet.Skip(23); Globals.ClientSalt = packet.ReadBytes(16u); packet.ReadBytes(24u); arg_28_0.GetBit(); packet.ReadBytes(AuthenticationHandler.smethod_1(packet)); while (true) { IL_921: uint arg_82F_0 = 2017539580u; while (true) { uint num; switch ((num = (arg_82F_0 ^ 973532324u)) % 57u) { case 0u: TimeHandler.HandleSetTimezoneInformation(ref session); arg_82F_0 = (num * 3644867839u ^ 4102176202u); continue; case 1u: { PacketWriter packetWriter; packetWriter.WriteUInt32(0u); arg_82F_0 = (num * 3925958146u ^ 429357566u); continue; } case 2u: { BitPack bitPack; bitPack.Flush(); PacketWriter packetWriter; packetWriter.WriteUInt32(0u); arg_82F_0 = (num * 3843609867u ^ 274333066u); continue; } case 3u: { PacketWriter packetWriter; byte[,] array; int num2; packetWriter.WriteUInt8(array[num2, 1]); arg_82F_0 = (num * 2139226297u ^ 222787957u); continue; } case 4u: { int num3 = 0; arg_82F_0 = (num * 1275993637u ^ 3289780354u); continue; } case 5u: { PacketWriter packetWriter; packetWriter.WriteUInt32(0u); BitPack bitPack; bool flag; bitPack.Write <bool>(flag); bool bit; bitPack.Write <bool>(bit); bitPack.Flush(); arg_82F_0 = (num * 190331667u ^ 3544293151u); continue; } case 6u: { PacketWriter packetWriter; int num3; byte[,] array2; packetWriter.WriteUInt8(array2[num3, 0]); arg_82F_0 = 979003297u; continue; } case 7u: { SHA256Managed hashAlgorithm_; byte[] array3; AuthenticationHandler.smethod_4(hashAlgorithm_, array3, array3.Length >> 1, array3.Length - (array3.Length >> 1)); SHA256Managed hashAlgorithm_2; SHA256Managed hashAlgorithm_3; AuthenticationHandler.smethod_3(hashAlgorithm_2, AuthenticationHandler.smethod_5(hashAlgorithm_3), 0, 32, AuthenticationHandler.smethod_5(hashAlgorithm_3), 0); arg_82F_0 = (num * 4247721102u ^ 2164875264u); continue; } case 8u: goto IL_921; case 9u: { int num3; byte[,] array2; arg_82F_0 = ((num3 < AuthenticationHandler.smethod_9(array2) / 2) ? 942732371u : 402681424u); continue; } case 10u: { PacketWriter packetWriter; packetWriter.WriteUInt32(0u); arg_82F_0 = (num * 1272726928u ^ 3573012072u); continue; } case 11u: { int num4; arg_82F_0 = ((num4 != 32) ? 1613600137u : 94715230u); continue; } case 12u: { SHA256Managed hashAlgorithm_; SHA256Managed hashAlgorithm_2; AuthenticationHandler.smethod_4(hashAlgorithm_2, AuthenticationHandler.smethod_5(hashAlgorithm_), 0, 32); AuthenticationHandler.sha2_3_grml = AuthenticationHandler.smethod_5(hashAlgorithm_2); int num4 = 0; int num5 = 0; arg_82F_0 = (num * 1594528258u ^ 4035022218u); continue; } case 13u: arg_82F_0 = (num * 3592674904u ^ 3437742173u); continue; case 14u: AuthenticationHandler.HandleConnectTo(session, 3724, 1, null); arg_82F_0 = (num * 4096365546u ^ 2720471261u); continue; case 15u: { bool bit = false; PacketWriter packetWriter = new PacketWriter(ServerMessage.AuthResponse, true); arg_82F_0 = (num * 1668503324u ^ 4008787019u); continue; } case 16u: { int num4; arg_82F_0 = ((num4 < 40) ? 1976385685u : 1159001732u); continue; } case 17u: { PacketWriter packetWriter; packetWriter.WriteUInt32(0u); arg_82F_0 = (num * 3445906520u ^ 4063066220u); continue; } case 18u: { BitPack bitPack; bitPack.Write <int>(0); bitPack.Write <int>(0); arg_82F_0 = (num * 621848300u ^ 3406194050u); continue; } case 19u: { PacketWriter packetWriter; packetWriter.WriteUInt32(0u); arg_82F_0 = (num * 3867729530u ^ 1908424397u); continue; } case 20u: { PacketWriter packetWriter; packetWriter.WriteUInt32(0u); arg_82F_0 = (num * 1394835192u ^ 145004486u); continue; } case 21u: { PacketWriter packetWriter; byte[,] array2; packetWriter.WriteInt32(AuthenticationHandler.smethod_9(array2) / 2); byte[,] array; packetWriter.WriteInt32(AuthenticationHandler.smethod_9(array) / 2); arg_82F_0 = (num * 3125389306u ^ 6579303u); continue; } case 22u: { byte[,] array; int num2; arg_82F_0 = ((num2 < AuthenticationHandler.smethod_9(array) / 2) ? 248887578u : 276684735u); continue; } case 23u: { int num4; num4++; int num5; num5++; arg_82F_0 = (num * 2780937424u ^ 1515612061u); continue; } case 24u: { PacketWriter packetWriter; packetWriter.WriteUInt32(0u); packetWriter.WriteUInt32(0u); arg_82F_0 = (num * 192068700u ^ 4062459581u); continue; } case 25u: { byte[,] expr_4C2 = new byte[12, 2]; AuthenticationHandler.smethod_8(expr_4C2, fieldof(< PrivateImplementationDetails >.struct7_0).FieldHandle); byte[,] array = expr_4C2; byte[,] expr_4D7 = new byte[19, 2]; AuthenticationHandler.smethod_8(expr_4D7, fieldof(< PrivateImplementationDetails >.B1151C6C80B16E10C2CAD0E6524E20DB89985020).FieldHandle); byte[,] array2 = expr_4D7; arg_82F_0 = (num * 775829900u ^ 1086551519u); continue; } case 26u: Manager.WorldMgr.SendHotfixes(session); arg_82F_0 = (num * 2297567052u ^ 3529457580u); continue; case 27u: { BitPack bitPack; bitPack.Write <int>(0); arg_82F_0 = (num * 2838081966u ^ 1401284309u); continue; } case 28u: { BitPack bitPack; bitPack.Write <int>(0); arg_82F_0 = (num * 1276988104u ^ 1332711413u); continue; } case 29u: new PacketWriter(ServerMessage.EnableCrypt, false); session.Account = new Account { Id = 1, Email = Module.smethod_35 <string>(2737471542u), PasswordVerifier = Module.smethod_36 <string>(1789483827u), Salt = Module.smethod_36 <string>(2533110280u), IP = "", SessionKey = "", SecurityFlags = 0, OS = Module.smethod_36 <string>(2605452825u), Expansion = 5, IsOnline = false }; arg_82F_0 = (num * 3099364030u ^ 778753807u); continue; case 30u: { PacketWriter packetWriter; packetWriter.WriteUInt8(6); arg_82F_0 = (num * 960037049u ^ 4251590658u); continue; } case 31u: { int num3; num3++; arg_82F_0 = (num * 2647826660u ^ 3081572510u); continue; } case 32u: { int num5 = 0; arg_82F_0 = (num * 2855624283u ^ 1934999727u); continue; } case 33u: { PacketWriter packetWriter; session.Send(ref packetWriter); arg_82F_0 = 394845639u; continue; } case 34u: { PacketWriter packetWriter; BitPack bitPack = new BitPack(packetWriter, 0uL, 0uL, 0uL, 0uL); arg_82F_0 = (num * 3839928679u ^ 2674270183u); continue; } case 35u: { BitPack bitPack; bitPack.Write <int>(0); arg_82F_0 = (num * 1275983207u ^ 2624941272u); continue; } case 36u: new PacketWriter(ServerMessage.SuspendComms, true).WriteUInt32(20u); arg_82F_0 = (num * 3412051023u ^ 3748987744u); continue; case 37u: { PacketWriter packetWriter; byte[,] array; int num2; packetWriter.WriteUInt8(array[num2, 0]); arg_82F_0 = 1152594217u; continue; } case 38u: { BitPack bitPack; bitPack.Write <int>(0); arg_82F_0 = (num * 1357121348u ^ 1027085582u); continue; } case 39u: { SHA256Managed hashAlgorithm_2 = AuthenticationHandler.smethod_6(); byte[] array3; SHA256Managed hashAlgorithm_3; AuthenticationHandler.smethod_4(hashAlgorithm_3, array3, 0, array3.Length >> 1); arg_82F_0 = (num * 3349724847u ^ 3826309419u); continue; } case 40u: { bool flag = true; arg_82F_0 = (num * 2469044217u ^ 389509509u); continue; } case 41u: { int num4; int num5; AuthenticationHandler.sessionKey[num4] = AuthenticationHandler.sha2_3_grml[num5]; arg_82F_0 = 121248238u; continue; } case 42u: { SHA256Managed hashAlgorithm_2; AuthenticationHandler.sha2_3_grml = AuthenticationHandler.smethod_5(hashAlgorithm_2); arg_82F_0 = (num * 3186781206u ^ 568291510u); continue; } case 43u: { SHA256Managed hashAlgorithm_2; AuthenticationHandler.smethod_7(hashAlgorithm_2); SHA256Managed hashAlgorithm_3; AuthenticationHandler.smethod_3(hashAlgorithm_2, AuthenticationHandler.smethod_5(hashAlgorithm_3), 0, 32, AuthenticationHandler.smethod_5(hashAlgorithm_3), 0); arg_82F_0 = (num * 273351295u ^ 2423198895u); continue; } case 44u: { PacketWriter packetWriter; int num3; byte[,] array2; packetWriter.WriteUInt8(array2[num3, 1]); arg_82F_0 = (num * 3258273611u ^ 1239887723u); continue; } case 46u: { HMACSHA256 expr_182 = AuthenticationHandler.smethod_2(Globals.SessionKey); AuthenticationHandler.smethod_3(expr_182, Globals.ServerSalt, 0, Globals.ServerSalt.Length, Globals.ServerSalt, 0); AuthenticationHandler.smethod_3(expr_182, Globals.ClientSalt, 0, Globals.ClientSalt.Length, Globals.ClientSalt, 0); AuthenticationHandler.smethod_4(expr_182, AuthenticationHandler.arr1, 0, AuthenticationHandler.arr1.Length); byte[] array3 = AuthenticationHandler.smethod_5(expr_182); SHA256Managed hashAlgorithm_3 = AuthenticationHandler.smethod_6(); SHA256Managed hashAlgorithm_ = AuthenticationHandler.smethod_6(); arg_82F_0 = (num * 1844584669u ^ 1891453460u); continue; } case 47u: { PacketWriter packetWriter; packetWriter.WriteUInt32(0u); arg_82F_0 = (num * 1008232628u ^ 30771472u); continue; } case 48u: { int num2 = 0; arg_82F_0 = (num * 1707978014u ^ 2368748458u); continue; } case 49u: { SHA256Managed hashAlgorithm_2; AuthenticationHandler.smethod_3(hashAlgorithm_2, AuthenticationHandler.sha2_3_grml, 0, 32, AuthenticationHandler.sha2_3_grml, 0); SHA256Managed hashAlgorithm_; AuthenticationHandler.smethod_4(hashAlgorithm_2, AuthenticationHandler.smethod_5(hashAlgorithm_), 0, 32); arg_82F_0 = (num * 1428097193u ^ 1748239185u); continue; } case 50u: { BitPack bitPack; bitPack.Write <int>(0); arg_82F_0 = (num * 2377469058u ^ 4212942142u); continue; } case 51u: { SHA256Managed hashAlgorithm_2; AuthenticationHandler.smethod_3(hashAlgorithm_2, AuthenticationHandler.sha2_3_grml, 0, 32, AuthenticationHandler.sha2_3_grml, 0); arg_82F_0 = (num * 116417243u ^ 3699589835u); continue; } case 52u: { bool flag; arg_82F_0 = (((!flag) ? 1888186652u : 1737280166u) ^ num * 1515350310u); continue; } case 53u: { PacketWriter packetWriter; packetWriter.WriteUInt8(6); arg_82F_0 = (num * 200448416u ^ 3957963237u); continue; } case 54u: { BitPack bitPack; bitPack.Flush(); arg_82F_0 = (num * 2761573231u ^ 325309565u); continue; } case 55u: arg_82F_0 = (num * 1571901877u ^ 4021021157u); continue; case 56u: { int num2; num2++; arg_82F_0 = (num * 3035465689u ^ 1114317311u); continue; } } return; } } }