コード例 #1
0
        /// <summary>
        /// Obtiene la clase Habbo mediante el Id de usuario.
        /// </summary>
        /// <param name="userId">Id del usuario</param>
        /// <returns></returns>
        internal static Habbo getHabboCache(uint userId)
        {
            GameClient client = OtanixEnvironment.GetGame().GetClientManager().GetClientByUserID(userId);

            if (client != null && client.GetHabbo() != null)
            {
                if (usersHabboCache.ContainsKey(userId))
                {
                    usersHabboCache.Remove(userId);
                }

                return(client.GetHabbo());
            }

            if (usersHabboCache.ContainsKey(userId))
            {
                return(usersHabboCache[userId]);
            }

            Habbo habbo = UserDataFactory.GetUserDataCache(userId);

            if (habbo != null)
            {
                if (!usersHabboCache.ContainsKey(userId))
                {
                    usersHabboCache.Add(userId, habbo);
                }
            }

            return(habbo);
        }
コード例 #2
0
        internal RelationshipComposer(uint userID, UserDataFactory data)
        {
            this.UserID = userID;
            foreach (Relationship relation in data.GetRelationships())
            {
                if (!this.composedRelations.ContainsKey(relation.targetID))
                {
                    composedRelations.Add(relation.targetID, relation.relationshipStatus);

                    switch (relation.relationshipStatus)
                    {
                    case 1:
                        relationshipStatusIndex[0]++;
                        break;

                    case 2:
                        relationshipStatusIndex[1]++;
                        break;

                    case 3:
                        relationshipStatusIndex[2]++;
                        break;
                    }
                }
            }
        }
コード例 #3
0
        internal void method_0(UserDataFactory class12_0)
        {
            this.hashtable_0 = new Hashtable();
            DataTable dataTable_ = class12_0.GetFriends();

            if (dataTable_ != null)
            {
                foreach (DataRow dataRow in dataTable_.Rows)
                {
                    if (!this.hashtable_0.Contains((uint)dataRow["Id"]))
                    {
                        this.hashtable_0.Add((uint)dataRow["Id"], new MessengerBuddy((uint)dataRow["Id"], dataRow["username"] as string, dataRow["look"] as string, dataRow["motto"] as string, dataRow["last_online"] as string));
                    }
                }
                try
                {
                    if (this.method_25().GetHabbo().HasFuse("receive_sa"))
                    {
                        this.hashtable_0.Add(0, new MessengerBuddy(0u, "Team Chat", "sh-290-64.ha-3129-73.fa-1206-1325.hr-893-39.lg-270-100.hd-3091-1.ch-3215-62.cc-3039-73", "Staff Chat Room", "0"));
                    }
                }
                catch
                {
                }
            }
        }
コード例 #4
0
        public static Habbo GetHabboById(int UserId)
        {
            try
            {
                if (GetGame() == null)
                {
                    return(null);
                }

                if (GetGame().GetClientManager() == null)
                {
                    return(null);
                }

                GameClient Client = GetGame().GetClientManager().GetClientByUserID(UserId);

                if (Client != null)
                {
                    Habbo User = Client.GetHabbo();
                    if (User != null && User.Id > 0)
                    {
                        if (_usersCached.ContainsKey(UserId))
                        {
                            _usersCached.TryRemove(UserId, out User);
                        }
                        return(User);
                    }
                }
                else
                {
                    try
                    {
                        if (_usersCached.ContainsKey(UserId))
                        {
                            return(_usersCached[UserId]);
                        }
                        else
                        {
                            UserData data = UserDataFactory.GetUserData(UserId);
                            if (data != null)
                            {
                                Habbo Generated = data.user;
                                if (Generated != null)
                                {
                                    Generated.InitInformation(data);
                                    _usersCached.TryAdd(UserId, Generated);
                                    return(Generated);
                                }
                            }
                        }
                    }
                    catch { return(null); }
                }
                return(null);
            }
            catch
            {
                return(null);
            }
        }
コード例 #5
0
        internal void method_0(UserDataFactory class12_0)
        {
            this.hashtable_0 = new Hashtable();

            DataTable dataTable_ = class12_0.GetFriends();

            if (dataTable_ != null)
            {
                foreach (DataRow dataRow in dataTable_.Rows)
                {
                    if (!this.hashtable_0.Contains((uint)dataRow["Id"]))
                    {
                        this.hashtable_0.Add((uint)dataRow["Id"], new MessengerBuddy((uint)dataRow["Id"], dataRow["username"] as string, dataRow["look"] as string, dataRow["motto"] as string, dataRow["last_online"] as string));
                    }
                }
                try
                {
                    if (this.method_25().GetHabbo().HasFuse("receive_sa"))
                    {
                        this.hashtable_0.Add(0, new MessengerBuddy(0u, "Staff Chat", this.method_25().GetHabbo().Figure, "Staff Chat Room", "0"));
                    }
                }
                catch
                {
                }
            }
        }
コード例 #6
0
        public PagedResult <IUserView> AllUsers()
        {
            PagedResult <IUserView> p = new PagedResult <IUserView>();

            p.Rows  = UserDataFactory.AllUsers();
            p.Total = p.Rows.Count;
            return(p);
        }
コード例 #7
0
        public InventoryComponent(uint userId, GameClient client, UserDataFactory userdata)
        {
            this.Session = client;
            this.UserId  = userId;

            this.Items = new List <UserItem>();

            this.Pets        = new Hashtable();
            this.Bots        = new Hashtable();
            this.hashtable_1 = new Hashtable();

            this.Discs = new Hashtable();

            this.list_1 = new List <uint>();

            foreach (DataRow row in userdata.GetItems().Rows)
            {
                string str;

                uint   id       = Convert.ToUInt32(row["Id"]);
                uint   baseItem = Convert.ToUInt32(row["base_item"]);
                int    ltdi     = Convert.ToInt32(row["ltd_id"]);
                int    ltdc     = Convert.ToInt32(row["ltd_cnt"]);
                string glddata  = (string)row["guild_data"];
                if (!DBNull.Value.Equals(row["extra_data"]))
                {
                    str = (string)row["extra_data"];
                }
                else
                {
                    str = string.Empty;
                }

                UserItem item = new UserItem(id, baseItem, str, ltdi, ltdc, glddata);

                Items.Add(item);



                if (item.GetBaseItem().InteractionType == "musicdisc")
                {
                    this.Discs.Add(item.uint_0, item);
                }
            }

            foreach (DataRow row in userdata.GetPets().Rows)
            {
                Pet pet = Essential.GetGame().GetCatalog().GetPet(row);
                this.Pets.Add(pet.PetId, pet);
            }

            foreach (DataRow row in userdata.GetBots().Rows)
            {
                UserBot bot = Essential.GetGame().GetCatalog().RetrBot(row);
                this.Bots.Add(bot.BotId, bot);
            }
        }
