Exemplo n.º 1
0
 public void parse(GameClient Session, ClientMessage Event)
 {
     if (((Session != null) && (Session.GetHabbo() != null)) && (Session.GetHabbo().CurrentRoom != null))
     {
         Room currentRoom = Session.GetHabbo().CurrentRoom;
         if (currentRoom.CheckRights(Session, true))
         {
             RoomMusicController roomMusicController = currentRoom.GetRoomMusicController();
             if (roomMusicController.PlaylistSize < roomMusicController.PlaylistCapacity)
             {
                 int num = Event.PopWiredInt32();
                 UserItem item = Session.GetHabbo().GetInventoryComponent().GetItem((uint)num);
                 if ((item != null) && (item.GetBaseItem().InteractionType == "musicdisc"))
                 {
                     SongItem diskItem = new SongItem(item);
                     if (roomMusicController.AddDisk(diskItem) >= 0)
                     {
                         //diskItem.SaveToDatabase((int)currentRoom.Id); // <-- old
                         diskItem.SaveToDatabase((int)roomMusicController.LinkedItemId); // <-- new
                         Session.GetHabbo().GetInventoryComponent().RemoveItem((uint)num, 0, true);
                         Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
                         Session.SendMessage(JukeboxDiscksComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList<SongInstance>()));
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        public int AddDisk(SongItem DiskItem)
        {
            int songID = DiskItem.songID;

            if (songID == 0)
            {
                return(-1);
            }
            SongData song = SongManager.GetSong(songID);

            if (song == null)
            {
                return(-1);
            }
            if (this.mLoadedDisks.ContainsKey(DiskItem.itemID))
            {
                return(-1);
            }
            this.mLoadedDisks.Add(DiskItem.itemID, DiskItem);
            int count = this.mPlaylist.Count;

            lock (this.mPlaylist)
            {
                this.mPlaylist.Add(count, new SongInstance(DiskItem, song));
            }
            return(count);
        }
Exemplo n.º 3
0
 public int AddDisk(SongItem DiskItem)
 {
     int songID = DiskItem.songID;
     if (songID == 0)
     {
         return -1;
     }
     SongData song = SongManager.GetSong(songID);
     if (song == null)
     {
         return -1;
     }
     if (this.mLoadedDisks.ContainsKey(DiskItem.itemID))
     {
         return -1;
     }
     this.mLoadedDisks.Add(DiskItem.itemID, DiskItem);
     int count = this.mPlaylist.Count;
     lock (this.mPlaylist)
     {
         this.mPlaylist.Add(count, new SongInstance(DiskItem, song));
     }
     return count;
 }
Exemplo n.º 4
0
 public SongInstance(SongItem Item, SongData SongData)
 {
     this.mDiskItem = Item;
     this.mSongData = SongData;
 }
Exemplo n.º 5
0
        internal void LoadMusic()
        {
            DataTable table;
            DataTable table2;
            using (DatabaseClient @class = PhoenixEnvironment.GetDatabase().GetClient())
            {
                table = @class.ReadDataTable("SELECT * FROM items_rooms_songs WHERE roomid = '" + Id + "'"); // <-- old
                table2 = @class.ReadDataTable("SELECT * FROM items_jukebox_songs WHERE jukeboxid = '" + this.GetRoomMusicController().LinkedItemId + "'"); // <-- new
            }

            foreach (DataRow row in table.Rows)
            {
                int songID = (int)row["songid"];
                uint num2 = (uint)row["itemid"];
                int baseItem = (int)row["baseitem"];
                SongItem diskItem = new SongItem((int)num2, songID, baseItem);
                diskItem.RemoveFromDatabase();
                diskItem.SaveToDatabase(this.GetRoomMusicController().LinkedItemId);
                this.GetRoomMusicController().AddDisk(diskItem);
            }

            foreach (DataRow row in table2.Rows)
            {
                int songID = (int)row["songid"];
                uint num2 = (uint)row["itemid"];
                int baseItem = (int)row["baseitem"];
                SongItem diskItem = new SongItem((int)num2, songID, baseItem);
                this.GetRoomMusicController().AddDisk(diskItem);
            }
        }
Exemplo n.º 6
0
 public SongInstance(SongItem Item, SongData SongData)
 {
     this.mDiskItem = Item;
     this.mSongData = SongData;
 }