コード例 #1
0
        public override void LoadItemData(string data)
        {
            string[] dataSpit = data.Split((char)9);

            if (!string.IsNullOrEmpty(dataSpit[0]))
            {
                foreach (string itemData in dataSpit[0].Split('|'))
                {
                    string[] itemDataSlit = itemData.Split(',');
                    uint     itemId       = uint.Parse(itemDataSlit[0]);

                    RoomItem item = this.Room.RoomItemManager.TryGetRoomItem(itemId);
                    if (item != null)
                    {
                        string extraData = itemDataSlit[1];
                        int    rot       = int.Parse(itemDataSlit[2]);
                        int    x         = int.Parse(itemDataSlit[3]);
                        int    y         = int.Parse(itemDataSlit[4]);
                        double z         = double.Parse(itemDataSlit[5]);

                        this.SelectedItems.Add(item);
                        this.MatchFurniData.Add(item.ID, new MatchFurniData(extraData, rot, x, y, z));
                    }
                }
            }

            this.FurniState = TextUtilies.StringToBool(dataSpit[1]);
            this.Direction  = TextUtilies.StringToBool(dataSpit[2]);
            this.Position   = TextUtilies.StringToBool(dataSpit[3]);
        }
コード例 #2
0
        public virtual void Handle(GameClient session, ClientMessage message)
        {
            if (session?.GetHabbo()?.GetMessenger() != null)
            {
                uint userId = 0;
                bool blockFriendRequests = false;

                GameClient target = Skylight.GetGame().GetGameClientManager().GetGameClientByUsername(this.Username);
                if (target?.GetHabbo()?.GetUserSettings() == null)
                {
                    DataRow dataRow = null;
                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("username", this.Username);
                        dataRow = dbClient.ReadDataRow("SELECT id, block_newfriends FROM users WHERE username = @username LIMIT 1");
                    }

                    if (dataRow != null)
                    {
                        userId = (uint)dataRow["id"];
                        blockFriendRequests = TextUtilies.StringToBool((string)dataRow["block_newfriends"]);
                    }
                }
                else
                {
                    userId = target.GetHabbo().ID;
                    blockFriendRequests = target.GetHabbo().GetUserSettings().BlockNewFriends;
                }

                if (userId > 0 && userId != session.GetHabbo().ID)
                {
                    if (blockFriendRequests)
                    {
                        session.SendMessage(new MessengerSendFriendRequestErrorComposerHandler(MessengerSendFriendRequestErrorCode.FriendRequestsDisabled));
                    }
                    else
                    {
                        if (session.GetHabbo().GetMessenger().TrySendFriendRequestTo(userId) && !(target?.GetHabbo()?.GetMessenger()?.HasFriendRequestPendingFrom(session.GetHabbo().ID) ?? true))
                        {
                            bool insertSuccess = false;
                            using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                            {
                                dbClient.AddParamWithValue("toid", userId);
                                dbClient.AddParamWithValue("userid", session.GetHabbo().ID);
                                insertSuccess = dbClient.ExecuteNonQuery("INSERT INTO messenger_requests (to_id, from_id) VALUES (@toid, @userid)") > 0;
                            }

                            if (insertSuccess)
                            {
                                target?.GetHabbo()?.GetMessenger()?.AddFriendRequest(new MessengerRequest(userId, session.GetHabbo().ID, session.GetHabbo().Username, session.GetHabbo().Look));
                            }
                        }
                    }
                }
                else
                {
                    session.SendMessage(new MessengerSendFriendRequestErrorComposerHandler(MessengerSendFriendRequestErrorCode.RequestNotFound));
                }
            }
        }
コード例 #3
0
ファイル: RoomData.cs プロジェクト: aromaa/Skylight
        public RoomData(DataRow dataRow)
        {
            if (dataRow != null)
            {
                this.ID          = (uint)dataRow["id"];
                this.Name        = (string)dataRow["name"];
                this.Description = (string)dataRow["description"];
                this.OwnerID     = (uint)dataRow["ownerid"];
                this.Type        = (string)dataRow["type"];
                this.Model       = (string)dataRow["model"];
                this.State       = (string)dataRow["state"] == "password" ? RoomStateType.PASSWORD : (string)dataRow["state"] == "locked" ? RoomStateType.LOCKED : RoomStateType.OPEN;
                this.Category    = (int)dataRow["category"];
                this.UsersNow    = (int)dataRow["users_now"]; //maybe we need this sometimes :3
                this.UsersMax    = (int)dataRow["users_max"];
                this.PublicCCTs  = (string)dataRow["public_ccts"];
                this.Score       = (int)dataRow["score"];
                string tags = (string)dataRow["tags"];
                if (!string.IsNullOrEmpty(tags))
                {
                    this.Tags = tags.Split(',').ToList();
                }
                else
                {
                    this.Tags = new List <string>();
                }
                this.RoomIcon         = new RoomIcon((int)dataRow["icon_bg"], (int)dataRow["icon_fg"], (string)dataRow["icon_items"]);
                this.Password         = (string)dataRow["password"];
                this.Wallpaper        = (string)dataRow["wallpaper"];
                this.Floor            = (string)dataRow["floor"];
                this.Landscape        = (string)dataRow["landscape"];
                this.AllowPets        = TextUtilies.StringToBool((string)dataRow["allow_pets"]);
                this.AllowPetsEat     = TextUtilies.StringToBool((string)dataRow["allow_pets_eat"]);
                this.AllowWalkthrough = TextUtilies.StringToBool((string)dataRow["allow_walkthrough"]);
                this.Hidewalls        = TextUtilies.StringToBool((string)dataRow["hidewalls"]);
                this.Wallthick        = (int)dataRow["wallthick"];
                this.Floorthick       = (int)dataRow["floorthick"];
                this.AllowTrade       = (RoomAllowTradeType)int.Parse((string)dataRow["trade"]);
                this.MuteOption       = (RoomWhoCanType)int.Parse((string)dataRow["mute_option"]);
                this.KickOption       = (RoomWhoCanType)int.Parse((string)dataRow["kick_option"]);
                this.BanOption        = (RoomWhoCanType)int.Parse((string)dataRow["ban_option"]);
                this.ChatMode         = (RoomChatModeType)int.Parse((string)dataRow["chat_mode"]);
                this.ChatWeight       = (RoomChatWeightType)int.Parse((string)dataRow["chat_weight"]);
                this.ChatSpeed        = (RoomChatSpeedType)int.Parse((string)dataRow["chat_speed"]);
                this.ChatProtection   = (RoomChatProtectionType)int.Parse((string)dataRow["chat_protection"]);

                string data = (string)dataRow["data"];
                if (!string.IsNullOrEmpty(data))
                {
                    this.ExtraData = JsonConvert.DeserializeObject <RoomExtraData>(data);
                }
                else
                {
                    this.ExtraData = new RoomExtraData();
                }
            }
            else
            {
                this.NullValues();
            }
        }