コード例 #8
0
ファイル: WardrobeManager.cs プロジェクト: aromaa/Skylight
        public WardrobeManager(uint id, Habbo habbo, UserDataFactory factory)
        {
            this.WardrobeItems = new Dictionary <int, WardrobeSlot>();
            this.HabboID       = id;
            this.Habbo         = habbo;

            foreach (DataRow dataRow in factory.GetWardrobe()?.Rows)
            {
                int slotId = (int)dataRow["slot_id"];
                this.WardrobeItems.Add(slotId, new WardrobeSlot(slotId, (string)dataRow["gender"], (string)dataRow["look"]));
            }
        }
コード例 #9
0
        /// <summary>
        ///     Get's Habbo By The User Id
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns>Habbo.</returns>
        /// Table: users.id
        internal static Habbo GetHabboById(uint userId)
        {
            if (userId == 0)
            {
                return(null);
            }

            GameClient clientByUserId = GetGame().GetClientManager().GetClientByUserId(userId);

            if (clientByUserId != null)
            {
                Habbo habbo = clientByUserId.GetHabbo();

                if (habbo != null && habbo.Id > 0)
                {
                    UsersCached.AddOrUpdate(userId, habbo, (key, value) => habbo);

                    return(habbo);
                }
            }
            else
            {
                if (UsersCached.ContainsKey(userId))
                {
                    return(UsersCached[userId]);
                }

                UserData userData = UserDataFactory.GetUserData((int)userId);

                if (userData == null)
                {
                    return(null);
                }

                if (UsersCached.ContainsKey(userId))
                {
                    return(UsersCached[userId]);
                }

                if (userData.User == null)
                {
                    return(null);
                }

                UsersCached.TryAdd(userId, userData.User);

                userData.User.InitInformation(userData);

                return(userData.User);
            }

            return(null);
        }
コード例 #10
0
        public BadgeManager(uint habboId, Habbo habbo, UserDataFactory userDataFactory)
        {
            this.Badges  = new Dictionary <string, Badge>(StringComparer.OrdinalIgnoreCase);
            this.HabboID = habboId;
            this.Habbo   = habbo;

            foreach (DataRow dataRow in userDataFactory.GetBadges()?.Rows)
            {
                string badgeId = (string)dataRow["badge_id"];
                this.Badges.Add(badgeId, new Badge(badgeId, (int)dataRow["badge_slot"]));
            }
        }
コード例 #11
0
        internal void method_1(UserDataFactory class12_0)
        {
            this.hashtable_1 = new Hashtable();
            DataTable dataTable_ = class12_0.DataTable_9;

            if (dataTable_ != null)
            {
                foreach (DataRow dataRow in dataTable_.Rows)
                {
                    this.hashtable_1.Add((uint)dataRow["from_id"], new MessengerRequest((uint)dataRow["Id"], this.uint_0, (uint)dataRow["from_id"], dataRow["username"] as string));
                }
            }
        }
コード例 #12
0
        public SubscriptionManager(uint uint_1, UserDataFactory class12_0)
        {
            this.uint_0       = uint_1;
            this.dictionary_0 = new Dictionary <string, Subscription>();
            DataTable dataTable_ = class12_0.DataTable_4;

            if (dataTable_ != null)
            {
                foreach (DataRow dataRow in dataTable_.Rows)
                {
                    this.dictionary_0.Add((string)dataRow["subscription_id"], new Subscription((string)dataRow["subscription_id"], (int)dataRow["timestamp_activated"], (int)dataRow["timestamp_expire"]));
                }
            }
        }
コード例 #13
0
        public BadgeComponent(uint uint_1, UserDataFactory class12_0)
        {
            this.list_0 = new List <Badge>();
            this.uint_0 = uint_1;
            DataTable dataTable_ = class12_0.DataTable_5;

            if (dataTable_ != null)
            {
                foreach (DataRow dataRow in dataTable_.Rows)
                {
                    this.list_0.Add(new Badge((string)dataRow["badge_id"], (int)dataRow["badge_slot"]));
                }
            }
        }
コード例 #14
0
        public InventoryComponent(uint userId, GameClient client, UserDataFactory userdata)
        {
            this.Session = client;



            this.UserId = userId;

            this.Items = new List <UserItem>();

            this.Pets        = new Hashtable();
            this.hashtable_1 = new Hashtable();

            this.Discs = new Hashtable();

            this.list_1 = new List <uint>();

            foreach (DataRow row in userdata.GetItems().Rows)
            {
                string str;

                uint id       = Convert.ToUInt32(row["Id"]);
                uint baseItem = Convert.ToUInt32(row["base_item"]);

                if (!DBNull.Value.Equals(row["extra_data"]))
                {
                    str = (string)row["extra_data"];
                }
                else
                {
                    str = string.Empty;
                }

                UserItem item = new UserItem(id, baseItem, str);
                Items.Add(item);

                if (item.method_1().InteractionType == "musicdisc")
                {
                    this.Discs.Add(item.uint_0, item);
                }
            }

            foreach (DataRow row in userdata.GetPets().Rows)
            {
                Pet pet = HabboIM.GetGame().GetCatalog().method_12(row);
                this.Pets.Add(pet.PetId, pet);
            }
        }
コード例 #15
0
        public static Habbo GetHabboById(int UserId)
        {
            try
            {
                var Client = Program.GameContext.PlayerController.GetClientByUserId(UserId);
                if (Client != null)
                {
                    var User = Client.GetHabbo();
                    if (User != null && User.Id > 0)
                    {
                        if (_usersCached.ContainsKey(UserId))
                        {
                            _usersCached.TryRemove(UserId, out User);
                        }

                        return(User);
                    }
                }
                else
                {
                    try
                    {
                        if (_usersCached.ContainsKey(UserId))
                        {
                            return(_usersCached[UserId]);
                        }

                        var data = UserDataFactory.GetUserData(UserId);
                        if (data != null)
                        {
                            var Generated = data.user;
                            if (Generated != null)
                            {
                                Generated.InitInformation(data);
                                _usersCached.TryAdd(UserId, Generated);
                                return(Generated);
                            }
                        }
                    }
                    catch { return(null); }
                }
                return(null);
            }
            catch
            {
                return(null);
            }
        }
コード例 #16
0
        internal void method_1(UserDataFactory class12_0)
        {
            this.hashtable_1 = new Hashtable();
            DataTable dataTable_ = class12_0.GetFriendRequests();

            if (dataTable_ != null)
            {
                foreach (DataRow dataRow in dataTable_.Rows)
                {
                    if (!this.hashtable_1.ContainsKey((uint)dataRow["from_id"]))
                    {
                        this.hashtable_1.Add((uint)dataRow["from_id"], new MessengerRequest((uint)dataRow["Id"], this.uint_0, (uint)dataRow["from_id"], dataRow["username"] as string, dataRow["gender"] as string, dataRow["look"] as string));
                    }
                }
            }
        }
