Beispiel #1
0
        public static void HandleSendKnownSpells(ref WorldClass session)
        {
            Character pChar = session.Character;

            var specializationSpells = SpecializationMgr.GetSpecializationSpells(pChar);
            var specializationSpellCount = ((specializationSpells != null) ? specializationSpells.Count : 0);

            var talentSpells = SpecializationMgr.GetTalentSpells(pChar, pChar.ActiveSpecGroup);
            var talentSpellCount = ((talentSpells != null) ? talentSpells.Count : 0);

            int count = pChar.SpellList.Count + specializationSpellCount + talentSpellCount;

            PacketWriter writer = new PacketWriter(ServerMessage.SendKnownSpells);
            BitPack BitPack = new BitPack(writer);

            BitPack.Write(1);
            BitPack.Write(count, 22);
            BitPack.Flush();

            pChar.SpellList.ForEach(spell =>
                writer.WriteUInt32(spell.SpellId));

            if (specializationSpells != null)
                specializationSpells.ForEach(spell => writer.WriteUInt32(spell.Spell));

            if (talentSpells != null)
                talentSpells.ForEach(spell => writer.WriteUInt32(spell));

            session.Send(ref writer);
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        public static void HandleMoveSetCanFly(ref WorldClass session)
        {
            PacketWriter setCanFly = new PacketWriter(JAMCMessage.MoveSetCanFly);
            BitPack BitPack = new BitPack(setCanFly, session.Character.Guid);

            BitPack.WriteGuidMask(7, 3, 1, 5, 0, 6, 2, 4);
            BitPack.Flush();

            setCanFly.WriteUInt32(0);

            BitPack.WriteGuidBytes(2, 6, 7, 1, 3, 4, 6, 0);
            session.Send(setCanFly);
        }
Beispiel #4
0
        public static void HandleLearnedSpells(ref WorldClass session, List<uint> newSpells)
        {
            PacketWriter writer = new PacketWriter(ServerMessage.LearnedSpells);
            BitPack BitPack = new BitPack(writer);

            BitPack.Write<int>(newSpells.Count, 22);
            BitPack.Write(0);
            BitPack.Flush();

            for (int i = 0; i < newSpells.Count; i++)
                writer.WriteUInt32(newSpells[i]);

            session.Send(ref writer);
        }
Beispiel #5
0
        public static PacketWriter HandleDestroyObject(ref WorldClass session, ulong guid)
        {
            PacketWriter destroyObject = new PacketWriter(ServerMessage.DestroyObject);
            BitPack BitPack = new BitPack(destroyObject, guid);

            BitPack.WriteGuidMask(1, 6, 5, 7, 4, 2, 0, 3);
            BitPack.Write(0);

            BitPack.Flush();

            BitPack.WriteGuidBytes(7, 2, 6, 1, 3, 7, 5, 0);

            return destroyObject;
        }
Beispiel #6
0
        public static void HandleMoveSetCanFly(ref WorldClass session)
        {
            PacketWriter moveSetCanFly = new PacketWriter(ServerMessage.MoveSetCanFly);
            BitPack BitPack = new BitPack(moveSetCanFly, session.Character.Guid);

            BitPack.WriteGuidMask(5, 3, 0, 2, 4, 1, 6, 7);
            BitPack.Flush();

            BitPack.WriteGuidBytes(1, 3, 5, 0, 7, 2, 4, 6);

            moveSetCanFly.WriteUInt32(0);

            session.Send(ref moveSetCanFly);
        }
        public static PacketWriter HandleDestroyObject(ref WorldClass session, ulong guid, bool animation = false)
        {
            PacketWriter destroyObject = new PacketWriter(ServerMessage.DestroyObject);
            BitPack BitPack = new BitPack(destroyObject, guid);

            BitPack.WriteGuidMask(7, 2, 6, 3, 1, 4);
            BitPack.Write(animation);
            BitPack.WriteGuidMask(5, 0);

            BitPack.Flush();

            BitPack.WriteGuidBytes(4, 3, 2, 7, 0, 1, 6, 5);

            return destroyObject;
        }
Beispiel #8
0
        public static void HandleMoveSetRunSpeed(ref WorldClass session, float speed = 7f)
        {
            PacketWriter setRunSpeed = new PacketWriter(JAMCMessage.MoveSetRunSpeed);
            BitPack BitPack = new BitPack(setRunSpeed, session.Character.Guid);

            BitPack.WriteGuidMask(0, 4, 1, 6, 3, 5, 7, 2);
            BitPack.Flush();

            setRunSpeed.WriteFloat(speed);
            BitPack.WriteGuidBytes(7);
            setRunSpeed.WriteUInt32(0);
            BitPack.WriteGuidBytes(3, 6, 0, 4, 1, 5, 2);

            session.Send(setRunSpeed);
        }
Beispiel #9
0
        public static void HandleSendKnownSpells(ref WorldClass session)
        {
            Character pChar = session.Character;

            PacketWriter writer = new PacketWriter(JAMCMessage.SendKnownSpells);
            BitPack BitPack = new BitPack(writer);

            BitPack.Write<uint>((uint)pChar.SpellList.Count, 24);
            BitPack.Write(1);
            BitPack.Flush();

            pChar.SpellList.ForEach(spell =>
                writer.WriteUInt32(spell.SpellId));

            session.Send(ref writer);
        }
Beispiel #10
0
        public static void HandleLogoutRequest(ref PacketReader packet, WorldClass session)
        {
            PacketWriter logoutResponse = new PacketWriter(ServerMessage.LogoutResponse);
            BitPack BitPack = new BitPack(logoutResponse);

            logoutResponse.WriteUInt8(0);
            BitPack.Write(0);
            BitPack.Flush();

            session.Send(ref logoutResponse);

            Task.Delay(20000).ContinueWith(_ => HandleLogoutComplete(session), (cts = new CancellationTokenSource()).Token);

            session.Character.setStandState(1);

            MoveHandler.HandleMoveRoot(session);
        }
Beispiel #11
0
        public static void HandleMoveSetFlightSpeed(ref WorldClass session, float speed = 7f)
        {
            PacketWriter setFlightSpeed = new PacketWriter(ServerMessage.MoveSetFlightSpeed);
            BitPack BitPack = new BitPack(setFlightSpeed, session.Character.Guid);

            BitPack.WriteGuidMask(5, 4, 2, 1, 7, 6, 3, 0);
            BitPack.Flush();

            setFlightSpeed.WriteUInt32(0);

            BitPack.WriteGuidBytes(5, 7);

            setFlightSpeed.WriteFloat(speed);

            BitPack.WriteGuidBytes(1, 2, 3, 6, 0, 4);

            session.Send(ref setFlightSpeed);
        }
Beispiel #12
0
        public static void SendSendKnownSpells()
        {
            Character pChar = GetSession().Character;

            if (pChar.SpellList.Count == 0)
                SpellMgr.LoadSpells();

            PacketWriter writer = new PacketWriter(LegacyMessage.SendKnownSpells);
            BitPack BitPack = new BitPack(writer);

            BitPack.Write(1);
            BitPack.Write<uint>((uint)pChar.SpellList.Count, 24);
            BitPack.Flush();

            pChar.SpellList.ForEach(spell =>
                writer.WriteUInt32(spell.SpellId));

            GetSession().Send(writer);
        }
Beispiel #13
0
        public static void HandleMoveSetRunSpeed(ref WorldClass session, float speed = 7f)
        {
            PacketWriter setRunSpeed = new PacketWriter(ServerMessage.MoveSetRunSpeed);
            BitPack BitPack = new BitPack(setRunSpeed, session.Character.Guid);

            BitPack.WriteGuidMask(6, 1, 2, 5, 0, 3, 7, 4);
            BitPack.Flush();

            BitPack.WriteGuidBytes(3, 0, 1, 5);

            setRunSpeed.WriteFloat(speed);

            BitPack.WriteGuidBytes(7, 4, 2);

            setRunSpeed.WriteUInt32(0);

            BitPack.WriteGuidBytes(6);

            session.Send(ref setRunSpeed);
        }
Beispiel #14
0
        public static void HandleRealmSplit(ref PacketReader packet, WorldClass session)
        {
            uint realmSplitState = 0;
            var date = "01/01/01";

            PacketWriter realmSplit = new PacketWriter(ServerMessage.RealmSplit);
            BitPack BitPack = new BitPack(realmSplit);

            realmSplit.WriteUInt32(packet.Read<uint>());
            realmSplit.WriteUInt32(realmSplitState);

            BitPack.Write(date.Length, 7);

            BitPack.Flush();

            realmSplit.WriteString(date);

            session.Send(ref realmSplit);

            AddonHandler.WriteAddonData(session);
        }
Beispiel #15
0
        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);
            }
        }
