Esempio n. 1
0
        public static void HandleUpdateObject(ref PacketReader packet, ref WorldClass session)
        {
            Character character = session.Character;
            PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);  // Grml sandbox style...
            updateObject.WriteUInt8(1);
            updateObject.WriteGuid(character.Guid);
            updateObject.WriteUInt8(4);

            UpdateFlag updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation | UpdateFlag.Self | UpdateFlag.Unknown4;
            WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);
            character.WriteUpdateFields(ref updateObject);

            session.Send(updateObject);
        }
Esempio n. 2
0
        public static void HandleUpdateObjectCreate(ref WorldClass session)
        {
            WorldObject character = session.Character;
            PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);
            updateObject.WriteUInt8((byte)UpdateType.CreateObject);
            updateObject.WriteGuid(character.Guid);
            updateObject.WriteUInt8((byte)ObjectType.Player);

            UpdateFlag updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation | UpdateFlag.Self;
            WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

            character.WriteUpdateFields(ref updateObject);
            character.WriteDynamicUpdateFields(ref updateObject);

            session.Send(ref updateObject);
        }
Esempio n. 3
0
        public static void HandleNameCache(ref PacketReader packet, ref WorldClass session)
        {
            Character pChar = session.Character;

            ulong guid = packet.ReadUInt64();
            uint realmId = packet.ReadUInt32();

            PacketWriter nameCache = new PacketWriter(LegacyMessage.NameCache);

            nameCache.WriteGuid(guid);
            nameCache.WriteUInt8(0);
            nameCache.WriteCString(pChar.Name);
            nameCache.WriteUInt32(realmId);
            nameCache.WriteUInt8(pChar.Race);
            nameCache.WriteUInt8(pChar.Gender);
            nameCache.WriteUInt8(pChar.Class);
            nameCache.WriteUInt8(0);

            session.Send(nameCache);
        }
Esempio n. 4
0
        public static void HandleUpdateObjectValues(ref WorldClass session)
        {
            WorldObject character = session.Character;
            PacketWriter updateObject = new PacketWriter(ServerMessage.ObjectUpdate);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);
            updateObject.WriteUInt8((byte)UpdateType.Values);
            updateObject.WriteGuid(character.Guid);

            character.WriteUpdateFields(ref updateObject);
            character.WriteDynamicUpdateFields(ref updateObject);

            session.Send(ref updateObject);
        }
Esempio n. 5
0
        public static void HandleUpdateObjectCreate(ref WorldClass session)
        {
            WorldObject character = session.Character;
            PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);
            updateObject.WriteUInt8((byte)UpdateType.CreateObject);
            updateObject.WriteGuid(character.Guid);
            updateObject.WriteUInt8((byte)ObjectType.Player);

            UpdateFlag updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation | UpdateFlag.Self;
            WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

            character.WriteUpdateFields(ref updateObject);
            character.WriteDynamicUpdateFields(ref updateObject);

            session.Send(ref updateObject);

            var tempSessions = new Dictionary<ulong, WorldClass>(WorldMgr.Sessions);
            tempSessions.Remove(character.Guid);

            if (tempSessions != null)
            {
                foreach (var s in tempSessions)
                {
                    if (s.Value.Character.CheckUpdateDistance(character))
                    {
                        updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                        updateObject.WriteUInt16((ushort)character.Map);
                        updateObject.WriteUInt32(1);
                        updateObject.WriteUInt8((byte)UpdateType.CreateObject);
                        updateObject.WriteGuid(character.Guid);
                        updateObject.WriteUInt8((byte)ObjectType.Player);

                        updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation;
                        WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

                        character.WriteUpdateFields(ref updateObject);
                        character.WriteDynamicUpdateFields(ref updateObject);

                        s.Value.Send(ref updateObject);
                    }
                }

                foreach (var s in tempSessions)
                {
                    WorldObject pChar = s.Value.Character;

                    if (character.CheckUpdateDistance(pChar))
                    {
                        character.ToCharacter().InRangeObjects.Add(pChar.Guid, pChar);

                        updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                        updateObject.WriteUInt16((ushort)pChar.Map);
                        updateObject.WriteUInt32(1);
                        updateObject.WriteUInt8((byte)UpdateType.CreateObject);
                        updateObject.WriteGuid(pChar.Guid);
                        updateObject.WriteUInt8((byte)ObjectType.Player);

                        updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation;
                        WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref pChar, updateFlags);

                        pChar.WriteUpdateFields(ref updateObject);
                        pChar.WriteDynamicUpdateFields(ref updateObject);

                        session.Send(ref updateObject);
                    }
                }
            }
        }
