Esempio n. 1
0
        public ProfileInformationComposer(Habbo Data, GameClient Session, List<Group> Groups, int friendCount)
            : base(ServerPacketHeader.ProfileInformationMessageComposer)
        {
            DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Data.AccountCreated);

            base.WriteInteger(Data.Id);
            base.WriteString(Data.Username);
            base.WriteString(Data.Look);
            base.WriteString(Data.Motto);
            base.WriteString(origin.ToString("dd/MM/yyyy"));
            base.WriteInteger(Data.GetStats().AchievementPoints);
            base.WriteInteger(friendCount); // Friend Count
            base.WriteBoolean(Data.Id != Session.GetHabbo().Id && Session.GetHabbo().GetMessenger().FriendshipExists(Data.Id)); //  Is friend
            base.WriteBoolean(Data.Id != Session.GetHabbo().Id && !Session.GetHabbo().GetMessenger().FriendshipExists(Data.Id) && Session.GetHabbo().GetMessenger().RequestExists(Data.Id)); // Sent friend request
            base.WriteBoolean((PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(Data.Id)) != null);

            base.WriteInteger(Groups.Count);
            foreach (Group Group in Groups)
            {
                base.WriteInteger(Group.Id);
                base.WriteString(Group.Name);
                base.WriteString(Group.Badge);
                base.WriteString(PlusEnvironment.GetGame().GetGroupManager().GetGroupColour(Group.Colour1, true));
                base.WriteString(PlusEnvironment.GetGame().GetGroupManager().GetGroupColour(Group.Colour2, false));
                base.WriteBoolean(Data.GetStats().FavouriteGroupId == Group.Id); // todo favs
                base.WriteInteger(0);//what the f**k
                base.WriteBoolean(Group != null ? Group.ForumEnabled : true);//HabboTalk
            }

            base.WriteInteger(Convert.ToInt32(PlusEnvironment.GetUnixTimestamp() - Data.LastOnline)); // Last online
            base.WriteBoolean(true); // Show the profile
        }
Esempio n. 2
0
        public static Item CreateGiftItem(ItemData Data, Habbo Habbo, string ExtraData, string DisplayFlags, int ItemId, int LimitedNumber = 0, int LimitedStack = 0)
        {
            if (Data == null) throw new InvalidOperationException("Data cannot be null.");

            Item Item = new Item(ItemId, 0, Data.Id, ExtraData, 0, 0, 0, 0, Habbo.Id, 0, LimitedNumber, LimitedStack, "");

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO `items` (`id`,base_item,user_id,room_id,x,y,z,wall_pos,rot,extra_data,`limited_number`,`limited_stack`) VALUES (@id, @did,@uid,@rid,@x,@y,@z,@wall_pos,@rot,@extra_data, @limited_number, @limited_stack)");
                dbClient.AddParameter("id", ItemId);
                dbClient.AddParameter("did", Data.Id);
                dbClient.AddParameter("uid", Habbo.Id);
                dbClient.AddParameter("rid", 0);
                dbClient.AddParameter("x", 0);
                dbClient.AddParameter("y", 0);
                dbClient.AddParameter("z", 0);
                dbClient.AddParameter("wall_pos", "");
                dbClient.AddParameter("rot", 0);
                dbClient.AddParameter("extra_data", ExtraData);
                dbClient.AddParameter("limited_number", LimitedNumber);
                dbClient.AddParameter("limited_stack", LimitedStack);
                dbClient.RunQuery();

                return Item;
            }
        }
Esempio n. 3
0
 public PetInformationComposer(Habbo Habbo)
     : base(ServerPacketHeader.PetInformationMessageComposer)
 {
     base.WriteInteger(Habbo.Id);
    base.WriteString(Habbo.Username);
     base.WriteInteger(Habbo.Rank);
     base.WriteInteger(10);
     base.WriteInteger(0);
     base.WriteInteger(0);
     base.WriteInteger(100);
     base.WriteInteger(100);
     base.WriteInteger(100);
     base.WriteInteger(100);
     base.WriteInteger(Habbo.GetStats().Respect);
     base.WriteInteger(Habbo.Id);
     base.WriteInteger(Convert.ToInt32(Math.Floor((PlusEnvironment.GetUnixTimestamp() - Habbo.AccountCreated) / 86400)));//How?
    base.WriteString(Habbo.Username);
     base.WriteInteger(1);//3 on hab
     base.WriteBoolean(false);
     base.WriteBoolean(false);
     base.WriteInteger(0);//5 on hab
     base.WriteInteger(0); // Anyone can ride horse
     base.WriteInteger(0);
     base.WriteInteger(0);//512 on hab
     base.WriteInteger(0);//1536
     base.WriteInteger(0);//2560
     base.WriteInteger(0);//3584
     base.WriteInteger(0);
    base.WriteString("");
     base.WriteBoolean(false);
     base.WriteInteger(-1);//255 on hab
     base.WriteInteger(-1);
     base.WriteInteger(-1);
     base.WriteBoolean(false);
 }
