本文整理汇总了C#中OpenSim.Framework.Serialization.TarArchiveWriter.WriteDir方法的典型用法代码示例。如果您正苦于以下问题:C# TarArchiveWriter.WriteDir方法的具体用法?C# TarArchiveWriter.WriteDir怎么用?C# TarArchiveWriter.WriteDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSim.Framework.Serialization.TarArchiveWriter
的用法示例。
在下文中一共展示了TarArchiveWriter.WriteDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveModuleToArchive
public void SaveModuleToArchive(TarArchiveWriter writer, IScene scene)
{
writer.WriteDir("windlight");
foreach (RegionLightShareData lsd in m_WindlightSettings.Values)
{
OSDMap map = lsd.ToOSD();
writer.WriteFile("windlight/" + lsd.UUID.ToString(), OSDParser.SerializeLLSDBinary(map));
}
}
示例2: SaveRegionBackup
public void SaveRegionBackup(TarArchiveWriter writer, IScene scene)
{
writer.WriteDir("assets"); //Used by many, create it by default
IAuroraBackupModule[] modules = scene.RequestModuleInterfaces<IAuroraBackupModule>();
foreach (IAuroraBackupModule module in modules)
module.SaveModuleToArchive(writer, scene);
foreach (IAuroraBackupModule module in modules)
{
while (module.IsArchiving) //Wait until all are done
System.Threading.Thread.Sleep(100);
}
writer.Close();
}
示例3: SaveRegionBackup
public void SaveRegionBackup(TarArchiveWriter writer, IScene scene)
{
writer.WriteDir("assets"); //Used by many, create it by default
IAuroraBackupModule[] modules = scene.RequestModuleInterfaces<IAuroraBackupModule>();
foreach (IAuroraBackupModule module in modules)
module.SaveModuleToArchive(writer, scene);
foreach (IAuroraBackupModule module in modules)
{
while (module.IsArchiving) //Wait until all are done
Thread.Sleep(100);
}
writer.Close();
GC.Collect();
MainConsole.Instance.Info("[Archive]: Finished saving of archive.");
}
示例4: SaveModuleToArchive
public void SaveModuleToArchive(TarArchiveWriter writer, IScene scene)
{
m_isArchiving = true;
m_log.Info("[Archive]: Writing parcels to archive");
writer.WriteDir("parcels");
IParcelManagementModule module = scene.RequestModuleInterface<IParcelManagementModule>();
if (module != null)
{
List<ILandObject> landObject = module.AllParcels();
foreach (ILandObject parcel in landObject)
{
OSDMap parcelMap = parcel.LandData.ToOSD();
writer.WriteFile("parcels/" + parcel.LandData.GlobalID.ToString(), OSDParser.SerializeLLSDBinary(parcelMap));
}
}
m_log.Info("[Archive]: Finished writing parcels to archive");
m_log.Info("[Archive]: Writing terrain to archive");
writer.WriteDir("terrain");
ITerrainModule tModule = scene.RequestModuleInterface<ITerrainModule>();
if (tModule != null)
{
MemoryStream s = new MemoryStream();
tModule.SaveToStream(scene.RegionInfo.RegionID.ToString() + ".r32", s);
writer.WriteFile("terrain/" + scene.RegionInfo.RegionID.ToString() + ".r32", s.ToArray());
s.Close();
}
m_log.Info("[Archive]: Finished writing terrain to archive");
m_log.Info("[Archive]: Writing entities to archive");
ISceneEntity[] entities = scene.Entities.GetEntities();
//Get all entities, then start writing them to the database
writer.WriteDir("entities");
IDictionary<UUID, AssetType> assets = new Dictionary<UUID, AssetType>();
UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);
foreach (ISceneEntity entity in entities)
{
//Write all entities
writer.WriteFile("entities/" + entity.UUID.ToString(), ((ISceneObject)entity).ToXml2());
//Get all the assets too
assetGatherer.GatherAssetUuids(entity, assets, scene);
}
m_log.Info("[Archive]: Finished writing entities to archive");
m_log.Info("[Archive]: Writing assets for entities to archive");
bool foundAllAssets = true;
foreach (UUID assetID in new List<UUID>(assets.Keys))
{
AssetBase asset = m_scene.AssetService.GetCached(assetID.ToString());
if (asset != null)
WriteAsset(asset, writer); //Write it syncronously since we havn't
else
{
foundAllAssets = false; //Not all are cached
m_missingAssets.Add(assetID);
m_scene.AssetService.Get(assetID.ToString(), writer, RetrievedAsset);
}
}
if (foundAllAssets)
m_isArchiving = false; //We're done if all the assets were found
m_log.Info("[Archive]: Finished writing assets for entities to archive");
}
示例5: TestLoadOarV0_2
public void TestLoadOarV0_2()
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
// Put in a random blank directory to check that this doesn't upset the load process
tar.WriteDir("ignoreme");
// Also check that direct entries which will also have a file entry containing that directory doesn't
// upset load
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
string part1Name = "object1";
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateCylinder();
Vector3 groupPosition = new Vector3(90, 80, 70);
Quaternion rotationOffset = new Quaternion(60, 70, 80, 90);
Vector3 offsetPosition = new Vector3(20, 25, 30);
SerialiserModule serialiserModule = new SerialiserModule();
ArchiverModule archiverModule = new ArchiverModule();
Scene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
SceneObjectPart part1
= new SceneObjectPart(
UUID.Zero, shape, groupPosition, rotationOffset, offsetPosition);
part1.Name = part1Name;
SceneObjectGroup object1 = new SceneObjectGroup(part1);
scene.AddNewSceneObject(object1, false);
string object1FileName = string.Format(
"{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
part1Name,
Math.Round(groupPosition.X), Math.Round(groupPosition.Y), Math.Round(groupPosition.Z),
part1.UUID);
tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
scene.EventManager.OnOarFileLoaded += LoadCompleted;
archiverModule.DearchiveRegion(archiveReadStream);
}
Assert.That(m_lastErrorMessage, Is.Null);
SceneObjectPart object1PartLoaded = scene.GetSceneObjectPart(part1Name);
Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded");
Assert.That(object1PartLoaded.Name, Is.EqualTo(part1Name), "object1 names not identical");
Assert.That(object1PartLoaded.GroupPosition, Is.EqualTo(groupPosition), "object1 group position not equal");
Assert.That(
object1PartLoaded.RotationOffset, Is.EqualTo(rotationOffset), "object1 rotation offset not equal");
Assert.That(
object1PartLoaded.OffsetPosition, Is.EqualTo(offsetPosition), "object1 offset position not equal");
// Temporary
Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
}
示例6: TestLoadOarRegionSettings
public void TestLoadOarRegionSettings()
{
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(
ArchiveConstants.CONTROL_FILE_PATH,
new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));
RegionSettings rs = new RegionSettings();
rs.AgentLimit = 17;
rs.AllowDamage = true;
rs.AllowLandJoinDivide = true;
rs.AllowLandResell = true;
rs.BlockFly = true;
rs.BlockShowInSearch = true;
rs.BlockTerraform = true;
rs.DisableCollisions = true;
rs.DisablePhysics = true;
rs.DisableScripts = true;
rs.Elevation1NW = 15.9;
rs.Elevation1NE = 45.3;
rs.Elevation1SE = 49;
rs.Elevation1SW = 1.9;
rs.Elevation2NW = 4.5;
rs.Elevation2NE = 19.2;
rs.Elevation2SE = 9.2;
rs.Elevation2SW = 2.1;
rs.FixedSun = true;
rs.SunPosition = 12.0;
rs.ObjectBonus = 1.4;
rs.RestrictPushing = true;
rs.TerrainLowerLimit = 0.4;
rs.TerrainRaiseLimit = 17.9;
rs.TerrainTexture1 = UUID.Parse("00000000-0000-0000-0000-000000000020");
rs.TerrainTexture2 = UUID.Parse("00000000-0000-0000-0000-000000000040");
rs.TerrainTexture3 = UUID.Parse("00000000-0000-0000-0000-000000000060");
rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080");
rs.UseEstateSun = true;
rs.WaterHeight = 23;
rs.TelehubObject = UUID.Parse("00000000-0000-0000-0000-111111111111");
rs.AddSpawnPoint(SpawnPoint.Parse("1,-2,0.33"));
tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_archiverModule.DearchiveRegion(archiveReadStream);
}
Assert.That(m_lastErrorMessage, Is.Null);
RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings;
Assert.That(loadedRs.AgentLimit, Is.EqualTo(17));
Assert.That(loadedRs.AllowDamage, Is.True);
Assert.That(loadedRs.AllowLandJoinDivide, Is.True);
Assert.That(loadedRs.AllowLandResell, Is.True);
Assert.That(loadedRs.BlockFly, Is.True);
Assert.That(loadedRs.BlockShowInSearch, Is.True);
Assert.That(loadedRs.BlockTerraform, Is.True);
Assert.That(loadedRs.DisableCollisions, Is.True);
Assert.That(loadedRs.DisablePhysics, Is.True);
Assert.That(loadedRs.DisableScripts, Is.True);
Assert.That(loadedRs.Elevation1NW, Is.EqualTo(15.9));
Assert.That(loadedRs.Elevation1NE, Is.EqualTo(45.3));
Assert.That(loadedRs.Elevation1SE, Is.EqualTo(49));
Assert.That(loadedRs.Elevation1SW, Is.EqualTo(1.9));
Assert.That(loadedRs.Elevation2NW, Is.EqualTo(4.5));
Assert.That(loadedRs.Elevation2NE, Is.EqualTo(19.2));
Assert.That(loadedRs.Elevation2SE, Is.EqualTo(9.2));
Assert.That(loadedRs.Elevation2SW, Is.EqualTo(2.1));
Assert.That(loadedRs.FixedSun, Is.True);
Assert.AreEqual(12.0, loadedRs.SunPosition);
Assert.That(loadedRs.ObjectBonus, Is.EqualTo(1.4));
Assert.That(loadedRs.RestrictPushing, Is.True);
Assert.That(loadedRs.TerrainLowerLimit, Is.EqualTo(0.4));
Assert.That(loadedRs.TerrainRaiseLimit, Is.EqualTo(17.9));
Assert.That(loadedRs.TerrainTexture1, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000020")));
Assert.That(loadedRs.TerrainTexture2, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000040")));
Assert.That(loadedRs.TerrainTexture3, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000060")));
Assert.That(loadedRs.TerrainTexture4, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000080")));
Assert.That(loadedRs.UseEstateSun, Is.True);
Assert.That(loadedRs.WaterHeight, Is.EqualTo(23));
Assert.AreEqual(UUID.Zero, loadedRs.TelehubObject); // because no object was found with the original UUID
Assert.AreEqual(0, loadedRs.SpawnPoints().Count);
}
示例7: TestLoadOarDeededLand
public void TestLoadOarDeededLand()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID landID = TestHelpers.ParseTail(0x10);
MockGroupsServicesConnector groupsService = new MockGroupsServicesConnector();
IConfigSource configSource = new IniConfigSource();
IConfig config = configSource.AddConfig("Groups");
config.Set("Enabled", true);
config.Set("Module", "GroupsModule");
config.Set("DebugEnabled", true);
SceneHelpers.SetupSceneModules(
m_scene, configSource, new object[] { new GroupsModule(), groupsService, new LandManagementModule() });
// Create group in scene for loading
// FIXME: For now we'll put up with the issue that we'll get a group ID that varies across tests.
UUID groupID
= groupsService.CreateGroup(UUID.Zero, "group1", "", true, UUID.Zero, 3, true, true, true, UUID.Zero);
// Construct OAR
MemoryStream oarStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(oarStream);
tar.WriteDir(ArchiveConstants.LANDDATA_PATH);
tar.WriteFile(
ArchiveConstants.CONTROL_FILE_PATH,
new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));
LandObject lo = new LandObject(groupID, true, m_scene);
lo.SetLandBitmap(lo.BasicFullRegionLandBitmap());
LandData ld = lo.LandData;
ld.GlobalID = landID;
string ldPath = ArchiveConstants.CreateOarLandDataPath(ld);
Dictionary<string, object> options = new Dictionary<string, object>();
tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, options));
tar.Close();
oarStream = new MemoryStream(oarStream.ToArray());
// Load OAR
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_archiverModule.DearchiveRegion(oarStream);
}
ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16);
LandData rLd = rLo.LandData;
Assert.That(rLd.GlobalID, Is.EqualTo(landID));
Assert.That(rLd.OwnerID, Is.EqualTo(groupID));
Assert.That(rLd.GroupID, Is.EqualTo(groupID));
Assert.That(rLd.IsGroupOwned, Is.EqualTo(true));
}
示例8: TestLoadOar
public void TestLoadOar()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
// Put in a random blank directory to check that this doesn't upset the load process
tar.WriteDir("ignoreme");
// Also check that direct entries which will also have a file entry containing that directory doesn't
// upset load
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(
ArchiveConstants.CONTROL_FILE_PATH,
new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));
SceneObjectPart part1 = CreateSceneObjectPart1();
part1.SitTargetOrientation = new Quaternion(0.2f, 0.3f, 0.4f, 0.5f);
part1.SitTargetPosition = new Vector3(1, 2, 3);
SceneObjectGroup object1 = new SceneObjectGroup(part1);
// Let's put some inventory items into our object
string soundItemName = "sound-item1";
UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
Type type = GetType();
Assembly assembly = type.Assembly;
string soundDataResourceName = null;
string[] names = assembly.GetManifestResourceNames();
foreach (string name in names)
{
if (name.EndsWith(".Resources.test-sound.wav"))
soundDataResourceName = name;
}
Assert.That(soundDataResourceName, Is.Not.Null);
byte[] soundData;
UUID soundUuid;
CreateSoundAsset(tar, assembly, soundDataResourceName, out soundData, out soundUuid);
TaskInventoryItem item1
= new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName };
part1.Inventory.AddInventoryItem(item1, true);
m_scene.AddNewSceneObject(object1, false);
string object1FileName = string.Format(
"{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
part1.Name,
Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z),
part1.UUID);
tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_archiverModule.DearchiveRegion(archiveReadStream);
}
Assert.That(m_lastErrorMessage, Is.Null);
TestLoadedRegion(part1, soundItemName, soundData);
}
示例9: TestLoadOarV0_2
public void TestLoadOarV0_2()
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
// Put in a random blank directory to check that this doesn't upset the load process
tar.WriteDir("ignoreme");
// Also check that direct entries which will also have a file entry containing that directory doesn't
// upset load
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
SceneObjectPart part1 = CreateSceneObjectPart1();
SceneObjectGroup object1 = new SceneObjectGroup(part1);
// Let's put some inventory items into our object
string soundItemName = "sound-item1";
UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
Type type = GetType();
Assembly assembly = type.Assembly;
string soundDataResourceName = null;
string[] names = assembly.GetManifestResourceNames();
foreach (string name in names)
{
if (name.EndsWith(".Resources.test-sound.wav"))
soundDataResourceName = name;
}
Assert.That(soundDataResourceName, Is.Not.Null);
byte[] soundData;
Console.WriteLine("Loading " + soundDataResourceName);
using (Stream resource = assembly.GetManifestResourceStream(soundDataResourceName))
{
using (BinaryReader br = new BinaryReader(resource))
{
// FIXME: Use the inspector insteadthere are so many forums and lists already, though admittedly none of them are suitable for cross virtual-enivornemnt discussion
soundData = br.ReadBytes(99999999);
UUID soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001");
string soundAssetFileName
= ArchiveConstants.ASSETS_PATH + soundUuid
+ ArchiveConstants.ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV];
tar.WriteFile(soundAssetFileName, soundData);
/*
AssetBase soundAsset = AssetHelpers.CreateAsset(soundUuid, soundData);
scene.AssetService.Store(soundAsset);
asset1FileName = ArchiveConstants.ASSETS_PATH + soundUuid + ".wav";
*/
TaskInventoryItem item1
= new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName };
part1.Inventory.AddInventoryItem(item1, true);
}
}
m_scene.AddNewSceneObject(object1, false);
string object1FileName = string.Format(
"{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
part1.Name,
Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z),
part1.UUID);
tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_archiverModule.DearchiveRegion(archiveReadStream);
}
Assert.That(m_lastErrorMessage, Is.Null);
SceneObjectPart object1PartLoaded = m_scene.GetSceneObjectPart(part1.Name);
Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded");
Assert.That(object1PartLoaded.Name, Is.EqualTo(part1.Name), "object1 names not identical");
Assert.That(object1PartLoaded.GroupPosition, Is.EqualTo(part1.GroupPosition), "object1 group position not equal");
Assert.That(
object1PartLoaded.RotationOffset, Is.EqualTo(part1.RotationOffset), "object1 rotation offset not equal");
Assert.That(
object1PartLoaded.OffsetPosition, Is.EqualTo(part1.OffsetPosition), "object1 offset position not equal");
TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItems(soundItemName)[0];
Assert.That(loadedSoundItem, Is.Not.Null, "loaded sound item was null");
AssetBase loadedSoundAsset = m_scene.AssetService.Get(loadedSoundItem.AssetID.ToString());
Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null");
Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match");
// Temporary
Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
}
示例10: SaveModuleToArchive
public void SaveModuleToArchive(TarArchiveWriter writer, IScene scene)
{
m_isArchiving = true;
m_log.Info("[Archive]: Writing parcels to archive");
writer.WriteDir("parcels");
IParcelManagementModule module = scene.RequestModuleInterface<IParcelManagementModule>();
if (module != null)
{
List<ILandObject> landObject = module.AllParcels();
foreach (ILandObject parcel in landObject)
{
OSDMap parcelMap = parcel.LandData.ToOSD();
writer.WriteFile("parcels/" + parcel.LandData.GlobalID.ToString(), OSDParser.SerializeLLSDBinary(parcelMap));
parcelMap = null;
}
}
m_log.Info("[Archive]: Finished writing parcels to archive");
m_log.Info ("[Archive]: Writing terrain to archive");
writer.WriteDir ("newstyleterrain");
writer.WriteDir ("newstylerevertterrain");
writer.WriteDir ("newstylewater");
writer.WriteDir ("newstylerevertwater");
ITerrainModule tModule = scene.RequestModuleInterface<ITerrainModule> ();
if (tModule != null)
{
try
{
byte[] sdata = WriteTerrainToStream (tModule.TerrainMap);
writer.WriteFile ("newstyleterrain/" + scene.RegionInfo.RegionID.ToString () + ".terrain", sdata);
sdata = null;
sdata = WriteTerrainToStream (tModule.TerrainRevertMap);
writer.WriteFile ("newstylerevertterrain/" + scene.RegionInfo.RegionID.ToString () + ".terrain", sdata);
sdata = null;
if (tModule.TerrainWaterMap != null)
{
sdata = WriteTerrainToStream (tModule.TerrainWaterMap);
writer.WriteFile ("newstylewater/" + scene.RegionInfo.RegionID.ToString () + ".terrain", sdata);
sdata = null;
sdata = WriteTerrainToStream (tModule.TerrainWaterRevertMap);
writer.WriteFile ("newstylerevertwater/" + scene.RegionInfo.RegionID.ToString () + ".terrain", sdata);
sdata = null;
}
}
catch (Exception ex)
{
m_log.WarnFormat ("[Backup]: Exception caught: {0}", ex.ToString ());
}
}
m_log.Info("[Archive]: Finished writing terrain to archive");
m_log.Info("[Archive]: Writing entities to archive");
ISceneEntity[] entities = scene.Entities.GetEntities();
//Get all entities, then start writing them to the database
writer.WriteDir("entities");
IDictionary<UUID, AssetType> assets = new Dictionary<UUID, AssetType>();
UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);
IAuroraBackupArchiver archiver = m_scene.RequestModuleInterface<IAuroraBackupArchiver> ();
bool saveAssets = false;
if(archiver.AllowPrompting)
saveAssets = MainConsole.Instance.CmdPrompt ("Save assets? (Will not be able to load on other grids)", "false").Equals ("true", StringComparison.CurrentCultureIgnoreCase);
int count = 0;
foreach (ISceneEntity entity in entities)
{
try
{
if (entity.IsAttachment || ((entity.RootChild.Flags & PrimFlags.Temporary) == PrimFlags.Temporary)
|| ((entity.RootChild.Flags & PrimFlags.TemporaryOnRez) == PrimFlags.TemporaryOnRez))
continue;
//Write all entities
byte[] xml = ((ISceneObject)entity).ToBinaryXml2 ();
writer.WriteFile ("entities/" + entity.UUID.ToString (), xml);
xml = null;
count++;
if (count % 5 == 0)
Thread.Sleep (1);
//Get all the assets too
if (saveAssets)
assetGatherer.GatherAssetUuids (entity, assets, scene);
}
catch (Exception ex)
{
m_log.WarnFormat ("[Backup]: Exception caught: {0}", ex.ToString ());
}
}
entities = null;
m_log.Info("[Archive]: Finished writing entities to archive");
m_log.Info("[Archive]: Writing assets for entities to archive");
//.........这里部分代码省略.........
示例11: SaveModuleToArchive
public void SaveModuleToArchive(TarArchiveWriter writer, IScene scene)
{
m_log.Info("[Archive]: Writing estates to archive");
writer.WriteDir("estate");
EstateSettings settings = scene.RegionInfo.EstateSettings;
string xmlData = WebUtils.BuildXmlResponse(settings.ToKeyValuePairs(true));
writer.WriteFile("estate/" + scene.RegionInfo.RegionName, xmlData);
m_log.Info("[Archive]: Finished writing estates to archive");
m_log.Info("[Archive]: Writing region info to archive");
writer.WriteDir("regioninfo");
RegionInfo regionInfo = scene.RegionInfo;
writer.WriteFile("regioninfo/" + scene.RegionInfo.RegionName, OSDParser.SerializeLLSDBinary(regionInfo.PackRegionInfoData(true)));
m_log.Info("[Archive]: Finished writing region info to archive");
}
示例12: WriteInventoryFolderToArchive
private static void WriteInventoryFolderToArchive(
TarArchiveWriter archive, InventoryFolderWithChildren folder, string path)
{
path += string.Format("{0}{1}{2}/", folder.Name, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folder.ID);
archive.WriteDir(path);
foreach (InventoryNodeBase inventoryNode in folder.Children.Values)
{
if (inventoryNode is InventoryFolderWithChildren)
{
WriteInventoryFolderToArchive(archive, (InventoryFolderWithChildren) inventoryNode, path);
}
else if (inventoryNode is InventoryItemBase)
{
WriteInventoryItemToArchive(archive, (InventoryItemBase) inventoryNode, path);
}
}
}
示例13: SaveBackup
/// <summary>
/// Save a backup of the sim
/// </summary>
/// <param name="appendedFilePath">The file path where the backup will be saved</param>
protected virtual void SaveBackup (string appendedFilePath, bool saveAssets)
{
if (appendedFilePath == "/")
appendedFilePath = "";
IBackupModule backupModule = m_scene.RequestModuleInterface<IBackupModule> ();
if (backupModule != null && backupModule.LoadingPrims) //Something is changing lots of prims
{
m_log.Info ("[Backup]: Not saving backup because the backup module is loading prims");
return;
}
//Save any script state saves that might be around
IScriptModule[] engines = m_scene.RequestModuleInterfaces<IScriptModule> ();
try
{
if (engines != null)
{
foreach (IScriptModule engine in engines)
{
if (engine != null)
{
engine.SaveStateSaves ();
}
}
}
}
catch(Exception ex)
{
m_log.WarnFormat ("[Backup]: Exception caught: {0}", ex.ToString());
}
m_log.Info ("[FileBasedSimulationData]: Saving Backup for region " + m_scene.RegionInfo.RegionName);
string fileName = appendedFilePath + m_scene.RegionInfo.RegionName + m_saveAppenedFileName + ".abackup";
if (File.Exists (fileName))
{
//Do new style saving here!
GZipStream m_saveStream = new GZipStream (new FileStream (fileName + ".tmp", FileMode.Create), CompressionMode.Compress);
TarArchiveWriter writer = new TarArchiveWriter (m_saveStream);
GZipStream m_loadStream = new GZipStream (new FileStream (fileName, FileMode.Open), CompressionMode.Decompress);
TarArchiveReader reader = new TarArchiveReader (m_loadStream);
writer.WriteDir ("parcels");
IParcelManagementModule module = m_scene.RequestModuleInterface<IParcelManagementModule> ();
if (module != null)
{
List<ILandObject> landObject = module.AllParcels ();
foreach (ILandObject parcel in landObject)
{
OSDMap parcelMap = parcel.LandData.ToOSD ();
writer.WriteFile ("parcels/" + parcel.LandData.GlobalID.ToString (), OSDParser.SerializeLLSDBinary (parcelMap));
parcelMap = null;
}
}
writer.WriteDir ("newstyleterrain");
writer.WriteDir ("newstylerevertterrain");
writer.WriteDir ("newstylewater");
writer.WriteDir ("newstylerevertwater");
ITerrainModule tModule = m_scene.RequestModuleInterface<ITerrainModule> ();
if (tModule != null)
{
try
{
byte[] sdata = WriteTerrainToStream (tModule.TerrainMap);
writer.WriteFile ("newstyleterrain/" + m_scene.RegionInfo.RegionID.ToString () + ".terrain", sdata);
sdata = null;
sdata = WriteTerrainToStream (tModule.TerrainRevertMap);
writer.WriteFile ("newstylerevertterrain/" + m_scene.RegionInfo.RegionID.ToString () + ".terrain", sdata);
sdata = null;
if (tModule.TerrainWaterMap != null)
{
sdata = WriteTerrainToStream (tModule.TerrainWaterMap);
writer.WriteFile ("newstylewater/" + m_scene.RegionInfo.RegionID.ToString () + ".terrain", sdata);
sdata = null;
sdata = WriteTerrainToStream (tModule.TerrainWaterRevertMap);
writer.WriteFile ("newstylerevertwater/" + m_scene.RegionInfo.RegionID.ToString () + ".terrain", sdata);
sdata = null;
}
}
catch (Exception ex)
{
m_log.WarnFormat ("[Backup]: Exception caught: {0}", ex.ToString ());
}
}
IDictionary<UUID, AssetType> assets = new Dictionary<UUID, AssetType>();
UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);
ISceneEntity[] saveentities = m_scene.Entities.GetEntities();
List<UUID> entitiesToSave = new List<UUID>();
//.........这里部分代码省略.........
示例14: TestLoadOarV0_2RegionSettings
public void TestLoadOarV0_2RegionSettings()
{
TestHelper.InMethod();
//log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile(new Dictionary<string, Object>()));
RegionSettings rs = new RegionSettings();
rs.AgentLimit = 17;
rs.AllowDamage = true;
rs.AllowLandJoinDivide = true;
rs.AllowLandResell = true;
rs.BlockFly = true;
rs.BlockShowInSearch = true;
rs.BlockTerraform = true;
rs.DisableCollisions = true;
rs.DisablePhysics = true;
rs.DisableScripts = true;
rs.Elevation1NW = 15.9;
rs.Elevation1NE = 45.3;
rs.Elevation1SE = 49;
rs.Elevation1SW = 1.9;
rs.Elevation2NW = 4.5;
rs.Elevation2NE = 19.2;
rs.Elevation2SE = 9.2;
rs.Elevation2SW = 2.1;
rs.FixedSun = true;
rs.ObjectBonus = 1.4;
rs.RestrictPushing = true;
rs.TerrainLowerLimit = 0.4;
rs.TerrainRaiseLimit = 17.9;
rs.TerrainTexture1 = UUID.Parse("00000000-0000-0000-0000-000000000020");
rs.TerrainTexture2 = UUID.Parse("00000000-0000-0000-0000-000000000040");
rs.TerrainTexture3 = UUID.Parse("00000000-0000-0000-0000-000000000060");
rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080");
rs.UseEstateSun = true;
rs.WaterHeight = 23;
tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs));
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
lock (this)
{
m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
m_archiverModule.DearchiveRegion(archiveReadStream);
}
Assert.That(m_lastErrorMessage, Is.Null);
RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings;
Assert.That(loadedRs.AgentLimit, Is.EqualTo(17));
Assert.That(loadedRs.AllowDamage, Is.True);
Assert.That(loadedRs.AllowLandJoinDivide, Is.True);
Assert.That(loadedRs.AllowLandResell, Is.True);
Assert.That(loadedRs.BlockFly, Is.True);
Assert.That(loadedRs.BlockShowInSearch, Is.True);
Assert.That(loadedRs.BlockTerraform, Is.True);
Assert.That(loadedRs.DisableCollisions, Is.True);
Assert.That(loadedRs.DisablePhysics, Is.True);
Assert.That(loadedRs.DisableScripts, Is.True);
Assert.That(loadedRs.Elevation1NW, Is.EqualTo(15.9));
Assert.That(loadedRs.Elevation1NE, Is.EqualTo(45.3));
Assert.That(loadedRs.Elevation1SE, Is.EqualTo(49));
Assert.That(loadedRs.Elevation1SW, Is.EqualTo(1.9));
Assert.That(loadedRs.Elevation2NW, Is.EqualTo(4.5));
Assert.That(loadedRs.Elevation2NE, Is.EqualTo(19.2));
Assert.That(loadedRs.Elevation2SE, Is.EqualTo(9.2));
Assert.That(loadedRs.Elevation2SW, Is.EqualTo(2.1));
Assert.That(loadedRs.FixedSun, Is.True);
Assert.That(loadedRs.ObjectBonus, Is.EqualTo(1.4));
Assert.That(loadedRs.RestrictPushing, Is.True);
Assert.That(loadedRs.TerrainLowerLimit, Is.EqualTo(0.4));
Assert.That(loadedRs.TerrainRaiseLimit, Is.EqualTo(17.9));
Assert.That(loadedRs.TerrainTexture1, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000020")));
Assert.That(loadedRs.TerrainTexture2, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000040")));
Assert.That(loadedRs.TerrainTexture3, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000060")));
Assert.That(loadedRs.TerrainTexture4, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000080")));
Assert.That(loadedRs.UseEstateSun, Is.True);
Assert.That(loadedRs.WaterHeight, Is.EqualTo(23));
}
示例15: doExport
/// <summary>
///
/// </summary>
/// <param name="filePath"></param>
/// <param name="GTAIV"></param>
/// <returns></returns>
private bool doExport(string filePath, DataSetType data_type )
{
// Initial stage for the export/import functionality is the ability to export/import
// the data correctly for the current city, uses OSDMap. For now the GTAIV flag is
// ignored, this needs to be changed to allow for internal, GTA and GIS data sets to
// be used for cities.
if (filePath == null || data_type == DataSetType.DATASET_TYPE_NULL)
{
return (false);
}
// Make sure the file is not present on the destination.
// ???
// First stage use a TarArchiveWriter in conjunction with OSDMap to write a file
// containing all the information needed about the city and regions to be able to
// import it in when the server is shutdown and restarted.
System.IO.MemoryStream data = new System.IO.MemoryStream(1024);
TarArchiveWriter tarArchive = null;
// Construct the archive before writing it to the destination.
tarArchive = new TarArchiveWriter(data);
tarArchive.WriteDir("citybuilder/");
tarArchive.WriteFile(filePath, data.GetBuffer());
return (false);
}