예제 #1
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            Session.GetHabbo().FriendbarState = FriendBarStateUtility.GetEnum(Packet.PopInt());
            Session.SendMessage(new SoundSettingsComposer(Session.GetHabbo().ClientVolume, Session.GetHabbo().ChatPreference, Session.GetHabbo().AllowMessengerInvites, Session.GetHabbo().FocusPreference, FriendBarStateUtility.GetInt(Session.GetHabbo().FriendbarState)));
        }
예제 #2
0
        public void Parse(Player session, ClientPacket packet)
        {
            if (session == null || session.GetHabbo() == null)
            {
                return;
            }

            session.GetHabbo().FriendbarState = FriendBarStateUtility.GetEnum(packet.PopInt());
            session.SendPacket(new SoundSettingsComposer(session.GetHabbo().ClientVolume, session.GetHabbo().ChatPreference, session.GetHabbo().AllowMessengerInvites, session.GetHabbo().FocusPreference, FriendBarStateUtility.GetInt(session.GetHabbo().FriendbarState)));
        }
예제 #3
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);
        }
예제 #4
0
        public void OnDisconnect()
        {
            if (_disconnected)
            {
                return;
            }

            try
            {
                if (_process != null)
                {
                    _process.Dispose();
                }
            }
            catch { }

            _disconnected = true;

            PlusEnvironment.GetGame().GetClientManager().UnregisterClient(Id, Username);

            if (!_habboSaved)
            {
                _habboSaved = true;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `users` SET `online` = '0', `last_online` = '" + PlusEnvironment.GetUnixTimestamp() + "', `activity_points` = '" + Duckets + "', `credits` = '" + Credits + "', `vip_points` = '" + Diamonds + "', `home_room` = '" + HomeRoom + "', `gotw_points` = '" + GOTWPoints + "', `time_muted` = '" + TimeMuted + "',`friend_bar_state` = '" + FriendBarStateUtility.GetInt(_friendbarState) + "' WHERE id = '" + Id + "' LIMIT 1;UPDATE `user_stats` SET `roomvisits` = '" + _habboStats.RoomVisits + "', `onlineTime` = '" + (PlusEnvironment.GetUnixTimestamp() - SessionStart + _habboStats.OnlineTime) + "', `respect` = '" + _habboStats.Respect + "', `respectGiven` = '" + _habboStats.RespectGiven + "', `giftsGiven` = '" + _habboStats.GiftsGiven + "', `giftsReceived` = '" + _habboStats.GiftsReceived + "', `dailyRespectPoints` = '" + _habboStats.DailyRespectPoints + "', `dailyPetRespectPoints` = '" + _habboStats.DailyPetRespectPoints + "', `AchievementScore` = '" + _habboStats.AchievementPoints + "', `quest_id` = '" + _habboStats.QuestId + "', `quest_progress` = '" + _habboStats.QuestProgress + "', `groupid` = '" + _habboStats.FavouriteGroupId + "',`forum_posts` = '" + _habboStats.ForumPosts + "' WHERE `id` = '" + Id + "' LIMIT 1;");

                    if (GetPermissions().HasRight("mod_tickets"))
                    {
                        dbClient.RunQuery("UPDATE `moderation_tickets` SET `status` = 'open', `moderator_id` = '0' WHERE `status` ='picked' AND `moderator_id` = '" + Id + "'");
                    }
                }
            }

            Dispose();

            _client = null;
        }
