コード例 #1
0
        internal MoodlightData(uint ItemId)
        {
            this.ItemId = ItemId;

            DataRow Row;

            using (IQueryAdapter dbClient = ButterflyEnvironment.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       = ButterflyEnvironment.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"]));
        }
コード例 #2
0
ファイル: BotManager.cs プロジェクト: nightwolf93/Bfly
        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"], ButterflyEnvironment.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));
            }
        }
コード例 #3
0
ファイル: Authenticator.cs プロジェクト: nightwolf93/Bfly
        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                  = ButterflyEnvironment.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             = ButterflyEnvironment.EnumToBool(dRow["block_newfriends"].ToString());
            uint   questID                  = Convert.ToUInt32(dRow["currentquestid"]);
            int    questProgress            = (int)dRow["currentquestprogress"];
            int    achiecvementPoints       = (int)dRow["achievement_points"];

            return(new Habbo(id, username, realname, rank, motto, look, gender, credits, activityPoints, activityPointsLastUpdate, isMuted, homeRoom, respect, dailyRespect, dailyPetRespect, mtantPenalty, blockFriends, questID, questProgress, group, achiecvementPoints));
        }
コード例 #4
0
        public MoodlightData(int ItemId)
        {
            this.ItemId = ItemId;

            DataRow Row = null;

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT enabled,current_preset,preset_one,preset_two,preset_three FROM room_items_moodlight WHERE item_id = '" + ItemId + "' LIMIT 1");
                Row = dbClient.GetRow();
            }

            if (Row == null)
            {
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("INSERT INTO `room_items_moodlight` (item_id,enabled,current_preset,preset_one,preset_two,preset_three) VALUES (" + ItemId + ",0,1,'#000000,255,0','#000000,255,0','#000000,255,0')");
                    dbClient.SetQuery("SELECT enabled,current_preset,preset_one,preset_two,preset_three FROM room_items_moodlight WHERE item_id=" + ItemId + " LIMIT 1");
                    Row = dbClient.GetRow();
                }
            }

            Enabled       = ButterflyEnvironment.EnumToBool(Row["enabled"].ToString());
            CurrentPreset = Convert.ToInt32(Row["current_preset"]);
            Presets       = new List <MoodlightPreset>();

            Presets.Add(GeneratePreset(Convert.ToString(Row["preset_one"])));
            Presets.Add(GeneratePreset(Convert.ToString(Row["preset_two"])));
            Presets.Add(GeneratePreset(Convert.ToString(Row["preset_three"])));
        }
コード例 #5
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]), ButterflyEnvironment.EnumToBool(Bits[2])));
        }
コード例 #6
0
        public void TryAuthenticate(string AuthTicket)
        {
            if (string.IsNullOrEmpty(AuthTicket))
            {
                return;
            }

            string ip = this.GetConnection().getIp();

            using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                queryreactor.SetQuery("SELECT id FROM bans WHERE expire > @nowtime AND (bantype = 'ip' AND value = @IP1) LIMIT 1");
                queryreactor.AddParameter("nowtime", ButterflyEnvironment.GetUnixTimestamp());
                queryreactor.AddParameter("IP1", ip);

                DataRow IsBanned = queryreactor.GetRow();
                if (IsBanned != null)
                {
                    return;
                }

                queryreactor.SetQuery("SELECT user_id, is_staff, langue FROM user_websocket WHERE auth_ticket = @sso");
                queryreactor.AddParameter("sso", AuthTicket);

                DataRow dUserInfo = queryreactor.GetRow();
                if (dUserInfo == null)
                {
                    return;
                }

                this.UserId   = Convert.ToInt32(dUserInfo["user_id"]);
                this._isStaff = ButterflyEnvironment.EnumToBool((string)dUserInfo["is_staff"]);
                this.Langue   = LanguageManager.ParseLanguage(Convert.ToString(dUserInfo["langue"]));
                queryreactor.RunQuery("UPDATE user_websocket SET auth_ticket = '' WHERE user_id = '" + UserId + "'");

                this._sendSettingSound(queryreactor);
            }

            ButterflyEnvironment.GetGame().GetClientWebManager().LogClonesOut(UserId);
            ButterflyEnvironment.GetGame().GetClientWebManager().RegisterClient(this, UserId);

            this.SendPacket(new AuthOkComposer());
            this.SendPacket(new UserIsStaffComposer(this._isStaff));
            //this.SendPacket(new NotifTopInitComposer(ButterflyEnvironment.GetGame().GetNotifTopManager().GetAllMessages()));
        }
