public IEnumerable <GuestRoomListing> GetGuestRoomListings(string categoryID, int maximumAmount = 30) { HabboDistributor habboDistributor = CoreManager.ServerCore.GetHabboDistributor(); List <int> loadedRoomIDs = new List <int>(); // TODO: Dusokay current rooms using (ISession db = CoreManager.ServerCore.GetDatabaseSession()) { IList <Room> rooms = db.CreateCriteria <Room>() .Add(Restrictions.Eq("category_id", categoryID)) .Add( new NotExpression( new InExpression("room_id", loadedRoomIDs.Cast <object>().ToArray()))) .AddOrder(Order.Desc("last_entry")) .SetMaxResults(maximumAmount - loadedRoomIDs.Count) .List <Room>(); foreach (Room room in rooms) { yield return(new GuestRoomListing { ID = room.room_id, Name = room.name, Description = room.description, Owner = habboDistributor.GetHabbo(room.owner_id), // TODO: Other values Population = 0 // If people were inside it would already be loaded. }); } } }
private static void ProcessMessengerSearch(Habbo sender, IncomingMessage message) { string searchString = message.PopPrefixedString(); List <IHI.Database.Habbo> matching; // Using IHIDB.Habbo rather than IHIDB.Friend because this will be passed to the HabboDistributor using (ISession db = CoreManager.ServerCore.GetDatabaseSession()) { matching = db.CreateCriteria <IHI.Database.Habbo>(). Add(new LikeExpression("username", searchString + "%")). SetMaxResults(20). // TODO: External config List <IHI.Database.Habbo>() as List <IHI.Database.Habbo>; } List <IBefriendable> friends = new List <IBefriendable>(); List <IBefriendable> strangers = new List <IBefriendable>(); MessengerObject messenger = sender.GetMessenger(); HabboDistributor habboDistributor = CoreManager.ServerCore.GetHabboDistributor(); foreach (IHI.Database.Habbo match in matching) { IBefriendable habbo = habboDistributor.GetHabbo(match); if (messenger.IsFriend(habbo)) { friends.Add(habbo); } else { strangers.Add(habbo); } } new MMessengerSearchResults(friends, strangers).Send(sender); }