Exemplo n.º 1
0
 public RoomInfo(uint Id, RoomType Type, uint OwnerId, string Name, string Description, List<string> Tags,
     RoomAccessType AccessType, string Password, RoomIcon Icon, int CategoryId, int MaxUsers, string Swfs,
     int Score, string ModelName, bool AllowPets, bool AllowPetEating, bool DisableBlocking, bool HideWalls,
     string PubInternalName, int WallThickness, int FloorThickness, Dictionary<string, string> Decorations)
 {
     mId = Id;
     mType = Type;
     mOwnerId = OwnerId;
     mName = Name;
     mDescription = Description;
     mTags = Tags;
     mAccessType = AccessType;
     mPassword = Password;
     mIcon = Icon;
     mCategoryId = CategoryId;
     mMaxUsers = MaxUsers;
     mSwfs = Swfs;
     mCacheAge = UnixTimestamp.GetCurrent();
     mScore = Score;
     mModelName = ModelName;
     mAllowPets = AllowPets;
     mAllowPetEating = AllowPetEating;
     mDisableRoomBlocking = DisableBlocking;
     mHideWalls = HideWalls;
     mPubInternalName = PubInternalName;
     mWallThickness = WallThickness;
     mFloorThickness = FloorThickness;
     mDecorations = Decorations;
     mSyncRoot = new object();
 }
Exemplo n.º 2
0
 public RoomInfo(uint Id, RoomType Type, uint OwnerId, string Name, string Description, List <string> Tags,
                 RoomAccessType AccessType, string Password, RoomIcon Icon, int CategoryId, int MaxUsers, string Swfs,
                 int Score, string ModelName, bool AllowPets, bool AllowPetEating, bool DisableBlocking, bool HideWalls,
                 string PubInternalName, int WallThickness, int FloorThickness, Dictionary <string, string> Decorations)
 {
     mId                  = Id;
     mType                = Type;
     mOwnerId             = OwnerId;
     mName                = Name;
     mDescription         = Description;
     mTags                = Tags;
     mAccessType          = AccessType;
     mPassword            = Password;
     mIcon                = Icon;
     mCategoryId          = CategoryId;
     mMaxUsers            = MaxUsers;
     mSwfs                = Swfs;
     mCacheAge            = UnixTimestamp.GetCurrent();
     mScore               = Score;
     mModelName           = ModelName;
     mAllowPets           = AllowPets;
     mAllowPetEating      = AllowPetEating;
     mDisableRoomBlocking = DisableBlocking;
     mHideWalls           = HideWalls;
     mPubInternalName     = PubInternalName;
     mWallThickness       = WallThickness;
     mFloorThickness      = FloorThickness;
     mDecorations         = Decorations;
     mSyncRoot            = new object();
 }
Exemplo n.º 3
0
        public static RoomInfo GenerateRoomInfoFromRow(DataRow Row)
        {
            List <string> Tags = new List <string>();

            foreach (string Tag in Row["tags"].ToString().Split(','))
            {
                Tags.Add(Tag);
            }

            RoomAccessType AccessType = RoomAccessType.Open;

            switch (Row["access_type"].ToString())
            {
            case "doorbell":

                AccessType = RoomAccessType.Locked;
                break;

            case "password":

                AccessType = RoomAccessType.PasswordProtected;
                break;
            }

            string   RawIconData = (string)Row["icon"];
            RoomIcon Icon        = new RoomIcon();

            if (RawIconData.Length > 0)
            {
                Icon.Deserialize((string)Row["icon"]);
            }

            Dictionary <string, string> Decorations = new Dictionary <string, string>();

            string[] DecorationBits = Row["decorations"].ToString().Split('|');

            foreach (string DecoBit in DecorationBits)
            {
                string[] Sub = DecoBit.Split('=');

                if (Sub.Length == 2)
                {
                    Decorations.Add(Sub[0], Sub[1]);
                }
            }

            return(new RoomInfo((uint)Row["id"], (Row["type"].ToString() == "public" ? RoomType.Public : RoomType.Flat),
                                (uint)Row["owner_id"], (string)Row["name"], (string)Row["description"], Tags, AccessType, (string)Row["password"],
                                Icon, (int)Row["category"], (int)Row["max_users"], (string)Row["swfs"], (int)Row["score"], (string)Row["model"],
                                (Row["allow_pets"].ToString() == "1"), (Row["allow_pet_eating"].ToString() == "1"),
                                (Row["disable_blocking"].ToString() == "1"), (Row["hide_walls"].ToString() == "1"),
                                (string)Row["pub_internal_name"], (int)Row["thickness_wall"], (int)Row["thickness_floor"], Decorations));
        }
Exemplo n.º 4
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();
            }
        }