예제 #5
0
        public Habbo(int Id, string Username, int Rank, string Motto, string Look, string Gender, int Credits, int ActivityPoints, int HomeRoom,
                     bool HasFriendRequestsDisabled, int LastOnline, bool AppearOffline, bool HideInRoom, double CreateDate, int Diamonds,
                     string machineID, string clientVolume, bool ChatPreference, bool FocusPreference, bool PetsMuted, bool BotsMuted, bool AdvertisingReportBlocked, double LastNameChange,
                     int GOTWPoints, bool IgnoreInvites, double TimeMuted, double TradingLock, bool AllowGifts, int FriendBarState, bool DisableForcedEffects, bool AllowMimic, int VIPRank)
        {
            _id             = Id;
            _username       = Username;
            _rank           = Rank;
            _motto          = Motto;
            _look           = Look;
            _gender         = Gender.ToLower();
            _footballLook   = PlusEnvironment.FilterFigure(Look.ToLower());
            _footballGender = Gender.ToLower();
            _credits        = Credits;
            _duckets        = ActivityPoints;
            _diamonds       = Diamonds;
            _gotwPoints     = GOTWPoints;
            _homeRoom       = HomeRoom;
            _lastOnline     = LastOnline;
            _accountCreated = CreateDate;
            _clientVolume   = new List <int>();
            foreach (string Str in clientVolume.Split(','))
            {
                int Val = 0;
                if (int.TryParse(Str, out Val))
                {
                    _clientVolume.Add(int.Parse(Str));
                }
                else
                {
                    _clientVolume.Add(100);
                }
            }

            _lastNameChange  = LastNameChange;
            _machineId       = machineID;
            _chatPreference  = ChatPreference;
            _focusPreference = FocusPreference;
            _isExpert        = IsExpert == true;

            _appearOffline         = AppearOffline;
            _allowTradingRequests  = true;                      //TODO
            _allowUserFollowing    = true;                      //TODO
            _allowFriendRequests   = HasFriendRequestsDisabled; //TODO
            _allowMessengerInvites = IgnoreInvites;
            _allowPetSpeech        = PetsMuted;
            _allowBotSpeech        = BotsMuted;
            _allowPublicRoomStatus = HideInRoom;
            _allowConsoleMessages  = true;
            _allowGifts            = AllowGifts;
            _allowMimic            = AllowMimic;
            _receiveWhispers       = true;
            _ignorePublicWhispers  = false;
            _playingFastFood       = false;
            _friendbarState        = FriendBarStateUtility.GetEnum(FriendBarState);
            _christmasDay          = ChristmasDay;
            _wantsToRideHorse      = 0;
            _timeAFK = 0;
            _disableForcedEffects = DisableForcedEffects;
            _vipRank = VIPRank;

            _disconnected = false;
            _habboSaved   = false;
            _changingName = false;

            _floodTime   = 0;
            _friendCount = 0;
            _timeMuted   = TimeMuted;
            _timeCached  = DateTime.Now;

            _tradingLockExpiry = TradingLock;
            if (_tradingLockExpiry > 0 && PlusEnvironment.GetUnixTimestamp() > TradingLockExpiry)
            {
                _tradingLockExpiry = 0;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `user_info` SET `trading_locked` = '0' WHERE `user_id` = '" + Id + "' LIMIT 1");
                }
            }

            _bannedPhraseCount  = 0;
            _sessionStart       = PlusEnvironment.GetUnixTimestamp();
            _messengerSpamCount = 0;
            _messengerSpamTime  = 0;
            _creditsTickUpdate  = Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("user.currency_scheduler.tick"));

            _tentId            = 0;
            _hopperId          = 0;
            _isHopping         = false;
            _teleportId        = 0;
            _isTeleporting     = false;
            _teleportingRoomId = 0;
            _roomAuthOk        = false;
            _currentRoomId     = 0;

            _hasSpoken                = false;
            _lastAdvertiseReport      = 0;
            _advertisingReported      = false;
            _advertisingReportBlocked = AdvertisingReportBlocked;

            _wiredInteraction   = false;
            _questLastCompleted = 0;
            _inventoryAlert     = false;
            _ignoreBobbaFilter  = false;
            _wiredTeleporting   = false;
            _customBubbleId     = 0;
            _onHelperDuty       = false;
            _fastfoodScore      = 0;
            _petId   = 0;
            _tempInt = 0;

            _lastGiftPurchaseTime       = DateTime.Now;
            _lastMottoUpdateTime        = DateTime.Now;
            _lastClothingUpdateTime     = DateTime.Now;
            _lastForumMessageUpdateTime = DateTime.Now;

            _giftPurchasingWarnings = 0;
            _mottoUpdateWarnings    = 0;
            _clothingUpdateWarnings = 0;

            _sessionGiftBlocked     = false;
            _sessionMottoBlocked    = false;
            _sessionClothingBlocked = false;

            FavoriteRooms = new ArrayList();
            Achievements  = new ConcurrentDictionary <string, UserAchievement>();
            Relationships = new Dictionary <int, Relationship>();
            RatedRooms    = new List <int>();

            //TODO: Nope.
            InitPermissions();

            #region Stats
            DataRow StatRow = null;
            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `id`,`roomvisits`,`onlinetime`,`respect`,`respectgiven`,`giftsgiven`,`giftsreceived`,`dailyrespectpoints`,`dailypetrespectpoints`,`achievementscore`,`quest_id`,`quest_progress`,`groupid`,`tickets_answered`,`respectstimestamp`,`forum_posts` FROM `user_stats` WHERE `id` = @user_id LIMIT 1");
                dbClient.AddParameter("user_id", Id);
                StatRow = dbClient.GetRow();

                if (StatRow == null)//No row, add it yo
                {
                    dbClient.RunQuery("INSERT INTO `user_stats` (`id`) VALUES ('" + Id + "')");
                    dbClient.SetQuery("SELECT `id`,`roomvisits`,`onlinetime`,`respect`,`respectgiven`,`giftsgiven`,`giftsreceived`,`dailyrespectpoints`,`dailypetrespectpoints`,`achievementscore`,`quest_id`,`quest_progress`,`groupid`,`tickets_answered`,`respectstimestamp`,`forum_posts` FROM `user_stats` WHERE `id` = @user_id LIMIT 1");
                    dbClient.AddParameter("user_id", Id);
                    StatRow = dbClient.GetRow();
                }

                try
                {
                    _habboStats = new HabboStats(Convert.ToInt32(StatRow["roomvisits"]), Convert.ToDouble(StatRow["onlineTime"]), Convert.ToInt32(StatRow["respect"]), Convert.ToInt32(StatRow["respectGiven"]), Convert.ToInt32(StatRow["giftsGiven"]),
                                                 Convert.ToInt32(StatRow["giftsReceived"]), Convert.ToInt32(StatRow["dailyRespectPoints"]), Convert.ToInt32(StatRow["dailyPetRespectPoints"]), Convert.ToInt32(StatRow["AchievementScore"]),
                                                 Convert.ToInt32(StatRow["quest_id"]), Convert.ToInt32(StatRow["quest_progress"]), Convert.ToInt32(StatRow["groupid"]), Convert.ToString(StatRow["respectsTimestamp"]), Convert.ToInt32(StatRow["forum_posts"]));

                    if (Convert.ToString(StatRow["respectsTimestamp"]) != DateTime.Today.ToString("MM/dd"))
                    {
                        _habboStats.RespectsTimestamp = DateTime.Today.ToString("MM/dd");
                        SubscriptionData SubData = null;

                        int DailyRespects = 10;

                        if (_permissions.HasRight("mod_tool"))
                        {
                            DailyRespects = 20;
                        }
                        else if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(VIPRank, out SubData))
                        {
                            DailyRespects = SubData.Respects;
                        }

                        _habboStats.DailyRespectPoints    = DailyRespects;
                        _habboStats.DailyPetRespectPoints = DailyRespects;

                        dbClient.RunQuery("UPDATE `user_stats` SET `dailyRespectPoints` = '" + DailyRespects + "', `dailyPetRespectPoints` = '" + DailyRespects + "', `respectsTimestamp` = '" + DateTime.Today.ToString("MM/dd") + "' WHERE `id` = '" + Id + "' LIMIT 1");
                    }
                }
                catch (Exception e)
                {
                    ExceptionLogger.LogException(e);
                }
            }

            Group G = null;
            if (!PlusEnvironment.GetGame().GetGroupManager().TryGetGroup(_habboStats.FavouriteGroupId, out G))
            {
                _habboStats.FavouriteGroupId = 0;
            }
            #endregion
        }
