예제 #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);
        }
예제 #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);
            }
        }
예제 #3
0
        public static void HandleUnlearnedSpells(ref WorldClass session, List<uint> oldSpells)
        {
            PacketWriter writer = new PacketWriter(ServerMessage.UnlearnedSpells);
            BitPack BitPack = new BitPack(writer);

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

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

            session.Send(ref writer);
        }
예제 #4
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);
        }
예제 #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;
        }
예제 #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);
        }
예제 #7
0
        public static void HandleLearnedSpells(ref WorldClass session, List<uint> newSpells)
        {
            PacketWriter writer = new PacketWriter(JAMCMessage.LearnedSpells);
            BitPack BitPack = new BitPack(writer);

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

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

            session.Send(ref writer);
        }
예제 #8
0
        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;
        }
예제 #9
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);
        }
예제 #10
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);
        }
예제 #11
0
        public static void HandleDBQueryBulk(ref PacketReader packet, ref WorldClass session)
        {
            var type = (DBTypes)packet.ReadUInt32();
            var unknown = packet.ReadInt32();
            var id = packet.ReadInt32();

            switch (type)
            {
                case DBTypes.BroadcastText:
                {
                    var broadCastText = GossipMgr.GetBroadCastText<Creature>(id);

                    PacketWriter dbReply = new PacketWriter(JAMCMessage.DBReply);
                    BitPack BitPack = new BitPack(dbReply);

                    var textLength = broadCastText.Text.Length;
                    var alternativeTextLength = broadCastText.AlternativeText.Length;
                    var size = 48;

                    if (textLength == 0 || alternativeTextLength == 0)
                        size += 1;

                    size += textLength + alternativeTextLength;

                    dbReply.WriteUInt32((uint)size);
                    dbReply.WriteInt32(broadCastText.Id);
                    dbReply.WriteInt32(broadCastText.Language);

                    dbReply.WriteUInt16((ushort)broadCastText.Text.Length);
                    dbReply.WriteString(broadCastText.Text);

                    dbReply.WriteUInt16((ushort)broadCastText.AlternativeText.Length);
                    dbReply.WriteString(broadCastText.AlternativeText);

                    broadCastText.Emotes.ForEach(emote => dbReply.WriteInt32(emote));

                    dbReply.WriteUInt32(1);

                    dbReply.WriteUInt32(0);    // UnixTime, last change server side
                    dbReply.WriteUInt32((uint)DBTypes.BroadcastText);
                    dbReply.WriteInt32(broadCastText.Id);

                    session.Send(ref dbReply);
                    break;
                }
            }
        }
예제 #12
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);
        }
예제 #13
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);
        }
예제 #14
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);
        }
예제 #15
0
        public static void HandleRealmSplit(ref PacketReader packet, ref WorldClass session)
        {
            uint realmSplitState = 0;
            var date = "01/01/01";

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

            BitPack.Write(date.Length, 7);
            realmSplit.WriteString(date);

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

            session.Send(ref realmSplit);

            // Crash!!!
            // Wrong data sent...
            // AddonMgr.WriteAddonData(ref session);
        }
예제 #16
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);
        }
예제 #17
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);
        }
예제 #18
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);
            }
        }
예제 #19
0
        public static void HandleBroadcastText(ref WorldClass session, int id)
        {
            var broadCastText = GossipMgr.GetBroadCastText<Creature>(id);

            PacketWriter dbReply = new PacketWriter(ServerMessage.DBReply);
            BitPack BitPack = new BitPack(dbReply);

            var textLength = broadCastText.Text.Length;
            var alternativeTextLength = broadCastText.AlternativeText.Length;
            var size = 48;

            if (textLength == 0 || alternativeTextLength == 0)
                size += 1;

            size += textLength + alternativeTextLength;

            dbReply.WriteUInt32(0);    // UnixTime, last change server side
            dbReply.WriteUInt32((uint)DBTypes.BroadcastText);
            dbReply.WriteUInt32((uint)size);

            dbReply.WriteInt32(broadCastText.Id);
            dbReply.WriteInt32(broadCastText.Language);

            dbReply.WriteUInt16((ushort)broadCastText.Text.Length);
            dbReply.WriteString(broadCastText.Text);

            dbReply.WriteUInt16((ushort)broadCastText.AlternativeText.Length);
            dbReply.WriteString(broadCastText.AlternativeText);

            broadCastText.Emotes.ForEach(emote => dbReply.WriteInt32(emote));

            dbReply.WriteUInt32(1);

            dbReply.WriteInt32(broadCastText.Id);

            session.Send(ref dbReply);
        }
예제 #20
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);
        }
예제 #21
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);
            }
        }
예제 #22
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);
            BitPack.Write(0);
            BitPack.Write(0);
            BitPack.Write(0);
            BitPack.Write(0);
            BitPack.Write(values.IsSelf);
            BitPack.Write(0);
            BitPack.Write(values.HasTarget);
            BitPack.Write(0, 22);
            BitPack.Write(0);
            BitPack.Write(0);
            BitPack.Write(0);
            BitPack.Write(0);
            BitPack.Write(values.HasStationaryPosition);
            BitPack.Write(0);
            BitPack.Write(values.IsAlive);
            BitPack.Write(values.HasAnimKits);
            BitPack.Write(values.IsVehicle);
            BitPack.Write(values.HasGoTransportPosition);
            BitPack.Write(0);
            BitPack.Write(wObject is GameObjectSpawn);

            if (values.IsAlive)
            {
                BitPack.WriteGuidMask(4, 1);
                BitPack.Write(0, 19);
                BitPack.WriteGuidMask(5);
                BitPack.Write(!values.HasRotation);
                BitPack.WriteGuidMask(7);
                BitPack.Write(0, 22);
                BitPack.Write(0);
                BitPack.Write(1);
                BitPack.Write(1);
                BitPack.WriteGuidMask(3);
                BitPack.Write(0);
                BitPack.Write(1);
                BitPack.Write(0);
                BitPack.Write(0);
                BitPack.WriteGuidMask(2);
                BitPack.Write(0);
                BitPack.WriteGuidMask(0);
                BitPack.Write(values.IsTransport);
                BitPack.WriteGuidMask(6);
                BitPack.Write(0);
                BitPack.Write(1);
                BitPack.Write(1);
            }

            BitPack.Flush();

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

            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));
            }
        }
예제 #23
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;
                }
            }
        }
예제 #24
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 :;
                    }
                }
            }
        }
예제 #25
0
        public static void SendMessage(ref WorldClass session, ChatMessageValues chatMessage, WorldClass pSession = null)
        {
            byte[] GuidMask   = { 4, 1, 3, 6, 2, 5, 0, 7 };
            byte[] GuidMask3  = { 6, 1, 3, 5, 4, 2, 7, 0 };
            byte[] GuidBytes  = { 7, 4, 0, 6, 3, 2, 5, 1 };
            byte[] GuidBytes3 = { 7, 4, 1, 3, 0, 6, 5, 2 };

            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(!chatMessage.HasLanguage);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(0, 8);
            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(0, 8);
            BitPack.Write(0);

            BitPack.WriteGuidMask(GuidMask3);

            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(!chatMessage.HasRealmId);
            BitPack.Write(0);
            BitPack.WriteStringLength(chatMessage.Message, 12);
            BitPack.Write(0);

            BitPack.WriteGuidMask(GuidMask);

            BitPack.Write(0);
            BitPack.Write(8, 9);

            BitPack.Flush();

            BitPack.WriteGuidBytes(GuidBytes3);

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

            BitPack.WriteGuidBytes(GuidBytes);

            chat.WriteString(chatMessage.Message, false);
            chat.WriteUInt8((byte)chatMessage.ChatType);

            chat.WriteInt32(0);

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

            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;
            }
        }
