Exemplo n.º 1
0
        /// <summary>
        /// 17 - "@Q"
        /// </summary>
        public void SRCHF()
        {
            string Criteria = Request.Content.Split('%')[1]; // Get plain criteria

            roomInformation[] Rooms = ObjectTree.Game.Rooms.getUserFlatsSearchResult(Criteria);
            if (Rooms.Length > 0)        // Rooms found!
            {
                Response.Initialize(55); // "@w"
                foreach (roomInformation Room in Rooms)
                {
                    roomCategoryInformation pCategory = ObjectTree.Game.Rooms.getRoomCategory(Room.categoryID);
                    if (pCategory != null && pCategory.userRoleHasAccess(Session.User.Role))
                    {
                        if (!(Room.showOwner ||
                              Room.ownerID == Session.User.ID ||
                              Session.User.hasFuseRight("fuse_see_all_roomowners")))
                        {
                            Room.Owner = "-"; // Can't see owner name
                        }
                        Response.Append(Room.ToUserFlatString());
                    }
                }
            }
            else
            {
                Response.Initialize(58); // "@z"
            }
            sendResponse();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parses a full data row of the rooms_categories table to a Woodpecker.Game.Rooms.roomCategory object. On errors, null is returned.
        /// </summary>
        /// <param name="dRow">The System.Data.DataRow object containing the required fields.</param>
        public static roomCategoryInformation Parse(DataRow dRow)
        {
            if (dRow == null)
            {
                return(null);
            }
            else
            {
                roomCategoryInformation ret = new roomCategoryInformation();
                try
                {
                    ret.ID                    = (int)dRow["id"];
                    ret.parentID              = (int)dRow["parentid"];
                    ret.isNode                = ((string)dRow["isnode"] == "1");
                    ret.Name                  = (string)dRow["name"];
                    ret.forPublicSpaces       = ((string)dRow["publicspaces"] == "1");
                    ret.allowTrading          = ((string)dRow["allowtrading"] == "1");
                    ret.minimumAccessRole     = (userRole)int.Parse(dRow["minrole_access"].ToString());
                    ret.minimumSetFlatCatRole = (userRole)int.Parse(dRow["minrole_setflatcat"].ToString());
                }
                catch { ret = null; }

                return(ret);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the instance of a room category and updates the active user count in the category if neccessary.
        /// </summary>
        /// <param name="ID">The database ID of the category to return.</param>
        public roomCategoryInformation getRoomCategory(int ID)
        {
            if (mCategories.ContainsKey(ID))
            {
                roomCategoryInformation pCategory = mCategories[ID];
                pCategory.refreshUserCounts();

                return(pCategory);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes the room category informations and stores them in a persistent collection object for further reference.
        /// </summary>
        public void initRoomCategories()
        {
            Logging.Log("Initializing room categories...");
            mCategories.Clear();

            Database dbClient = new Database(true, true);

            if (dbClient.Ready)
            {
                foreach (DataRow dRow in dbClient.getTable("SELECT * FROM rooms_categories ORDER BY orderid ASC").Rows)
                {
                    roomCategoryInformation pCategory = roomCategoryInformation.Parse(dRow);
                    if (pCategory != null)
                    {
                        mCategories.Add(pCategory.ID, pCategory);
                    }
                }
            }
            Logging.Log("Initialized " + mCategories.Count + " room categories.");
        }
Exemplo n.º 5
0
        /// <summary>
        /// 153 - "BY"
        /// </summary>
        public void SETFLATCAT()
        {
            int[] Parameters = Request.getWiredParameters();
            int   roomID     = Parameters[0];
            int   categoryID = Parameters[1];

            roomCategoryInformation newCategory = Engine.Game.Rooms.getRoomCategory(categoryID);

            if (newCategory != null && newCategory.userRoleCanPutFlat(Session.User.Role)) // Valid category
            {
                roomInformation Room = Engine.Game.Rooms.getRoomInformation(roomID);
                if (Room != null && Room.ownerID == Session.User.ID && Room.categoryID != newCategory.ID) // Valid change
                {
                    Room.categoryID = newCategory.ID;
                    Room.updateSettings();
                    if (Engine.Game.Rooms.roomInstanceRunning(roomID))
                    {
                        Engine.Game.Rooms.getRoomInstance(roomID).Information = Room;
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 17 - "@Q"
        /// </summary>
        public void SRCHF()
        {
            string Criteria = Request.Content.Split('%')[1]; // Get plain criteria

            roomInformation[] Rooms = Engine.Game.Rooms.getUserFlatsSearchResult(Criteria);
            if (Rooms.Length > 0)        // Rooms found!
            {
                Response.Initialize(55); // "@w"
                foreach (roomInformation Room in Rooms)
                {
                    roomCategoryInformation pCategory = Engine.Game.Rooms.getRoomCategory(Room.categoryID);
                    if (pCategory != null && pCategory.userRoleHasAccess(Session.User.Role))
                    {
                        if (!Room.showOwner)
                        {
                            if (Room.ownerID != Session.User.ID && !Session.User.hasFuseRight("fuse_see_all_roomowners"))
                            {
                                if (Room.Owner == Criteria) // Was searching for room owners
                                {
                                    continue;               // Can't view this room at all
                                }
                                else
                                {
                                    Room.Owner = "-";
                                }
                            }
                        }

                        Response.Append(Room.ToUserFlatString());
                    }
                }
            }
            else
            {
                Response.Initialize(58); // "@z"
            }
            sendResponse();
        }
Exemplo n.º 7
0
        /// <summary>
        /// 21 - "@U"
        /// </summary>
        public void GETFLATINFO()
        {
            int             roomID = int.Parse(Request.Content);
            roomInformation Room   = Engine.Game.Rooms.getRoomInformation(roomID);

            if (Room == null || !Room.isUserFlat) // Room is not found / not valid
            {
                return;
            }

            Response.Initialize(54); // "@v"

            Response.appendWired(Room.superUsers);
            Response.appendWired((int)Room.accessType);
            Response.appendWired(roomID);

            if (Room.showOwner || Room.ownerID == Session.User.ID || Session.User.hasFuseRight("fuse_see_all_roomowners"))
            {
                Response.appendClosedValue(Room.Owner);
            }
            else
            {
                Response.appendClosedValue("-");
            }

            Response.appendClosedValue(Room.modelType);
            Response.appendClosedValue(Room.Name);
            Response.appendClosedValue(Room.Description);

            roomCategoryInformation Category = Engine.Game.Rooms.getRoomCategory(Room.categoryID);

            Response.appendWired(Room.showOwner);
            Response.appendWired(Category != null && Category.allowTrading);
            Response.appendWired(Room.currentVisitors);
            Response.appendWired(Room.maxVisitors);

            sendResponse();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Parses a full data row of the rooms_categories table to a Woodpecker.Game.Rooms.roomCategory object. On errors, null is returned.
        /// </summary>
        /// <param name="dRow">The System.Data.DataRow object containing the required fields.</param>
        public static roomCategoryInformation Parse(DataRow dRow)
        {
            if (dRow == null)
                return null;
            else
            {
                roomCategoryInformation ret = new roomCategoryInformation();
                try
                {
                    ret.ID = (int)dRow["id"];
                    ret.parentID = (int)dRow["parentid"];
                    ret.isNode = ((string)dRow["isnode"] == "1");
                    ret.Name = (string)dRow["name"];
                    ret.forPublicSpaces = ((string)dRow["publicspaces"] == "1");
                    ret.allowTrading = ((string)dRow["allowtrading"] == "1");
                    ret.minimumAccessRole = (userRole)int.Parse(dRow["minrole_access"].ToString());
                    ret.minimumSetFlatCatRole = (userRole)int.Parse(dRow["minrole_setflatcat"].ToString());
                }
                catch { ret = null; }

                return ret;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 150 - "BV"
        /// </summary>
        public void NAVIGATE()
        {
            int categoryID = Request.getWiredParameters()[1];

            Response.Initialize(220); // "C\"
            roomCategoryInformation pCategory = Engine.Game.Rooms.getRoomCategory(categoryID);

            if (pCategory != null && pCategory.userRoleHasAccess(Session.User.Role)) // Valid category
            {
                bool hideFull = wireEncoding.decodeBoolean(Request.Content.Substring(0, 1));

                #region Build category info
                Response.appendWired(hideFull);
                Response.appendWired(pCategory.ID);
                if (pCategory.forPublicSpaces)
                {
                    Response.appendWired(false); // Public spaces
                }
                else
                {
                    Response.appendWired(2); // User flats
                }
                Response.appendClosedValue(pCategory.Name);
                Response.appendWired(pCategory.currentVisitors);
                Response.appendWired(pCategory.maxVisitors);
                Response.appendWired(pCategory.parentID);

                List <roomInformation> Rooms = Engine.Game.Rooms.getCategoryRooms(categoryID, !pCategory.forPublicSpaces);
                if (!pCategory.forPublicSpaces) // User flats
                {
                    Response.appendWired(Rooms.Count);
                }
                #endregion

                #region Build rooms info
                foreach (roomInformation lRoom in Rooms)
                {
                    if (!hideFull || lRoom.currentVisitors <= lRoom.maxVisitors)
                    {
                        Response.Append(lRoom.ToString(Session.User));
                    }
                }
                #endregion

                #region Build subcategory info
                foreach (roomCategoryInformation lSubcategory in Engine.Game.Rooms.getChildRoomCategories(pCategory.ID))
                {
                    if (lSubcategory.userRoleHasAccess(Session.User.Role) && (!hideFull || lSubcategory.currentVisitors < lSubcategory.maxVisitors)) // User has access to this room category and requests to see this category
                    {
                        Response.appendWired(lSubcategory.ID);
                        Response.appendWired(false);
                        Response.appendClosedValue(lSubcategory.Name);
                        Response.appendWired(lSubcategory.currentVisitors);
                        Response.appendWired(lSubcategory.maxVisitors);
                        Response.appendWired(pCategory.ID);
                    }
                }
                #endregion
            }

            sendResponse();
        }