当前位置: 首页>>代码示例>>C#>>正文


C# Session.HasRight方法代码示例

本文整理汇总了C#中Reality.Game.Sessions.Session.HasRight方法的典型用法代码示例。如果您正苦于以下问题:C# Session.HasRight方法的具体用法?C# Session.HasRight怎么用?C# Session.HasRight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Reality.Game.Sessions.Session的用法示例。


在下文中一共展示了Session.HasRight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Compose

        public static ServerMessage Compose(Session Session, Dictionary<int, CatalogPage> Pages)
        {
            ServerMessage Message = new ServerMessage(OpcodesOut.CATALOG_INDEX);
            SerializePage(Message, Pages[-1], CalcTreeSize(Session, Pages, -1));

            foreach (CatalogPage Page in Pages.Values)
            {
                if (Page.ParentId != -1 || (Page.RequiredRight.Length > 0 && !Session.HasRight(Page.RequiredRight)))
                {
                    continue;
                }

                SerializePage(Message, Page, CalcTreeSize(Session, Pages, Page.Id));

                foreach (CatalogPage ChildPage in Pages.Values)
                {
                    if (ChildPage.ParentId != Page.Id || (ChildPage.RequiredRight.Length > 0 && !Session.HasRight(ChildPage.RequiredRight)))
                    {
                        continue;
                    }

                    SerializePage(Message, ChildPage, 0);
                }
            }

            return Message;
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:27,代码来源:CatalogIndexComposer.cs

示例2: CheckUserRights

        public bool CheckUserRights(Session Session, bool RequireOwnership = false)
        {
            bool IsOwner = (Session.HasRight("room_rights_owner") || Session.CharacterId == Info.OwnerId);

            if (RequireOwnership)
            {
                return IsOwner;
            }

            return (IsOwner || Session.HasRight("room_rights") || mUsersWithRights.Contains(Session.CharacterId));
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:11,代码来源:Rights.cs

示例3: GetWardrobeSlotAmountForSession

        public static int GetWardrobeSlotAmountForSession(Session Session)
        {
            int WardrobeSlots = 0;

            if (Session.HasRight("club_regular"))
            {
                WardrobeSlots += 5;
            }

            if (Session.HasRight("club_vip"))
            {
                WardrobeSlots += 5;
            }

            return WardrobeSlots;
        }
开发者ID:DaimOwns,项目名称:ProRP,代码行数:16,代码来源:Inventory.cs

示例4: AlertRoom

        private static void AlertRoom(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("moderation_tool"))
            {
                return;
            }

            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null)
            {
                Session.SendData(NotificationMessageComposer.Compose("Could not send room alert."));
                return;
            }

            int Unknown1 = Message.PopWiredInt32();
            int AlertMode = Message.PopWiredInt32();
            string AlertMessage = Message.PopString();
            bool IsCaution = AlertMode != 3;

            Instance.SendModerationAlert(AlertMessage, IsCaution);

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                ModerationLogs.LogModerationAction(MySqlClient, Session, "Sent room " + (IsCaution ? "caution" : "message"),
                    "Room " + Instance.Info.Name + " (ID " + Instance.RoomId + "): '" + AlertMessage + "'");
            }
        }
开发者ID:DaimOwns,项目名称:ProRP,代码行数:28,代码来源:ModerationHandler.cs

示例5: BanUser

        private static void BanUser(Session Session, ClientMessage Message)
        {
            if (!Session.HasRight("moderation_tool"))
            {
                return;
            }

            uint UserId = Message.PopWiredUInt32();
            string MessageText = Message.PopString();
            double Length = (Message.PopWiredInt32() * 3600);

            Session TargetSession = SessionManager.GetSessionByCharacterId(UserId);

            if (TargetSession == null || TargetSession.HasRight("moderation_tool"))
            {
                Session.SendData(NotificationMessageComposer.Compose("This user is not online or you do not have permission to ban them.\nPlease use housekeeping to ban users that are offline."));
                return;
            }

            SessionManager.StopSession(TargetSession.Id);

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                ModerationBanManager.BanUser(MySqlClient, UserId, MessageText, Session.CharacterId, Length);
                ModerationLogs.LogModerationAction(MySqlClient, Session, "Banned user",
                    "User '" + TargetSession.CharacterInfo.Username + "' (ID " + TargetSession.CharacterId + ") for " +
                    Length + " hours: '" + MessageText + "'");
            }
        }
