Ejemplo n.º 1
0
 /// <summary>
 /// Initializes the specified client.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="data">The data.</param>
 internal void Init(GameClient client, UserData data)
 {
     _mClient = client;
     _subscriptionManager = new SubscriptionManager(Id, data);
     _badgeComponent = new BadgeComponent(Id, data);
     _inventoryComponent = new InventoryComponent(Id, client, data);
     _inventoryComponent.SetActiveState(client);
     _avatarEffectsInventoryComponent = new AvatarEffectsInventoryComponent(Id, client, data);
     Quests = data.Quests;
     _messenger = new HabboMessenger(Id);
     _messenger.Init(data.Friends, data.Requests);
     FriendCount = Convert.ToUInt32(data.Friends.Count);
     SpectatorMode = false;
     Disconnected = false;
     UsersRooms = data.Rooms;
     MinimailUnreadMessages = data.MiniMailCount;
     Relationships = data.Relations;
     AnsweredPolls = data.SuggestedPolls;
     _clothingManager = new UserClothing(Id);
     Preferences = new UserPreferences(Id);
     _youtubeManager = new YoutubeManager(Id);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes the information.
 /// </summary>
 /// <param name="data">The data.</param>
 internal void InitInformation(UserData data)
 {
     _subscriptionManager = new SubscriptionManager(Id, data);
     _badgeComponent = new BadgeComponent(Id, data);
     Quests = data.Quests;
     _messenger = new HabboMessenger(Id);
     _messenger.Init(data.Friends, data.Requests);
     SpectatorMode = false;
     Disconnected = false;
     UsersRooms = data.Rooms;
     Relationships = data.Relations;
     AnsweredPolls = data.SuggestedPolls;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Called when [disconnect].
        /// </summary>
        /// <param name="reason">The reason.</param>
        internal void OnDisconnect(string reason)
        {
            if (Disconnected)
                return;
            Disconnected = true;
            if (_inventoryComponent != null)
            {
                _inventoryComponent.RunDbUpdate();
                _inventoryComponent.SetIdleState();
            }
            var navilogs = string.Empty;
            if (NavigatorLogs.Any())
            {
                navilogs = NavigatorLogs.Values.Aggregate(navilogs, (current, navi) => current + string.Format("{0},{1},{2};", navi.Id, navi.Value1, navi.Value2));
                navilogs = navilogs.Remove(navilogs.Length - 1);
            }
            AzureEmulator.GetGame().GetClientManager().UnregisterClient(Id, UserName);

            Out.WriteLine(UserName + " disconnected from game. Reason: " + reason, "Azure.Users", ConsoleColor.DarkYellow);
            TimeSpan GetOnlineSeconds = DateTime.Now - TimeLoggedOn;
            int SecondsToGive = GetOnlineSeconds.Seconds;
            if (!_habboinfoSaved)
            {
                _habboinfoSaved = true;
                using (var queryReactor = AzureEmulator.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.SetQuery("UPDATE users SET activity_points = " + ActivityPoints + ", credits = " + Credits + ", diamonds = " + Diamonds + ", online='0', last_online = '" + AzureEmulator.GetUnixTimeStamp() + "', builders_items_used = " + BuildersItemsUsed + ", navilogs = @navilogs  WHERE id = " + Id + " LIMIT 1;UPDATE users_stats SET achievement_score=" + AchievementPoints + " WHERE id=" + Id + " LIMIT 1;");
                    queryReactor.AddParameter("navilogs", navilogs);
                    queryReactor.RunQuery();
                    queryReactor.RunFastQuery("UPDATE users_stats SET online_seconds = online_seconds + " + SecondsToGive + " WHERE id = " + Id);
                    if (HasFuse("moderator"))
                        queryReactor.RunFastQuery(
                            string.Format(
                                "UPDATE moderation_tickets SET status='open', moderator_id=0 WHERE status='picked' AND moderator_id={0}",
                                Id));
                }
            }
            if (InRoom && CurrentRoom != null)
                CurrentRoom.GetRoomUserManager().RemoveUserFromRoom(_mClient, false, false);
            if (_messenger != null)
            {
                _messenger.AppearOffline = true;
                _messenger.Destroy();
                _messenger = null;
            }

            if (_avatarEffectsInventoryComponent != null)
                _avatarEffectsInventoryComponent.Dispose();
            _mClient = null;
        }