Beispiel #16
0
        public static void HandleEnumCharactersResult(ref PacketReader packet, ref WorldClass session)
        {
            // Set existing character from last world session to null
            session.Character = null;

            DB.Realms.Execute("UPDATE accounts SET online = 1 WHERE id = ?", session.Account.Id);

            SQLResult result = DB.Characters.Select("SELECT * FROM characters WHERE accountid = ?", session.Account.Id);

            PacketWriter enumCharacters = new PacketWriter(ServerMessage.EnumCharactersResult);
            BitPack      BitPack        = new BitPack(enumCharacters);

            BitPack.Write(0, 21);
            BitPack.Write(result.Count, 16);

            if (result.Count != 0)
            {
                for (int c = 0; c < result.Count; c++)
                {
                    string name           = result.Read <String>(c, "Name");
                    bool   loginCinematic = result.Read <Boolean>(c, "LoginCinematic");

                    BitPack.Guid      = result.Read <UInt64>(c, "Guid");
                    BitPack.GuildGuid = result.Read <UInt64>(c, "GuildGuid");

                    BitPack.WriteGuildGuidMask(3, 2);
                    BitPack.WriteGuidMask(7, 5);
                    BitPack.Write((uint)UTF8Encoding.UTF8.GetBytes(name).Length, 6);
                    BitPack.WriteGuildGuidMask(0, 4);
                    BitPack.WriteGuidMask(3, 4, 6);
                    BitPack.WriteGuildGuidMask(1);
                    BitPack.WriteGuidMask(1, 2);
                    BitPack.WriteGuildGuidMask(5, 7);
                    BitPack.Write(loginCinematic);
                    BitPack.WriteGuildGuidMask(6);
                    BitPack.WriteGuidMask(0);
                }

                BitPack.Write(1);
                BitPack.Flush();

                for (int c = 0; c < result.Count; c++)
                {
                    string name = result.Read <String>(c, "Name");
                    BitPack.Guid      = result.Read <UInt64>(c, "Guid");
                    BitPack.GuildGuid = result.Read <UInt64>(c, "GuildGuid");

                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "HairStyle"));

                    BitPack.WriteGuildGuidBytes(0);
                    BitPack.WriteGuidBytes(1, 3);

                    enumCharacters.WriteFloat(result.Read <Single>(c, "Y"));

                    BitPack.WriteGuidBytes(4);

                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "FacialHair"));
                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "CharacterFlags"));

                    // Not implanted
                    for (int j = 0; j < 23; j++)
                    {
                        enumCharacters.WriteUInt32(0);
                        enumCharacters.WriteUInt32(0);
                        enumCharacters.WriteUInt8(0);
                    }

                    BitPack.WriteGuildGuidBytes(1);

                    enumCharacters.WriteFloat(result.Read <Single>(c, "Z"));

                    BitPack.WriteGuildGuidBytes(6);

                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "PetDisplayId"));
                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "Zone"));

                    BitPack.WriteGuildGuidBytes(5);

                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "Face"));
                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "Class"));

                    BitPack.WriteGuildGuidBytes(2);
                    BitPack.WriteGuidBytes(2, 5, 7, 0);

                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "Level"));
                    enumCharacters.WriteUInt8(0);
                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "CustomizeFlags"));
                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "PetLevel"));
                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "Map"));
                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "PetFamily"));
                    enumCharacters.WriteFloat(result.Read <Single>(c, "X"));

                    BitPack.WriteGuildGuidBytes(4);

                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "Skin"));

                    BitPack.WriteGuidBytes(6);

                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "HairColor"));

                    BitPack.WriteGuildGuidBytes(7);

                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "Gender"));

                    BitPack.WriteGuildGuidBytes(3);

                    enumCharacters.WriteString(name);
                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "Race"));
                }
            }
            else
            {
                BitPack.Write(1);
                BitPack.Flush();
            };

            session.Send(ref enumCharacters);
        }
Beispiel #17
0
        public static void HandleMoveSetWalkSpeed(ref WorldClass session, float speed = 2.5f)
        {
            PacketWriter setWalkSpeed = new PacketWriter(ServerMessage.MoveSetWalkSpeed);
            BitPack BitPack = new BitPack(setWalkSpeed, session.Character.Guid);

            setWalkSpeed.WriteFloat(speed);
            setWalkSpeed.WriteUInt32(0);

            BitPack.WriteGuidMask(5, 4, 3, 1, 0, 7, 2, 6);

            BitPack.Flush();

            BitPack.WriteGuidBytes(7, 5, 3, 2, 4, 1, 6, 0);

            session.Send(ref setWalkSpeed);
        }
Beispiel #18
0
        public static void HandleMoveUpdate(ulong guid, ObjectMovementValues movementValues, Vector4 vector)
        {
            PacketWriter moveUpdate = new PacketWriter(ServerMessage.MoveUpdate);
            BitPack      BitPack    = new BitPack(moveUpdate, guid);

            BitPack.WriteGuidMask(0);

            BitPack.Write(!movementValues.HasRotation);
            BitPack.Write(!movementValues.HasMovementFlags2);

            BitPack.WriteGuidMask(5);

            if (movementValues.HasMovementFlags2)
            {
                BitPack.Write((uint)movementValues.MovementFlags2, 13);
            }

            BitPack.Write(!movementValues.HasMovementFlags);
            BitPack.Write(0);
            BitPack.Write <uint>(0, 22);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(0);

            BitPack.WriteGuidMask(7);

            BitPack.Write(movementValues.IsTransport);
            BitPack.Write(1);

            BitPack.WriteGuidMask(4, 1);

            BitPack.Write(movementValues.IsFallingOrJumping);

            if (movementValues.HasMovementFlags)
            {
                BitPack.Write((uint)movementValues.MovementFlags, 30);
            }

            BitPack.Write(movementValues.Time == 0);

            if (movementValues.IsFallingOrJumping)
            {
                BitPack.Write(movementValues.HasJumpData);
            }

            BitPack.WriteGuidMask(2, 3, 6);

            BitPack.Flush();

            BitPack.WriteGuidBytes(6);

            if (movementValues.Time != 0)
            {
                moveUpdate.WriteUInt32(movementValues.Time);
            }

            if (movementValues.IsFallingOrJumping)
            {
                moveUpdate.WriteFloat(movementValues.JumpVelocity);

                if (movementValues.HasJumpData)
                {
                    moveUpdate.WriteFloat(movementValues.Cos);
                    moveUpdate.WriteFloat(movementValues.CurrentSpeed);
                    moveUpdate.WriteFloat(movementValues.Sin);
                }

                moveUpdate.WriteUInt32(movementValues.FallTime);
            }

            moveUpdate.WriteFloat(vector.X);

            BitPack.WriteGuidBytes(1);

            moveUpdate.WriteFloat(vector.Y);

            BitPack.WriteGuidBytes(2, 7, 5);

            moveUpdate.WriteFloat(vector.Z);

            BitPack.WriteGuidBytes(0, 4, 3);

            if (movementValues.HasRotation)
            {
                moveUpdate.WriteFloat(vector.O);
            }

            var session = WorldMgr.GetSession(guid);

            if (session != null)
            {
                Character pChar = session.Character;

                ObjectMgr.SetPosition(ref pChar, vector, false);
                WorldMgr.SendToInRangeCharacter(pChar, moveUpdate);
            }
        }
Beispiel #19
0
        public static void HandleUpdateActionButtons(ref WorldClass session)
        {
            var pChar = session.Character;

            PacketWriter updateActionButtons = new PacketWriter(ServerMessage.UpdateActionButtons);
            BitPack BitPack = new BitPack(updateActionButtons);

            const int buttonCount = 132;
            var buttons = new byte[buttonCount][];

            byte[] buttonMask = { 0, 1, 3, 4, 6, 7, 2, 5 };
            byte[] buttonBytes = { 5, 2, 0, 1, 3, 6, 4, 7 };

            var actions = ActionMgr.GetActionButtons(pChar, pChar.ActiveSpecGroup);

            for (int i = 0; i < buttonCount; i++)
                if (actions.Any(action => action.SlotId == i))
                    buttons[i] = BitConverter.GetBytes((ulong)actions.Where(action => action.SlotId == i).Select(action => action.Action).First());
                else
                    buttons[i] = new byte[8];

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < buttonCount; j++)
                {
                    if (i < 8)
                        BitPack.Write(buttons[j][buttonMask[i]]);
                    else if (i < 16)
                    {
                        BitPack.Flush();

                        if (buttons[j][buttonBytes[i - 8]] != 0)
                            updateActionButtons.WriteUInt8((byte)(buttons[j][buttonBytes[i - 8]] ^ 1));
                    }
                }
            }

            // 0 - Initial packet on Login (no verification) / 1 - Verify spells on switch (Spec change) / 2 - Clear Action Buttons (Spec change)
            updateActionButtons.WriteInt8(0);

            session.Send(ref updateActionButtons);
        }
Beispiel #20
0
        public static void HandleGenerateRandomCharacterName(ref PacketReader packet, WorldClass session)
        {
            var race = packet.ReadByte();
            var gender = packet.ReadByte();

            List<string> names = CliDB.NameGen.Where(n => n.Race == race && n.Gender == gender).Select(n => n.Name).ToList();
            Random rand = new Random(Environment.TickCount);

            string NewName;
            SQLResult result;
            do
            {
                NewName = names[rand.Next(names.Count)];
                result = DB.Characters.Select("SELECT * FROM characters WHERE name = ?", NewName);
            }
            while (result.Count != 0);

            PacketWriter generateRandomCharacterNameResult = new PacketWriter(ServerMessage.GenerateRandomCharacterNameResult);
            BitPack BitPack = new BitPack(generateRandomCharacterNameResult);

            BitPack.Write(1);
            BitPack.Write(NewName.Length, 6);

            BitPack.Flush();

            generateRandomCharacterNameResult.WriteString(NewName);
            session.Send(ref generateRandomCharacterNameResult);
        }