예제 #6
0
        public Habbo(int Id, string Username, int Rank, string Motto, string Look, string Gender, int Credits, int ActivityPoints, int HomeRoom,
                     bool HasFriendRequestsDisabled, int LastOnline, bool AppearOffline, bool HideInRoom, double CreateDate, int Diamonds,
                     string machineID, string clientVolume, bool ChatPreference, bool FocusPreference, bool PetsMuted, bool BotsMuted, bool AdvertisingReportBlocked, double LastNameChange,
                     int GOTWPoints, int UserPoints, bool IgnoreInvites, double TimeMuted, double TradingLock, bool AllowGifts, int FriendBarState, bool DisableForcedEffects, bool AllowMimic, int VIPRank,
                     byte guidelevel, byte publicistalevel, byte builder, byte croupier, bool Nux, byte TargetedBuy, string NameColor, string Tag, string TagColor, byte NameChange, string PinClient, int CatRank)
        {
            this.Id          = Id;
            this.Username    = Username;
            this.Rank        = Rank;
            this.CatRank     = CatRank;
            this.Motto       = Motto;
            this.Look        = NeonEnvironment.GetGame().GetAntiMutant().RunLook(Look);
            this.Gender      = Gender.ToLower();
            FootballLook     = NeonEnvironment.FilterFigure(Look.ToLower());
            FootballGender   = Gender.ToLower();
            this.Credits     = Credits;
            Duckets          = ActivityPoints;
            this.Diamonds    = Diamonds;
            this.GOTWPoints  = GOTWPoints;
            this.PinClient   = PinClient;
            _NUX             = Nux;
            this.UserPoints  = UserPoints;
            this.HomeRoom    = HomeRoom;
            this.LastOnline  = LastOnline;
            _guidelevel      = guidelevel;
            _publicistalevel = publicistalevel;
            _builder         = builder;
            _croupier        = croupier;
            _TargetedBuy     = TargetedBuy;
            AccountCreated   = CreateDate;
            ClientVolume     = new List <int>();
            _nameColor       = NameColor;
            _tag             = Tag;
            _tagcolor        = TagColor;
            _changename      = NameChange;
            foreach (string Str in clientVolume.Split(','))
            {
                if (int.TryParse(Str, out _))
                {
                    ClientVolume.Add(int.Parse(Str));
                }
                else
                {
                    ClientVolume.Add(100);
                }
            }

            this.LastNameChange  = LastNameChange;
            MachineId            = machineID;
            this.ChatPreference  = ChatPreference;
            this.FocusPreference = FocusPreference;
            IsExpert             = IsExpert == true;

            this.AppearOffline    = AppearOffline;
            AllowTradingRequests  = true;                      //TODO
            AllowUserFollowing    = true;                      //TODO
            AllowFriendRequests   = HasFriendRequestsDisabled; //TODO
            AllowMessengerInvites = IgnoreInvites;
            AllowPetSpeech        = PetsMuted;
            AllowBotSpeech        = BotsMuted;
            AllowPublicRoomStatus = HideInRoom;
            AllowConsoleMessages  = true;
            this.AllowGifts       = AllowGifts;
            this.AllowMimic       = AllowMimic;
            _lastPhotoPreview     = lastPhotoPreview;
            ReceiveWhispers       = true;
            IgnorePublicWhispers  = false;
            PlayingFastFood       = false;
            FriendbarState        = FriendBarStateUtility.GetEnum(FriendBarState);
            ChristmasDay          = ChristmasDay;
            WantsToRideHorse      = 0;
            TimeAFK = 0;
            this.DisableForcedEffects = DisableForcedEffects;
            this.VIPRank = VIPRank;
            _bet         = 0;

            onDuty              = false;
            requestHelp         = false;
            requestTour         = false;
            userHelping         = 0;
            reportsOfHarassment = false;
            onService           = false;

            _disconnected = false;
            _habboSaved   = false;
            ChangingName  = false;

            FloodTime      = 0;
            FriendCount    = 0;
            this.TimeMuted = TimeMuted;
            _timeCached    = DateTime.Now;

            _sellingroom = false;

            //this._CurrentTalentLevel = GetCurrentTalentLevel();

            TradingLockExpiry = TradingLock;
            if (TradingLockExpiry > 0 && NeonEnvironment.GetUnixTimestamp() > TradingLockExpiry)
            {
                TradingLockExpiry = 0;
                using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `user_info` SET `trading_locked` = '0' WHERE `user_id` = '" + Id + "' LIMIT 1");
                }
            }

            BannedPhraseCount  = 0;
            SessionStart       = NeonEnvironment.GetUnixTimestamp();
            MessengerSpamCount = 0;
            MessengerSpamTime  = 0;
            CreditsUpdateTick  = NeonStaticGameSettings.UserCreditsUpdateTimer;

            TentId            = 0;
            HopperId          = 0;
            IsHopping         = false;
            TeleporterId      = 0;
            IsTeleporting     = false;
            TeleportingRoomID = 0;
            RoomAuthOk        = false;
            CurrentRoomId     = 0;

            HasSpoken                  = false;
            LastAdvertiseReport        = 0;
            AdvertisingReported        = false;
            AdvertisingReportedBlocked = AdvertisingReportBlocked;

            _multiWhisper          = false;
            WiredInteraction       = false;
            QuestLastCompleted     = 0;
            InventoryAlert         = false;
            IgnoreBobbaFilter      = false;
            WiredTeleporting       = false;
            LastClothingUpdateTime = DateTime.Now;
            CustomBubbleId         = 0;
            OnHelperDuty           = false;
            FastfoodScore          = 0;
            PetId   = 0;
            TempInt = 0;

            LastGiftPurchaseTime       = DateTime.Now;
            LastMottoUpdateTime        = DateTime.Now;
            LastForumMessageUpdateTime = DateTime.Now;
            ClothingUpdateWarnings     = 0;

            GiftPurchasingWarnings = 0;
            MottoUpdateWarnings    = 0;

            SessionGiftBlocked     = false;
            SessionMottoBlocked    = false;
            _isFirstThrow          = true;
            SessionClothingBlocked = false;

            FavoriteRooms = new ArrayList();
            MutedUsers    = new List <int>();
            MultiWhispers = new List <RoomUser>();
            Achievements  = new ConcurrentDictionary <string, UserAchievement>();
            Relationships = new Dictionary <int, Relationship>();
            RatedRooms    = new List <int>();
            UsersRooms    = new List <RoomData>();
            TradeItems    = new List <Item>();

            //TODO: Nope.
            InitPermissions();

            #region Stats
            using (IQueryAdapter dbClient = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `id`,`roomvisits`,`onlinetime`,`respect`,`respectgiven`,`giftsgiven`,`giftsreceived`,`dailyrespectpoints`,`dailypetrespectpoints`,`achievementscore`,`quest_id`,`quest_progress`,`groupid`,`tickets_answered`,`respectstimestamp`,`forum_posts`, `PurchaseUsersConcurrent`, `vip_gifts` FROM `user_stats` WHERE `id` = @user_id LIMIT 1");
                dbClient.AddParameter("user_id", Id);

                DataRow StatRow = dbClient.getRow();

                if (StatRow == null)//No row, add it yo
                {
                    dbClient.RunQuery("INSERT INTO `user_stats` (`id`) VALUES ('" + Id + "')");
                    dbClient.SetQuery("SELECT `id`,`roomvisits`,`onlinetime`,`respect`,`respectgiven`,`giftsgiven`,`giftsreceived`,`dailyrespectpoints`,`dailypetrespectpoints`,`achievementscore`,`quest_id`,`quest_progress`,`groupid`,`tickets_answered`,`respectstimestamp`,`forum_posts`, `PurchaseUsersConcurrent`, `vip_gifts` FROM `user_stats` WHERE `id` = @user_id LIMIT 1");
                    dbClient.AddParameter("user_id", Id);
                    StatRow = dbClient.getRow();
                }

                try
                {
                    _habboStats = new HabboStats(Convert.ToInt32(StatRow["roomvisits"]), Convert.ToDouble(StatRow["onlineTime"]), Convert.ToInt32(StatRow["respect"]), Convert.ToInt32(StatRow["respectGiven"]), Convert.ToInt32(StatRow["giftsGiven"]),
                                                 Convert.ToInt32(StatRow["giftsReceived"]), Convert.ToInt32(StatRow["dailyRespectPoints"]), Convert.ToInt32(StatRow["dailyPetRespectPoints"]), Convert.ToInt32(StatRow["AchievementScore"]),
                                                 Convert.ToInt32(StatRow["quest_id"]), Convert.ToInt32(StatRow["quest_progress"]), Convert.ToInt32(StatRow["groupid"]), Convert.ToString(StatRow["respectsTimestamp"]), Convert.ToInt32(StatRow["forum_posts"]), Convert.ToBoolean(StatRow["PurchaseUsersConcurrent"]), Convert.ToInt32(StatRow["vip_gifts"]));

                    if (Convert.ToString(StatRow["respectsTimestamp"]) != DateTime.Today.ToString("MM/dd"))
                    {
                        _habboStats.RespectsTimestamp = DateTime.Today.ToString("MM/dd");
                        SubscriptionData SubData = null;

                        int DailyRespects = 3;

                        if (_permissions.HasRight("mod_tool"))
                        {
                            DailyRespects = 20;
                        }
                        else if (NeonEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(VIPRank, out SubData))
                        {
                            DailyRespects = SubData.Respects;
                        }

                        _habboStats.DailyRespectPoints    = DailyRespects;
                        _habboStats.DailyPetRespectPoints = DailyRespects;

                        dbClient.RunQuery("UPDATE `user_stats` SET `dailyRespectPoints` = '" + DailyRespects + "', `dailyPetRespectPoints` = '" + DailyRespects + "', `respectsTimestamp` = '" + DateTime.Today.ToString("MM/dd") + "' WHERE `id` = '" + Id + "' LIMIT 1");
                    }
                }
                catch (Exception e)
                {
                    Logging.LogException(e.ToString());
                }
            }

            if (!NeonEnvironment.GetGame().GetGroupManager().TryGetGroup(_habboStats.FavouriteGroupId, out _))
            {
                _habboStats.FavouriteGroupId = 0;
            }
            #endregion
        }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
