/// <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); }
/// <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 itemsTable = dbClient.GetTable(); dbClient.SetQuery("SELECT * FROM catalog_pages ORDER BY id ASC"); DataTable pagesTable = dbClient.GetTable(); dbClient.SetQuery("SELECT * FROM catalog_ecotron_items ORDER BY reward_level ASC"); DataTable ecotronItems = dbClient.GetTable(); dbClient.SetQuery("SELECT * FROM catalog_items WHERE special_name LIKE 'HABBO_CLUB_VIP%'"); DataTable habboClubItems = dbClient.GetTable(); if (itemsTable != null) { foreach (DataRow dataRow in itemsTable.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 (pagesTable != null) { foreach (DataRow dataRow2 in pagesTable.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 (ecotronItems != null) { foreach (DataRow dataRow3 in ecotronItems.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 (habboClubItems != null) { foreach (DataRow row in habboClubItems.Rows) HabboClubItems.Add(new CatalogItem(row, row.IsNull("special_name") ? "Habbo VIP" : (string) row["special_name"])); } }