internal void GetPlaylists() { if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().CurrentRoom == null) { return; } Room currentRoom = Session.GetHabbo().CurrentRoom; if (!currentRoom.GotMusicController()) { return; } RoomMusicController musicController = currentRoom.GetRoomMusicController(); Session.SendMessage(JukeboxComposer.Compose(musicController.PlaylistCapacity, musicController.Playlist.Values.ToList())); //var song = musicController.Playlist[0]; //ServerMessage message = new ServerMessage(Outgoing.PlayListSongAdded); //message.AppendUInt(song.DiskItem.itemID); //message.AppendUInt(song.SongData.Id); //message.AppendString(song.SongData.Name); //message.AppendString(song.SongData.Data); //Session.SendMessage(message); }
public void Handle(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().GetItemById((uint)num); if ((item != null) && (item.method_1().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().method_12((uint)num, 0u, true); Session.GetHabbo().GetInventoryComponent().method_9(true); Session.SendMessage(JukeboxDiscksComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList <SongInstance>())); } } } } } }
internal void RemovePlaylistItem() { if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().CurrentRoom == null) { return; } Room currentRoom = Session.GetHabbo().CurrentRoom; if (!currentRoom.CheckRights(Session, true) || !currentRoom.GotMusicController()) { return; } RoomMusicController musicController = currentRoom.GetRoomMusicController(); SongItem item = musicController.RemoveDisk(Request.ReadInt32()); if (item == null) { return; } item.RemoveFromDatabase(); Session.GetHabbo().GetInventoryComponent().AddNewItem(item.itemID, item.baseItem.ItemId, new StringData(item.songID.ToString()), 0, true, true); Session.GetHabbo().GetInventoryComponent().UpdateItems(false); Session.SendMessage(JukeboxComposer.SerializeSongInventory(Session.GetHabbo().GetInventoryComponent().songDisks)); Session.SendMessage(JukeboxComposer.Compose(musicController.PlaylistCapacity, musicController.Playlist.Values.ToList())); }
/// <summary> /// Removes the playlist item. /// </summary> internal void RemovePlaylistItem() { if (this.Session == null || this.Session.GetHabbo() == null || this.Session.GetHabbo().CurrentRoom == null) { return; } Room currentRoom = this.Session.GetHabbo().CurrentRoom; if (!currentRoom.GotMusicController()) { return; } RoomMusicController roomMusicController = currentRoom.GetRoomMusicController(); SongItem songItem = roomMusicController.RemoveDisk(this.Request.GetInteger()); if (songItem == null) { return; } songItem.RemoveFromDatabase(); this.Session.GetHabbo().GetInventoryComponent().AddNewItem(songItem.ItemId, songItem.BaseItem.ItemId, songItem.ExtraData, 0u, false, true, 0, 0, songItem.SongCode); this.Session.GetHabbo().GetInventoryComponent().UpdateItems(false); using (IQueryAdapter queryReactor = global::Plus.Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.RunFastQuery(string.Format("UPDATE items_rooms SET user_id='{0}' WHERE id='{1}' LIMIT 1;", Session.GetHabbo().Id, songItem.ItemId)); } this.Session.SendMessage(JukeboxComposer.SerializeSongInventory(this.Session.GetHabbo().GetInventoryComponent().SongDisks)); this.Session.SendMessage(JukeboxComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList <SongInstance>())); }
public override void OnRemove(GameClient Session, RoomItem Item) { RoomMusicController roomMusicController = GoldTree.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId).GetRoomMusicController(); roomMusicController.UnLinkRoomOutputItem(); Item.UpdateState(true, true); }
public override void OnPlace(GameClient Session, RoomItem Item) { RoomMusicController roomMusicController = HabboIM.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId).GetRoomMusicController(); roomMusicController.LinkRoomOutputItemIfNotAlreadyExits(Item); roomMusicController.Stop(); Session.GetHabbo().CurrentRoom.LoadMusic(); }
internal RoomMusicController GetRoomMusicController() { if (musicController == null) { musicController = new RoomMusicController(); } return(musicController); }
/// <summary> /// Gets the playlists. /// </summary> internal void GetPlaylists() { if (this.Session == null || this.Session.GetHabbo() == null || this.Session.GetHabbo().CurrentRoom == null) { return; } Room currentRoom = this.Session.GetHabbo().CurrentRoom; if (!currentRoom.GotMusicController()) { return; } RoomMusicController roomMusicController = currentRoom.GetRoomMusicController(); this.Session.SendMessage(JukeboxComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList <SongInstance>())); }
public void Handle(GameClient Session, ClientMessage Event) { /*ServerMessage Message = new ServerMessage(334u); * Message.AppendInt32(20); * Message.AppendInt32(16); * for (int i = 1; i <= 16; i++) * { * Message.AppendInt32(i); * Message.AppendInt32(i); * } * Session.SendMessage(Message);*/ Room currentRoom = Session.GetHabbo().CurrentRoom; RoomMusicController roomMusicController = currentRoom.GetRoomMusicController(); Session.SendMessage(JukeboxDiscksComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList <SongInstance>())); }
public override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights) { RoomMusicController roomMusicController = HabboIM.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId).GetRoomMusicController(); roomMusicController.LinkRoomOutputItemIfNotAlreadyExits(Item); if ((UserHasRights && (Session != null)) && (Item != null)) { if (roomMusicController.IsPlaying) { roomMusicController.Stop(); } else { roomMusicController.Start(Request); } } }
internal void GetPlaylists() { if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().CurrentRoom == null) { return; } Room currentRoom = Session.GetHabbo().CurrentRoom; if (!currentRoom.CheckRights(Session, true) || !currentRoom.GotMusicController()) { return; } RoomMusicController musicController = currentRoom.GetRoomMusicController(); Session.SendMessage(JukeboxComposer.Compose(musicController.PlaylistCapacity, musicController.Playlist.Values.ToList())); }
internal void AddPlaylistItem() { if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().CurrentRoom == null) { return; } Room currentRoom = Session.GetHabbo().CurrentRoom; if (!currentRoom.CheckRights(Session, true)) { return; } RoomMusicController musicController = currentRoom.GetRoomMusicController(); if (musicController.PlaylistSize >= musicController.PlaylistCapacity) { return; } uint itemID = Request.ReadUInt32(); UserItem item = Session.GetHabbo().GetInventoryComponent().GetItem(itemID); if (item == null || item.GetBaseItem().InteractionType != InteractionType.musicdisc) { return; } //RoomItem roomItem = new RoomItem(item.Id, currentRoom.RoomId, item.BaseItem, ((StringData)item.data).Data, 0, 0, 0, 0, currentRoom); SongItem sitem = new SongItem(item); int NewOrder = musicController.AddDisk(sitem); if (NewOrder < 0) { return; } sitem.SaveToDatabase(currentRoom.RoomId); Session.GetHabbo().GetInventoryComponent().RemoveItem(itemID, true); Session.SendMessage(JukeboxComposer.Compose(musicController.PlaylistCapacity, musicController.Playlist.Values.ToList())); }
public void Handle(GameClient Session, ClientMessage Event) { if (((Session != null) && (Session.GetHabbo() != null)) && (Session.GetHabbo().CurrentRoom != null)) { Room currentRoom = Session.GetHabbo().CurrentRoom; if (currentRoom.CheckRights(Session, true) && currentRoom.GotMusicController()) { RoomMusicController roomMusicController = currentRoom.GetRoomMusicController(); SongItem item = roomMusicController.RemoveDisk(Event.PopWiredInt32()); if (item != null) { item.RemoveFromDatabase(); Session.GetHabbo().GetInventoryComponent().method_11((uint)item.itemID, item.baseItem.UInt32_0, item.songID.ToString(), false); Session.GetHabbo().GetInventoryComponent().method_9(true); Session.SendMessage(JukeboxDiscksComposer.SerializeSongInventory(Session.GetHabbo().GetInventoryComponent().songDisks)); Session.SendMessage(JukeboxDiscksComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList <SongInstance>())); } } } }
/// <summary> /// Adds the playlist item. /// </summary> internal void AddPlaylistItem() { if (this.Session == null || this.Session.GetHabbo() == null || this.Session.GetHabbo().CurrentRoom == null) { return; } Room currentRoom = this.Session.GetHabbo().CurrentRoom; if (!currentRoom.CheckRights(this.Session, true, false)) { return; } RoomMusicController roomMusicController = currentRoom.GetRoomMusicController(); if (roomMusicController.PlaylistSize >= roomMusicController.PlaylistCapacity) { return; } uint num = this.Request.GetUInteger(); UserItem item = this.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); this.Session.GetHabbo().GetInventoryComponent().RemoveItem(num, true); using (IQueryAdapter queryReactor = global::Plus.Plus.GetDatabaseManager().GetQueryReactor()) queryReactor.RunFastQuery(string.Format("UPDATE items_rooms SET user_id='0' WHERE id={0} LIMIT 1", num)); this.Session.SendMessage(JukeboxComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList <SongInstance>())); }
private void Dispose() { if (!mDisposed) { try { mDisposed = true; mCycleEnded = true; OtanixEnvironment.GetGame().GetRoomManager().QueueActiveRoomRemove(mRoomData); using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { GetRoomItemHandler().SaveFurniture(dbClient); saveBots(); } WorkRoomServerMessageThread(); WorkRoomChatServerMessageThread(); ClearMute(); UsersWithRights.Clear(); Bans.Clear(); foreach (var item in GetRoomItemHandler().mFloorItems.Values) { item.Destroy(); } foreach (var item in GetRoomItemHandler().mWallItems.Values) { item.Destroy(); } roomUserManager.Destroy(); roomUserManager = null; chatMessageManager.Destroy(); chatMessageManager = null; roomItemHandling.Destroy(); roomItemHandling = null; if (GetGameManager() != null) { GetGameManager().Destroy(); games = null; } if (GotSoccer()) { GetSoccer().Destroy(); soccer = null; } if (GotWired()) { GetWiredHandler().Destroy(); wiredHandler = null; } if (GotMusicController()) { GetRoomMusicController().Destroy(); musicController = null; } if (GetGameMap() != null) { GetGameMap().Destroy(); gamemap = null; } } catch (Exception e) { Logging.LogCriticalException("Unload of room " + e); } } }
public RoomItem(uint uint_5, uint uint_6, uint BaseItem, string string_8, int int_5, int int_6, double double_1, int int_7, string string_9, Room class14_1) { this.Id = uint_5; this.RoomId = uint_6; this.BaseItem = BaseItem; this.ExtraData = string_8; this.mX = int_5; this.mY = int_6; this.mZ = double_1; this.Rot = int_7; this.string_7 = string_9; this.UpdateNeeded = false; this.UpdateCounter = 0; this.InteractingUser = 0u; this.InteractingUser2 = 0u; this.TimerRunning = false; this.string_1 = "none"; //this.enum5_0 = RoomItem.Enum5.const_0; this.Extra1 = ""; this.Extra2 = ""; this.Extra3 = ""; this.Extra4 = ""; this.Extra5 = ""; this.int_0 = 0; this.dictionary_1 = new Dictionary <RoomUser, int>(); this.mBaseItem = PhoenixEnvironment.GetGame().GetItemManager().GetItem(BaseItem); this.mRoom = class14_1; if (this.GetBaseItem() == null) { Logging.LogException("Unknown baseID: " + BaseItem); } string text = this.GetBaseItem().InteractionType.ToLower(); if (text != null) { if (!(text == "teleport")) { if (!(text == "roller")) { if (!(text == "blue_score")) { if (!(text == "green_score")) { if (!(text == "red_score")) { if (text == "yellow_score") { this.string_1 = "yellow"; } } else { this.string_1 = "red"; } } else { this.string_1 = "green"; } } else { this.string_1 = "blue"; } } else { this.mIsRoller = true; class14_1.Boolean_1 = true; } } else { this.ReqUpdate(0); } } if (text != null) { switch (text) { case "jukebox": RoomMusicController roomMusicController = this.GetRoom().GetRoomMusicController(); roomMusicController.LinkRoomOutputItemIfNotAlreadyExits(this); break; } } this.mIsWallItem = (this.GetBaseItem().Type == 'i'); this.mIsFloorItem = (this.GetBaseItem().Type == 's'); this.mAffectedPoints = this.GetRoom().GetAffectedTiles(this.GetBaseItem().Length, this.GetBaseItem().Width, this.mX, this.mY, int_7); }
public RoomInstance(uint InstanceId, RoomInfo Info, RoomModel Model) { mActorSyncRoot = new object(); mItemSyncRoot = new object(); mInstanceId = InstanceId; mInfo = Info; mActors = new Dictionary <uint, RoomActor>(); mCachedModel = Model; mRelativeHeightmap = string.Empty; mActorIdGenerator = 1; mActorIdGeneratorSyncLock = new object(); mTileStates = new TileState[mCachedModel.Heightmap.SizeX, mCachedModel.Heightmap.SizeY]; mUsersWithRights = new List <uint>(); mBannedUsers = new Dictionary <uint, double>(); mItems = new Dictionary <uint, Item>(); mStaticObjects = new List <StaticObject>(); mItemLimitCache = new Dictionary <ItemBehavior, int>(); mUserGrid = new List <RoomActor> [mCachedModel.Heightmap.SizeX, mCachedModel.Heightmap.SizeY]; mMusicController = new RoomMusicController(); mTemporaryStickieRights = new Dictionary <uint, uint>(); mTradeManager = new TradeManager(); mRollerItems = new List <Item> [mCachedModel.Heightmap.SizeX, mCachedModel.Heightmap.SizeY]; mWiredManager = new WiredManager(this); foreach (Bot Bot in BotManager.GenerateBotInstancesForRoom(RoomId)) { AddBotToRoom(Bot); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { // Items MySqlClient.SetParameter("id", RoomId); DataTable ItemTable = MySqlClient.ExecuteQueryTable("SELECT * FROM items WHERE room_id = @id"); foreach (DataRow Row in ItemTable.Rows) { Item Item = ItemFactory.CreateFromDatabaseRow(Row, mWiredManager); if (Item.PendingExpiration && Item.ExpireTimeLeft <= 0) { Item.RemovePermanently(MySqlClient); continue; } if (Item.InSoundManager) { continue; } mItems.Add(Item.Id, Item); IncrecementFurniLimitCache(Item.Definition.Behavior); ItemEventDispatcher.InvokeItemEventHandler(null, Item, this, ItemEventType.InstanceLoaded); } // Static objects MySqlClient.SetParameter("id", RoomId); DataTable StaticObjectTable = MySqlClient.ExecuteQueryTable("SELECT id,name,position,height,rotation,is_seat FROM static_objects WHERE room_id = @id"); foreach (DataRow Row in StaticObjectTable.Rows) { mStaticObjects.Add(new StaticObject((uint)Row["id"], (string)Row["name"], Vector2.FromString((string)Row["position"]), (int)Row["height"], (int)Row["rotation"], (Row["is_seat"].ToString() == "1"))); } // Rights MySqlClient.SetParameter("id", RoomId); DataTable RightsTable = MySqlClient.ExecuteQueryTable("SELECT user_id FROM room_rights WHERE room_id = @id"); foreach (DataRow Row in RightsTable.Rows) { mUsersWithRights.Add((uint)Row["user_id"]); } // Pets MySqlClient.SetParameter("id", RoomId); DataTable PetsTable = MySqlClient.ExecuteQueryTable("SELECT * FROM pets WHERE room_id = @id"); foreach (DataRow Row in PetsTable.Rows) { Pet PetData = PetFactory.GetPetFromDatabaseRow(Row); AddBotToRoom(BotManager.CreateNewInstance(BotManager.GetHandlerDefinitionForPetType(PetData.Type), RoomId, Vector3.FromString(Row["room_pos"].ToString()), PetData)); } } RegenerateRelativeHeightmap(); mUpdater = new Timer(new TimerCallback(PerformUpdate), null, TimeSpan.FromMilliseconds(500), TimeSpan.FromMilliseconds(500)); }