0
        public bool TryAuthenticate(string AuthTicket)
        {
            try
            {
                byte     errorCode = 0;
                UserData userData  = UserDataFactory.GetUserData(AuthTicket, out errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect(true);
                    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 (PlusEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (PlusEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect(true);
                            return(false);
                        }
                    }
                }

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

                #region Roleplay Data
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT * FROM `rp_stats` WHERE `id` = '" + userData.userID + "' LIMIT 1");
                    DataRow UserRPRow = dbClient.getRow();

                    dbClient.SetQuery("SELECT * FROM `rp_stats_cooldowns` WHERE `id` = '" + userData.userID + "' LIMIT 1");
                    DataRow UserRPCooldowns = dbClient.getRow();

                    if (UserRPCooldowns == null)
                    {
                        dbClient.RunQuery("INSERT INTO `rp_stats_cooldowns` (`id`) VALUES ('" + userData.userID + "')");
                        dbClient.SetQuery("SELECT * FROM `rp_stats_cooldowns` WHERE `id` = '" + userData.userID + "' LIMIT 1");
                        UserRPCooldowns = dbClient.getRow();
                    }

                    dbClient.SetQuery("SELECT * FROM `rp_stats_farming` WHERE `id` = '" + userData.userID + "' LIMIT 1");
                    DataRow UserRPFarming = dbClient.getRow();

                    if (UserRPFarming == null)
                    {
                        dbClient.RunQuery("INSERT INTO `rp_stats_farming` (`id`) VALUES ('" + userData.userID + "')");
                        dbClient.SetQuery("SELECT * FROM `rp_stats_farming` WHERE `id` = '" + userData.userID + "' LIMIT 1");
                        UserRPFarming = dbClient.getRow();
                    }

                    _roleplay = new RoleplayUser(this, UserRPRow, UserRPCooldowns, UserRPFarming);
                }
                #endregion

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

                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().GetClothingAllParts));
                    SendMessage(new UserRightsComposer(this, _habbo.Rank));
                    SendMessage(new AvailabilityStatusComposer());
                    SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));
                    SendMessage(new BuildersClubMembershipComposer());
                    SendMessage(new CfhTopicsInitComposer());
                    SendMessage(new BadgeDefinitionsComposer(PlusEnvironment.GetGame().GetAchievementManager()._achievements));
                    SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState)));
                    //SendMessage(new TalentTrackLevelComposer());

                    if (!string.IsNullOrEmpty(MachineId))
                    {
                        if (this._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;
                    }

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

                    SubscriptionData SubData = null;
                    if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(this._habbo.VIPRank, out 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.InitProcess();

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

                    if (!string.IsNullOrWhiteSpace(PlusEnvironment.GetDBConfig().DBData["welcome_message"]))
                    {
                        SendMessage(new MOTDNotificationComposer(PlusEnvironment.GetDBConfig().DBData["welcome_message"].Replace("\\r\\n", "\n")));
                    }

                    PlusEnvironment.GetGame().GetRewardManager().CheckRewards(this);
                    this.AuthTicket = AuthTicket;
                    EventManager.TriggerEvent("OnLogin", this);
                    return(true);
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Erro durante o login do usuário: " + e);
            }
            return(false);
        }
