コード例 #1
0
        internal void ToggleStaffPick()
        {
            var roomId  = Request.GetUInteger();
            var current = Request.GetBool();
            var room    = Plus.GetGame().GetRoomManager().GetRoom(roomId);

            if (room == null)
            {
                return;
            }
            using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
            {
                var pubItem = Plus.GetGame().GetNavigator().GetPublicItem(roomId);
                if (pubItem == null) // not picked
                {
                    queryReactor.SetQuery("INSERT INTO navigator_publics (bannertype, room_id, category_parent_id) VALUES ('0', @roomId, '-2')");
                    queryReactor.AddParameter("roomId", room.RoomId);
                    queryReactor.RunQuery();
                    queryReactor.RunFastQuery("SELECT last_insert_id()");
                    var publicItemId = queryReactor.GetInteger();
                    var publicItem   = new PublicItem(publicItemId, 0, string.Empty, string.Empty, string.Empty, PublicImageType.Internal, room.RoomId, 0, -2, false, 1, string.Empty);
                    Plus.GetGame().GetNavigator().AddPublicItem(publicItem);
                }
                else // picked
                {
                    queryReactor.SetQuery("DELETE FROM navigator_publics WHERE id = @pubId");
                    queryReactor.AddParameter("pubId", pubItem.Id);
                    queryReactor.RunQuery();
                    Plus.GetGame().GetNavigator().RemovePublicItem(pubItem.Id);
                }
                room.RoomData.SerializeRoomData(Response, Session, false, true);
                Plus.GetGame().GetNavigator().LoadNewPublicRooms();
            }
        }
コード例 #2
0
        public ServerMessage Handle(ValueHolder valueHolder = null)
        {
            ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);

            message.Init(r63aOutgoing.Navigator);
            message.AppendInt32(1);
            message.AppendString(valueHolder.GetValue <string>("Entry"));

            List <RoomData> rooms = valueHolder.GetValue <List <RoomData> >("Rooms");

            message.AppendInt32(rooms.Count);
            foreach (RoomData roomData in rooms)
            {
                roomData.Serialize(message, false);
            }

            PublicItem publicRoom = valueHolder.GetValue <PublicItem>("PublicRoom");

            if (publicRoom != null)
            {
                message.AppendBoolean(true);
                publicRoom.Serialize(message);
            }
            else
            {
                message.AppendBoolean(false);
            }
            return(message);
        }
コード例 #3
0
        public void Handle(GameClient session, ClientMessage message)
        {
            if (session.GetHabbo().HasPermission("acc_staffpick"))
            {
                uint roomId = message.PopWiredUInt();
                bool pick   = message.PopWiredBoolean();

                Room room = Skylight.GetGame().GetRoomManager().TryGetAndLoadRoom(roomId);
                if (room != null)
                {
                    PublicItem item = Skylight.GetGame().GetNavigatorManager().GetPublicItem(roomId, ServerConfiguration.StaffPicksCategoryId);
                    if (item == null)
                    {
                        GameClient roomOwner = Skylight.GetGame().GetGameClientManager().GetGameClientById(room.RoomData.OwnerID);
                        using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                        {
                            dbClient.AddParamWithValue("roomId", room.ID);
                            dbClient.AddParamWithValue("caption", room.RoomData.Name);
                            dbClient.AddParamWithValue("categoryId", ServerConfiguration.StaffPicksCategoryId);
                            dbClient.ExecuteQuery("INSERT INTO navigator_publics(ordernum, bannertype, caption, image, type, room_id, category_parent_id, image_type) VALUES(0, '1', @caption, '', 'FLAT', @roomId, @categoryId, 'internal')");

                            Skylight.GetGame().GetNavigatorManager().LoadPublicRooms(dbClient);

                            if (roomOwner == null)
                            {
                                dbClient.AddParamWithValue("roomOwner", room.RoomData.OwnerID);
                                dbClient.ExecuteQuery("UPDATE user_stats SET staff_picks = staff_picks + 1 WHERE user_id = @roomOwner LIMIT 1");
                            }
                        }

                        if (roomOwner != null)
                        {
                            roomOwner.GetHabbo().GetUserStats().StaffPicks++;
                            roomOwner.GetHabbo().GetUserAchievements().CheckAchievement("StaffPick");
                        }
                    }
                    else
                    {
                        using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                        {
                            dbClient.AddParamWithValue("roomId", room.ID);
                            dbClient.AddParamWithValue("categoryId", ServerConfiguration.StaffPicksCategoryId);
                            dbClient.ExecuteQuery("DELETE FROM navigator_publics WHERE room_id = @roomId AND category_parent_id = @categoryId LIMIT 1");

                            Skylight.GetGame().GetNavigatorManager().LoadPublicRooms(dbClient);
                        }
                    }

                    ServerMessage roomData = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                    roomData.Init(r63aOutgoing.RoomData);
                    roomData.AppendBoolean(false);                     //entered room
                    room.RoomData.Serialize(roomData, false);
                    roomData.AppendBoolean(false);                     //forward
                    roomData.AppendBoolean(room.RoomData.IsStaffPick); //is staff pick
                    room.SendToAll(roomData);
                }
            }
        }
