Esempio n. 1
0
        //internal Role GetRole(UInt32 Id)
        //{
        //    if (!ContainsRole(Id))
        //    {
        //        return null;
        //    }
        //    return Roles[Id];
        //}
        internal List<string> GetRightsForHabbo(Habbo Habbo)
        {
            List<string> UserRights = new List<string>();

            if (Habbo == null)
                return UserRights;

            UserRights.AddRange(GetRightsForRank(Habbo.Rank));

            foreach (string SubscriptionId in Habbo.GetSubscriptionManager().SubList)
            {
                UserRights.AddRange(GetRightsForSub(SubscriptionId));
            }

            return UserRights;
        }
Esempio n. 2
0
 public UserData(uint userID, Dictionary<string, UserAchievement> achievements, List<uint> favouritedRooms, List<uint> ignores, List<string> tags, 
     Dictionary<string, Subscription> subscriptions, List<Badge> badges, List<UserItem> inventory, List<AvatarEffect> effects,
     Dictionary<uint, MessengerBuddy> friends, Dictionary<uint, MessengerRequest> requests, List<RoomData> rooms, Dictionary<uint, Pet> pets, Dictionary<uint, int> quests, Hashtable inventorySongs, Habbo user)
 {
     this.userID = userID;
     this.achievements = achievements;
     this.favouritedRooms = favouritedRooms;
     this.ignores = ignores;
     this.tags = tags;
     this.subscriptions = subscriptions;
     this.badges = badges;
     this.inventory = inventory;
     this.effects = effects;
     this.friends = friends;
     this.requests = requests;
     this.rooms = rooms;
     this.pets = pets;
     this.quests = quests;
     this.inventorySongs = inventorySongs;
     this.user = user;
 }
Esempio n. 3
0
        internal bool tryLogin(string AuthTicket)
        {
            try
            {
                string ip = GetConnection().getIp();
                byte errorCode = 0;
                UserData userData = UserDataFactory.GetUserData(AuthTicket, ip, out errorCode);
                if (errorCode == 1)
                {
                    SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso"));
                    return false;
                }
                else if (errorCode == 2)
                {
                    SendNotifWithScroll(LanguageLocale.GetValue("login.loggedin"));
                    return false;
                }

                if (Program.LicHandeler != null && ButterflyEnvironment.GetGame().GetClientManager().ClientCount > Program.LicHandeler.AmountOfSlots)
                {
                    Program.LicHandeler.ReportFullServer();
                    SendBanMessage(LanguageLocale.GetValue("server.full"));
                    return false;
                }
                ButterflyEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                this.Habbo = userData.user;
                userData.user.LoadData(userData);

                if (userData.user.Username == null)
                {
                    SendBanMessage("You have no username.");
                    return false;
                }
                string banReason = ButterflyEnvironment.GetGame().GetBanManager().GetBanReason(userData.user.Username, ip);
                if (!string.IsNullOrEmpty(banReason))
                {
                    SendBanMessage(banReason);
                    return false;
                }

                userData.user.Init(this, userData);

                QueuedServerMessage response = new QueuedServerMessage(Connection);

                userData.user.SerializeQuests(ref response);

                List<string> Rights = ButterflyEnvironment.GetGame().GetRoleManager().GetRightsForHabbo(userData.user);

                ServerMessage appendingResponse = new ServerMessage(2);
                appendingResponse.Init(2);
                appendingResponse.AppendInt32(Rights.Count);

                foreach (string Right in Rights)
                {
                    appendingResponse.AppendStringWithBreak(Right);
                }

                response.appendResponse(appendingResponse);

                if (userData.user.HasFuse("fuse_mod"))
                {
                    response.appendResponse(ButterflyEnvironment.GetGame().GetModerationTool().SerializeTool());
                    ButterflyEnvironment.GetGame().GetModerationTool().SerializeOpenTickets(ref response, userData.userID);
                }

                response.appendResponse(userData.user.GetAvatarEffectsInventoryComponent().Serialize());

                appendingResponse.Init(290);
                appendingResponse.AppendBoolean(true);
                appendingResponse.AppendBoolean(false);
                response.appendResponse(appendingResponse);

                appendingResponse.Init(3);
                response.appendResponse(appendingResponse);

                appendingResponse.Init(517);
                appendingResponse.AppendBoolean(true);
                response.appendResponse(appendingResponse);

                //if (PixelManager.NeedsUpdate(this))
                //    PixelManager.GivePixels(this);

                if (ButterflyEnvironment.GetGame().GetClientManager().pixelsOnLogin > 0)
                {
                    PixelManager.GivePixels(this, ButterflyEnvironment.GetGame().GetClientManager().pixelsOnLogin);
                }

                if (ButterflyEnvironment.GetGame().GetClientManager().creditsOnLogin > 0)
                {
                    userData.user.Credits += ButterflyEnvironment.GetGame().GetClientManager().creditsOnLogin;
                    userData.user.UpdateCreditsBalance();
                }

                if (userData.user.HomeRoom > 0)
                {
                    appendingResponse.Init(455);
                    appendingResponse.AppendUInt(userData.user.HomeRoom);
                    response.appendResponse(appendingResponse);
                }

                appendingResponse.Init(458);
                appendingResponse.AppendInt32(30);
                appendingResponse.AppendInt32(userData.user.FavoriteRooms.Count);

                foreach (uint Id in userData.user.FavoriteRooms.ToArray())
                {
                    appendingResponse.AppendUInt(Id);
                }

                response.appendResponse(appendingResponse);

                if (userData.user.HasFuse("fuse_use_club_badge") && !userData.user.GetBadgeComponent().HasBadge("ACH_BasicClub1"))
                {
                    userData.user.GetBadgeComponent().GiveBadge("ACH_BasicClub1", true);
                }
                else if (!userData.user.HasFuse("fuse_use_club_badge") && userData.user.GetBadgeComponent().HasBadge("ACH_BasicClub1"))
                {
                    userData.user.GetBadgeComponent().RemoveBadge("ACH_BasicClub1");
                }

                if (!userData.user.GetBadgeComponent().HasBadge("Z63"))
                    userData.user.GetBadgeComponent().GiveBadge("Z63", true);

                appendingResponse.Init(2);
                appendingResponse.AppendInt32(0);

                if (userData.user.HasFuse("fuse_use_vip_outfits")) // VIP
                    appendingResponse.AppendInt32(2);
                else if (userData.user.HasFuse("fuse_furni_chooser")) // HC
                    appendingResponse.AppendInt32(1);
                else
                    appendingResponse.AppendInt32(0);

                appendingResponse.AppendInt32(0);
                response.appendResponse(appendingResponse);

                appendingResponse.Init(2);
                appendingResponse.AppendInt32(Rights.Count);

                foreach (string Right in Rights)
                {
                    appendingResponse.AppendStringWithBreak(Right);
                }

                response.appendResponse(appendingResponse);

                if (LanguageLocale.welcomeAlertEnabled)
                {
                    ServerMessage alert = new ServerMessage(810);
                    alert.AppendUInt(1);
                    alert.AppendStringWithBreak(LanguageLocale.welcomeAlert);
                    response.appendResponse(alert);
                }

                response.sendResponse();
                Logging.WriteLine("[" + Habbo.Username + "] logged in");

                return true;
            }
            catch (UserDataNotFoundException e)
            {
                SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso") + "extra data: " + e.ToString());
            }
            catch (Exception e)
            {
                //Logging.LogCriticalException("Invalid Dario bug duing user login: "******"Login error: " + e.ToString());
                SendNotifWithScroll("Login error: " + e.ToString());
            }
            return false;
        }