예제 #10
0
        public bool TryAuthenticate(string AuthTicket)
        {
            try
            {
                byte     errorCode = 0;
                UserData userData  = UserDataFactory.GetUserData(AuthTicket, out 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 (QuasarEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (QuasarEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

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

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

                    SendMessage(new AuthenticationOKComposer());
                    SendMessage(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects));
                    //FurniListNotification -> why?
                    SendMessage(new NavigatorSettingsComposer(_habbo.HomeRoom));
                    SendMessage(new FavouritesComposer(userData.user.FavoriteRooms));
                    SendMessage(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingAllParts));
                    //1984
                    //2102
                    SendMessage(new UserRightsComposer(_habbo));
                    SendMessage(new AvailabilityStatusComposer());
                    //1044
                    SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));
                    //3674
                    //3437
                    SendMessage(new CampaignCalendarDataComposer(_habbo.calendarGift));

                    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(QuasarEnvironment.GetGame().GetAchievementManager()._achievements));
                    SendMessage(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState)));
                    //SendMessage(new TalentTrackLevelComposer());

                    if (!string.IsNullOrEmpty(MachineId))
                    {
                        if (this._habbo.MachineId != MachineId)
                        {
                            using (IQueryAdapter dbClient = QuasarEnvironment.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;
                    }

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

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

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


                    _habbo.InitProcess();

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

                    if (!string.IsNullOrWhiteSpace(QuasarEnvironment.GetDBConfig().DBData["welcome_message"]))
                    {
                        SendMessage(new MOTDNotificationComposer(QuasarEnvironment.GetDBConfig().DBData["welcome_message"]));
                    }

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


                    if (GetHabbo()._NUX)
                    {
                        var nuxStatus = new ServerPacket(ServerPacketHeader.NuxUserStatus);
                        nuxStatus.WriteInteger(2);
                        SendMessage(nuxStatus);
                        QuasarEnvironment.GetGame().GetClientManager().StaffAlert(RoomNotificationComposer.SendBubble("bubble_filter", "Er is een nieuwe gebruiker geregistreerd in Habbis!\n\nGebruiker: " + GetHabbo().Username + "", ""));
                    }

                    if (QuasarEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer != null)
                    {
                        SendMessage(QuasarEnvironment.GetGame().GetTargetedOffersManager().TargetedOffer.Serialize());
                    }

                    return(true);
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Bug during user login: " + e);
            }
            return(false);
        }
        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 (BiosEmuThiago.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (BiosEmuThiago.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

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

                BiosEmuThiago.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(BiosEmuThiago.GetGame().GetModerationManager().UserActionPresets));
                    SendMessage(new BadgeDefinitionsComposer(BiosEmuThiago.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 = BiosEmuThiago.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 (BiosEmuThiago.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 (!BiosEmuThiago.GetGame().GetCacheManager().ContainsUser(_habbo.Id))
                    {
                        BiosEmuThiago.GetGame().GetCacheManager().GenerateUser(_habbo.Id);
                    }

                    _habbo.InitProcess();

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

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

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

                    if (GetHabbo().Rank >= 3)
                    {
                        using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT * FROM `ranks` WHERE id = '" + GetHabbo().Rank + "'");
                            DataRow Table = dbClient.getRow();

                            if (GetHabbo().GetBadgeComponent().HasBadge(Convert.ToString(Table["badgeid"])))
                            {
                            }
                            else
                            {
                                GetHabbo().GetBadgeComponent().GiveBadge(Convert.ToString(Table["badgeid"]), true, GetHabbo().GetClient());
                                SendMessage(RoomNotificationComposer.SendBubble("badge/" + Table["badgeid"], "Você recebeu o emblema staff do seu rank!", "/inventory/open/badge"));
                            }
                        }
                    }

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

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

                    // Fixe do Presentes do HC By Thiago Araujo
                    //DateTime dateGregorians = new DateTime();
                    //dateGregorians = DateTime.Today;
                    //int days = (dateGregorians.Day);
                    //if (30 == days)
                    //{
                    //    SendMessage(new HCGiftsAlertComposer());
                    //    SendMessage(new RoomNotificationComposer("sumando", "message", "Hoje é dia de presentes HC, pegue o seu antes que acabe!"));
                    //}

                    // Da a conquista de login por dia feito por Thiago Araujo
                    string dFrank = null;
                    using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("SELECT Datahoje FROM users WHERE id = '" + userData.user.GetClient().GetHabbo().Id + "' LIMIT 1");
                        dFrank = dbClient.getString();
                    }
                    int      dFrankInt     = Int32.Parse(dFrank);
                    DateTime dateGregorian = new DateTime();
                    dateGregorian = DateTime.Today;
                    int day = (dateGregorian.Day);
                    if (dFrankInt != day)
                    {
                        using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunQuery("UPDATE users SET Datahoje = '" + day + "' WHERE id = " + GetHabbo().Id + ";");
                        }
                        BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(userData.user.GetClient(), "ACH_Login", 1);
                    }

                    if (ExtraSettings.STAFF_MENSG_ENTERTHIAGO)
                    {
                        using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT * FROM `ranks` WHERE id = '" + GetHabbo().Rank + "'");
                            DataRow Table = dbClient.getRow();

                            if (GetHabbo().Rank == 1)
                            {
                                // Thiago é muito lindo ser é doido
                            }
                            else
                            {
                                string figure = this.GetHabbo().Look;

                                BiosEmuThiago.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("fig/" + figure, 3, "O " + Convert.ToString(Table["name"]) + " " + userData.user.GetClient().GetHabbo().Username + " entrou no hotel!", ""));
                            }
                        }

                        if (GetHabbo().isMedal)
                        {
                            var nuxStatus = new ServerPacket(ServerPacketHeader.NuxUserStatus);
                            nuxStatus.WriteInteger(2);
                            SendMessage(nuxStatus);

                            string thiagolindogostoso = this.GetHabbo().Look;

                            BiosEmuThiago.GetGame().GetClientManager().StaffAlert(new RoomNotificationComposer("fig/" + thiagolindogostoso, 3, "Hey o usuário: " + GetHabbo().Username + " acaba de se registra no hotel.", ""));

                            if (GetHabbo().isMedal)
                            {
                                string thiago = this.GetHabbo().Look;

                                SendMessage(new RoomNotificationComposer("fig/" + thiago, 3, "Hey " + userData.user.GetClient().GetHabbo().Username + " Bem-vindo ao nosso hotel!", ""));
                            }


                            if (GetHabbo().isMedal == false)
                            {
                                string thiagolindo = this.GetHabbo().Look;

                                SendMessage(new RoomNotificationComposer("fig/" + thiagolindo, 3, "Hey " + userData.user.GetClient().GetHabbo().Username + " Bem-vindo de volta ao nosso hotel!", ""));
                            }
                        }
                    }

                    if (GetHabbo().Rank > Convert.ToInt32(BiosEmuThiago.GetConfig().data["MineRankStaff"]))
                    {
                        using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunQuery("UPDATE users SET prefix_name = '' WHERE id = '" + GetHabbo().Id + "'");
                            dbClient.RunQuery("UPDATE users SET prefix_name_color = '' WHERE id = '" + GetHabbo().Id + "'");
                        }
                        GetHabbo()._NamePrefixColor = "";
                        GetHabbo()._NamePrefix      = "";
                    }

                    if (GetHabbo().Rank > 0)
                    {
                        using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.SetQuery("SELECT * FROM `users` WHERE id = '" + GetHabbo().Id + "'");
                            DataRow Table = dbClient.getRow();

                            if (Convert.ToString(Table["LalaConf"]) == "0")
                            {
                                // Thiago é muito lindo ser é doido
                            }
                            else
                            {
                                BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(userData.user.GetClient(), "ACH_TraderPass", 1);
                                BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(userData.user.GetClient(), "ACH_AvatarTags", 1);
                                BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(userData.user.GetClient(), "ACH_EmailVerification", 1);
                            }
                        }
                    }

                    if (GetHabbo().isMedal)
                    {
                        if (ExtraSettings.WELCOME_NEW_MESSAGE_ENABLED)
                        {
                            ServerPacket notif = new ServerPacket(ServerPacketHeader.NuxAlertMessageComposer);
                            notif.WriteString(ExtraSettings.WELCOME_MESSAGE_URL);
                            SendMessage(notif);
                        }
                        using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunQuery("UPDATE users SET isMedal = '0' WHERE id = " + GetHabbo().Id + ";");
                        }
                        GetHabbo().isMedal = false;
                    }

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

                        GameClient Friend = BiosEmuThiago.GetGame().GetClientManager().GetClientByUserID(Buddy.Id);
                        if (Friend == null)
                        {
                            continue;
                        }
                        string figure = GetHabbo().Look;

                        Friend.SendMessage(new RoomNotificationComposer("fig/" + figure, 3, this.GetHabbo().Username + ", seu amigo acabou de entrar no hotel!", ""));
                    }
                    return(true);
                }
            }
            catch (Exception e)
            {
                ExceptionLogger.LogException(e);
            }
            return(false);
        }
