using System; using System.Data; using System.Text; using System.Collections; using System.Threading; using Ion.Storage; using System.Collections.Generic; namespace Holo.Managers { /// /// Manager for catalogue page caching, catalogue item templates, catalogue purchase handling and few other catalogue related tasks. /// public static class catalogueManager { private static Hashtable cataloguePages; private static Hashtable itemCache; private static Dictionary CatalogueNames; /// /// Initializes the catalogue manager, (re)caching all the pages and item templates. /// public static void Init(bool Update) { Out.WriteLine("Starting caching of catalogue + items..."); DataTable dCol; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dCol = dbClient.getTable("SELECT indexid, indexname FROM catalogue_pages ORDER BY indexid"); } cataloguePages = new Hashtable(); itemCache = new Hashtable(); CatalogueNames = new Dictionary(); foreach (DataRow dRow in dCol.Rows) { int ID = Convert.ToInt32(dRow["indexid"]); CatalogueNames.Add(ID, Convert.ToString(dRow["indexname"])); cachePage(ID); } cachePage(Convert.ToInt32(-1)); Out.WriteLine("Successfully cached " + cataloguePages.Count + " catalogue pages and " + itemCache.Count + " item templates!"); CachePages(); if (Update) Thread.CurrentThread.Abort(); } /// /// Caches a specified catalogue page, plus the items on this page. /// /// The ID of the page to cache. If -1 is specified, all the items that aren't on a page are cached. private static void cachePage(int pageID) { DataRow dRow; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dRow = dbClient.getRow("SELECT indexname,minrank,displayname,style_layout,img_header,img_side,label_description,label_misc,label_moredetails,page_brother,content_else,header_else FROM catalogue_pages WHERE indexid = '" + pageID + "'"); } if (pageID > 0 && dRow.Table.Rows.Count == 0) { return; } object[] pageObject = dRow.ItemArray; string[] pageData = new string[pageObject.Length]; for (int a = 0; a < pageData.Length; a++) pageData[a] = pageObject[a].ToString(); string pageIndexName = ""; StringBuilder pageBuilder = new System.Text.StringBuilder(); cataloguePage objPage = new cataloguePage(); if (pageID > 0) { pageIndexName = pageData[0]; objPage.displayName = pageData[2]; objPage.minRank = Convert.ToByte(bool.Parse(pageData[1])); if (pageData[10] != "") { // It has a custom content, set it pageBuilder.Append(pageData[10]); objPage.pageData = pageBuilder.ToString(); cataloguePages.Add(pageIndexName, objPage); return; } if (pageData[11] != "") { // It has a custom content, set it pageBuilder.Append(pageData[11]); goto doFurnitures; } // Add the required fields for catalogue page (indexname, showname, page layout style (boxes etc)) pageBuilder.Append(pageData[3] + Convert.ToChar(2)); if (pageData[4] != "") // If there's a headline image set, add it pageBuilder.Append("K" + pageData[4] + Convert.ToChar(2)); if (pageData[5] != "") // If there is/are side image(s) set, add it/them pageBuilder.Append(pageData[5] + Convert.ToChar(2) + Convert.ToChar(2)); if (pageData[6] != "") // If there's a description set, add it pageBuilder.Append("K" + pageData[6].Replace("
", Convert.ToString(Convert.ToChar(13))) + Convert.ToChar(2)); if (pageData[7] != "") // If the misc + more details additions field is not blank pageBuilder.Append(pageData[8].Replace("
", Convert.ToString(Convert.ToChar(13))) + Convert.ToChar(2)); pageBuilder.Append(pageData[7].Replace("
", Convert.ToString(Convert.ToChar(13))) + Convert.ToChar(2)); if (pageData[9] != "") // Add the indexname of the 'brother page' (multi page catalogue pages) { string[] miscDetail = pageData[9].Split(Convert.ToChar(2)); for (int m = 0; m < miscDetail.Length; m++) pageBuilder.Append(miscDetail[m].Replace("
", Convert.ToString(Convert.ToChar(13))) + Convert.ToChar(2)); } } doFurnitures: DataTable dTable; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dTable = dbClient.getTable("SELECT tid, typeid, catalogue_cost_credits, catalogue_cost_pixels, door, tradeable, recycleable, name_cct, top, status_max, next_to_required, rights_required, drink_ids FROM catalogue_items WHERE catalogue_id_page = '" + pageID + "' ORDER BY catalogue_id_index ASC"); } int count = dTable.Rows.Count; int[] itemTemplateIDs = new int[count]; int[] itemTypeIDs = new int[count]; int[] itemLengths = new int[count]; int[] itemWidths = new int[count]; int[] itemCosts_Credits = new int[count]; int[] itemCosts_Pixels = new int[count]; int[] itemDoorFlags = new int[count]; int[] itemTradeableFlags = new int[count]; int[] itemRecycleableFlags = new int[count]; int[] statusMax = new int[count]; int[] nexttoRequired = new int[count]; int[] rightsRequired = new int[count]; string[] strPoster = new string[count]; string[] itemNames = new string[count]; string[] itemDescs = new string[count]; string[] itemCCTs = new string[count]; string[] itemTopHs = new string[count]; string[] itemDrinks = new string[count]; int[] itemID = new int[count]; int i = 0; foreach (DataRow dbRow in dTable.Rows) { itemTemplateIDs[i] = Convert.ToInt32(dbRow["tid"]); itemTypeIDs[i] = Convert.ToInt32(dbRow["typeid"]); itemCosts_Credits[i] = Convert.ToInt32(dbRow["catalogue_cost_credits"]); itemCosts_Pixels[i] = Convert.ToInt32(dbRow["catalogue_cost_pixels"]); itemDoorFlags[i] = Convert.ToInt32(dbRow["door"]); itemTradeableFlags[i] = Convert.ToInt32(dbRow["tradeable"]); itemRecycleableFlags[i] = Convert.ToInt32(dbRow["recycleable"]); itemCCTs[i] = Convert.ToString(dbRow["name_cct"]); itemTopHs[i] = Convert.ToString(dbRow["top"]); statusMax[i] = Convert.ToInt32(dbRow["status_max"]); nexttoRequired[i] = Convert.ToInt32(dbRow["next_to_required"]); rightsRequired[i] = Convert.ToInt32(dbRow["rights_required"]); itemDrinks[i] = Convert.ToString(dbRow["drink_ids"]); string[] nameCheck = itemCCTs[i].Split(' '); using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { strPoster[i] = ""; if (itemCCTs[i].Contains("wallpaper ") == true) { strPoster[i] = itemCCTs[i].Replace("wallpaper ", ""); itemCCTs[i] = "wallpaper"; } else if (itemCCTs[i].Contains("landscape ") == true) { strPoster[i] = itemCCTs[i].Replace("landscape ", ""); itemCCTs[i] = "landscape"; } if (nameCheck[0] == "poster ") { itemCCTs[i] = nameCheck[0]; strPoster[i] = nameCheck[1]; } itemID[i] = itemTemplateIDs[i]; if (itemCCTs[i] == "wallpaper") { itemCCTs[i] = "wallpaper " + strPoster[i]; } else if (itemCCTs[i] == "poster") { itemCCTs[i] += " " + nameCheck[1]; } else if (itemCCTs[i] == "landscape") { itemCCTs[i] = "landscape " + strPoster[i]; } if (itemCCTs[i].Contains("avatar_effect")) { itemLengths[i] = 0; itemWidths[i] = 0; } else { // string itemWidth = dbClient.getString("SELECT width FROM dynamic_items WHERE name_cct = '" + itemCCTs[i].Split(' ')[0] + "'"); // string itemLength = dbClient.getString("SELECT length FROM dynamic_items WHERE name_cct = '" + itemCCTs[i].Split(' ')[0] + "'"); // //string itemWidth = dbClient.getString("SELECT width FROM catalogue_items WHERE tid = '" + itemTemplateIDs[i] + "'"); // //string itemLength = dbClient.getString("SELECT length FROM catalogue_items WHERE tid = '" + itemTemplateIDs[i] + "'"); // if (itemWidth == "") // itemWidth = Convert.ToString(0); // if (itemLength == "") // itemLength = Convert.ToString(0); // itemLengths[i] = Convert.ToInt32(itemLength); // itemWidths[i] = Convert.ToInt32(itemWidth); } } i++; } pageBuilder.Append(Encoding.encodeVL64(dTable.Rows.Count)); for (i = 0; i < itemTemplateIDs.Length; i++) { if (Config.enableHappyHour == true) { itemCosts_Credits[i] = 0; if (itemCosts_Pixels[i] > 0) { itemCosts_Credits[i] = 1; } itemCosts_Pixels[i] = itemCosts_Pixels[i] / 2; } if (stringManager.getStringPart(itemCCTs[i], 0, 4) != "deal") { itemCache.Add(itemTemplateIDs[i], new itemTemplate(itemCCTs[i], Convert.ToByte(itemTypeIDs[i]), itemLengths[i], itemWidths[i], double.Parse(itemTopHs[i]), (itemDoorFlags[i] == 1), (itemTradeableFlags[i] == 1), (itemRecycleableFlags[i] == 1), (statusMax[i]), (nexttoRequired[i]), (rightsRequired[i]), (itemDrinks[i]), (itemID[i]))); if (pageID == -1) continue; pageBuilder.Append(Encoding.encodeVL64(itemTemplateIDs[i]) + itemCCTs[i] + Convert.ToChar(2) + Encoding.encodeVL64(itemCosts_Credits[i]) + Encoding.encodeVL64(itemCosts_Pixels[i]) + "I"); if (itemTypeIDs[i] == 0) { pageBuilder.Append("i"); } else if (itemCCTs[i].Contains("avatar_effect") == true) { pageBuilder.Append("e"); } else { pageBuilder.Append("s"); } if (itemCCTs[i].Contains("avatar_effect") == true) { pageBuilder.Append(Convert.ToChar(2) + Encoding.encodeVL64(int.Parse(itemCCTs[i].Replace("avatar_effect", ""))) + Convert.ToChar(2) + "IPO"); } else { string custInformation = ""; if (itemCCTs[i].Contains(" ")) custInformation = itemCCTs[i].Split(' ')[1]; pageBuilder.Append(Convert.ToChar(2) + Encoding.encodeVL64(itemID[i]) + custInformation + Convert.ToChar(2) + "IM"); } } } if (pageID == -1) return; objPage.pageData = pageBuilder.ToString(); cataloguePages.Add(pageIndexName, objPage); } /// /// Returns a bool that specifies if the catalogue manager contains a certain page, specified by name. /// /// The name of the catalogue page to check. public static bool getPageExists(string pageName) { return cataloguePages.ContainsKey(cataloguePages.ContainsKey(pageName)); } /// /// Returns the index of catalogue pages for a certain user rank. /// /// The rank of the user to handout the index to. /// private static Hashtable PageCache = new Hashtable(); public static void CachePages() { for (int i = 1; i < 8; i++) { PageCache.Add(i, getDynamicPageIndex(i)); } Out.WriteLine("Catalogue cached"); } public static string getPageIndex(int Rank) { return (string)PageCache[Rank]; } private static string getDynamicPageIndex(int userRank) { try { StringBuilder listBuilder = new StringBuilder(); DataColumn dCol; DataColumn dCol_Categories; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dCol_Categories = dbClient.getColumn("SELECT indexname FROM catalogue_categories WHERE minrank <= '" + userRank + "' ORDER BY indexid ASC"); string[] pageNames = dataHandling.dColToArray(dCol_Categories); int catIcon = 0; int catColour = 0; int catID = 0; int catContent = 0; int catCount = 0; int subcatCount = 0; int lstID = 0; bool catNull = true; string lstName = ""; string catContent_add = ""; catCount = dbClient.getInt("SELECT COUNT(indexname) FROM catalogue_categories WHERE minrank <= '" + userRank + "'"); for (int i = 0; i < pageNames.Length; i++) { if (catNull == true) listBuilder.Append(Encoding.encodeVL64(0)); catNull = true; //VB6 (Habbo Motel): Send Index, "SBIRBIZHD" & "Frontpage" & Chr$(2) & "HIRAJM" & "Furni Shop" & Chr$(2) & prjJeax.encodeVL64(Count + 1) & "HHHHH" & Chr$(2) & List & "H" & prjJeax.encodeVL64(Val(HoloDB.runRead("SELECT state FROM catalogue WHERE tab='habbo_club'"))) & "JQBXQD" & HoloDB.runRead("SELECT page_name FROM catalogue WHERE tab='habbo_club'") & Chr$(2) & "H" & prjJeax.encodeVL64(Val(Catalogue(500).state)) & "SARA[PD" & Catalogue(500).pagename & Chr$(2) & "HII" & prjJeax.encodeVL64(8) & "[XD" & "Pets" & Chr$(2) & "HIQAQAM" & "Pixel Shop" & Chr$(2) & prjJeax.encodeVL64(Count_2 + 1) & "HHHHH" & Chr$(2) & List_2 & addList & "HHHH[Jmagic.credits" & Chr$(2) & "HHHHX@Kmagic.pixels" & Chr$(2) & "H" & Chr$(1) catIcon = dbClient.getInt("SELECT icon FROM catalogue_categories WHERE indexname = '" + pageNames[i] + "' LIMIT 1"); catIcon = dbClient.getInt("SELECT icon FROM catalogue_categories WHERE indexname = '" + pageNames[i] + "' LIMIT 1"); catColour = dbClient.getInt("SELECT colour FROM catalogue_categories WHERE indexname = '" + pageNames[i] + "' LIMIT 1"); catID = dbClient.getInt("SELECT indexid FROM catalogue_categories WHERE indexname = '" + pageNames[i] + "' LIMIT 1"); catContent = dbClient.getInt("SELECT content FROM catalogue_categories WHERE indexname = '" + pageNames[i] + "' LIMIT 1"); subcatCount = dbClient.getInt("SELECT COUNT(indexid) FROM catalogue_pages WHERE content = '" + catID + "' AND minrank <= '" + userRank + "'"); if (catCount != 0) { listBuilder.Append(Encoding.encodeVL64(catCount)); catCount = 0; } if (catContent == 0) catContent_add = "M"; else catContent_add = Encoding.encodeVL64(catContent); if (subcatCount == 0) listBuilder.Append(Encoding.encodeVL64(1) + Encoding.encodeVL64(catColour) + Encoding.encodeVL64(catIcon) + catContent_add + pageNames[i] + Convert.ToChar(2) + Encoding.encodeVL64(0)); else listBuilder.Append(Encoding.encodeVL64(1) + Encoding.encodeVL64(catColour) + Encoding.encodeVL64(catIcon) + catContent_add + pageNames[i] + Convert.ToChar(2) + Encoding.encodeVL64(0) + Encoding.encodeVL64(subcatCount)); if (subcatCount != 0) { dCol = dbClient.getColumn("SELECT indexname FROM catalogue_pages WHERE content = '" + catID + "' AND minrank <= '" + userRank + "' ORDER BY indexid ASC"); string[] catNames = dataHandling.dColToArray(dCol); for (int b = 0; b < catNames.Length; b++) { if (catNames[b] != "") { lstID = dbClient.getInt("SELECT indexid FROM catalogue_pages WHERE indexname = '" + catNames[b] + "' LIMIT 1"); lstName = dbClient.getString("SELECT displayname FROM catalogue_pages WHERE indexname = '" + catNames[b] + "' LIMIT 1"); int styleColour = dbClient.getInt("SELECT style_colour FROM catalogue_pages WHERE indexname = '" + catNames[b] + "' LIMIT 1"); int styleIcon = dbClient.getInt("SELECT style_icon FROM catalogue_pages WHERE indexname = '" + catNames[b] + "' LIMIT 1"); listBuilder.Append("I" + Encoding.encodeVL64(styleColour) + Encoding.encodeVL64(styleIcon) + Encoding.encodeVL64(lstID) + lstName); } listBuilder.Append(Convert.ToChar(2) + "HH"); } catNull = false; } } return listBuilder.ToString(); } } catch { return Convert.ToChar(2).ToString(); } } /// /// Returns the content of a certain catalogue page as string. /// /// The name of the catalogue page to retrieve the content of. /// The rank of the user to handout the page content to. If this rank is lower than the required minimum rank to access this page, the 'access denied' cast is returned. /// public static string getPage(string pageName, byte userRank) { try { using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { pageName = dbClient.getString("SELECT indexname FROM catalogue_pages WHERE indexid = '" + Encoding.decodeVL64(pageName) + "'"); } cataloguePage objPage = ((cataloguePage)cataloguePages[pageName]); if (userRank < objPage.minRank) return ""; return objPage.pageData; } catch { return ""; } } /// /// Handles special actions at purchase in the catalogue, such as decoration variables for items and items who are sold in pairs. /// /// The template ID of the item being purchased. /// The ID of the user that receives the item in his/her Hand. /// The target room ID of this item. 0 = inhand, -1 = in presentbox, -2 = in Recycler /// The wallpaper/floor value for wallpaper/floor purchases. /// If the item is bought as present, then specify the ID of the present box item. If not, specify 0. /// ItemID of the other teleporter public static void handlePurchase(int templateID, int receiverID, int roomID, string decorID, int presentBoxID, int teleportID1) { string Sprite = getTemplate(templateID).Sprite; bool handlePresentbox = true; int FurnitureType = 0; if (Sprite == "landscape" || Sprite == "wallpaper" || Sprite == "floor") FurnitureType = 1; if (Sprite == "roomdimmer") FurnitureType = 2; if (Sprite.Contains("post.it")) FurnitureType = 4; itemTemplate Template = getTemplate(templateID); if (Template.maxStatus == -1) FurnitureType = 3; switch (FurnitureType) { case 1: { int itemID = lastItemID; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dbClient.runQuery("UPDATE furniture SET var = '" + decorID + "' WHERE id = '" + itemID + "' LIMIT 1"); } break; } case 2: { int itemID = lastItemID; string defaultPreset = "1,#000000,155"; string defaultSetPreset = "1,1,1,#000000,155"; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dbClient.runQuery("INSERT INTO furniture_moodlight(id,roomid,preset_cur,preset_1,preset_2,preset_3) VALUES ('" + itemID + "','0','1','" + defaultPreset + "','" + defaultPreset + "','" + defaultPreset + "')"); dbClient.runQuery("UPDATE furniture SET var = '" + defaultSetPreset + "' WHERE id = '" + itemID + "' LIMIT 1"); } break; } case 3: { int itemID1 = teleportID1; int itemID2; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dbClient.runQuery("INSERT INTO furniture(tid,ownerid,roomid,teleportid) VALUES ('" + templateID + "','" + receiverID + "','" + roomID + "','" + itemID1 + "')"); itemID2 = lastItemID; dbClient.runQuery("UPDATE furniture SET teleportid = '" + itemID2 + "' WHERE id = '" + itemID1 + "' LIMIT 1"); if (presentBoxID > 0) { dbClient.runQuery("INSERT INTO furniture_presents(id,itemid) VALUES ('" + presentBoxID + "','" + itemID1 + "')"); dbClient.runQuery("INSERT INTO furniture_presents(id,itemid) VALUES ('" + presentBoxID + "','" + itemID2 + "')"); } } handlePresentbox = false; break; } case 4: { int itemID = lastItemID; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dbClient.runQuery("UPDATE furniture SET var = '20' WHERE id = '" + itemID + "' LIMIT 1"); } break; } default: { if (stringManager.getStringPart(Sprite, 0, 10) == "sound_set_") { int itemID = lastItemID; int soundSet = int.Parse(Sprite.Substring(10)); using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dbClient.runQuery("UPDATE furniture SET soundmachine_soundset = '" + soundSet + "' WHERE id = '" + itemID + "' LIMIT 1"); } } break; } } if (presentBoxID > 0 && handlePresentbox) { using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dbClient.runQuery("INSERT INTO furniture_presents(id,itemid) VALUES ('" + presentBoxID + "','" + lastItemID + "')"); } } } /// /// Returns the last purchased/created item in the 'furniture' table of the HoloDB. /// public static int lastItemID { get { using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { return dbClient.getInt("SELECT MAX(id) FROM furniture"); } } } public static string tradeItemList(int[] itemIDs) { StringBuilder List = new StringBuilder(); int countFurnitures = 0; string containItem = ""; for (int i = 0; i < itemIDs.Length; i++) { if (containItem.Contains("<" + itemIDs[i] + ">")) { } else { if (itemIDs[i] == 0) continue; DataRow dRow; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dRow = dbClient.getRow("SELECT tid, var FROM furniture WHERE id = '" + itemIDs[i] + "'"); } int templateID = Convert.ToInt32(dRow["tid"]); itemTemplate Template = getTemplate(templateID); int useVar = 0; if (Template.Sprite == "poster") useVar = int.Parse(Template.Colour); if (Template.Sprite == "post.it" || Template.Sprite == "post.it.vd") // Stickies - pad size useVar = Convert.ToInt32(dRow["var"]); if (Template.typeID == 0) List.Append(Encoding.encodeVL64(itemIDs[i]) + "i" + Encoding.encodeVL64(itemIDs[i]) + Encoding.encodeVL64(templateID) + useVar + "HHH"); else List.Append(Encoding.encodeVL64(itemIDs[i]) + "s" + Encoding.encodeVL64(itemIDs[i]) + Encoding.encodeVL64(templateID) + "KRDPAYvGM"); containItem += "<" + itemIDs[i] + ">"; countFurnitures = countFurnitures + 1; } } return Encoding.encodeVL64(countFurnitures) + List.ToString(); } /// /// Checks if the wallposition for a wallitem is correct, if it is, then the output should be exactly the same as the input. If not, then the wallposition is invalid. /// /// The original wallposition. [input] public static string wallPositionOK(string wallPosition) { //:w=3,2 l=9,63 l try { string[] posD = wallPosition.Split(' '); if (posD[2] != "l" && posD[2] != "r") return ""; string[] widD = posD[0].Substring(3).Split(','); int widthX = int.Parse(widD[0]); int widthY = int.Parse(widD[1]); if (widthX < 0 || widthY < 0 || widthX > 200 || widthY > 200) return ""; string[] lenD = posD[1].Substring(2).Split(','); int lengthX = int.Parse(lenD[0]); int lengthY = int.Parse(lenD[1]); if (lengthX < 0 || lengthY < 0 || lengthX > 200 || lengthY > 200) return ""; return ":w=" + widthX + "," + widthY + " " + "l=" + lengthX + "," + lengthY + " " + posD[2]; } catch { return ""; } } /// /// Represents a page in the Catalogue. /// private struct cataloguePage { /// /// The display name of the page in the client. /// internal string displayName; /// /// The page string of the page, containing the layout, items etc. /// internal string pageData; /// /// The minimum rank that a virtual user requires to access this rank. /// internal byte minRank; } /// /// Represents a cached virtual item template. /// public struct itemTemplate { /// /// The type ID of the item, eg, 0 = walliten, 1 = flooritem, 2 = seat etc. /// internal byte typeID; /// /// The sprite of the item. /// internal string Sprite; /// /// The colour of the item. /// internal string Colour; /// /// The length of the item. /// internal int Length; /// /// The width of the item. /// internal int Width; /// /// The topheight of the item, if seat, then this indicates the sitheight. If a solid stackable item, then this is the stackheight. If 0.0, then the item is classified as non-stackable. /// internal double topH; /// /// Specifies if the item can be used as door. /// internal bool isDoor; /// /// Specifies if the item can be traded between virtual users. /// internal bool isTradeable; /// /// Specifies if the item can be recycled in the item recycler. /// internal bool isRecycleable; /// /// Specifies the highest status of the item. /// internal int maxStatus; /// /// Specifies the rights which are required to update status of the item. /// internal int rightsRequired; /// /// Specifies if you have to be next to the furniture to update status of the item. /// internal int nexttoRequired; /// /// Specifies what drinks the item spends. /// internal string drinkIDs; /// /// Specifies the index ID of furniture data of the item. /// internal int indexID; public itemTemplate(bool b) { this.typeID = 1; this.Sprite = ""; this.Colour = "null"; this.Length = 1; this.Width = 1; this.topH = 0.0; this.isDoor = false; this.isTradeable = true; this.isRecycleable = false; this.maxStatus = 1; this.nexttoRequired = 0; this.rightsRequired = 1; this.indexID = 0; this.drinkIDs = ""; } /// /// Initializes the item template. /// /// The sprite of the item. /// The type ID of the item, eg, 0 = walliten, 1 = flooritem, 2 = seat etc. /// The length of the item. /// The width of the item. /// The topheight of the item, if seat, then this indicates the sitheight. If a solid stackable item, then this is the stackheight. If 0.0, then the item is classified as non-stackable. /// Specifies if the item can be used as door. /// Specifies if the item can be traded between virtual users. /// Specifies if the item can be recycled in the item recycler. public itemTemplate(string Sprite, byte typeID, int Length, int Width, double topH, bool isDoor, bool isTradeable, bool isRecycleable, int maxStatus, int nexttoRequired, int rightsRequired, string drinkIDs, int dataID) { if (Sprite.Contains(" ")) { this.Sprite = Sprite.Split(' ')[0]; this.Colour = Sprite.Split(' ')[1]; } else { this.Sprite = Sprite; this.Colour = "null"; } this.typeID = typeID; this.Length = Length; this.Width = Width; this.topH = topH; this.isDoor = isDoor; this.isTradeable = isTradeable; this.isRecycleable = isRecycleable; this.maxStatus = maxStatus; this.nexttoRequired = nexttoRequired; this.rightsRequired = rightsRequired; this.drinkIDs = drinkIDs; this.indexID = dataID; } } /// /// Returns the itemTemplate object matching a certain template ID. If the specified item template is not loaded, then an empty item template is returned. /// /// The template ID to return the item template of. public static itemTemplate getTemplate(int templateID) { try { return (itemTemplate)itemCache[templateID]; } catch { return new itemTemplate(); } } } }