namespace Holo.Managers { using Holo; using Holo.Virtual.Rooms; using System; using System.Collections; using System.Text; public static class roomManager { private static Hashtable ᙃ = new Hashtable(); private static int ᙄ; public static void addRoom(int roomID, virtualRoom Room) { if (!ᙃ.ContainsKey(roomID)) { ᙃ.Add(roomID, Room); Out.WriteLine(string.Concat(new object[] { "Room [", roomID, ", publicroom: ", Room.isPublicroom.ToString().ToLower(), "] loaded." }), Out.logFlags.StandardAction); if (ᙃ.Count > ᙄ) { ᙄ = ᙃ.Count; } } } public static bool containsRoom(int roomID) { return ᙃ.ContainsKey(roomID); } public static string getPoll(int roomID) { string[] strArray = DB.runReadRow("SELECT pid,title,thanks FROM poll WHERE rid = '" + roomID + "'"); int i = int.Parse(strArray[0]); string str = strArray[1]; string str2 = strArray[2]; int[] numArray = DB.runReadColumn("SELECT qid FROM poll_questions WHERE pid = '" + i + "'", 0, null); string[] strArray2 = DB.runReadColumn("SELECT question FROM poll_questions WHERE pid = '" + i + "'", 0); int length = strArray2.Length; int[] numArray2 = DB.runReadColumn("SELECT type FROM poll_questions WHERE pid = '" + i + "'", 0, null); int[] numArray3 = DB.runReadColumn("SELECT min FROM poll_questions WHERE pid = '" + i + "'", 0, null); int[] numArray4 = DB.runReadColumn("SELECT max FROM poll_questions WHERE pid = '" + i + "'", 0, null); string[][] strArray3 = new string[numArray.Length][]; int[] numArray5 = new int[numArray.Length]; int index = 0; foreach (int num4 in numArray) { int[] numArray6 = DB.runReadColumn("SELECT aid FROM poll_answers WHERE qid = '" + num4 + "'", 0, null); strArray3[index] = new string[numArray6.Length]; int num5 = 0; foreach (int num6 in numArray6) { strArray3[index][num5] = DB.runRead(string.Concat(new object[] { "SELECT answer FROM poll_answers WHERE qid = '", num4, "' AND aid = '", num6, "'" })); num5++; } numArray5[index] = strArray3[index].Length; index++; } StringBuilder builder = new StringBuilder("D}"); builder.Append(Holo.Encoding.encodeVL64(i)); builder.Append(str); builder.Append(Convert.ToChar(2)); builder.Append(str2); builder.Append(Convert.ToChar(2)); builder.Append(Holo.Encoding.encodeVL64(length)); index = 0; foreach (int num7 in numArray) { builder.Append(Holo.Encoding.encodeVL64(num7)); builder.Append(Holo.Encoding.encodeVL64(index + 1)); builder.Append(Holo.Encoding.encodeVL64(numArray2[index])); builder.Append(strArray2[index]); builder.Append(Convert.ToChar(2)); builder.Append(Holo.Encoding.encodeVL64(numArray5[index])); builder.Append(Holo.Encoding.encodeVL64(numArray3[index])); builder.Append(Holo.Encoding.encodeVL64(numArray4[index])); foreach (string str3 in strArray3[index]) { builder.Append(str3); builder.Append(Convert.ToChar(2)); } index++; } return builder.ToString(); } public static virtualRoom getRoom(int roomID) { return (virtualRoom) ᙃ[roomID]; } public static string getRoomState(int State) { if (State == 1) { return "closed"; } if (State == 2) { return "password"; } return "open"; } public static int getRoomState(string State) { if (State == "closed") { return 1; } if (State == "password") { return 2; } return 0; } public static void refreshWallitem(int roomID, int itemID, string cctName, string wallPosition, string itemVariable) { getRoom(roomID).sendData(string.Concat(new object[] { "AU", itemID, Convert.ToChar(9), cctName, Convert.ToChar(9), " ", wallPosition, Convert.ToChar(9), itemVariable })); } public static void removeRoom(int roomID) { if (ᙃ.ContainsKey(roomID)) { bool isPublicroom = ((virtualRoom) ᙃ[roomID]).isPublicroom; ᙃ.Remove(roomID); updateRoomVisitorCount(roomID, 0); Out.WriteLine(string.Concat(new object[] { "Room [", roomID, ", publicroom: ", isPublicroom.ToString().ToLower(), "] destroyed." }), Out.logFlags.StandardAction); GC.Collect(); } } public static void updateRoomVisitorCount(int roomID, int visitorCount) { DB.runQuery(string.Concat(new object[] { "UPDATE rooms SET visitors_now = '", visitorCount, "' WHERE id = '", roomID, "' LIMIT 1" })); } public static int peakRoomCount { get { return ᙄ; } } public static int roomCount { get { return ᙃ.Count; } } public static class moodlight { public static string getSettings(int roomID) { try { string[] strArray = DB.runReadRow("SELECT preset_cur,preset_1,preset_2,preset_3 FROM furniture_moodlight WHERE roomid = '" + roomID + "'"); string str = Holo.Encoding.encodeVL64(3) + Holo.Encoding.encodeVL64(int.Parse(strArray[0])); for (int i = 1; i <= 3; i++) { string[] strArray2 = strArray[i].Split(new char[] { char.Parse(",") }); object obj2 = str; str = string.Concat(new object[] { obj2, Holo.Encoding.encodeVL64(i), Holo.Encoding.encodeVL64(int.Parse(strArray2[0])), strArray2[1], Convert.ToChar(2), Holo.Encoding.encodeVL64(int.Parse(strArray2[2])) }); } return str; } catch { return null; } } public static void setSettings(int roomID, bool isEnabled, int presetID, int bgState, string presetColour, int alphaDarkF) { string str; int itemID = DB.runRead("SELECT id FROM furniture_moodlight WHERE roomid = '" + roomID + "'", null); if (!isEnabled) { string str2 = DB.runRead("SELECT var FROM furniture WHERE id = '" + itemID + "'"); if (str2.Substring(0, 1) == "2") { str = "1" + str2.Substring(1); } else { str = "2" + str2.Substring(1); } DB.runQuery("UPDATE furniture SET var = '" + str + "' WHERE id = '" + itemID.ToString() + "' LIMIT 1"); } else { str = "2," + presetID.ToString() + "," + bgState.ToString() + "," + presetColour + "," + alphaDarkF.ToString(); DB.runQuery("UPDATE furniture SET var = '" + str + "' WHERE id = '" + itemID.ToString() + "' LIMIT 1"); DB.runQuery("UPDATE furniture_moodlight SET preset_cur = '" + presetID.ToString() + "',preset_" + presetID.ToString() + "= '" + bgState.ToString() + "," + presetColour + "," + alphaDarkF.ToString() + "' WHERE id = '" + itemID.ToString() + "' LIMIT 1"); } string wallPosition = DB.runRead("SELECT wallpos FROM furniture WHERE id = '" + itemID + "'"); roomManager.refreshWallitem(roomID, itemID, "roomdimmer", wallPosition, str); } } } }