Ejemplo n.º 1
0
        public static void HandleCharacterSelect(WorldSession session, ClientCharacterSelect characterSelect)
        {
            Character character = session.Characters.SingleOrDefault(c => c.Id == characterSelect.CharacterId);

            if (character == null)
            {
                session.EnqueueMessageEncrypted(new ServerCharacterSelectFail
                {
                    Result = CharacterSelectResult.Failed
                });
                return;
            }

            session.Player = new Player(session, character);

            WorldEntry entry = GameTableManager.World.GetEntry(character.WorldId);

            if (entry == null)
            {
                throw new ArgumentOutOfRangeException();
            }

            switch (entry.Type)
            {
            // housing map
            case 5:
            {
                // characters logging in to a housing map are returned to their own residence
                session.EnqueueEvent(new TaskGenericEvent <Residence>(ResidenceManager.GetResidence(session.Player.Name),
                                                                      residence =>
                    {
                        if (residence == null)
                        {
                            residence = ResidenceManager.CreateResidence(session.Player);
                        }

                        ResidenceEntrance entrance = ResidenceManager.GetResidenceEntrance(residence);
                        var mapInfo = new MapInfo(entrance.Entry, 0u, residence.Id);
                        MapManager.AddToMap(session.Player, mapInfo, entrance.Position);
                    }));

                break;
            }

            default:
            {
                var mapInfo = new MapInfo(entry);
                var vector3 = new Vector3(character.LocationX, character.LocationY, character.LocationZ);
                MapManager.AddToMap(session.Player, mapInfo, vector3);
                break;
            }
            }
        }
Ejemplo n.º 2
0
        public static void HandleCharacterSelect(WorldSession session, ClientCharacterSelect characterSelect)
        {
            Character character = session.Characters.SingleOrDefault(c => c.Id == characterSelect.CharacterId);

            if (character == null)
            {
                session.EnqueueMessageEncrypted(new ServerCharacterSelectFail
                {
                    Result = CharacterSelectResult.Failed
                });
                return;
            }

            session.Player = new Player(session, character);
            Vector3 vector = new Vector3(character.LocationX, character.LocationY, character.LocationZ);

            MapManager.AddToMap(session.Player, character.WorldId, vector);
        }
Ejemplo n.º 3
0
        public static void HandleCharacterSelect(WorldSession session, ClientCharacterSelect characterSelect)
        {
            Character character = session.Characters.SingleOrDefault(c => c.Id == characterSelect.CharacterId);

            if (character == null)
            {
                session.EnqueueMessageEncrypted(new ServerCharacterSelectFail
                {
                    Result = CharacterSelectResult.Failed
                });
                return;
            }

            session.Player = new Player(session, character);

            // TODO: make this not so... static
            ushort  worldId = 870;
            Vector3 vector  = new Vector3(-7683.809f, -942.5914f, -666.6343f);

            MapManager.AddToMap(session.Player, worldId, vector);
        }
Ejemplo n.º 4
0
        public static void HandleCharacterSelect(WorldSession session, ClientCharacterSelect characterSelect)
        {
            CharacterModel character = session.Characters.SingleOrDefault(c => c.Id == characterSelect.CharacterId);

            if (character == null)
            {
                session.EnqueueMessageEncrypted(new ServerCharacterSelectFail
                {
                    Result = CharacterSelectResult.Failed
                });
                return;
            }

            if (PlayerCleanupManager.HasPendingCleanup(session.Account))
            {
                session.EnqueueMessageEncrypted(new ServerCharacterSelectFail
                {
                    Result = CharacterSelectResult.FailedCharacterInWorld
                });
                return;
            }

            session.Player = new Player(session, character);

            WorldEntry entry = GameTableManager.Instance.World.GetEntry(character.WorldId);

            if (entry == null)
            {
                throw new ArgumentOutOfRangeException();
            }

            switch ((MapType)entry.Type)
            {
            case MapType.Residence:
            case MapType.Community:
            {
                // characters logging in to a housing map are returned to their own residence
                Residence residence = session.Player.ResidenceManager.Residence;
                residence ??= GlobalResidenceManager.Instance.CreateResidence(session.Player);

                ResidenceEntrance entrance = GlobalResidenceManager.Instance.GetResidenceEntrance(residence.PropertyInfoId);
                session.Player.Rotation = entrance.Rotation.ToEulerDegrees();
                MapManager.Instance.AddToMap(session.Player, new MapPosition
                    {
                        Info = new MapInfo
                        {
                            Entry      = entrance.Entry,
                            InstanceId = residence.Parent?.Id ?? residence.Id
                        },
                        Position = entrance.Position
                    });

                break;
            }

            default:
            {
                session.Player.Rotation = new Vector3(character.RotationX, character.RotationY, character.RotationZ);
                MapManager.Instance.AddToMap(session.Player, new MapPosition
                    {
                        Info = new MapInfo
                        {
                            Entry = entry
                        },
                        Position = new Vector3(character.LocationX, character.LocationY, character.LocationZ)
                    });
                break;
            }
            }
        }