Esempio n. 6
0
        public static void HandleUpdateObject(ref WorldClass session)
        {
            WorldObject character = session.Character;
            PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);
            updateObject.WriteUInt8(1);
            updateObject.WriteGuid(character.Guid);
            updateObject.WriteUInt8(4);

            UpdateFlag updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation | UpdateFlag.Self;
            WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

            character.WriteUpdateFields(ref updateObject);
            character.WriteDynamicUpdateFields(ref updateObject);
            session.Send(ref updateObject);

            var tempSessions = new Dictionary<ulong, WorldClass>(WorldMgr.Sessions);
            tempSessions.Remove(character.Guid);

            if (tempSessions != null)
            {
                foreach (var s in tempSessions)
                {
                    if (character.Map != s.Value.Character.Map)
                        continue;

                    updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                    updateObject.WriteUInt16((ushort)character.Map);
                    updateObject.WriteUInt32(1);
                    updateObject.WriteUInt8(1);
                    updateObject.WriteGuid(character.Guid);
                    updateObject.WriteUInt8(4);

                    updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation;
                    WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

                    character.WriteUpdateFields(ref updateObject);
                    character.WriteDynamicUpdateFields(ref updateObject);

                    s.Value.Send(ref updateObject);
                }

                foreach (var s in tempSessions)
                {
                    WorldObject pChar = s.Value.Character;

                    if (pChar.Map != character.Map)
                        continue;

                    updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                    updateObject.WriteUInt16((ushort)pChar.Map);
                    updateObject.WriteUInt32(1);
                    updateObject.WriteUInt8(1);
                    updateObject.WriteGuid(pChar.Guid);
                    updateObject.WriteUInt8(4);

                    updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation;
                    WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref pChar, updateFlags);

                    pChar.WriteUpdateFields(ref updateObject);
                    pChar.WriteDynamicUpdateFields(ref updateObject);

                    session.Send(ref updateObject);
                }
            }

            character.AddCreatureSpawnsToWorld(ref session);
            character.AddGameObjectSpawnsToWorld(ref session);
        }
Esempio n. 7
0
        public void AddToWorld()
        {
            CreateFullGuid();
            CreateData(GameObject);

            Globals.SpawnMgr.AddSpawn(this, ref GameObject);

            SetGameObjectFields();

            WorldObject obj = this;
            UpdateFlag updateFlags = UpdateFlag.Rotation | UpdateFlag.StationaryPosition;

            foreach (var v in Globals.WorldMgr.Sessions)
            {
                Character pChar = v.Value.Character;

                if (pChar.CheckUpdateDistance(this))
                {
                    PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                    updateObject.WriteUInt16((ushort)Map);
                    updateObject.WriteUInt32(1);
                    updateObject.WriteUInt8(1);
                    updateObject.WriteGuid(Guid);
                    updateObject.WriteUInt8(5);

                    Globals.WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref obj, updateFlags);

                    WriteUpdateFields(ref updateObject);
                    WriteDynamicUpdateFields(ref updateObject);

                    v.Value.Send(ref updateObject);
                }
            }
        }
Esempio n. 8
0
        public static void HandleNameCache(ref PacketReader packet, ref WorldClass session)
        {
            ulong guid = packet.ReadUInt64();
            uint realmId = packet.ReadUInt32();

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

                if (pChar != null)
                {
                    PacketWriter nameCache = new PacketWriter(LegacyMessage.NameCache);

                    nameCache.WriteGuid(guid);
                    nameCache.WriteUInt8(0);
                    nameCache.WriteCString(pChar.Name);
                    nameCache.WriteUInt32(realmId);
                    nameCache.WriteUInt8(pChar.Race);
                    nameCache.WriteUInt8(pChar.Gender);
                    nameCache.WriteUInt8(pChar.Class);
                    nameCache.WriteUInt8(0);

                    session.Send(ref nameCache);
                }
            }
        }