Beispiel #21
0
        public static void HandleUpdateObjectCreateItem(SmartGuid guid, Item item2, ref WorldClass session)
        {
            int id = item2.Id;

            while (true)
            {
IL_1E2:
                uint arg_1B9_0 = 2511239562u;
                while (true)
                {
                    uint num;
                    switch ((num = (arg_1B9_0 ^ 4026668597u)) % 7u)
                    {
                    case 0u:
                        goto IL_1E2;

                    case 1u:
                    {
                        PacketWriter packetWriter = new PacketWriter(ServerMessage.ObjectUpdate, true);
                        arg_1B9_0 = (num * 930516696u ^ 722285656u);
                        continue;
                    }

                    case 2u:
                    {
                        WorldObject character = session.Character;
                        arg_1B9_0 = (num * 3409398618u ^ 278691816u);
                        continue;
                    }

                    case 3u:
                    {
                        PacketWriter packetWriter;
                        uint         data = (uint)ObjectHandler.smethod_1(ObjectHandler.smethod_0(packetWriter)) - 17u;
                        arg_1B9_0 = (num * 3608865686u ^ 1852252423u);
                        continue;
                    }

                    case 4u:
                    {
                        PacketWriter packetWriter;
                        uint         data;
                        packetWriter.WriteUInt32Pos(data, 13);
                        session.Send(ref packetWriter);
                        arg_1B9_0 = (num * 1567485334u ^ 1076014059u);
                        continue;
                    }

                    case 5u:
                    {
                        PacketWriter packetWriter;
                        BitPack      arg_6D_0 = new BitPack(packetWriter, 0uL, 0uL, 0uL, 0uL);
                        packetWriter.WriteUInt32(1u);
                        WorldObject character;
                        packetWriter.WriteUInt16((ushort)character.Map);
                        packetWriter.WriteUInt8(0);
                        packetWriter.WriteInt32(0);
                        packetWriter.WriteUInt8(1);
                        packetWriter.WriteSmartGuid(guid);
                        packetWriter.WriteUInt8(1);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Write <int>(0);
                        arg_6D_0.Flush();
                        packetWriter.WriteUInt32(0u);
                        WorldObject expr_101 = new WorldObject(230);
                        expr_101.Guid = session.Character.Guid;
                        expr_101.SetItemUpdateFields(guid, id, item2.ModId);
                        expr_101.WriteUpdateFields(ref packetWriter);
                        expr_101.WriteDynamicUpdateFields(ref packetWriter);
                        arg_1B9_0 = (num * 64307666u ^ 2886005418u);
                        continue;
                    }
                    }
                    return;
                }
            }
        }
        public static void HandleEnumCharactersResult(ref PacketReader packet, ref WorldClass session)
        {
            SQLResult result = DB.Characters.Select("SELECT guid, name, race, class, gender, skin, face, hairstyle, " +
                                                    "haircolor, facialhair, level, zone, map, x, y, z, guildguid, petdisplayid, " +
                                                    "petlevel, petfamily, characterflags, customizeflags, loginCinematic FROM characters WHERE accountid = {0}", session.Account.Id);

            PacketWriter enumCharacters = new PacketWriter(JAMCMessage.EnumCharactersResult);
            BitPack      BitPack        = new BitPack(enumCharacters);

            BitPack.Write(0, 23);
            BitPack.Write(result.Count, 17);

            if (result.Count != 0)
            {
                for (int c = 0; c < result.Count; c++)
                {
                    string name           = result.Read <String>(c, "Name");
                    bool   loginCinematic = result.Read <Boolean>(c, "LoginCinematic");

                    BitPack.Guid      = result.Read <UInt64>(c, "Guid");
                    BitPack.GuildGuid = result.Read <UInt64>(c, "GuildGuid");

                    BitPack.WriteGuidMask(7, 0, 4);
                    BitPack.WriteGuildGuidMask(2);
                    BitPack.WriteGuidMask(5, 3);
                    BitPack.Write((uint)Encoding.ASCII.GetBytes(name).Length, 7);
                    BitPack.WriteGuildGuidMask(0, 5, 3);
                    BitPack.Write(loginCinematic);
                    BitPack.WriteGuildGuidMask(6, 7);
                    BitPack.WriteGuidMask(1);
                    BitPack.WriteGuildGuidMask(4, 1);
                    BitPack.WriteGuidMask(2, 6);
                }

                BitPack.Write(1);
                BitPack.Flush();

                for (int c = 0; c < result.Count; c++)
                {
                    string name = result.Read <String>(c, "Name");
                    BitPack.Guid      = result.Read <UInt64>(c, "Guid");
                    BitPack.GuildGuid = result.Read <UInt64>(c, "GuildGuid");

                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "CharacterFlags"));
                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "PetFamily"));
                    enumCharacters.WriteFloat(result.Read <Single>(c, "Z"));

                    BitPack.WriteGuidBytes(7);
                    BitPack.WriteGuildGuidBytes(6);

                    // Not implanted
                    for (int j = 0; j < 23; j++)
                    {
                        enumCharacters.WriteUInt32(0);
                        enumCharacters.WriteUInt8(0);
                        enumCharacters.WriteUInt32(0);
                    }

                    enumCharacters.WriteFloat(result.Read <Single>(c, "X"));
                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "Class"));

                    BitPack.WriteGuidBytes(5);

                    enumCharacters.WriteFloat(result.Read <Single>(c, "Y"));

                    BitPack.WriteGuildGuidBytes(3);
                    BitPack.WriteGuidBytes(6);

                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "PetLevel"));
                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "PetDisplayId"));

                    BitPack.WriteGuidBytes(2);
                    BitPack.WriteGuidBytes(1);

                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "HairColor"));
                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "FacialHair"));

                    BitPack.WriteGuildGuidBytes(2);

                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "Zone"));
                    enumCharacters.WriteUInt8(0);

                    BitPack.WriteGuidBytes(0);
                    BitPack.WriteGuildGuidBytes(1);

                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "Skin"));

                    BitPack.WriteGuidBytes(4);
                    BitPack.WriteGuildGuidBytes(5);

                    enumCharacters.WriteString(name);

                    BitPack.WriteGuildGuidBytes(0);

                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "Level"));

                    BitPack.WriteGuidBytes(3);
                    BitPack.WriteGuildGuidBytes(7);

                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "HairStyle"));

                    BitPack.WriteGuildGuidBytes(4);

                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "Gender"));
                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "Map"));
                    enumCharacters.WriteUInt32(result.Read <UInt32>(c, "CustomizeFlags"));
                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "Race"));
                    enumCharacters.WriteUInt8(result.Read <Byte>(c, "Face"));
                }
            }
            else
            {
                BitPack.Write(1);
                BitPack.Flush();
            };

            session.Send(enumCharacters);
        }
Beispiel #23
0
        public static void HandleAuthResponse(ref PacketReader packet, ref WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            packet.Skip(54);

            int addonSize = packet.ReadInt32();

            packet.Skip(addonSize);

            uint   nameLength  = BitUnpack.GetNameLength <uint>(12);
            string accountName = packet.ReadString(nameLength);

            SQLResult result = DB.Realms.Select("SELECT * FROM accounts WHERE name = '{0}'", 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 = '{0}'", realmId);
            SQLResult realmRaceResult  = DB.Realms.Select("SELECT race, expansion FROM realm_races WHERE realmId = '{0}'", realmId);

            bool HasAccountData = true;
            bool IsInQueue      = false;

            PacketWriter authResponse = new PacketWriter(JAMCMessage.AuthResponse);
            BitPack      BitPack      = new BitPack(authResponse);

            BitPack.Write(1);                                      // HasAccountData

            if (HasAccountData)
            {
                BitPack.Write(realmClassResult.Count, 25);         // Activation count for classes
                BitPack.Write(0);                                  // Unknown, 5.0.4
                BitPack.Write(0);                                  // Unknown, 5.1.0
                BitPack.Write(0, 22);                              // Activate character template windows/button

                //if (HasCharacterTemplate)
                //Write bits for char templates...

                BitPack.Write(realmRaceResult.Count, 25);          // Activation count for races
                BitPack.Write(IsInQueue);                          // IsInQueue
            }

            if (IsInQueue)
            {
                BitPack.Write(0);                                  // Unknown
                BitPack.Flush();

                authResponse.WriteUInt32(0);                       // QueuePosition
            }
            else
            {
                BitPack.Flush();
            }

            if (HasAccountData)
            {
                //if (HasCharacterTemplate)
                //Write data for char templates...

                for (int r = 0; r < realmRaceResult.Count; r++)
                {
                    authResponse.WriteUInt8(realmRaceResult.Read <byte>(r, "expansion"));
                    authResponse.WriteUInt8(realmRaceResult.Read <byte>(r, "race"));
                }

                authResponse.WriteUInt32(0);
                authResponse.WriteUInt32(0);
                authResponse.WriteUInt8(0);
                authResponse.WriteUInt8(session.Account.Expansion);
                authResponse.WriteUInt8(session.Account.Expansion);

                for (int c = 0; c < realmClassResult.Count; c++)
                {
                    authResponse.WriteUInt8(realmClassResult.Read <byte>(c, "class"));
                    authResponse.WriteUInt8(realmClassResult.Read <byte>(c, "expansion"));
                }

                authResponse.WriteUInt32(0);
            }

            authResponse.WriteUInt8((byte)AuthCodes.AUTH_OK);

            session.Send(authResponse);

            MiscHandler.HandleUpdateClientCacheVersion(ref session);
            TutorialHandler.HandleTutorialFlags(ref session);
        }
    }