コード例 #7
0
ファイル: RoomManager.cs プロジェクト: nightwolf93/Bfly
        internal void LoadModels(IQueryAdapter dbClient)
        {
            roomModels.Clear();

            dbClient.setQuery("SELECT id,door_x,door_y,door_z,door_dir,heightmap,public_items,club_only,poolmap FROM room_models");
            DataTable Data = dbClient.getTable();

            dbClient.setQuery("SELECT model, x, y, rot FROM room_model_static");
            DataTable PublicRoomItems = dbClient.getTable();

            List <PublicRoomSquare> PublicRoomDataSqList = new List <PublicRoomSquare>();

            foreach (DataRow dRow in PublicRoomItems.Rows)
            {
                PublicRoomDataSqList.Add(new PublicRoomSquare(dRow));
            }

            if (Data == null)
            {
                return;
            }

            foreach (DataRow Row in Data.Rows)
            {
                string Modelname       = (string)Row["id"];
                string staticFurniture = (string)Row["public_items"];

                List <PublicRoomSquare> publicFurni = new List <PublicRoomSquare>();
                if (!string.IsNullOrEmpty(staticFurniture))
                {
                    publicFurni.AddRange(from p in PublicRoomDataSqList where p.RoomModelName == Modelname select p);
                }

                roomModels.Add(Modelname, new RoomModel((int)Row["door_x"],
                                                        (int)Row["door_y"], (Double)Row["door_z"], (int)Row["door_dir"], (string)Row["heightmap"],
                                                        staticFurniture, ButterflyEnvironment.EnumToBool(Row["club_only"].ToString()), (string)Row["poolmap"], publicFurni));
            }
        }
コード例 #8
0
        public static Habbo GenerateHabbo(DataRow dRow, DataRow dRow2, bool ChangeName)
        {
            int      Id                        = Convert.ToInt32(dRow["id"]);
            string   Username                  = (string)dRow["username"];
            int      Rank                      = Convert.ToInt32(dRow["rank"]);
            string   Motto                     = (string)dRow["motto"];
            string   Look                      = (string)dRow["look"];
            string   Gender                    = (string)dRow["gender"];
            int      LastOnline                = (int)dRow["last_online"];
            int      Credits                   = (int)dRow["credits"];
            int      Diamonds                  = (int)dRow["vip_points"];
            int      ActivityPoints            = (int)dRow["activity_points"];
            double   LastActivityPointsUpdate  = Convert.ToDouble(dRow["activity_points_lastupdate"]);
            int      HomeRoom                  = Convert.ToInt32(dRow["home_room"]);
            int      Respect                   = (int)dRow2["respect"];
            int      DailyRespectPoints        = (int)dRow2["DailyRespectPoints"];
            int      DailyPetRespectPoints     = (int)dRow2["DailyPetRespectPoints"];
            bool     HasFriendRequestsDisabled = ButterflyEnvironment.EnumToBool(dRow["block_newfriends"].ToString());
            int      currentQuestID            = Convert.ToInt32(dRow2["quest_id"]);
            int      achievementPoints         = (int)dRow2["AchievementScore"];
            int      FavoriteGroup             = (int)dRow2["groupid"];
            int      accountCreated            = (int)dRow["account_created"];
            bool     AcceptTrading             = ButterflyEnvironment.EnumToBool(dRow["accept_trading"].ToString());
            string   Ip                        = dRow["ip_last"].ToString();
            bool     HideInroom                = ButterflyEnvironment.EnumToBool(dRow["hide_inroom"].ToString());
            bool     HideOnline                = ButterflyEnvironment.EnumToBool(dRow["hide_online"].ToString());
            int      MazoHighScore             = Convert.ToInt32(dRow["mazoscore"]);
            int      Mazo                      = Convert.ToInt32(dRow["mazo"]);
            string   clientVolume              = (string)dRow["volume"];
            bool     NuxEnable                 = ButterflyEnvironment.EnumToBool(dRow["nux_enable"].ToString());
            string   MachineId                 = (string)dRow["machine_id"];
            Language Langue                    = LanguageManager.ParseLanguage((string)dRow["langue"]);
            bool     IgnoreAll                 = ButterflyEnvironment.EnumToBool(dRow["ignoreall"].ToString());

            return(new Habbo(Id, Username, Rank, Motto, Look, Gender, Credits, Diamonds, ActivityPoints, LastActivityPointsUpdate, HomeRoom, Respect, DailyRespectPoints, DailyPetRespectPoints, HasFriendRequestsDisabled, currentQuestID, achievementPoints, LastOnline, FavoriteGroup, accountCreated, AcceptTrading, Ip, HideInroom, HideOnline, MazoHighScore, Mazo, clientVolume, NuxEnable, MachineId, ChangeName, Langue, IgnoreAll));
        }
