コード例 #1
0
ファイル: MoodlightData.cs プロジェクト: TheNaked/Firewind
        internal MoodlightData(uint ItemId)
        {
            this.ItemId = ItemId;

            DataRow Row;

            using (IQueryAdapter dbClient = FirewindEnvironment.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       = FirewindEnvironment.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
        internal static Habbo GenerateHabbo(DataRow dRow)
        {
            int    id                       = Convert.ToInt32(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"];
            string lastonline               = Convert.ToString(dRow["last_online"]);
            int    credits                  = (int)dRow["credits"];
            int    activityPoints           = (int)dRow["activity_points"];
            double activityPointsLastUpdate = Convert.ToDouble(dRow["activity_points_lastupdate"]);
            bool   isMuted                  = FirewindEnvironment.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             = FirewindEnvironment.EnumToBool(dRow["block_newfriends"].ToString());
            uint   questID                  = Convert.ToUInt32(dRow["currentquestid"]);
            int    questProgress            = Convert.ToInt32(dRow["currentquestprogress"]);
            int    achiecvementPoints       = Convert.ToInt32(dRow["achievement_points"]);
            int    vippoints                = Convert.ToInt32(dRow["vip_points"]);
            int    favgroup                 = dRow["favourite_group"] == DBNull.Value ? 0 : Convert.ToInt32(dRow["favourite_group"]);

            return(new Habbo(id, username, realname, rank, motto, look, gender, credits, vippoints, activityPoints, activityPointsLastUpdate, isMuted, homeRoom, respect, dailyRespect, dailyPetRespect, mtantPenalty, blockFriends, questID, questProgress, achiecvementPoints, lastonline, favgroup));
        }
コード例 #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"], FirewindEnvironment.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));
            }
        }
コード例 #4
0
        internal void DeadFill(DataRow Row)
        {
            this.Id          = Convert.ToUInt32(Row["id"]);
            this.Name        = (string)Row["caption"];
            this.Description = (string)Row["description"];
            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.Score               = (int)Row["score"];
            this.Tags                = new List <string>();
            this.AllowPets           = FirewindEnvironment.EnumToBool(Row["allow_pets"].ToString());
            this.AllowPetsEating     = FirewindEnvironment.EnumToBool(Row["allow_pets_eat"].ToString());
            this.AllowWalkthrough    = FirewindEnvironment.EnumToBool(Row["allow_walkthrough"].ToString());
            this.AllowRightsOverride = FirewindEnvironment.EnumToBool(Row["allow_rightsoverride"].ToString());
            this.Hidewall            = FirewindEnvironment.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;

            foreach (string Tag in Row["tags"].ToString().Split(','))
            {
                this.Tags.Add(Tag);
            }
        }
コード例 #5
0
ファイル: MoodlightData.cs プロジェクト: TheNaked/Firewind
        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]), FirewindEnvironment.EnumToBool(Bits[2])));
        }
コード例 #6
0
        internal void LoadModels(IQueryAdapter dbClient)
        {
            roomModels.Clear();

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

            if (Data == null)
            {
                return;
            }

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

                roomModels.Add(Modelname, new RoomModel((int)Row["door_x"],
                                                        (int)Row["door_y"], (Double)Row["door_z"], (int)Row["door_dir"], (string)Row["heightmap"],
                                                        FirewindEnvironment.EnumToBool(Row["club_only"].ToString())));
            }
        }
