namespace Holo.Virtual.Users.Items { using Holo; using Ion.Storage; using System; using System.Text; internal class virtualSongEditor { private int machineID; private int[] Slot; private int userID; internal virtualSongEditor(int machineID, int userID) { this.machineID = machineID; this.userID = userID; this.Slot = new int[4]; this.loadSoundsets(); } internal void addSoundset(int soundSetID, int slotID) { this.Slot[slotID - 1] = soundSetID; using (DatabaseClient client = Eucalypt.dbManager.GetClient()) { client.runQuery(string.Concat(new object[] { "UPDATE furniture SET roomid = '-3',soundmachine_machineid = '", this.machineID, "',soundmachine_slot = '", slotID, "' WHERE ownerid = '", this.userID, "' AND soundmachine_soundset = '", soundSetID, "' ORDER BY id ASC LIMIT 1" })); } } internal string getSoundsets() { int i = 0; StringBuilder builder = new StringBuilder(); for (int j = 0; j < 4; j++) { int num3 = this.Slot[j]; if (num3 > 0) { builder.Append(Encoding.encodeVL64(j + 1) + Encoding.encodeVL64(num3) + "QB"); int num4 = (num3 * 9) - 8; for (int k = num4; k <= (num4 + 8); k++) { builder.Append(Encoding.encodeVL64(k)); } i++; } } return ("PA" + Encoding.encodeVL64(i) + builder.ToString()); } internal void loadSoundsets() { using (DatabaseClient client = Eucalypt.dbManager.GetClient()) { this.Slot[0] = client.getInt("SELECT soundmachine_soundset FROM furniture WHERE soundmachine_machineid = '" + this.machineID + "' AND soundmachine_slot = '1'"); this.Slot[1] = client.getInt("SELECT soundmachine_soundset FROM furniture WHERE soundmachine_machineid = '" + this.machineID + "' AND soundmachine_slot = '2'"); this.Slot[2] = client.getInt("SELECT soundmachine_soundset FROM furniture WHERE soundmachine_machineid = '" + this.machineID + "' AND soundmachine_slot = '3'"); this.Slot[3] = client.getInt("SELECT soundmachine_soundset FROM furniture WHERE soundmachine_machineid = '" + this.machineID + "' AND soundmachine_slot = '4'"); } } internal void removeSoundset(int slotID) { this.Slot[slotID - 1] = 0; using (DatabaseClient client = Eucalypt.dbManager.GetClient()) { client.runQuery(string.Concat(new object[] { "UPDATE furniture SET roomid = '0',soundmachine_machineid = NULL,soundmachine_slot = NULL WHERE ownerid = '", this.userID, "' AND soundmachine_machineid = '", this.machineID, "' AND soundmachine_slot = '", slotID, "' LIMIT 1" })); } } internal bool slotFree(int slotID) { return (this.Slot[slotID - 1] == 0); } } }