Esempio n. 1
0
        internal static Habbo GenerateHabbo(DataRow dRow, DataRow group)
        {
            uint   id                       = Convert.ToUInt32(dRow["id"]);
            string username                 = (string)dRow["username"];
            string realname                 = (string)dRow["real_name"];
            uint   rank                     = Convert.ToUInt32(dRow["rank"]);
            string motto                    = (string)dRow["motto"];
            string look                     = (string)dRow["look"];
            string gender                   = (string)dRow["gender"];
            int    credits                  = (int)dRow["credits"];
            int    activityPoints           = (int)dRow["activity_points"];
            double activityPointsLastUpdate = Convert.ToDouble(dRow["activity_points_lastupdate"]);
            bool   isMuted                  = PiciEnvironment.EnumToBool(dRow["is_muted"].ToString());
            uint   homeRoom                 = Convert.ToUInt32(dRow["home_room"]);
            int    respect                  = (Int32)dRow["respect"];
            int    dailyRespect             = (int)dRow["daily_respect_points"];
            int    dailyPetRespect          = (int)dRow["daily_pet_respect_points"];
            bool   mtantPenalty             = (dRow["mutant_penalty"].ToString() != "0");
            bool   blockFriends             = PiciEnvironment.EnumToBool(dRow["block_newfriends"].ToString());
            uint   questID                  = Convert.ToUInt32(dRow["currentquestid"]);
            int    questProgress            = (int)dRow["currentquestprogress"];
            int    achiecvementPoints       = (int)dRow["achievement_points"];
            int    crystals                 = (int)dRow["crystals"];
            int    newbiestatus             = (int)dRow["newbie_status"];

            return(new Habbo(id, username, realname, rank, motto, look, gender, credits, activityPoints, activityPointsLastUpdate, isMuted, homeRoom, respect, dailyRespect, dailyPetRespect, mtantPenalty, blockFriends, questID, questProgress, group, achiecvementPoints, crystals, newbiestatus));
        }
Esempio n. 2
0
        internal MoodlightData(uint ItemId)
        {
            this.ItemId = ItemId;

            DataRow Row;

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT enabled,current_preset,preset_one,preset_two,preset_three FROM items_moodlight WHERE item_id = " + ItemId);
                Row = dbClient.getRow();
            }

            if (Row == null)
            {
                throw new NullReferenceException("No moodlightdata found in the database");
            }

            this.Enabled       = PiciEnvironment.EnumToBool(Row["enabled"].ToString());
            this.CurrentPreset = (int)Row["current_preset"];
            this.Presets       = new List <MoodlightPreset>();

            this.Presets.Add(GeneratePreset((string)Row["preset_one"]));
            this.Presets.Add(GeneratePreset((string)Row["preset_two"]));
            this.Presets.Add(GeneratePreset((string)Row["preset_three"]));
        }
Esempio n. 3
0
        internal void LoadBots(IQueryAdapter dbClient)
        {
            Bots = new List <RoomBot>();

            dbClient.setQuery("SELECT id, room_id, ai_type, walk_mode, name, motto, look, x, y, z, rotation, min_x, min_y, max_x, max_y FROM bots;");
            DataTable Data = dbClient.getTable();

            dbClient.setQuery("SELECT id, bot_id, keywords, response_text, mode, serve_id FROM bots_responses;");
            DataTable BotResponses = dbClient.getTable();

            dbClient.setQuery("SELECT text, shout, bot_id FROM bots_speech;");
            DataTable BotSpeech = dbClient.getTable();

            List <BotResponse>  Responses = new List <BotResponse>();
            List <RandomSpeech> Speeches  = new List <RandomSpeech>();

            foreach (DataRow Row in BotResponses.Rows)
            {
                Responses.Add(new BotResponse(Convert.ToUInt32(Row["bot_id"]), (string)Row["keywords"], (string)Row["response_text"], Row["mode"].ToString(), (int)Row["serve_id"]));
            }

            foreach (DataRow Row in BotSpeech.Rows)
            {
                Speeches.Add(new RandomSpeech((string)Row["text"], PiciEnvironment.EnumToBool(Row["shout"].ToString()), Convert.ToUInt32(Row["bot_id"])));
            }


            if (Data == null)
            {
                return;
            }

            foreach (DataRow Row in Data.Rows)
            {
                string BotAI = (string)Row["ai_type"];
                AIType BotAIType;
                switch (BotAI)
                {
                case "generic":
                    BotAIType = AIType.Generic;
                    break;

                case "guide":
                    BotAIType = AIType.Guide;
                    break;

                case "pet":
                    BotAIType = AIType.Pet;
                    break;

                default:
                    BotAIType = AIType.Generic;
                    break;
                }

                Bots.Add(new RoomBot(Convert.ToUInt32(Row["id"]), Convert.ToUInt32(Row["room_id"]), BotAIType, (string)Row["walk_mode"],
                                     (String)Row["name"], (string)Row["motto"], (String)Row["look"], (int)Row["x"], (int)Row["y"], (int)Row["z"],
                                     (int)Row["rotation"], (int)Row["min_x"], (int)Row["min_y"], (int)Row["max_x"], (int)Row["max_y"], ref Speeches, ref Responses));
            }
        }
Esempio n. 4
0
        internal static MoodlightPreset GeneratePreset(string Data)
        {
            String[] Bits = Data.Split(',');

            if (!IsValidColor(Bits[0]))
            {
                Bits[0] = "#000000";
            }

            return(new MoodlightPreset(Bits[0], int.Parse(Bits[1]), PiciEnvironment.EnumToBool(Bits[2])));
        }