Exemplo n.º 5
0
        public void EditRoom(string Name, string Description, RoomAccessType AccessType, string Password, int UserLimit,
            int CategoryId, List<string> Tags, bool AllowPets, bool AllowPetEating, bool DisableBlocking, bool HideWalls,
            int WallThickness, int FloorThickness)
        {
            lock (mSyncRoot)
            {
                mName = Name;
                mDescription = Description;
                mAccessType = AccessType;
                mPassword = Password;
                mMaxUsers = UserLimit;
                mCategoryId = CategoryId;
                mTags = Tags;
                mAllowPets = AllowPets;
                mAllowPetEating = AllowPetEating;
                mDisableRoomBlocking = DisableBlocking;
                mHideWalls = HideWalls;
                mWallThickness = WallThickness;
                mFloorThickness = FloorThickness;

                using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                {
                    StringBuilder FormattedTags = new StringBuilder();

                    foreach (string Tag in Tags)
                    {
                        if (FormattedTags.Length > 0)
                        {
                            FormattedTags.Append(",");
                        }

                        FormattedTags.Append(Tag);
                    }

                    string AccessTypeString = "open";

                    if (mAccessType == RoomAccessType.PasswordProtected)
                    {
                        AccessTypeString = "password";
                    }
                    else if (mAccessType == RoomAccessType.Locked)
                    {
                        AccessTypeString = "doorbell";
                    }

                    MySqlClient.SetParameter("id", mId);
                    MySqlClient.SetParameter("name", mName);
                    MySqlClient.SetParameter("description", mDescription);
                    MySqlClient.SetParameter("accesstype", AccessTypeString);
                    MySqlClient.SetParameter("password", mPassword);
                    MySqlClient.SetParameter("maxusers", mMaxUsers);
                    MySqlClient.SetParameter("categoryid", mCategoryId);
                    MySqlClient.SetParameter("allowpets", mAllowPets ? "1" : "0");
                    MySqlClient.SetParameter("allowpeteating", mAllowPetEating ? "1" : "0");
                    MySqlClient.SetParameter("disableblocking", mDisableRoomBlocking ? "1" : "0");
                    MySqlClient.SetParameter("hidewalls", mHideWalls ? "1" : "0");
                    MySqlClient.SetParameter("tags", FormattedTags.ToString());
                    MySqlClient.SetParameter("wthickness", mWallThickness);
                    MySqlClient.SetParameter("fthickness", mFloorThickness);
                    MySqlClient.ExecuteNonQuery("UPDATE rooms SET name = @name, description = @description, tags = @tags, access_type = @accesstype, password = @password, category = @categoryid, max_users = @maxusers, allow_pets = @allowpets, allow_pet_eating = @allowpeteating, disable_blocking = @disableblocking, hide_walls = @hidewalls, thickness_wall = @wthickness, thickness_floor = @fthickness WHERE id = @id LIMIT 1");
                }
            }
        }
Exemplo n.º 6
0
        public void EditRoom(string Name, string Description, RoomAccessType AccessType, string Password, int UserLimit,
                             int CategoryId, List <string> Tags, bool AllowPets, bool AllowPetEating, bool DisableBlocking, bool HideWalls,
                             int WallThickness, int FloorThickness)
        {
            lock (mSyncRoot)
            {
                mName                = Name;
                mDescription         = Description;
                mAccessType          = AccessType;
                mPassword            = Password;
                mMaxUsers            = UserLimit;
                mCategoryId          = CategoryId;
                mTags                = Tags;
                mAllowPets           = AllowPets;
                mAllowPetEating      = AllowPetEating;
                mDisableRoomBlocking = DisableBlocking;
                mHideWalls           = HideWalls;
                mWallThickness       = WallThickness;
                mFloorThickness      = FloorThickness;

                using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                {
                    StringBuilder FormattedTags = new StringBuilder();

                    foreach (string Tag in Tags)
                    {
                        if (FormattedTags.Length > 0)
                        {
                            FormattedTags.Append(",");
                        }

                        FormattedTags.Append(Tag);
                    }

                    string AccessTypeString = "open";

                    if (mAccessType == RoomAccessType.PasswordProtected)
                    {
                        AccessTypeString = "password";
                    }
                    else if (mAccessType == RoomAccessType.Locked)
                    {
                        AccessTypeString = "doorbell";
                    }

                    MySqlClient.SetParameter("id", mId);
                    MySqlClient.SetParameter("name", mName);
                    MySqlClient.SetParameter("description", mDescription);
                    MySqlClient.SetParameter("accesstype", AccessTypeString);
                    MySqlClient.SetParameter("password", mPassword);
                    MySqlClient.SetParameter("maxusers", mMaxUsers);
                    MySqlClient.SetParameter("categoryid", mCategoryId);
                    MySqlClient.SetParameter("allowpets", mAllowPets ? "1" : "0");
                    MySqlClient.SetParameter("allowpeteating", mAllowPetEating ? "1" : "0");
                    MySqlClient.SetParameter("disableblocking", mDisableRoomBlocking ? "1" : "0");
                    MySqlClient.SetParameter("hidewalls", mHideWalls ? "1" : "0");
                    MySqlClient.SetParameter("tags", FormattedTags.ToString());
                    MySqlClient.SetParameter("wthickness", mWallThickness);
                    MySqlClient.SetParameter("fthickness", mFloorThickness);
                    MySqlClient.ExecuteNonQuery("UPDATE rooms SET name = @name, description = @description, tags = @tags, access_type = @accesstype, password = @password, category = @categoryid, max_users = @maxusers, allow_pets = @allowpets, allow_pet_eating = @allowpeteating, disable_blocking = @disableblocking, hide_walls = @hidewalls, thickness_wall = @wthickness, thickness_floor = @fthickness WHERE id = @id LIMIT 1");
                }
            }
        }