예제 #26
0
        public void DecompressDCTPatch()
        {
            byte[] volumeData =
            {
                0x08, 0x01, 0x10, 0x4c, 0x8b, 0xfa, 0x6d, 0xa7, 0x41, 0x01, 0x00, 0x07, 0x7e, 0xff, 0xf0, 0x18,
                0x38, 0x10, 0x30, 0x08, 0x03, 0x80, 0x82, 0x8a, 0xba, 0xda, 0xa4, 0x41, 0x01, 0x00, 0xe7, 0x3a,
                0x45, 0xf0, 0x90, 0xe1, 0x01, 0xc1, 0x03, 0x83, 0x87, 0x06, 0x0e, 0x08, 0x1c, 0x18, 0x38, 0x28,
                0x70, 0x30, 0xe0, 0x41, 0xc1, 0x03, 0x82, 0x07, 0x04, 0x0e, 0x06, 0x1c, 0x08, 0x38, 0x18, 0x70,
                0x30, 0xe0, 0x61, 0xc0, 0xc3, 0x81, 0x07, 0x01, 0x0e, 0x04, 0x1c, 0x0c, 0x38, 0x18, 0x70, 0x20,
                0xe0, 0x41, 0xc0, 0x43, 0x80, 0x87, 0x02, 0x0e, 0x04, 0x1c, 0x08, 0x38, 0x10, 0x70, 0x20, 0xe0,
                0x41, 0xc0, 0x43, 0x80, 0x87, 0x01, 0x0e, 0x04, 0x1c, 0x08, 0x38, 0x10, 0x70, 0x10, 0xe0, 0x21,
                0xc0, 0x43, 0x80, 0x83, 0x80, 0x87, 0x01, 0x0e, 0x02, 0x1c, 0x04, 0x38, 0x08, 0x70, 0x10, 0xe0,
                0x21, 0xc0, 0x43, 0x80, 0x83, 0x80, 0x87, 0x01, 0x0e, 0x02, 0x1c, 0x04, 0x38, 0x08, 0x70, 0x10,
                0xe0, 0x21, 0xc0, 0x43, 0x80, 0x81, 0xc0, 0x43, 0x80, 0x87, 0x01, 0x0e, 0x02, 0x1c, 0x04, 0x38,
                0x08, 0x70, 0x10, 0xe0, 0x21, 0xc0, 0x43, 0x80, 0x80, 0x38, 0x08, 0x70, 0x10, 0xe0, 0x21, 0xc0,
                0x43, 0x80, 0x85, 0x17, 0x6c, 0xe7, 0x4e, 0x82, 0x02, 0x00, 0x10, 0xff, 0xff, 0xd1, 0x66, 0x92,
                0x31, 0x08, 0x20, 0x80, 0x00, 0xce, 0xc6, 0xce, 0x9b, 0x0e, 0x1a, 0x0e, 0x3b, 0x07, 0xd2, 0x07,
                0x96, 0x06, 0x1e, 0x06, 0x65, 0x07, 0x2b, 0x07, 0x86, 0x06, 0x52, 0x06, 0x7c, 0x06, 0x05, 0x07,
                0x22, 0x06, 0x12, 0x07, 0x18, 0x07, 0x01, 0x06, 0x14, 0x07, 0x38, 0x07, 0x53, 0x07, 0x08, 0x07,
                0x19, 0x06, 0x0d, 0x06, 0x31, 0x06, 0x02, 0x07, 0x1b, 0x06, 0x09, 0x06, 0x0d, 0x03, 0x83, 0x03,
                0x0b, 0x03, 0x0c, 0x03, 0x89, 0x83, 0x89, 0x83, 0x0b, 0x03, 0x08, 0x01, 0xc4, 0x01, 0xc0, 0xc1,
                0x85, 0x81, 0x80, 0x41, 0xc6, 0x41, 0xc2, 0x80, 0xe0, 0xc0, 0xc0, 0x80, 0xc0, 0x60, 0xc0, 0x20,
                0xc1, 0xc0, 0xc0, 0x80, 0xe2, 0x80, 0xe1, 0x60, 0xc1, 0x00, 0x70, 0x40, 0x30, 0x18, 0x38, 0x18,
                0x38, 0x08, 0x30, 0x88, 0x30, 0x70, 0x38, 0x20, 0x38, 0x08, 0x30, 0x10, 0x38, 0x10, 0x1c, 0x08,
                0x0e, 0x04, 0x0e, 0x08, 0x0c, 0x02, 0x0e, 0x0a, 0x0e, 0x1c, 0x0e, 0x04, 0x0c, 0x0a, 0x03, 0x00,
                0x81, 0xc0, 0x40, 0xe0, 0x20, 0xe0, 0xa0, 0xc0, 0x60, 0xc0, 0xe0, 0x30, 0x18, 0x18, 0x04, 0x18,
                0x04, 0x18, 0x04, 0x0c, 0x02, 0x03, 0x01, 0x81, 0xc0, 0x81, 0x80, 0xc1, 0x80, 0x80, 0xc0, 0x20,
                0x70, 0x10, 0x30, 0x08, 0x38, 0x08, 0x18, 0x04, 0x1c, 0x04, 0x07, 0x03, 0x07, 0x02, 0x03, 0x81,
                0x00, 0xe0, 0x60, 0xc0, 0x40, 0xc0, 0x20, 0x60, 0x20, 0x60, 0x10, 0x30, 0x10, 0x07, 0x01, 0x03,
                0x01, 0x00, 0xc0, 0x40, 0xe0, 0x20, 0xc0, 0x20, 0xe0, 0x20, 0xe0, 0x60, 0x60, 0x10, 0x60, 0x10,
                0x60, 0x10, 0x0e, 0x02, 0x06, 0x01, 0x07, 0x01, 0x07, 0x01, 0x07, 0x02, 0x01, 0xc0, 0x80, 0xe0,
                0x20, 0xe0, 0x20, 0xe0, 0x20, 0xe0, 0x20, 0xc0, 0x40, 0xc0, 0x40, 0xe0, 0x40, 0x60, 0x20, 0x60,
                0x10, 0x70, 0x20, 0x30, 0x08, 0x30, 0x08, 0x0c, 0x02, 0x0c, 0x02, 0x0e, 0x02, 0x06, 0x02, 0x03,
                0x00, 0x81, 0xc0, 0x40, 0x38, 0x08, 0x18, 0x04, 0x0e, 0x06, 0x0c, 0x04, 0x03, 0x00, 0x80, 0x30,
                0x08, 0x38, 0x08, 0x38, 0x08, 0x30, 0x08, 0x1c, 0x04, 0x03, 0x80, 0x81, 0x80, 0x40, 0xe0, 0x20,
                0xe0, 0x20, 0x06, 0x01, 0x05, 0x10, 0x45, 0xfb, 0x08, 0x82, 0x0a, 0x00, 0x4e, 0xec, 0x8f, 0x28,
                0x5c, 0xd0, 0xea, 0x27, 0x33, 0xb6, 0x53, 0xe7, 0x4d, 0xf4, 0x75, 0x93, 0x01, 0x18, 0x1c, 0xe7,
                0x27, 0x6a, 0x36, 0x01, 0x8d, 0x8c, 0x34, 0x73, 0x73, 0x4c, 0x9c, 0xac, 0xe2, 0x06, 0x0e, 0x30,
                0x58, 0xe3, 0xe6, 0x12, 0x31, 0x21, 0x82, 0x0e, 0x06, 0x70, 0xb3, 0x03, 0x9c, 0x20, 0xc6, 0xa7,
                0x04, 0x38, 0xf9, 0xc1, 0x0c, 0x0c, 0x60, 0x33, 0x80, 0x9c, 0x1c, 0xe0, 0x66, 0x13, 0x38, 0x11,
                0xc0, 0x8c, 0x14, 0x60, 0xa3, 0x82, 0x1c, 0x28, 0xe0, 0x46, 0x11, 0x30, 0x49, 0x82, 0xce, 0x0c,
                0x70, 0x53, 0x00, 0x98, 0x04, 0xc0, 0x46, 0x02, 0x38, 0x20, 0xc0, 0x27, 0x02, 0x30, 0x51, 0xc2,
                0x0c, 0x16, 0x38, 0x19, 0xc0, 0xce, 0x04, 0x70, 0x83, 0x83, 0x18, 0x28, 0xc0, 0x67, 0x02, 0x38,
                0x09, 0xc0, 0x4e, 0x06, 0x07, 0x03, 0x38, 0x21, 0x80, 0x8e, 0x04, 0x70, 0x13, 0x07, 0x1c, 0x38,
                0xc0, 0xe7, 0x04, 0x38, 0x10, 0x70, 0x41, 0xc0, 0x8c, 0x06, 0x60, 0x13, 0x04, 0x9c, 0x18, 0xe0,
                0x66, 0x03, 0x38, 0x10, 0xe0, 0x21, 0xc0, 0x8e, 0x04, 0x70, 0x13, 0x01, 0x98, 0x04, 0xe0, 0xc6,
                0x06, 0x30, 0x39, 0xc1, 0xcc, 0x04, 0x70, 0x33, 0x00, 0x98, 0x08, 0xc0, 0x23, 0x00, 0x9c, 0x0c,
                0x70, 0x33, 0x01, 0x1c, 0x04, 0xc1, 0x46, 0x01, 0x38, 0x29, 0x80, 0x46, 0x01, 0x1c, 0x04, 0x18,
                0x04, 0xc0, 0x26, 0x02, 0x38, 0x19, 0xc0, 0x4c, 0x10, 0x38, 0x11, 0xc0, 0x43, 0x00, 0x9c, 0x04,
                0x70, 0x11, 0x80, 0x43, 0x00, 0x98, 0x14, 0x18, 0x04, 0xc0, 0x27, 0x01, 0x03, 0x80, 0x98, 0x04,
                0xc0, 0x41, 0xc0, 0x4e, 0x02, 0x70, 0x31, 0xc0, 0x4e, 0x06, 0x38, 0x19, 0x80, 0x40, 0x60, 0x13,
                0x01, 0x07, 0x01, 0x06, 0x02, 0x38, 0x18, 0xe0, 0x23, 0x81, 0x0e, 0x02, 0x30, 0x09, 0xc0, 0x8e,
                0x02, 0x38, 0x08, 0x1c, 0x0c, 0xc0, 0x26, 0x01, 0x38, 0x11, 0x80, 0x4e, 0x02, 0x0c, 0x06, 0x60,
                0x13, 0x81, 0x14, 0x51, 0xa4, 0x8c, 0x42, 0x08, 0x20, 0x01, 0x43, 0x9a, 0x7f, 0x64, 0x27, 0x4f,
                0x3e, 0x32, 0x18, 0xa0, 0xbc, 0x68, 0x78, 0x90, 0xf0, 0x61, 0xc2, 0x43, 0x5c, 0x87, 0x20, 0x0f,
                0x10, 0x18, 0xb8, 0x39, 0xd8, 0x64, 0x50, 0xc2, 0xc1, 0x8f, 0x83, 0x91, 0x06, 0x06, 0x0c, 0x38,
                0x1c, 0x6c, 0x38, 0x30, 0x61, 0x70, 0xe1, 0x01, 0x89, 0x83, 0x04, 0x86, 0x02, 0x0e, 0x34, 0x1c,
                0x18, 0x38, 0xf8, 0x70, 0x40, 0xe1, 0xc1, 0xc0, 0xc3, 0x81, 0x87, 0x01, 0x0c, 0x34, 0x1c, 0x34,
                0x38, 0xc0, 0x60, 0xf0, 0xe0, 0xa1, 0x81, 0xc3, 0x86, 0x06, 0x0b, 0x0c, 0x12, 0x18, 0x44, 0x38,
                0x28, 0x61, 0x00, 0xe0, 0xe1, 0x82, 0x83, 0x82, 0x86, 0x01, 0x0e, 0x24, 0x18, 0x10, 0x30, 0x68,
                0x70, 0x40, 0xe0, 0x21, 0x80, 0x83, 0x82, 0x86, 0x09, 0x0c, 0x12, 0x18, 0x08, 0x30, 0x10, 0x60,
                0x30, 0xe0, 0x41, 0xc3, 0x43, 0x81, 0x03, 0x80, 0x86, 0x04, 0x0e, 0x0e, 0x1c, 0x04, 0x38, 0x08,
                0x38, 0x58, 0x30, 0x10, 0x30, 0x28, 0x70, 0x50, 0xe0, 0x81, 0x80, 0xc3, 0x81, 0x06, 0x02, 0x0c,
                0x08, 0x0e, 0x02, 0x18, 0x08, 0x38, 0x08, 0x30, 0x20, 0x60, 0x10, 0x60, 0x20, 0xe0, 0x21, 0x81,
                0xc3, 0x81, 0x06, 0x02, 0x0e, 0x06, 0x18, 0x08, 0x38, 0x08, 0x38, 0x28, 0x30, 0x28, 0x70, 0x10,
                0x38, 0x18, 0x60, 0x40, 0xc0, 0xa1, 0x80, 0x81, 0xc0, 0xc3, 0x02, 0x03, 0x00, 0x87, 0x04, 0x0e,
                0x06, 0x1c, 0x14, 0x38, 0x08, 0x60, 0x10, 0xc0, 0x21, 0x80, 0xc3, 0x80, 0x80, 0x38, 0x08, 0x70,
                0x20, 0xe0, 0xc0, 0xc0, 0x40, 0xc0, 0x20, 0x70, 0x20, 0x60, 0x30, 0x18, 0x04, 0x38, 0x20, 0x70,
                0x10, 0x60, 0x10, 0x60, 0x10, 0xe0, 0x41, 0x80, 0xc1, 0x80, 0x83, 0x01, 0x83, 0x80, 0x83, 0x00,
                0x83, 0x80, 0x81, 0xc0, 0x83, 0x01, 0x86, 0x01, 0x0c, 0x02, 0x0e, 0x02, 0x06, 0x01, 0x0e, 0x04,
                0x18, 0x04, 0x38, 0x08, 0x38, 0x28, 0x60, 0x10, 0x70, 0x10, 0xc0, 0x40, 0x18, 0x04, 0x38, 0x08,
                0x70, 0x10, 0xe0, 0x40, 0x18, 0x04, 0x0e, 0x02, 0x1c, 0x04, 0x38, 0x08, 0x30, 0x10, 0x30, 0x08,
                0x30, 0x08, 0x70, 0x10, 0x01, 0x80, 0x41, 0xc0, 0x80, 0x0c, 0x02, 0x14, 0x5d, 0xb3, 0x9d, 0x3a,
                0x08, 0x08, 0x00, 0x4b, 0xff, 0xff, 0x30, 0x80,
            };

            float[] heights =
            {
                44.8443375f, 23.8873062f, 16.1412125f, 19.8912125f, 19.7037125f,   18.03965f, 19.7310562f,    19.0709f, 18.6724625f,  19.367775f, 19.0709f, 18.8912125f, 19.1685562f, 19.1763687f, 18.7310562f, 19.3130875f,
                22.3755875f, 14.9693375f, 21.8326187f, 17.8755875f, 19.0279312f, 19.5279312f, 18.7193375f,    19.0709f, 19.2935562f, 18.9068375f, 19.0709f, 19.1685562f,    19.0709f,    19.0709f, 19.1919937f, 18.9419937f,
                20.2232437f, 17.8951187f, 19.2466812f,  19.930275f, 17.6998062f, 20.3599625f, 18.4068375f, 19.1451187f, 19.2349625f, 18.8912125f, 19.0709f, 19.1763687f,    19.0709f,    19.0709f, 19.1998062f, 18.9341812f,
                15.4068375f,  23.430275f,   16.66465f, 19.1724625f,   20.47715f, 17.4107437f, 20.1099625f, 18.9888687f,  18.711525f, 19.3638687f, 19.0709f, 18.8443375f, 19.3130875f,    19.0709f, 18.7974625f, 19.3599625f,
                21.9537125f, 15.5044937f, 21.5591812f, 17.9576187f, 19.1373062f,  19.367775f,  18.742775f, 19.1607437f,    19.0709f,    19.0709f, 19.0709f, 19.1919937f, 18.9419937f,    19.0709f,    19.0709f,    19.0709f,
                18.72715f,   19.7310562f, 17.9576187f, 20.5318375f,  17.586525f, 20.2193375f, 18.6216812f,    19.0709f, 19.3873062f, 18.8443375f, 19.0709f,    19.0709f,    19.0709f, 18.9263687f, 19.2232437f, 18.9107437f,
                17.8013687f, 20.3599625f, 18.8716812f, 18.2544937f, 20.4654312f, 17.8130875f, 19.7544937f,    19.0709f, 18.7310562f, 19.3130875f, 19.0709f, 18.7974625f, 19.2154312f,    19.0709f, 18.9107437f, 19.2388687f,
                20.0084f,       18.0084f,   19.66465f, 18.9888687f, 18.8912125f, 19.3638687f, 18.8599625f,    19.0709f,    19.0709f,    19.0709f, 19.0709f, 19.2154312f, 18.9185562f, 19.2310562f,    19.0709f,    19.0709f,
                19.0709f,       19.0709f, 18.8248062f, 19.5201187f, 18.5826187f, 19.3873062f,    19.0709f,    19.0709f, 19.1998062f, 18.9341812f, 19.0709f,    19.0709f,    19.0709f, 18.9029312f, 19.2466812f,    19.0709f,
                18.774025f,  19.3169937f,    19.0709f, 18.9732437f, 19.2818375f, 18.9576187f,    19.0709f, 19.1998062f, 18.9341812f,    19.0709f, 19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,
                19.0709f,       19.0709f,    19.0709f,    19.0709f, 19.1841812f, 18.9498062f, 19.1998062f, 18.9341812f, 19.2154312f,    19.0709f, 19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,
                19.1607437f, 18.9732437f, 19.1763687f,    19.0709f,    19.0709f,    19.0709f, 18.9341812f, 19.2154312f, 18.9185562f,    19.0709f, 19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,
                19.0709f,       19.0709f, 18.9576187f, 19.3130875f, 18.6841812f, 19.3443375f,    19.0709f,    19.0709f, 19.2310562f, 18.9029312f, 19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,
                18.9654312f, 19.1841812f,    19.0709f, 18.9419937f, 19.3443375f, 18.7818375f, 19.2232437f,    19.0709f,    19.0709f,    19.0709f, 19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,
                19.0709f,       19.0709f, 19.1998062f, 18.7974625f, 19.2154312f,    19.0709f,    19.0709f, 19.2388687f, 18.8951187f,    19.0709f, 19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,
                19.3130875f, 18.9419937f,    19.0709f, 19.3599625f, 18.6138687f, 19.3912125f,    19.0709f, 18.8951187f,    19.0709f,    19.0709f, 19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,    19.0709f,
            };

            Surface surface = new Surface(SurfaceType.Land, null);

            surface.Create(256, 16, new Vector3Double(0, 0, 0), 256);

            BitPack bitPack = new BitPack(volumeData);

            GroupHeader groupHeader = new GroupHeader(bitPack);

            Assert.AreEqual(0x108, groupHeader.Stride);
            Assert.AreEqual(0x10, groupHeader.PatchSize);
            Assert.AreEqual(LayerType.Land, groupHeader.LayerType);

            surface.DecompressPatches(bitPack, groupHeader, false);
            SurfacePatch patch = surface.GetPatch(8, 6);

            Assert.AreEqual(0x60e0, patch.DataZStart); // y = 96, x = 224

            string s = "";

            for (int y = 0; y < surface.GridsPerEdge; y++)
            {
                for (int x = 0; x < surface.GridsPerEdge; x++)
                {
                    float height = surface.GetZ(x, y);
                    s += $"{height}, ";
                }
                s += "\n";
            }
            File.WriteAllText("surfaceHeightsUNITY.csv", s);

            //string s = "";
            //for (int y = 0; y < groupHeader.PatchSize; y++)
            //{
            //    for (int x = 0; x < groupHeader.PatchSize; x++)
            //    {
            //        s += $"{surface._SurfaceZ[patch.DataZStart + y * groupHeader.Stride + x]}, ";
            //    }
            //    s += "\n";
            //}
            //File.WriteAllText("surfacePatchHeights_8_6.csv", s);

            for (int y = 0; y < groupHeader.PatchSize; y++)
            {
                for (int x = 0; x < groupHeader.PatchSize; x++)
                {
                    Assert.AreEqual(heights[y * groupHeader.PatchSize + x], surface._SurfaceZ[patch.DataZStart + y * groupHeader.Stride + x]);
                }
            }

            //for (int i = 0; i < heights.Length; i++)
            //{
            //    Assert.AreEqual(heights[i], surface._SurfaceZ[patch.DataZStart + i], $"Height: Incorrect value at position {i}");
            //}
        }