Esempio n. 5
0
        internal void Initialize(IQueryAdapter dbClient)
        {
            //dbClient.setQuery("SELECT id,caption FROM navigator_pubcats WHERE enabled = 2"); //wtf?
            //DataTable dPubCats = dbClient.getTable();

            dbClient.setQuery("SELECT id,caption,min_rank FROM navigator_flatcats WHERE enabled = 2");
            DataTable dPrivCats = dbClient.getTable();

            dbClient.setQuery("SELECT * FROM navigator_publics ORDER BY ordernum ASC");
            DataTable dPubItems = dbClient.getTable();

            //if (dPubCats != null)
            //{
            //    foreach (DataRow Row in dPubCats.Rows)
            //    {
            //        PublicCategories.Add((int)Row["id"], (string)Row["caption"]);
            //    }
            //}

            if (dPrivCats != null)
            {
                foreach (DataRow Row in dPrivCats.Rows)
                {
                    PrivateCategories.Add((int)Row["id"], new FlatCat((int)Row["id"], (string)Row["caption"], (int)Row["min_rank"]));
                }
            }

            if (dPubItems != null)
            {
                foreach (DataRow Row in dPubItems.Rows)
                {
                    PublicItems.Add((int)Row["id"], new PublicItem((int)Row["id"], int.Parse(Row["bannertype"].ToString()), (string)Row["caption"],
                                                                   (string)Row["image"], ((Row["image_type"].ToString().ToLower() == "internal") ? PublicImageType.INTERNAL : PublicImageType.EXTERNAL),
                                                                   Convert.ToUInt32(Row["room_id"]), (int)Row["category_parent_id"], PiciEnvironment.EnumToBool(Row["category"].ToString()), PiciEnvironment.EnumToBool(Row["recommended"].ToString())));
                }
            }

            //if (dPubRecommended != null)
            //{
            //    foreach (DataRow Row in dPubRecommended.Rows)
            //    {
            //        PublicRecommended.Add((int)Row["id"], new PublicItem((int)Row["id"], int.Parse(Row["bannertype"].ToString()), (string)Row["caption"],
            //            (string)Row["image"], ((Row["image_type"].ToString().ToLower() == "internal") ? PublicImageType.INTERNAL : PublicImageType.EXTERNAL),
            //            (uint)Row["room_id"], (int)Row["category_parent_id"], false));
            //    }
            //}
        }