Esempio n. 9
0
        public void AddToWorld()
        {
            CreateFullGuid();
            CreateData(Creature);

            Globals.SpawnMgr.AddSpawn(this, ref Creature);

            SetCreatureFields();

            WorldObject obj = this;
            UpdateFlag updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation;

            foreach (var v in Globals.WorldMgr.Sessions)
            {
                Character pChar = v.Value.Character;
                if (pChar.Map != Map)
                    continue;

                PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                updateObject.WriteUInt16((ushort)Map);
                updateObject.WriteUInt32(1);
                updateObject.WriteUInt8(1);
                updateObject.WriteGuid(Guid);
                updateObject.WriteUInt8(3);

                Globals.WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref obj, updateFlags);

                WriteUpdateFields(ref updateObject);
                WriteDynamicUpdateFields(ref updateObject);

                v.Value.Send(ref updateObject);
            }
        }
Esempio n. 10
0
        public static void HandleUpdateObjectValues(ref WorldClass session, bool broadcast = false, bool toself = true)
        {
            WorldObject character = session.Character;
            PacketWriter updateObject = new PacketWriter(ServerMessage.ObjectUpdate);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);
            updateObject.WriteUInt8((byte)UpdateType.Values);
            updateObject.WriteGuid(character.Guid);

            character.WriteUpdateFields(ref updateObject);
            character.WriteDynamicUpdateFields(ref updateObject);

            if (toself)
                session.Send(ref updateObject);

            if (broadcast)
                WorldMgr.SendToInRangeCharacter(character as Character, updateObject);
        }
Esempio n. 11
0
        public static void HandleUpdateObject(ref WorldClass session)
        {
            Character character = session.Character;
            PacketWriter updateObject = new PacketWriter(LegacyMessage.UpdateObject);

            updateObject.WriteUInt16((ushort)character.Map);
            updateObject.WriteUInt32(1);
            updateObject.WriteUInt8(1);
            updateObject.WriteGuid(character.Guid);
            updateObject.WriteUInt8(4);

            UpdateFlag updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation | UpdateFlag.Self;
            WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

            character.WriteUpdateFields(ref updateObject);
            character.WriteDynamicUpdateFields(ref updateObject);

            session.Send(updateObject);

            var tempSession = WorldMgr.Sessions;
            tempSession.Remove(character.Guid);

            foreach (var s in tempSession)
            {
                if (character.Zone != s.Value.Character.Zone)
                    continue;

                updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                updateObject.WriteUInt16((ushort)character.Map);
                updateObject.WriteUInt32(1);
                updateObject.WriteUInt8(1);
                updateObject.WriteGuid(character.Guid);
                updateObject.WriteUInt8(4);

                updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation;
                WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

                character.WriteUpdateFields(ref updateObject);
                character.WriteDynamicUpdateFields(ref updateObject);

                s.Value.Send(updateObject);
            }

            foreach (var s in tempSession)
            {
                character = s.Value.Character;

                if (character.Zone != session.Character.Zone)
                    continue;

                updateObject = new PacketWriter(LegacyMessage.UpdateObject);

                updateObject.WriteUInt16((ushort)character.Map);
                updateObject.WriteUInt32(1);
                updateObject.WriteUInt8(1);
                updateObject.WriteGuid(character.Guid);
                updateObject.WriteUInt8(4);

                updateFlags = UpdateFlag.Alive | UpdateFlag.Rotation;
                WorldMgr.WriteUpdateObjectMovement(ref updateObject, ref character, updateFlags);

                character.WriteUpdateFields(ref updateObject);
                character.WriteDynamicUpdateFields(ref updateObject);

                session.Send(updateObject);
            }
        }