Esempio n. 4
0
 public GetRelationshipsComposer(Habbo Habbo, int Loves, int Likes, int Hates)
     : base(ServerPacketHeader.GetRelationshipsMessageComposer)
 {
     base.WriteInteger(Habbo.Id);
     base.WriteInteger(Habbo.Relationships.Count); // Count
     foreach (Relationship Rel in Habbo.Relationships.Values)
     {
         UserCache HHab = PlusEnvironment.GetGame().GetCacheManager().GenerateUser(Rel.UserId);
         if (HHab == null)
         {
             base.WriteInteger(0);
             base.WriteInteger(0);
             base.WriteInteger(0); // Their ID
            base.WriteString("Placeholder");
            base.WriteString("hr-115-42.hd-190-1.ch-215-62.lg-285-91.sh-290-62");
         }
         else
         {
             base.WriteInteger(Rel.Type);
             base.WriteInteger(Rel.Type == 1 ? Loves : Rel.Type == 2 ? Likes : Hates);
             base.WriteInteger(Rel.UserId); // Their ID
            base.WriteString(HHab.Username);
            base.WriteString(HHab.Look);
         }
     }
 }
Esempio n. 5
0
        public BuddyListComposer(ICollection<MessengerBuddy> Friends, Habbo Player)
            : base(ServerPacketHeader.BuddyListMessageComposer)
        {
            base.WriteInteger(1);
            base.WriteInteger(0);

            base.WriteInteger(Friends.Count);
            foreach (MessengerBuddy Friend in Friends.ToList())
            {
                Relationship Relationship = Player.Relationships.FirstOrDefault(x => x.Value.UserId == Convert.ToInt32(Friend.UserId)).Value;

                base.WriteInteger(Friend.Id);
               base.WriteString(Friend.mUsername);
                base.WriteInteger(1);//Gender.
                base.WriteBoolean(Friend.IsOnline);
                base.WriteBoolean(Friend.IsOnline && Friend.InRoom);
               base.WriteString(Friend.IsOnline ? Friend.mLook : string.Empty);
                base.WriteInteger(0); // category id
               base.WriteString(Friend.IsOnline ? Friend.mMotto : string.Empty);
               base.WriteString(string.Empty);//Alternative name?
               base.WriteString(string.Empty);
                base.WriteBoolean(true);
                base.WriteBoolean(false);
                base.WriteBoolean(false);//Pocket Habbo user.
                base.WriteShort(Relationship == null ? 0 : Relationship.Type);
            }
        }
Esempio n. 6
0
 public GroupMemberUpdatedComposer(int GroupId, Habbo Habbo, int Type)
     : base(ServerPacketHeader.GroupMemberUpdatedMessageComposer)
 {
     base.WriteInteger(GroupId);//GroupId
     base.WriteInteger(Type);//Type?
     {
         base.WriteInteger(Habbo.Id);//UserId
         base.WriteString(Habbo.Username);
         base.WriteString(Habbo.Look);
         base.WriteString(string.Empty);
     }
 }