예제 #27
0
        public static void HandleAuthResponse(ref PacketReader packet, WorldClass session)
        {
            BitUnpack arg_28_0 = new BitUnpack(packet);

            packet.Skip(23);
            Globals.ClientSalt = packet.ReadBytes(16u);
            packet.ReadBytes(24u);
            arg_28_0.GetBit();
            packet.ReadBytes(AuthenticationHandler.smethod_1(packet));
            while (true)
            {
IL_921:
                uint arg_82F_0 = 2017539580u;
                while (true)
                {
                    uint num;
                    switch ((num = (arg_82F_0 ^ 973532324u)) % 57u)
                    {
                    case 0u:
                        TimeHandler.HandleSetTimezoneInformation(ref session);
                        arg_82F_0 = (num * 3644867839u ^ 4102176202u);
                        continue;

                    case 1u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt32(0u);
                        arg_82F_0 = (num * 3925958146u ^ 429357566u);
                        continue;
                    }

                    case 2u:
                    {
                        BitPack bitPack;
                        bitPack.Flush();
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt32(0u);
                        arg_82F_0 = (num * 3843609867u ^ 274333066u);
                        continue;
                    }

                    case 3u:
                    {
                        PacketWriter packetWriter;
                        byte[,] array;
                        int num2;
                        packetWriter.WriteUInt8(array[num2, 1]);
                        arg_82F_0 = (num * 2139226297u ^ 222787957u);
                        continue;
                    }

                    case 4u:
                    {
                        int num3 = 0;
                        arg_82F_0 = (num * 1275993637u ^ 3289780354u);
                        continue;
                    }

                    case 5u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt32(0u);
                        BitPack bitPack;
                        bool    flag;
                        bitPack.Write <bool>(flag);
                        bool bit;
                        bitPack.Write <bool>(bit);
                        bitPack.Flush();
                        arg_82F_0 = (num * 190331667u ^ 3544293151u);
                        continue;
                    }

                    case 6u:
                    {
                        PacketWriter packetWriter;
                        int          num3;
                        byte[,] array2;
                        packetWriter.WriteUInt8(array2[num3, 0]);
                        arg_82F_0 = 979003297u;
                        continue;
                    }

                    case 7u:
                    {
                        SHA256Managed hashAlgorithm_;
                        byte[]        array3;
                        AuthenticationHandler.smethod_4(hashAlgorithm_, array3, array3.Length >> 1, array3.Length - (array3.Length >> 1));
                        SHA256Managed hashAlgorithm_2;
                        SHA256Managed hashAlgorithm_3;
                        AuthenticationHandler.smethod_3(hashAlgorithm_2, AuthenticationHandler.smethod_5(hashAlgorithm_3), 0, 32, AuthenticationHandler.smethod_5(hashAlgorithm_3), 0);
                        arg_82F_0 = (num * 4247721102u ^ 2164875264u);
                        continue;
                    }

                    case 8u:
                        goto IL_921;

                    case 9u:
                    {
                        int num3;
                        byte[,] array2;
                        arg_82F_0 = ((num3 < AuthenticationHandler.smethod_9(array2) / 2) ? 942732371u : 402681424u);
                        continue;
                    }

                    case 10u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt32(0u);
                        arg_82F_0 = (num * 1272726928u ^ 3573012072u);
                        continue;
                    }

                    case 11u:
                    {
                        int num4;
                        arg_82F_0 = ((num4 != 32) ? 1613600137u : 94715230u);
                        continue;
                    }

                    case 12u:
                    {
                        SHA256Managed hashAlgorithm_;
                        SHA256Managed hashAlgorithm_2;
                        AuthenticationHandler.smethod_4(hashAlgorithm_2, AuthenticationHandler.smethod_5(hashAlgorithm_), 0, 32);
                        AuthenticationHandler.sha2_3_grml = AuthenticationHandler.smethod_5(hashAlgorithm_2);
                        int num4 = 0;
                        int num5 = 0;
                        arg_82F_0 = (num * 1594528258u ^ 4035022218u);
                        continue;
                    }

                    case 13u:
                        arg_82F_0 = (num * 3592674904u ^ 3437742173u);
                        continue;

                    case 14u:
                        AuthenticationHandler.HandleConnectTo(session, 3724, 1, null);
                        arg_82F_0 = (num * 4096365546u ^ 2720471261u);
                        continue;

                    case 15u:
                    {
                        bool         bit          = false;
                        PacketWriter packetWriter = new PacketWriter(ServerMessage.AuthResponse, true);
                        arg_82F_0 = (num * 1668503324u ^ 4008787019u);
                        continue;
                    }

                    case 16u:
                    {
                        int num4;
                        arg_82F_0 = ((num4 < 40) ? 1976385685u : 1159001732u);
                        continue;
                    }

                    case 17u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt32(0u);
                        arg_82F_0 = (num * 3445906520u ^ 4063066220u);
                        continue;
                    }

                    case 18u:
                    {
                        BitPack bitPack;
                        bitPack.Write <int>(0);
                        bitPack.Write <int>(0);
                        arg_82F_0 = (num * 621848300u ^ 3406194050u);
                        continue;
                    }

                    case 19u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt32(0u);
                        arg_82F_0 = (num * 3867729530u ^ 1908424397u);
                        continue;
                    }

                    case 20u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt32(0u);
                        arg_82F_0 = (num * 1394835192u ^ 145004486u);
                        continue;
                    }

                    case 21u:
                    {
                        PacketWriter packetWriter;
                        byte[,] array2;
                        packetWriter.WriteInt32(AuthenticationHandler.smethod_9(array2) / 2);
                        byte[,] array;
                        packetWriter.WriteInt32(AuthenticationHandler.smethod_9(array) / 2);
                        arg_82F_0 = (num * 3125389306u ^ 6579303u);
                        continue;
                    }

                    case 22u:
                    {
                        byte[,] array;
                        int num2;
                        arg_82F_0 = ((num2 < AuthenticationHandler.smethod_9(array) / 2) ? 248887578u : 276684735u);
                        continue;
                    }

                    case 23u:
                    {
                        int num4;
                        num4++;
                        int num5;
                        num5++;
                        arg_82F_0 = (num * 2780937424u ^ 1515612061u);
                        continue;
                    }

                    case 24u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt32(0u);
                        packetWriter.WriteUInt32(0u);
                        arg_82F_0 = (num * 192068700u ^ 4062459581u);
                        continue;
                    }

                    case 25u:
                    {
                        byte[,] expr_4C2 = new byte[12, 2];
                        AuthenticationHandler.smethod_8(expr_4C2, fieldof(< PrivateImplementationDetails >.struct7_0).FieldHandle);
                        byte[,] array    = expr_4C2;
                        byte[,] expr_4D7 = new byte[19, 2];
                        AuthenticationHandler.smethod_8(expr_4D7, fieldof(< PrivateImplementationDetails >.B1151C6C80B16E10C2CAD0E6524E20DB89985020).FieldHandle);
                        byte[,] array2 = expr_4D7;
                        arg_82F_0      = (num * 775829900u ^ 1086551519u);
                        continue;
                    }

                    case 26u:
                        Manager.WorldMgr.SendHotfixes(session);
                        arg_82F_0 = (num * 2297567052u ^ 3529457580u);
                        continue;

                    case 27u:
                    {
                        BitPack bitPack;
                        bitPack.Write <int>(0);
                        arg_82F_0 = (num * 2838081966u ^ 1401284309u);
                        continue;
                    }

                    case 28u:
                    {
                        BitPack bitPack;
                        bitPack.Write <int>(0);
                        arg_82F_0 = (num * 1276988104u ^ 1332711413u);
                        continue;
                    }

                    case 29u:
                        new PacketWriter(ServerMessage.EnableCrypt, false);
                        session.Account = new Account
                        {
                            Id               = 1,
                            Email            = Module.smethod_35 <string>(2737471542u),
                            PasswordVerifier = Module.smethod_36 <string>(1789483827u),
                            Salt             = Module.smethod_36 <string>(2533110280u),
                            IP               = "",
                            SessionKey       = "",
                            SecurityFlags    = 0,
                            OS               = Module.smethod_36 <string>(2605452825u),
                            Expansion        = 5,
                            IsOnline         = false
                        };
                        arg_82F_0 = (num * 3099364030u ^ 778753807u);
                        continue;

                    case 30u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt8(6);
                        arg_82F_0 = (num * 960037049u ^ 4251590658u);
                        continue;
                    }

                    case 31u:
                    {
                        int num3;
                        num3++;
                        arg_82F_0 = (num * 2647826660u ^ 3081572510u);
                        continue;
                    }

                    case 32u:
                    {
                        int num5 = 0;
                        arg_82F_0 = (num * 2855624283u ^ 1934999727u);
                        continue;
                    }

                    case 33u:
                    {
                        PacketWriter packetWriter;
                        session.Send(ref packetWriter);
                        arg_82F_0 = 394845639u;
                        continue;
                    }

                    case 34u:
                    {
                        PacketWriter packetWriter;
                        BitPack      bitPack = new BitPack(packetWriter, 0uL, 0uL, 0uL, 0uL);
                        arg_82F_0 = (num * 3839928679u ^ 2674270183u);
                        continue;
                    }

                    case 35u:
                    {
                        BitPack bitPack;
                        bitPack.Write <int>(0);
                        arg_82F_0 = (num * 1275983207u ^ 2624941272u);
                        continue;
                    }

                    case 36u:
                        new PacketWriter(ServerMessage.SuspendComms, true).WriteUInt32(20u);
                        arg_82F_0 = (num * 3412051023u ^ 3748987744u);
                        continue;

                    case 37u:
                    {
                        PacketWriter packetWriter;
                        byte[,] array;
                        int num2;
                        packetWriter.WriteUInt8(array[num2, 0]);
                        arg_82F_0 = 1152594217u;
                        continue;
                    }

                    case 38u:
                    {
                        BitPack bitPack;
                        bitPack.Write <int>(0);
                        arg_82F_0 = (num * 1357121348u ^ 1027085582u);
                        continue;
                    }

                    case 39u:
                    {
                        SHA256Managed hashAlgorithm_2 = AuthenticationHandler.smethod_6();
                        byte[]        array3;
                        SHA256Managed hashAlgorithm_3;
                        AuthenticationHandler.smethod_4(hashAlgorithm_3, array3, 0, array3.Length >> 1);
                        arg_82F_0 = (num * 3349724847u ^ 3826309419u);
                        continue;
                    }

                    case 40u:
                    {
                        bool flag = true;
                        arg_82F_0 = (num * 2469044217u ^ 389509509u);
                        continue;
                    }

                    case 41u:
                    {
                        int num4;
                        int num5;
                        AuthenticationHandler.sessionKey[num4] = AuthenticationHandler.sha2_3_grml[num5];
                        arg_82F_0 = 121248238u;
                        continue;
                    }

                    case 42u:
                    {
                        SHA256Managed hashAlgorithm_2;
                        AuthenticationHandler.sha2_3_grml = AuthenticationHandler.smethod_5(hashAlgorithm_2);
                        arg_82F_0 = (num * 3186781206u ^ 568291510u);
                        continue;
                    }

                    case 43u:
                    {
                        SHA256Managed hashAlgorithm_2;
                        AuthenticationHandler.smethod_7(hashAlgorithm_2);
                        SHA256Managed hashAlgorithm_3;
                        AuthenticationHandler.smethod_3(hashAlgorithm_2, AuthenticationHandler.smethod_5(hashAlgorithm_3), 0, 32, AuthenticationHandler.smethod_5(hashAlgorithm_3), 0);
                        arg_82F_0 = (num * 273351295u ^ 2423198895u);
                        continue;
                    }

                    case 44u:
                    {
                        PacketWriter packetWriter;
                        int          num3;
                        byte[,] array2;
                        packetWriter.WriteUInt8(array2[num3, 1]);
                        arg_82F_0 = (num * 3258273611u ^ 1239887723u);
                        continue;
                    }

                    case 46u:
                    {
                        HMACSHA256 expr_182 = AuthenticationHandler.smethod_2(Globals.SessionKey);
                        AuthenticationHandler.smethod_3(expr_182, Globals.ServerSalt, 0, Globals.ServerSalt.Length, Globals.ServerSalt, 0);
                        AuthenticationHandler.smethod_3(expr_182, Globals.ClientSalt, 0, Globals.ClientSalt.Length, Globals.ClientSalt, 0);
                        AuthenticationHandler.smethod_4(expr_182, AuthenticationHandler.arr1, 0, AuthenticationHandler.arr1.Length);
                        byte[]        array3          = AuthenticationHandler.smethod_5(expr_182);
                        SHA256Managed hashAlgorithm_3 = AuthenticationHandler.smethod_6();
                        SHA256Managed hashAlgorithm_  = AuthenticationHandler.smethod_6();
                        arg_82F_0 = (num * 1844584669u ^ 1891453460u);
                        continue;
                    }

                    case 47u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt32(0u);
                        arg_82F_0 = (num * 1008232628u ^ 30771472u);
                        continue;
                    }

                    case 48u:
                    {
                        int num2 = 0;
                        arg_82F_0 = (num * 1707978014u ^ 2368748458u);
                        continue;
                    }

                    case 49u:
                    {
                        SHA256Managed hashAlgorithm_2;
                        AuthenticationHandler.smethod_3(hashAlgorithm_2, AuthenticationHandler.sha2_3_grml, 0, 32, AuthenticationHandler.sha2_3_grml, 0);
                        SHA256Managed hashAlgorithm_;
                        AuthenticationHandler.smethod_4(hashAlgorithm_2, AuthenticationHandler.smethod_5(hashAlgorithm_), 0, 32);
                        arg_82F_0 = (num * 1428097193u ^ 1748239185u);
                        continue;
                    }

                    case 50u:
                    {
                        BitPack bitPack;
                        bitPack.Write <int>(0);
                        arg_82F_0 = (num * 2377469058u ^ 4212942142u);
                        continue;
                    }

                    case 51u:
                    {
                        SHA256Managed hashAlgorithm_2;
                        AuthenticationHandler.smethod_3(hashAlgorithm_2, AuthenticationHandler.sha2_3_grml, 0, 32, AuthenticationHandler.sha2_3_grml, 0);
                        arg_82F_0 = (num * 116417243u ^ 3699589835u);
                        continue;
                    }

                    case 52u:
                    {
                        bool flag;
                        arg_82F_0 = (((!flag) ? 1888186652u : 1737280166u) ^ num * 1515350310u);
                        continue;
                    }

                    case 53u:
                    {
                        PacketWriter packetWriter;
                        packetWriter.WriteUInt8(6);
                        arg_82F_0 = (num * 200448416u ^ 3957963237u);
                        continue;
                    }

                    case 54u:
                    {
                        BitPack bitPack;
                        bitPack.Flush();
                        arg_82F_0 = (num * 2761573231u ^ 325309565u);
                        continue;
                    }

                    case 55u:
                        arg_82F_0 = (num * 1571901877u ^ 4021021157u);
                        continue;

                    case 56u:
                    {
                        int num2;
                        num2++;
                        arg_82F_0 = (num * 3035465689u ^ 1114317311u);
                        continue;
                    }
                    }
                    return;
                }
            }
        }
