示例#1
0
        private static void SetIcon(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null || !Instance.CheckUserRights(Session, true))
            {
                return;
            }

            int Junk       = Message.PopWiredInt32();
            int Background = Message.PopWiredInt32();

            if (Background < 1 || Background > 24)
            {
                Background = 1;
            }

            int Foreground = Message.PopWiredInt32();

            if (Foreground < 0 || Foreground > 11)
            {
                Foreground = 0;
            }

            int ObjectCount = Message.PopWiredInt32();

            Dictionary <int, int> Objects = new Dictionary <int, int>();

            for (int i = 0; (i < ObjectCount && i < 10); i++)
            {
                int Position = Message.PopWiredInt32();
                int Item     = Message.PopWiredInt32();

                if (Position < 0 || Position > 10 || Item < 1 || Item > 27 || Objects.ContainsKey(Position))
                {
                    continue;
                }

                Objects.Add(Position, Item);
            }

            Instance.Info.UpdateIcon(Background, Foreground, Objects);
            Session.SendData(RoomUpdatedNotification3Composer.Compose(Instance.RoomId));
            Instance.BroadcastMessage(RoomUpdatedNotification2Composer.Compose(Instance.RoomId));
        }
示例#2
0
        private static void EditRoom(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null || !Instance.CheckUserRights(Session, true))
            {
                return;
            }

            // FQJ@LRoy's Office@fThis is where I handle business. Yeah.J@@RBIJ@Foffice@IbuttsechsAAAA

            uint Id = Message.PopWiredUInt32();

            if (Id != Instance.RoomId)
            {
                return;
            }

            string         Name        = UserInputFilter.FilterString(Message.PopString()).Trim();
            string         Description = UserInputFilter.FilterString(Message.PopString()).Trim();
            RoomAccessType AccessType  = (RoomAccessType)Message.PopWiredInt32();
            string         Password    = UserInputFilter.FilterString(Message.PopString()).Trim();
            int            UserLimit   = Message.PopWiredInt32();
            int            CategoryId  = Message.PopWiredInt32();
            int            TagCount    = Message.PopWiredInt32();

            List <string> Tags = new List <string>();

            for (int i = 0; (i < TagCount && i < 2); i++)
            {
                string Tag = UserInputFilter.FilterString(Message.PopString()).Trim().ToLower();

                if (Tag.Length > 32)
                {
                    Tag = Tag.Substring(0, 32);
                }

                if (Tag.Length > 0 && !Tags.Contains(Tag))
                {
                    Tags.Add(Tag);
                }
            }

            bool AllowPets      = (Message.ReadBytes(1)[0] == 65);
            bool AllowPetEating = (Message.ReadBytes(1)[0] == 65);
            bool AllowBlocking  = (Message.ReadBytes(1)[0] == 65);
            bool HideWalls      = (Message.ReadBytes(1)[0] == 65);
            int  WallThickness  = Message.PopWiredInt32();
            int  FloorThickness = Message.PopWiredInt32();

            if (WallThickness < -2 || WallThickness > 1)
            {
                WallThickness = 0;
            }

            if (FloorThickness < -2 || FloorThickness > 1)
            {
                FloorThickness = 0;
            }

            if (HideWalls && !Session.HasRight("club_vip"))
            {
                HideWalls = false;
            }

            if (Name.Length > 60) // was 25
            {
                Name = Name.Substring(0, 60);
            }

            if (Description.Length > 128)
            {
                Description = Description.Substring(0, 128);
            }

            if (Password.Length > 64)
            {
                Password = Password.Substring(0, 64);
            }

            if (UserLimit > Instance.Model.MaxUsers)
            {
                UserLimit = Instance.Model.MaxUsers;
            }

            if (Name.Length == 0)
            {
                Name = "Room";
            }

            if (AccessType == RoomAccessType.PasswordProtected && Password.Length == 0)
            {
                AccessType = RoomAccessType.Open;
            }

            Instance.Info.EditRoom(Name, Description, AccessType, Password, UserLimit, CategoryId, Tags, AllowPets,
                                   AllowPetEating, AllowBlocking, HideWalls, WallThickness, FloorThickness);

            Session.SendData(RoomUpdatedNotification1Composer.Compose(Instance.RoomId));
            Instance.BroadcastMessage(RoomUpdatedNotification2Composer.Compose(Instance.RoomId));
            Instance.BroadcastMessage(RoomWallsStatusComposer.Compose(Instance.Info.HideWalls, Instance.Info.WallThickness,
                                                                      Instance.Info.FloorThickness));
            //Instance.BroadcastMessage(RoomInfoComposer.Compose(Instance.Info, false));

            if (Instance.Info.AccessType != RoomAccessType.Open && Instance.HasOngoingEvent)
            {
                Instance.StopEvent();
            }
        }