예제 #12
0
        public Habbo(int id,
                     string username,
                     int rank,
                     string motto,
                     string look,
                     string gender,
                     int credits,
                     int activityPoints,
                     int homeRoom,
                     bool hasFriendRequestsDisabled,
                     int lastOnline,
                     bool appearOffline,
                     bool hideInRoom,
                     double createDate,
                     int diamonds,
                     string machineId,
                     string clientVolume,
                     bool chatPreference,
                     bool focusPreference,
                     bool petsMuted,
                     bool botsMuted,
                     bool advertisingReportBlocked,
                     double lastNameChange,
                     int gotwPoints,
                     bool ignoreInvites,
                     double timeMuted,
                     double tradingLock,
                     bool allowGifts,
                     int friendBarState,
                     bool disableForcedEffects,
                     bool allowMimic,
                     int vipRank)
        {
            Id             = id;
            Username       = username;
            Rank           = rank;
            Motto          = motto;
            Look           = look;
            Gender         = gender.ToLower();
            FootballLook   = PlusEnvironment.FilterFigure(look.ToLower());
            FootballGender = gender.ToLower();
            Credits        = credits;
            Duckets        = activityPoints;
            Diamonds       = diamonds;
            GotwPoints     = gotwPoints;
            HomeRoom       = homeRoom;
            LastOnline     = lastOnline;
            AccountCreated = createDate;
            ClientVolume   = new List <int>();
            foreach (var str in clientVolume.Split(','))
            {
                ClientVolume.Add(int.TryParse(str, out _) ? int.Parse(str) : 100);
            }

            LastNameChange        = lastNameChange;
            MachineId             = machineId;
            ChatPreference        = chatPreference;
            FocusPreference       = focusPreference;
            IsExpert              = IsExpert;
            AppearOffline         = appearOffline;
            AllowTradingRequests  = true;                      //TODO
            AllowUserFollowing    = true;                      //TODO
            AllowFriendRequests   = hasFriendRequestsDisabled; //TODO
            AllowMessengerInvites = ignoreInvites;
            AllowPetSpeech        = petsMuted;
            AllowBotSpeech        = botsMuted;
            AllowPublicRoomStatus = hideInRoom;
            AllowConsoleMessages  = true;
            AllowGifts            = allowGifts;
            AllowMimic            = allowMimic;
            ReceiveWhispers       = true;
            IgnorePublicWhispers  = false;
            PlayingFastFood       = false;
            FriendbarState        = FriendBarStateUtility.GetEnum(friendBarState);
            ChristmasDay          = ChristmasDay;
            WantsToRideHorse      = 0;
            TimeAfk = 0;
            DisableForcedEffects = disableForcedEffects;
            VipRank           = vipRank;
            _disconnected     = false;
            _habboSaved       = false;
            ChangingName      = false;
            FloodTime         = 0;
            FriendCount       = 0;
            TimeMuted         = timeMuted;
            _timeCached       = DateTime.Now;
            TradingLockExpiry = tradingLock;
            if (TradingLockExpiry > 0 && PlusEnvironment.GetUnixTimestamp() > TradingLockExpiry)
            {
                TradingLockExpiry = 0;
                using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `user_info` SET `trading_locked` = '0' WHERE `user_id` = '" + id + "' LIMIT 1");
                }
            }
            BannedPhraseCount          = 0;
            SessionStart               = PlusEnvironment.GetUnixTimestamp();
            MessengerSpamCount         = 0;
            MessengerSpamTime          = 0;
            CreditsUpdateTick          = Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("user.currency_scheduler.tick"));
            TentId                     = 0;
            HopperId                   = 0;
            IsHopping                  = false;
            TeleporterId               = 0;
            IsTeleporting              = false;
            TeleportingRoomId          = 0;
            RoomAuthOk                 = false;
            CurrentRoomId              = 0;
            HasSpoken                  = false;
            LastAdvertiseReport        = 0;
            AdvertisingReported        = false;
            AdvertisingReportedBlocked = advertisingReportBlocked;
            WiredInteraction           = false;
            QuestLastCompleted         = 0;
            InventoryAlert             = false;
            IgnoreBobbaFilter          = false;
            WiredTeleporting           = false;
            CustomBubbleId             = 0;
            OnHelperDuty               = false;
            FastfoodScore              = 0;
            PetId   = 0;
            TempInt = 0;
            LastGiftPurchaseTime       = DateTime.Now;
            LastMottoUpdateTime        = DateTime.Now;
            LastClothingUpdateTime     = DateTime.Now;
            LastForumMessageUpdateTime = DateTime.Now;
            GiftPurchasingWarnings     = 0;
            MottoUpdateWarnings        = 0;
            ClothingUpdateWarnings     = 0;
            SessionGiftBlocked         = false;
            SessionMottoBlocked        = false;
            SessionClothingBlocked     = false;
            FavoriteRooms = new ArrayList();
            Achievements  = new ConcurrentDictionary <string, UserAchievement>();
            Relationships = new Dictionary <int, Relationship>();
            RatedRooms    = new List <int>();
            UsersRooms    = new List <RoomData>();

            //TODO: Nope.
            InitPermissions();
            DataRow statRow = null;

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery(
                    "SELECT `id`,`roomvisits`,`onlinetime`,`respect`,`respectgiven`,`giftsgiven`,`giftsreceived`,`dailyrespectpoints`,`dailypetrespectpoints`,`achievementscore`,`quest_id`,`quest_progress`,`groupid`,`tickets_answered`,`respectstimestamp`,`forum_posts` FROM `user_stats` WHERE `id` = @user_id LIMIT 1");
                dbClient.AddParameter("user_id", id);
                statRow = dbClient.GetRow();
                if (statRow == null) //No row, add it yo
                {
                    dbClient.RunQuery("INSERT INTO `user_stats` (`id`) VALUES ('" + id + "')");
                    dbClient.SetQuery(
                        "SELECT `id`,`roomvisits`,`onlinetime`,`respect`,`respectgiven`,`giftsgiven`,`giftsreceived`,`dailyrespectpoints`,`dailypetrespectpoints`,`achievementscore`,`quest_id`,`quest_progress`,`groupid`,`tickets_answered`,`respectstimestamp`,`forum_posts` FROM `user_stats` WHERE `id` = @user_id LIMIT 1");
                    dbClient.AddParameter("user_id", id);
                    statRow = dbClient.GetRow();
                }
                try
                {
                    _habboStats = new HabboStats(Convert.ToInt32(statRow["roomvisits"]),
                                                 Convert.ToDouble(statRow["onlineTime"]),
                                                 Convert.ToInt32(statRow["respect"]),
                                                 Convert.ToInt32(statRow["respectGiven"]),
                                                 Convert.ToInt32(statRow["giftsGiven"]),
                                                 Convert.ToInt32(statRow["giftsReceived"]),
                                                 Convert.ToInt32(statRow["dailyRespectPoints"]),
                                                 Convert.ToInt32(statRow["dailyPetRespectPoints"]),
                                                 Convert.ToInt32(statRow["AchievementScore"]),
                                                 Convert.ToInt32(statRow["quest_id"]),
                                                 Convert.ToInt32(statRow["quest_progress"]),
                                                 Convert.ToInt32(statRow["groupid"]),
                                                 Convert.ToString(statRow["respectsTimestamp"]),
                                                 Convert.ToInt32(statRow["forum_posts"]));
                    if (Convert.ToString(statRow["respectsTimestamp"]) != DateTime.Today.ToString("MM/dd"))
                    {
                        _habboStats.RespectsTimestamp = DateTime.Today.ToString("MM/dd");
                        SubscriptionData subData = null;
                        var dailyRespects        = 10;
                        if (_permissions.HasRight("mod_tool"))
                        {
                            dailyRespects = 20;
                        }
                        else if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(vipRank, out subData))
                        {
                            dailyRespects = subData.Respects;
                        }
                        _habboStats.DailyRespectPoints    = dailyRespects;
                        _habboStats.DailyPetRespectPoints = dailyRespects;
                        dbClient.RunQuery("UPDATE `user_stats` SET `dailyRespectPoints` = '" +
                                          dailyRespects +
                                          "', `dailyPetRespectPoints` = '" +
                                          dailyRespects +
                                          "', `respectsTimestamp` = '" +
                                          DateTime.Today.ToString("MM/dd") +
                                          "' WHERE `id` = '" +
                                          id +
                                          "' LIMIT 1");
                    }
                }
                catch (Exception e)
                {
                    ExceptionLogger.LogException(e);
                }
            }
            Group g = null;

            if (!PlusEnvironment.GetGame().GetGroupManager().TryGetGroup(_habboStats.FavouriteGroupId, out g))
            {
                _habboStats.FavouriteGroupId = 0;
            }
        }