예제 #28
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);
        }
    }
예제 #29
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);
        }
예제 #30
0
        public virtual void LoadMesh(string filename)
        {
            byte[]  buffer = File.ReadAllBytes(filename);
            BitPack input  = new BitPack(buffer, 0);

            _header = TrimAt0(input.UnpackString(24));
            if (!String.Equals(_header, MESH_HEADER))
            {
                return;
            }

            // Populate base mesh variables
            _hasWeights         = (input.UnpackByte() != 0);
            _hasDetailTexCoords = (input.UnpackByte() != 0);
            _position           = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
            _rotationAngles     = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
            _rotationOrder      = input.UnpackByte();
            _scale       = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
            _numVertices = (ushort)input.UnpackUShort();

            // Populate the vertex array
            _vertices = new Vertex[_numVertices];

            for (int i = 0; i < _numVertices; i++)
            {
                _vertices[i].Coord = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
            }

            for (int i = 0; i < _numVertices; i++)
            {
                _vertices[i].Normal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
            }

            for (int i = 0; i < _numVertices; i++)
            {
                _vertices[i].BiNormal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
            }

            for (int i = 0; i < _numVertices; i++)
            {
                _vertices[i].TexCoord = new Vector2(input.UnpackFloat(), input.UnpackFloat());
            }

            if (_hasDetailTexCoords)
            {
                for (int i = 0; i < _numVertices; i++)
                {
                    _vertices[i].DetailTexCoord = new Vector2(input.UnpackFloat(), input.UnpackFloat());
                }
            }

            if (_hasWeights)
            {
                for (int i = 0; i < _numVertices; i++)
                {
                    _vertices[i].Weight = input.UnpackFloat();
                }
            }

            _numFaces = input.UnpackUShort();

            _faces = new Face[_numFaces];

            for (int i = 0; i < _numFaces; i++)
            {
                _faces[i].Indices = new short[] { input.UnpackShort(), input.UnpackShort(), input.UnpackShort() }
            }
            ;

            if (_hasWeights)
            {
                _numSkinJoints = input.UnpackUShort();
                _skinJoints    = new string[_numSkinJoints];

                for (int i = 0; i < _numSkinJoints; i++)
                {
                    _skinJoints[i] = TrimAt0(input.UnpackString(64));
                }
            }
            else
            {
                _numSkinJoints = 0;
                _skinJoints    = new string[0];
            }

            // Grab morphs
            List <Morph> morphs    = new List <Morph>();
            string       morphName = TrimAt0(input.UnpackString(64));

            while (morphName != MORPH_FOOTER)
            {
                if (input.BytePos + 48 >= input.Data.Length)
                {
                    throw new FileLoadException("Encountered end of file while parsing morphs");
                }

                Morph morph = new Morph();
                morph.Name        = morphName;
                morph.NumVertices = input.UnpackInt();
                morph.Vertices    = new MorphVertex[morph.NumVertices];

                for (int i = 0; i < morph.NumVertices; i++)
                {
                    morph.Vertices[i].VertexIndex = input.UnpackUInt();
                    morph.Vertices[i].Coord       = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
                    morph.Vertices[i].Normal      = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
                    morph.Vertices[i].BiNormal    = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
                    morph.Vertices[i].TexCoord    = new Vector2(input.UnpackFloat(), input.UnpackFloat());
                }

                morphs.Add(morph);

                // Grab the next name
                morphName = TrimAt0(input.UnpackString(64));
            }

            _morphs = morphs.ToArray();

            // Check if there are remaps or if we're at the end of the file
            if (input.BytePos < input.Data.Length - 1)
            {
                _numRemaps    = input.UnpackInt();
                _vertexRemaps = new VertexRemap[_numRemaps];

                for (int i = 0; i < _numRemaps; i++)
                {
                    _vertexRemaps[i].RemapSource      = input.UnpackInt();
                    _vertexRemaps[i].RemapDestination = input.UnpackInt();
                }
            }
            else
            {
                _numRemaps    = 0;
                _vertexRemaps = new VertexRemap[0];
            }
        }