コード例 #9
0
        public void Init()
        {
            this._effects.Clear();
            this._effectsStaff.Clear();

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM systeme_effects ORDER by id ASC");
                DataTable table = dbClient.GetTable();
                if (table == null)
                {
                    return;
                }

                foreach (DataRow dataRow in table.Rows)
                {
                    int  EffectId  = (int)dataRow["id"];
                    bool OnlyStaff = ButterflyEnvironment.EnumToBool((string)dataRow["only_staff"]);

                    if (OnlyStaff)
                    {
                        if (!this._effectsStaff.Contains(EffectId))
                        {
                            this._effectsStaff.Add(EffectId);
                        }
                    }
                    else
                    {
                        if (!this._effects.Contains(EffectId))
                        {
                            this._effects.Add(EffectId);
                        }
                    }
                }
            }
        }
コード例 #10
0
ファイル: CatalogManager.cs プロジェクト: EmuZoneDEV/HBBO-EMU
        public void Init(ItemDataManager ItemDataManager)
        {
            if (this._pages.Count > 0)
            {
                this._pages.Clear();
            }
            if (this._botPresets.Count > 0)
            {
                this._botPresets.Clear();
            }
            if (this._items.Count > 0)
            {
                this._items.Clear();
            }
            if (this._promotions.Count > 0)
            {
                this._promotions.Clear();
            }
            if (this._itemsPage.Count > 0)
            {
                this._itemsPage.Clear();
            }

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `id`,`item_id`,`catalog_name`,`cost_credits`,`cost_pixels`,`cost_diamonds`,`amount`,`page_id`,`limited_sells`,`limited_stack`,`offer_active`,`badge` FROM `catalog_items` ORDER by ID DESC");
                DataTable CatalogueItems = dbClient.GetTable();

                if (CatalogueItems != null)
                {
                    foreach (DataRow Row in CatalogueItems.Rows)
                    {
                        if (Convert.ToInt32(Row["amount"]) <= 0)
                        {
                            continue;
                        }

                        int ItemId = Convert.ToInt32(Row["id"]);
                        int PageId = Convert.ToInt32(Row["page_id"]);
                        int BaseId = Convert.ToInt32(Row["item_id"]);

                        ItemData Data = null;
                        if (!ItemDataManager.GetItem(BaseId, out Data))
                        {
                            Console.WriteLine("Couldn't load Catalog Item " + ItemId + ", no furniture record found.");
                            continue;
                        }

                        if (!this._items.ContainsKey(PageId))
                        {
                            this._items[PageId] = new Dictionary <int, CatalogItem>();
                        }

                        this._items[PageId].Add(Convert.ToInt32(Row["id"]), new CatalogItem(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["item_id"]),
                                                                                            Data, Convert.ToString(Row["catalog_name"]), Convert.ToInt32(Row["page_id"]), Convert.ToInt32(Row["cost_credits"]), Convert.ToInt32(Row["cost_pixels"]), Convert.ToInt32(Row["cost_diamonds"]),
                                                                                            Convert.ToInt32(Row["amount"]), Convert.ToInt32(Row["limited_sells"]), Convert.ToInt32(Row["limited_stack"]), ButterflyEnvironment.EnumToBool(Row["offer_active"].ToString()), Convert.ToString(Row["badge"])));
                        this._itemsPage.Add(Convert.ToInt32(Row["id"]), PageId);
                    }
                }


                dbClient.SetQuery("SELECT catalog_pages.id, catalog_pages.parent_id, catalog_pages.caption, catalog_pages.page_link, catalog_pages.enabled, catalog_pages.min_rank, catalog_pages.icon_image," +
                                  " catalog_pages.page_layout, catalog_pages.page_strings_1, catalog_pages.page_strings_2, catalog_pages_langue.caption_en, catalog_pages_langue.caption_br," +
                                  " catalog_pages_langue.page_strings_2_en, catalog_pages_langue.page_strings_2_br" +
                                  " FROM catalog_pages" +
                                  " LEFT JOIN catalog_pages_langue ON catalog_pages.id = catalog_pages_langue.page_id" +
                                  " ORDER BY order_num;");
                DataTable CatalogPages = dbClient.GetTable();

                if (CatalogPages != null)
                {
                    foreach (DataRow Row in CatalogPages.Rows)
                    {
                        this._pages.Add(Convert.ToInt32(Row["id"]), new CatalogPage(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["parent_id"]), Row["enabled"].ToString(), Convert.ToString(Row["caption"]),
                                                                                    Convert.ToString(Row["page_link"]), Convert.ToInt32(Row["icon_image"]), Convert.ToInt32(Row["min_rank"]), Convert.ToString(Row["page_layout"]),
                                                                                    Convert.ToString(Row["page_strings_1"]), Convert.ToString(Row["page_strings_2"]), Convert.ToString(Row["caption_en"]),
                                                                                    Convert.ToString(Row["caption_br"]), Convert.ToString(Row["page_strings_2_en"]), Convert.ToString(Row["page_strings_2_br"]),
                                                                                    this._items.ContainsKey(Convert.ToInt32(Row["id"])) ? this._items[Convert.ToInt32(Row["id"])] : new Dictionary <int, CatalogItem>()));
                    }
                }

                dbClient.SetQuery("SELECT `id`,`name`,`figure`,`motto`,`gender`,`ai_type` FROM `catalog_bot_presets`");
                DataTable bots = dbClient.GetTable();

                if (bots != null)
                {
                    foreach (DataRow Row in bots.Rows)
                    {
                        this._botPresets.Add(Convert.ToInt32(Row[0]), new CatalogBot(Convert.ToInt32(Row[0]), Convert.ToString(Row[1]), Convert.ToString(Row[2]), Convert.ToString(Row[3]), Convert.ToString(Row[4]), Convert.ToString(Row[5])));
                    }
                }

                dbClient.SetQuery("SELECT * FROM `catalog_promotions`");
                DataTable GetPromotions = dbClient.GetTable();

                if (GetPromotions != null)
                {
                    foreach (DataRow Row in GetPromotions.Rows)
                    {
                        if (!this._promotions.ContainsKey(Convert.ToInt32(Row["id"])))
                        {
                            this._promotions.Add(Convert.ToInt32(Row["id"]), new CatalogPromotion(Convert.ToInt32(Row["id"]), Convert.ToString(Row["title"]), Convert.ToString(Row["title_en"]), Convert.ToString(Row["title_br"]), Convert.ToString(Row["image"]), Convert.ToInt32(Row["unknown"]), Convert.ToString(Row["page_link"]), Convert.ToInt32(Row["parent_id"])));
                        }
                    }
                }

                this._petRaceManager.Init();
            }

            Console.WriteLine("Catalog Manager -> LOADED");
        }