コード例 #17
0
        public SubscriptionManager(uint userId, UserDataFactory userdata)
        {
            this.UserId = userId;

            this.Subscriptions = new Dictionary <string, Subscription>();

            DataTable dataTable_ = userdata.GetSubscriptions();

            if (dataTable_ != null)
            {
                foreach (DataRow dataRow in dataTable_.Rows)
                {
                    this.Subscriptions.Add((string)dataRow["subscription_id"], new Subscription((string)dataRow["subscription_id"], (int)dataRow["timestamp_activated"], (int)dataRow["timestamp_expire"]));
                }
            }
        }
コード例 #18
0
        public BadgeComponent(uint userId, UserDataFactory userdata)
        {
            this.Badges = new List <Badge>();

            this.UserId = userId;

            DataTable dataTable_ = userdata.GetBadges();

            if (dataTable_ != null)
            {
                foreach (DataRow dataRow in dataTable_.Rows)
                {
                    this.Badges.Add(new Badge((string)dataRow["badge_id"], (int)dataRow["badge_slot"]));
                }
            }
        }
コード例 #19
0
        internal static Habbo getHabboForId(uint UserId)
        {
            Habbo result;

            try
            {
                GameClient clientByUserID = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
                if (clientByUserID != null)
                {
                    Habbo habbo = clientByUserID.GetHabbo();
                    if (habbo != null && habbo.Id > 0u)
                    {
                        if (CyberEnvironment.usersCached.Contains(UserId))
                        {
                            CyberEnvironment.usersCached.Remove(UserId);
                        }
                        result = habbo;
                        return(result);
                    }
                }
                else
                {
                    if (CyberEnvironment.usersCached.Contains(UserId))
                    {
                        result = (Habbo)CyberEnvironment.usersCached[UserId];
                        return(result);
                    }
                    UserData userData = UserDataFactory.GetUserData(checked ((int)UserId));
                    Habbo    user     = userData.user;
                    if (user != null)
                    {
                        user.InitInformation(userData);
                        CyberEnvironment.usersCached.Add(UserId, user);
                        result = user;
                        return(result);
                    }
                }
                result = null;
            }
            catch
            {
                result = null;
            }
            return(result);
        }
コード例 #20
0
        public InventoryManager(GameClient session, UserDataFactory dataFactory)
        {
            this.Session = session;

            this.FloorItems           = new Dictionary <uint, InventoryItem>();
            this.WallItems            = new Dictionary <uint, InventoryItem>();
            this.Pets                 = new Dictionary <uint, Pet>();
            this.BytesWaitingToBeSend = new List <ArraySegment <byte> >();
            this.QueueBytes           = false;

            this.FloorItems.Clear();
            this.WallItems.Clear();

            DataTable inventoryItems = dataFactory.GetInventoryItems();

            if (inventoryItems != null && inventoryItems.Rows.Count > 0)
            {
                foreach (DataRow dataRow in inventoryItems.Rows)
                {
                    InventoryItem item = new InventoryItem((uint)dataRow["id"], (uint)dataRow["base_item"], (string)dataRow["extra_data"]);
                    if (item.GetItem().IsWallItem)
                    {
                        this.WallItems.Add(item.ID, item);
                    }
                    else
                    {
                        this.FloorItems.Add(item.ID, item);
                    }
                }
            }

            DataTable pets = dataFactory.GetPets();

            if (pets != null && pets.Rows.Count > 0)
            {
                foreach (DataRow dataRow in pets.Rows)
                {
                    if ((uint)dataRow["room_id"] == 0)
                    {
                        Pet pet = new Pet((uint)dataRow["id"], (uint)dataRow["user_id"], (int)dataRow["type"], (string)dataRow["name"], (string)dataRow["race"], (string)dataRow["color"], (int)dataRow["expirience"], (int)dataRow["energy"], (int)dataRow["happiness"], (int)dataRow["respect"], (double)dataRow["create_timestamp"]);
                        this.Pets.Add(pet.ID, pet);
                    }
                }
            }
        }
コード例 #21
0
        public InventoryComponent(uint uint_1, GameClient class16_1, UserDataFactory class12_0)
        {
            this.Session     = class16_1;
            this.uint_0      = uint_1;
            this.list_0      = new List <UserItem>();
            this.hashtable_0 = new Hashtable();
            this.hashtable_1 = new Hashtable();
            this.discs       = new Hashtable();
            this.list_1      = new List <uint>();
            this.list_0.Clear();
            DataTable dataTable_ = class12_0.DataTable_6;

            foreach (DataRow dataRow in dataTable_.Rows)
            {
                string str;
                uint   id       = Convert.ToUInt32(dataRow["Id"]);
                uint   baseItem = Convert.ToUInt32(dataRow["base_item"]);
                if (!DBNull.Value.Equals(dataRow["extra_data"]))
                {
                    str = (string)dataRow["extra_data"];
                }
                else
                {
                    str = string.Empty;
                }

                list_0.Add(new UserItem(id, baseItem, str));
                UserItem item = new UserItem(id, baseItem, str);

                if (item.method_1().InteractionType == "musicdisc")
                {
                    this.discs.Add(item.uint_0, item);
                }
            }

            this.hashtable_0.Clear();
            DataTable dataTable_2 = class12_0.DataTable_11;

            foreach (DataRow dataRow in dataTable_2.Rows)
            {
                Pet @class = GoldTree.GetGame().GetCatalog().method_12(dataRow);
                this.hashtable_0.Add(@class.PetId, @class);
            }
        }
コード例 #22
0
        public override void Validate(string userName, string password)
        {
            if (userName.Length <= 0 || password.Length <= 0)
            {
                // Message.CreateMessage(MessageVersion.Default, "Kein Benutzername oder Passwort angegeben");
                throw new FaultException <LoginError>(new LoginError("Kein Benutzername oder Passwort angegeben"));
            }
            IUserView user = UserDataFactory.UserByIdent(userName);

            if (user == null)
            {
                //  Message.CreateMessage(MessageVersion.Default, "Userident not found");
                throw new FaultException <LoginError>(new LoginError("Userident not found"));
            }


            if (user.UsrPassword != password)
            {
                //    Message.CreateMessage(MessageVersion.Default, "Wrong Password");
                throw new FaultException <LoginError>(new LoginError("Wrong Password"));
            }
        }