コード例 #7
0
ファイル: HabboMessenger.cs プロジェクト: Habbotard/Firewind
        internal bool RequestBuddy(string UserQuery)
        {
            int  userID;
            bool hasFQDisabled;

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

            if (client == null)
            {
                DataRow Row = null;
                using (IQueryAdapter dbClient = FirewindEnvironment.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.ToInt32(Row["id"]);
                hasFQDisabled = FirewindEnvironment.EnumToBool(Row["block_newfriends"].ToString());
            }
            else
            {
                userID        = client.GetHabbo().Id;
                hasFQDisabled = client.GetHabbo().HasFriendRequestsDisabled;
            }

            if (hasFQDisabled)
            {
                GetClient().GetMessageHandler().GetResponse().Init(Outgoing.MessengerError);
                GetClient().GetMessageHandler().GetResponse().AppendInt32(0); // clientMessageId (not that important really)
                GetClient().GetMessageHandler().GetResponse().AppendInt32(3); // errorCode (1=limit reached,2=limit reached for other person,3=requests disabled,4=requestnotfound)
                GetClient().GetMessageHandler().SendResponse();
                return(true);
            }

            int ToId = userID;

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

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("REPLACE INTO messenger_requests (sender,receiver) VALUES (" + this.UserId + "," + ToId + ")");
            }

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

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

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

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

            ServerMessage NewFriendNotif = new ServerMessage(Outgoing.SendFriendRequest);

            Request.Serialize(NewFriendNotif);
            ToUser.SendMessage(NewFriendNotif);
            requests.Add(ToId, Request);
            return(true);
        }
コード例 #8
0
ファイル: Catalog.cs プロジェクト: Habbotard/Firewind
        internal void Initialize(IQueryAdapter dbClient)
        {
            Pages          = new Dictionary <int, CatalogPage>();
            EcotronRewards = new List <EcotronReward>();

            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 * FROM catalog_items");
            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;

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

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

                    Pages.Add((int)Row["id"], new CatalogPage((int)Row["id"], (int)Row["parent_id"],
                                                              (string)Row["caption"], Visible, Enabled, Convert.ToUInt32(Row["min_rank"]),
                                                              FirewindEnvironment.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();
        }
コード例 #9
0
ファイル: Navigator.cs プロジェクト: TheNaked/Firewind
        internal void Initialize(IQueryAdapter dbClient)
        {
            PrivateCategories.Clear();
            PublicItems.Clear();
            //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["description"],
                                                                   (string)Row["image"], ((Row["image_type"].ToString().ToLower() == "internal") ? PublicImageType.INTERNAL : PublicImageType.EXTERNAL),
                                                                   Convert.ToUInt32(Row["room_id"]), (int)Row["category_id"], (int)Row["category_parent_id"], FirewindEnvironment.EnumToBool(Row["recommended"].ToString()), (int)Row["typeofdata"], (string)Row["tag"]));
                }
            }

            //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));
            //    }
            //}
        }
コード例 #10
0
        internal void Fill(DataRow Row)
        {
            this.Id          = Convert.ToUInt32(Row["id"]);
            this.Name        = (string)Row["caption"];
            this.Description = (string)Row["description"];
            this.Owner       = (string)Row["owner"];
            this.Badge       = (string)Row["badge"];
            this.OwnerId     = 0;

            DataRow groupRow;

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT id FROM users WHERE username = '******'");
                int result = dbClient.getInteger();
                if (result > 0)
                {
                    this.OwnerId = result;
                }

                //    dbClient.setQuery("SELECT * FROM guild WHERE rooms_id = @id");
                //    dbClient.addParameter("id", Id);
                //    groupRow = dbClient.getRow();
            }

            //if(groupRow != null)
            //    Group = new Group(groupRow, new DataTable());

            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.Score               = (int)Row["score"];
            this.Tags                = new List <string>();
            this.AllowPets           = FirewindEnvironment.EnumToBool(Row["allow_pets"].ToString());
            this.AllowPetsEating     = FirewindEnvironment.EnumToBool(Row["allow_pets_eat"].ToString());
            this.AllowWalkthrough    = FirewindEnvironment.EnumToBool(Row["allow_walkthrough"].ToString());
            this.AllowRightsOverride = FirewindEnvironment.EnumToBool(Row["allow_rightsoverride"].ToString());
            this.Hidewall            = FirewindEnvironment.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      = Convert.ToInt32(Row["floorthickness"]);
            this.WallThickness       = Convert.ToInt32(Row["wallthickness"]);
            //this.Event = null;

            foreach (string Tag in Row["tags"].ToString().Split(','))
            {
                this.Tags.Add(Tag);
            }

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