Esempio n. 6
0
        internal static UserData GetUserData(string sessionTicket, string ip, out byte errorCode)
        {
            DataRow dUserInfo;

            DataTable dAchievements;
            DataTable dFavouriteRooms;
            DataTable dIgnores;
            DataTable dTags;
            DataTable dSubscriptions;
            DataTable dBadges;
            DataTable dInventory;
            DataTable dEffects;
            DataTable dFriends;
            DataTable dRequests;
            DataTable dRooms;
            DataTable dPets;
            DataTable dQuests;
            //DataTable dSongs;
            DataRow dGroups = null;

            UInt32 userID;

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (PiciEnvironment.useSSO)
                {
                    dbClient.setQuery("SELECT * FROM users WHERE auth_ticket = @sso " +
                                      "AND ip_last = @ipaddress ");
                }
                else
                {
                    dbClient.setQuery("SELECT * FROM users WHERE auth_ticket = @sso " +
                                      "AND ip_last = @ipaddress ");
                }

                dbClient.addParameter("sso", sessionTicket);
                dbClient.addParameter("ipaddress", ip);
                dUserInfo = dbClient.getRow();


                if (dUserInfo == null)
                {
                    errorCode = 1;
                    return(null);
                    //Logging.LogException("No user found. Debug data: [" + sessionTicket + "], [" + ip + "]");
                    //thRow new UserDataNotFoundException(string.Format("No user found with ip {0} and sso {1}. Use SSO: {2} ", ip, sessionTicket, PiciEnvironment.useSSO.ToString()));
                }


                userID = Convert.ToUInt32(dUserInfo["id"]);
                if (PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(userID) != null)
                {
                    errorCode = 2;
                    return(null);
                }

                string creditsTimestamp = (string)dUserInfo["lastdailycredits"];
                string todayTimestamp   = DateTime.Today.ToString("MM/dd");
                if (creditsTimestamp != todayTimestamp)
                {
                    dbClient.runFastQuery("UPDATE users SET credits = credits + 3000, daily_respect_points = 3, lastdailycredits = '" + todayTimestamp + "' WHERE id = " + userID);
                    dUserInfo["credits"] = (int)dUserInfo["credits"] + 3000;
                }

                dbClient.setQuery("SELECT * FROM user_achievement WHERE userid = " + userID);
                dAchievements = dbClient.getTable();

                dbClient.setQuery("SELECT room_id FROM user_favorites WHERE user_id = " + userID);
                dFavouriteRooms = dbClient.getTable();

                dbClient.setQuery("SELECT ignore_id FROM user_ignores WHERE user_id = " + userID);
                dIgnores = dbClient.getTable();

                dbClient.setQuery("SELECT tag FROM user_tags WHERE user_id = " + userID);
                dTags = dbClient.getTable();

                dbClient.setQuery("SELECT * FROM user_subscriptions WHERE user_id = " + userID);
                dSubscriptions = dbClient.getTable();

                dbClient.setQuery("SELECT * FROM user_badges WHERE user_id = " + userID);
                dBadges = dbClient.getTable();

                if (dbClient.dbType == Pici.Storage.Database.DatabaseType.MySQL)
                {
                    dbClient.setQuery("CALL getuseritems(" + userID + ")");
                }
                else
                {
                    dbClient.setQuery("EXECUTE getuseritems " + userID + "");
                }
                dInventory = dbClient.getTable();

                dbClient.setQuery("SELECT * FROM user_effects WHERE user_id =  " + userID);
                dEffects = dbClient.getTable();

                dbClient.setQuery("SELECT users.id,users.username,users.motto,users.look,users.last_online " +
                                  "FROM users " +
                                  "JOIN messenger_friendships " +
                                  "ON users.id = messenger_friendships.sender " +
                                  "WHERE messenger_friendships.receiver = " + userID + " " +
                                  "UNION ALL " +
                                  "SELECT users.id,users.username,users.motto,users.look,users.last_online " +
                                  "FROM users " +
                                  "JOIN messenger_friendships " +
                                  "ON users.id = messenger_friendships.receiver " +
                                  "WHERE messenger_friendships.sender = " + userID);
                dFriends = dbClient.getTable();

                dbClient.setQuery("SELECT messenger_requests.sender,messenger_requests.receiver,users.username " +
                                  "FROM users " +
                                  "JOIN messenger_requests " +
                                  "ON users.id = messenger_requests.sender " +
                                  "WHERE messenger_requests.receiver = " + userID);
                dRequests = dbClient.getTable();

                dbClient.setQuery("SELECT rooms.*, room_active.active_users FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) WHERE owner = @name");
                dbClient.addParameter("name", (string)dUserInfo["username"]);
                dRooms = dbClient.getTable();

                dbClient.setQuery("SELECT * FROM user_pets WHERE user_id = " + userID + " AND room_id = 0");
                dPets = dbClient.getTable();

                dbClient.setQuery("SELECT * FROM user_quests WHERE user_id = " + userID + "");
                dQuests = dbClient.getTable();

                if (PiciEnvironment.groupsEnabled)
                {
                    dbClient.setQuery("SELECT groups_memberships.*, groups_details.* FROM groups_memberships " +
                                      "LEFT JOIN groups_details " +
                                      "ON groups_memberships.groupid = groups_details.id " +
                                      "WHERE groups_memberships.userid = " + userID + " AND groups_memberships.is_current = '1'");

                    dGroups = dbClient.getRow();
                }

                //dbClient.setQuery("SELECT item_id, song_id FROM user_items_songs WHERE user_id = " + userID);
                //dSongs = dbClient.getTable();


                /* dbClient.setQuery("UPDATE users SET ip_last = @ip WHERE id = " + userID + " LIMIT 1; " +
                 *                     "UPDATE user_info SET login_timestamp = '" + PiciEnvironment.GetUnixTimestamp() + "' WHERE user_id = " + userID + " LIMIT 1; " +
                 *                     "REPLACE INTO user_online VALUES (" + userID + "); " +
                 *                     "DELETE FROM user_tickets WHERE userid = " + userID + ";");*/

                dbClient.setQuery("UPDATE users SET ip_last = @ip WHERE id = " + userID + "; " +
                                  "UPDATE user_info SET login_timestamp = '" + PiciEnvironment.GetUnixTimestamp() + "' WHERE user_id = " + userID + " ; " +
                                  "");
                dbClient.addParameter("ip", ip);
                dbClient.runQuery();

                if (dbClient.dbType == Pici.Storage.Database.DatabaseType.MySQL)
                {
                    dbClient.runFastQuery("REPLACE INTO user_online VALUES (" + userID + ")");
                }
                else
                {
                    dbClient.runFastQuery("IF NOT EXISTS (SELECT userid FROM user_online WHERE userid = " + userID + ") " +
                                          "INSERT INTO user_online VALUES (" + userID + ")");
                }
            }

            Dictionary <string, UserAchievement> achievements = new Dictionary <string, UserAchievement>();

            string achievementGroup;
            int    achievementLevel;
            int    achievementProgress;

            foreach (DataRow dRow in dAchievements.Rows)
            {
                achievementGroup    = (string)dRow["group"];
                achievementLevel    = (int)dRow["level"];
                achievementProgress = (int)dRow["progress"];

                UserAchievement achievement = new UserAchievement(achievementGroup, achievementLevel, achievementProgress);
                achievements.Add(achievementGroup, achievement);
            }

            List <uint> favouritedRooms = new List <uint>();

            uint favoritedRoomID;

            foreach (DataRow dRow in dFavouriteRooms.Rows)
            {
                favoritedRoomID = Convert.ToUInt32(dRow["room_id"]);
                favouritedRooms.Add(favoritedRoomID);
            }


            List <uint> ignores = new List <uint>();

            uint ignoredUserID;

            foreach (DataRow dRow in dIgnores.Rows)
            {
                ignoredUserID = Convert.ToUInt32(dRow["ignore_id"]);
                ignores.Add(ignoredUserID);
            }


            List <string> tags = new List <string>();

            string tag;

            foreach (DataRow dRow in dTags.Rows)
            {
                tag = (string)dRow["tag"];
                tags.Add(tag);
            }

            Dictionary <string, Subscription> subscriptions = new Dictionary <string, Subscription>();

            string subscriptionID;
            int    expireTimestamp;

            foreach (DataRow dRow in dSubscriptions.Rows)
            {
                subscriptionID  = (string)dRow["subscription_id"];
                expireTimestamp = (int)dRow["timestamp_expire"];

                subscriptions.Add(subscriptionID, new Subscription(subscriptionID, expireTimestamp));
            }

            List <Badge> badges = new List <Badge>();

            string badgeID;
            int    slotID;

            foreach (DataRow dRow in dBadges.Rows)
            {
                badgeID = (string)dRow["badge_id"];
                slotID  = (int)dRow["badge_slot"];
                badges.Add(new Badge(badgeID, slotID));
            }


            List <UserItem> inventory = new List <UserItem>();

            uint   itemID;
            uint   baseItem;
            string extraData;

            foreach (DataRow dRow in dInventory.Rows)
            {
                itemID   = Convert.ToUInt32(dRow[0]);
                baseItem = Convert.ToUInt32(dRow[1]);
                if (!DBNull.Value.Equals(dRow[2]))
                {
                    extraData = (string)dRow[2];
                }
                else
                {
                    extraData = string.Empty;
                }

                inventory.Add(new UserItem(itemID, baseItem, extraData));
            }


            List <AvatarEffect> effects = new List <AvatarEffect>();

            int    effectID;
            int    duration;
            bool   isActivated;
            double activatedTimeStamp;

            foreach (DataRow dRow in dEffects.Rows)
            {
                effectID           = (int)dRow["effect_id"];
                duration           = (int)dRow["total_duration"];
                isActivated        = PiciEnvironment.EnumToBool((string)dRow["is_activated"]);
                activatedTimeStamp = (double)dRow["activated_stamp"];

                effects.Add(new AvatarEffect(effectID, duration, isActivated, activatedTimeStamp));
            }


            Dictionary <uint, MessengerBuddy> friends = new Dictionary <uint, MessengerBuddy>();

            string username = (string)dUserInfo["username"];

            UInt32 friendID;
            string friendName;
            string friendLook;
            string friendMotto;
            string friendLastOnline;

            foreach (DataRow dRow in dFriends.Rows)
            {
                friendID         = Convert.ToUInt32(dRow["id"]);
                friendName       = (string)dRow["username"];
                friendLook       = (string)dRow["look"];
                friendMotto      = (string)dRow["motto"];
                friendLastOnline = (string)dRow["last_online"];


                if (friendID == userID)
                {
                    continue;
                }


                if (!friends.ContainsKey(friendID))
                {
                    friends.Add(friendID, new MessengerBuddy(friendID, friendName, friendLook, friendMotto, friendLastOnline));
                }
            }

            Dictionary <uint, MessengerRequest> requests = new Dictionary <uint, MessengerRequest>();

            uint   receiverID;
            uint   senderID;
            string requestUsername;

            foreach (DataRow dRow in dRequests.Rows)
            {
                receiverID = Convert.ToUInt32(dRow["sender"]);
                senderID   = Convert.ToUInt32(dRow["receiver"]);

                requestUsername = (string)dRow["username"];

                if (receiverID != userID)
                {
                    if (!requests.ContainsKey(receiverID))
                    {
                        requests.Add(receiverID, new MessengerRequest(userID, receiverID, requestUsername));
                    }
                }
                else
                {
                    if (!requests.ContainsKey(senderID))
                    {
                        requests.Add(senderID, new MessengerRequest(userID, senderID, requestUsername));
                    }
                }
            }

            List <RoomData> rooms = new List <RoomData>();

            uint roomID;

            foreach (DataRow dRow in dRooms.Rows)
            {
                roomID = Convert.ToUInt32(dRow["id"]);
                rooms.Add(PiciEnvironment.GetGame().GetRoomManager().FetchRoomData(roomID, dRow));
            }


            Dictionary <uint, Pet> pets = new Dictionary <uint, Pet>();

            Pet pet;

            foreach (DataRow dRow in dPets.Rows)
            {
                pet = Catalog.GeneratePetFromRow(dRow);
                pets.Add(pet.PetId, pet);
            }



            Dictionary <uint, int> quests = new Dictionary <uint, int>();

            uint questId;
            int  progress;

            foreach (DataRow dRow in dQuests.Rows)
            {
                questId  = Convert.ToUInt32(dRow["quest_id"]);
                progress = (int)dRow["progress"];
                quests.Add(questId, progress);
            }

            Hashtable songs = new Hashtable();

            //uint songItemID;
            //uint songID;
            //foreach (DataRow dRow in dSongs.Rows)
            //{
            //    songItemID = (uint)dRow[0];
            //    songID = (uint)dRow[1];

            //    SongItem song = new SongItem(songItemID, songID);
            //    songs.Add(songItemID, song);
            //}

            Habbo user = HabboFactory.GenerateHabbo(dUserInfo, dGroups);

            dUserInfo       = null;
            dAchievements   = null;
            dFavouriteRooms = null;
            dIgnores        = null;
            dTags           = null;
            dSubscriptions  = null;
            dBadges         = null;
            dInventory      = null;
            dEffects        = null;
            dFriends        = null;
            dRequests       = null;
            dRooms          = null;
            dPets           = null;

            errorCode = 0;
            return(new UserData(userID, achievements, favouritedRooms, ignores, tags, subscriptions, badges, inventory, effects, friends, requests, rooms, pets, quests, songs, user));
        }