コード例 #23
0
 internal static Habbo getHabboForId(uint UserId)
 {
     try
     {
         HabboHotel.GameClients.GameClient game = GetGame().GetClientManager().GetClientByUserID(UserId);
         if (game != null)
         {
             Habbo noUser = game.GetHabbo();
             if (noUser != null && noUser.Id > 0)
             {
                 if (usersCached.ContainsKey(UserId))
                 {
                     usersCached.Remove(UserId);
                 }
                 return(noUser);
             }
         }
         else
         {
             if (usersCached.ContainsKey(UserId))
             {
                 return(usersCached[UserId]);
             }
             else
             {
                 UserData data      = UserDataFactory.GetUserData((int)UserId);
                 Habbo    Generated = data.user;
                 if (Generated != null)
                 {
                     Generated.InitInformation(data);
                     usersCached.Add(UserId, Generated);
                     return(Generated);
                 }
             }
         }
         return(null);
     }
     catch { return(null); }
 }
コード例 #24
0
ファイル: Plus.cs プロジェクト: Mereos/HabboEMU
        /// <summary>
        /// Get's Habbo By The User Id
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns>Habbo.</returns>
        /// Table: users.id
        internal static Habbo GetHabboById(uint userId)
        {
            try
            {
                var clientByUserId = GetGame().GetClientManager().GetClientByUserId(userId);
                if (clientByUserId != null)
                {
                    var habbo = clientByUserId.GetHabbo();
                    if (habbo != null && habbo.Id > 0)
                    {
                        UsersCached.AddOrUpdate(userId, habbo, (key, value) => habbo);
                        return(habbo);
                    }
                }
                else
                {
                    var userData = UserDataFactory.GetUserData((int)userId);
                    if (UsersCached.ContainsKey(userId))
                    {
                        return(UsersCached[userId]);
                    }

                    if (userData == null || userData.User == null)
                    {
                        return(null);
                    }

                    UsersCached.TryAdd(userId, userData.User);
                    userData.User.InitInformation(userData);
                    return(userData.User);
                }
            }
            catch (Exception e)
            {
                Writer.Writer.LogException("Habbo GetHabboForId: " + e);
            }
            return(null);
        }
コード例 #25
0
        public AvatarEffectsInventoryComponent(uint uint_1, GameClient class16_1, UserDataFactory class12_0)
        {
            this.Session = class16_1;
            this.list_0  = new List <AvatarEffect>();
            this.uint_0  = uint_1;
            this.int_0   = -1;
            this.list_0.Clear();
            DataTable     dataTable_    = class12_0.GetEffects();
            StringBuilder stringBuilder = new StringBuilder();

            foreach (DataRow dataRow in dataTable_.Rows)
            {
                AvatarEffect @class = new AvatarEffect((int)dataRow["effect_id"], (int)dataRow["total_duration"], Essential.StringToBoolean(dataRow["is_activated"].ToString()), (double)dataRow["activated_stamp"]);
                if (@class.Boolean_0)
                {
                    stringBuilder.Append(string.Concat(new object[]
                    {
                        "DELETE FROM user_effects WHERE user_id = '",
                        uint_1,
                        "' AND effect_id = '",
                        @class.int_0,
                        "' LIMIT 1; "
                    }));
                }
                else
                {
                    this.list_0.Add(@class);
                }
            }
            if (stringBuilder.Length > 0)
            {
                using (DatabaseClient class2 = Essential.GetDatabase().GetClient())
                {
                    class2.ExecuteQuery(stringBuilder.ToString());
                }
            }
        }
コード例 #26
0
        public SubscriptionManager(uint id, Habbo habbo, UserDataFactory factory)
        {
            this.Subscriptions = new Dictionary <string, List <Subscription> >();

            this.ID    = id;
            this.Habbo = habbo;

            foreach (DataRow dataRow in factory.GetSubscriptions()?.Rows)
            {
                string subscription = (string)dataRow["subscription_name"];

                Subscription sub = new Subscription((int)dataRow["id"], subscription, (double)dataRow["subscription_started"], (double)dataRow["subscription_expires"]);
                if (!this.Subscriptions.ContainsKey(subscription))
                {
                    this.Subscriptions.Add(subscription, new List <Subscription> {
                        sub
                    });
                }
                else
                {
                    this.Subscriptions[subscription].Add(sub);
                }
            }
        }