コード例 #11
0
ファイル: RoomData.cs プロジェクト: nightwolf93/Bfly
        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           = ButterflyEnvironment.EnumToBool(Row["allow_pets"].ToString());
            this.AllowPetsEating     = ButterflyEnvironment.EnumToBool(Row["allow_pets_eat"].ToString());
            this.AllowWalkthrough    = ButterflyEnvironment.EnumToBool(Row["allow_walkthrough"].ToString());
            this.AllowRightsOverride = ButterflyEnvironment.EnumToBool(Row["allow_rightsoverride"].ToString());
            this.Hidewall            = ButterflyEnvironment.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);
            }
        }
コード例 #12
0
        public void Init()
        {
            if (this._items.Count > 0)
            {
                this._items.Clear();
            }

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT * FROM `furniture`");
                DataTable ItemData = dbClient.GetTable();

                if (ItemData != null)
                {
                    foreach (DataRow Row in ItemData.Rows)
                    {
                        try
                        {
                            int             id                  = Convert.ToInt32(Row["id"]);
                            int             spriteID            = Convert.ToInt32(Row["sprite_id"]);
                            string          itemName            = Convert.ToString(Row["item_name"]);
                            string          type                = Row["type"].ToString();
                            int             width               = Convert.ToInt32(Row["width"]);
                            int             length              = Convert.ToInt32(Row["length"]);
                            double          height              = Convert.ToDouble(Row["stack_height"]);
                            bool            allowStack          = ButterflyEnvironment.EnumToBool(Row["can_stack"].ToString());
                            bool            allowWalk           = ButterflyEnvironment.EnumToBool(Row["is_walkable"].ToString());
                            bool            allowSit            = ButterflyEnvironment.EnumToBool(Row["can_sit"].ToString());
                            bool            allowRecycle        = ButterflyEnvironment.EnumToBool(Row["allow_recycle"].ToString());
                            bool            allowTrade          = ButterflyEnvironment.EnumToBool(Row["allow_trade"].ToString());
                            bool            allowGift           = Convert.ToInt32(Row["allow_gift"]) == 1;
                            bool            allowInventoryStack = ButterflyEnvironment.EnumToBool(Row["allow_inventory_stack"].ToString());
                            InteractionType interactionType     = InteractionTypes.GetTypeFromString(Convert.ToString(Row["interaction_type"]));
                            int             cycleCount          = Convert.ToInt32(Row["interaction_modes_count"]);
                            string          vendingIDS          = Convert.ToString(Row["vending_ids"]);
                            string          heightAdjustable    = Convert.ToString(Row["height_adjustable"]);
                            int             EffectId            = Convert.ToInt32(Row["effect_id"]);
                            bool            IsRare              = ButterflyEnvironment.EnumToBool(Row["is_rare"].ToString());

                            if (!this._gifts.ContainsKey(spriteID) && interactionType == InteractionType.GIFT)
                            {
                                this._gifts.Add(spriteID, new ItemData(id, spriteID, itemName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowGift, allowInventoryStack, interactionType, cycleCount, vendingIDS, heightAdjustable, EffectId, IsRare));
                            }

                            if (!this._items.ContainsKey(id))
                            {
                                this._items.Add(id, new ItemData(id, spriteID, itemName, type, width, length, height, allowStack, allowWalk, allowSit, allowRecycle, allowTrade, allowGift, allowInventoryStack, interactionType, cycleCount, vendingIDS, heightAdjustable, EffectId, IsRare));
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                            Console.ReadKey();
                            //Logging.WriteLine("Could not load item #" + Convert.ToInt32(Row[0]) + ", please verify the data is okay.");
                        }
                    }
                }
            }

            Console.WriteLine("Item Manager -> LOADED");
        }