コード例 #4
0
 public MoodlightPreset StringToMoodlightPreset(string data)
 {
     string[] dataSplitted = data.Split(',');
     if (!this.IsValidColor(dataSplitted[0]))
     {
         dataSplitted[0] = "#000000";
     }
     return(new MoodlightPreset(dataSplitted[0], int.Parse(dataSplitted[1]), TextUtilies.StringToBool(dataSplitted[2])));
 }
コード例 #5
0
        public static Habbo LoadHabbo(UserDataFactory userData, GameClient session)
        {
            DataRow habboData = userData.GetUserData();

            uint   id                       = (uint)habboData["id"];
            string username                 = (string)habboData["username"];
            string realName                 = (string)habboData["real_name"];
            string email                    = (string)habboData["mail"];
            string sso                      = (string)habboData["auth_ticket"];
            int    rank                     = (int)habboData["rank"];
            int    credits                  = (int)habboData["credits"];
            string activityPoints           = (string)habboData["activity_points"];
            double activityPointsLastUpdate = (double)habboData["activity_points_lastupdate"];
            string look                     = (string)habboData["look"];
            string gender                   = (string)habboData["gender"];
            string motto                    = (string)habboData["motto"];
            double accountCreated           = (double)habboData["account_created"];
            double lastOnline               = (double)habboData["last_online"];
            string ipLast                   = (string)habboData["ip_last"];
            string ipReg                    = (string)habboData["ip_reg"];
            uint   homeRoom                 = (uint)habboData["home_room"];
            int    dailyRespectPoints       = (int)habboData["daily_respect_points"];
            int    dailyPetRespectPoints    = (int)habboData["daily_pet_respect_points"];
            double muteExpires              = (double)habboData["mute_expires"];
            bool   blockNewFriends          = TextUtilies.StringToBool((string)habboData["block_newfriends"]);
            bool   hideOnline               = TextUtilies.StringToBool((string)habboData["hide_online"]);
            bool   hideInRoom               = TextUtilies.StringToBool((string)habboData["hide_inroom"]);

            int[] volume = ((string)habboData["volume"]).Split(new char[] { ',' }, 3, StringSplitOptions.RemoveEmptyEntries).Select(v => int.TryParse(v, out int i) ? i : 100).ToArray();
            if (volume.Length == 0)
            {
                volume = new int[] { 100, 100, 100 };
            }
            else if (volume.Length == 1)
            {
                volume = new int[] { volume[0], 100, 100 };
            }
            else if (volume.Length == 2)
            {
                volume = new int[] { volume[0], volume[1], 100 };
            }
            bool   acceptTrading     = TextUtilies.StringToBool((string)habboData["accept_trading"]);
            int    marketplaceTokens = (int)habboData["marketplace_tokens"];
            int    newbieStatus      = (int)habboData["newbie_status"];
            uint   newbieRoom        = (uint)habboData["newbie_room"];
            bool   friendStream      = TextUtilies.StringToBool((string)habboData["friend_stream"]);
            string twoFactoryAuthenicationSecretCode = (string)habboData["two_factory_authenication_secret_code"];
            bool   mailConfirmed            = TextUtilies.StringToBool((string)habboData["mail_confirmed"]);
            bool   preferOldChat            = TextUtilies.StringToBool((string)habboData["prefer_old_chat"]);
            bool   blockRoomInvites         = TextUtilies.StringToBool((string)habboData["block_room_invites"]);
            bool   blockCameraFollow        = TextUtilies.StringToBool((string)habboData["block_camera_follow"]);
            int    chatColor                = (int)habboData["chat_color"];
            double guideEnrollmentTimestamp = (double)habboData["guide_enrollment_timestamp"];

            return(new Habbo(session, userData, id, username, realName, email, sso, rank, credits, activityPoints, activityPointsLastUpdate, look, gender, motto, accountCreated, lastOnline, ipLast, ipReg, homeRoom, dailyRespectPoints, dailyPetRespectPoints, muteExpires, blockNewFriends, hideOnline, hideInRoom, volume, acceptTrading, marketplaceTokens, newbieStatus, newbieRoom, friendStream, twoFactoryAuthenicationSecretCode, mailConfirmed, preferOldChat, blockRoomInvites, blockCameraFollow, chatColor, guideEnrollmentTimestamp));
        }