Beispiel #24
0
        public void WriteUpdateObjectMovement(ref PacketWriter packet, ref WorldObject wObject, UpdateFlag updateFlags)
        {
            ObjectMovementValues values = new ObjectMovementValues(updateFlags);
            BitPack BitPack             = new BitPack(packet, wObject.Guid);

            BitPack.Write(0);                                // Unknown 4
            BitPack.Write(0, 22);                            // BitCounter
            BitPack.Write(values.IsVehicle);
            BitPack.Write(0);                                // Unknown 8
            BitPack.Write(values.HasGoTransportPosition);
            BitPack.Write(0);                                // Bit 3
            BitPack.Write(0);                                // Unknown 6
            BitPack.Write(0);                                // Unknown
            BitPack.Write(0);                                // Unknown 3
            BitPack.Write(0);                                // Unknown 2
            BitPack.Write(wObject is GameObjectSpawn);
            BitPack.Write(values.HasTarget);
            BitPack.Write(0);                                // Bit 2
            BitPack.Write(0);                                // Bit 0
            BitPack.Write(values.IsSelf);
            BitPack.Write(0);                                // Bit 1
            BitPack.Write(values.IsAlive);
            BitPack.Write(0);                                // Unknown 7
            BitPack.Write(0);                                // Unknown 5
            BitPack.Write(values.HasAnimKits);
            BitPack.Write(values.HasStationaryPosition);

            if (values.IsAlive)
            {
                BitPack.WriteGuidMask(0);
                BitPack.Write(1);                   // !Pitch or !SplineElevation
                BitPack.WriteGuidMask(4, 7);
                BitPack.Write(1);                   // !MovementFlags2
                BitPack.WriteGuidMask(5, 2);
                BitPack.Write(0);                   // HasBasicSplineData
                BitPack.Write(1);                   // !MovementFlags
                BitPack.Write(0);                   // !HasTime
                BitPack.Write(0);                   // Unknown_Alive_2
                BitPack.Write(0);                   // Unknown_Alive_1
                BitPack.Write(!values.HasRotation);
                BitPack.Write(values.IsTransport);
                BitPack.Write(1);                   // Pitch or SplineElevation
                BitPack.WriteGuidMask(6);
                BitPack.Write(0, 19);               // BitCounter_Alive_1
                BitPack.WriteGuidMask(1);
                BitPack.Write(1);                   // !Unknown_Alive_3
                BitPack.WriteGuidMask(3);
                BitPack.Write(0, 22);               // BitCounter_Alive_2
                BitPack.Write(0);                   // IsFallingOrJumping
                BitPack.Write(0);                   // Unknown_Alive_4
            }

            BitPack.Flush();

            if (values.IsAlive)
            {
                packet.WriteUInt32(0);
                BitPack.WriteGuidBytes(2, 1);
                packet.WriteFloat((float)MovementSpeed.WalkSpeed);
                packet.WriteFloat((float)MovementSpeed.RunSpeed);
                BitPack.WriteGuidBytes(0, 3);
                packet.WriteFloat((float)MovementSpeed.SwimBackSpeed);
                packet.WriteFloat((float)MovementSpeed.TurnSpeed);
                BitPack.WriteGuidBytes(5);
                packet.WriteFloat(wObject.Position.Z);
                packet.WriteFloat(wObject.Position.O);
                BitPack.WriteGuidBytes(6);
                packet.WriteFloat((float)MovementSpeed.PitchSpeed);
                packet.WriteFloat((float)MovementSpeed.RunBackSpeed);
                packet.WriteFloat(wObject.Position.Y);
                packet.WriteFloat((float)MovementSpeed.SwimSpeed);
                packet.WriteFloat((float)MovementSpeed.FlyBackSpeed);
                BitPack.WriteGuidBytes(7);
                packet.WriteFloat((float)MovementSpeed.FlySpeed);
                packet.WriteFloat(wObject.Position.X);
                BitPack.WriteGuidBytes(4);
            }

            if (wObject is GameObjectSpawn)
            {
                packet.WriteInt64(Quaternion.GetCompressed(wObject.Position.O));
            }

            if (values.HasStationaryPosition)
            {
                packet.WriteFloat(wObject.Position.X);
                packet.WriteFloat(wObject.Position.Z);
                packet.WriteFloat(wObject.Position.O);
                packet.WriteFloat(wObject.Position.Y);
            }
        }
Beispiel #25
0
        private static void WriteInRangeObjects(IEnumerable <WorldObject> objects, WorldClass session, ObjectType type)
        {
            Character  character  = session.Character;
            int        arg_10_0   = objects.Count <WorldObject>();
            UpdateFlag updateFlag = UpdateFlag.Alive;

            if (arg_10_0 > 0)
            {
                updateFlag |= ((type == ObjectType.GameObject) ? UpdateFlag.StationaryPosition : UpdateFlag.Alive);
                IEnumerator <WorldObject> enumerator = objects.GetEnumerator();
                try
                {
                    while (true)
                    {
IL_361:
                        uint arg_2F0_0 = (!ObjectHandler.smethod_3(enumerator)) ? 1527969684u : 1848967450u;
                        while (true)
                        {
                            uint num;
                            switch ((num = (arg_2F0_0 ^ 969171285u)) % 21u)
                            {
                            case 0u:
                                arg_2F0_0 = (((type == ObjectType.GameObject) ? 1738499285u : 646977882u) ^ num * 1593683944u);
                                continue;

                            case 1u:
                            {
                                PacketWriter packetWriter;
                                packetWriter.WriteUInt8(1);
                                arg_2F0_0 = (((type == ObjectType.Player) ? 3818654308u : 3591559160u) ^ num * 648131247u);
                                continue;
                            }

                            case 2u:
                            {
                                PacketWriter packetWriter;
                                WorldObject  worldObject;
                                packetWriter.WriteSmartGuid(worldObject.SGuid);
                                arg_2F0_0 = 2122628810u;
                                continue;
                            }

                            case 3u:
                            {
                                WorldObject current;
                                arg_2F0_0 = (((character.Guid != current.Guid) ? 2929494894u : 2211260839u) ^ num * 4047706010u);
                                continue;
                            }

                            case 4u:
                            {
                                PacketWriter packetWriter;
                                packetWriter.WriteUInt8((byte)type);
                                arg_2F0_0 = 2032235371u;
                                continue;
                            }

                            case 5u:
                                ObjectHandler.smethod_2(5);
                                arg_2F0_0 = (num * 2857407048u ^ 4065091795u);
                                continue;

                            case 6u:
                            {
                                PacketWriter packetWriter;
                                uint         data;
                                packetWriter.WriteUInt32Pos(data, 13);
                                arg_2F0_0 = (num * 945023592u ^ 666258815u);
                                continue;
                            }

                            case 7u:
                                arg_2F0_0 = ((type == ObjectType.Unit) ? 1066124101u : 1317094159u);
                                continue;

                            case 8u:
                            {
                                PacketWriter packetWriter;
                                WorldObject  worldObject;
                                worldObject.WriteDynamicUpdateFields(ref packetWriter);
                                arg_2F0_0 = (num * 3168312685u ^ 1016797372u);
                                continue;
                            }

                            case 9u:
                            {
                                WorldObject current;
                                WorldObject worldObject = current;
                                arg_2F0_0 = (((!character.InRangeObjects.ContainsKey(current.Guid)) ? 241293809u : 970459467u) ^ num * 547093509u);
                                continue;
                            }

                            case 11u:
                            {
                                WorldObject worldObject;
                                character.InRangeObjects.Add(worldObject.Guid, worldObject);
                                arg_2F0_0 = (num * 1271401156u ^ 2252314095u);
                                continue;
                            }

                            case 12u:
                            {
                                PacketWriter packetWriter;
                                uint         data = (uint)ObjectHandler.smethod_1(ObjectHandler.smethod_0(packetWriter)) - 17u;
                                arg_2F0_0 = 1218186453u;
                                continue;
                            }

                            case 13u:
                            {
                                PacketWriter packetWriter = new PacketWriter(ServerMessage.ObjectUpdate, true);
                                BitPack      arg_131_0    = new BitPack(packetWriter, 0uL, 0uL, 0uL, 0uL);
                                packetWriter.WriteInt32(1);
                                packetWriter.WriteUInt16((ushort)character.Map);
                                arg_131_0.Write <int>(0);
                                arg_131_0.Flush();
                                arg_2F0_0 = (num * 3222425454u ^ 2984538751u);
                                continue;
                            }

                            case 14u:
                            {
                                PacketWriter packetWriter;
                                WorldObject  worldObject;
                                packetWriter.WriteSmartGuid(worldObject.Guid, global::GuidType.Player);
                                arg_2F0_0 = (num * 1757694464u ^ 3297668298u);
                                continue;
                            }

                            case 15u:
                                goto IL_361;

                            case 16u:
                            {
                                PacketWriter packetWriter;
                                packetWriter.WriteInt32(0);
                                arg_2F0_0 = (num * 4015340619u ^ 2939785537u);
                                continue;
                            }

                            case 17u:
                            {
                                WorldObject current = enumerator.Current;
                                arg_2F0_0 = 1029453396u;
                                continue;
                            }

                            case 18u:
                            {
                                PacketWriter packetWriter;
                                session.Send(ref packetWriter);
                                arg_2F0_0 = (num * 3659980510u ^ 976080836u);
                                continue;
                            }

                            case 19u:
                            {
                                PacketWriter packetWriter;
                                WorldObject  worldObject;
                                Manager.WorldMgr.WriteUpdateObjectMovement(ref packetWriter, ref worldObject, updateFlag, type);
                                worldObject.SetUpdateFields();
                                worldObject.WriteUpdateFields(ref packetWriter);
                                arg_2F0_0 = (num * 3313353577u ^ 2170531980u);
                                continue;
                            }

                            case 20u:
                                arg_2F0_0 = 1848967450u;
                                continue;
                            }
                            goto Block_10;
                        }
                    }
                    Block_10:;
                }
                finally
                {
                    if (enumerator != null)
                    {
                        while (true)
                        {
IL_3A7:
                            uint arg_38E_0 = 1857051829u;
                            while (true)
                            {
                                uint num;
                                switch ((num = (arg_38E_0 ^ 969171285u)) % 3u)
                                {
                                case 0u:
                                    goto IL_3A7;

                                case 2u:
                                    ObjectHandler.smethod_4(enumerator);
                                    arg_38E_0 = (num * 3244275826u ^ 1817846266u);
                                    continue;
                                }
                                goto Block_14;
                            }
                        }
                        Block_14 :;
                    }
                }
            }
        }