コード例 #13
0
ファイル: Catalog.cs プロジェクト: nightwolf93/Bfly
        internal void Initialize(IQueryAdapter dbClient)
        {
            Pages          = new Dictionary <int, CatalogPage>();
            EcotronRewards = new List <EcotronReward>();
            gifts          = new Hashtable();

            dbClient.setQuery("SELECT * FROM catalog_pages ORDER BY order_num");
            DataTable Data = dbClient.getTable();

            dbClient.setQuery("SELECT * FROM ecotron_rewards ORDER BY item_id");
            DataTable EcoData = dbClient.getTable();

            Hashtable CataItems = new Hashtable();

            dbClient.setQuery("SELECT id,item_ids,catalog_name,cost_credits,cost_pixels,amount,page_id,cost_crystal,cost_oude_belcredits,song_id FROM catalog_items_copy");
            DataTable CatalogueItems = dbClient.getTable();

            if (CatalogueItems != null)
            {
                foreach (DataRow Row in CatalogueItems.Rows)
                {
                    if (string.IsNullOrEmpty(Row["item_ids"].ToString()) || (int)Row["amount"] <= 0)
                    {
                        continue;
                    }
                    CataItems.Add(Convert.ToUInt32(Row["id"]), new CatalogItem(Row));
                    //Items.Add(new CatalogItem((uint)Row["id"], (string)Row["catalog_name"], (string)Row["item_ids"], (int)Row["cost_credits"], (int)Row["cost_pixels"], (int)Row["amount"]));
                }
            }

            if (Data != null)
            {
                foreach (DataRow Row in Data.Rows)
                {
                    Boolean Visible    = false;
                    Boolean Enabled    = false;
                    Boolean ComingSoon = false;

                    if (Row["visible"].ToString() == "1")
                    {
                        Visible = true;
                    }

                    if (Row["enabled"].ToString() == "1")
                    {
                        Enabled = true;
                    }

                    if (Row["coming_soon"].ToString() == "1")
                    {
                        ComingSoon = true;
                    }

                    Pages.Add((int)Row["id"], new CatalogPage((int)Row["id"], (int)Row["parent_id"],
                                                              (string)Row["caption"], Visible, Enabled, ComingSoon, Convert.ToUInt32(Row["min_rank"]),
                                                              ButterflyEnvironment.EnumToBool(Row["club_only"].ToString()), (int)Row["icon_color"],
                                                              (int)Row["icon_image"], (string)Row["page_layout"], (string)Row["page_headline"],
                                                              (string)Row["page_teaser"], (string)Row["page_special"], (string)Row["page_text1"],
                                                              (string)Row["page_text2"], (string)Row["page_text_details"], (string)Row["page_text_teaser"], ref CataItems));
                }
            }

            if (EcoData != null)
            {
                foreach (DataRow Row in EcoData.Rows)
                {
                    EcotronRewards.Add(new EcotronReward(Convert.ToUInt32(Row["display_id"]), Convert.ToUInt32(Row["item_id"]), Convert.ToUInt32(Row["reward_level"])));
                }
            }

            RestackByFrontpage();
        }