Esempio n. 7
0
 public UserPerksComposer(Habbo Habbo)
     : base(ServerPacketHeader.UserPerksMessageComposer)
 {
     base.WriteInteger(15); // Count
     base.WriteString("USE_GUIDE_TOOL");
     base.WriteString("");
     base.WriteBoolean(false);
     base.WriteString("GIVE_GUIDE_TOURS");
     base.WriteString("requirement.unfulfilled.helper_le");
     base.WriteBoolean(false);
     base.WriteString("JUDGE_CHAT_REVIEWS");
     base.WriteString(""); // ??
     base.WriteBoolean(true);
     base.WriteString("VOTE_IN_COMPETITIONS");
     base.WriteString(""); // ??
     base.WriteBoolean(true);
     base.WriteString("CALL_ON_HELPERS");
     base.WriteString(""); // ??
     base.WriteBoolean(false);
     base.WriteString("CITIZEN");
     base.WriteString(""); // ??
     base.WriteBoolean(true);
     base.WriteString("TRADE");
     base.WriteString(""); // ??
     base.WriteBoolean(true);
     base.WriteString("HEIGHTMAP_EDITOR_BETA");
     base.WriteString(""); // ??
     base.WriteBoolean(false);
     base.WriteString("EXPERIMENTAL_CHAT_BETA");
     base.WriteString("requirement.unfulfilled.helper_level_2");
     base.WriteBoolean(true);
     base.WriteString("EXPERIMENTAL_TOOLBAR");
     base.WriteString(""); // ??
     base.WriteBoolean(true);
     base.WriteString("BUILDER_AT_WORK");
     base.WriteString(""); // ??
     base.WriteBoolean(true);
     base.WriteString("NAVIGATOR_PHASE_ONE_2014");
     base.WriteString(""); // ??
     base.WriteBoolean(false);
     base.WriteString("CAMERA");
     base.WriteString(""); // ??
     base.WriteBoolean(false);
     base.WriteString("NAVIGATOR_PHASE_TWO_2014");
     base.WriteString(""); // ??
     base.WriteBoolean(true);
     base.WriteString("MOUSE_ZOOM");
     base.WriteString(""); // ??
     base.WriteBoolean(true);
     base.WriteString("NAVIGATOR_ROOM_THUMBNAIL_CAMERA");
     base.WriteString(""); // ??
     base.WriteBoolean(false);
 }
Esempio n. 8
0
        public ChatlogEntry(int PlayerId, int RoomId, string Message, double Timestamp, Habbo Player = null, RoomData Instance = null)
        {
            this._playerId = PlayerId;
            this._roomId = RoomId;
            this._message = Message;
            this._timestamp = Timestamp;

            if (Player != null)
                this._playerReference = new WeakReference(Player);

            if (Instance != null)
                this._roomReference = new WeakReference(Instance);
        }
Esempio n. 9
0
 public ModerationTicket(int Id, int Type, int Category, double Timestamp, int Priority, Habbo Sender, Habbo Reported, string Issue, RoomData Room)
 {
     this.Id = Id;
     this.Type = Type;
     this.Category = Category;
     this.Timestamp = Timestamp;
     this.Priority = Priority;
     this.Sender = Sender;
     this.Reported = Reported;
     this.Moderator = null;
     this.Issue = Issue;
     this.Room = Room;
     this.Answered = false;
 }
        public ModeratorUserRoomVisitsComposer(Habbo Data, Dictionary<double, RoomData> Visits)
            : base(ServerPacketHeader.ModeratorUserRoomVisitsMessageComposer)
        {
            base.WriteInteger(Data.Id);
           base.WriteString(Data.Username);
            base.WriteInteger(Visits.Count);

            foreach (KeyValuePair<double, RoomData> Visit in Visits)
            {
                base.WriteInteger(Visit.Value.Id);
               base.WriteString(Visit.Value.Name);
                base.WriteInteger(UnixTimestamp.FromUnixTimestamp(Visit.Key).Hour);
                base.WriteInteger(UnixTimestamp.FromUnixTimestamp(Visit.Key).Minute);
            }
        }
 public RespectPetNotificationMessageComposer(Habbo Habbo, RoomUser User)
     : base(ServerPacketHeader.RespectPetNotificationMessageComposer)
 {
     //TODO: Structure
     base.WriteInteger(User.VirtualId);
     base.WriteInteger(User.VirtualId);
     base.WriteInteger(Habbo.Id);//Pet Id, 100%
    base.WriteString(Habbo.Username);
     base.WriteInteger(0);
     base.WriteInteger(0);
    base.WriteString("FFFFFF");//Yeah..
     base.WriteInteger(0);
     base.WriteInteger(0);//Count - 3 ints.
     base.WriteInteger(1);
 }