예제 #31
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 :;
            }
        }
예제 #32
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);
        }
예제 #33
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);
            }
        }
예제 #34
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);
            }
        }
예제 #35
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.HasTarget);
            BitPack.Write(values.Bit1);
            BitPack.Write(values.HasUnknown2);
            BitPack.Write(0);                       // New in 5.1.0, 784, Unknown
            BitPack.Write(values.Bit0);
            BitPack.Write(values.Bit3);
            BitPack.Write(0);                       // New in 5.1.0, 654, Unknown
            BitPack.Write(values.IsSelf);
            BitPack.Write(values.HasGoTransportPosition);
            BitPack.Write(values.HasUnknown);
            BitPack.Write(wObject is GameObjectSpawn);
            BitPack.Write(values.IsAlive);
            BitPack.Write(values.HasUnknown4);
            BitPack.Write(values.HasAnimKits);
            BitPack.Write(values.HasUnknown3);
            BitPack.Write(values.IsVehicle);
            BitPack.Write(values.HasStationaryPosition);
            BitPack.Write(values.Bit2);
            BitPack.Write(values.BitCounter, 22);

            if (values.IsAlive)
            {
                BitPack.WriteGuidMask(7);
                BitPack.Write(0, 19);               // BitCounter_Alive_1
                BitPack.Write(0);                   // IsInterpolated, not implanted
                BitPack.Write(values.IsTransport);
                BitPack.Write(0);                   // Unknown_Alive_1
                BitPack.WriteGuidMask(0);
                BitPack.Write(1);                   // splineElevation, not implanted
                BitPack.Write(true);                // Movementflags are not implanted
                BitPack.Write(0);                   // HasSplineData, don't write simple basic splineData
                BitPack.WriteGuidMask(1);
                BitPack.Write(true);                // MovementFlags2 are not implanted
                BitPack.Write(0, 22);               // BitCounter_Alive_2
                BitPack.WriteGuidMask(3, 5, 6);
                BitPack.Write(0);                   // Unknown_Alive_3
                BitPack.Write(!values.HasRotation);
                BitPack.Write(1);                   // Pitch, not implanted
                BitPack.Write(1);                   // Unknown_Alive_2, Reversed
                BitPack.WriteGuidMask(2);
                BitPack.Write(!values.IsAlive);
                BitPack.Write(0);                   // Unknown_Alive_4
                BitPack.WriteGuidMask(4);
            }

            BitPack.Flush();

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

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

            if (wObject is GameObjectSpawn)
            {
                packet.WriteInt64(Quaternion.GetCompressed(wObject.Position.O));
            }
        }
예제 #36
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);
            }
        }
예제 #37
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);
        }
예제 #38
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);
            }
        }
예제 #39
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);
        }
예제 #40
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(1);
            BitPack.Write(result.Count, 16);

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

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

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

                BitPack.Write(0, 21);
                BitPack.Flush();

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

                    BitPack.WriteGuidBytes(4);

                    enumCharacters.WriteUInt8(result.Read <byte>(c, "Race"));

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

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

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

                    enumCharacters.WriteFloat(result.Read <float>(c, "X"));
                    enumCharacters.WriteUInt32(result.Read <uint>(c, "CharacterFlags"));

                    BitPack.WriteGuildGuidBytes(0);

                    enumCharacters.WriteUInt32(result.Read <uint>(c, "PetLevel"));
                    enumCharacters.WriteUInt32(result.Read <uint>(c, "Map"));

                    BitPack.WriteGuildGuidBytes(7);

                    enumCharacters.WriteUInt32(result.Read <uint>(c, "CustomizeFlags"));

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

                    enumCharacters.WriteFloat(result.Read <float>(c, "Y"));
                    enumCharacters.WriteUInt32(result.Read <uint>(c, "PetFamily"));
                    enumCharacters.WriteString(name);
                    enumCharacters.WriteUInt32(result.Read <uint>(c, "PetDisplayId"));

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

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

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

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

                    enumCharacters.WriteFloat(result.Read <float>(c, "Z"));
                    enumCharacters.WriteUInt32(result.Read <uint>(c, "Zone"));
                    enumCharacters.WriteUInt8(result.Read <byte>(c, "FacialHair"));
                    enumCharacters.WriteUInt8(result.Read <byte>(c, "Class"));

                    BitPack.WriteGuildGuidBytes(5);

                    enumCharacters.WriteUInt8(result.Read <byte>(c, "Skin"));
                    enumCharacters.WriteUInt8(result.Read <byte>(c, "Gender"));
                    enumCharacters.WriteUInt8(result.Read <byte>(c, "Face"));

                    BitPack.WriteGuidBytes(0);

                    enumCharacters.WriteUInt8(result.Read <byte>(c, "HairColor"));
                }
            }
            else
            {
                BitPack.Write(0, 21);
                BitPack.Flush();
            };

            session.Send(ref enumCharacters);
        }