Esempio n. 7
0
        internal void DeadFill(DataRow Row)
        {
            this.Id          = Convert.ToUInt32(Row["id"]);
            this.Name        = (string)Row["caption"];
            this.Description = (string)Row["description"];
            this.Type        = (string)Row["roomtype"];
            this.Owner       = (string)Row["owner"];

            switch (Row["state"].ToString().ToLower())
            {
            case "open":

                this.State = 0;
                break;

            case "password":

                this.State = 2;
                break;

            case "locked":
            default:

                this.State = 1;
                break;
            }

            this.Category = (int)Row["category"];

            if (!string.IsNullOrEmpty(Row["active_users"].ToString()))
            {
                this.UsersNow = (int)Row["active_users"];
            }
            else
            {
                this.UsersNow = 0;
            }
            this.UsersMax            = (int)Row["users_max"];
            this.ModelName           = (string)Row["model_name"];
            this.CCTs                = (string)Row["public_ccts"];
            this.Score               = (int)Row["score"];
            this.Tags                = new List <string>();
            this.AllowPets           = PiciEnvironment.EnumToBool(Row["allow_pets"].ToString());
            this.AllowPetsEating     = PiciEnvironment.EnumToBool(Row["allow_pets_eat"].ToString());
            this.AllowWalkthrough    = PiciEnvironment.EnumToBool(Row["allow_walkthrough"].ToString());
            this.AllowRightsOverride = PiciEnvironment.EnumToBool(Row["allow_rightsoverride"].ToString());
            this.Hidewall            = PiciEnvironment.EnumToBool(Row["allow_hidewall"].ToString());
            this.Password            = (string)Row["password"];
            this.Wallpaper           = (string)Row["wallpaper"];
            this.Floor               = (string)Row["floor"];
            this.Landscape           = (string)Row["landscape"];
            this.Landscape           = (string)Row["landscape"];
            this.FloorThickness      = (int)Row["floorthickness"];
            //this.Event = null;

            Dictionary <int, int> IconItems = new Dictionary <int, int>();

            if (!string.IsNullOrEmpty(Row["icon_items"].ToString()))
            {
                foreach (string Bit in Row["icon_items"].ToString().Split('|'))
                {
                    if (string.IsNullOrEmpty(Bit))
                    {
                        continue;
                    }

                    string[] tBit = Bit.Replace('.', ',').Split(',');

                    int a = 0;
                    int b = 0;


                    if (tBit.Length > 1)
                    {
                        int.TryParse(tBit[1], out b);
                    }
                    else
                    {
                        int.TryParse(tBit[0], out a);
                    }

                    try
                    {
                        if (!IconItems.ContainsKey(a))
                        {
                            IconItems.Add(a, b);
                        }
                    }
                    catch (Exception e)
                    {
                        Logging.LogException("Exception: " + e.ToString() + "[" + Bit + "]");
                    }
                }
            }

            this.myIcon = new RoomIcon((int)Row["icon_bg"], (int)Row["icon_fg"], IconItems);

            foreach (string Tag in Row["tags"].ToString().Split(','))
            {
                this.Tags.Add(Tag);
            }
        }