예제 #13
0
        public bool TryAuthenticate(string AuthTicket)
        {
            try
            {
                byte     errorCode = 0;
                UserData userData  = UserDataFactory.GetUserData(AuthTicket, out errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect();
                    return(false);
                }

                #region Ban Checking

                ModerationBan BanRecord = null;
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (RocketEmulador.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (RocketEmulador.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

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

                RocketEmulador.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                this._habbo = userData.user;
                bool flag8 = this._habbo != null;
                if (flag8)
                {
                    userData.user.Init(this, userData);
                    this.SendMessage(new AuthenticationOKComposer());
                    this.SendMessage(new AvatarEffectsComposer(this._habbo.Effects().GetAllEffects));
                    this.SendMessage(new NavigatorSettingsComposer(this._habbo.HomeRoom));
                    this.SendMessage(new FavouritesComposer(userData.user.FavoriteRooms));
                    this.SendMessage(new FigureSetIdsComposer(this._habbo.GetClothing().GetClothingAllParts));
                    this.SendMessage(new UserRightsComposer(this._habbo.Rank));
                    this.SendMessage(new AvailabilityStatusComposer());

                    this.SendMessage(new TalentTrackLevelComposer());
                    this.SendMessage(new TargetOfferMessageComposer());
                    this.SendMessage(new AchievementScoreComposer(this._habbo.GetStats().AchievementPoints));

                    ServerPacket serverPacket = new ServerPacket(879);
                    serverPacket.WriteString("club_habbo");
                    serverPacket.WriteInteger(0);
                    serverPacket.WriteInteger(0);
                    serverPacket.WriteInteger(0);
                    serverPacket.WriteInteger(2);
                    serverPacket.WriteBoolean(false);
                    serverPacket.WriteBoolean(false);
                    serverPacket.WriteInteger(0);
                    serverPacket.WriteInteger(0);
                    serverPacket.WriteInteger(0);
                    this.SendMessage(serverPacket);
                    this.SendMessage(new BuildersClubMembershipComposer());
                    this.SendMessage(new CfhTopicsInitComposer());
                    this.SendMessage(new BadgeDefinitionsComposer(RocketEmulador.GetGame().GetAchievementManager()._achievements));
                    this.SendMessage(new SoundSettingsComposer(this._habbo.ClientVolume, this._habbo.ChatPreference, this._habbo.AllowMessengerInvites, this._habbo.FocusPreference, FriendBarStateUtility.GetInt(this._habbo.FriendbarState)));
                    bool flag9 = this.GetHabbo().GetMessenger() != null;
                    if (flag9)
                    {
                        this.GetHabbo().GetMessenger().OnStatusChanged(true);
                    }
                    bool flag10 = !string.IsNullOrEmpty(this.MachineId);
                    if (flag10)
                    {
                        bool flag11 = this._habbo.MachineId != this.MachineId;
                        if (flag11)
                        {
                            using (IQueryAdapter queryReactor = RocketEmulador.GetDatabaseManager().GetQueryReactor())
                            {
                                queryReactor.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1");
                                queryReactor.AddParameter("MachineId", this.MachineId);
                                queryReactor.AddParameter("id", this._habbo.Id);
                                queryReactor.RunQuery();
                            }
                        }
                        this._habbo.MachineId = this.MachineId;
                    }

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

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

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

                    _habbo.InitProcess();

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

                    {
                        string hotelName = RocketEmulador.RocketData().data["hotelname"];
                        if (!string.IsNullOrWhiteSpace(RocketEmulador.GetDBConfig().DBData["welcome_message"]))
                        {
                            SendMessage(new MOTDNotificationComposer(RocketEmulador.GetDBConfig().DBData["welcome_message"]));
                        }


                        SendMessage(new RoomNotificationComposer("entrar", "message", "Bem-vindo" +
                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                 "ao " + hotelName + "!"));


                        if (GetHabbo().Rank == 10)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O PROGRAMADOR" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }
                        if (GetHabbo().Rank == 9)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O CEO" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        if (GetHabbo().Rank == 8)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O GERENTE" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        if (GetHabbo().Rank == 7)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O ADM" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        if (GetHabbo().Rank == 6)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O MOD" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        if (GetHabbo().Rank == 5)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O PROMOTOR" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        if (GetHabbo().Rank == 4)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O EMB" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        if (GetHabbo().Rank == 3)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O VIP" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }



                        if (GetHabbo().Rank == 2)
                        {
                            RocketEmulador.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("login", "message", "O LOCUTOR" +
                                                                                                                 " " + userData.user.GetClient().GetHabbo().Username + " " +
                                                                                                                 "entrou no " + hotelName + "!"));
                        }

                        Console.WriteLine("Um novo usuário se conectou seu nick é: " + userData.user.GetClient().GetHabbo().Username + " e seu ip: " + userData.user.GetClient().GetConnection().getIp(), "Rocket.Users",
                                          ConsoleColor.DarkGreen);
                    }
                }
            }


            catch (Exception e)
            {
                Logging.LogCriticalException("Bug during user login: " + e);
            }
            return(false);
        }