예제 #41
0
        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);
        }
        public static void HandleAuthResponse(ref PacketReader packet, WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            packet.Skip(54);

            int addonSize = packet.Read <int>();

            packet.Skip(addonSize);

            uint   nameLength  = BitUnpack.GetBits <uint>(11);
            string accountName = packet.ReadString(nameLength);

            SQLResult result = DB.Realms.Select("SELECT * FROM accounts WHERE name = ?", accountName);

            if (result.Count == 0)
            {
                session.clientSocket.Close();
            }
            else
            {
                session.Account = new Account()
                {
                    Id         = result.Read <int>(0, "id"),
                    Name       = result.Read <string>(0, "name"),
                    Password   = result.Read <string>(0, "password"),
                    SessionKey = result.Read <string>(0, "sessionkey"),
                    Expansion  = result.Read <byte>(0, "expansion"),
                    GMLevel    = result.Read <byte>(0, "gmlevel"),
                    IP         = result.Read <string>(0, "ip"),
                    Language   = result.Read <string>(0, "language")
                }
            };

            string K = session.Account.SessionKey;

            byte[] kBytes = new byte[K.Length / 2];

            for (int i = 0; i < K.Length; i += 2)
            {
                kBytes[i / 2] = Convert.ToByte(K.Substring(i, 2), 16);
            }

            session.Crypt.Initialize(kBytes);

            uint      realmId          = WorldConfig.RealmId;
            SQLResult realmClassResult = DB.Realms.Select("SELECT class, expansion FROM realm_classes WHERE realmId = ?", realmId);
            SQLResult realmRaceResult  = DB.Realms.Select("SELECT race, expansion FROM realm_races WHERE realmId = ?", realmId);

            var HasAccountData = true;
            var IsInQueue      = false;

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

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

            BitPack.Write(IsInQueue);

            if (IsInQueue)
            {
                BitPack.Write(1);                                  // Unknown
            }
            BitPack.Write(HasAccountData);

            if (HasAccountData)
            {
                BitPack.Write(0);
                BitPack.Write(0, 21);
                BitPack.Write(0, 21);
                BitPack.Write(realmRaceResult.Count, 23);
                BitPack.Write(0);
                BitPack.Write(0);
                BitPack.Write(0);
                BitPack.Write(realmClassResult.Count, 23);
            }

            BitPack.Flush();

            if (HasAccountData)
            {
                authResponse.WriteUInt32(0);
                authResponse.WriteUInt32(0);
                authResponse.WriteUInt8(session.Account.Expansion);

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


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

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

                authResponse.WriteUInt32(0);
                authResponse.WriteUInt32(0);
            }

            if (IsInQueue)
            {
                authResponse.WriteUInt32(0);
            }

            session.Send(ref authResponse);

            MiscHandler.HandleCacheVersion(ref session);
            TutorialHandler.HandleTutorialFlags(ref session);
        }
    }
예제 #43
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);
            BitPack.Write(values.IsVehicle);
            BitPack.Write(0);
            BitPack.Write(wObject is GameObjectSpawn);
            BitPack.Write(0);
            BitPack.Write(values.IsAlive);
            BitPack.Write(values.IsSceneObject);
            BitPack.Write(0);
            BitPack.Write(values.IsAreaTrigger);
            BitPack.Write(values.IsSelf);
            BitPack.Write(0);
            BitPack.Write(0);
            BitPack.Write(values.HasGoTransportPosition);
            BitPack.Write(values.IsTransport);
            BitPack.Write(values.HasAnimKits);
            BitPack.Write(values.HasStationaryPosition);
            BitPack.Write(values.HasTarget);
            BitPack.Write(0);
            BitPack.Write(0, 22);
            BitPack.Write(0);
            BitPack.Write(0);

            if (values.IsAlive)
            {
                BitPack.Write(values.IsTransport);
                BitPack.Write(1);
                BitPack.Write(0);
                BitPack.Write(0, 19);
                BitPack.WriteGuidMask(1);
                BitPack.Write(!values.HasMovementFlags2);
                BitPack.Write(0);
                BitPack.Write(1);

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

                BitPack.Write(!values.HasRotation);
                BitPack.Write(0);
                BitPack.Write(!values.HasMovementFlags);
                BitPack.Write(1);
                BitPack.WriteGuidMask(2, 6);
                BitPack.Write(values.IsFallingOrJumping);
                BitPack.WriteGuidMask(5, 4, 0);

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

                BitPack.Write(0);

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

                BitPack.Write(0, 22);
                BitPack.WriteGuidMask(7);
                BitPack.Write(0);
                BitPack.WriteGuidMask(3);
            }

            BitPack.Flush();

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

                    packet.WriteFloat(values.JumpVelocity);
                    packet.WriteUInt32(values.FallTime);
                }

                packet.WriteFloat(wObject.Position.Z);
                packet.WriteFloat(wObject.Position.Y);
                packet.WriteFloat(MovementSpeed.FlySpeed);
                BitPack.WriteGuidBytes(6);
                packet.WriteFloat(MovementSpeed.FlyBackSpeed);
                packet.WriteFloat(wObject.Position.X);
                BitPack.WriteGuidBytes(2);
                packet.WriteFloat(MovementSpeed.SwimBackSpeed);
                BitPack.WriteGuidBytes(1);
                packet.WriteFloat(MovementSpeed.RunBackSpeed);
                packet.WriteFloat(MovementSpeed.SwimSpeed);
                BitPack.WriteGuidBytes(5);
                packet.WriteFloat(MovementSpeed.TurnSpeed);
                BitPack.WriteGuidBytes(3);
                packet.WriteFloat(MovementSpeed.RunSpeed);
                BitPack.WriteGuidBytes(7);
                packet.WriteFloat(MovementSpeed.WalkSpeed);
                packet.WriteFloat(MovementSpeed.PitchSpeed);
                packet.WritePackedTime();
                BitPack.WriteGuidBytes(4, 0);

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

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

            if (wObject is GameObjectSpawn)
            {
                packet.WriteInt64(Quaternion.GetCompressed(wObject.Position.O));
            }
        }
예제 #44
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);
        }
예제 #45
0
        public static void HandleQueryGameObject(ref PacketReader packet, WorldClass session)
        {
            byte[] guidMask  = { 3, 6, 0, 7, 2, 1, 4, 5 };
            byte[] guidBytes = { 3, 6, 1, 2, 0, 7, 5, 4 };

            BitUnpack BitUnpack = new BitUnpack(packet);

            var id   = packet.Read <int>();
            var guid = BitUnpack.GetPackedValue(guidMask, guidBytes);

            PacketWriter queryGameObjectResponse = new PacketWriter(ServerMessage.QueryGameObjectResponse);
            BitPack      BitPack = new BitPack(queryGameObjectResponse);

            var gObject = DataMgr.FindGameObject(id);
            var hasData = (gObject != null);

            queryGameObjectResponse.WriteInt32(id);
            queryGameObjectResponse.WriteInt32(0);

            if (hasData)
            {
                var stats = gObject.Stats;

                queryGameObjectResponse.WriteInt32((int)stats.Type);
                queryGameObjectResponse.WriteInt32(stats.DisplayInfoId);

                queryGameObjectResponse.WriteCString(stats.Name);

                for (int i = 0; i < 3; i++)
                {
                    queryGameObjectResponse.WriteCString("");
                }

                queryGameObjectResponse.WriteCString(stats.IconName);
                queryGameObjectResponse.WriteCString(stats.CastBarCaption);
                queryGameObjectResponse.WriteCString("");

                foreach (var v in stats.Data)
                {
                    queryGameObjectResponse.WriteInt32(v);
                }

                queryGameObjectResponse.WriteFloat(stats.Size);
                queryGameObjectResponse.WriteUInt8((byte)stats.QuestItemId.Count);

                foreach (var v in stats.QuestItemId)
                {
                    queryGameObjectResponse.WriteInt32(v);
                }

                queryGameObjectResponse.WriteInt32(stats.ExpansionRequired);

                var size = (uint)queryGameObjectResponse.BaseStream.Length - 13;
                queryGameObjectResponse.WriteUInt32Pos(size, 9);
            }
            else
            {
                Log.Message(LogType.Debug, "Gameobject (Id: {0}) not found.", id);
            }

            BitPack.Write(hasData);
            BitPack.Flush();

            session.Send(ref queryGameObjectResponse);
        }
예제 #46
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);
        }
예제 #47
0
        public static void HandleQueryPlayerName(ref PacketReader packet, WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            var guidMask  = new bool[8];
            var guidBytes = new byte[8];

            guidMask[4] = BitUnpack.GetBit();

            var hasUnknown = BitUnpack.GetBit();

            guidMask[2] = BitUnpack.GetBit();
            guidMask[5] = BitUnpack.GetBit();
            guidMask[7] = BitUnpack.GetBit();
            guidMask[3] = BitUnpack.GetBit();
            guidMask[6] = BitUnpack.GetBit();
            guidMask[0] = BitUnpack.GetBit();
            guidMask[1] = BitUnpack.GetBit();

            var hasUnknown2 = BitUnpack.GetBit();

            if (guidMask[1])
            {
                guidBytes[1] = (byte)(packet.Read <byte>() ^ 1);
            }
            if (guidMask[0])
            {
                guidBytes[0] = (byte)(packet.Read <byte>() ^ 1);
            }
            if (guidMask[2])
            {
                guidBytes[2] = (byte)(packet.Read <byte>() ^ 1);
            }
            if (guidMask[6])
            {
                guidBytes[6] = (byte)(packet.Read <byte>() ^ 1);
            }
            if (guidMask[4])
            {
                guidBytes[4] = (byte)(packet.Read <byte>() ^ 1);
            }
            if (guidMask[7])
            {
                guidBytes[7] = (byte)(packet.Read <byte>() ^ 1);
            }
            if (guidMask[5])
            {
                guidBytes[5] = (byte)(packet.Read <byte>() ^ 1);
            }
            if (guidMask[3])
            {
                guidBytes[3] = (byte)(packet.Read <byte>() ^ 1);
            }

            if (hasUnknown2)
            {
                packet.Read <uint>();
            }

            if (hasUnknown)
            {
                packet.Read <uint>();
            }

            var guid = BitConverter.ToUInt64(guidBytes, 0);

            var pSession = WorldMgr.GetSession(guid);

            if (pSession != null)
            {
                var pChar = pSession.Character;

                if (pChar != null)
                {
                    PacketWriter queryPlayerNameResponse = new PacketWriter(ServerMessage.QueryPlayerNameResponse);
                    BitPack      BitPack = new BitPack(queryPlayerNameResponse, guid);

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

                    BitPack.Flush();

                    BitPack.WriteGuidBytes(1);

                    queryPlayerNameResponse.WriteUInt8(0);

                    queryPlayerNameResponse.WriteUInt32(WorldConfig.RealmId);
                    queryPlayerNameResponse.WriteUInt32(0);
                    queryPlayerNameResponse.WriteUInt8(pChar.Level);
                    queryPlayerNameResponse.WriteUInt8(pChar.Race);
                    queryPlayerNameResponse.WriteUInt8(pChar.Gender);
                    queryPlayerNameResponse.WriteUInt8(pChar.Class);

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

                    BitPack.Write(0);

                    BitPack.WriteGuidMask(3);

                    BitPack.Write(0);
                    BitPack.Write(0);
                    BitPack.WriteGuidMask(6);

                    BitPack.Write(pChar.Name.Length, 6);

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

                    BitPack.WriteGuidMask(1, 4);

                    for (int i = 0; i < 5; i++)
                    {
                        BitPack.Write(0, 7);
                    }

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

                    BitPack.Flush();

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

                    queryPlayerNameResponse.WriteString(pChar.Name);

                    session.Send(ref queryPlayerNameResponse);
                }
            }
        }