Beispiel #26
0
        public static void HandleUpdateObjectCreate(ref WorldClass session, bool tele = false)
        {
            WorldObject character = session.Character;

            while (true)
            {
IL_238:
                uint arg_1F2_0 = 2275508388u;
                while (true)
                {
                    uint num;
                    switch ((num = (arg_1F2_0 ^ 3154599871u)) % 14u)
                    {
                    case 0u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteSmartGuid(character.Guid, global::GuidType.Player);
                        arg_1F2_0 = (num * 3881833045u ^ 1180485233u);
                        continue;
                    }

                    case 1u:
                        (character as Character).InRangeObjects.Clear();
                        arg_1F2_0 = (num * 2283818524u ^ 355223714u);
                        continue;

                    case 2u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt8(4);
                        UpdateFlag updateFlags = UpdateFlag.Self | UpdateFlag.Alive | UpdateFlag.Rotation;
                        arg_1F2_0 = (num * 103799057u ^ 21624365u);
                        continue;
                    }

                    case 3u:
                    {
                        PacketWriter packetWriter;
                        character.WriteUpdateFields(ref packetWriter);
                        arg_1F2_0 = (num * 49266881u ^ 2307507266u);
                        continue;
                    }

                    case 4u:
                    {
                        PacketWriter packetWriter;
                        session.Send(ref packetWriter);
                        arg_1F2_0 = (num * 1672062260u ^ 2814400482u);
                        continue;
                    }

                    case 6u:
                    {
                        PacketWriter packetWriter;
                        UpdateFlag   updateFlags;
                        Manager.WorldMgr.WriteUpdateObjectMovement(ref packetWriter, ref character, updateFlags, ObjectType.Player);
                        arg_1F2_0 = (num * 86580379u ^ 2193049942u);
                        continue;
                    }

                    case 7u:
                        character.SetUpdateFields();
                        arg_1F2_0 = (num * 2334973880u ^ 3652082974u);
                        continue;

                    case 8u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt8(1);
                        arg_1F2_0 = (num * 2061835051u ^ 1546086745u);
                        continue;
                    }

                    case 9u:
                    {
                        PacketWriter packetWriter = new PacketWriter(ServerMessage.ObjectUpdate, true);
                        arg_1F2_0 = (num * 3719673916u ^ 4267485768u);
                        continue;
                    }

                    case 10u:
                    {
                        PacketWriter packetWriter;
                        character.WriteDynamicUpdateFields(ref packetWriter);
                        uint data = (uint)ObjectHandler.smethod_1(ObjectHandler.smethod_0(packetWriter)) - 17u;
                        packetWriter.WriteUInt32Pos(data, 13);
                        arg_1F2_0 = (num * 91628017u ^ 979890369u);
                        continue;
                    }

                    case 11u:
                    {
                        PacketWriter packetWriter;
                        BitPack      arg_A2_0 = new BitPack(packetWriter, 0uL, 0uL, 0uL, 0uL);
                        if (session.Character.Bag == null)
                        {
                            session.Character.Bag = new Dictionary <byte, Item>();
                        }
                        if (session.Character.Equipment == null)
                        {
                            session.Character.Equipment = new Dictionary <byte, Item>();
                        }
                        packetWriter.WriteInt32(1);
                        packetWriter.WriteUInt16((ushort)character.Map);
                        arg_A2_0.Write <int>(0);
                        arg_A2_0.Flush();
                        packetWriter.WriteInt32(0);
                        arg_1F2_0 = 3587135917u;
                        continue;
                    }

                    case 12u:
                        goto IL_238;

                    case 13u:
                        if (!tele)
                        {
                            arg_1F2_0 = (num * 4070430128u ^ 2204553002u);
                            continue;
                        }
                        return;
                    }
                    goto Block_4;
                }
            }
Block_4:
            using (Dictionary <byte, Item> .Enumerator enumerator = session.Character.Bag.GetEnumerator())
            {
                while (true)
                {
IL_39B:
                    uint arg_35F_0 = enumerator.MoveNext() ? 4174226275u : 4027859808u;
                    while (true)
                    {
                        uint num;
                        switch ((num = (arg_35F_0 ^ 3154599871u)) % 8u)
                        {
                        case 0u:
                            arg_35F_0 = 4174226275u;
                            continue;

                        case 1u:
                            ObjectHandler.HandleUpdateObjectValues(ref session, false);
                            arg_35F_0 = (num * 2901385184u ^ 3008738973u);
                            continue;

                        case 2u:
                            goto IL_39B;

                        case 3u:
                        {
                            SmartGuid smartGuid;
                            session.Character.SetUpdateField <ulong>(1085 + (23 + (session.Character.Bag.Count - 1)) * 4, smartGuid.Guid, 0);
                            arg_35F_0 = (num * 1633749325u ^ 882616989u);
                            continue;
                        }

                        case 4u:
                        {
                            KeyValuePair <byte, Item> current = enumerator.Current;
                            arg_35F_0 = 2355109817u;
                            continue;
                        }

                        case 5u:
                        {
                            SmartGuid smartGuid;
                            session.Character.SetUpdateField <ulong>(1085 + (23 + (session.Character.Bag.Count - 1)) * 4 + 2, smartGuid.HighGuid, 0);
                            arg_35F_0 = (num * 2081811083u ^ 929503609u);
                            continue;
                        }

                        case 6u:
                        {
                            KeyValuePair <byte, Item> current;
                            SmartGuid smartGuid = new SmartGuid(current.Value.Guid, 0, global::GuidType.Item, 0uL);
                            ObjectHandler.HandleUpdateObjectCreateItem(smartGuid, current.Value, ref session);
                            arg_35F_0 = (num * 935936635u ^ 2677446734u);
                            continue;
                        }
                        }
                        goto Block_8;
                    }
                }
                Block_8 :;
            }
            using (Dictionary <byte, Item> .Enumerator enumerator = session.Character.Equipment.GetEnumerator())
            {
                while (true)
                {
                    IL_60C                                                  :
                    uint arg_5CB_0 = (!enumerator.MoveNext()) ? 4153873960u : 2528389413u;
                    while (true)
                    {
                        uint num;
                        switch ((num = (arg_5CB_0 ^ 3154599871u)) % 9u)
                        {
                        case 0u:
                        {
                            KeyValuePair <byte, Item> current2;
                            session.Character.SetUpdateField <ulong>(1085 + (int)(current2.Key * 4) + 2, 0uL, 0);
                            arg_5CB_0 = (num * 2903315187u ^ 1606612479u);
                            continue;
                        }

                        case 1u:
                        {
                            KeyValuePair <byte, Item> current2;
                            session.Character.SetUpdateField <ushort>(1035 + (int)(current2.Key * 2) + 1, (ushort)current2.Value.ModId, 0);
                            arg_5CB_0 = (num * 2254772229u ^ 3249291789u);
                            continue;
                        }

                        case 2u:
                            arg_5CB_0 = 2528389413u;
                            continue;

                        case 3u:
                            goto IL_60C;

                        case 4u:
                        {
                            KeyValuePair <byte, Item> current2 = enumerator.Current;
                            SmartGuid smartGuid2 = new SmartGuid(current2.Value.Guid, 0, global::GuidType.Item, 0uL);
                            ObjectHandler.HandleUpdateObjectCreateItem(smartGuid2, current2.Value, ref session);
                            session.Character.SetUpdateField <ulong>(1085 + (int)(current2.Key * 4), 0uL, 0);
                            arg_5CB_0 = 3525416964u;
                            continue;
                        }

                        case 6u:
                        {
                            KeyValuePair <byte, Item> current2;
                            session.Character.SetUpdateField <int>(1035 + (int)(current2.Key * 2), current2.Value.Id, 0);
                            ObjectHandler.HandleUpdateObjectValues(ref session, false);
                            arg_5CB_0 = (num * 2025118931u ^ 1226385667u);
                            continue;
                        }

                        case 7u:
                        {
                            KeyValuePair <byte, Item> current2;
                            SmartGuid smartGuid2;
                            session.Character.SetUpdateField <ulong>(1085 + (int)(current2.Key * 4), smartGuid2.Guid, 0);
                            session.Character.SetUpdateField <ulong>(1085 + (int)(current2.Key * 4) + 2, smartGuid2.HighGuid, 0);
                            session.Character.SetUpdateField <ushort>(1035 + (int)(current2.Key * 2) + 1, 0, 0);
                            arg_5CB_0 = (num * 1833648401u ^ 1914681319u);
                            continue;
                        }

                        case 8u:
                        {
                            KeyValuePair <byte, Item> current2;
                            session.Character.SetUpdateField <ushort>(1035 + (int)(current2.Key * 2) + 1, 0, 1);
                            session.Character.SetUpdateField <int>(1035 + (int)(current2.Key * 2), 0, 0);
                            arg_5CB_0 = (num * 772582332u ^ 2291984992u);
                            continue;
                        }
                        }
                        goto Block_12;
                    }
                }
                Block_12 :;
            }
        }