コード例 #27
0
        public bool TryAuthenticate(string AuthTicket)
        {
            try
            {
                UserData userData = UserDataFactory.GetUserData(AuthTicket, out byte errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect();
                    return(false);
                }

                #region Ban Checking
                //Let's have a quick search for a ban before we successfully authenticate..
                ModerationBan BanRecord = null;
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (CloudServer.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (CloudServer.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

                if (userData.user != null)
                {
                    //Now let us check for a username ban record..
                    BanRecord = null;
                    if (CloudServer.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord))
                    {
                        if (CloudServer.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }
                #endregion

                CloudServer.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                _habbo           = userData.user;
                _habbo.ssoTicket = AuthTicket;
                if (_habbo != null)
                {
                    userData.user.Init(this, userData);

                    SendMessage(new AuthenticationOKComposer());
                    SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects));
                    SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom));
                    SendMessage(new FavouritesComposer(userData.user.FavoriteRooms));
                    SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingParts));
                    SendMessage(new UserRightsComposer(_habbo));
                    SendMessage(new AvailabilityStatusComposer());
                    SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));
                    SendMessage(new BuildersClubMembershipComposer());
                    SendMessage(new CfhTopicsInitComposer(CloudServer.GetGame().GetModerationManager().UserActionPresets));
                    SendMessage(new BadgeDefinitionsComposer(CloudServer.GetGame().GetAchievementManager()._achievements));
                    SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState)));

                    if (GetHabbo().GetMessenger() != null)
                    {
                        GetHabbo().GetMessenger().OnStatusChanged(true);
                    }

                    if (!string.IsNullOrEmpty(MachineId))
                    {
                        if (_habbo.MachineId != MachineId)
                        {
                            using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1");
                                dbClient.AddParameter("MachineId", MachineId);
                                dbClient.AddParameter("id", _habbo.Id);
                                dbClient.RunQuery();
                            }
                        }

                        _habbo.MachineId = MachineId;
                    }

                    if (CloudServer.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup PermissionGroup))
                    {
                        if (!String.IsNullOrEmpty(PermissionGroup.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this);
                            }
                        }
                    }

                    if (!CloudServer.GetGame().GetCacheManager().ContainsUser(_habbo.Id))
                    {
                        CloudServer.GetGame().GetCacheManager().GenerateUser(_habbo.Id);
                    }

                    _habbo.InitProcess();

                    if (userData.user.GetPermissions().HasRight("mod_tickets"))
                    {
                        SendMessage(new ModeratorInitComposer(
                                        CloudServer.GetGame().GetModerationManager().UserMessagePresets,
                                        CloudServer.GetGame().GetModerationManager().RoomMessagePresets,
                                        CloudServer.GetGame().GetModerationManager().GetTickets));
                    }

                    if (CloudServer.GetGame().GetSettingsManager().TryGetValue("user.login.message.enabled") == "1")
                    {
                        SendMessage(new MOTDNotificationComposer(CloudServer.GetGame().GetLanguageManager().TryGetValue("user.login.message")));
                    }

                    if (ExtraSettings.WELCOME_MESSAGE_ENABLED)
                    {
                        SendMessage(new MOTDNotificationComposer(ExtraSettings.WelcomeMessage.Replace("%username%", GetHabbo().Username)));
                    }



                    if (ExtraSettings.TARGETED_OFFERS_ENABLED)
                    {
                        if (CloudServer.GetGame().GetTargetedOffersManager().TargetedOffer != null)
                        {
                            CloudServer.GetGame().GetTargetedOffersManager().Initialize(CloudServer.GetDatabaseManager().GetQueryReactor());
                            TargetedOffers TargetedOffer = CloudServer.GetGame().GetTargetedOffersManager().TargetedOffer;

                            if (TargetedOffer.Expire > CloudServer.GetIUnixTimestamp())
                            {
                                if (TargetedOffer.Limit != GetHabbo()._TargetedBuy)
                                {
                                    SendMessage(CloudServer.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize());
                                }
                            }
                            else
                            {
                                using (var dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                                    dbClient.runFastQuery("UPDATE targeted_offers SET active = 'false'");
                                using (var dbClient2 = CloudServer.GetDatabaseManager().GetQueryReactor())
                                    dbClient2.runFastQuery("UPDATE users SET targeted_buy = '0' WHERE targeted_buy > 0");
                            }
                        }
                    }

                    //SendMessage(new HCGiftsAlertComposer());



                    /*var nuxStatuss = new ServerPacket(ServerPacketHeader.NuxSuggestFreeGiftsMessageComposer);
                     * SendMessage(nuxStatuss);*/

                    CloudServer.GetGame().GetRewardManager().CheckRewards(this);
                    CloudServer.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(this);
                    CloudServer.GetGame().GetAchievementManager().TryProgressRegistrationAchievements(this);
                    CloudServer.GetGame().GetAchievementManager().TryProgressLoginAchievements(this);
                    ICollection <MessengerBuddy> Friends = new List <MessengerBuddy>();
                    foreach (MessengerBuddy Buddy in GetHabbo().GetMessenger().GetFriends().ToList())
                    {
                        if (Buddy == null)
                        {
                            continue;
                        }

                        GameClient Friend = CloudServer.GetGame().GetClientManager().GetClientByUserID(Buddy.Id);
                        if (Friend == null)
                        {
                            continue;
                        }
                        string figure = GetHabbo().Look;
                    }
                    return(true);
                }
            }
            catch (Exception e)
            {
                ExceptionLogger.LogException(e);
            }
            return(false);
        }