コード例 #6
0
        public static void LoadConfigsFromDB(DatabaseClient dbClient)
        {
            Logging.Write("Loading server settings... ");

            DataRow settings = dbClient.ReadDataRow("SELECT * FROM server_settings");

            ServerConfiguration.EnableSecureSession = TextUtilies.StringToBool((string)settings["enable_secure_session"]);
            ServerConfiguration.EveryoneVIP         = TextUtilies.StringToBool((string)settings["everyone_vip"]);
            ServerConfiguration.MaxRoomsPerUser     = (int)settings["max_rooms_per_user"];
            ServerConfiguration.UseIPLastForBans    = TextUtilies.StringToBool((string)settings["ip_last_for_bans"]);
            ServerConfiguration.MOTD = (string)settings["motd"];
            ServerConfiguration.EnableMarketplace            = TextUtilies.StringToBool((string)settings["enable_marketplace"]);
            ServerConfiguration.MarketplaceMinPrice          = (int)settings["marketplace_min_price"];
            ServerConfiguration.MarketplaceMaxPrice          = (int)settings["marketplace_max_price"];
            ServerConfiguration.MarketplaceOffersActiveHours = (int)settings["marketplace_offers_active_hours"];
            ServerConfiguration.MarketplaceTokensNonPremium  = (int)settings["marketplace_tokens_non_premium"];
            ServerConfiguration.MarketplaceTokensPremium     = (int)settings["marketplace_tokens_premium"];
            ServerConfiguration.MarketplaceTokensPrice       = (int)settings["marketplace_tokens_price"];
            ServerConfiguration.MarketplaceCompremission     = (int)settings["marketplace_compremission"];
            ServerConfiguration.MarketplaceAvaragePriceDays  = (int)settings["marketplace_avarage_price_days"];
            ServerConfiguration.EventsEnabled                  = TextUtilies.StringToBool((string)settings["events_enabled"]);
            ServerConfiguration.EnableCrypto                   = TextUtilies.StringToBool((string)settings["enable_crypto"]);
            ServerConfiguration.RequireMachineID               = TextUtilies.StringToBool((string)settings["require_machine_id"]);
            ServerConfiguration.CryptoType                     = (int)settings["crypto_type"];
            ServerConfiguration.IdleTime                       = (int)settings["idle_time"];
            ServerConfiguration.IdleKickTime                   = (int)settings["idle_kick_time"];
            ServerConfiguration.ActivityBonusTime              = (int)settings["activity_bonus_time"];
            ServerConfiguration.CreditsBonus                   = (int)settings["credits_bonus"];
            ServerConfiguration.PixelsBonus                    = (int)settings["pixels_bonus"];
            ServerConfiguration.ActivityPointsBonusType        = (int)settings["activity_points_bonus_type"];
            ServerConfiguration.ActivityPointsBonus            = (int)settings["activity_points_bonus"];
            ServerConfiguration.AllowedComamndsToBeBlacklisted = ((string)settings["allowed_commands_to_be_blacklisted"]).ToLower().Split(',').ToList();
            ServerConfiguration.MinRankRequireLogin            = (int)settings["min_rank_require_login"];

            ServerConfiguration.BlacklistedEffects.Clear();
            foreach (string string_ in ((string)settings["blacklisted_effects"]).Split(';'))
            {
                string[] string_2 = string_.Split(',');
                if (string_2.Length == 2)
                {
                    ServerConfiguration.BlacklistedEffects.Add(int.Parse(string_2[0]), int.Parse(string_2[1]));
                }
            }

            ServerConfiguration.StaffPicksCategoryId = (int)settings["staff_picks_category_id"];

            Logging.WriteLine("completed!", ConsoleColor.Green);
        }
コード例 #7
0
        public override void LoadItemData(string data)
        {
            string[] splitData = data.Split((char)9);

            foreach (string sItemId in splitData[0].Split(','))
            {
                if (!string.IsNullOrEmpty(sItemId))
                {
                    RoomItem item = this.Room.RoomItemManager.TryGetRoomItem(uint.Parse(sItemId));
                    if (item != null)
                    {
                        this.SelectedItems.Add(item);
                    }
                }
            }

            this.AllFurnis = TextUtilies.StringToBool(splitData[1]);
        }
コード例 #8
0
        public MoodlightData(uint itemId)
        {
            this.ItemID  = itemId;
            this.Presets = new List <MoodlightPreset>();

            DataRow dataRow = null;

            using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
            {
                dbClient.AddParamWithValue("itemId", this.ItemID);
                dataRow = dbClient.ReadDataRow("SELECT * FROM items_moodlight WHERE item_id = @itemId LIMIT 1");
            }

            this.Enabled       = TextUtilies.StringToBool((string)dataRow["enabled"]);
            this.CurrentPreset = (int)dataRow["current_preset"];
            this.Presets.Add(this.StringToMoodlightPreset((string)dataRow["preset_one"]));
            this.Presets.Add(this.StringToMoodlightPreset((string)dataRow["preset_two"]));
            this.Presets.Add(this.StringToMoodlightPreset((string)dataRow["preset_three"]));
        }
