/// <summary> /// Composes the item. /// </summary> /// <param name="item">The item.</param> /// <param name="message">The message.</param> internal static void ComposeItem(CatalogItem item, ServerMessage message) { message.AppendInteger(item.Id); string displayName = item.Name; if (PetTypeManager.ItemIsPet(item.Name)) { displayName = PetTypeManager.GetHabboPetType(item.Name); } message.AppendString(displayName, true); message.AppendBool(false); message.AppendInteger(item.CreditsCost); if (item.DiamondsCost > 0) { message.AppendInteger(item.DiamondsCost); message.AppendInteger(105); } else { message.AppendInteger(item.DucketsCost); message.AppendInteger(0); } message.AppendBool(item.GetFirstBaseItem().AllowGift); switch (item.Name) { case "g0 group_product": message.AppendInteger(0); break; case "room_ad_plus_badge": message.AppendInteger(1); message.AppendString("b"); message.AppendString("RADZZ"); break; default: if (item.Name.StartsWith("builders_club_addon_") || item.Name.StartsWith("builders_club_time_")) { message.AppendInteger(0); } else if (item.Badge == "") { message.AppendInteger(item.Items.Count); } else { message.AppendInteger(item.Items.Count + 1); message.AppendString("b"); message.AppendString(item.Badge); } break; } foreach (Item baseItem in item.Items.Keys) { if (item.Name == "g0 group_product" || item.Name.StartsWith("builders_club_addon_") || item.Name.StartsWith("builders_club_time_")) { break; } if (item.Name == "room_ad_plus_badge") { message.AppendString(""); message.AppendInteger(0); } else { message.AppendString(baseItem.Type.ToString()); message.AppendInteger(baseItem.SpriteId); if (item.Name.Contains("wallpaper_single") || item.Name.Contains("floor_single") || item.Name.Contains("landscape_single")) { string[] array = item.Name.Split('_'); message.AppendString(array[2]); } else if (item.Name.StartsWith("bot_") || baseItem.InteractionType == Interaction.MusicDisc || item.GetFirstBaseItem().Name == "poster") { message.AppendString(item.ExtraData); } else if (item.Name.StartsWith("poster_")) { string[] array2 = item.Name.Split('_'); message.AppendString(array2[1]); } else if (item.Name.StartsWith("poster ")) { string[] array3 = item.Name.Split(' '); message.AppendString(array3[1]); } else if (item.SongId > 0u && baseItem.InteractionType == Interaction.MusicDisc) { message.AppendString(item.ExtraData); } else { message.AppendString(string.Empty); } message.AppendInteger(item.Items[baseItem]); message.AppendBool(item.IsLimited); if (!item.IsLimited) { continue; } message.AppendInteger(item.LimitedStack); message.AppendInteger(item.LimitedStack - item.LimitedSelled); } } message.AppendInteger(item.ClubOnly ? 1 : 0); if (item.IsLimited || item.FirstAmount != 1) { message.AppendBool(false); return; } message.AppendBool(item.HaveOffer && !item.IsLimited); }
internal static void ComposeItem(CatalogItem Item, ServerMessage Message) { Message.AppendUInt(Item.Id); Message.AppendString(Item.Name); Message.AppendBoolean(false); Message.AppendInt32(Item.CreditsCost); if (Item.BelCreditsCost > 0) { Message.AppendInt32(Item.BelCreditsCost); Message.AppendInt32(105); } else { if (Item.LoyaltyCost > 0) { Message.AppendInt32(Item.LoyaltyCost); Message.AppendInt32(105); } else { Message.AppendInt32(Item.DucketsCost); Message.AppendInt32(0); } } Message.AppendBoolean(Item.GetFirstBaseItem().AllowGift); checked { if (Item.Name == "g0 group_product") { Message.AppendInt32(0); } else { if (Item.Badge == "") { Message.AppendInt32(Item.Items.Count); } else { if (Item.Name == "room_ad_plus_badge") { Message.AppendInt32(1); } else { Message.AppendInt32(Item.Items.Count + 1); } Message.AppendString("b"); Message.AppendString(Item.Badge); } } foreach (uint current in Item.Items.Keys) { if (Item.Name == "g0 group_product") { break; } if (Item.Name != "room_ad_plus_badge") { Message.AppendString(Item.GetBaseItem(current).Type.ToString()); Message.AppendInt32(Item.GetBaseItem(current).SpriteId); if (Item.Name.Contains("wallpaper_single") || Item.Name.Contains("floor_single") || Item.Name.Contains("landscape_single")) { string[] array = Item.Name.Split('_'); Message.AppendString(array[2]); } else { if (Item.Name.StartsWith("bot_") || Item.GetBaseItem(current).InteractionType == InteractionType.musicdisc) { Message.AppendString(Item.ExtraData); } else { if (Item.Name.StartsWith("poster_")) { string[] array2 = Item.Name.Split('_'); Message.AppendString(array2[1]); } else { if (Item.Name.StartsWith("poster ")) { string[] array3 = Item.Name.Split(' '); Message.AppendString(array3[1]); } else { if (Item.songID > 0u && Item.GetBaseItem(current).InteractionType == InteractionType.musicdisc) { Message.AppendString(Item.ExtraData); } else { Message.AppendString(string.Empty); } } } } } Message.AppendInt32(Item.Items[current]); Message.AppendBoolean(Item.IsLimited); if (Item.IsLimited) { Message.AppendInt32(Item.LimitedStack); Message.AppendInt32(Item.LimitedStack - Item.LimitedSelled); } } else { Message.AppendString(""); Message.AppendInt32(0); } } Message.AppendInt32(Item.ClubOnly ? 1 : 0); if (Item.IsLimited || Item.FirstAmount != 1) { Message.AppendBoolean(false); return; } Message.AppendBoolean(Item.HaveOffer && !Item.IsLimited); } }
/// <summary> /// Composes the item. /// </summary> /// <param name="item">The item.</param> /// <param name="message">The message.</param> internal static void ComposeItem(CatalogItem item, ServerMessage message) { message.AppendInteger(item.Id); message.AppendString(item.Name, true); message.AppendBool(false); message.AppendInteger(item.CreditsCost); if (item.DiamondsCost > 0) { message.AppendInteger(item.DiamondsCost); message.AppendInteger(105); } else { message.AppendInteger(item.DucketsCost); message.AppendInteger(0); } message.AppendBool(item.GetFirstBaseItem().AllowGift); switch (item.Name) { case "g0 group_product": message.AppendInteger(0); break; case "room_ad_plus_badge": message.AppendInteger(1); message.AppendString("b"); message.AppendString("RADZZ"); break; default: if (item.Name.StartsWith("builders_club_addon_") || item.Name.StartsWith("builders_club_time_")) { message.AppendInteger(0); } else if (item.Badge == "") { message.AppendInteger(item.Items.Count); } else { message.AppendInteger(item.Items.Count + 1); message.AppendString("b"); message.AppendString(item.Badge); } break; } foreach (var baseItem in item.Items.Keys) { if (item.Name == "g0 group_product" || item.Name.StartsWith("builders_club_addon_") || item.Name.StartsWith("builders_club_time_")) { break; } if (item.Name == "room_ad_plus_badge") { message.AppendString(""); message.AppendInteger(0); } else { message.AppendString(baseItem.Type.ToString()); message.AppendInteger(baseItem.SpriteId); if (item.Name.Contains("wallpaper_single") || item.Name.Contains("floor_single") || item.Name.Contains("landscape_single")) { var array = item.Name.Split('_'); message.AppendString(array[2]); } else if (item.Name.StartsWith("bot_") || baseItem.InteractionType == Interaction.MusicDisc || item.GetFirstBaseItem().Name == "poster") { message.AppendString(item.ExtraData); } else if (item.Name.StartsWith("poster_")) { var array2 = item.Name.Split('_'); message.AppendString(array2[1]); } else if (item.Name.StartsWith("poster ")) { var array3 = item.Name.Split(' '); message.AppendString(array3[1]); } else if (item.SongId > 0u && baseItem.InteractionType == Interaction.MusicDisc) { message.AppendString(item.ExtraData); } else { message.AppendString(string.Empty); } message.AppendInteger(item.Items[baseItem]); message.AppendBool(item.IsLimited); if (!item.IsLimited) continue; message.AppendInteger(item.LimitedStack); message.AppendInteger(item.LimitedStack - item.LimitedSelled); } } message.AppendInteger(item.ClubOnly ? 1 : 0); if (item.IsLimited || item.FirstAmount != 1) { message.AppendBool(false); return; } message.AppendBool(item.HaveOffer && !item.IsLimited && !item.Name.StartsWith("bot_")); }
/// <summary> /// Initializes the specified database client. /// </summary> /// <param name="dbClient">The database client.</param> internal void Initialize(IQueryAdapter dbClient) { Categories = new HybridDictionary(); Offers = new HybridDictionary(); FlatOffers = new Dictionary <uint, uint>(); EcotronRewards = new List <EcotronReward>(); EcotronLevels = new List <int>(); HabboClubItems = new List <CatalogItem>(); dbClient.SetQuery("SELECT * FROM catalog_items ORDER BY id ASC"); DataTable table = dbClient.GetTable(); dbClient.SetQuery("SELECT * FROM catalog_pages ORDER BY id ASC"); DataTable table2 = dbClient.GetTable(); dbClient.SetQuery("SELECT * FROM catalog_ecotron_items ORDER BY reward_level ASC"); DataTable table3 = dbClient.GetTable(); dbClient.SetQuery("SELECT * FROM catalog_items WHERE special_name LIKE 'HABBO_CLUB_VIP%'"); DataTable table4 = dbClient.GetTable(); if (table != null) { foreach (DataRow dataRow in table.Rows) { if (string.IsNullOrEmpty(dataRow["item_names"].ToString()) || string.IsNullOrEmpty(dataRow["amounts"].ToString())) { continue; } string source = dataRow["item_names"].ToString(); string firstItem = dataRow["item_names"].ToString().Split(';')[0]; Item item; if (!Yupi.GetGame().GetItemManager().GetItem(firstItem, out item)) { continue; } uint num = !source.Contains(';') ? item.FlatId : 0; if (!dataRow.IsNull("special_name")) { item.PublicName = (string)dataRow["special_name"]; } CatalogItem catalogItem = new CatalogItem(dataRow, item.PublicName); if (catalogItem.GetFirstBaseItem() == null) { continue; } Offers.Add(catalogItem.Id, catalogItem); if (!FlatOffers.ContainsKey(num)) { FlatOffers.Add(num, catalogItem.Id); } } } if (table2 != null) { foreach (DataRow dataRow2 in table2.Rows) { bool visible = false; bool enabled = false; if (dataRow2["visible"].ToString() == "1") { visible = true; } if (dataRow2["enabled"].ToString() == "1") { enabled = true; } Categories.Add((uint)dataRow2["id"], new CatalogPage((uint)dataRow2["id"], short.Parse(dataRow2["parent_id"].ToString()), (string)dataRow2["code_name"], (string)dataRow2["caption"], visible, enabled, false, (uint)dataRow2["min_rank"], (int)dataRow2["icon_image"], (string)dataRow2["page_layout"], (string)dataRow2["page_headline"], (string)dataRow2["page_teaser"], (string)dataRow2["page_special"], (string)dataRow2["page_text1"], (string)dataRow2["page_text2"], (string)dataRow2["page_text_details"], (string)dataRow2["page_text_teaser"], (string)dataRow2["page_link_description"], (string)dataRow2["page_link_pagename"], (int)dataRow2["order_num"], ref Offers)); } } if (table3 != null) { foreach (DataRow dataRow3 in table3.Rows) { EcotronRewards.Add(new EcotronReward(Convert.ToUInt32(dataRow3["display_id"]), Convert.ToUInt32(dataRow3["item_id"]), Convert.ToUInt32(dataRow3["reward_level"]))); if (!EcotronLevels.Contains(Convert.ToInt16(dataRow3["reward_level"]))) { EcotronLevels.Add(Convert.ToInt16(dataRow3["reward_level"])); } } } if (table4 != null) { foreach (DataRow row in table4.Rows) { HabboClubItems.Add(new CatalogItem(row, row.IsNull("special_name") ? "Habbo VIP" : (string)row["special_name"])); } } }
/// <summary> /// Initializes the specified database client. /// </summary> /// <param name="dbClient">The database client.</param> internal void Initialize(IQueryAdapter dbClient) { Categories = new HybridDictionary(); Offers = new HybridDictionary(); FlatOffers = new Dictionary<int, uint>(); EcotronRewards = new List<EcotronReward>(); EcotronLevels = new List<int>(); HabboClubItems = new List<CatalogItem>(); dbClient.SetQuery("SELECT * FROM catalog_items ORDER BY order_num ASC"); var table = dbClient.GetTable(); dbClient.SetQuery("SELECT * FROM catalog_pages ORDER BY order_num ASC"); var table2 = dbClient.GetTable(); dbClient.SetQuery("SELECT * FROM catalog_ecotron ORDER BY reward_level ASC"); var table3 = dbClient.GetTable(); dbClient.SetQuery("SELECT * FROM catalog_items WHERE specialName LIKE 'HABBO_CLUB_VIP%'"); var table4 = dbClient.GetTable(); if (table != null) { foreach (DataRow dataRow in table.Rows) { if (string.IsNullOrEmpty(dataRow["item_names"].ToString()) || string.IsNullOrEmpty(dataRow["amounts"].ToString())) continue; var source = dataRow["item_names"].ToString(); var firstItem = dataRow["item_names"].ToString().Split(';')[0]; Item item; if (!AzureEmulator.GetGame().GetItemManager().GetItem(firstItem, out item)) continue; var num = !source.Contains(';') ? item.FlatId : -1; if (!dataRow.IsNull("specialName")) item.PublicName = (string)dataRow["specialName"]; var catalogItem = new CatalogItem(dataRow, item.PublicName); if (catalogItem.GetFirstBaseItem() == null) continue; Offers.Add(catalogItem.Id, catalogItem); if (num != -1 && !FlatOffers.ContainsKey(num)) FlatOffers.Add(num, catalogItem.Id); } } if (table2 != null) { foreach (DataRow dataRow2 in table2.Rows) { var visible = false; var enabled = false; var comingSoon = false; if (dataRow2["visible"].ToString() == "1") visible = true; if (dataRow2["enabled"].ToString() == "1") enabled = true; Categories.Add(Convert.ToUInt32(dataRow2["id"]), new CatalogPage(Convert.ToUInt32(dataRow2["id"]), short.Parse(dataRow2["parent_id"].ToString()), (string)dataRow2["code_name"], (string)dataRow2["caption"], visible, enabled, comingSoon, Convert.ToUInt32(dataRow2["min_rank"]), (int)dataRow2["icon_image"], (string)dataRow2["page_layout"], (string)dataRow2["page_headline"], (string)dataRow2["page_teaser"], (string)dataRow2["page_special"], (string)dataRow2["page_text1"], (string)dataRow2["page_text2"], (string)dataRow2["page_text_details"], (string)dataRow2["page_text_teaser"], (string)dataRow2["page_link_description"], (string)dataRow2["page_link_pagename"], (int)dataRow2["order_num"], ref Offers)); } } if (table3 != null) { foreach (DataRow dataRow3 in table3.Rows) { EcotronRewards.Add(new EcotronReward(Convert.ToUInt32(dataRow3["display_id"]), Convert.ToUInt32(dataRow3["item_id"]), Convert.ToUInt32(dataRow3["reward_level"]))); if (!EcotronLevels.Contains(Convert.ToInt16(dataRow3["reward_level"]))) EcotronLevels.Add(Convert.ToInt16(dataRow3["reward_level"])); } } if (table4 != null) { foreach (DataRow row in table4.Rows) { HabboClubItems.Add(new CatalogItem(row, row.IsNull("specialName") ? "Habbo VIP" : (string)row["specialName"])); } } }