Esempio n. 8
0
        internal bool RequestBuddy(string UserQuery)
        {
            uint userID;
            bool hasFQDisabled;

            GameClient client = PiciEnvironment.GetGame().GetClientManager().GetClientByUsername(UserQuery);

            if (client == null)
            {
                DataRow Row = null;
                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT id,block_newfriends FROM users WHERE username = @query");
                    dbClient.addParameter("query", UserQuery.ToLower());
                    Row = dbClient.getRow();
                }

                if (Row == null)
                {
                    return(false);
                }

                userID        = Convert.ToUInt32(Row["id"]);
                hasFQDisabled = PiciEnvironment.EnumToBool(Row["block_newfriends"].ToString());
            }
            else
            {
                userID        = client.GetHabbo().Id;
                hasFQDisabled = client.GetHabbo().HasFriendRequestsDisabled;
            }

            if (hasFQDisabled)
            {
                GetClient().GetMessageHandler().GetResponse().Init(260);
                GetClient().GetMessageHandler().GetResponse().AppendInt32(39);
                GetClient().GetMessageHandler().GetResponse().AppendInt32(3);
                GetClient().GetMessageHandler().SendResponse();
                return(true);
            }

            uint ToId = userID;

            if (RequestExists(ToId))
            {
                return(true);
            }

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == DatabaseType.MSSQL)
                {
                    dbClient.runFastQuery("DELETE FROM messenger_requests WHERE sender = " + userID + " AND receiver = " + ToId);
                    dbClient.runFastQuery("INSERT INTO messenger_requests (sender,receiver) VALUES (" + this.UserId + "," + ToId + ")");
                }
                else
                {
                    dbClient.runFastQuery("REPLACE INTO messenger_requests (sender,receiver) VALUES (" + this.UserId + "," + ToId + ")");
                }
            }

            GameClient ToUser = PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(ToId);

            if (ToUser == null || ToUser.GetHabbo() == null)
            {
                return(true);
            }

            MessengerRequest Request = new MessengerRequest(ToId, UserId, PiciEnvironment.GetGame().GetClientManager().GetNameById(UserId));

            ToUser.GetHabbo().GetMessenger().OnNewRequest(UserId);

            ServerMessage NewFriendNotif = new ServerMessage(132);

            Request.Serialize(NewFriendNotif);
            ToUser.SendMessage(NewFriendNotif);
            requests.Add(ToId, Request);
            return(true);
        }