コード例 #14
0
ファイル: HabboMessenger.cs プロジェクト: nightwolf93/Bfly
        internal bool RequestBuddy(string UserQuery)
        {
            uint userID;
            bool hasFQDisabled;

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

            if (client == null)
            {
                DataRow Row = null;
                using (IQueryAdapter dbClient = ButterflyEnvironment.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 = ButterflyEnvironment.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 = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == Database_Manager.Database.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 = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(ToId);

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

            MessengerRequest Request = new MessengerRequest(ToId, UserId, ButterflyEnvironment.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);
        }
コード例 #15
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"], ButterflyEnvironment.EnumToBool(Row["category"].ToString()), ButterflyEnvironment.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));
            //    }
            //}
        }
コード例 #16
0
ファイル: HabboMessenger.cs プロジェクト: EmuZoneDEV/HBBO-EMU
        public bool RequestBuddy(string UserQuery)
        {
            GameClient clientByUsername = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(UserQuery);
            int        num1;
            bool       flag;

            if (clientByUsername == null)
            {
                DataRow dataRow = (DataRow)null;
                using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    queryreactor.SetQuery("SELECT id,block_newfriends FROM users WHERE username = @query");
                    queryreactor.AddParameter("query", UserQuery.ToLower());
                    dataRow = queryreactor.GetRow();
                }
                if (dataRow == null)
                {
                    return(false);
                }
                num1 = Convert.ToInt32(dataRow["id"]);
                flag = ButterflyEnvironment.EnumToBool(dataRow["block_newfriends"].ToString());
            }
            else
            {
                if (clientByUsername.GetHabbo() != null)
                {
                    num1 = clientByUsername.GetHabbo().Id;
                    flag = clientByUsername.GetHabbo().HasFriendRequestsDisabled;
                }
                else
                {
                    return(false);
                }
            }
            if (flag)
            {
                this.GetClient().SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("notif.textamigo.error", this.GetClient().Langue));
                return(false);
            }
            else
            {
                int num2 = num1;
                if (this.RequestExists(num2))
                {
                    return(false);
                }
                using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    queryreactor.RunQuery("REPLACE INTO messenger_requests (from_id,to_id) VALUES (" + this.UserId + "," + num2 + ")");
                }
                GameClient clientByUserId = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(num2);
                if (clientByUserId == null || clientByUserId.GetHabbo() == null)
                {
                    return(false);
                }
                MessengerRequest messengerRequest = new MessengerRequest(num2, this.UserId, ButterflyEnvironment.GetGame().GetClientManager().GetNameById(this.UserId));
                clientByUserId.GetHabbo().GetMessenger().OnNewRequest(this.UserId);
                ServerPacket serverMessage = new ServerPacket(ServerPacketHeader.NewBuddyRequestMessageComposer);
                messengerRequest.Serialize(serverMessage);
                clientByUserId.SendPacket(serverMessage);
                if (!this.requests.ContainsKey(num2))
                {
                    this.requests.Add(num2, messengerRequest);
                }
                return(true);
            }
        }