コード例 #9
0
ファイル: UserProfileManager.cs プロジェクト: aromaa/Skylight
        public UserProfile GetProfile(uint userId)
        {
            GameClient target = Skylight.GetGame().GetGameClientManager().GetGameClientById(userId);

            if (!this.Profiles.TryGetValue(userId, out UserProfile profile))
            {
                profile = this.Profiles[userId] = new UserProfile(userId);

                if (target?.GetHabbo() == null)
                {
                    DataRow user = null;
                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("userId", userId);
                        user = dbClient.ReadDataRow("SELECT u.username, u.look, u.motto, u.account_created, u.online, u.last_online, s.achievement_points, COUNT(f.user_one_id) AS friends, GROUP_CONCAT(IF(IF(f.user_one_id = @userId, f.user_one_relation, f.user_two_relation) = '1', f.user_one_relation, NULL)) AS lovers, GROUP_CONCAT(IF(IF(f.user_one_id = @userId, f.user_one_relation, f.user_two_relation) = '2', f.user_one_relation, NULL)) AS friends2 , GROUP_CONCAT(IF(IF(f.user_one_id = @userId, f.user_one_relation, f.user_two_relation) = '3', f.user_one_relation, NULL)) AS haters, GROUP_CONCAT(b.badge_id ORDER BY b.badge_slot) AS badges FROM users u LEFT JOIN user_stats s ON u.id = s.user_id LEFT JOIN messenger_friends f ON f.user_one_id = @userId OR f.user_two_id = @userId LEFT JOIN user_badges b ON b.user_id = u.id AND b.badge_slot > 0 WHERE u.id = @userId GROUP BY u.id");
                    }

                    if (user != null)
                    {
                        profile.UpdateValues(user);
                        profile.SetOnline(TextUtilies.StringToBool((string)user["online"]));
                    }
                }
            }

            if (target?.GetHabbo() != null)
            {
                profile.UpdateValues(target.GetHabbo());
                profile.SetOnline(true);
            }
            else
            {
                profile.SetOnline(false);
            }

            return(profile);
        }
コード例 #10
0
        public void LoadBans(DatabaseClient dbClient)
        {
            Logging.Write("Loading bans... ");
            Dictionary <int, Ban> newBans = new Dictionary <int, Ban>();

            DataTable bans = dbClient.ReadDataTable("SELECT * FROM bans;");

            if (bans != null && bans.Rows.Count > 0)
            {
                foreach (DataRow dataRow in bans.Rows)
                {
                    int     id      = (int)dataRow["id"];
                    BanType banType = (string)dataRow["type"] == "user" ? BanType.User : (string)dataRow["type"] == "ip" ? BanType.IP : BanType.Machine;

                    newBans.Add(id, new Ban(id, banType, (string)dataRow["value"], (string)dataRow["reason"], (double)dataRow["expire"], (uint)dataRow["added_by_id"], (double)dataRow["added_on"], TextUtilies.StringToBool((string)dataRow["active"])));
                }
            }

            this.Bans = newBans;
            Logging.WriteLine("completed!", ConsoleColor.Green);
        }
コード例 #11
0
ファイル: PermissionManager.cs プロジェクト: aromaa/Skylight
        public void LoadRanks(DatabaseClient dbClient)
        {
            Logging.Write("Loading ranks... ");
            Dictionary <int, PermissionRank> newRanks = new Dictionary <int, PermissionRank>();

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

            if (ranks != null && ranks.Rows.Count > 0)
            {
                foreach (DataRow dataRow in ranks.Rows)
                {
                    int id = (int)dataRow["id"];
                    newRanks.Add(id, new PermissionRank(id, (string)dataRow["name"], (string)dataRow["public_name"], (string)dataRow["badge_id"]));
                }

                //then we can load permissions
                DataTable permissionRanks = dbClient.ReadDataTable("SELECT * FROM permissions_ranks");
                if (permissionRanks != null && permissionRanks.Rows.Count > 0)
                {
                    foreach (DataRow dataRow in permissionRanks.Rows)
                    {
                        int rankId = (int)dataRow["rank_id"];

                        PermissionRank rank = null;
                        if (newRanks.TryGetValue(rankId, out rank))
                        {
                            List <string> permissions = new List <string>();
                            for (int i = 1; i < dataRow.ItemArray.Length; i++)
                            {
                                if (dataRow[i] is string) //enum (0, 1) aka bool
                                {
                                    if (TextUtilies.StringToBool((string)dataRow[i]))
                                    {
                                        permissions.Add(dataRow.Table.Columns[i].ColumnName);
                                    }
                                }
                                else if (dataRow[i] is int) //flood times, etc
                                {
                                    string columnName = dataRow.Table.Columns[i].ColumnName;
                                    if (columnName == "floodtime")
                                    {
                                        rank.Floodtime = (int)dataRow[i];
                                    }
                                    else if (columnName == "ha_interval")
                                    {
                                        rank.HaInterval = (int)dataRow[i];
                                    }
                                    else if (columnName == "hal_interval")
                                    {
                                        rank.HalInterval = (int)dataRow[i];
                                    }
                                    else if (columnName == "wired_trigger_limit")
                                    {
                                        rank.WiredTriggerLimit = (int)dataRow[i];
                                    }
                                    else if (columnName == "wired_action_limit")
                                    {
                                        rank.WiredActionLimit = (int)dataRow[i];
                                    }
                                    else if (columnName == "wired_condition_limit")
                                    {
                                        rank.WiredConditionLimit = (int)dataRow[i];
                                    }
                                }
                            }

                            rank.SetPermissions(permissions);
                        }
                    }
                }
            }

            this.Ranks = newRanks;
            Logging.WriteLine("completed!", ConsoleColor.Green);
        }