コード例 #4
0
        public void AddPublicItem(PublicItem item)
        {
            if (item == null)
            {
                return;
            }

            _publicItems.Add(Convert.ToUInt32(item.Id), item);
        }
コード例 #5
0
        /// <summary>
        ///     Serializes the public rooms.
        /// </summary>
        /// <returns>ServerMessage.</returns>
        internal ServerMessage SerializePublicRooms()
        {
            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("OfficialRoomsMessageComposer"));

            PublicItem[] rooms =
                _publicItems.Values.Where(current => current.ParentId <= 0 && current.RoomData != null).ToArray();

            serverMessage.AppendInteger(rooms.Length);

            foreach (PublicItem current in rooms)
            {
                current.Serialize(serverMessage);

                if (current.ItemType != PublicItemType.Category)
                {
                    continue;
                }

                foreach (PublicItem current2 in _publicItems.Values.Where(x => x.ParentId == current.Id))
                {
                    current2.Serialize(serverMessage);
                }
            }

            if (!_publicItems.Values.Any(current => current.Recommended))
            {
                serverMessage.AppendInteger(0);
            }
            else
            {
                PublicItem room = _publicItems.Values.First(current => current.Recommended);

                if (room != null)
                {
                    serverMessage.AppendInteger(1);
                    room.Serialize(serverMessage);
                }
                else
                {
                    serverMessage.AppendInteger(0);
                }
            }
            serverMessage.AppendInteger(0);

            return(serverMessage);
        }
コード例 #6
0
ファイル: Navigator.cs プロジェクト: dm5wg/Yupi
        internal void ToggleStaffPick()
        {
            uint roomId  = Request.GetUInteger();
            bool current = Request.GetBool();
            Room room    = Yupi.GetGame().GetRoomManager().GetRoom(roomId);

            Yupi.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_Spr", 1, true);
            if (room == null)
            {
                return;
            }
            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                PublicItem pubItem = Yupi.GetGame().GetNavigator().GetPublicItem(roomId);
                if (pubItem == null) // not picked
                {
                    commitableQueryReactor.SetQuery(
                        "INSERT INTO navigator_publics (bannertype, room_id, category_parent_id) VALUES ('0', @roomId, '-2')");
                    commitableQueryReactor.AddParameter("roomId", room.RoomId);
                    commitableQueryReactor.RunQuery();
                    commitableQueryReactor.RunFastQuery("SELECT last_insert_id()");
                    uint       publicItemId = (uint)commitableQueryReactor.GetInteger();
                    PublicItem publicItem   = new PublicItem(publicItemId, 0, string.Empty, string.Empty, string.Empty,
                                                             PublicImageType.Internal, room.RoomId, 0, -2, false, 1, string.Empty);
                    Yupi.GetGame().GetNavigator().AddPublicItem(publicItem);
                }
                else // picked
                {
                    commitableQueryReactor.SetQuery("DELETE FROM navigator_publics WHERE id = @pubId");
                    commitableQueryReactor.AddParameter("pubId", pubItem.Id);
                    commitableQueryReactor.RunQuery();
                    Yupi.GetGame().GetNavigator().RemovePublicItem(pubItem.Id);
                }
                room.RoomData.SerializeRoomData(Response, Session, false, true);
                Yupi.GetGame().GetNavigator().LoadNewPublicRooms();
            }
        }