Esempio n. 12
0
        public HabboUserBadgesComposer(Habbo Habbo)
            : base(ServerPacketHeader.HabboUserBadgesMessageComposer)
        {
            base.WriteInteger(Habbo.Id);
            base.WriteInteger(Habbo.GetBadgeComponent().EquippedCount);

            foreach (Badge Badge in Habbo.GetBadgeComponent().GetBadges().ToList())
            {
                if (Badge.Slot <= 0)
                    continue;

                base.WriteInteger(Badge.Slot);
               base.WriteString(Badge.Code);
            }
        }
Esempio n. 13
0
        private bool CanChangeName(Habbo Habbo)
        {
            if (Habbo.Rank == 1 && Habbo.VIPRank == 0 && Habbo.LastNameChange == 0)
                return true;
            else if (Habbo.Rank == 1 && Habbo.VIPRank == 1 && (Habbo.LastNameChange == 0 || (PlusEnvironment.GetUnixTimestamp() + 604800) > Habbo.LastNameChange))
                return true;
            else if (Habbo.Rank == 1 && Habbo.VIPRank == 2 && (Habbo.LastNameChange == 0 || (PlusEnvironment.GetUnixTimestamp() + 86400) > Habbo.LastNameChange))
                return true;
            else if (Habbo.Rank == 1 && Habbo.VIPRank == 3)
                return true;
            else if (Habbo.GetPermissions().HasRight("mod_tool"))
                return true;

            return false;
        }
Esempio n. 14
0
 public UserObjectComposer(Habbo Habbo)
     : base(ServerPacketHeader.UserObjectMessageComposer)
 {
     base.WriteInteger(Habbo.Id);
     base.WriteString(Habbo.Username);
     base.WriteString(Habbo.Look);
     base.WriteString(Habbo.Gender.ToUpper());
     base.WriteString(Habbo.Motto);
     base.WriteString("");
     base.WriteBoolean(false);
     base.WriteInteger(Habbo.GetStats().Respect);
     base.WriteInteger(Habbo.GetStats().DailyRespectPoints);
     base.WriteInteger(Habbo.GetStats().DailyPetRespectPoints);
     base.WriteBoolean(false); // Friends stream active
     base.WriteString(Habbo.LastOnline.ToString()); // last online?
     base.WriteBoolean(Habbo.ChangingName); // Can change name
     base.WriteBoolean(false);
 }
Esempio n. 15
0
        public List<string> GetPermissionsForPlayer(Habbo Player)
        {
            List<string> PermissionSet = new List<string>();

            List<string> PermRights = null;
            if (this.PermissionGroupRights.TryGetValue(Player.Rank, out PermRights))
            {
                PermissionSet.AddRange(PermRights);
            }

            List<string> SubscriptionRights = null;
            if (this.PermissionSubscriptionRights.TryGetValue(Player.VIPRank, out SubscriptionRights))
            {
                PermissionSet.AddRange(SubscriptionRights);
            }

            return PermissionSet;
        }
Esempio n. 16
0
        public static List<Item> CreateMultipleItems(ItemData Data, Habbo Habbo, string ExtraData, int Amount, int GroupId = 0)
        {
            if (Data == null) throw new InvalidOperationException("Data cannot be null.");

            List<Item> Items = new List<Item>();

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                for (int i = 0; i < Amount; i++)
                {
                    dbClient.SetQuery("INSERT INTO `items` (base_item,user_id,room_id,x,y,z,wall_pos,rot,extra_data) VALUES(@did,@uid,@rid,@x,@y,@z,@wallpos,@rot,@flags);");
                    dbClient.AddParameter("did", Data.Id);
                    dbClient.AddParameter("uid", Habbo.Id);
                    dbClient.AddParameter("rid", 0);
                    dbClient.AddParameter("x", 0);
                    dbClient.AddParameter("y", 0);
                    dbClient.AddParameter("z", 0);
                    dbClient.AddParameter("wallpos", "");
                    dbClient.AddParameter("rot", 0);
                    dbClient.AddParameter("flags", ExtraData);

                    Item Item = new Item(Convert.ToInt32(dbClient.InsertQuery()), 0, Data.Id, ExtraData, 0, 0, 0, 0, Habbo.Id, GroupId, 0, 0, "");

                    if (GroupId > 0)
                    {
                        dbClient.SetQuery("INSERT INTO `items_groups` (`id`, `group_id`) VALUES (@id, @gid)");
                        dbClient.AddParameter("id", Item.Id);
                        dbClient.AddParameter("gid", GroupId);
                        dbClient.RunQuery();
                    }

                    Items.Add(Item);
                }
            }
            return Items;
        }