コード例 #17
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 = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (ButterflyEnvironment.useSSO)
                {
                    dbClient.setQuery("SELECT users.* " +
                                      "FROM users " +
                                      "RIGHT JOIN user_tickets " +
                                      "ON user_tickets.userid = users.id " +
                                      "WHERE user_tickets.sessionticket = @sso " +
                                      "AND ipaddress = @ipaddress ");
                }
                else
                {
                    dbClient.setQuery("SELECT users.* " +
                                      "FROM users " +
                                      "RIGHT JOIN user_tickets " +
                                      "ON user_tickets.userid = users.id " +
                                      "WHERE user_tickets.sessionticket = @sso ");
                }

                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, ButterflyEnvironment.useSSO.ToString()));
                }


                userID = Convert.ToUInt32(dUserInfo["id"]);
                if (ButterflyEnvironment.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 == Database_Manager.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 (ButterflyEnvironment.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 = '" + ButterflyEnvironment.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 = '" + ButterflyEnvironment.GetUnixTimestamp() + "' WHERE user_id = " + userID + " ; " +
                                  "");
                dbClient.addParameter("ip", ip);
                dbClient.runQuery();

                if (dbClient.dbType == Database_Manager.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        = ButterflyEnvironment.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(ButterflyEnvironment.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));
        }