Esempio n. 9
0
        //internal RoleManager()
        //{
        //Roles = new Dictionary<uint,Role>();
        //Rights = new Dictionary<string, uint>();
        //SubRights = new Dictionary<string, string>();
        //}

        //internal void LoadRoles(DatabaseClient dbClient)
        //{
        //    ClearRoles();

        //    DataTable Data = dbClient.getTable("SELECT * FROM ranks ORDER BY id ASC;");

        //    if (Data != null)
        //    {
        //        foreach (DataRow Row in Data.Rows)
        //        {
        //            Roles.Add((uint)pur["id"], new Role((uint)pur["id"], (string)pur["name"]));
        //        }
        //    }
        //}

        internal void LoadRights(IQueryAdapter dbClient)
        {
            ClearRights();

            /*            DataTable table = class1_0.method_3("SELECT * FROM ranks ORDER BY id ASC;");
             * if (table != null)
             * {
             *  foreach (DataRow row in table.Rows)
             *  {
             *      this.dictionary_2.Add((uint) pur["id"], pur["badgeid"].ToString());
             *  }
             * }*/
            List <string> list;

            dbClient.setQuery("SELECT * FROM ranks ORDER BY id ASC;");
            DataTable Ranks = dbClient.getTable();

            if (Ranks != null)
            {
                foreach (DataRow RankRow in Ranks.Rows)
                {
                    this.Ranks.Add((uint)RankRow["id"], RankRow["badgeid"].ToString());
                }
            }

            dbClient.setQuery("SELECT * FROM permissions_users ORDER BY userid ASC;");
            DataTable PermissionsUsers = dbClient.getTable();

            foreach (DataRow pur in PermissionsUsers.Rows)
            {
                list = new List <string>();

                if (PiciEnvironment.EnumToBool(pur["cmd_update_settings"].ToString()))
                {
                    list.Add("cmd_update_settings");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_update_bans"].ToString()))
                {
                    list.Add("cmd_update_bans");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_update_bots"].ToString()))
                {
                    list.Add("cmd_update_bots");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_update_catalogue"].ToString()))
                {
                    list.Add("cmd_update_catalogue");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_update_navigator"].ToString()))
                {
                    list.Add("cmd_update_navigator");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_update_items"].ToString()))
                {
                    list.Add("cmd_update_items");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_award"].ToString()))
                {
                    list.Add("cmd_award");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_coords"].ToString()))
                {
                    list.Add("cmd_coords");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_override"].ToString()))
                {
                    list.Add("cmd_override");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_coins"].ToString()))
                {
                    list.Add("cmd_coins");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_pixels"].ToString()))
                {
                    list.Add("cmd_pixels");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_ha"].ToString()))
                {
                    list.Add("cmd_ha");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_hal"].ToString()))
                {
                    list.Add("cmd_hal");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_freeze"].ToString()))
                {
                    list.Add("cmd_freeze");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_enable"].ToString()))
                {
                    list.Add("cmd_enable");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_roommute"].ToString()))
                {
                    list.Add("cmd_roommute");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_setspeed"].ToString()))
                {
                    list.Add("cmd_setspeed");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_masscredits"].ToString()))
                {
                    list.Add("cmd_masscredits");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_globalcredits"].ToString()))
                {
                    list.Add("cmd_globalcredits");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_masspixels"].ToString()))
                {
                    list.Add("cmd_masspixels");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_globalpixels"].ToString()))
                {
                    list.Add("cmd_globalpixels");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_roombadge"].ToString()))
                {
                    list.Add("cmd_roombadge");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_massbadge"].ToString()))
                {
                    list.Add("cmd_massbadge");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_userinfo"].ToString()))
                {
                    list.Add("cmd_userinfo");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_shutdown"].ToString()))
                {
                    list.Add("cmd_shutdown");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_givebadge"].ToString()))
                {
                    list.Add("cmd_givebadge");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_removebadge"].ToString()))
                {
                    list.Add("cmd_removebadge");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_summon"].ToString()))
                {
                    list.Add("cmd_summon");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_invisible"].ToString()))
                {
                    list.Add("cmd_invisible");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_ban"].ToString()))
                {
                    list.Add("cmd_ban");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_superban"].ToString()))
                {
                    list.Add("cmd_superban");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_roomkick"].ToString()))
                {
                    list.Add("cmd_roomkick");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_roomalert"].ToString()))
                {
                    list.Add("cmd_roomalert");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_mute"].ToString()))
                {
                    list.Add("cmd_mute");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_unmute"].ToString()))
                {
                    list.Add("cmd_unmute");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_alert"].ToString()))
                {
                    list.Add("cmd_alert");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_motd"].ToString()))
                {
                    list.Add("cmd_motd");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_kick"].ToString()))
                {
                    list.Add("cmd_kick");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_update_filter"].ToString()))
                {
                    list.Add("cmd_update_filter");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_update_permissions"].ToString()))
                {
                    list.Add("cmd_update_permissions");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_sa"].ToString()))
                {
                    list.Add("cmd_sa");
                }
                if (PiciEnvironment.EnumToBool(pur["receive_sa"].ToString()))
                {
                    list.Add("receive_sa");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_ipban"].ToString()))
                {
                    list.Add("cmd_ipban");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_spull"].ToString()))
                {
                    list.Add("cmd_spull");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_disconnect"].ToString()))
                {
                    list.Add("cmd_disconnect");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_update_achievements"].ToString()))
                {
                    list.Add("cmd_update_achievements");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_update_texts"].ToString()))
                {
                    list.Add("cmd_update_texts");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_teleport"].ToString()))
                {
                    list.Add("cmd_teleport");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_points"].ToString()))
                {
                    list.Add("cmd_points");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_masspoints"].ToString()))
                {
                    list.Add("cmd_masspoints");
                }
                if (PiciEnvironment.EnumToBool(pur["cmd_globalpoints"].ToString()))
                {
                    list.Add("cmd_globalpoints");
                }
                if (PiciEnvironment.EnumToBool(pur["acc_anyroomrights"].ToString()))
                {
                    list.Add("acc_anyroomrights");
                }
                if (PiciEnvironment.EnumToBool(pur["acc_anyroomowner"].ToString()))
                {
                    list.Add("acc_anyroomowner");
                }
                if (PiciEnvironment.EnumToBool(pur["acc_supporttool"].ToString()))
                {
                    list.Add("acc_supporttool");
                }
                if (PiciEnvironment.EnumToBool(pur["acc_chatlogs"].ToString()))
                {
                    list.Add("acc_chatlogs");
                }
                if (PiciEnvironment.EnumToBool(pur["acc_enter_fullrooms"].ToString()))
                {
                    list.Add("acc_enter_fullrooms");
                }
                if (PiciEnvironment.EnumToBool(pur["acc_enter_anyroom"].ToString()))
                {
                    list.Add("acc_enter_anyroom");
                }
                if (PiciEnvironment.EnumToBool(pur["acc_restrictedrooms"].ToString()))
                {
                    list.Add("acc_restrictedrooms");
                }
                if (PiciEnvironment.EnumToBool(pur["acc_unkickable"].ToString()))
                {
                    list.Add("acc_unkickable");
                }
                if (PiciEnvironment.EnumToBool(pur["acc_unbannable"].ToString()))
                {
                    list.Add("acc_unbannable");
                }
                if (PiciEnvironment.EnumToBool(pur["ignore_friendsettings"].ToString()))
                {
                    list.Add("ignore_friendsettings");
                }
                this.PermissionsUsersD.Add((uint)pur["userid"], list);
            }

            dbClient.setQuery("SELECT * FROM permissions_ranks ORDER BY rank ASC;");
            DataTable PermissionsRanks = dbClient.getTable();

            if (PermissionsRanks != null)
            {
                foreach (DataRow pur1 in PermissionsRanks.Rows)
                {
                    this.PermissionsUsersR.Add((uint)pur1["rank"], (int)pur1["floodtime"]);
                }
                foreach (DataRow pur in PermissionsRanks.Rows)
                {
                    list = new List <string>();
                    if (PiciEnvironment.EnumToBool(pur["cmd_update_settings"].ToString()))
                    {
                        list.Add("cmd_update_settings");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_update_bans"].ToString()))
                    {
                        list.Add("cmd_update_bans");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_update_bots"].ToString()))
                    {
                        list.Add("cmd_update_bots");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_update_catalogue"].ToString()))
                    {
                        list.Add("cmd_update_catalogue");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_update_navigator"].ToString()))
                    {
                        list.Add("cmd_update_navigator");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_update_items"].ToString()))
                    {
                        list.Add("cmd_update_items");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_award"].ToString()))
                    {
                        list.Add("cmd_award");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_coords"].ToString()))
                    {
                        list.Add("cmd_coords");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_override"].ToString()))
                    {
                        list.Add("cmd_override");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_coins"].ToString()))
                    {
                        list.Add("cmd_coins");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_pixels"].ToString()))
                    {
                        list.Add("cmd_pixels");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_ha"].ToString()))
                    {
                        list.Add("cmd_ha");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_hal"].ToString()))
                    {
                        list.Add("cmd_hal");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_freeze"].ToString()))
                    {
                        list.Add("cmd_freeze");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_enable"].ToString()))
                    {
                        list.Add("cmd_enable");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_roommute"].ToString()))
                    {
                        list.Add("cmd_roommute");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_setspeed"].ToString()))
                    {
                        list.Add("cmd_setspeed");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_masscredits"].ToString()))
                    {
                        list.Add("cmd_masscredits");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_globalcredits"].ToString()))
                    {
                        list.Add("cmd_globalcredits");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_masspixels"].ToString()))
                    {
                        list.Add("cmd_masspixels");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_globalpixels"].ToString()))
                    {
                        list.Add("cmd_globalpixels");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_roombadge"].ToString()))
                    {
                        list.Add("cmd_roombadge");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_massbadge"].ToString()))
                    {
                        list.Add("cmd_massbadge");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_userinfo"].ToString()))
                    {
                        list.Add("cmd_userinfo");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_shutdown"].ToString()))
                    {
                        list.Add("cmd_shutdown");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_givebadge"].ToString()))
                    {
                        list.Add("cmd_givebadge");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_removebadge"].ToString()))
                    {
                        list.Add("cmd_removebadge");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_summon"].ToString()))
                    {
                        list.Add("cmd_summon");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_invisible"].ToString()))
                    {
                        list.Add("cmd_invisible");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_ban"].ToString()))
                    {
                        list.Add("cmd_ban");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_superban"].ToString()))
                    {
                        list.Add("cmd_superban");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_roomkick"].ToString()))
                    {
                        list.Add("cmd_roomkick");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_roomalert"].ToString()))
                    {
                        list.Add("cmd_roomalert");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_mute"].ToString()))
                    {
                        list.Add("cmd_mute");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_unmute"].ToString()))
                    {
                        list.Add("cmd_unmute");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_alert"].ToString()))
                    {
                        list.Add("cmd_alert");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_motd"].ToString()))
                    {
                        list.Add("cmd_motd");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_kick"].ToString()))
                    {
                        list.Add("cmd_kick");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_update_filter"].ToString()))
                    {
                        list.Add("cmd_update_filter");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_update_permissions"].ToString()))
                    {
                        list.Add("cmd_update_permissions");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_sa"].ToString()))
                    {
                        list.Add("cmd_sa");
                    }
                    if (PiciEnvironment.EnumToBool(pur["receive_sa"].ToString()))
                    {
                        list.Add("receive_sa");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_ipban"].ToString()))
                    {
                        list.Add("cmd_ipban");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_spull"].ToString()))
                    {
                        list.Add("cmd_spull");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_disconnect"].ToString()))
                    {
                        list.Add("cmd_disconnect");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_update_achievements"].ToString()))
                    {
                        list.Add("cmd_update_achievements");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_update_texts"].ToString()))
                    {
                        list.Add("cmd_update_texts");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_teleport"].ToString()))
                    {
                        list.Add("cmd_teleport");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_points"].ToString()))
                    {
                        list.Add("cmd_points");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_masspoints"].ToString()))
                    {
                        list.Add("cmd_masspoints");
                    }
                    if (PiciEnvironment.EnumToBool(pur["cmd_globalpoints"].ToString()))
                    {
                        list.Add("cmd_globalpoints");
                    }
                    if (PiciEnvironment.EnumToBool(pur["acc_anyroomrights"].ToString()))
                    {
                        list.Add("acc_anyroomrights");
                    }
                    if (PiciEnvironment.EnumToBool(pur["acc_anyroomowner"].ToString()))
                    {
                        list.Add("acc_anyroomowner");
                    }
                    if (PiciEnvironment.EnumToBool(pur["acc_supporttool"].ToString()))
                    {
                        list.Add("acc_supporttool");
                    }
                    if (PiciEnvironment.EnumToBool(pur["acc_chatlogs"].ToString()))
                    {
                        list.Add("acc_chatlogs");
                    }
                    if (PiciEnvironment.EnumToBool(pur["acc_enter_fullrooms"].ToString()))
                    {
                        list.Add("acc_enter_fullrooms");
                    }
                    if (PiciEnvironment.EnumToBool(pur["acc_enter_anyroom"].ToString()))
                    {
                        list.Add("acc_enter_anyroom");
                    }
                    if (PiciEnvironment.EnumToBool(pur["acc_restrictedrooms"].ToString()))
                    {
                        list.Add("acc_restrictedrooms");
                    }
                    if (PiciEnvironment.EnumToBool(pur["acc_unkickable"].ToString()))
                    {
                        list.Add("acc_unkickable");
                    }
                    if (PiciEnvironment.EnumToBool(pur["acc_unbannable"].ToString()))
                    {
                        list.Add("acc_unbannable");
                    }
                    if (PiciEnvironment.EnumToBool(pur["ignore_friendsettings"].ToString()))
                    {
                        list.Add("ignore_friendsettings");
                    }

                    this.PermissionsRanksD.Add((uint)pur["rank"], list);
                }


                dbClient.setQuery("SELECT * FROM permissions_vip;");
                DataTable table = dbClient.getTable();
                if (table != null)
                {
                    Class19.Boolean_8  = false;
                    Class19.Boolean_10 = false;
                    Class19.Boolean_11 = false;
                    Class19.Boolean_12 = false;
                    Class19.Boolean_13 = false;
                    Class19.Boolean_9  = false;
                    foreach (DataRow row in table.Rows)
                    {
                        if (PiciEnvironment.EnumToBool(row["cmdPush"].ToString()))
                        {
                            Class19.Boolean_8 = true;
                        }
                        if (PiciEnvironment.EnumToBool(row["cmdPull"].ToString()))
                        {
                            Class19.Boolean_10 = true;
                        }
                        if (PiciEnvironment.EnumToBool(row["cmdFlagme"].ToString()))
                        {
                            Class19.Boolean_11 = true;
                        }
                        if (PiciEnvironment.EnumToBool(row["cmdMimic"].ToString()))
                        {
                            Class19.Boolean_12 = true;
                        }
                        if (PiciEnvironment.EnumToBool(row["cmdMoonwalk"].ToString()))
                        {
                            Class19.Boolean_13 = true;
                        }
                        if (PiciEnvironment.EnumToBool(row["cmdFollow"].ToString()))
                        {
                            Class19.Boolean_9 = true;
                        }
                    }
                }
            }


            /* dbClient.setQuery("SELECT fuse, rank FROM fuserights;");
             * DataTable Data = dbClient.getTable();
             *
             * dbClient.setQuery("SELECT fuse, sub FROM fuserights_subs;");
             * DataTable SubData = dbClient.getTable();
             *
             * if (Data != null)
             * {
             *   foreach (DataRow Row in Data.Rows)
             *   {
             *       Rights.Add((string)pur["fuse"], Convert.ToUInt32(pur["rank"]));
             *   }
             * }
             *
             * if (SubData != null)
             * {
             *   foreach (DataRow Row in SubData.Rows)
             *   {
             *       SubRights.Add((string)pur["fuse"], (string)pur["sub"]);
             *   }
             * }*/
        }