Beispiel #27
0
        public static void HandleMoveUnsetCanFly(ref WorldClass session)
        {
            PacketWriter unsetCanFly = new PacketWriter(ServerMessage.MoveUnsetCanFly);
            BitPack BitPack = new BitPack(unsetCanFly, session.Character.Guid);

            BitPack.WriteGuidMask(7, 6, 5, 1, 2, 4, 3, 0);

            BitPack.Flush();

            BitPack.WriteGuidBytes(0, 6, 3, 7, 2, 1, 5);

            unsetCanFly.WriteUInt32(0);

            BitPack.WriteGuidBytes(4);

            session.Send(ref unsetCanFly);
        }
        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);
        }
Beispiel #29
0
        public static void HandleTransferPending(ref WorldClass session, uint mapId)
        {
            bool Unknown = false;
            bool IsTransport = false;

            PacketWriter transferPending = new PacketWriter(ServerMessage.TransferPending);
            BitPack BitPack = new BitPack(transferPending);

            BitPack.Write(Unknown);
            BitPack.Write(IsTransport);

            BitPack.Flush();

            if (Unknown)
                transferPending.WriteUInt32(0);

            transferPending.WriteUInt32(mapId);

            if (IsTransport)
            {
                transferPending.WriteUInt32(0);
                transferPending.WriteUInt32(0);
            }

            session.Send(ref transferPending);
        }
Beispiel #30
0
        public static void HandleMessageOfTheDay(ref WorldClass session)
        {
            PacketWriter motd = new PacketWriter(ServerMessage.MOTD);
            BitPack BitPack = new BitPack(motd);

            List<string> motds = new List<string>();

            motds.Add("Arctium MoP test");
            motds.Add("Welcome to our MoP server test.");
            motds.Add("Your development team =)");

            BitPack.Write<uint>(3, 4);

            motds.ForEach(m => BitPack.Write(m.Length, 7));

            BitPack.Flush();

            motds.ForEach(m => motd.WriteString(m));

            session.Send(ref motd);
        }
Beispiel #31
0
        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);
            }
        }
Beispiel #32
0
        public static void HandleMoveSetSwimSpeed(ref WorldClass session, float speed = 4.72222f)
        {
            PacketWriter setSwimSpeed = new PacketWriter(ServerMessage.MoveSetSwimSpeed);
            BitPack BitPack = new BitPack(setSwimSpeed, session.Character.Guid);

            BitPack.WriteGuidMask(6, 3, 1, 2, 0, 4, 7, 5);

            BitPack.Flush();

            BitPack.WriteGuidBytes(2);

            setSwimSpeed.WriteFloat(speed);

            BitPack.WriteGuidBytes(1, 6);

            setSwimSpeed.WriteUInt32(0);

            BitPack.WriteGuidBytes(3, 4, 0, 7, 5);

            session.Send(ref setSwimSpeed);
        }
Beispiel #33
0
        public static void SendMessage(ref WorldClass session, ChatMessageValues chatMessage, WorldClass pSession = null)
        {
            byte[] GuidMask   = { 4, 2, 7, 5, 1, 3, 0, 6 };
            byte[] GuidMask3  = { 1, 5, 4, 6, 3, 2, 7, 0 };
            byte[] GuidBytes  = { 5, 7, 3, 1, 6, 2, 4, 0 };
            byte[] GuidBytes3 = { 2, 7, 5, 0, 3, 4, 1, 6 };

            var pChar = session.Character;
            var guid  = pChar.Guid;

            if (pSession != null)
            {
                guid = pSession.Character.Guid;
            }

            PacketWriter chat    = new PacketWriter(ServerMessage.Chat);
            BitPack      BitPack = new BitPack(chat, guid);

            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(1);

            BitPack.Write(0, 8);
            BitPack.Write(1);
            BitPack.Write(!chatMessage.HasRealmId);
            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(!chatMessage.HasLanguage);
            BitPack.Write(1);
            BitPack.Write(0, 8);

            BitPack.WriteStringLength(chatMessage.Message, 12);

            BitPack.Write(0);
            BitPack.Write(1);

            BitPack.WriteGuidMask(GuidMask);

            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(0);

            BitPack.WriteGuidMask(GuidMask3);

            BitPack.Flush();

            if (chatMessage.HasRealmId)
            {
                chat.WriteInt32(chatMessage.RealmId);
            }

            BitPack.WriteGuidBytes(GuidBytes3);

            BitPack.WriteGuidBytes(GuidBytes);

            if (chatMessage.HasLanguage)
            {
                chat.WriteUInt8(chatMessage.Language);
            }

            chat.WriteString(chatMessage.Message, false);

            chat.WriteUInt8((byte)chatMessage.ChatType);

            switch (chatMessage.ChatType)
            {
            case MessageType.ChatMessageSay:
                WorldMgr.SendByDist(pChar, chat, 625);
                break;

            case MessageType.ChatMessageYell:
                WorldMgr.SendByDist(pChar, chat, 90000);
                break;

            default:
                session.Send(ref chat);
                break;
            }
        }
Beispiel #34
0
        public static void HandleMoveTeleport(ref WorldClass session, Vector4 vector)
        {
            bool IsTransport = false;
            bool Unknown = false;

            PacketWriter moveTeleport = new PacketWriter(ServerMessage.MoveTeleport);
            BitPack BitPack = new BitPack(moveTeleport, session.Character.Guid);

            BitPack.WriteGuidMask(7);
            BitPack.Write(Unknown);
            BitPack.WriteGuidMask(2, 0);

            if (Unknown)
            {
                BitPack.Write(0);
                BitPack.Write(0);
            }

            BitPack.Write(IsTransport);

            if (IsTransport)
                BitPack.WriteTransportGuidMask(4, 3, 5, 7, 0, 2, 6, 1);

            BitPack.WriteGuidMask(5, 1, 3, 6, 4);

            BitPack.Flush();

            BitPack.WriteGuidBytes(0);

            if (IsTransport)
                BitPack.WriteTransportGuidBytes(7, 6, 0, 2, 3, 1, 5, 4);

            BitPack.WriteGuidBytes(6, 1);

            moveTeleport.WriteUInt32(0);

            BitPack.WriteGuidBytes(7, 5);

            moveTeleport.WriteFloat(vector.X);

            BitPack.WriteGuidBytes(4, 3, 2);

            moveTeleport.WriteFloat(vector.Y);
            moveTeleport.WriteFloat(vector.O);
            moveTeleport.WriteFloat(vector.Z);

            if (Unknown)
                moveTeleport.WriteUInt8(0);

            session.Send(ref moveTeleport);
        }
Beispiel #35
0
        public static void HandleTalkToGossip(ref PacketReader packet, ref WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            byte[] guidMask  = { 2, 1, 7, 3, 6, 0, 4, 5 };
            byte[] guidBytes = { 5, 3, 6, 2, 7, 0, 4, 1 };

            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, 5);
                BitPack.Write(gossipData.OptionsCount, 20);
                BitPack.WriteGuidMask(6, 1);

                for (int i = 0; i < gossipData.OptionsCount; i++)
                {
                    // OptionsCount not supported.
                }

                BitPack.WriteGuidMask(2);
                BitPack.Write(gossipData.QuestsCount, 19);
                BitPack.WriteGuidMask(4);

                for (int i = 0; i < gossipData.QuestsCount; i++)
                {
                    // QuestsCount not supported.
                }

                BitPack.WriteGuidMask(3, 7);
                BitPack.Flush();

                for (int i = 0; i < gossipData.OptionsCount; i++)
                {
                    // OptionsCount not supported.
                }

                for (int i = 0; i < gossipData.QuestsCount; i++)
                {
                    // QuestsCount not supported.
                }

                BitPack.WriteGuidBytes(5, 2, 6, 0);

                gossipMessage.WriteInt32(gossipData.Id);

                BitPack.WriteGuidBytes(4, 7);

                gossipMessage.WriteInt32(gossipData.TextID);

                BitPack.WriteGuidBytes(3, 1);

                gossipMessage.WriteInt32(gossipData.FriendshipFactionID);

                session.Send(ref gossipMessage);
            }
        }
