public static void ReloadCache(SqlDatabaseClient MySqlClient) { lock (mSyncRoot) { mCharacterBlacklist.Clear(); mRemoteAddressBlacklist.Clear(); MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent()); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM bans WHERE timestamp_expire > @timestamp"); foreach (DataRow Row in Table.Rows) { uint UserId = (uint)Row["user_id"]; string RemoteAddr = (string)Row["remote_address"]; if (UserId > 0 && !mCharacterBlacklist.Contains(UserId)) { mCharacterBlacklist.Add(UserId); } if (RemoteAddr.Length > 0 && !mRemoteAddressBlacklist.Contains(RemoteAddr)) { mRemoteAddressBlacklist.Add(RemoteAddr); } } } }
public static void Initialize(SqlDatabaseClient MySqlClient) { mSets = new Dictionary<int, DrinkSet>(); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM drink_sets"); foreach (DataRow Row in Table.Rows) { int Id = (int)Row["id"]; string[] DrinkData = Row["drinks"].ToString().Split(','); List<int> Drinks = new List<int>(); foreach (string Drink in DrinkData) { int i = 0; int.TryParse(Drink, out i); if (i > 0) { Drinks.Add(i); } } if (Drinks.Count > 0) { mSets.Add(Id, new DrinkSet(Id, Drinks)); } } }
public static void ReloadRewards(SqlDatabaseClient MySqlClient) { lock (mSyncRoot) { DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM recycler_rewards"); int UniqueLevels = 0; foreach (DataRow Row in Table.Rows) { int RewardLevel = (int)Row["chance_level"]; if (!mRewards.ContainsKey(RewardLevel)) { mRewards.Add(RewardLevel, new List<uint>()); UniqueLevels++; } mRewards[RewardLevel].Add((uint)Row["item_id"]); } if (UniqueLevels != 5) { Output.WriteLine("Recycler is not configured correctly and will *not* work properly. Please ensure there are 5 unique reward levels.", OutputLevel.Warning); mEnabled = false; } else { mEnabled = true; } } }
public static void Reload(SqlDatabaseClient MySqlClient) { int i = 0; mUserMessagePresets.Clear(); mRoomMessagePresets.Clear(); mUserActionPresetCategories.Clear(); mUserActionPresetMessages.Clear(); DataTable BasicPresetTable = MySqlClient.ExecuteQueryTable("SELECT type,message FROM moderation_presets"); foreach (DataRow Row in BasicPresetTable.Rows) { string Message = (string)Row["message"]; switch ((string)Row["type"]) { case "room": mRoomMessagePresets.Add(Message); break; case "user": mUserMessagePresets.Add(Message); break; } i++; } DataTable UserActionCategoryTable = MySqlClient.ExecuteQueryTable("SELECT id,caption FROM moderation_preset_action_categories"); foreach (DataRow Row in UserActionCategoryTable.Rows) { mUserActionPresetCategories.Add((uint)Row["id"], (string)Row["caption"]); i++; } DataTable UserActionMsgTable = MySqlClient.ExecuteQueryTable("SELECT id,parent_id,caption,message_text FROM moderation_preset_action_messages"); foreach (DataRow Row in UserActionMsgTable.Rows) { uint ParentId = (uint)Row["parent_id"]; if (!mUserActionPresetMessages.ContainsKey(ParentId)) { mUserActionPresetMessages.Add(ParentId, new Dictionary<string, string>()); } mUserActionPresetMessages[ParentId].Add((string)Row["caption"], (string)Row["message_text"]); i++; } Output.WriteLine("Loaded " + i + " moderation categories and presets.", OutputLevel.DebugInformation); }
public static void ReloadCache(SqlDatabaseClient MySqlClient) { mBlockedWords = new List<String>(); DataTable words = MySqlClient.ExecuteQueryTable("SELECT word FROM wordfilter"); foreach (DataRow Row in words.Rows) { if(!mBlockedWords.Contains((string)Row["word"])) { mBlockedWords.Add((string)Row["word"]); } } }
public static void ReloadData(SqlDatabaseClient MySqlClient) { Dictionary<int, List<PetRaceData>> NewRaceData = new Dictionary<int, List<PetRaceData>>(); Dictionary<int, List<string>> NewTrickData = new Dictionary<int, List<string>>(); DataTable RaceTable = MySqlClient.ExecuteQueryTable("SELECT * FROM pet_races"); foreach (DataRow Row in RaceTable.Rows) { int PetType = (int)Row["pet_type"]; if (!NewRaceData.ContainsKey(PetType)) { NewRaceData.Add(PetType, new List<PetRaceData>()); } NewRaceData[PetType].Add(new PetRaceData((int)Row["data1"], (int)Row["data2"], (int)Row["data3"])); } DataTable TrickTable = MySqlClient.ExecuteQueryTable("SELECT * FROM pet_tricks"); foreach (DataRow Row in TrickTable.Rows) { int PetType = (int)Row["type"]; if (!NewTrickData.ContainsKey(PetType)) { NewTrickData.Add(PetType, new List<string>()); } NewTrickData[PetType].Add((string)Row["trick"]); } lock (mSyncRoot) { mRaces = NewRaceData; mTricks = NewTrickData; } }
public static void ReloadInterstitials(SqlDatabaseClient MySqlClient) { lock (mInterstitials) { mInterstitials.Clear(); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM interstitials WHERE enabled = '1'"); foreach (DataRow Row in Table.Rows) { mInterstitials.Add((uint)Row["id"], new Interstitial((uint)Row["id"], (string)Row["url"], (string)Row["image"])); } } }
public static List<uint> GetFriendsForUser(SqlDatabaseClient MySqlClient, uint UserId, int Confirmed) { List<uint> Friends = new List<uint>(); MySqlClient.SetParameter("id", UserId); MySqlClient.SetParameter("confirmed", Confirmed); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT user_2_id FROM messenger_friendships WHERE user_1_id = @id AND confirmed = @confirmed"); foreach (DataRow Row in Table.Rows) { Friends.Add((uint)Row[0]); } return Friends; }
public void ReloadCache(SqlDatabaseClient MySqlClient) { lock (mSyncRoot) { mInner.Clear(); MySqlClient.SetParameter("userid", mUserId); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT group_id,level,progress FROM user_achievements WHERE user_id = @userid"); foreach (DataRow Row in Table.Rows) { string Group = (string)Row["group_id"]; mInner.Add(Group, new UserAchievement(Group, (int)Row["level"], (int)Row["progress"])); } } }
public static void RebuildCache(SqlDatabaseClient MySqlClient) { lock (mRights) { mRights.Clear(); mRightSets.Clear(); mRightsBages.Clear(); DataTable RankTable = MySqlClient.ExecuteQueryTable("SELECT rank_id,rights_sets,badge_code FROM ranks"); DataTable RightsTable = MySqlClient.ExecuteQueryTable("SELECT set_id,right_id FROM rights"); foreach (DataRow Row in RankTable.Rows) { List<uint> Sets = new List<uint>(); string[] SetBits = ((string)Row["rights_sets"]).Split(','); uint rank = (uint)Row["rank_id"]; if (!mRights.ContainsKey(rank)) { mRights.Add(rank, new List<int>()); } if (!mRightsBages.ContainsKey(rank)) { mRightsBages.Add(rank, (String)Row["badge_code"]); } foreach (string SetBit in SetBits) { int Set = 0; int.TryParse(SetBit, out Set); if (Set > 0) { mRights[rank].Add(Set); } } } foreach (DataRow Row in RightsTable.Rows) { uint SetId = (uint)Row["set_id"]; if (!mRightSets.ContainsKey(SetId)) { mRightSets.Add(SetId, new List<string>()); } mRightSets[SetId].Add((string)Row["right_id"]); } } }
public void ReloadCache(SqlDatabaseClient MySqlClient) { lock (mInner) { mInner.Clear(); MySqlClient.SetParameter("characterid", mCharacterId); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT room_id FROM favorites WHERE user_id = @characterid LIMIT " + Navigator.MaxFavoritesPerUser); foreach (DataRow Row in Table.Rows) { mInner.Add((uint)Row["room_id"]); } } }
private static List<Item> LoadPlaylist(SqlDatabaseClient MySqlClient, uint SoundManagerId) { List<Item> List = new List<Item>(); MySqlClient.SetParameter("soundmanagerid", SoundManagerId); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM items WHERE soundmanager_id = @soundmanagerid ORDER BY soundmanager_order ASC"); foreach (DataRow Row in Table.Rows) { Item Item = ItemFactory.CreateFromDatabaseRow(Row); if (Item == null) { continue; } List.Add(Item); } return List; }
public static void Initialize(SqlDatabaseClient MySqlClient) { mDefinitions = new Dictionary<uint, ItemDefinition>(); int Count = 0; int Failed = 0; DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM item_definitions"); foreach (DataRow Row in Table.Rows) { ItemStackingBehavior Behavior = ItemStackingBehavior.Normal; switch (Row["stacking_behavior"].ToString().ToLower()) { case "terminator": Behavior = ItemStackingBehavior.Terminator; break; case "initiator": Behavior = ItemStackingBehavior.Initiator; break; case "ignore": Behavior = ItemStackingBehavior.Ignore; break; case "disable": Behavior = ItemStackingBehavior.InitiateAndTerminate; break; } ItemWalkableMode WMode = ItemWalkableMode.Never; switch (Row["walkable"].ToString()) { case "1": WMode = ItemWalkableMode.Limited; break; case "2": WMode = ItemWalkableMode.Always; break; } mDefinitions.Add((uint)Row["id"], new ItemDefinition((uint)Row["id"], (uint)Row["sprite_id"], (string)Row["name"], GetTypeFromString(Row["type"].ToString()), ItemBehaviorUtil.FromString((Row["behavior"].ToString())), (int)Row["behavior_data"], Behavior, WMode, (int)Row["room_limit"], (int)Row["size_x"], (int)Row["size_y"], (float)Row["height"], (Row["allow_recycling"].ToString() == "1"), (Row["allow_trading"].ToString() == "1"), (Row["allow_selling"].ToString() == "1"), (Row["allow_gifting"].ToString() == "1"), (Row["allow_inventory_stacking"].ToString() == "1"))); Count++; } Output.WriteLine("Loaded " + Count + " item definition(s)" + (Failed > 0 ? " (" + Failed + " skipped due to errors)" : "") + ".", OutputLevel.DebugInformation); }
public void ReloadCache(SqlDatabaseClient MySqlClient) { lock (mSyncRoot) { mInner.Clear(); MySqlClient.SetParameter("user_id", mUserId); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT ignore_id FROM ignores WHERE user_id = @user_id"); foreach (DataRow Row in Table.Rows) { mInner.Add((uint)Row["ignore_id"]); } } }
public static void ReloadFlatCategories(SqlDatabaseClient MySqlClient) { int NumberLoaded = 0; lock (mFlatCategories) { mFlatCategories.Clear(); mEventSearchQueries.Clear(); MySqlClient.SetParameter("enabled", "1"); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM flat_categories WHERE enabled = @enabled ORDER BY order_num ASC"); foreach (DataRow Row in Table.Rows) { mFlatCategories.Add(new FlatCategory((int)Row["id"], (Row["visible"].ToString() == "1"), (string)Row["title"], (Row["allow_trading"].ToString() == "1"))); NumberLoaded++; } DataTable EventQueries = MySqlClient.ExecuteQueryTable("SELECT * FROM navigator_event_search_categories"); foreach (DataRow Row in EventQueries.Rows) { mEventSearchQueries.Add(Row["query"].ToString().ToLower(), (int)Row["category_id"]); } } Output.WriteLine("Loaded " + NumberLoaded + " flat " + ((NumberLoaded != 1) ? "categories" : "category") + ".", OutputLevel.DebugInformation); }
public void ReloadCache(SqlDatabaseClient MySqlClient) { lock (mSyncRoot) { mInner.Clear(); MySqlClient.SetParameter("userid", mUserId); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT quest_id,progress,is_current FROM user_quests WHERE user_id = @userid"); foreach (DataRow Row in Table.Rows) { uint Id = (uint)Row["quest_id"]; mInner.Add(Id, (int)Row["progress"]); if (Row["is_current"].ToString() == "1") { mCurrentQuest = Id; } } } }
public void ReloadCache(SqlDatabaseClient MySqlClient) { lock (mSyncRoot) { mInner.Clear(); MySqlClient.SetParameter("userid", mCharacterId); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM pets WHERE user_id = @userid AND room_id = 0"); foreach (DataRow Row in Table.Rows) { Pet Pet = PetFactory.GetPetFromDatabaseRow(Row); mInner.Add(Pet.Id, Pet); } } }
public static void LoadPendingTickets(SqlDatabaseClient MySqlClient) { int i = 0; lock (mSyncRoot) { mTickets.Clear(); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM moderation_tickets WHERE status = '0' OR status = '1' ORDER BY id ASC"); foreach (DataRow Row in Table.Rows) { mTickets.Add((uint)Row["id"], new ModerationTicket((uint)Row["id"], (uint)Row["category"], (ModerationTicketStatus)int.Parse(Row["status"].ToString()), (uint)Row["reported_user_id"], (uint)Row["reportee_user_id"], (uint)Row["moderator_user_id"], (uint)Row["room_id"], (double)Row["timestamp"], (string)Row["message"])); i++; } } Output.WriteLine("Loaded " + i + " pending moderation ticket(s) from the database.", OutputLevel.DebugInformation); }
public static void ReloadModels(SqlDatabaseClient MySqlClient) { lock (mRoomModels) { mRoomModels.Clear(); MySqlClient.SetParameter("enabled", "1"); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM room_models WHERE enabled = @enabled"); foreach (DataRow Row in Table.Rows) { mRoomModels.Add((string)Row["id"], new RoomModel((string)Row["id"], ((string)Row["type"] == "flat" ? RoomModelType.Flat : RoomModelType.Public), new Heightmap((string)Row["heightmap"]), new Vector3((int)Row["door_x"], (int)Row["door_y"], (double)Row["door_z"]), (int)Row["door_dir"], (ClubSubscriptionLevel)(int.Parse(Row["subscription_requirement"].ToString())), (int)Row["max_users"])); } } }
public static void LoadTopics(SqlDatabaseClient MySqlClient) { int i = 0; lock (mTopics) { mTopics.Clear(); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT id,category,title,body,priority FROM help_topics ORDER BY id ASC"); foreach (DataRow Row in Table.Rows) { mTopics.Add((uint)Row["id"], new HelpTopic((uint)Row["id"], (uint)Row["category"], (string)Row["title"], (string)Row["body"], (HelpTopicPriority)((int.Parse(Row["priority"].ToString()))))); i++; } } Output.WriteLine("Loaded " + i + " help topic(s).", OutputLevel.DebugInformation); }
public static void RebuildCache(SqlDatabaseClient MySqlClient) { lock (mBadges) { mBadges.Clear(); mRightSets.Clear(); DataTable BadgeTable = MySqlClient.ExecuteQueryTable("SELECT id,code,rights_sets FROM badge_definitions"); DataTable RightsTable = MySqlClient.ExecuteQueryTable("SELECT set_id,right_id FROM rights"); foreach (DataRow Row in BadgeTable.Rows) { List<uint> Sets = new List<uint>(); string[] SetBits = ((string)Row["rights_sets"]).Split(','); foreach (string SetBit in SetBits) { uint Set = 0; uint.TryParse(SetBit, out Set); if (Set > 0) { Sets.Add(Set); } } mBadges.Add((uint)Row["id"], new Badge((uint)Row["id"], (string)Row["code"], Sets)); } foreach (DataRow Row in RightsTable.Rows) { uint SetId = (uint)Row["set_id"]; if (!mRightSets.ContainsKey(SetId)) { mRightSets.Add(SetId, new List<string>()); } mRightSets[SetId].Add((string)Row["right_id"]); } } }
public static void LoadCategories(SqlDatabaseClient MySqlClient) { int i = 0; lock (mTopics) { mCategories.Clear(); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT id,name FROM help_categories ORDER BY id ASC"); foreach (DataRow Row in Table.Rows) { mCategories.Add((uint)Row["id"], new HelpCategory((uint)Row["id"], (string)Row["name"])); i++; } } Output.WriteLine("Loaded " + i + " help categories(s).", OutputLevel.DebugInformation); }
public static void RefreshCatalogData(SqlDatabaseClient MySqlClient, bool NotifyUsers = true) { int CountLoaded = 0; lock (mPages) { mCatalogItems.Clear(); mCatalogItemsIdIndex.Clear(); mCatalogItemsNameIndex.Clear(); mPages.Clear(); mClubOffers.Clear(); mPages.Add(-1, new CatalogPage(-1, 0, string.Empty, 0, 0, string.Empty, true, true, string.Empty, null, null, new List<CatalogItem>())); // root category MySqlClient.SetParameter("enabled", "1"); DataTable ItemTable = MySqlClient.ExecuteQueryTable("SELECT * FROM catalog_items WHERE enabled = @enabled ORDER BY name ASC"); foreach (DataRow Row in ItemTable.Rows) { int PageId = (int)Row["page_id"]; if (!mCatalogItems.ContainsKey(PageId)) { mCatalogItems[PageId] = new List<CatalogItem>(); } CatalogItem Item = new CatalogItem((uint)Row["id"], (uint)Row["base_id"], (string)Row["name"], (int)Row["cost_credits"], (int)Row["cost_pixels"], (int)Row["amount"], (string)Row["preset_flags"], (int)Row["club_restriction"]); if (Item.Definition == null) { Output.WriteLine("Warning: Catalog item " + (uint)Row["id"] + " has an invalid base_id reference.", OutputLevel.Warning); continue; } mCatalogItems[PageId].Add(Item); mCatalogItemsIdIndex[Item.Id] = Item; mCatalogItemsNameIndex[Item.DisplayName] = Item; } MySqlClient.SetParameter("enabled", "1"); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM catalog WHERE enabled = @enabled ORDER BY order_num ASC"); foreach (DataRow Row in Table.Rows) { List<string> PageStrings1 = new List<string>(); List<string> PageStrings2 = new List<string>(); foreach (string String in Row["page_strings_1"].ToString().Split('|')) PageStrings1.Add(String); foreach (string String in Row["page_strings_2"].ToString().Split('|')) PageStrings2.Add(String); int Id = (int)Row["id"]; mPages.Add(Id, new CatalogPage((int)Row["id"], (int)Row["parent_id"], (string)Row["title"], (int)Row["icon"], (int)Row["color"], (string)Row["required_right"], (Row["visible"].ToString() == "1"), (Row["dummy_page"].ToString() == "1"), (string)Row["template"], PageStrings1, PageStrings2, mCatalogItems.ContainsKey(Id) ? mCatalogItems[Id] : new List<CatalogItem>())); CountLoaded++; } DataTable ClubTable = MySqlClient.ExecuteQueryTable("SELECT * FROM catalog_subscriptions"); foreach (DataRow Row in ClubTable.Rows) { CatalogClubOfferType OfferType = CatalogClubOfferType.Basic; switch ((string)Row["type"]) { case "vip": OfferType = CatalogClubOfferType.Vip; break; case "upgrade": OfferType = CatalogClubOfferType.VipUpgrade; break; } mClubOffers.Add((uint)Row["id"], new CatalogClubOffer((uint)Row["id"], (string)Row["name"], (int)Row["cost_credits"], (int)Row["length_days"], OfferType)); } } Output.WriteLine("Loaded " + CountLoaded + " catalog page(s).", OutputLevel.DebugInformation); if (NotifyUsers) { SessionManager.BroadcastPacket(CatalogUpdatedNotificationComposer.Compose()); } }
public static void ReloadQuests(SqlDatabaseClient MySqlClient) { lock (mSyncRoot) { mQuests.Clear(); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM quests"); foreach (DataRow Row in Table.Rows) { mQuests.Add((uint)Row["id"], new Quest((uint)Row["id"], (string)Row["category"], (int)Row["series_number"], (QuestType)((int)Row["goal_type"]), (uint)Row["goal_data"], (string)Row["name"], (int)Row["reward"], (string)Row["data_bit"])); } } }
public static void LoadBotDefinitions(SqlDatabaseClient MySqlClient) { mBotDefinitions.Clear(); mDefinedResponses.Clear(); mDefinedSpeech.Clear(); mPetHandlerIndex.Clear(); DataTable ResponseTable = MySqlClient.ExecuteQueryTable("SELECT bot_id,triggers,responses,response_serve_id FROM bot_responses"); foreach (DataRow Row in ResponseTable.Rows) { BotResponse Response = new BotResponse(Row["triggers"].ToString().Split('|').ToList(), Row["responses"].ToString().Split('|').ToList(), (int)Row["response_serve_id"]); if (!mDefinedResponses.ContainsKey((uint)Row["bot_id"])) { mDefinedResponses.Add((uint)Row["bot_id"], new List<BotResponse>()); } mDefinedResponses[(uint)Row["bot_id"]].Add(Response); } DataTable SpeechTable = MySqlClient.ExecuteQueryTable("SELECT bot_id,message FROM bots_speech"); foreach (DataRow Row in SpeechTable.Rows) { if (!mDefinedSpeech.ContainsKey((uint)Row["bot_id"])) { mDefinedSpeech.Add((uint)Row["bot_id"], new List<string>()); } mDefinedSpeech[(uint)Row["bot_id"]].Add((string)Row["message"]); } MySqlClient.SetParameter("enabled", "1"); DataTable BotTable = MySqlClient.ExecuteQueryTable("SELECT * FROM bots WHERE enabled = @enabled"); foreach (DataRow Row in BotTable.Rows) { BotWalkMode WMode = BotWalkMode.STAND; switch ((string)Row["walk_mode"]) { case "freeroam": WMode = BotWalkMode.FREEROAM; break; case "defined": WMode = BotWalkMode.SPECIFIED_RANGE; break; } List<Vector2> DefinedPositions = new List<Vector2>(); string[] DefPosBits = Row["pos_defined_range"].ToString().Split(';'); foreach (string DefPosBit in DefPosBits) { DefinedPositions.Add(Vector2.FromString(DefPosBit)); } Bot Bot = new Bot((uint)Row["id"], (uint)Row["id"], (string)Row["ai_type"], (string)Row["name"], (string)Row["look"], (string)Row["motto"], (uint)Row["room_id"], Vector3.FromString((string)Row["pos_start"]), Vector2.FromString((string)Row["pos_serve"]), DefinedPositions, WMode, (Row["kickable"].ToString() == "1"), (int)Row["rotation"], (mDefinedResponses.ContainsKey((uint)Row["id"]) ? mDefinedResponses[(uint)Row["id"]] : new List<BotResponse>()), (int)Row["effect"], (int)Row["response_distance"]); mBotDefinitions.Add((uint)Row["id"], Bot); int PetHandler = (int)Row["pet_type_handler_id"]; if ((string)Row["ai_type"] == "pet") { mPetHandlerIndex.Add(PetHandler, Bot); } } }
public void ReloadCache(SqlDatabaseClient MySqlClient, AchievementCache UserAchievementCache) { Dictionary<int, Badge> EquippedBadges = new Dictionary<int, Badge>(); List<Badge> StaticBadges = new List<Badge>(); Dictionary<string, Badge> AchievementBadges = new Dictionary<string, Badge>(); List<string> IndexCache = new List<string>(); MySqlClient.SetParameter("userid", mUserId); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT badge_code,slot_id,source_type,source_data FROM user_badges WHERE user_id = @userid"); foreach (DataRow Row in Table.Rows) { string SourceType = Row["source_type"].ToString(); string SourceData = Row["source_data"].ToString(); Badge BadgeToEquip = null; if (SourceType == "static") { BadgeToEquip = new Badge(Row["badge_code"].ToString()); StaticBadges.Add(BadgeToEquip); } else if (SourceType == "achievement") { if (AchievementBadges.ContainsKey(SourceData)) { continue; } UserAchievement UserAchievement = UserAchievementCache.GetAchievementData(SourceData); if (UserAchievement == null || UserAchievement.Level < 1) { MySqlClient.SetParameter("userid", mUserId); MySqlClient.SetParameter("badgecode", Row["badge_code"].ToString()); MySqlClient.ExecuteNonQuery("DELETE FROM user_badges WHERE user_id = @userid AND badge_id = @badgeid"); continue; } string Code = UserAchievement.GetBadgeCodeForLevel(); BadgeToEquip = new Badge(Code); AchievementBadges.Add(SourceData, BadgeToEquip); } if (BadgeToEquip != null) { int SlotId = (int)Row["slot_id"]; if (!EquippedBadges.ContainsKey(SlotId) && SlotId >= 1 && SlotId <= 5) { EquippedBadges.Add(SlotId, BadgeToEquip); } IndexCache.Add(BadgeToEquip.Code); } } lock (mSyncRoot) { mEquippedBadges = EquippedBadges; mStaticBadges = StaticBadges; mAchievementBadges = AchievementBadges; mIndexCache = IndexCache; } }
public static void ReloadAchievements(SqlDatabaseClient MySqlClient) { lock (mSyncRoot) { mAchievements.Clear(); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM achievements"); foreach (DataRow Row in Table.Rows) { string Group = (string)Row["group_name"]; if (!mAchievements.ContainsKey(Group)) { mAchievements.Add(Group, new Achievement((uint)Row["id"], Group, (string)Row["category"])); } mAchievements[Group].AddLevel(new AchievementLevel((int)Row["level"], (int)Row["reward_pixels"], (int)Row["reward_points"], (int)Row["progress_needed"])); } } }
public void ReloadCache(SqlDatabaseClient MySqlClient) { lock (mInner) { mInner.Clear(); MySqlClient.SetParameter("userid", mCharacterId); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM items WHERE user_id = @userid"); foreach (DataRow Row in Table.Rows) { Item Item = ItemFactory.CreateFromDatabaseRow(Row); if (Item == null || Item.Definition == null || Item.InSoundManager) { continue; } if (Item.PendingExpiration && Item.ExpireTimeLeft <= 0) { Item.RemovePermanently(MySqlClient); continue; } mInner.Add(Item.Id, Item); } } }
public static void ReloadOfficialItems(SqlDatabaseClient MySqlClient) { int NumberLoaded = 0; lock (mOfficialItems) { mOfficialItems.Clear(); MySqlClient.SetParameter("enabled", "1"); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM navigator_frontpage WHERE enabled = @enabled ORDER BY order_num ASC"); foreach (DataRow Row in Table.Rows) { mOfficialItems.Add(new NavigatorOfficialItem((uint)Row["id"], (uint)Row["parent_id"], (uint)Row["room_id"], (Row["is_category"].ToString() == "1"), (Row["display_type"].ToString() == "details" ? NavigatorOfficialItemDisplayType.Detailed : NavigatorOfficialItemDisplayType.Banner), (string)Row["name"], (string)Row["descr"], (Row["image_type"].ToString() == "internal" ? NavigatorOfficialItemImageType.Internal : NavigatorOfficialItemImageType.External), (string)Row["image_src"], (string)Row["banner_label"], (Row["category_autoexpand"].ToString() == "1"))); NumberLoaded++; } } Output.WriteLine("Loaded " + NumberLoaded + " navigator frontpage item(s).", OutputLevel.DebugInformation); }
public CharacterInfo(SqlDatabaseClient MySqlClient, uint SessionId, uint Id, string Username, uint Rank, bool Premium, string RealName, string Figure, CharacterGender Gender, string Motto, int Credits, int ActivityPoints, double ActivityPointsLastUpdate, bool PrivacyAcceptFriends, uint HomeRoom, int Score, int ConfigVolume, int ModerationTickets, int ModerationTicketsAbusive, double ModerationTicketCooldown, int ModerationBans, int ModerationCautions, double TimestampLastOnline, double TimestampRegistered, int RespectPoints, int RespectCreditHuman, int RespectCreditPets, double ModerationMutedUntil) { mSessionId = SessionId; mId = Id; mUsername = Username; mRank = Rank; mPremium = Premium; mRealName = RealName; mFigure = Figure; mGender = Gender; mMotto = Motto; mCredits = Credits; mActivityPoints = ActivityPoints; mPrivacyAcceptFriends = PrivacyAcceptFriends; mHomeRoom = HomeRoom; mScore = Score; mConfigVolume = ConfigVolume; mRespectPoints = RespectPoints; mRespectCreditHuman = RespectCreditHuman; mRespectCreditPets = RespectCreditPets; mModerationTickets = ModerationTickets; mModerationTicketsAbusive = ModerationTicketsAbusive; mModerationTicketsCooldown = ModerationTicketCooldown; mModerationCautions = ModerationCautions; mModerationBans = ModerationBans; mModerationMutedUntil = ModerationMutedUntil; mCacheAge = UnixTimestamp.GetCurrent(); mTimestampLastActivityPointsUpdate = ActivityPointsLastUpdate; mTimestampLastOnline = TimestampLastOnline; mTimestampRegistered = TimestampRegistered; mWardrobe = new Dictionary<int, WardrobeItem>(); mTags = new List<string>(); if (MySqlClient != null) { MySqlClient.SetParameter("userid", mId); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM wardrobe WHERE user_id = @userid LIMIT 10"); foreach (DataRow Row in Table.Rows) { mWardrobe.Add((int)Row["slot_id"], new WardrobeItem((string)Row["figure"], (Row["gender"].ToString().ToLower() == "m" ? CharacterGender.Male : CharacterGender.Female))); } MySqlClient.SetParameter("userid", mId); DataTable TagsTable = MySqlClient.ExecuteQueryTable("SELECT * FROM tags WHERE user_id = @userid"); foreach (DataRow Row in TagsTable.Rows) { mTags.Add((string)Row["tag"]); } } }