Esempio n. 17
0
        private void TeleportUser(Habbo Player)
        {
            if (Player == null)
                return;

            Room Room = Player.CurrentRoom;
            if (Room == null)
                return;

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);
            if (User == null)
                return;

            if (Player.IsTeleporting || Player.IsHopping || Player.TeleporterId != 0)
                return;

            Random rand = new Random();
            List<Item> Items = SetItems.Values.ToList();
            Items = Items.OrderBy(x => rand.Next()).ToList();

            if (Items.Count == 0)
                return;

            Item Item = Items.First();
            if (Item == null)
                return;

            if (!Instance.GetRoomItemHandler().GetFloor.Contains(Item))
            {
                SetItems.TryRemove(Item.Id, out Item);

                if (Items.Contains(Item))
                Items.Remove(Item);

                if (SetItems.Count == 0 || Items.Count == 0)
                    return;

                Item = Items.First();
                if (Item == null)
                    return;
            }

            if (Room.GetGameMap() == null)
                return;

            Room.GetGameMap().TeleportToItem(User, Item);
            Room.GetRoomUserManager().UpdateUserStatusses();

            if (Player.Effects() != null)
                Player.Effects().ApplyEffect(0);
        }
Esempio n. 18
0
        private static bool TrySetWallItem(Habbo Habbo, Item item, string[] data, out string position)
        {
            if (data.Length != 3 || !data[0].StartsWith(":w=") || !data[1].StartsWith("l=") || (data[2] != "r" && data[2] != "l"))
            {
                position = null;
                return false;
            }

            string wBit = data[0].Substring(3, data[0].Length - 3);
            string lBit = data[1].Substring(2, data[1].Length - 2);

            if (!wBit.Contains(",") || !lBit.Contains(","))
            {
                position = null;
                return false;
            }

            int w1 = 0;
            int w2 = 0;
            int l1 = 0;
            int l2 = 0;

            int.TryParse(wBit.Split(',')[0], out w1);
            int.TryParse(wBit.Split(',')[1], out w2);
            int.TryParse(lBit.Split(',')[0], out l1);
            int.TryParse(lBit.Split(',')[1], out l2);
            //
            //if (!Habbo.HasFuse("super_admin") && (w1 < 0 || w2 < 0 || l1 < 0 || l2 < 0 || w1 > 200 || w2 > 200 || l1 > 200 || l2 > 200))
            //{
            //    position = null;
            //    return false;
            //}



            string WallPos = ":w=" + w1 + "," + w2 + " l=" + l1 + "," + l2 + " " + data[2];

            position = WallPositionCheck(WallPos);

            return (position != null);
        }
Esempio n. 19
0
 public List<string> GetCommandsForPlayer(Habbo Player)
 {
     return this._commands.Where(x => Player.Rank >= x.Value.GroupId && Player.VIPRank >= x.Value.SubscriptionId).Select(x => x.Key).ToList();
 }