コード例 #12
0
        public void Initialize()
        {
            Logging.WriteLine("█▀▀▀█ █ █ █  █ █    ▀  █▀▀▀ █  █ ▀▀█▀▀", ConsoleColor.Yellow);
            Logging.WriteLine("▀▀▀▄▄ █▀▄ █▄▄█ █   ▀█▀ █ ▀█ █▀▀█   █  ", ConsoleColor.Yellow);
            Logging.WriteLine("█▄▄▄█ ▀ ▀ ▄▄▄█ ▀▀▀ ▀▀▀ ▀▀▀▀ ▀  ▀   ▀  ", ConsoleColor.Yellow);
            Logging.WriteLine(Skylight.Version, ConsoleColor.Yellow);
            Logging.WriteBlank();

            Logging.WriteLine(Licence.WelcomeMessage, ConsoleColor.Green);
            Logging.WriteBlank();

            try
            {
                Skylight.ServerStarted     = Stopwatch.StartNew();
                Skylight.ConfigurationData = new ConfigurationData("config.conf");

                Logging.Write("Connecting to database... ", ConsoleColor.White);
                try
                {
                    DatabaseServer DatabaseServer = new DatabaseServer(Skylight.GetConfig()["db.hostname"], uint.Parse(Skylight.GetConfig()["db.port"]), Skylight.GetConfig()["db.username"], Skylight.GetConfig()["db.password"]);
                    Database       Database       = new Database(Skylight.GetConfig()["db.name"], uint.Parse(Skylight.GetConfig()["db.pool.minsize"]), uint.Parse(Skylight.GetConfig()["db.pool.maxsize"]));
                    Skylight.DatabaseManager = new DatabaseManager(DatabaseServer, Database);

                    using (DatabaseClient dbClient = Skylight.DatabaseManager.GetClient())
                    {
                        //WHAT AN LOVLY COMMAND WE HAVE OVER HERE! =D
                        dbClient.ExecuteQuery(@"DROP PROCEDURE IF EXISTS parse_activity_points;
CREATE PROCEDURE parse_activity_points(bound VARCHAR(255), bound2 VARCHAR(255))
  BEGIN
    DECLARE id INT DEFAULT 0;
    DECLARE value TEXT;
    DECLARE occurance INT DEFAULT 0;
    DECLARE i INT DEFAULT 0;
    DECLARE splitted_value TEXT;
    DECLARE splitted_value_2 TEXT;
    DECLARE splitted_value_3 TEXT;
    DECLARE done INT DEFAULT 0;
    DECLARE cur1 CURSOR FOR SELECT users.id, users.activity_points FROM users;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
    DROP TEMPORARY TABLE IF EXISTS activity_points_parsed_data;
    CREATE TEMPORARY TABLE activity_points_parsed_data(`id` INT NOT NULL,`value` VARCHAR(255) NOT NULL,`value2` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`,`value`)) ENGINE=Memory;
    OPEN cur1;
      read_loop: LOOP
        FETCH cur1 INTO id, value;
        IF done THEN LEAVE read_loop;
        END IF;
        SET occurance = (SELECT LENGTH(value) - LENGTH(REPLACE(value, bound, '')) +1);
        SET i=1;
        WHILE i <= occurance DO
          SET splitted_value = (SELECT REPLACE(SUBSTRING(SUBSTRING_INDEX(value, bound, i), LENGTH(SUBSTRING_INDEX(value, bound, i - 1)) + 1), bound, ''));
					SET splitted_value_2 = (SELECT REPLACE(SUBSTRING(SUBSTRING_INDEX(splitted_value, bound2, 1), LENGTH(SUBSTRING_INDEX(splitted_value, bound2, 1 - 1)) + 1), bound2, ''));
					SET splitted_value_3 = (SELECT REPLACE(SUBSTRING(SUBSTRING_INDEX(splitted_value, bound2, 2), LENGTH(SUBSTRING_INDEX(splitted_value, bound2, 2 - 1)) + 1), bound2, ''));
                    IF splitted_value_3 = '' THEN SET splitted_value_3 = splitted_value_2, splitted_value_2 = '0'; END IF;
          INSERT INTO activity_points_parsed_data VALUES (id, splitted_value_2, splitted_value_3) ON DUPLICATE KEY UPDATE value2 = value2 + splitted_value_3;
          SET i = i + 1;
        END WHILE;
      END LOOP;
    CLOSE cur1;
  END;");
                    }
                }
                catch (MySqlException ex)
                {
                    Logging.WriteLine("failed!", ConsoleColor.Red);

                    Skylight.ExceptionShutdown(ex);
                    return;
                }
                Logging.WriteLine("completed!", ConsoleColor.Green);

                Skylight.LateQueryManager = new LateQueryManager();

                Skylight.PublicToken = new BigInteger(DiffieHellman.GenerateRandomHexString(15), 16).ToString();
                Skylight.HabboCrypto = new HabboCrypto(n, e, d);

                using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                {
                    dbClient.AddParamWithValue("bannerData", Skylight.HabboCrypto.Prime + ":" + Skylight.HabboCrypto.Generator);
                    dbClient.ExecuteQuery("UPDATE users SET online = '0'; UPDATE rooms SET users_now = '0'; UPDATE server_settings SET banner_data = @bannerData;");
                }

                Skylight.TargetRevision       = RevisionUtilies.StringToRevision(Skylight.GetConfig()["game.revision"]);
                Skylight.MultiRevisionSupport = TextUtilies.StringToBool(Skylight.GetConfig()["game.mrs.enabled"]);

                Skylight.PacketManager = BasicUtilies.GetRevisionPacketManager(Skylight.Revision); //needed for stuff
                Skylight.PacketManager.Initialize();

                Skylight.Game = new Game();
                Skylight.Game.Init();

                if (Skylight.GetConfig()["game.efpfr.enabled"] == "1")
                {
                    Skylight.ExternalFlashPolicyFileRequestPort = true;
                    Skylight.FlashPolicyFileRequestListener     = new FlashPolicyFileRequestListener(Skylight.GetConfig()["game.efpfr.bindip"], int.Parse(Skylight.GetConfig()["game.efpfr.port"]));
                    Skylight.FlashPolicyFileRequestListener.Start();
                }

                Skylight.SocketsManager = new SocketsManager(Skylight.GetConfig()["game.tcp.bindip"], int.Parse(Skylight.GetConfig()["game.tcp.port"]), int.Parse(Skylight.GetConfig()["game.tcp.conlimit"]));
                foreach (string key in Skylight.ConfigurationData.GetChildKeys("game.tcp.extra"))
                {
                    Skylight.SocketsManager.AddListener(new SocketsListener(Skylight.SocketsManager, Skylight.GetConfig()["game.tcp.extra." + key + ".bindip"], int.Parse(Skylight.GetConfig()["game.tcp.extra." + key + ".port"]), RevisionUtilies.StringToRevision(Skylight.GetConfig()["game.tcp.extra." + key + ".revision"]), RevisionUtilies.StringToCrypto(Skylight.GetConfig().TryGet("game.tcp.extra." + key + ".crypto"))));
                }
                Skylight.SocketsManager.Start();

                if (Skylight.GetConfig()["rcon.tcp.enabled"] == "1")
                {
                    Skylight.RCONListener = new RCONListener(Skylight.GetConfig()["rcon.tcp.bindip"], int.Parse(Skylight.GetConfig()["rcon.tcp.port"]), Skylight.GetConfig()["rcon.tcp.allowedips"]);
                    Skylight.RCONListener.Start();
                }

                if (Skylight.GetConfig()["mus.tcp.enabled"] == "1")
                {
                    Skylight.MUSListener = new MUSListener(Skylight.GetConfig()["mus.tcp.bindip"], int.Parse(Skylight.GetConfig()["mus.tcp.port"]));
                    Skylight.MUSListener.Start();
                }

                TimeSpan bootTime = Skylight.Uptime;
                Logging.WriteLine("READY! (" + bootTime.Seconds + " s, " + bootTime.Milliseconds + " ms)", ConsoleColor.Green);
            }
            catch (Exception ex)
            {
                Logging.WriteLine("FAILED TO BOOT! ", ConsoleColor.Red);

                Skylight.ExceptionShutdown(ex);
            }
        }
コード例 #13
0
ファイル: NavigatorManager.cs プロジェクト: aromaa/Skylight
        public void LoadFlatCats(DatabaseClient dbClient)
        {
            Logging.Write("Loading flat cats... ");
            Dictionary <int, FlatCat> newFlatCats = new Dictionary <int, FlatCat>();

            foreach (KeyValuePair <int, object> item in this.OldSchoolCategoryThingy.ToList())
            {
                if (item.Value is FlatCat)
                {
                    this.OldSchoolCategoryThingy.Remove(item.Key);
                }
            }

            DataTable flatCats = dbClient.ReadDataTable("SELECT id, caption, min_rank, can_trade FROM navigator_flatcats");

            if (flatCats != null)
            {
                foreach (DataRow dataRow in flatCats.Rows)
                {
                    int     id   = (int)dataRow["id"];
                    FlatCat item = new FlatCat(id, (string)dataRow["caption"], (int)dataRow["min_rank"], TextUtilies.StringToBool((string)dataRow["can_trade"]));
                    newFlatCats.Add(id, item);

                    for (int i = 5; ; i++)
                    {
                        object trash;
                        if (!this.OldSchoolCategoryThingy.TryGetValue(i, out trash))
                        {
                            this.OldSchoolCategoryThingy.Add(i, item);
                            this.OldSchoolCategoryThingy2.Add(new KeyValuePair <int, bool>(id, true), i);
                            break;
                        }
                    }
                }
            }

            this.FlatCats = newFlatCats;
            Logging.WriteLine("completed!", ConsoleColor.Green);
        }
コード例 #14
0
ファイル: RoomItemWiredOnSay.cs プロジェクト: aromaa/Skylight
 public override void LoadItemData(string data)
 {
     string[] splitData = data.Split((char)9);
     this.Message = splitData[0];
     this.OnlyOwner = TextUtilies.StringToBool(splitData[1]);
 }
コード例 #15
0
        public void LoadMarketplaceOffers(DatabaseClient dbClient)
        {
            Logging.Write("Loading marketplace offers... ");
            this.Offers.Clear();
            this.Sold.Clear();

            DataTable offers = dbClient.ReadDataTable("SELECT * FROM catalog_marketplace_offers");

            if (offers != null && offers.Rows.Count > 0)
            {
                foreach (DataRow dataRow in offers.Rows)
                {
                    uint             id    = (uint)dataRow["id"];
                    MarketplaceOffer offer = new MarketplaceOffer(id, (uint)dataRow["user_id"], (uint)dataRow["item_id"], (int)dataRow["price"], (double)dataRow["timestamp"], TextUtilies.StringToBool((string)dataRow["sold"]), (double)dataRow["sold_timestamp"], TextUtilies.StringToBool((string)dataRow["redeem"]), (uint)dataRow["furni_id"], (string)dataRow["furni_extra_data"]);

                    if (!offer.Sold)        //not sold
                    {
                        if (!offer.Expired) //not expired
                        {
                            this.Offers.Add(id, offer);
                        }
                        else //expired
                        {
                            this.Expired.Add(id, offer);
                        }
                    }
                    else //sold
                    {
                        this.Sold.Add(id, offer);
                    }
                }
            }
            Logging.WriteLine("completed!", ConsoleColor.Green);
        }
コード例 #16
0
ファイル: CatalogManager.cs プロジェクト: aromaa/Skylight
        public void LoadCatalogPages(DatabaseClient dbClient)
        {
            Logging.Write("Loading catalog pages... ");
            Dictionary <int, CatalogPage> newPages = new Dictionary <int, CatalogPage>();

            DataTable pages = dbClient.ReadDataTable("SELECT * FROM catalog_pages ORDER BY IF(order_num != -1, order_num, caption) ASC");

            if (pages != null)
            {
                foreach (DataRow dataRow in pages.Rows)
                {
                    int id = (int)dataRow["id"];
                    newPages.Add(id, new CatalogPage((int)dataRow["Id"], (int)dataRow["parent_id"], (string)dataRow["caption"], TextUtilies.StringToBool(dataRow["visible"].ToString()), TextUtilies.StringToBool(dataRow["enabled"].ToString()), (int)dataRow["min_rank"], TextUtilies.StringToBool(dataRow["club_only"].ToString()), (int)dataRow["icon_color"], (int)dataRow["icon_image"], (string)dataRow["page_layout"], (string)dataRow["page_headline"], (string)dataRow["page_teaser"], (string)dataRow["page_special"], (string)dataRow["page_text1"], (string)dataRow["page_text2"], (string)dataRow["page_text_details"], (string)dataRow["page_text_teaser"], (string)dataRow["page_link_description"], (string)dataRow["page_link_pagename"], this.CatalogItems.Values.Where(i => i.PageID == id)));
                }
            }

            this.CatalogPages = newPages;
            Logging.WriteLine("completed!", ConsoleColor.Green);
        }
コード例 #17
0
        public void LoadAchievements(DatabaseClient dbClient)
        {
            Logging.Write("Loading achievements... ");
            Dictionary <string, Achievement> newAchievemetns = new Dictionary <string, Achievement>();

            DataTable achievements = dbClient.ReadDataTable("SELECT * FROM achievements");

            if (achievements != null && achievements.Rows.Count > 0)
            {
                foreach (DataRow dataRow in achievements.Rows)
                {
                    string groupName = (string)dataRow["group_name"];

                    if (!newAchievemetns.TryGetValue(groupName, out Achievement achievement))
                    {
                        achievement = new Achievement((string)dataRow["category"], groupName);
                        newAchievemetns.Add(groupName, achievement);
                    }

                    achievement.AddLevel(new AchievementLevel((int)dataRow["id"], (int)dataRow["level"], TextUtilies.StringToBool((string)dataRow["dynamic_badgelevel"]), (string)dataRow["badge"], (int)dataRow["activity_points_type"], (int)dataRow["activity_points"], (int)dataRow["score"], (int)dataRow["progress_needed"]));
                }
            }

            this.Achievements = newAchievemetns;
            Logging.WriteLine("completed!", ConsoleColor.Green);
        }
コード例 #18
0
ファイル: Game.cs プロジェクト: aromaa/Skylight
        public void Init()
        {
            using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
            {
                ServerConfiguration.LoadConfigsFromDB(dbClient);

                this.GameClientManager = new GameClientManager();

                this.NavigatorManager = new NavigatorManager();
                this.NavigatorManager.LoadPublicRooms(dbClient);
                this.NavigatorManager.LoadFlatCats(dbClient);

                this.RoomManager = new RoomManager();
                this.RoomManager.LoadRoomModels(dbClient);
                this.RoomManager.LoadNewbieRooms(dbClient);

                this.ItemManager = new ItemManager();
                this.ItemManager.LoadItems(dbClient);
                this.ItemManager.LoadSoundtracks(dbClient);
                this.ItemManager.LoadNewbieRoomItems(dbClient);

                this.CatalogManager = new CatalogManager();
                this.CatalogManager.LoadCatalogItems(dbClient);
                this.CatalogManager.LoadCatalogPages(dbClient);
                this.CatalogManager.LoadPetRaces(dbClient);
                this.CatalogManager.LoadPresents(dbClient);

                this.CatalogManager.GetMarketplaceManager().LoadMarketplaceOffers(dbClient);

                this.PermissionManager = new PermissionManager();
                this.PermissionManager.LoadRanks(dbClient);

                this.BanManager = new BanManager();
                this.BanManager.LoadBans(dbClient);

                this.ModerationToolManager = new ModerationToolManager();
                this.ModerationToolManager.LoadIssues(dbClient);
                this.ModerationToolManager.LoadPresents(dbClient);
                this.ModerationToolManager.LoadSupportTickets(dbClient);

                this.CautionManager = new CautionManager();
                this.CautionManager.LoadCauctions(dbClient);

                this.HelpManager = new HelpManager();
                this.HelpManager.LoadFAQs(dbClient);

                this.ChatlogManager = new ChatlogManager();

                this.RoomvisitManager = new RoomvisitManager();

                this.AchievementManager = new AchievementManager();
                this.AchievementManager.LoadAchievements(dbClient);

                this.BotManager = new BotManager();
                this.BotManager.LoadBots(dbClient);
                this.BotManager.LoadNewbieBotActions(dbClient);

                TextUtilies.LoadWordfilter(dbClient);

                this.QuestManager = new QuestManager();
                this.QuestManager.LoadQuests(dbClient);

                this.TalentManager = new TalentManager();
                this.TalentManager.LoadTalents(dbClient);

                this.FastFoodManager = new FastFoodManager();
                this.FastFoodManager.CreateNewConnection();

                this.UserProfileManager = new UserProfileManager();

                this.GuideManager = new GuideManager();
            }

            this.ClientPingEnabled = TextUtilies.StringToBool(Skylight.GetConfig()["client.ping.enabled"]);

            this.AutoRestartEnabled = TextUtilies.StringToBool(Skylight.GetConfig()["auto.restart.enabled"]);
            if (this.AutoRestartEnabled)
            {
                this.AutoRestartBackup         = TextUtilies.StringToBool(Skylight.GetConfig()["auto.restart.backup"]);
                this.AutoRestartBackupCompress = TextUtilies.StringToBool(Skylight.GetConfig()["auto.restart.backup.compress"]);
                this.AutoRestartTime           = DateTime.ParseExact(Skylight.GetConfig()["auto.restart.time"], "HH:mm", CultureInfo.InvariantCulture);
            }

            this.LastUpdateEmulatorStatus = Stopwatch.StartNew();
            this.LastActivityBonusesCheck = Stopwatch.StartNew();
            this.LastTimeoutCheck         = Stopwatch.StartNew();

            this.GameCycleTimer           = new System.Timers.Timer();
            this.GameCycleTimer.Elapsed  += this.GameCycle;
            this.GameCycleTimer.AutoReset = true;
            this.GameCycleTimer.Interval  = 1; //moved from 25ms, 40 times in a second to 1ms, 1000 times in second to help keep everything be in sync
            this.GameCycleTimer.Start();
            GC.KeepAlive(this.GameCycleTimer); //IK timer adds itself to the gc already, but just for sure ;P
        }
コード例 #19
0
ファイル: BotManager.cs プロジェクト: aromaa/Skylight
        public void LoadBots(DatabaseClient dbClient)
        {
            Logging.Write("Loading bots... ");
            Dictionary <int, RoomBotData> newBots         = new Dictionary <int, RoomBotData>();
            List <BotResponse>            newBotResponses = new List <BotResponse>();
            List <BotSpeech> newBotSpeech = new List <BotSpeech>();

            DataTable botResponses = dbClient.ReadDataTable("SELECT * FROM bots_responses");

            if (botResponses != null && botResponses.Rows.Count > 0)
            {
                foreach (DataRow dataRow in botResponses.Rows)
                {
                    newBotResponses.Add(new BotResponse((int)dataRow["bot_id"], (string)dataRow["keywords"], (string)dataRow["response_text"], (string)dataRow["mode"] == "say" ? 0 : (string)dataRow["mode"] == "shout" ? 1 : 2, (int)dataRow["serve_id"]));
                }
            }

            DataTable botSpeech = dbClient.ReadDataTable("SELECT * FROM bots_speech");

            if (botSpeech != null && botSpeech.Rows.Count > 0)
            {
                foreach (DataRow dataRow in botSpeech.Rows)
                {
                    newBotSpeech.Add(new BotSpeech((int)dataRow["bot_id"], (string)dataRow["text"], TextUtilies.StringToBool((string)dataRow["shout"])));
                }
            }

            DataTable bots = dbClient.ReadDataTable("SELECT * FROM bots");

            if (bots != null && bots.Rows.Count > 0)
            {
                foreach (DataRow dataRow in bots.Rows)
                {
                    int id = (int)dataRow["id"];
                    newBots.Add(id, new RoomBotData(id, (uint)dataRow["room_id"], (string)dataRow["name"], (string)dataRow["look"], (string)dataRow["motto"], (int)dataRow["x"], (int)dataRow["y"], (double)dataRow["z"], (int)dataRow["rotation"], (string)dataRow["walk_mode"] == "stand" ? 0 : (string)dataRow["walk_mode"] == "freeroam" ? 1 : 2, (int)dataRow["min_x"], (int)dataRow["min_y"], (int)dataRow["max_x"], (int)dataRow["max_y"], (int)dataRow["effect"], newBotResponses.Where(r => r.BotID == id).ToList(), newBotSpeech.Where(s => s.BotID == id).ToList()));
                }
            }

            this.Bots = newBots;
            Logging.WriteLine("completed!", ConsoleColor.Green);
        }
コード例 #20
0
ファイル: Item.cs プロジェクト: aromaa/Skylight
 public Item(DataRow dataRow) : this((uint)dataRow["Id"], (int)dataRow["sprite_id"], (string)dataRow["public_name"], (string)dataRow["item_name"], (string)dataRow["type"], (int)dataRow["width"], (int)dataRow["length"], (double)dataRow["stack_height"], TextUtilies.StringToBool(dataRow["can_stack"].ToString()), TextUtilies.StringToBool(dataRow["is_walkable"].ToString()), TextUtilies.StringToBool(dataRow["can_sit"].ToString()), TextUtilies.StringToBool(dataRow["allow_recycle"].ToString()), TextUtilies.StringToBool(dataRow["allow_trade"].ToString()), TextUtilies.StringToBool(dataRow["allow_marketplace_sell"].ToString()), TextUtilies.StringToBool(dataRow["allow_gift"].ToString()), TextUtilies.StringToBool(dataRow["allow_inventory_stack"].ToString()), (string)dataRow["interaction_type"], (int)dataRow["interaction_modes_count"], (string)dataRow["vending_ids"], (string)dataRow["height_adjustable"], (int)dataRow["effectM"], (int)dataRow["effectF"], TextUtilies.StringToBool((string)dataRow["HeightOverride"]))
 {
 }