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


C# RegionInfo.SaveRegionToFile方法代码示例

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


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

示例1: XmlRpcCreateRegionMethod


//.........这里部分代码省略.........
                        catch (Exception)
                        {
                            // No INI setting recorded.
                        }
                        
                        string regionIniPath;
                        
                        if (requestData.Contains("region_file"))
                        {
                            // Make sure that the file to be created is in a subdirectory of the region storage directory.
                            string requestedFilePath = Path.Combine(regionConfigPath, (string) requestData["region_file"]);
                            string requestedDirectory = Path.GetDirectoryName(Path.GetFullPath(requestedFilePath));
                            if (requestedDirectory.StartsWith(Path.GetFullPath(regionConfigPath)))
                                regionIniPath = requestedFilePath;
                            else
                                throw new Exception("Invalid location for region file.");
                        }
                        else
                        {
                            regionIniPath = Path.Combine(regionConfigPath,
                                                            String.Format(
                                                                m_config.GetString("region_file_template",
                                                                                   "{0}x{1}-{2}.ini"),
                                                                region.RegionLocX.ToString(),
                                                                region.RegionLocY.ToString(),
                                                                regionID.ToString(),
                                                                region.InternalEndPoint.Port.ToString(),
                                                                region.RegionName.Replace(" ", "_").Replace(":", "_").
                                                                    Replace("/", "_")));
                        }
                        
                        m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}",
                                          region.RegionID, regionIniPath);
                        region.SaveRegionToFile("dynamic region", regionIniPath);
                    }
                    else
                    {
                        region.Persistent = false;
                    }
                        
                    // Set the estate
                    
                    // Check for an existing estate
                    List<int> estateIDs = m_application.EstateDataService.GetEstates((string) requestData["estate_name"]);
                    if (estateIDs.Count < 1)
                    {
                        UUID userID = UUID.Zero;
                        if (requestData.ContainsKey("estate_owner_uuid"))
                        {
                            // ok, client wants us to use an explicit UUID
                            // regardless of what the avatar name provided
                            userID = new UUID((string) requestData["estate_owner_uuid"]);
                            
                            // Check that the specified user exists
                            Scene currentOrFirst = m_application.SceneManager.CurrentOrFirstScene;
                            IUserAccountService accountService = currentOrFirst.UserAccountService;
                            UserAccount user = accountService.GetUserAccount(currentOrFirst.RegionInfo.ScopeID, userID);
                            
                            if (user == null)
                                throw new Exception("Specified user was not found.");
                        }
                        else if (requestData.ContainsKey("estate_owner_first") & requestData.ContainsKey("estate_owner_last"))
                        {
                            // We need to look up the UUID for the avatar with the provided name.
                            string ownerFirst = (string) requestData["estate_owner_first"];
                            string ownerLast = (string) requestData["estate_owner_last"];
开发者ID:NovaGrid,项目名称:opensim,代码行数:67,代码来源:RemoteAdminPlugin.cs

示例2: XmlRpcCreateRegionMethod


//.........这里部分代码省略.........
                                    masterFirst, masterLast, masterPassword, "", region.RegionLocX, region.RegionLocY);

                                if (userID == UUID.Zero)
                                    throw new Exception(String.Format("failed to create new user {0} {1}",
                                                                      masterFirst, masterLast));
                            }
                            else
                            {
                                userID = userInfo.UserProfile.ID;
                            }
                        }
                    }

                    region.MasterAvatarFirstName = masterFirst;
                    region.MasterAvatarLastName = masterLast;
                    region.MasterAvatarSandboxPassword = masterPassword;
                    region.MasterAvatarAssignedUUID = userID;

                    bool persist = Convert.ToBoolean((string) requestData["persist"]);
                    if (persist)
                    {
                        // default place for region XML files is in the
                        // Regions directory of the config dir (aka /bin)
                        string regionConfigPath = Path.Combine(Util.configDir(), "Regions");
                        try
                        {
                            // OpenSim.ini can specify a different regions dir
                            IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"];
                            regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim();
                        }
                        catch (Exception)
                        {
                            // No INI setting recorded.
                        }
                        string regionXmlPath = Path.Combine(regionConfigPath,
                                                            String.Format(
                                                                m_config.GetString("region_file_template",
                                                                                   "{0}x{1}-{2}.xml"),
                                                                region.RegionLocX.ToString(),
                                                                region.RegionLocY.ToString(),
                                                                regionID.ToString(),
                                                                region.InternalEndPoint.Port.ToString(),
                                                                region.RegionName.Replace(" ", "_").Replace(":", "_").
                                                                    Replace("/", "_")));
                        m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}",
                                          region.RegionID, regionXmlPath);
                        region.SaveRegionToFile("dynamic region", regionXmlPath);
                    }
                    else
                    {
                        region.Persistent = false;
                    }

                    // Create the region and perform any initial initialization

                    IScene newscene;
                    m_app.CreateRegion(region, out newscene);

                    // If an access specification was provided, use it.
                    // Otherwise accept the default.
                    newscene.RegionInfo.EstateSettings.PublicAccess = getBoolean(requestData, "public", m_publicAccess);
                    if (persist)
                        newscene.RegionInfo.EstateSettings.Save();

                    // enable voice on newly created region if
                    // requested by either the XmlRpc request or the
                    // configuration
                    if (getBoolean(requestData, "enable_voice", m_enableVoiceForNewRegions))
                    {
                        List<ILandObject> parcels = ((Scene)newscene).LandChannel.AllParcels();

                        foreach (ILandObject parcel in parcels)
                        {
                            parcel.LandData.Flags |= (uint) ParcelFlags.AllowVoiceChat;
                            parcel.LandData.Flags |= (uint) ParcelFlags.UseEstateVoiceChan;
                            ((Scene)newscene).LandChannel.UpdateLandObject(parcel.LandData.LocalID, parcel.LandData);
                        }
                    }

                    responseData["success"] = true;
                    responseData["region_name"] = region.RegionName;
                    responseData["region_uuid"] = region.RegionID.ToString();

                    response.Value = responseData;
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[RADMIN] CreateRegion: failed {0}", e.Message);
                    m_log.DebugFormat("[RADMIN] CreateRegion: failed {0}", e.ToString());

                    responseData["success"] = false;
                    responseData["error"] = e.Message;

                    response.Value = responseData;
                }

                m_log.Info("[RADMIN]: CreateRegion: request complete");
                return response;
            }
        }
开发者ID:intari,项目名称:OpenSimMirror,代码行数:101,代码来源:RemoteAdminPlugin.cs


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