コード例 #7
0
        /// <summary>
        ///     Serializes the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="showEvents">if set to <c>true</c> [show events].</param>
        /// <param name="enterRoom"></param>
        internal void Serialize(ServerMessage message, bool showEvents = false, bool enterRoom = false)
        {
            message.AppendInteger(Id);
            message.AppendString(Name);
            message.AppendInteger(OwnerId);
            message.AppendString(Owner);
            message.AppendInteger(State);
            message.AppendInteger(UsersNow);
            message.AppendInteger(UsersMax);
            message.AppendString(Description);
            message.AppendInteger(TradeState);
            message.AppendInteger(Score);
            message.AppendInteger(0); // Ranking
            message.AppendInteger(Category);

            message.AppendInteger(TagCount);
            foreach (string current in Tags)
            {
                message.AppendString(current);
            }

            string imageData = null;

            int        enumType   = enterRoom ? 32 : 0;
            PublicItem publicItem = Yupi.GetGame().GetNavigator().GetPublicItem(Id);

            if (publicItem != null && !string.IsNullOrEmpty(publicItem.Image))
            {
                imageData = publicItem.Image;
                enumType += 1;
            }

            if (Group != null)
            {
                enumType += 2;
            }
            if (showEvents && Event != null)
            {
                enumType += 4;
            }
            if (Type == "private")
            {
                enumType += 8;
            }
            if (AllowPets)
            {
                enumType += 16;
            }
            message.AppendInteger(enumType);

            if (imageData != null)
            {
                message.AppendString(imageData);
            }
            if (Group != null)
            {
                message.AppendInteger(Group.Id);
                message.AppendString(Group.Name);
                message.AppendString(Group.Badge);
            }
            if (showEvents && Event != null)
            {
                message.AppendString(Event.Name);
                message.AppendString(Event.Description);
                message.AppendInteger((int)Math.Floor((Event.Time - Yupi.GetUnixTimeStamp()) / 60.0));
            }
        }
コード例 #8
0
 public bool doFilter(string query, PublicItem item)
 {
     return(this.doFilter(query, item.RoomData));
 }
コード例 #9
0
ファイル: Navigator.cs プロジェクト: kessiler/azureEmulator
 internal void ToggleStaffPick()
 {
     var roomId = Request.GetUInteger();
     var current = Request.GetBool();
     var room = Azure.GetGame().GetRoomManager().GetRoom(roomId);
     Azure.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_Spr", 1, true);
     if (room == null) return;
     using (var queryReactor = Azure.GetDatabaseManager().GetQueryReactor())
     {
         var pubItem = Azure.GetGame().GetNavigator().GetPublicItem(roomId);
         if (pubItem == null) // not picked
         {
             queryReactor.SetQuery("INSERT INTO navigator_publics (bannertype, room_id, category_parent_id) VALUES ('0', @roomId, '-2')");
             queryReactor.AddParameter("roomId", room.RoomId);
             queryReactor.RunQuery();
             queryReactor.RunFastQuery("SELECT last_insert_id()");
             var publicItemId = (uint)queryReactor.GetInteger();
             var publicItem = new PublicItem(publicItemId, 0, string.Empty, string.Empty, string.Empty, PublicImageType.Internal, room.RoomId, 0, -2, false, 1, string.Empty);
             Azure.GetGame().GetNavigator().AddPublicItem(publicItem);
         }
         else // picked
         {
             queryReactor.SetQuery("DELETE FROM navigator_publics WHERE id = @pubId");
             queryReactor.AddParameter("pubId", pubItem.Id);
             queryReactor.RunQuery();
             Azure.GetGame().GetNavigator().RemovePublicItem(pubItem.Id);
         }
         room.RoomData.SerializeRoomData(Response, Session, false, true);
         Azure.GetGame().GetNavigator().LoadNewPublicRooms();
     }
 }
