Exemplo n.º 1
0
        public static roomModel Parse(DataRow dRow)
        {
            roomModel retModel = new roomModel();
            try
            {
                retModel.typeName = (string)dRow["modeltype"];
                retModel.userType = (roomModelUserType)int.Parse(dRow["usertype"].ToString());
                retModel.doorX = (byte)int.Parse(dRow["door_x"].ToString());
                retModel.doorY = (byte)int.Parse(dRow["door_y"].ToString());
                retModel.doorZ = (float)dRow["door_z"];
                retModel.sHeightmap = dRow["heightmap"].ToString().ToLower();
                retModel.mHeightMapAxes = retModel.sHeightmap.Split('|');
            }
            catch { retModel = null; }

            return retModel;
        }
Exemplo n.º 2
0
        public static roomModel Parse(DataRow dRow)
        {
            roomModel retModel = new roomModel();

            try
            {
                retModel.typeName       = (string)dRow["modeltype"];
                retModel.userType       = (roomModelUserType)int.Parse(dRow["usertype"].ToString());
                retModel.doorX          = (byte)int.Parse(dRow["door_x"].ToString());
                retModel.doorY          = (byte)int.Parse(dRow["door_y"].ToString());
                retModel.doorZ          = (float)dRow["door_z"];
                retModel.sHeightmap     = dRow["heightmap"].ToString().ToLower();
                retModel.mHeightMapAxes = retModel.sHeightmap.Split('|');
            }
            catch { retModel = null; }

            return(retModel);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes the room models and stores them in a persistent collection object for further reference.
        /// </summary>
        public void initRoomModels()
        {
            Logging.Log("Initializing room models...");
            mModels.Clear();

            Database dbClient = new Database(true, true);

            if (dbClient.Ready)
            {
                foreach (DataRow dRow in dbClient.getTable("SELECT * FROM rooms_models").Rows)
                {
                    roomModel pModel = roomModel.Parse(dRow);
                    if (pModel != null)
                    {
                        mModels.Add(pModel.typeName, pModel);
                    }
                }
            }
            Logging.Log("Initialized " + mModels.Count + " room models.");
        }
Exemplo n.º 4
0
        /// <summary>
        /// 29 - "@]"
        /// </summary>
        public void CREATEFLAT()
        {
            if (Engine.Game.Rooms.getUserRoomCount(Session.User.ID) >= Configuration.getNumericConfigurationValue("users.rooms.maxroomsperuser"))
            {
                Session.gameConnection.sendLocalizedError("Error creating a private room");
                return;
            }

            Response.Initialize(59); // "@{"

            string[]        Settings = Request.Content.Split('/');
            roomInformation newRoom  = new roomInformation();

            newRoom.ownerID   = Session.User.ID;
            newRoom.Name      = Settings[2];
            newRoom.modelType = Settings[3];
            stringFunctions.filterVulnerableStuff(ref newRoom.Name, true);

            // Verify room model
            roomModel testModel = Engine.Game.Rooms.getModel(newRoom.modelType);

            if (testModel == null ||
                testModel.userType == roomModelUserType.PublicSpaceModel ||
                testModel.userType == roomModelUserType.UserFlatSpecialModel && !Session.User.hasFuseRight("fuse_use_special_room_layouts"))
            {
                return; // Model does not exist, model is for public spaces only or model requires certain FUSE right and user does not has this fuse right
            }
            newRoom.accessType = (roomAccessType)Enum.Parse(typeof(roomAccessType), Settings[4]);
            newRoom.showOwner  = (Settings[5] == "1");

            int newRoomID = Engine.Game.Rooms.createFlat(newRoom);

            Response.Append(newRoomID);
            Response.appendChar(13);
            Response.Append(newRoom.Name);

            sendResponse();
        }
Exemplo n.º 5
0
        public roomModel getModel(string Type)
        {
            if (!mModels.ContainsKey(Type)) // Not initialized yet
            {
                Database Database = new Database(false, true);
                Database.addParameterWithValue("modeltype", Type);
                Database.Open();

                if (Database.Ready)
                {
                    DataRow dRow = Database.getRow("SELECT * FROM rooms_models WHERE modeltype = @modeltype");
                    if (dRow != null)
                    {
                        roomModel New = roomModel.Parse(dRow);
                        if (New == null || dRow["modeltype"].ToString() != Type) // Not found / invalid case
                        {
                            Logging.Log("Room model '" + Type + "' was found but contained invalid data.", Logging.logType.commonWarning);
                            return(null);
                        }
                        else
                        {
                            mModels.Add(Type, New);
                        }
                    }
                    else
                    {
                        Logging.Log("The requested room model '" + Type + "' was not found in the 'rooms_models' table of the database!", Logging.logType.commonWarning);
                        return(null);
                    }
                }

                Logging.Log("Room model '" + Type + "' is initialized and added to cache.", Logging.logType.roomInstanceEvent);
            }

            return(mModels[Type]);
        }