コード例 #18
0
        public void Fill(DataRow Row)
        {
            this.Id          = Convert.ToInt32(Row["id"]);
            this.Name        = (string)Row["caption"];
            this.Description = (string)Row["description"];
            this.OwnerName   = (string)Row["owner"];
            this.OwnerId     = 0;
            this.Langue      = Language.FRANCAIS;
            using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                queryreactor.SetQuery("SELECT id, langue FROM users WHERE username = @owner");
                queryreactor.AddParameter("owner", this.OwnerName);
                DataRow UserRow = queryreactor.GetRow();
                if (UserRow != null)
                {
                    this.OwnerId = Convert.ToInt32(UserRow["id"]);
                    this.Langue  = LanguageManager.ParseLanguage(UserRow["langue"].ToString());
                }
            }
            switch (Row["state"].ToString().ToLower())
            {
            case "open":
                this.State = 0;
                break;

            case "password":
                this.State = 2;
                break;

            case "hide":
                this.State = 3;
                break;

            default:
                this.State = 1;
                break;
            }
            this.Category            = (int)Row["category"];
            this.UsersNow            = (int)Row["users_now"];
            this.UsersMax            = (int)Row["users_max"];
            this.ModelName           = (string)Row["model_name"];
            this.Score               = (int)Row["score"];
            this.Tags                = new List <string>();
            this.AllowPets           = ButterflyEnvironment.EnumToBool(Row["allow_pets"].ToString());
            this.AllowPetsEating     = ButterflyEnvironment.EnumToBool(Row["allow_pets_eat"].ToString());
            this.AllowWalkthrough    = ButterflyEnvironment.EnumToBool(Row["allow_walkthrough"].ToString());
            this.AllowRightsOverride = ButterflyEnvironment.EnumToBool(Row["allow_rightsoverride"].ToString());
            this.Hidewall            = ButterflyEnvironment.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.FloorThickness      = (int)Row["floorthick"];
            this.WallThickness       = (int)Row["wallthick"];

            this.ChatType            = (int)Row["chat_type"];
            this.ChatBalloon         = (int)Row["chat_balloon"];
            this.ChatSpeed           = (int)Row["chat_speed"];
            this.ChatMaxDistance     = (int)Row["chat_max_distance"];
            this.ChatFloodProtection = (int)Row["chat_flood_protection"];

            this.MuteFuse   = Convert.ToInt32((string)Row["moderation_mute_fuse"]);
            this.WhoCanKick = Convert.ToInt32((string)Row["moderation_kick_fuse"]);
            this.BanFuse    = Convert.ToInt32((string)Row["moderation_ban_fuse"]);
            this.GroupId    = (int)Row["groupId"];
            Group Group;

            ButterflyEnvironment.GetGame().GetGroupManager().TryGetGroup(this.GroupId, out Group);
            this.Group      = Group;
            this.HideWireds = ButterflyEnvironment.EnumToBool(Row["allow_hidewireds"].ToString());

            this.TrocStatus = Convert.ToInt32((string)Row["TrocStatus"]);
            Dictionary <int, int> Items = new Dictionary <int, int>();

            if (!string.IsNullOrEmpty(Row["icon_items"].ToString()))
            {
                string str1    = Row["icon_items"].ToString();
                char[] chArray = new char[1] {
                    '|'
                };
                foreach (string str2 in str1.Split(chArray))
                {
                    if (!string.IsNullOrEmpty(str2))
                    {
                        string[] strArray = str2.Replace('.', ',').Split(new char[1] {
                            ','
                        });
                        int result1 = 0;
                        int result2 = 0;
                        int.TryParse(strArray[0], out result1);
                        if (strArray.Length > 1)
                        {
                            int.TryParse(strArray[1], out result2);
                        }
                        try
                        {
                            if (!Items.ContainsKey(result1))
                            {
                                Items.Add(result1, result2);
                            }
                        }
                        catch (Exception ex)
                        {
                            Logging.LogException("Exception: " + (ex).ToString() + "[" + str2 + "]");
                        }
                    }
                }
            }
            string str3 = Row["tags"].ToString();

            char[] chArray1 = new char[1] {
                ','
            };
            foreach (string str1 in str3.Split(chArray1))
            {
                this.Tags.Add(str1);
            }

            this.SellPrice = (int)Row["price"];

            this.mModel = ButterflyEnvironment.GetGame().GetRoomManager().GetModel(this.ModelName, this.Id);
        }