コード例 #28
0
        public bool TryAuthenticate(string AuthTicket)
        {
            try
            {
                UserData userData = UserDataFactory.GetUserData(AuthTicket, out byte errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect();
                    return(false);
                }

                #region Ban Checking

                //Let's have a quick search for a ban before we successfully authenticate..
                ModerationBan BanRecord;
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (NeonEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (NeonEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

                if (NeonEnvironment.GetGame().GetModerationManager().IsBanned(userData.user.Username, out BanRecord))
                {
                    if (NeonEnvironment.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username))
                    {
                        Disconnect();
                        return(false);
                    }
                }

                #endregion

                NeonEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                _habbo = userData.user;


                if (_habbo != null)
                {
                    ssoTicket = AuthTicket;
                    userData.user.Init(this, userData);


                    SendMessage(new AuthenticationOKComposer());
                    SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects));
                    SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom));
                    SendMessage(new FavouritesComposer(userData.user.FavoriteRooms));
                    SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingAllParts));
                    SendMessage(new UserRightsComposer(_habbo));
                    SendMessage(new AvailabilityStatusComposer());
                    SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));


                    //var habboClubSubscription = new ServerPacket(ServerPacketHeader.HabboClubSubscriptionComposer);
                    //habboClubSubscription.WriteString("club_habbo");
                    //habboClubSubscription.WriteInteger(0);
                    //habboClubSubscription.WriteInteger(0);
                    //habboClubSubscription.WriteInteger(0);
                    //habboClubSubscription.WriteInteger(2);
                    //habboClubSubscription.WriteBoolean(false);
                    //habboClubSubscription.WriteBoolean(false);
                    //habboClubSubscription.WriteInteger(0);
                    //habboClubSubscription.WriteInteger(0);
                    //habboClubSubscription.WriteInteger(0);
                    //SendMessage(habboClubSubscription);

                    SendMessage(new BuildersClubMembershipComposer());
                    SendMessage(new CfhTopicsInitComposer());

                    SendMessage(new BadgeDefinitionsComposer(NeonEnvironment.GetGame().GetAchievementManager()._achievements));
                    SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState)));

                    if (GetHabbo().GetMessenger() != null)
                    {
                        GetHabbo().GetMessenger().OnStatusChanged(true);
                    }

                    if (_habbo.Rank < 2 && !NeonStaticGameSettings.HotelOpenForUsers)
                    {
                        SendMessage(new SendHotelAlertLinkEventComposer("Actualmente solo el Equipo Adminsitrativo puede entrar al hotel para comprobar que todo está bien antes de que los usuarios puedan entrar. Vuelve a intentarlo en unos minutos, podrás encontrar más información en nuestro Facebook.", NeonEnvironment.GetDBConfig().DBData["facebook_url"]));
                        Thread.Sleep(10000);
                        Disconnect();
                        return(false);
                    }

                    if (!string.IsNullOrEmpty(MachineId))
                    {
                        if (_habbo.MachineId != MachineId)
                        {
                            using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1");
                                dbClient.AddParameter("MachineId", MachineId);
                                dbClient.AddParameter("id", _habbo.Id);
                                dbClient.RunQuery();
                            }
                        }

                        _habbo.MachineId = MachineId;
                    }
                    if (NeonEnvironment.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup PermissionGroup))
                    {
                        if (!string.IsNullOrEmpty(PermissionGroup.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(PermissionGroup.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(PermissionGroup.Badge, true, this);
                            }
                        }
                    }

                    if (NeonEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(_habbo.VIPRank, out SubscriptionData SubData))
                    {
                        if (!string.IsNullOrEmpty(SubData.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(SubData.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(SubData.Badge, true, this);
                            }
                        }
                    }

                    if (!NeonEnvironment.GetGame().GetCacheManager().ContainsUser(_habbo.Id))
                    {
                        NeonEnvironment.GetGame().GetCacheManager().GenerateUser(_habbo.Id);
                    }

                    _habbo.InitProcess();

                    GetHabbo()._lastitems = new Dictionary <int, CatalogItem>();
                    //ICollection<MessengerBuddy> Friends = new List<MessengerBuddy>();
                    //foreach (MessengerBuddy Buddy in this.GetHabbo().GetMessenger().GetFriends().ToList())
                    //{
                    //    if (Buddy == null)
                    //        continue;

                    //    GameClient Friend = NeonEnvironment.GetGame().GetClientManager().GetClientByUserID(Buddy.Id);
                    //    if (Friend == null)
                    //        continue;
                    //    string figure = this.GetHabbo().Look;


                    //    Friend.SendMessage(RoomNotificationComposer.SendBubble("usr/look/" + this.GetHabbo().Username + "", this.GetHabbo().Username + " se ha conectado a " + NeonEnvironment.GetDBConfig().DBData["hotel.name"] + ".", ""));

                    //}

                    if (GetHabbo()._NUX)
                    {
                        SendMessage(new MassEventComposer("habbopages/bienvenida.txt"));
                    }
                    else
                    {
                        SendMessage(new MassEventComposer("habbopages/welk.txt?249"));
                    }


                    if (NeonEnvironment.GetDBConfig().DBData["pin.system.enable"] == "0")
                    {
                        GetHabbo().StaffOk = true;
                    }

                    if (GetHabbo().StaffOk)
                    {
                        if (GetHabbo().GetPermissions().HasRight("mod_tickets"))
                        {
                            SendMessage(new ModeratorInitComposer(
                                            NeonEnvironment.GetGame().GetModerationManager().UserMessagePresets,
                                            NeonEnvironment.GetGame().GetModerationManager().RoomMessagePresets,
                                            NeonEnvironment.GetGame().GetModerationManager().GetTickets));
                        }
                    }

                    if (GetHabbo().Rank > 5 || GetHabbo()._guidelevel > 0)
                    {
                        HelperToolsManager.AddHelper(_habbo.GetClient(), false, true, true);
                        SendMessage(new HandleHelperToolComposer(true));
                    }

                    //SendMessage(new CampaignCalendarDataComposer(_habbo.calendarGift));
                    //if (int.Parse(NeonEnvironment.GetDBConfig().DBData["advent.calendar.enable"]) == 1) // Tk Custom By Whats
                    //    SendMessage(new MassEventComposer("openView/calendar"));

                    if (NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer != null)
                    {
                        NeonEnvironment.GetGame().GetTargetedOffersManager().Initialize(NeonEnvironment.GetDatabaseManager().GetQueryReactor());
                        TargetedOffers TargetedOffer = NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer;

                        if (TargetedOffer.Expire > NeonEnvironment.GetIUnixTimestamp())
                        {
                            if (TargetedOffer.Limit != GetHabbo()._TargetedBuy)
                            {
                                SendMessage(NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize());
                            }
                        }
                        else if (TargetedOffer.Expire == -1)
                        {
                            if (TargetedOffer.Limit != GetHabbo()._TargetedBuy)
                            {
                                SendMessage(NeonEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize());
                            }
                        }
                        else
                        {
                            using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.runFastQuery("UPDATE targeted_offers SET active = 'false'");
                            }

                            using (IQueryAdapter dbClient2 = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient2.runFastQuery("UPDATE users SET targeted_buy = '0' WHERE targeted_buy > 0");
                            }
                        }
                    }

                    if (_habbo.MysticBoxes.Count == 0 && _habbo.MysticKeys.Count == 0)
                    {
                        int    box      = RandomNumber.GenerateRandom(1, 8);
                        string boxcolor = "";
                        switch (box)
                        {
                        case 1:
                            boxcolor = "purple";
                            break;

                        case 2:
                            boxcolor = "blue";
                            break;

                        case 3:
                            boxcolor = "green";
                            break;

                        case 4:
                            boxcolor = "yellow";
                            break;

                        case 5:
                            boxcolor = "lilac";
                            break;

                        case 6:
                            boxcolor = "orange";
                            break;

                        case 7:
                            boxcolor = "turquoise";
                            break;

                        case 8:
                            boxcolor = "red";
                            break;
                        }

                        int    key      = RandomNumber.GenerateRandom(1, 8);
                        string keycolor = "";
                        switch (key)
                        {
                        case 1:
                            keycolor = "purple";
                            break;

                        case 2:
                            keycolor = "blue";
                            break;

                        case 3:
                            keycolor = "green";
                            break;

                        case 4:
                            keycolor = "yellow";
                            break;

                        case 5:
                            keycolor = "lilac";
                            break;

                        case 6:
                            keycolor = "orange";
                            break;

                        case 7:
                            keycolor = "turquoise";
                            break;

                        case 8:
                            keycolor = "red";
                            break;
                        }

                        _habbo.MysticKeys.Add(keycolor);
                        _habbo.MysticBoxes.Add(boxcolor);

                        using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.runFastQuery("INSERT INTO user_mystic_data(user_id, mystic_keys, mystic_boxes) VALUES(" + GetHabbo().Id + ", '" + keycolor + "', '" + boxcolor + "');");
                        }
                    }

                    SendMessage(new MysteryBoxDataComposer(_habbo.GetClient()));

                    SendMessage(new HCGiftsAlertComposer());

                    //if(!GetHabbo()._NUX)
                    //{
                    //    DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                    //    dtDateTime = dtDateTime.AddSeconds(GetHabbo().LastOnline);

                    //    if ((DateTime.Now - dtDateTime).TotalDays > 2)
                    //    {
                    //        //NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_Login", 1, true);
                    //        NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_RegistrationDuration", 1);
                    //    }

                    //    else if ((DateTime.Now - dtDateTime).TotalDays > 1 && (DateTime.Now - dtDateTime).TotalDays < 2)
                    //    {
                    //        NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_Login", 1);
                    //        NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_RegistrationDuration", 1);

                    //        if(GetHabbo().Rank > 2 || GetHabbo()._guidelevel > 0)
                    //        {
                    //            NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(_habbo.GetClient(), "ACH_GuideEnrollmentLifetime", 1);
                    //        }
                    //    }
                    //}


                    NeonEnvironment.GetGame().GetRewardManager().CheckRewards(this);

                    if (GetHabbo()._NUX)
                    {
                        NeonEnvironment.GetGame().GetClientManager().StaffAlert(new RoomInviteComposer(int.MinValue, GetHabbo().Username + " acaba de registrarse en Keko."));

                        GetHabbo()._NUX = false;
                        using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.runFastQuery("UPDATE users SET nux_user = '******' WHERE id = " + GetHabbo().Id + ";");
                        }
                    }

                    return(true);
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Bug during user login: " + e);
            }
            return(false);
        }