예제 #48
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);
            }
        }
예제 #49
0
        public static void HandleQueryCreature(ref PacketReader packet, WorldClass session)
        {
            var id = packet.Read <int>();

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

            var creature = DataMgr.FindCreature(id);
            var hasData  = (creature != null);

            queryCreatureResponse.WriteInt32(id);

            BitPack.Write(hasData);

            if (hasData)
            {
                var stats = creature.Stats;

                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.QuestItemId.Count, 22);
                BitPack.Write(stats.SubName.Length != 0 ? stats.SubName.Length + 1 : 0, 11);
                BitPack.Write(0, 11);

                BitPack.Flush();

                queryCreatureResponse.WriteFloat(stats.PowerModifier);
                queryCreatureResponse.WriteCString(stats.Name);
                queryCreatureResponse.WriteFloat(stats.HealthModifier);
                queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[1]);
                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[1]);

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

                queryCreatureResponse.WriteInt32(stats.Type);

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

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

                queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[0]);
                queryCreatureResponse.WriteInt32(stats.Family);
                queryCreatureResponse.WriteInt32(stats.MovementInfoId);
                queryCreatureResponse.WriteInt32(stats.ExpansionRequired);
                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[0]);
                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[2]);
                queryCreatureResponse.WriteInt32(stats.Rank);

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

                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[3]);
            }
            else
            {
                Log.Message(LogType.Debug, "Creature (Id: {0}) not found.", id);
            }

            session.Send(ref queryCreatureResponse);
        }
예제 #50
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);
            }
        }
예제 #51
0
        private static int EncodePatchHeader(BitPack output, TerrainPatch.Header header, int[] patch, int RegionSizeX,
                                             int RegionSizeY, int wbits)
        {
            /*
             *      int temp;
             *      int wbits = (header.QuantWBits & 0x0f) + 2;
             *      uint maxWbits = (uint)wbits + 5;
             *      uint minWbits = ((uint)wbits >> 1);
             *      int wbitsMaxValue;
             */
            // goal is to determ minimum number of bits to use so all data fits

            /*
             *      wbits = (int)minWbits;
             *      wbitsMaxValue = (1 << wbits);
             *
             *      for (int i = 0; i < patch.Length; i++)
             *      {
             *          temp = patch[i];
             *          if (temp != 0)
             *          {
             *              // Get the absolute value
             *              if (temp < 0) temp *= -1;
             *
             * no coments..
             *
             *              for (int j = (int)maxWbits; j > (int)minWbits; j--)
             *              {
             *                  if ((temp & (1 << j)) != 0)
             *                  {
             *                      if (j > wbits) wbits = j;
             *                      break;
             *                  }
             *              }
             *
             *              while (temp > wbitsMaxValue)
             *                  {
             *                  wbits++;
             *                  if (wbits == maxWbits)
             *                      goto Done;
             *                  wbitsMaxValue = 1 << wbits;
             *                  }
             *          }
             *      }
             *
             *  Done:
             *
             *      //            wbits += 1;
             */
            // better check
            if (wbits > 17)
            {
                wbits = 16;
            }
            else if (wbits < 3)
            {
                wbits = 3;
            }

            header.QuantWBits &= 0xf0;

            header.QuantWBits |= (wbits - 2);

            output.PackBits(header.QuantWBits, 8);
            output.PackFloat(header.DCOffset);
            output.PackBits(header.Range, 16);
            if (RegionSizeX > Constants.RegionSize || RegionSizeY > Constants.RegionSize)
            {
                output.PackBits(header.PatchIDs, 32);
            }
            else
            {
                output.PackBits(header.PatchIDs, 10);
            }

            return(wbits);
        }
예제 #52
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);
                }
            }
        }
예제 #53
0
        private static void EncodePatch(BitPack output, int[] patch, int postquant, int wbits)
        {
            int maxwbitssize = (1 << wbits) - 1;

            if (postquant > Constants.TerrainPatchSize * Constants.TerrainPatchSize || postquant < 0)
            {
                Logger.Log("Postquant is outside the range of allowed values in EncodePatch()", Helpers.LogLevel.Error);
                return;
            }

            if (postquant != 0)
            {
                patch[Constants.TerrainPatchSize * Constants.TerrainPatchSize - postquant] = 0;
            }

            for (int i = 0; i < Constants.TerrainPatchSize * Constants.TerrainPatchSize; i++)
            {
                int temp = patch[i];

                if (temp == 0)
                {
                    bool eob = true;

                    for (int j = i; j < Constants.TerrainPatchSize * Constants.TerrainPatchSize - postquant; j++)
                    {
                        if (patch[j] != 0)
                        {
                            eob = false;
                            break;
                        }
                    }

                    if (eob)
                    {
                        output.PackBits(ZERO_EOB, 2);
                        return;
                    }
                    output.PackBits(ZERO_CODE, 1);
                }
                else
                {
                    if (temp < 0)
                    {
                        temp *= -1;

                        if (temp > maxwbitssize)
                        {
                            temp = maxwbitssize;
                        }

                        output.PackBits(NEGATIVE_VALUE, 3);
                        output.PackBits(temp, wbits);
                    }
                    else
                    {
                        if (temp > maxwbitssize)
                        {
                            temp = maxwbitssize;
                        }

                        output.PackBits(POSITIVE_VALUE, 3);
                        output.PackBits(temp, wbits);
                    }
                }
            }
        }
예제 #54
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);
            }
        }