Esempio n. 4
0
        internal void Stop()
        {
            if (GetMessageHandler() != null)
                MessageHandler.Destroy();

            if (GetHabbo() != null)
                Habbo.OnDisconnect();
            CurrentRoomUserID = -1;

            this.MessageHandler = null;
            this.Habbo = null;
            this.Connection = null;
        }
Esempio n. 5
0
 internal void ItemUpdated(Habbo updatable)
 {
     if (updatable.ActiveListenerCount == 0)
         this.loadedHabboData.Remove(updatable.Id);
 }
Esempio n. 6
0
        internal GroupData RegisterGroup(string name, uint ownerid, string description, int roomid, string image, int customcolor1, 
            int customcolor2, int guildbase, int guildbasecolor, string htmlcolor1, string htmlcolor2, List<int> states, Habbo owner, UserGroupManager manager)
        {
            uint groupID;
            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {

                dbClient.setQuery("INSERT INTO groups (name, owner_id, description, room_id, image, custom_color_primary, " + 
                    "custom_color_secondary, base, base_color, html_color_primary, html_color_secondary, date_create) " + 
                    "VALUES (@name, @ownerid, @description, @roomid, @image, @customprimaryhtml, @customsecondaryhtml, " +
                    "@base, @basecolor, @htmlcolorprimary, @htmlcolorsecondary, @created)");
                
                dbClient.addParameter("name", name);
                dbClient.addParameter("description", description);
                dbClient.addParameter("ownerid", owner.Id);
                dbClient.addParameter("roomid", roomid);
                dbClient.addParameter("created", DateTime.Now.ToShortDateString());
                dbClient.addParameter("image", image);
                dbClient.addParameter("customprimaryhtml", customcolor1);
                dbClient.addParameter("customsecondaryhtml", customcolor2);
                dbClient.addParameter("base", guildbase);
                dbClient.addParameter("basecolor", guildbasecolor);
                dbClient.addParameter("htmlcolorprimary", htmlcolor1);
                dbClient.addParameter("htmlcolorsecondary", htmlcolor2);

                groupID = (uint)dbClient.insertQuery();

                dbClient.runFastQuery("UPDATE rooms SET group_id = " + groupID + " WHERE id = " + roomid);
                dbClient.runFastQuery("UPDATE users SET group_favorite = " + groupID + " WHERE id = " + owner.Id);

                foreach (int state in states)
                    dbClient.runFastQuery("INSERT INTO groups_states (group_id, state) VALUES (" + groupID + "," + state + ")");
            }

            owner.EquippedGroup = groupID;
            GroupData group = GetGroup(groupID);
            group.RegisterOwner(owner, manager);

            return group;
        }