开发者ID:DaimOwns,项目名称:ProRP,代码行数:29,代码来源:ModerationHandler.cs

示例6: Compose

        public static ServerMessage Compose(Session Session)
        {
            ServerMessage Message = new ServerMessage(OpcodesOut.USER_RIGHTS);

            if (Session.HasRight("club_vip"))
            {
                Message.AppendInt32(2);
            }
            else if (Session.HasRight("club_regular"))
            {
                Message.AppendInt32(1);
            }
            else
            {
                Message.AppendInt32(0);
            }

            // TODO: Dig in to the mod tool and other staff stuff further to figure out how much this does

            Message.AppendInt32(Session.HasRight("hotel_admin") ? 1000 : 0);

            return Message;
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:23,代码来源:FuseRightsListComposer.cs

示例7: Compose

        public static ServerMessage Compose(Session Session, List<string> UserMessagePresets,
            Dictionary<string, Dictionary<string, string>> UserActionPresets, List<string> RoomMessagePresets)
        {
            ServerMessage Message = new ServerMessage(OpcodesOut.MODERATION_TOOL_INIT);
            Message.AppendInt32(-1);
            Message.AppendInt32(UserMessagePresets.Count);

            foreach (string Preset in UserMessagePresets)
            {
                Message.AppendStringWithBreak(Preset);
            }

            Message.AppendInt32(UserActionPresets.Count);

            foreach (KeyValuePair<string, Dictionary<string, string>> PresetCategory in UserActionPresets)
            {
                Message.AppendStringWithBreak(PresetCategory.Key);
                Message.AppendInt32(PresetCategory.Value.Count);

                foreach (KeyValuePair<string, string> Preset in PresetCategory.Value)
                {
                    Message.AppendStringWithBreak(Preset.Key);
                    Message.AppendStringWithBreak(Preset.Value);
                }
            }

            Message.AppendBoolean(Session.HasRight("moderation_tickets")); // Tickets
            Message.AppendInt32(1); // Chatlogs
            Message.AppendInt32(1); // Message, user action, send caution
            Message.AppendInt32(1); // kick
            Message.AppendInt32(1); // ban
            Message.AppendInt32(1); // caution, message
            Message.AppendInt32(1); // ?

            Message.AppendInt32(RoomMessagePresets.Count);

            foreach (string Preset in RoomMessagePresets)
            {
                Message.AppendStringWithBreak(Preset);
            }

            return Message;
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:43,代码来源:ModerationToolComposer.cs

示例8: CalcTreeSize

        private static int CalcTreeSize(Session Session, Dictionary<int, CatalogPage> Pages, int ParentId)
        {
            int Num = 0;

            foreach (CatalogPage Page in Pages.Values)
            {
                if (Page.RequiredRight.Length > 0 && !Session.HasRight(Page.RequiredRight))
                {
                    continue;
                }

                if (Page.ParentId == ParentId)
                {
                    Num++;
                }
            }

            return Num;
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:19,代码来源:CatalogIndexComposer.cs

示例9: GetFriendsRooms

        private static void GetFriendsRooms(Session Session, ClientMessage Message)
        {
            if (Session.HasRight("hotel_admin"))
            {
                ServerMessage Response = TryGetResponseFromCache(Session.CharacterId, Message);

                if (Response != null)
                {
                    Session.SendData(Response);
                    return;
                }

                List<RoomInfo> Rooms = new List<RoomInfo>();
                ReadOnlyCollection<uint> Friends = Session.MessengerFriendCache.Friends;

                if (Friends.Count > 0)
                {
                    using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                    {
                        StringBuilder QueryBuilder = new StringBuilder("SELECT * FROM rooms WHERE ");

                        int i = 0;

                        foreach (uint FriendId in Friends)
                        {
                            if (i >= 1)
                            {
                                QueryBuilder.Append("OR ");
                            }

                            QueryBuilder.Append("owner_id = " + FriendId + " ");
                            i++;
                        }

                        QueryBuilder.Append("ORDER BY current_users DESC LIMIT 50");

                        DataTable Table = MySqlClient.ExecuteQueryTable(QueryBuilder.ToString());

                        foreach (DataRow Row in Table.Rows)
                        {
                            Rooms.Add(RoomInfoLoader.GenerateRoomInfoFromRow(Row));
                        }
                    }
                }

                Response = NavigatorRoomListComposer.Compose(0, 3, string.Empty, Rooms);
                AddToCacheIfNeeded(Session.CharacterId, Message, Response);
                Session.SendData(Response);
            }
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:50,代码来源:Navigator.cs

示例10: GetEventRooms

        private static void GetEventRooms(Session Session, ClientMessage Message)
        {
            if (Session.HasRight("hotel_admin"))
            {
                ServerMessage Response = TryGetResponseFromCache(0, Message);

                if (Response != null)
                {
                    Session.SendData(Response);
                    return;
                }

                int Category = -1;
                int.TryParse(Message.PopString(), out Category);

                IEnumerable<RoomInstance> Rooms =
                    (from RoomInstance in RoomManager.RoomInstances
                     where (RoomInstance.Value.HasOngoingEvent &&
                         (Category == -1 || RoomInstance.Value.Event.CategoryId == Category))
                     orderby RoomInstance.Value.Event.TimestampStarted descending
                     select RoomInstance.Value).Take(50);

                Response = NavigatorRoomListComposer.Compose(Category, 12, string.Empty, Rooms.ToList(), true);
                AddToCacheIfNeeded(0, Message, Response);
                Session.SendData(Response);
            }
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:27,代码来源:Navigator.cs

示例11: GetCategories

        private static void GetCategories(Session Session, ClientMessage Message)
        {
            if (Session.HasRight("hotel_admin"))
            {
                ServerMessage Response = TryGetResponseFromCache(0, Message);

                if (Response != null)
                {
                    Session.SendData(Response);
                    return;
                }

                Response = NavigatorFlatCategoriesComposer.Compose(mFlatCategories);
                AddToCacheIfNeeded(0, Message, Response);
                Session.SendData(Response);
            }
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:17,代码来源:Navigator.cs

示例12: SetWallItem

        public string SetWallItem(Session Session, string[] Data, Item Item)
        {
            bool AlreadyContained = mItems.ContainsKey(Item.Id);
            int TotalLimitCount = AlreadyContained ? mItems.Count - 1 : mItems.Count;
            int SpecificLimitCount = mItemLimitCache.ContainsKey(Item.Definition.Behavior) ? (AlreadyContained ?
                mItemLimitCache[Item.Definition.Behavior] - 1 : mItemLimitCache[Item.Definition.Behavior]) : 0;

            if (Item.Definition.RoomLimit > 0 && SpecificLimitCount >= Item.Definition.RoomLimit)
            {
                Session.SendData(NotificationMessageComposer.Compose("This room cannot hold any more furniture of this type."));
                return string.Empty;
            }

            if (TotalLimitCount >= (int)ConfigManager.GetValue("rooms.limit.furni"))
            {
                Session.SendData(RoomItemPlacementErrorComposer.Compose(RoomItemPlacementErrorCode.FurniLimitReached));
                return string.Empty;
            }

            if (Data.Length != 3 || !Data[0].StartsWith(":w=") || !Data[1].StartsWith("l=") || (Data[2] != "r" &&
                Data[2] != "l"))
            {
                return string.Empty;
            }

            string wBit = Data[0].Substring(3, Data[0].Length - 3);
            string lBit = Data[1].Substring(2, Data[1].Length - 2);

            if (!wBit.Contains(",") || !lBit.Contains(","))
            {
                return string.Empty;
            }

            int w1 = 0;
            int w2 = 0;
            int l1 = 0;
            int l2 = 0;

            int.TryParse(wBit.Split(',')[0], out w1);
            int.TryParse(wBit.Split(',')[1], out w2);
            int.TryParse(lBit.Split(',')[0], out l1);
            int.TryParse(lBit.Split(',')[1], out l2);

            if (!Session.HasRight("hotel_admin") && (w1 < 0 || w2 < 0 || l1 < 0 || l2 < 0 || w1 > 200 || w2 > 200 || l1 > 200 || l2 > 200))
            {
                return string.Empty;
            }

            string WallPos = ":w=" + w1 + "," + w2 + " l=" + l1 + "," + l2 + " " + Data[2];

            lock (mItemSyncRoot)
            {
                if (!mItems.ContainsKey(Item.Id))
                {
                    mItems.Add(Item.Id, Item);
                    IncrecementFurniLimitCache(Item.Definition.Behavior);
                }
            }

            return WallPos;
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:61,代码来源:Items.cs

示例13: PerformSearch

        private static void PerformSearch(Session Session, ClientMessage Message)
        {
            if (Session.HasRight("hotel_admin"))
            {
                ServerMessage Response = TryGetResponseFromCache(0, Message);

                if (Response != null)
                {
                    Session.SendData(Response);
                    return;
                }

                Dictionary<uint, RoomInfo> Rooms = new Dictionary<uint, RoomInfo>();
                string Query = UserInputFilter.FilterString(Message.PopString()).ToLower().Trim();
                int SearchEventCatId = 0;

                if (mEventSearchQueries.ContainsKey(Query.ToLower()))
                {
                    SearchEventCatId = mEventSearchQueries[Query.ToLower()];
                }

                // Limit query length. just a precaution.
                if (Query.Length > 64)
                {
                    Query = Query.Substring(0, 64);
                }

                if (Query.Length > 0)
                {
                    IEnumerable<RoomInstance> InstanceMatches =
                        (from RoomInstance in RoomManager.RoomInstances
                         where RoomInstance.Value.HumanActorCount > 0 &&
                             RoomInstance.Value.Info.Type == RoomType.Flat &&
                             (RoomInstance.Value.Info.OwnerName.StartsWith(Query) ||
                             RoomInstance.Value.SearchableTags.Contains(Query) ||
                             RoomInstance.Value.Info.Name.Contains(Query) ||
                             (RoomInstance.Value.HasOngoingEvent &&
                             (RoomInstance.Value.Event.Name.StartsWith(Query) ||
                             (SearchEventCatId > 0 && RoomInstance.Value.Event.CategoryId == SearchEventCatId))))
                         orderby RoomInstance.Value.HumanActorCount descending
                         select RoomInstance.Value).Take(50);

                    foreach (RoomInstance Instance in InstanceMatches)
                    {
                        Rooms.Add(Instance.RoomId, Instance.Info);
                    }

                    if (Rooms.Count < 50) // need db results?
                    {
                        using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                        {
                            MySqlClient.SetParameter("query", Query + "%");
                            MySqlClient.SetParameter("fquery", "%" + Query + "%");

                            uint ToUid = CharacterResolverCache.GetUidFromName(Query);

                            if (ToUid > 0)
                            {
                                MySqlClient.SetParameter("owneruid", ToUid);
                            }

                            DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM rooms WHERE name LIKE @query AND type = 'flat' OR tags LIKE @fquery AND type = 'flat'" + (ToUid > 0 ? " OR owner_id = @owneruid AND type = 'flat'" : string.Empty) + " LIMIT 50");

                            foreach (DataRow Row in Table.Rows)
                            {
                                uint RoomId = (uint)Row["id"];

                                if (!Rooms.ContainsKey(RoomId))
                                {
                                    Rooms.Add(RoomId, RoomInfoLoader.GenerateRoomInfoFromRow(Row));
                                }
                            }
                        }
                    }
                }

                Response = NavigatorRoomListComposer.Compose(1, 9, Query, Rooms.Values.Take(50).ToList());
                AddToCacheIfNeeded(0, Message, Response);
                Session.SendData(Response);
            }
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:81,代码来源:Navigator.cs

示例14: GetRecentRooms

        private static void GetRecentRooms(Session Session, ClientMessage Message)
        {
            if (Session.HasRight("hotel_admin"))
            {
                ServerMessage Response = TryGetResponseFromCache(Session.CharacterId, Message);

                if (Response != null)
                {
                    Session.SendData(Response);
                    return;
                }

                List<uint> VisitedUids = new List<uint>();
                List<RoomInfo> Rooms = new List<RoomInfo>();

                using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                {
                    MySqlClient.SetParameter("userid", Session.CharacterId);
                    DataTable Table = MySqlClient.ExecuteQueryTable("SELECT room_id FROM room_visits WHERE user_id = @userid ORDER BY timestamp_entered DESC LIMIT 50");

                    foreach (DataRow Row in Table.Rows)
                    {
                        uint Id = (uint)Row["room_id"];

                        if (VisitedUids.Contains(Id))
                        {
                            continue;
                        }

                        RoomInfo Info = RoomInfoLoader.GetRoomInfo(Id);

                        if (Info == null || Info.Type == RoomType.Public)
                        {
                            continue;
                        }

                        Rooms.Add(Info);
                        VisitedUids.Add(Info.Id);
                    }
                }

                Response = NavigatorRoomListComposer.Compose(0, 7, string.Empty, Rooms);
                AddToCacheIfNeeded(Session.CharacterId, Message, Response);
                Session.SendData(Response);
            }
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:46,代码来源:Navigator.cs

示例15: GetPopularTags

        private static void GetPopularTags(Session Session, ClientMessage Message)
        {
            if (Session.HasRight("hotel_admin"))
            {
                ServerMessage Response = TryGetResponseFromCache(0, Message);

                if (Response != null)
                {
                    Session.SendData(Response);
                    return;
                }

                IEnumerable<List<string>> Tags =
                    (from RoomInstance in RoomManager.RoomInstances
                     where RoomInstance.Value.HumanActorCount > 0
                     orderby RoomInstance.Value.HumanActorCount descending
                     select RoomInstance.Value.SearchableTags).Take(50);

                Dictionary<string, int> TagValues = new Dictionary<string, int>();

                foreach (List<string> TagList in Tags)
                {
                    foreach (string Tag in TagList)
                    {
                        if (!TagValues.ContainsKey(Tag))
                        {
                            TagValues.Add(Tag, 1);
                        }
                        else
                        {
                            TagValues[Tag]++;
                        }
                    }
                }

                List<KeyValuePair<string, int>> SortedTags = new List<KeyValuePair<string, int>>(TagValues);

                SortedTags.Sort((FirstPair, NextPair) =>
                {
                    return FirstPair.Value.CompareTo(NextPair.Value);
                });

                SortedTags.Reverse();

                Response = NavigatorPopularTagListComposer.Compose(SortedTags);
                AddToCacheIfNeeded(0, Message, Response);
                Session.SendData(Response);
            }
        }
开发者ID:BjkGkh,项目名称:BobbaRP,代码行数:49,代码来源:Navigator.cs


注:本文中的Reality.Game.Sessions.Session.HasRight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。