예제 #1
0
파일: Music.cs 프로젝트: BjkGkh/Azure2
 /// <summary>
 /// Adds the playlist item.
 /// </summary>
 internal void AddPlaylistItem()
 {
     if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().CurrentRoom == null)
         return;
     Room currentRoom = Session.GetHabbo().CurrentRoom;
     if (!currentRoom.CheckRights(Session, true, false))
         return;
     RoomMusicController roomMusicController = currentRoom.GetRoomMusicController();
     if (roomMusicController.PlaylistSize >= roomMusicController.PlaylistCapacity)
         return;
     uint num = Request.GetUInteger();
     UserItem item = Session.GetHabbo().GetInventoryComponent().GetItem(num);
     if (item == null || item.BaseItem.InteractionType != Interaction.MusicDisc)
         return;
     var songItem = new SongItem(item);
     int num2 = roomMusicController.AddDisk(songItem);
     if (num2 < 0)
         return;
     songItem.SaveToDatabase(currentRoom.RoomId);
     Session.GetHabbo().GetInventoryComponent().RemoveItem(num, true);
     using (IQueryAdapter queryReactor = AzureEmulator.GetDatabaseManager().GetQueryReactor())
         queryReactor.RunFastQuery(string.Format("UPDATE items_rooms SET user_id='0' WHERE id={0} LIMIT 1", num));
     Session.SendMessage(JukeboxComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList()));
 }
예제 #2
0
 /// <summary>
 /// Adds the disk.
 /// </summary>
 /// <param name="diskItem">The disk item.</param>
 /// <returns>System.Int32.</returns>
 public int AddDisk(SongItem diskItem)
 {
     uint songId = diskItem.SongId;
     if (songId == 0u)
     {
         return -1;
     }
     SongData song = SongManager.GetSong(songId);
     if (song == null)
     {
         return -1;
     }
     if (_mLoadedDisks.ContainsKey(diskItem.ItemId))
     {
         return -1;
     }
     _mLoadedDisks.Add(diskItem.ItemId, diskItem);
     int count = _mPlaylist.Count;
     lock (_mPlaylist)
     {
         _mPlaylist.Add(count, new SongInstance(diskItem, song));
     }
     return count;
 }
예제 #3
0
파일: Room.cs 프로젝트: BjkGkh/Azure2
        /// <summary>
        /// Loads the music.
        /// </summary>
        internal void LoadMusic()
        {
            DataTable table;
            using (IQueryAdapter queryReactor = AzureEmulator.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(
                    string.Format(
                        "SELECT items_songs.songid,items_rooms.id,items_rooms.base_item FROM items_songs LEFT JOIN items_rooms ON items_rooms.id = items_songs.itemid WHERE items_songs.roomid = {0}",
                        RoomId));
                table = queryReactor.GetTable();
            }

            if (table == null)
                return;
            foreach (DataRow dataRow in table.Rows)
            {
                var songId = (uint)dataRow[0];
                var num = Convert.ToUInt32(dataRow[1]);
                var baseItem = Convert.ToInt32(dataRow[2]);
                var songCode = string.Empty;
                var extraData = string.Empty;
                using (IQueryAdapter queryreactor2 = AzureEmulator.GetDatabaseManager().GetQueryReactor())
                {
                    queryreactor2.SetQuery(string.Format("SELECT extra_data,songcode FROM items_rooms WHERE id = {0}",
                        num));
                    var row = queryreactor2.GetRow();
                    if (row != null)
                    {
                        extraData = (string)row["extra_data"];
                        songCode = (string)row["songcode"];
                    }
                }
                var diskItem = new SongItem(num, songId, baseItem, extraData, songCode);
                GetRoomMusicController().AddDisk(diskItem);
            }
        }