Beispiel #36
0
        public static void HandleMoveUpdate(ulong guid, ObjectMovementValues movementValues, Vector4 vector)
        {
            PacketWriter moveUpdate = new PacketWriter(ServerMessage.MoveUpdate);
            BitPack BitPack = new BitPack(moveUpdate, guid);

            moveUpdate.WriteFloat(vector.Y);
            moveUpdate.WriteFloat(vector.Z);
            moveUpdate.WriteFloat(vector.X);

            BitPack.WriteGuidMask(5);
            BitPack.Write(0);
            BitPack.WriteGuidMask(3);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(!movementValues.HasMovementFlags2);
            BitPack.WriteGuidMask(0);
            BitPack.Write(1);
            BitPack.Write(!movementValues.HasRotation);
            BitPack.WriteGuidMask(7);
            BitPack.Write(movementValues.IsTransport);
            BitPack.Write(0);
            BitPack.Write(movementValues.Time == 0);
            BitPack.Write(!movementValues.HasMovementFlags);
            BitPack.WriteGuidMask(2);
            BitPack.Write(1);
            BitPack.Write(movementValues.IsFallingOrJumping);
            BitPack.WriteGuidMask(1, 6);
            BitPack.Write<uint>(0, 22);
            BitPack.WriteGuidMask(4);

            if (movementValues.IsFallingOrJumping)
                BitPack.Write(movementValues.HasJumpData);

            if (movementValues.HasMovementFlags)
                BitPack.Write((uint)movementValues.MovementFlags, 30);

            if (movementValues.HasMovementFlags2)
                BitPack.Write((uint)movementValues.MovementFlags2, 13);

            BitPack.Flush();

            if (movementValues.IsFallingOrJumping)
            {
                if (movementValues.HasJumpData)
                {
                    moveUpdate.WriteFloat(movementValues.CurrentSpeed);
                    moveUpdate.WriteFloat(movementValues.Sin);
                    moveUpdate.WriteFloat(movementValues.Cos);
                }

                moveUpdate.WriteFloat(movementValues.JumpVelocity);
                moveUpdate.WriteUInt32(movementValues.FallTime);
            }

            BitPack.WriteGuidBytes(1, 0, 4, 5, 7, 2);

            if (movementValues.Time != 0)
                moveUpdate.WriteUInt32(movementValues.Time);

            if (movementValues.HasRotation)
                moveUpdate.WriteFloat(vector.O);

            BitPack.WriteGuidBytes(6, 3);

            var session = WorldMgr.GetSession(guid);
            if (session != null)
            {
                Character pChar = session.Character;

                ObjectMgr.SetPosition(ref pChar, vector, false);
                WorldMgr.SendToInRangeCharacter(pChar, moveUpdate);
            }
        }
Beispiel #37
0
        public static void HandleQueryRealmName(ref PacketReader packet, ref WorldClass session)
        {
            Character pChar = session.Character;

            uint realmId = packet.Read<uint>();

            SQLResult result = DB.Realms.Select("SELECT name FROM realms WHERE id = ?", WorldConfig.RealmId);
            string realmName = result.Read<string>(0, "Name");

            PacketWriter realmQueryResponse = new PacketWriter(ServerMessage.RealmQueryResponse);
            BitPack BitPack = new BitPack(realmQueryResponse);

            realmQueryResponse.WriteUInt8(0);
            realmQueryResponse.WriteUInt32(realmId);       // <= 0 => End of packet

            BitPack.Write(realmName.Length, 8);
            BitPack.Write(realmName.Length, 8);
            BitPack.Write(1);

            BitPack.Flush();

            realmQueryResponse.WriteString(realmName);
            realmQueryResponse.WriteString(realmName);

            session.Send(ref realmQueryResponse);
        }
Beispiel #38
0
        public static void HandleQueryCreature(ref PacketReader packet, ref WorldClass session)
        {
            var hasData = false;
            var id = packet.Read<int>();

            PacketWriter queryCreatureResponse = new PacketWriter(ServerMessage.QueryCreatureResponse);
            BitPack BitPack = new BitPack(queryCreatureResponse);

            queryCreatureResponse.WriteInt32(id);

            Creature creature = DataMgr.FindCreature(id);
            if (hasData = (creature != null))
            {
                CreatureStats stats = creature.Stats;

                BitPack.Write(hasData);
                BitPack.Write(stats.QuestItemId.Count, 22);
                BitPack.Write(0, 11);
                BitPack.Write(stats.RacialLeader);
                BitPack.Write(stats.IconName.Length + 1, 6);

                for (int i = 0; i < 8; i++)
                {
                    if (i == 1)
                        BitPack.Write(stats.Name.Length + 1, 11);
                    else
                        BitPack.Write(0, 11);
                }

                BitPack.Write(stats.SubName.Length != 0 ? stats.SubName.Length + 1 : 0, 11);
                BitPack.Flush();

                queryCreatureResponse.WriteInt32(stats.Rank);
                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[2]);
                queryCreatureResponse.WriteInt32(stats.Type);

                foreach (var v in stats.Flag)
                    queryCreatureResponse.WriteInt32(v);

                queryCreatureResponse.WriteFloat(stats.PowerModifier);
                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[0]);
                queryCreatureResponse.WriteFloat(1);

                queryCreatureResponse.WriteCString(stats.Name);

                if (stats.IconName != "")
                    queryCreatureResponse.WriteCString(stats.IconName);

                queryCreatureResponse.WriteInt32(stats.Family);
                queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[0]);

                if (stats.SubName != "")
                    queryCreatureResponse.WriteCString(stats.SubName);

                queryCreatureResponse.WriteInt32(stats.MovementInfoId);
                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[1]);
                queryCreatureResponse.WriteFloat(1);
                queryCreatureResponse.WriteFloat(stats.HealthModifier);
                queryCreatureResponse.WriteInt32(0);

                foreach (var v in stats.QuestItemId)
                    queryCreatureResponse.WriteInt32(v);

                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[3]);
                queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[1]);
                queryCreatureResponse.WriteInt32(stats.ExpansionRequired);

                session.Send(ref queryCreatureResponse);
            }
            else
            {
                BitPack.Write(hasData);
                Log.Message(LogType.DEBUG, "Creature (Id: {0}) not found.", id);
            }
        }
Beispiel #39
0
        public void WriteUpdateObjectMovement(ref PacketWriter packet, ref WorldObject wObject, UpdateFlag updateFlags)
        {
            ObjectMovementValues values = new ObjectMovementValues(updateFlags);
            BitPack BitPack             = new BitPack(packet, wObject.Guid);

            BitPack.Write(values.IsVehicle);
            BitPack.Write(values.IsSelf);
            BitPack.Write(0);
            BitPack.Write(values.IsTransport);
            BitPack.Write(0);
            BitPack.Write(0);
            BitPack.Write(values.HasTarget);
            BitPack.Write(values.HasStationaryPosition);
            BitPack.Write(values.IsAreaTrigger);
            BitPack.Write(0);
            BitPack.Write(values.IsSceneObject);
            BitPack.Write(0);
            BitPack.Write(0);
            BitPack.Write(0, 22);
            BitPack.Write(values.IsAlive);
            BitPack.Write(values.HasGoTransportPosition);
            BitPack.Write(0);
            BitPack.Write(wObject is GameObjectSpawn);
            BitPack.Write(0);
            BitPack.Write(0);
            BitPack.Write(values.HasAnimKits);

            if (values.IsAlive)
            {
                BitPack.WriteGuidMask(5);
                BitPack.Write(0);
                BitPack.Write(1);           // !Spline elevation
                BitPack.WriteGuidMask(6);
                BitPack.Write(0);
                BitPack.Write(0, 19);
                BitPack.WriteGuidMask(4);
                BitPack.Write(!values.HasRotation);
                BitPack.Write(!values.HasMovementFlags2);
                BitPack.Write(1);
                BitPack.WriteGuidMask(2, 3, 7);
                BitPack.Write(0, 22);
                BitPack.Write(!values.HasMovementFlags);
                BitPack.Write(0);           // !Time
                BitPack.Write(1);           // !Pitch
                BitPack.WriteGuidMask(1);
                BitPack.Write(values.IsFallingOrJumping);
                BitPack.Write(0);

                if (values.HasMovementFlags2)
                {
                    BitPack.Write(values.MovementFlags2, 13);
                }

                BitPack.WriteGuidMask(0);
                BitPack.Write(0);           // Spline
                BitPack.Write(values.IsTransport);

                if (values.HasMovementFlags)
                {
                    BitPack.Write(values.MovementFlags, 30);
                }

                if (values.IsFallingOrJumping)
                {
                    BitPack.Write(values.HasJumpData);
                }
            }

            BitPack.Flush();

            if (values.IsAlive)
            {
                packet.WriteFloat(wObject.Position.Y);
                BitPack.WriteGuidBytes(7, 1);

                if (values.IsFallingOrJumping)
                {
                    packet.WriteUInt32(values.FallTime);

                    if (values.HasJumpData)
                    {
                        packet.WriteFloat(values.Sin);
                        packet.WriteFloat(values.Cos);
                        packet.WriteFloat(values.CurrentSpeed);
                    }

                    packet.WriteFloat(values.JumpVelocity);
                }

                packet.WriteFloat(MovementSpeed.TurnSpeed);
                packet.WriteFloat(MovementSpeed.FlyBackSpeed);
                packet.WriteFloat(MovementSpeed.RunBackSpeed);
                packet.WritePackedTime();
                packet.WriteFloat(wObject.Position.X);
                BitPack.WriteGuidBytes(2);
                packet.WriteFloat(MovementSpeed.SwimSpeed);
                packet.WriteFloat(MovementSpeed.SwimBackSpeed);

                if (values.HasRotation)
                {
                    packet.WriteFloat(wObject.Position.O);
                }

                packet.WriteFloat(MovementSpeed.FlySpeed);
                BitPack.WriteGuidBytes(6);
                packet.WriteFloat(MovementSpeed.RunSpeed);
                packet.WriteFloat(MovementSpeed.PitchSpeed);
                BitPack.WriteGuidBytes(0, 5, 4);
                packet.WriteFloat(MovementSpeed.WalkSpeed);
                packet.WriteFloat(wObject.Position.Z);
                BitPack.WriteGuidBytes(3);
            }

            if (values.HasStationaryPosition)
            {
                packet.WriteFloat(wObject.Position.X);
                packet.WriteFloat(wObject.Position.Z);
                packet.WriteFloat(wObject.Position.Y);
                packet.WriteFloat(wObject.Position.O);
            }

            if (wObject is GameObjectSpawn)
            {
                packet.WriteInt64(Quaternion.GetCompressed(wObject.Position.O));
            }
        }
