Exemple #1
0
        internal void DoFinishLogout()
        {
            if (!m_isLoggingOut)
            {
                // cancel if logout was cancelled
                return;
            }

            var evt = LoggingOut;

            if (evt != null)
            {
                evt(this);
            }

            // take Player out of world context
            if (!World.RemoveCharacter(this))
            {
                // was already removed
                return;
            }

            // client might now do other things
            m_client.ActiveCharacter = null;
            Account.ActiveCharacter  = null;

            // set to false so it can't be cancelled anymore
            m_isLoggingOut = false;

            // get rid of any minions, totems and their summons
            RemoveSummonedEntourage();

            // jump out of vehicle
            DetatchFromVechicle();

            // remove from the channels they're in
            for (var i = ChatChannels.Count - 1; i >= 0; i--)
            {
                ChatChannels[i].Leave(this, true);
            }

            if (Ticket != null)
            {
                Ticket.OnOwnerLogout();
                Ticket = null;
            }

            if (m_TaxiMovementTimer != null)
            {
                m_TaxiMovementTimer.Stop();
            }

            GroupMgr.Instance.OnCharacterLogout(m_groupMember);
            GuildMgr.Instance.OnCharacterLogout(m_guildMember);
            RelationMgr.Instance.OnCharacterLogout(this);
            InstanceMgr.OnCharacterLogout(this);
            Battlegrounds.OnLogout();

            LastLogout = DateTime.Now;

            // delete and re-spawn corpses and pets when logging back in
            if (m_corpse != null)
            {
                m_corpse.Delete();
            }

            CancelAllActions();
            m_auras.CleanupAuras();

            m_Map.RemoveObjectNow(this);

            //if (!IsPlayerLogout)
            if (!Account.IsActive)
            {
                // Character has been banned
                m_client.Disconnect();
            }
            else
            {
                CharacterHandler.SendPlayerImmediateLogoutReply(m_client);
            }

            if (CharacterHandler.NotifyPlayerStatus)
            {
                World.Broadcast("{0} is now " + ChatUtility.Colorize("Offline", Color.Red) + ".", Name);
            }

            m_initialized = false;

            Dispose();
        }