コード例 #29
0
        public bool TryAuthenticate(string authTicket)
        {
            try
            {
                UserData userData = UserDataFactory.GetUserData(authTicket, out byte errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect();
                    return(false);
                }

                #region Ban Checking
                //Let's have a quick search for a ban before we successfully authenticate..
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (PlusEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out _))
                    {
                        if (PlusEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

                if (userData.user != null)
                {
                    if (PlusEnvironment.GetGame().GetModerationManager().IsBanned(userData.user.Username, out _))
                    {
                        if (PlusEnvironment.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }
                #endregion

                if (userData.user == null) //Possible NPE
                {
                    return(false);
                }

                PlusEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.UserId, userData.user.Username);
                _habbo = userData.user;
                if (_habbo != null)
                {
                    userData.user.Init(this, userData);

                    SendPacket(new AuthenticationOKComposer());
                    SendPacket(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects));
                    SendPacket(new NavigatorSettingsComposer(_habbo.HomeRoom));
                    SendPacket(new FavouritesComposer(userData.user.FavoriteRooms));
                    SendPacket(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingParts));
                    SendPacket(new UserRightsComposer(_habbo.Rank));
                    SendPacket(new AvailabilityStatusComposer());
                    SendPacket(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));
                    SendPacket(new BuildersClubMembershipComposer());
                    SendPacket(new CfhTopicsInitComposer(PlusEnvironment.GetGame().GetModerationManager().UserActionPresets));

                    SendPacket(new BadgeDefinitionsComposer(PlusEnvironment.GetGame().GetAchievementManager().Achievements));
                    SendPacket(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState)));
                    //SendMessage(new TalentTrackLevelComposer());

                    if (GetHabbo().GetMessenger() != null)
                    {
                        GetHabbo().GetMessenger().OnStatusChanged(true);
                    }

                    if (!string.IsNullOrEmpty(MachineId))
                    {
                        if (_habbo.MachineId != MachineId)
                        {
                            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1");
                                dbClient.AddParameter("MachineId", MachineId);
                                dbClient.AddParameter("id", _habbo.Id);
                                dbClient.RunQuery();
                            }
                        }

                        _habbo.MachineId = MachineId;
                    }

                    if (PlusEnvironment.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup group))
                    {
                        if (!String.IsNullOrEmpty(group.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(group.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(group.Badge, true, this);
                            }
                        }
                    }

                    if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(_habbo.VIPRank, out SubscriptionData subData))
                    {
                        if (!String.IsNullOrEmpty(subData.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(subData.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(subData.Badge, true, this);
                            }
                        }
                    }

                    if (!PlusEnvironment.GetGame().GetCacheManager().ContainsUser(_habbo.Id))
                    {
                        PlusEnvironment.GetGame().GetCacheManager().GenerateUser(_habbo.Id);
                    }

                    _habbo.Look = PlusEnvironment.GetFigureManager().ProcessFigure(_habbo.Look, _habbo.Gender, _habbo.GetClothing().GetClothingParts, true);
                    _habbo.InitProcess();

                    if (userData.user.GetPermissions().HasRight("mod_tickets"))
                    {
                        SendPacket(new ModeratorInitComposer(
                                       PlusEnvironment.GetGame().GetModerationManager().UserMessagePresets,
                                       PlusEnvironment.GetGame().GetModerationManager().RoomMessagePresets,
                                       PlusEnvironment.GetGame().GetModerationManager().GetTickets));
                    }

                    if (PlusEnvironment.GetSettingsManager().TryGetValue("user.login.message.enabled") == "1")
                    {
                        SendPacket(new MotdNotificationComposer(PlusEnvironment.GetLanguageManager().TryGetValue("user.login.message")));
                    }

                    PlusEnvironment.GetGame().GetRewardManager().CheckRewards(this);
                    return(true);
                }
            }
            catch (Exception e)
            {
                ExceptionLogger.LogException(e);
            }
            return(false);
        }