Beispiel #40
0
        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);
                }
            }
        }
Beispiel #41
0
        public static void HandleMoveUpdate(ulong guid, ObjectMovementValues movementValues, Vector4 vector)
        {
            PacketWriter moveUpdate = new PacketWriter(JAMCMessage.MoveUpdate);
            BitPack      BitPack    = new BitPack(moveUpdate, guid);

            BitPack.WriteGuidMask(0);
            BitPack.Write(!movementValues.HasMovementFlags);
            BitPack.Write(!movementValues.HasRotation);
            BitPack.WriteGuidMask(2, 6);
            BitPack.Write(!movementValues.HasMovementFlags2);
            BitPack.WriteGuidMask(7);
            BitPack.Write <uint>(0, 24);
            BitPack.WriteGuidMask(1);

            if (movementValues.HasMovementFlags)
            {
                BitPack.Write((uint)movementValues.MovementFlags, 30);
            }

            BitPack.WriteGuidMask(4);
            BitPack.Write(!movementValues.IsAlive);
            BitPack.Write(0);

            if (movementValues.HasMovementFlags2)
            {
                BitPack.Write((uint)movementValues.MovementFlags2, 13);
            }

            BitPack.Write(0);
            BitPack.WriteGuidMask(5);
            BitPack.Write(true);
            BitPack.Write(0);
            BitPack.Write(movementValues.IsInterpolated);
            BitPack.Write(0);
            BitPack.Write(true);
            BitPack.WriteGuidMask(3);
            BitPack.Write(true);

            if (movementValues.IsInterpolated)
            {
                BitPack.Write(movementValues.IsInterpolated2);
            }

            BitPack.Flush();

            if (movementValues.IsInterpolated)
            {
                moveUpdate.WriteUInt32(0);

                if (movementValues.IsInterpolated2)
                {
                    moveUpdate.WriteFloat(0);
                    moveUpdate.WriteFloat(0);
                    moveUpdate.WriteFloat(0);
                }

                moveUpdate.WriteFloat(0);
            }

            if (movementValues.IsAlive)
            {
                moveUpdate.WriteUInt32(movementValues.Time);
            }

            BitPack.WriteGuidBytes(5, 7);

            moveUpdate.WriteFloat(vector.Z);

            BitPack.WriteGuidBytes(4, 3, 2, 6, 0);

            moveUpdate.WriteFloat(vector.X);

            if (movementValues.HasRotation)
            {
                moveUpdate.WriteFloat(vector.W);
            }

            moveUpdate.WriteFloat(vector.Y);

            Character pChar = WorldMgr.GetSession(guid).Character;

            ObjectMgr.SetPosition(ref pChar, vector, false);

            WorldMgr.SendToAllInZone(guid, moveUpdate);
        }
Beispiel #42
0
        public static void HandleCliQueryNPCText(ref PacketReader packet, ref WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            byte[] guidMask = { 4, 7, 3, 6, 0, 1, 5, 2 };
            byte[] guidBytes = { 5, 6, 7, 1, 2, 3, 0, 4 };

            var gossipTextId = packet.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(gossipTextId);
                queryNPCTextResponse.WriteInt32(0);
                queryNPCTextResponse.WriteFloat(1);

                for (int i = 0; i < 7; i++)
                    queryNPCTextResponse.WriteUInt32(0);

                queryNPCTextResponse.WriteInt32(gossipData.BroadCastText.Id);

                for (int i = 0; i < 7; i++)
                    queryNPCTextResponse.WriteUInt32(0);

                BitPack.Write(1);
                BitPack.Flush();

                var size = (uint)queryNPCTextResponse.BaseStream.Length - 13;
                queryNPCTextResponse.WriteUInt32Pos(size, 8);

                session.Send(ref queryNPCTextResponse);
            }
        }
Beispiel #43
0
        public void WriteUpdateObjectMovement(ref PacketWriter packet, ref Character character, UpdateFlag updateFlags)
        {
            ObjectMovementValues values = new ObjectMovementValues(updateFlags);

            BitPack BitPack = new BitPack(packet, character.Guid, character.GuildGuid);

            BitPack.Write(0);                       // New in 5.1.0, 654, Unknown
            BitPack.Write(values.Bit0);
            BitPack.Write(values.HasRotation);
            BitPack.Write(values.HasTarget);
            BitPack.Write(values.Bit2);
            BitPack.Write(values.HasUnknown3);
            BitPack.Write(values.BitCounter, 24);
            BitPack.Write(values.HasUnknown);
            BitPack.Write(values.HasGoTransportPosition);
            BitPack.Write(values.HasUnknown2);
            BitPack.Write(0);                       // New in 5.1.0, 784, Unknown
            BitPack.Write(values.IsSelf);
            BitPack.Write(values.Bit1);
            BitPack.Write(values.IsAlive);
            BitPack.Write(values.Bit3);
            BitPack.Write(values.HasUnknown4);
            BitPack.Write(values.HasStationaryPosition);
            BitPack.Write(values.IsVehicle);
            BitPack.Write(values.BitCounter2, 21);
            BitPack.Write(values.HasAnimKits);

            if (values.IsAlive)
            {
                BitPack.WriteGuidMask(3);
                BitPack.Write(0);                   // IsInterpolated, not implanted
                BitPack.Write(1);                   // Unknown_Alive_2, Reversed
                BitPack.Write(0);                   // Unknown_Alive_4
                BitPack.WriteGuidMask(2);
                BitPack.Write(0);                   // Unknown_Alive_1
                BitPack.Write(1);                   // Pitch or splineElevation, not implanted
                BitPack.Write(true);                // MovementFlags2 are not implanted
                BitPack.WriteGuidMask(4, 5);
                BitPack.Write(0, 24);               // BitCounter_Alive_1
                BitPack.Write(1);                   // Pitch or splineElevation, not implanted
                BitPack.Write(!values.IsAlive);
                BitPack.Write(0);                   // Unknown_Alive_3
                BitPack.WriteGuidMask(0, 6, 7);
                BitPack.Write(values.IsTransport);
                BitPack.Write(!values.HasRotation);

                if (values.IsTransport)
                {
                    // Transports not implanted.
                }

                /* MovementFlags2 are not implanted
                 * if (movementFlag2 != 0)
                 *     BitPack.Write(0, 12);*/

                BitPack.Write(true);                // Movementflags are not implanted
                BitPack.WriteGuidMask(1);

                /* IsInterpolated, not implanted
                 * if (IsInterpolated)
                 * {
                 *     BitPack.Write(0);            // IsFalling
                 * }*/

                BitPack.Write(0);                   // HasSplineData, don't write simple basic splineData

                /* Movementflags are not implanted
                 * if (movementFlags != 0)
                 *  BitPack.Write((uint)movementFlags, 30);*/

                // Don't send basic spline data and disable advanced data
                // if (HasSplineData)
                //BitPack.Write(0);             // Disable advance splineData
            }

            BitPack.Flush();

            if (values.IsAlive)
            {
                packet.WriteFloat((float)MovementSpeed.FlyBackSpeed);

                // Don't send basic spline data

                /*if (HasSplineBasicData)
                 * {
                 *  // Advanced spline data not implanted
                 *  if (HasAdvancedSplineData)
                 *  {
                 *
                 *  }
                 *
                 *  packet.WriteFloat(character.X);
                 *  packet.WriteFloat(character.Y);
                 *  packet.WriteUInt32(0);
                 *  packet.WriteFloat(character.Z);
                 * }*/

                packet.WriteFloat((float)MovementSpeed.SwimSpeed);

                if (values.IsTransport)
                {
                    // Not implanted
                }

                BitPack.WriteGuidBytes(1);
                packet.WriteFloat((float)MovementSpeed.TurnSpeed);
                packet.WriteFloat(character.Y);
                BitPack.WriteGuidBytes(3);
                packet.WriteFloat(character.Z);
                packet.WriteFloat(character.O);
                packet.WriteFloat((float)MovementSpeed.RunBackSpeed);
                BitPack.WriteGuidBytes(0, 6);
                packet.WriteFloat(character.X);
                packet.WriteFloat((float)MovementSpeed.WalkSpeed);
                BitPack.WriteGuidBytes(5);
                packet.WriteUInt32(0);
                packet.WriteFloat((float)MovementSpeed.PitchSpeed);
                BitPack.WriteGuidBytes(2);
                packet.WriteFloat((float)MovementSpeed.RunSpeed);
                BitPack.WriteGuidBytes(7);
                packet.WriteFloat((float)MovementSpeed.SwimBackSpeed);
                BitPack.WriteGuidBytes(4);
                packet.WriteFloat((float)MovementSpeed.FlySpeed);
            }

            if (values.HasRotation)
            {
                // Packed orientation
                packet.WriteUInt64(0);
            }
        }