예제 #55
0
        public void LayerData()
        {
            byte[] buffer =
            {
                0x08, 0x01, 0x10, 0x4C, 0x8A, 0x40, 0x93, 0xB5, 0x41, 0x01, 0x00, 0x08, 0x7F, 0xD6, 0x6C, 0x50,
                0xE7, 0x05, 0x8E, 0x07, 0x17, 0x07, 0x28, 0x0C, 0x4C, 0x1C, 0x38, 0x1D, 0xCC, 0x32, 0xC8, 0x70,
                0x10, 0xC3, 0x81, 0x86, 0x43, 0x82, 0x86, 0x09, 0x0C, 0x02, 0x18, 0x14, 0x30, 0xA8, 0x71, 0x40,
                0xE4, 0xA1, 0x86, 0x43, 0x09, 0x06, 0x0F, 0x0E, 0x1E, 0x18, 0x30, 0x30, 0x68, 0x30, 0x10, 0x60,
                0x70, 0xC0, 0x21, 0x81, 0x43, 0x06, 0x07, 0x03, 0x0E, 0x0C, 0x1C, 0x20, 0x30, 0x08, 0x60, 0x20,
                0xC1, 0x01, 0xC1, 0xC3, 0x03, 0x86, 0x02, 0x0E, 0x02, 0x18, 0x08, 0x30, 0x28, 0x30, 0x18, 0x60,
                0x30, 0xC0, 0x61, 0x80, 0x43, 0x80, 0x86, 0x08, 0x0C, 0x02, 0x18, 0x0C, 0x30, 0x30, 0x70, 0xD0,
                0xC0, 0x21, 0x80, 0x43, 0x82, 0x86, 0x06, 0x0C, 0x02, 0x1C, 0x08, 0x30, 0x28, 0x18, 0x08, 0x30,
                0x08, 0x60, 0x10, 0xC0, 0x41, 0xC0, 0x43, 0x80, 0x86, 0x05, 0x0E, 0x02, 0x0C, 0x06, 0x1C, 0x08,
                0x30, 0x10, 0x60, 0xF0, 0xE1, 0xC0, 0x60, 0x10, 0xC0, 0x21, 0x80, 0x41, 0x80, 0x83, 0x80, 0x86,
                0x01, 0x01, 0x80, 0x40, 0x60, 0x10, 0xC0, 0x21, 0xC0, 0x83, 0x01, 0x87, 0x01, 0x01, 0x80, 0x83,
                0x05, 0x07, 0x06, 0x03, 0x00, 0x83, 0x00, 0x87, 0x01, 0x0C, 0x02, 0x0E, 0x02, 0x06, 0x01, 0x0C,
                0x02, 0x1C, 0x04, 0x0E, 0x02, 0x00, 0x60, 0x10, 0x0C, 0x04, 0x18, 0x0C, 0x38, 0x08, 0x30, 0x10,
                0x30, 0x08, 0x60, 0x10, 0x60, 0x10, 0x0E, 0x02, 0x0C, 0x02, 0x1C, 0x04, 0x00, 0x00, 0x60, 0x10,
                0x30, 0x08, 0x00, 0x00, 0xC0, 0x20, 0x03, 0x00, 0x85, 0x17, 0x95, 0x87, 0x6E, 0x82, 0x02, 0x01,
                0xD0, 0x7F, 0x3C, 0xE2, 0xE0, 0x61, 0xC0, 0xE1, 0xC0, 0x60, 0x40, 0x60, 0x30, 0x38, 0x38, 0x38,
                0x28, 0x31, 0x58, 0x31, 0x58, 0x30, 0x48, 0x30, 0x48, 0x18, 0x10, 0x0E, 0x0A, 0x0E, 0x08, 0x0E,
                0x06, 0x0E, 0x0C, 0x0C, 0x22, 0x0C, 0x2C, 0x0C, 0x04, 0x06, 0x07, 0x06, 0x03, 0x07, 0x02, 0x03,
                0x00, 0x83, 0x80, 0x83, 0x81, 0x03, 0x81, 0x03, 0x80, 0x83, 0x01, 0x83, 0x01, 0x03, 0x09, 0x03,
                0x04, 0x80, 0x70, 0x20, 0x03, 0x00, 0x83, 0x00, 0x83, 0x00, 0x83, 0x80, 0x83, 0x00, 0x80, 0x60,
                0xB0, 0x60, 0x80, 0x70, 0x10, 0x60, 0x20, 0x38, 0x08, 0x38, 0x08, 0x38, 0x08, 0x00, 0x60, 0x10,
                0x0E, 0x04, 0x0C, 0x02, 0x0C, 0x02, 0x0C, 0x02, 0x0C, 0x06, 0x0C, 0x0A, 0x00, 0x00, 0x0C, 0x02,
                0x00, 0xE0, 0x20, 0x60, 0x10, 0x30, 0x18, 0x03, 0x80, 0x80, 0x00, 0x00, 0x01, 0x80, 0x80, 0x38,
                0x08, 0x28, 0xB8, 0xC3, 0x9B, 0x74, 0x10, 0x10, 0x00, 0x77, 0xB9, 0xDB, 0x25, 0x87, 0x2A, 0x83,
                0x94, 0x03, 0x12, 0x83, 0x4B, 0x03, 0x28, 0x03, 0x93, 0x03, 0x8C, 0x03, 0x0B, 0x03, 0x82, 0x83,
                0x06, 0x03, 0x05, 0x83, 0x88, 0x83, 0x21, 0x83, 0x1B, 0x81, 0x82, 0x01, 0xC0, 0x81, 0x80, 0x41,
                0xC0, 0xC1, 0x80, 0xC1, 0xC1, 0x40, 0xE0, 0x20, 0xC0, 0x80, 0xE0, 0x40, 0xC4, 0x80, 0xC3, 0x00,
                0xE0, 0x80, 0xC0, 0x20, 0xE0, 0x80, 0xE0, 0x40, 0xC0, 0x40, 0xC0, 0x60, 0xE0, 0x80, 0xC0, 0x20,
                0xE0, 0x60, 0xE0, 0x60, 0xC0, 0x40, 0x70, 0x30, 0x60, 0x10, 0x60, 0x10, 0x61, 0x60, 0x61, 0x20,
                0x60, 0x30, 0x60, 0x20, 0x70, 0x10, 0x1C, 0x04, 0x18, 0x04, 0x07, 0x02, 0x00, 0x38, 0x08, 0x38,
                0x18, 0x30, 0x08, 0x18, 0x30, 0x18, 0x20, 0x0E, 0x02, 0x0E, 0x04, 0x01, 0x80, 0x41, 0x80, 0x40,
                0xE0, 0x20, 0xC0, 0x20, 0x1C, 0x04, 0x00, 0x70, 0x10, 0x60, 0x30, 0x60, 0x70, 0x60, 0x60, 0x60,
                0x20, 0x30, 0x08, 0x00, 0x70, 0x10, 0x18, 0x04, 0x00, 0x0E, 0x02, 0x0E, 0x02, 0x03, 0x01, 0x80,
                0xE0, 0x40, 0x0C, 0x02, 0x00, 0x1C, 0x04, 0x00, 0x01, 0x80, 0x41, 0xC0, 0x41, 0x80, 0x80, 0x0E,
                0x02, 0x00, 0x00, 0x18, 0x04, 0x01, 0xC0, 0x40, 0x60, 0x10, 0x00, 0x00, 0x38, 0x08, 0x28, 0xA7,
                0x4A, 0x48, 0x74, 0x10, 0x70, 0x0E, 0x73, 0x4B, 0xD7, 0xB4, 0x2E, 0x82, 0xBF, 0x40, 0x3A, 0x80,
                0xE8, 0xC0, 0xE3, 0x41, 0x9A, 0x03, 0x84, 0x86, 0x42, 0x0C, 0x98, 0x18, 0xAC, 0x30, 0x98, 0x71,
                0x70, 0xC3, 0x01, 0xC3, 0xC3, 0x0C, 0x07, 0x0E, 0x0E, 0x44, 0x18, 0x20, 0x38, 0x08, 0x70, 0x80,
                0xE2, 0x21, 0xC7, 0xC3, 0x82, 0x86, 0x1A, 0x0E, 0x10, 0x18, 0x18, 0x30, 0x28, 0x60, 0x50, 0xE0,
                0x61, 0x85, 0x03, 0x00, 0x87, 0x04, 0x0E, 0x18, 0x18, 0x24, 0x30, 0x38, 0x60, 0x30, 0xC0, 0xE1,
                0x80, 0x83, 0x01, 0x87, 0x05, 0x0C, 0x02, 0x18, 0x0C, 0x38, 0x10, 0x60, 0x40, 0xE0, 0x41, 0xC0,
                0x81, 0x80, 0x83, 0x81, 0x86, 0x03, 0x0C, 0x0A, 0x0C, 0x08, 0x1C, 0x0C, 0x38, 0x18, 0x70, 0x20,
                0xE0, 0x21, 0xC1, 0x03, 0x01, 0x87, 0x02, 0x0E, 0x0C, 0x1C, 0x04, 0x30, 0x18, 0x30, 0x08, 0x1C,
                0x04, 0x38, 0x20, 0x30, 0x18, 0x70, 0x20, 0xE0, 0xA1, 0xC1, 0x03, 0x81, 0x07, 0x02, 0x07, 0x01,
                0x0C, 0x04, 0x0C, 0x02, 0x18, 0x08, 0x30, 0x08, 0x0E, 0x02, 0x18, 0x04, 0x06, 0x01, 0x0E, 0x02,
                0x0C, 0x06, 0x18, 0x0C, 0x38, 0x08, 0x60, 0x20, 0xC0, 0x21, 0x80, 0x43, 0x02, 0x01, 0x80, 0x83,
                0x80, 0x80, 0xC0, 0x21, 0xC0, 0xC3, 0x00, 0x86, 0x02, 0x03, 0x00, 0x81, 0xC0, 0x40, 0xC0, 0x21,
                0xC0, 0x40, 0x1C, 0x08, 0x1C, 0x04, 0x1C, 0x04, 0x0C, 0x02, 0x0E, 0x02, 0x00, 0x30, 0x08, 0x30,
                0x08, 0x00, 0x00, 0xC0, 0x40, 0x06, 0x01, 0x00, 0x1C, 0x04, 0x01, 0xC0, 0x40, 0x70, 0x20, 0xA2,
                0xC4, 0x3E, 0xA6, 0x90, 0x41, 0x40, 0x02, 0x5C, 0x95, 0x1C, 0xAC, 0x1C, 0xAA, 0x0F, 0x06, 0x0F,
                0x26, 0x0E, 0xC0, 0x0C, 0x08, 0x0C, 0xD8, 0x0C, 0xA0, 0x0C, 0x8E, 0x0C, 0x12, 0x0E, 0x46, 0x0E,
                0x18, 0x0C, 0x0C, 0x0C, 0x1A, 0x0C, 0x08, 0x0C, 0x0A, 0x0E, 0x16, 0x0C, 0x18, 0x0C, 0x0C, 0x0C,
                0x4A, 0x0E, 0x1A, 0x0E, 0x44, 0x0E, 0x2A, 0x0E, 0x1C, 0x07, 0x01, 0x07, 0x0E, 0x06, 0x02, 0x03,
                0x01, 0x83, 0x04, 0x03, 0x05, 0x83, 0x07, 0x03, 0x07, 0x83, 0x80, 0x83, 0x83, 0x83, 0x80, 0x83,
                0x85, 0x03, 0x82, 0x83, 0x82, 0x83, 0x81, 0x03, 0x83, 0x01, 0xC0, 0xC0, 0x70, 0x10, 0x38, 0x10,
                0x38, 0x10, 0x30, 0x20, 0x18, 0x14, 0x18, 0x10, 0x0E, 0x0A, 0x0E, 0x04, 0x0C, 0x04, 0x0C, 0x06,
                0x0C, 0x0A, 0x03, 0x00, 0x80, 0xE0, 0x40, 0x70, 0x10, 0x60, 0x20, 0x60, 0x20, 0x70, 0x20, 0x70,
                0x40, 0x30, 0x10, 0x30, 0x10, 0x18, 0x04, 0x18, 0x04, 0x0C, 0x02, 0x0C, 0x02, 0x0C, 0x02, 0x06,
                0x01, 0x07, 0x01, 0x07, 0x01, 0x06, 0x01, 0x03, 0x01, 0x03, 0x01, 0x00, 0xE0, 0x20, 0x30, 0x10,
                0x0E, 0x02, 0x0E, 0x04, 0x0E, 0x02, 0x00, 0x0C, 0x04, 0x0C, 0x02, 0x0E, 0x02, 0x00, 0xC0, 0x20,
                0x00, 0xE0, 0x20, 0x70, 0x20, 0x70, 0x10, 0x70, 0x10, 0x70, 0x10, 0x0E, 0x02, 0x00, 0xC0, 0x20,
                0xC0, 0x20, 0x18, 0x04, 0x00, 0x00, 0x38, 0x08, 0x38, 0x08, 0x01, 0x80, 0x41, 0x30, 0x80
            };
            BitPack bitPack = new BitPack(buffer);

            // GroupHeader:
            UInt16 stride = bitPack.GetUInt16_Le();

            Assert.AreEqual(0x0108, stride);

            byte patchSize = bitPack.GetUInt8();

            Assert.AreEqual(0x10, patchSize);

            byte layerType = bitPack.GetUInt8();

            Assert.AreEqual(0x4c, layerType);

            // PatchHeader:
            byte quantWBits = bitPack.GetUInt8();

            Assert.AreEqual(0x8a, quantWBits);

            float dcOffset = bitPack.GetFloat_Le();

            Assert.AreEqual(22.6969f, dcOffset);

            UInt16 range = bitPack.GetUInt16_Le();

            Assert.AreEqual(1, range);

            UInt16 patchIds = bitPack.GetUInt16_Le(10);

            Assert.AreEqual(0x0108, patchIds);
        }