コード例 #10
0
        public void Handle(GameClient session, ClientMessage message)
        {
            bool hideFull   = message.PopWiredBoolean();
            int  caterogyId = message.PopWiredInt32();

            if (caterogyId == GetRoomsMessageEvent.PRIVATE_ROOMS) //private rooms
            {
                ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                Message.Init(r26Outgoing.SendRooms);
                Message.AppendBoolean(hideFull);
                Message.AppendInt32(caterogyId);
                Message.AppendInt32(GetRoomsMessageEvent.PRIVATE); //type
                Message.AppendString("Guestrooms");                //caption
                Message.AppendInt32(0);                            //unknown
                Message.AppendInt32(10000);                        //unknown
                Message.AppendInt32(GetRoomsMessageEvent.NONE);    //parent id
                Message.AppendInt32(0);                            //rooms count

                foreach (FlatCat flatCat in Skylight.GetGame().GetNavigatorManager().GetFlatCats())
                {
                    int usersNow = 0;
                    int usersMax = 0;
                    foreach (RoomData room in Skylight.GetGame().GetRoomManager().GetLoadedRooms().Where(r => r.RoomData.Type == "private" && r.RoomData.UsersNow > 0 && r.RoomData.Category == flatCat.Id).OrderByDescending(r => r.RoomData.UsersNow).Take(50).Select(r => r.RoomData).ToList())
                    {
                        usersNow += room.UsersNow;
                        usersMax += room.UsersMax;
                    }

                    Message.AppendInt32(Skylight.GetGame().GetNavigatorManager().GetOldSchoolCategoryThingy2()[new KeyValuePair <int, bool>(flatCat.Id, true)]); //id
                    Message.AppendBoolean(false);                                                                                                                //is room
                    Message.AppendString(flatCat.Caption);
                    Message.AppendInt32(usersNow);                                                                                                               //users now
                    Message.AppendInt32(usersMax);                                                                                                               //users max
                    Message.AppendInt32(GetRoomsMessageEvent.PRIVATE_ROOMS);                                                                                     //parent id
                }

                session.SendMessage(Message);
            }
            else if (caterogyId == GetRoomsMessageEvent.PUBLIC_ROOMS) //public rooms
            {
                ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                Message.Init(r26Outgoing.SendRooms);
                Message.AppendBoolean(hideFull);
                Message.AppendInt32(caterogyId);
                Message.AppendInt32(GetRoomsMessageEvent.PUBLIC); //type
                Message.AppendString("Publics");                  //caption
                Message.AppendInt32(0);                           //unknown
                Message.AppendInt32(10000);                       //unknown
                Message.AppendInt32(GetRoomsMessageEvent.NONE);   //parent id

                foreach (PublicItem category in Skylight.GetGame().GetNavigatorManager().GetPublicRoomItems().Where(i => i.Type == PublicItemType.CATEGORY && i.ParentCategoryID == 0))
                {
                    int usersNow = 0;
                    int usersMax = 0;
                    foreach (PublicItem item in Skylight.GetGame().GetNavigatorManager().GetPublicRoomItems().Where(i => i.ParentCategoryID == category.ID))
                    {
                        usersNow += item.RoomData.UsersNow;
                        usersMax += item.RoomData.UsersMax;
                    }

                    Message.AppendInt32(Skylight.GetGame().GetNavigatorManager().GetOldSchoolCategoryThingy2()[new KeyValuePair <int, bool>(category.ID, false)]); //id
                    Message.AppendBoolean(false);                                                                                                                  //is room
                    Message.AppendString(category.Caption);                                                                                                        //name
                    Message.AppendInt32(usersNow);                                                                                                                 //users now
                    Message.AppendInt32(usersMax);                                                                                                                 //users max
                    Message.AppendInt32(GetRoomsMessageEvent.PUBLIC_ROOMS);                                                                                        //parent id
                }

                foreach (PublicItem item in Skylight.GetGame().GetNavigatorManager().GetPublicRoomItems().Where(i => i.Type != PublicItemType.CATEGORY && i.ParentCategoryID == 0))
                {
                    Message.AppendUInt(item.RoomData.ID);            //id
                    Message.AppendBoolean(true);                     //is room
                    Message.AppendString(item.RoomData.Name);        //name
                    Message.AppendInt32(item.RoomData.UsersNow);     //visitors now
                    Message.AppendInt32(item.RoomData.UsersMax);     //visitors max
                    Message.AppendInt32(caterogyId);                 //category inside
                    Message.AppendString(item.RoomData.Description); //desc
                    Message.AppendUInt(item.RoomData.ID);            //id
                    Message.AppendBoolean(false);                    //unknwon
                    Message.AppendString(item.RoomData.PublicCCTs);  //ccts
                    Message.AppendBoolean(false);                    //unknwon
                    Message.AppendBoolean(true);                     //unknwon
                }

                session.SendMessage(Message);
            }
            else //private room category
            {
                object category;
                Skylight.GetGame().GetNavigatorManager().GetOldSchoolCategoryThingy().TryGetValue(caterogyId, out category);

                if (category is FlatCat)
                {
                    FlatCat flatCat = (FlatCat)category;

                    ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                    Message.Init(r26Outgoing.SendRooms);
                    Message.AppendBoolean(hideFull);
                    Message.AppendInt32(caterogyId);
                    Message.AppendInt32(GetRoomsMessageEvent.PRIVATE);       //type
                    Message.AppendString(flatCat.Caption);
                    Message.AppendInt32(0);                                  //unknown
                    Message.AppendInt32(10000);                              //unknown
                    Message.AppendInt32(GetRoomsMessageEvent.PRIVATE_ROOMS); //parent id

                    List <Room> rooms = Skylight.GetGame().GetRoomManager().GetLoadedRooms().Where(r => !r.RoomData.IsPublicRoom && r.RoomData.Category == flatCat.Id).Take(50).ToList();

                    Message.AppendInt32(rooms.Count);
                    foreach (Room room in rooms)
                    {
                        Message.AppendUInt(room.RoomData.ID);                                                                   //id
                        Message.AppendString(room.RoomData.Name);                                                               //name
                        Message.AppendString(Skylight.GetGame().GetGameClientManager().GetUsernameByID(room.RoomData.OwnerID)); //owner
                        Message.AppendString(room.RoomData.State == RoomStateType.OPEN ? "open" : room.RoomData.State == RoomStateType.LOCKED ? "closed" : "password");
                        Message.AppendInt32(room.RoomData.UsersNow);                                                            //visitors now
                        Message.AppendInt32(room.RoomData.UsersMax);                                                            //visitors max
                        Message.AppendString(room.RoomData.Description);                                                        //desc
                    }

                    session.SendMessage(Message);
                }
                else if (category is PublicItem)
                {
                    PublicItem item = (PublicItem)category;

                    if (item.Type == PublicItemType.CATEGORY)
                    {
                        ServerMessage Message = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);
                        Message.Init(r26Outgoing.SendRooms);
                        Message.AppendBoolean(hideFull);
                        Message.AppendInt32(caterogyId);
                        Message.AppendInt32(GetRoomsMessageEvent.PUBLIC);       //type
                        Message.AppendString(item.Caption);                     //caption
                        Message.AppendInt32(0);                                 //unknown
                        Message.AppendInt32(10000);                             //unknown
                        Message.AppendInt32(GetRoomsMessageEvent.PUBLIC_ROOMS); //parent id

                        foreach (PublicItem item_ in Skylight.GetGame().GetNavigatorManager().GetPublicRoomItems().Where(i => i.Type != PublicItemType.CATEGORY && i.ParentCategoryID == item.ID))
                        {
                            Message.AppendUInt(item_.RoomData.ID);            //id
                            Message.AppendBoolean(true);                      //is room
                            Message.AppendString(item_.RoomData.Name);        //name
                            Message.AppendInt32(item_.RoomData.UsersNow);     //visitors now
                            Message.AppendInt32(item_.RoomData.UsersMax);     //visitors max
                            Message.AppendInt32(caterogyId);                  //category inside
                            Message.AppendString(item_.RoomData.Description); //desc
                            Message.AppendUInt(item_.RoomData.ID);            //id
                            Message.AppendBoolean(false);                     //unknwon
                            Message.AppendString(item_.RoomData.PublicCCTs);  //ccts
                            Message.AppendBoolean(false);                     //unknwon
                            Message.AppendBoolean(true);                      //unknwon
                        }

                        session.SendMessage(Message);
                    }
                }
            }
        }