コード例 #30
0
ファイル: GameClient.cs プロジェクト: RootkitR/Essential-5.1
        internal void tryLogin(string AuthTicket)
        {
            try
            {
                UserDataFactory @class = new UserDataFactory(AuthTicket, this.GetConnection().String_0, true);
                if ([email protected])
                {
                    @class = new UserDataFactory(AuthTicket, this.GetConnection().String_0, true);
                }
                if ([email protected])
                {
                    string str = "";
                    if (ServerConfiguration.EnableSSO)
                    {
                        str = EssentialEnvironment.GetExternalText("emu_sso_wrong_secure") + "(" + this.GetConnection().String_0 + ")";
                    }
                    SendNotifWithScroll(EssentialEnvironment.GetExternalText("emu_sso_wrong") + str);
                    return;
                }
                Habbo class2 = Authenticator.CreateHabbo(AuthTicket, this, @class, @class);
                Essential.GetGame().GetClientManager().Disconnect(class2.Id, "New Session");
                this.Habbo = class2;
                this.Habbo.method_2(@class);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Logging login error because you are on alpha test!");
                Logging.LogException(ex.ToString());
                if (this != null)
                {
                    this.SendNotification(ex.ToString());
                    this.Disconnect("Login Error");
                }
                return;
            }

            try
            {
                Essential.GetGame().GetBanManager().method_1(this);
            }
            catch (ModerationBanException gException)
            {
                this.NotifyBan(gException.Message);
                this.Disconnect("Banned!");
                return;
            }
            #region "AKS"
            if (this.MachineId != "" && !Essential.StringToBoolean(this.GetHabbo().GetUserDataFactory().GetUserData()["staff_inacc"].ToString()))
            {
                using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                {
                    string oldMachineId = dbClient.SpecialString("SELECT machineId FROM user_machineids WHERE userid=" + this.GetHabbo().Id);

                    dbClient.AddParamWithValue("machineid", this.MachineId);
                    if ((oldMachineId == "" || oldMachineId != this.MachineId))
                    {
                        dbClient.AddParamWithValue("username", this.GetHabbo().Username);
                        dbClient.ExecuteQuery("INSERT INTO user_machineids (username,userid,timestamp,machineId) VALUES (@username," + this.GetHabbo().Id + ",'" + Convert.ToInt32(Essential.GetUnixTimestamp()) + "',@machineid)");
                    }
                }
            }
            #endregion
            ServerMessage Message2 = new ServerMessage(Outgoing.Fuserights);
            if (this == null || this.GetHabbo() == null)
            {
                return;
            }
            if (this.GetHabbo().IsVIP || ServerConfiguration.HabboClubForClothes)
            {
                Message2.AppendInt32(2);
            }
            else
            {
                if (this.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club"))
                {
                    Message2.AppendInt32(1);
                }
                else
                {
                    Message2.AppendInt32(0);
                }
            }
            if (this.GetHabbo().HasFuse("acc_anyroomowner"))
            {
                Message2.AppendInt32(7);
            }
            else
            {
                if (this.GetHabbo().HasFuse("acc_anyroomrights"))
                {
                    Message2.AppendInt32(5);
                }
                else
                {
                    if (this.GetHabbo().HasFuse("acc_supporttool"))
                    {
                        Message2.AppendInt32(4);
                    }
                    else
                    {
                        if (this.GetHabbo().IsVIP || ServerConfiguration.HabboClubForClothes || this.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club"))
                        {
                            Message2.AppendInt32(2);
                        }
                        else
                        {
                            Message2.AppendInt32(0);
                        }
                    }
                }
            }

            this.SendMessage(Message2);

            this.SendMessage(this.GetHabbo().GetEffectsInventoryComponent().method_6());

            ServerMessage Message3 = new ServerMessage(Outgoing.AvailabilityStatus);
            Message3.AppendBoolean(true);
            Message3.AppendBoolean(false);
            this.SendMessage(Message3);
            ServerMessage message = new ServerMessage(Outgoing.UniqueID);
            message.AppendString(this.MachineId);
            this.SendMessage(message);
            ServerMessage Message5_ = new ServerMessage(Outgoing.AuthenticationOK);
            this.SendMessage(Message5_);

            if (GetHabbo().HomeRoomId <= 0)
            {
                GetHabbo().HomeRoomId = 64259;
            }
            ServerMessage Message5 = new ServerMessage(Outgoing.HomeRoom);
            Message5.AppendUInt(this.GetHabbo().HomeRoomId);
            Message5.AppendUInt(this.GetHabbo().HomeRoomId);
            this.SendMessage(Message5);
            Console.WriteLine("[" + this.GetConnection().UInt32_0 + "] [" + this.GetHabbo().Username + "] [" + this.GetHabbo().Id + "] [" + this.GetConnection().String_0 + "] [" + DateTime.Now.Hour + ":" + DateTime.Now.Minute + "]");
            GetHabbo().UpdateCredits(false);
            GetHabbo().UpdateActivityPoints(false);
            if (this.GetHabbo().HasFuse("acc_supporttool"))
            {
                this.SendMessage(Essential.GetGame().GetModerationTool().SerializeTool());
                Essential.GetGame().GetModerationTool().method_4(this);
            }
            if (Essential.GetGame().GetPixelManager().CanHaveReward(this))
            {
                Essential.GetGame().GetPixelManager().UpdateNeeded(this);
            }

            ServerMessage Message6 = new ServerMessage(Outgoing.FavouriteRooms);
            Message6.AppendInt32(30);
            Message6.AppendInt32(this.GetHabbo().list_1.Count);
            foreach (uint current in this.GetHabbo().list_1)
            {
                Message6.AppendUInt(current);
            }
            this.SendMessage(Message6);
            try
            {
                this.GetHabbo().CheckTotalTimeOnlineAchievements();
                this.GetHabbo().CheckHappyHourAchievements();
                this.GetHabbo().CheckTrueHabboAchievements();
                this.GetHabbo().CheckRegularVisitorAchievements();
                this.GetHabbo().CheckFootballGoalHostScoreAchievements();
                this.GetHabbo().CheckStaffPicksAchievement();
            }
            catch { }
            if (ServerConfiguration.MOTD != "")
            {
                this.SendNotification(ServerConfiguration.MOTD, 2);
            }
            for (uint num = (uint)Essential.GetGame().GetRoleManager().GetRankCount(); num > 1u; num -= 1u)
            {
                if (Essential.GetGame().GetRoleManager().GetBadgeByRank(num).Length > 0)
                {
                    if (!this.GetHabbo().GetBadgeComponent().HasBadge(Essential.GetGame().GetRoleManager().GetBadgeByRank(num)) && this.GetHabbo().Rank == num)
                    {
                        this.GetHabbo().GetBadgeComponent().SendBadge(this, Essential.GetGame().GetRoleManager().GetBadgeByRank(num), true);
                    }
                    else
                    {
                        if (this.GetHabbo().GetBadgeComponent().HasBadge(Essential.GetGame().GetRoleManager().GetBadgeByRank(num)) && this.GetHabbo().Rank < num)
                        {
                            this.GetHabbo().GetBadgeComponent().RemoveBadge(Essential.GetGame().GetRoleManager().GetBadgeByRank(num));
                        }
                    }
                }
            }
            if (this.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club"))
            {
                this.GetHabbo().CheckHCAchievements();
            }
            if (this.GetHabbo().IsVIP&& !this.GetHabbo().GetBadgeComponent().HasBadge("VIP"))
            {
                this.GetHabbo().GetBadgeComponent().SendBadge(this, "VIP", true);
            }
            else
            {
                if (!this.GetHabbo().IsVIP&& this.GetHabbo().GetBadgeComponent().HasBadge("VIP"))
                {
                    this.GetHabbo().GetBadgeComponent().RemoveBadge("VIP");
                }
            }
            if (this.GetHabbo().CurrentQuestId > 0u)
            {
                Essential.GetGame().GetQuestManager().ActivateQuest(this.GetHabbo().CurrentQuestId, this);
            }
            if (!Regex.IsMatch(this.GetHabbo().Username, "^[-a-zA-Z0-9._:,]+$"))
            {
                ServerMessage Message5_2 = new ServerMessage(Outgoing.Disconnect);
                this.SendMessage(Message5_2);
            }
            this.GetHabbo().Motto = Essential.FilterString(this.GetHabbo().Motto);
            DataTable dataTable = null;
            using (DatabaseClient class3 = Essential.GetDatabase().GetClient())
            {
                dataTable = class3.ReadDataTable("SELECT achievement,achlevel FROM achievements_owed WHERE user = '******'");
            }
            if (dataTable != null)
            {
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    Essential.GetGame().GetAchievementManager().addAchievement(this, (uint)dataRow["achievement"], (int)dataRow["achlevel"]);
                    using (DatabaseClient class3 = Essential.GetDatabase().GetClient())
                    {
                        class3.ExecuteQuery(string.Concat(new object[]
                        {
                            "DELETE FROM achievements_owed WHERE achievement = '",
                            (uint)dataRow["achievement"],
                            "' AND user = '******' LIMIT 1"
                        }));
                    }
                }
            }
            if (this.GetHabbo().list_2 != null && this.GetHabbo().list_2.Count > 0)
            {
                ServerMessage IgnoringList = new ServerMessage(Outgoing.IgnoringList);
                IgnoringList.AppendInt32(this.GetHabbo().list_2.Count);
                foreach (uint userId in this.GetHabbo().list_2)
                {
                    IgnoringList.AppendString(Essential.GetGame().GetClientManager().GetNameById(userId));
                }
                this.SendMessage(IgnoringList);
            }
            //this.GetClientMessageHandler().method_5(this.GetHabbo().HomeRoomId, "");
        }