Esempio n. 20
0
        public static List<Item> CreateTeleporterItems(ItemData Data, Habbo Habbo, int GroupId = 0)
        {
            List<Item> Items = new List<Item>();

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO `items` (base_item,user_id,room_id,x,y,z,wall_pos,rot,extra_data) VALUES(@did,@uid,@rid,@x,@y,@z,@wallpos,@rot,@flags);");
                dbClient.AddParameter("did", Data.Id);
                dbClient.AddParameter("uid", Habbo.Id);
                dbClient.AddParameter("rid", 0);
                dbClient.AddParameter("x", 0);
                dbClient.AddParameter("y", 0);
                dbClient.AddParameter("z", 0);
                dbClient.AddParameter("wallpos", "");
                dbClient.AddParameter("rot", 0);
                dbClient.AddParameter("flags", "");

                int Item1Id = Convert.ToInt32(dbClient.InsertQuery());

                dbClient.SetQuery("INSERT INTO `items` (base_item,user_id,room_id,x,y,z,wall_pos,rot,extra_data) VALUES(@did,@uid,@rid,@x,@y,@z,@wallpos,@rot,@flags);");
                dbClient.AddParameter("did", Data.Id);
                dbClient.AddParameter("uid", Habbo.Id);
                dbClient.AddParameter("rid", 0);
                dbClient.AddParameter("x", 0);
                dbClient.AddParameter("y", 0);
                dbClient.AddParameter("z", 0);
                dbClient.AddParameter("wallpos", "");
                dbClient.AddParameter("rot", 0);
                dbClient.AddParameter("flags", Item1Id.ToString());

                int Item2Id = Convert.ToInt32(dbClient.InsertQuery());

                Item Item1 = new Item(Item1Id, 0, Data.Id, "", 0, 0, 0, 0, Habbo.Id, GroupId, 0, 0, "");
                Item Item2 = new Item(Item2Id, 0, Data.Id, "", 0, 0, 0, 0, Habbo.Id, GroupId, 0, 0, "");

                dbClient.SetQuery("INSERT INTO `room_items_tele_links` (`tele_one_id`, `tele_two_id`) VALUES (" + Item1Id + ", " + Item2Id + "), (" + Item2Id + ", " + Item1Id + ")");
                dbClient.RunQuery();

                Items.Add(Item1);
                Items.Add(Item2);
            }
            return Items;
        }
Esempio n. 21
0
        public bool TryCreateGroup(Habbo Player, string Name, string Description, int RoomId, string Badge, int Colour1, int Colour2, out Group Group)
        {
            Group = new Group(0, Name, Description, Badge, RoomId, Player.Id, (int)PlusEnvironment.GetUnixTimestamp(), 0, Colour1, Colour2, 0);
            if (string.IsNullOrWhiteSpace(Name) || string.IsNullOrWhiteSpace(Badge))
                return false;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO `groups` (`name`, `desc`, `badge`, `owner_id`, `created`, `room_id`, `state`, `colour1`, `colour2`, `admindeco`) VALUES (@name, @desc, @badge, @owner, UNIX_TIMESTAMP(), @room, '0', @colour1, @colour2, '0')");
                dbClient.AddParameter("name", Group.Name);
                dbClient.AddParameter("desc", Group.Description);
                dbClient.AddParameter("owner", Group.CreatorId);
                dbClient.AddParameter("badge", Group.Badge);
                dbClient.AddParameter("room", Group.RoomId);
                dbClient.AddParameter("colour1", Group.Colour1);
                dbClient.AddParameter("colour2", Group.Colour2);
                Group.Id = Convert.ToInt32(dbClient.InsertQuery());

                Group.AddMember(Player.Id);
                Group.MakeAdmin(Player.Id);

                if (!this._groups.TryAdd(Group.Id, Group))
                    return false;
                else
                {
                    dbClient.SetQuery("UPDATE `rooms` SET `group_id` = @gid WHERE `id` = @rid LIMIT 1");
                    dbClient.AddParameter("gid", Group.Id);
                    dbClient.AddParameter("rid", Group.RoomId);
                    dbClient.RunQuery();

                    dbClient.RunQuery("DELETE FROM `room_rights` WHERE `room_id` = '" + RoomId + "'");
                }
            }
            return true;
        }
Esempio n. 22
0
 public static bool RemoveFromCache(int Id, out Habbo Data)
 {
     return _usersCached.TryRemove(Id, out Data);
 }
Esempio n. 23
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 (PlusEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (PlusEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            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();
                            return false;
                        }
                    }
                }
                #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));
                    //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.Rank));
                    SendMessage(new AvailabilityStatusComposer());
                    //1044
                    SendMessage(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));
                    //3674
                    //3437
                    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"]));

                    PlusEnvironment.GetGame().GetRewardManager().CheckRewards(this);
                    return true;
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Bug during user login: " + e);
            }
            return false;
        }
Esempio n. 24
0
        public void Dispose()
        {
            if (GetHabbo() != null)
                GetHabbo().OnDisconnect();

            this.MachineId = string.Empty;
            this._disconnected = true;
            this._habbo = null;
            this._connection = null;
            this.RC4Client = null;
            this._packetParser = null;
        }