aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs363
1 files changed, 281 insertions, 82 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 9c6706f..41515c0 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -40,6 +40,7 @@ using OpenSim.Framework.Monitoring;
40using OpenSim.Framework.Serialization; 40using OpenSim.Framework.Serialization;
41using OpenSim.Framework.Serialization.External; 41using OpenSim.Framework.Serialization.External;
42using OpenSim.Region.CoreModules.World.Terrain; 42using OpenSim.Region.CoreModules.World.Terrain;
43using OpenSim.Region.CoreModules.World.Land;
43using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes; 45using OpenSim.Region.Framework.Scenes;
45using OpenSim.Region.Framework.Scenes.Serialization; 46using OpenSim.Region.Framework.Scenes.Serialization;
@@ -76,14 +77,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver
76 SceneObjects = new List<SceneObjectGroup>(); 77 SceneObjects = new List<SceneObjectGroup>();
77 } 78 }
78 } 79 }
79 80
80 81
81 /// <summary> 82 /// <summary>
82 /// The maximum major version of OAR that we can read. Minor versions shouldn't need a max number since version 83 /// The maximum major version of OAR that we can read. Minor versions shouldn't need a max number since version
83 /// bumps here should be compatible. 84 /// bumps here should be compatible.
84 /// </summary> 85 /// </summary>
85 public static int MAX_MAJOR_VERSION = 1; 86 public static int MAX_MAJOR_VERSION = 1;
86 87
87 /// <summary> 88 /// <summary>
88 /// Has the control file been loaded for this archive? 89 /// Has the control file been loaded for this archive?
89 /// </summary> 90 /// </summary>
@@ -126,12 +127,29 @@ namespace OpenSim.Region.CoreModules.World.Archiver
126 /// </value> 127 /// </value>
127 protected float m_rotation = 0f; 128 protected float m_rotation = 0f;
128 129
130 /// <value>
131 /// original oar region size. not using Constants.RegionSize
132 /// </value>
133 protected Vector3 m_incomingRegionSize = new Vector3(256f, 256f, float.MaxValue);
134
135 /// <value>
136 /// Center around which to apply the rotation relative to the original oar position
137 /// </value>
138 protected Vector3 m_rotationCenter = new Vector3(128f, 128f, 0f);
139
140 /// <value>
141 /// Corner 1 of a bounding cuboid which specifies which objects we load from the oar
142 /// </value>
143 protected Vector3 m_boundingOrigin = Vector3.Zero;
144
129 /// <value> 145 /// <value>
130 /// Center around which to apply the rotation relative to the origional oar position 146 /// Size of a bounding cuboid which specifies which objects we load from the oar
131 /// </value> 147 /// </value>
132 protected Vector3 m_rotationCenter = new Vector3(Constants.RegionSize / 2f, Constants.RegionSize / 2f, 0f); 148 protected Vector3 m_boundingSize = new Vector3(Constants.MaximumRegionSize, Constants.MaximumRegionSize, float.MaxValue);
133 149
134 protected bool m_noObjects = false; 150 protected bool m_noObjects = false;
151 protected bool m_boundingBox = false;
152 protected bool m_debug = false;
135 153
136 /// <summary> 154 /// <summary>
137 /// Used to cache lookups for valid uuids. 155 /// Used to cache lookups for valid uuids.
@@ -160,10 +178,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
160 178
161 private IAssetService m_assetService = null; 179 private IAssetService m_assetService = null;
162 180
163
164 private UUID m_defaultUser; 181 private UUID m_defaultUser;
165 182
166 public ArchiveReadRequest(Scene scene, string loadPath, Guid requestId, Dictionary<string,object>options) 183 public ArchiveReadRequest(Scene scene, string loadPath, Guid requestId, Dictionary<string, object> options)
167 { 184 {
168 m_rootScene = scene; 185 m_rootScene = scene;
169 186
@@ -172,7 +189,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
172 m_defaultUser = (UUID)options["default-user"]; 189 m_defaultUser = (UUID)options["default-user"];
173 m_log.InfoFormat("Using User {0} as default user", m_defaultUser.ToString()); 190 m_log.InfoFormat("Using User {0} as default user", m_defaultUser.ToString());
174 } 191 }
175 else 192 else
176 { 193 {
177 m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner; 194 m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner;
178 } 195 }
@@ -189,8 +206,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
189 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); 206 + "If you've manually installed Mono, have you appropriately updated zlib1g as well?");
190 m_log.Error(e); 207 m_log.Error(e);
191 } 208 }
192 209
193 m_errorMessage = String.Empty; 210 m_errorMessage = String.Empty;
211
194 m_merge = options.ContainsKey("merge"); 212 m_merge = options.ContainsKey("merge");
195 m_forceTerrain = options.ContainsKey("force-terrain"); 213 m_forceTerrain = options.ContainsKey("force-terrain");
196 m_forceParcels = options.ContainsKey("force-parcels"); 214 m_forceParcels = options.ContainsKey("force-parcels");
@@ -199,10 +217,45 @@ namespace OpenSim.Region.CoreModules.World.Archiver
199 m_requestId = requestId; 217 m_requestId = requestId;
200 m_displacement = options.ContainsKey("displacement") ? (Vector3)options["displacement"] : Vector3.Zero; 218 m_displacement = options.ContainsKey("displacement") ? (Vector3)options["displacement"] : Vector3.Zero;
201 m_rotation = options.ContainsKey("rotation") ? (float)options["rotation"] : 0f; 219 m_rotation = options.ContainsKey("rotation") ? (float)options["rotation"] : 0f;
202 m_rotationCenter = options.ContainsKey("rotation-center") ? (Vector3)options["rotation-center"]
203 : new Vector3(scene.RegionInfo.RegionSizeX / 2f, scene.RegionInfo.RegionSizeY / 2f, 0f);
204 220
205 // Zero can never be a valid user or group id 221 m_boundingOrigin = Vector3.Zero;
222 m_boundingSize = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, float.MaxValue);
223
224 if (options.ContainsKey("bounding-origin"))
225 {
226 Vector3 boOption = (Vector3)options["bounding-origin"];
227 if (boOption != m_boundingOrigin)
228 {
229 m_boundingOrigin = boOption;
230 }
231 m_boundingBox = true;
232 }
233
234 if (options.ContainsKey("bounding-size"))
235 {
236 Vector3 bsOption = (Vector3)options["bounding-size"];
237 bool clip = false;
238 if (bsOption.X <= 0 || bsOption.X > m_boundingSize.X)
239 {
240 bsOption.X = m_boundingSize.X;
241 clip = true;
242 }
243 if (bsOption.Y <= 0 || bsOption.Y > m_boundingSize.Y)
244 {
245 bsOption.Y = m_boundingSize.Y;
246 clip = true;
247 }
248 if (bsOption != m_boundingSize)
249 {
250 m_boundingSize = bsOption;
251 m_boundingBox = true;
252 }
253 if (clip) m_log.InfoFormat("[ARCHIVER]: The bounding cube specified is larger than the destination region! Clipping to {0}.", m_boundingSize.ToString());
254 }
255
256 m_debug = options.ContainsKey("debug");
257
258 // Zero can never be a valid user id (or group)
206 m_validUserUuids[UUID.Zero] = false; 259 m_validUserUuids[UUID.Zero] = false;
207 m_validGroupUuids[UUID.Zero] = false; 260 m_validGroupUuids[UUID.Zero] = false;
208 261
@@ -210,7 +263,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
210 m_assetService = m_rootScene.AssetService; 263 m_assetService = m_rootScene.AssetService;
211 } 264 }
212 265
213 public ArchiveReadRequest(Scene scene, Stream loadStream, Guid requestId, Dictionary<string, object>options) 266 public ArchiveReadRequest(Scene scene, Stream loadStream, Guid requestId, Dictionary<string, object> options)
214 { 267 {
215 m_rootScene = scene; 268 m_rootScene = scene;
216 m_loadPath = null; 269 m_loadPath = null;
@@ -220,7 +273,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
220 m_requestId = requestId; 273 m_requestId = requestId;
221 274
222 m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner; 275 m_defaultUser = scene.RegionInfo.EstateSettings.EstateOwner;
223 276
224 // Zero can never be a valid user id 277 // Zero can never be a valid user id
225 m_validUserUuids[UUID.Zero] = false; 278 m_validUserUuids[UUID.Zero] = false;
226 279
@@ -233,6 +286,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
233 /// </summary> 286 /// </summary>
234 public void DearchiveRegion() 287 public void DearchiveRegion()
235 { 288 {
289 DearchiveRegion(true);
290 }
291
292 public void DearchiveRegion(bool shouldStartScripts)
293 {
236 int successfulAssetRestores = 0; 294 int successfulAssetRestores = 0;
237 int failedAssetRestores = 0; 295 int failedAssetRestores = 0;
238 296
@@ -255,7 +313,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
255 { 313 {
256 //m_log.DebugFormat( 314 //m_log.DebugFormat(
257 // "[ARCHIVER]: Successfully read {0} ({1} bytes)", filePath, data.Length); 315 // "[ARCHIVER]: Successfully read {0} ({1} bytes)", filePath, data.Length);
258 316
259 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) 317 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
260 continue; 318 continue;
261 319
@@ -301,11 +359,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
301 else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH)) 359 else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH))
302 { 360 {
303 LoadRegionSettings(scene, filePath, data, dearchivedScenes); 361 LoadRegionSettings(scene, filePath, data, dearchivedScenes);
304 } 362 }
305 else if (filePath.StartsWith(ArchiveConstants.LANDDATA_PATH) && (!m_merge || m_forceParcels)) 363 else if (filePath.StartsWith(ArchiveConstants.LANDDATA_PATH) && (!m_merge || m_forceParcels))
306 { 364 {
307 sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data)); 365 sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data));
308 } 366 }
309 else if (filePath == ArchiveConstants.CONTROL_FILE_PATH) 367 else if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
310 { 368 {
311 // Ignore, because we already read the control file 369 // Ignore, because we already read the control file
@@ -353,7 +411,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
353 { 411 {
354 LoadParcels(sceneContext.Scene, sceneContext.SerialisedParcels); 412 LoadParcels(sceneContext.Scene, sceneContext.SerialisedParcels);
355 LoadObjects(sceneContext.Scene, sceneContext.SerialisedSceneObjects, sceneContext.SceneObjects); 413 LoadObjects(sceneContext.Scene, sceneContext.SerialisedSceneObjects, sceneContext.SceneObjects);
356 414
357 // Inform any interested parties that the region has changed. We waited until now so that all 415 // Inform any interested parties that the region has changed. We waited until now so that all
358 // of the region's objects will be loaded when we send this notification. 416 // of the region's objects will be loaded when we send this notification.
359 IEstateModule estateModule = sceneContext.Scene.RequestModuleInterface<IEstateModule>(); 417 IEstateModule estateModule = sceneContext.Scene.RequestModuleInterface<IEstateModule>();
@@ -372,22 +430,25 @@ namespace OpenSim.Region.CoreModules.World.Archiver
372 // Start the scripts. We delayed this because we want the OAR to finish loading ASAP, so 430 // Start the scripts. We delayed this because we want the OAR to finish loading ASAP, so
373 // that users can enter the scene. If we allow the scripts to start in the loop above 431 // that users can enter the scene. If we allow the scripts to start in the loop above
374 // then they significantly increase the time until the OAR finishes loading. 432 // then they significantly increase the time until the OAR finishes loading.
375 WorkManager.RunInThread(o => 433 if (shouldStartScripts)
376 { 434 {
377 Thread.Sleep(15000); 435 WorkManager.RunInThread(o =>
378 m_log.Info("[ARCHIVER]: Starting scripts in scene objects");
379
380 foreach (DearchiveContext sceneContext in sceneContexts.Values)
381 { 436 {
382 foreach (SceneObjectGroup sceneObject in sceneContext.SceneObjects) 437 Thread.Sleep(15000);
438 m_log.Info("[ARCHIVER]: Starting scripts in scene objects");
439
440 foreach (DearchiveContext sceneContext in sceneContexts.Values)
383 { 441 {
384 sceneObject.CreateScriptInstances(0, false, sceneContext.Scene.DefaultScriptEngine, 0); // StateSource.RegionStart 442 foreach (SceneObjectGroup sceneObject in sceneContext.SceneObjects)
385 sceneObject.ResumeScripts(); 443 {
386 } 444 sceneObject.CreateScriptInstances(0, false, sceneContext.Scene.DefaultScriptEngine, 0); // StateSource.RegionStart
445 sceneObject.ResumeScripts();
446 }
387 447
388 sceneContext.SceneObjects.Clear(); 448 sceneContext.SceneObjects.Clear();
389 } 449 }
390 }, null, string.Format("ReadArchiveStartScripts (request {0})", m_requestId)); 450 }, null, string.Format("ReadArchiveStartScripts (request {0})", m_requestId));
451 }
391 452
392 m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); 453 m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive");
393 454
@@ -418,7 +479,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
418 { 479 {
419 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) 480 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
420 continue; 481 continue;
421 482
422 if (filePath == ArchiveConstants.CONTROL_FILE_PATH) 483 if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
423 { 484 {
424 LoadControlFile(filePath, data, dearchivedScenes); 485 LoadControlFile(filePath, data, dearchivedScenes);
@@ -435,7 +496,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
435 // If the control file wasn't the first file then reset the read pointer 496 // If the control file wasn't the first file then reset the read pointer
436 if (!firstFile) 497 if (!firstFile)
437 { 498 {
438 m_log.Warn("Control file wasn't the first file in the archive"); 499 m_log.Warn("[ARCHIVER]: Control file wasn't the first file in the archive");
439 if (m_loadStream.CanSeek) 500 if (m_loadStream.CanSeek)
440 { 501 {
441 m_loadStream.Seek(0, SeekOrigin.Begin); 502 m_loadStream.Seek(0, SeekOrigin.Begin);
@@ -452,7 +513,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
452 else 513 else
453 { 514 {
454 // There isn't currently a scenario where this happens, but it's best to add a check just in case 515 // There isn't currently a scenario where this happens, but it's best to add a check just in case
455 throw new Exception("Error reading archive: control file wasn't the first file, and the input stream doesn't allow seeking"); 516 throw new Exception("[ARCHIVER]: Error reading archive: control file wasn't the first file, and the input stream doesn't allow seeking");
456 } 517 }
457 } 518 }
458 519
@@ -462,9 +523,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
462 firstFile = false; 523 firstFile = false;
463 } 524 }
464 525
465 throw new Exception("Control file not found"); 526 throw new Exception("[ARCHIVER]: Control file not found");
466 } 527 }
467 528
468 /// <summary> 529 /// <summary>
469 /// Load serialized scene objects. 530 /// Load serialized scene objects.
470 /// </summary> 531 /// </summary>
@@ -473,12 +534,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
473 // Reload serialized prims 534 // Reload serialized prims
474 m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); 535 m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count);
475 536
476 OpenMetaverse.Quaternion rot = OpenMetaverse.Quaternion.CreateFromAxisAngle(0, 0, 1, m_rotation); 537 // Convert rotation to radians
538 double rotation = Math.PI * m_rotation / 180f;
539
540 OpenMetaverse.Quaternion rot = OpenMetaverse.Quaternion.CreateFromAxisAngle(0, 0, 1, (float)rotation);
477 541
478 UUID oldTelehubUUID = scene.RegionInfo.RegionSettings.TelehubObject; 542 UUID oldTelehubUUID = scene.RegionInfo.RegionSettings.TelehubObject;
479 543
480 IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>(); 544 IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>();
481 int sceneObjectsLoadedCount = 0; 545 int sceneObjectsLoadedCount = 0;
546 Vector3 boundingExtent = new Vector3(m_boundingOrigin.X + m_boundingSize.X, m_boundingOrigin.Y + m_boundingSize.Y, m_boundingOrigin.Z + m_boundingSize.Z);
482 547
483 foreach (string serialisedSceneObject in serialisedSceneObjects) 548 foreach (string serialisedSceneObject in serialisedSceneObjects)
484 { 549 {
@@ -488,7 +553,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
488 // Really large xml files (multi megabyte) appear to cause 553 // Really large xml files (multi megabyte) appear to cause
489 // memory problems 554 // memory problems
490 // when loading the xml. But don't enable this check yet 555 // when loading the xml. But don't enable this check yet
491 556
492 if (serialisedSceneObject.Length > 5000000) 557 if (serialisedSceneObject.Length > 5000000)
493 { 558 {
494 m_log.Error("[ARCHIVER]: Ignoring xml since size > 5000000);"); 559 m_log.Error("[ARCHIVER]: Ignoring xml since size > 5000000);");
@@ -498,31 +563,52 @@ namespace OpenSim.Region.CoreModules.World.Archiver
498 563
499 SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject); 564 SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject);
500 565
566 Vector3 pos = sceneObject.AbsolutePosition;
567 if (m_debug)
568 m_log.DebugFormat("[ARCHIVER]: Loading object from OAR with original scene position {0}.", pos.ToString());
569
501 // Happily this does not do much to the object since it hasn't been added to the scene yet 570 // Happily this does not do much to the object since it hasn't been added to the scene yet
502 if (!sceneObject.IsAttachment) 571 if (!sceneObject.IsAttachment)
503 { 572 {
504 if (m_displacement != Vector3.Zero || m_rotation != 0f) 573 if (m_rotation != 0f)
505 { 574 {
506 Vector3 pos = sceneObject.AbsolutePosition; 575 //fix the rotation center to the middle of the incoming region now as it's otherwise hopelessly confusing on varRegions
507 if (m_rotation != 0f) 576 //as it only works with objects and terrain (using old Merge method) and not parcels
508 { 577 m_rotationCenter.X = m_incomingRegionSize.X / 2;
509 // Rotate the object 578 m_rotationCenter.Y = m_incomingRegionSize.Y / 2;
510 sceneObject.RootPart.RotationOffset = rot * sceneObject.GroupRotation; 579
511 // Get object position relative to rotation axis 580 // Rotate the object
512 Vector3 offset = pos - m_rotationCenter; 581 sceneObject.RootPart.RotationOffset = rot * sceneObject.GroupRotation;
513 // Rotate the object position 582 // Get object position relative to rotation axis
514 offset *= rot; 583 Vector3 offset = pos - m_rotationCenter;
515 // Restore the object position back to relative to the region 584 // Rotate the object position
516 pos = m_rotationCenter + offset; 585 offset *= rot;
517 } 586 // Restore the object position back to relative to the region
518 if (m_displacement != Vector3.Zero) 587 pos = m_rotationCenter + offset;
588 if (m_debug) m_log.DebugFormat("[ARCHIVER]: After rotation, object from OAR is at scene position {0}.", pos.ToString());
589 }
590 if (m_boundingBox)
591 {
592 if (pos.X < m_boundingOrigin.X || pos.X >= boundingExtent.X
593 || pos.Y < m_boundingOrigin.Y || pos.Y >= boundingExtent.Y
594 || pos.Z < m_boundingOrigin.Z || pos.Z >= boundingExtent.Z)
519 { 595 {
520 pos += m_displacement; 596 if (m_debug) m_log.DebugFormat("[ARCHIVER]: Skipping object from OAR in scene because it's position {0} is outside of bounding cube.", pos.ToString());
597 continue;
521 } 598 }
522 sceneObject.AbsolutePosition = pos; 599 //adjust object position to be relative to <0,0> so we can apply the displacement
600 pos.X -= m_boundingOrigin.X;
601 pos.Y -= m_boundingOrigin.Y;
602 }
603 if (m_displacement != Vector3.Zero)
604 {
605 pos += m_displacement;
606 if (m_debug) m_log.DebugFormat("[ARCHIVER]: After displacement, object from OAR is at scene position {0}.", pos.ToString());
523 } 607 }
608 sceneObject.AbsolutePosition = pos;
524 } 609 }
525 610 if (m_debug)
611 m_log.DebugFormat("[ARCHIVER]: Placing object from OAR in scene at position {0}. ", pos.ToString());
526 612
527 bool isTelehub = (sceneObject.UUID == oldTelehubUUID) && (oldTelehubUUID != UUID.Zero); 613 bool isTelehub = (sceneObject.UUID == oldTelehubUUID) && (oldTelehubUUID != UUID.Zero);
528 614
@@ -554,11 +640,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
554 int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount; 640 int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount;
555 641
556 if (ignoredObjects > 0) 642 if (ignoredObjects > 0)
557 m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects); 643 m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene or were out of bounds", ignoredObjects);
558 644
559 if (oldTelehubUUID != UUID.Zero) 645 if (oldTelehubUUID != UUID.Zero)
560 { 646 {
561 m_log.WarnFormat("Telehub object not found: {0}", oldTelehubUUID); 647 m_log.WarnFormat("[ARCHIVER]: Telehub object not found: {0}", oldTelehubUUID);
562 scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; 648 scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
563 scene.RegionInfo.RegionSettings.ClearSpawnPoints(); 649 scene.RegionInfo.RegionSettings.ClearSpawnPoints();
564 } 650 }
@@ -600,6 +686,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
600 // being no copy/no mod for everyone 686 // being no copy/no mod for everyone
601 lock (part.TaskInventory) 687 lock (part.TaskInventory)
602 { 688 {
689/* avination code disabled for opensim
690 // And zap any troublesome sit target information
691 part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
692 part.SitTargetPosition = new Vector3(0, 0, 0);
693*/
694 // Fix ownership/creator of inventory items
695 // Not doing so results in inventory items
696 // being no copy/no mod for everyone
697 part.TaskInventory.LockItemsForRead(true);
698
603 TaskInventoryDictionary inv = part.TaskInventory; 699 TaskInventoryDictionary inv = part.TaskInventory;
604 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) 700 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
605 { 701 {
@@ -620,11 +716,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
620 if (!ResolveGroupUuid(kvp.Value.GroupID)) 716 if (!ResolveGroupUuid(kvp.Value.GroupID))
621 kvp.Value.GroupID = UUID.Zero; 717 kvp.Value.GroupID = UUID.Zero;
622 } 718 }
719 part.TaskInventory.LockItemsForRead(false);
720
623 } 721 }
624 } 722 }
625 } 723 }
626 724
627
628 /// <summary> 725 /// <summary>
629 /// Load serialized parcels. 726 /// Load serialized parcels.
630 /// </summary> 727 /// </summary>
@@ -635,17 +732,88 @@ namespace OpenSim.Region.CoreModules.World.Archiver
635 // Reload serialized parcels 732 // Reload serialized parcels
636 m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count); 733 m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count);
637 List<LandData> landData = new List<LandData>(); 734 List<LandData> landData = new List<LandData>();
735 ILandObject landObject = scene.RequestModuleInterface<ILandObject>();
736 List<ILandObject> parcels;
737 Vector3 parcelDisp = new Vector3(m_displacement.X, m_displacement.Y, 0f);
738 Vector2 displacement = new Vector2(m_displacement.X, m_displacement.Y);
739 Vector2 boundingOrigin = new Vector2(m_boundingOrigin.X, m_boundingOrigin.Y);
740 Vector2 boundingSize = new Vector2(m_boundingSize.X, m_boundingSize.Y);
741 Vector2 regionSize = new Vector2(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY);
742
743 // Gather any existing parcels before we add any more. Later as we add parcels we can check if the new parcel
744 // data overlays any of the old data, and we can modify and remove (if empty) the old parcel so that there's no conflict
745 parcels = scene.LandChannel.AllParcels();
746
638 foreach (string serialisedParcel in serialisedParcels) 747 foreach (string serialisedParcel in serialisedParcels)
639 { 748 {
640 LandData parcel = LandDataSerializer.Deserialize(serialisedParcel); 749 LandData parcel = LandDataSerializer.Deserialize(serialisedParcel);
750 bool overrideRegionSize = true; //use the src land parcel data size not the dst region size
751 bool isEmptyNow;
752 Vector3 AABBMin;
753 Vector3 AABBMax;
754
755 // create a new LandObject that we can use to manipulate the incoming source parcel data
756 // this is ok, but just beware that some of the LandObject functions (that we haven't used here) still
757 // assume we're always using the destination region size
758 LandData ld = new LandData();
759 landObject = new LandObject(ld, scene);
760 landObject.LandData = parcel;
761
762 bool[,] srcLandBitmap = landObject.ConvertBytesToLandBitmap(overrideRegionSize);
763 if (landObject.IsLandBitmapEmpty(srcLandBitmap))
764 {
765 m_log.InfoFormat("[ARCHIVER]: Skipping source parcel {0} with GlobalID: {1} LocalID: {2} that has no claimed land.",
766 parcel.Name, parcel.GlobalID, parcel.LocalID);
767 continue;
768 }
769 //m_log.DebugFormat("[ARCHIVER]: Showing claimed land for source parcel: {0} with GlobalID: {1} LocalID: {2}.",
770 // parcel.Name, parcel.GlobalID, parcel.LocalID);
771 //landObject.DebugLandBitmap(srcLandBitmap);
772
773 bool[,] dstLandBitmap = landObject.RemapLandBitmap(srcLandBitmap, displacement, m_rotation, boundingOrigin, boundingSize, regionSize, out isEmptyNow, out AABBMin, out AABBMax);
774 if (isEmptyNow)
775 {
776 m_log.WarnFormat("[ARCHIVER]: Not adding destination parcel {0} with GlobalID: {1} LocalID: {2} because, after applying rotation, bounding and displacement, it has no claimed land.",
777 parcel.Name, parcel.GlobalID, parcel.LocalID);
778 continue;
779 }
780 //m_log.DebugFormat("[ARCHIVER]: Showing claimed land for destination parcel: {0} with GlobalID: {1} LocalID: {2} after applying rotation, bounding and displacement.",
781 // parcel.Name, parcel.GlobalID, parcel.LocalID);
782 //landObject.DebugLandBitmap(dstLandBitmap);
783
784 landObject.LandBitmap = dstLandBitmap;
785 parcel.Bitmap = landObject.ConvertLandBitmapToBytes();
786 parcel.AABBMin = AABBMin;
787 parcel.AABBMax = AABBMax;
641 788
642 if (m_displacement != Vector3.Zero) 789 if (m_merge)
643 { 790 {
644 Vector3 parcelDisp = new Vector3(m_displacement.X, m_displacement.Y, 0f); 791 // give the remapped parcel a new GlobalID, in case we're using the same OAR twice and a bounding cube, displacement and --merge
645 parcel.AABBMin += parcelDisp; 792 parcel.GlobalID = UUID.Random();
646 parcel.AABBMax += parcelDisp; 793
794 //now check if the area of this new incoming parcel overlays an area in any existing parcels
795 //and if so modify or lose the existing parcels
796 for (int i = 0; i < parcels.Count; i++)
797 {
798 if (parcels[i] != null)
799 {
800 bool[,] modLandBitmap = parcels[i].ConvertBytesToLandBitmap(overrideRegionSize);
801 modLandBitmap = parcels[i].RemoveFromLandBitmap(modLandBitmap, dstLandBitmap, out isEmptyNow, out AABBMin, out AABBMax);
802 if (isEmptyNow)
803 {
804 parcels[i] = null;
805 }
806 else
807 {
808 parcels[i].LandBitmap = modLandBitmap;
809 parcels[i].LandData.Bitmap = parcels[i].ConvertLandBitmapToBytes();
810 parcels[i].LandData.AABBMin = AABBMin;
811 parcels[i].LandData.AABBMax = AABBMax;
812 }
813 }
814 }
647 } 815 }
648 816
649 // Validate User and Group UUID's 817 // Validate User and Group UUID's
650 818
651 if (!ResolveGroupUuid(parcel.GroupID)) 819 if (!ResolveGroupUuid(parcel.GroupID))
@@ -679,19 +847,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver
679 } 847 }
680 parcel.ParcelAccessList = accessList; 848 parcel.ParcelAccessList = accessList;
681 849
682// m_log.DebugFormat( 850 if (m_debug) m_log.DebugFormat("[ARCHIVER]: Adding parcel {0}, local id {1}, owner {2}, group {3}, isGroupOwned {4}, area {5}",
683// "[ARCHIVER]: Adding parcel {0}, local id {1}, owner {2}, group {3}, isGroupOwned {4}, area {5}", 851 parcel.Name, parcel.LocalID, parcel.OwnerID, parcel.GroupID, parcel.IsGroupOwned, parcel.Area);
684// parcel.Name, parcel.LocalID, parcel.OwnerID, parcel.GroupID, parcel.IsGroupOwned, parcel.Area); 852
685
686 landData.Add(parcel); 853 landData.Add(parcel);
687 } 854 }
688 855
689 if (!m_merge) 856 if (m_merge)
690 { 857 {
691 bool setupDefaultParcel = (landData.Count == 0); 858 for (int i = 0; i < parcels.Count; i++) //if merging then we need to also add back in any existing parcels
692 scene.LandChannel.Clear(setupDefaultParcel); 859 {
860 if (parcels[i] != null) landData.Add(parcels[i].LandData);
861 }
693 } 862 }
694 863
864 m_log.InfoFormat("[ARCHIVER]: Clearing {0} parcels.", parcels.Count);
865 bool setupDefaultParcel = (landData.Count == 0);
866 scene.LandChannel.Clear(setupDefaultParcel);
695 scene.EventManager.TriggerIncomingLandDataFromStorage(landData); 867 scene.EventManager.TriggerIncomingLandDataFromStorage(landData);
696 m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count); 868 m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count);
697 } 869 }
@@ -772,6 +944,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
772 944
773 if (m_assetService.GetMetadata(uuid) != null) 945 if (m_assetService.GetMetadata(uuid) != null)
774 { 946 {
947 sbyte asype = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
948 if(asype == -2)
949 {
950
951 }
952
775 // m_log.DebugFormat("[ARCHIVER]: found existing asset {0}",uuid); 953 // m_log.DebugFormat("[ARCHIVER]: found existing asset {0}",uuid);
776 return true; 954 return true;
777 } 955 }
@@ -780,6 +958,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
780 { 958 {
781 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; 959 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
782 960
961 if(assetType == -2)
962 {
963
964 }
783 if (assetType == (sbyte)AssetType.Unknown) 965 if (assetType == (sbyte)AssetType.Unknown)
784 { 966 {
785 m_log.WarnFormat("[ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); 967 m_log.WarnFormat("[ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid);
@@ -792,7 +974,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
792 ModifySceneObject(m_rootScene, sog); 974 ModifySceneObject(m_rootScene, sog);
793 return true; 975 return true;
794 }); 976 });
795 977
796 if (data == null) 978 if (data == null)
797 return false; 979 return false;
798 } 980 }
@@ -898,7 +1080,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
898 currentRegionSettings.Save(); 1080 currentRegionSettings.Save();
899 1081
900 scene.TriggerEstateSunUpdate(); 1082 scene.TriggerEstateSunUpdate();
901 1083
902 IEstateModule estateModule = scene.RequestModuleInterface<IEstateModule>(); 1084 IEstateModule estateModule = scene.RequestModuleInterface<IEstateModule>();
903 if (estateModule != null) 1085 if (estateModule != null)
904 estateModule.sendRegionHandshakeToAll(); 1086 estateModule.sendRegionHandshakeToAll();
@@ -918,13 +1100,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
918 private bool LoadTerrain(Scene scene, string terrainPath, byte[] data) 1100 private bool LoadTerrain(Scene scene, string terrainPath, byte[] data)
919 { 1101 {
920 ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); 1102 ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
921
922 using (MemoryStream ms = new MemoryStream(data)) 1103 using (MemoryStream ms = new MemoryStream(data))
923 { 1104 {
924 if (m_displacement != Vector3.Zero || m_rotation != 0f) 1105 if (m_displacement != Vector3.Zero || m_rotation != 0f || m_boundingBox)
925 { 1106 {
926 Vector2 rotationCenter = new Vector2(m_rotationCenter.X, m_rotationCenter.Y); 1107 Vector2 boundingOrigin = new Vector2(m_boundingOrigin.X, m_boundingOrigin.Y);
927 terrainModule.LoadFromStream(terrainPath, m_displacement, m_rotation, rotationCenter, ms); 1108 Vector2 boundingSize = new Vector2(m_boundingSize.X, m_boundingSize.Y);
1109 terrainModule.LoadFromStream(terrainPath, m_displacement, m_rotation, boundingOrigin, boundingSize, ms); ;
928 } 1110 }
929 else 1111 else
930 { 1112 {
@@ -948,6 +1130,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
948 XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); 1130 XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
949 XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); 1131 XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
950 XmlTextReader xtr = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context); 1132 XmlTextReader xtr = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context);
1133 xtr.ProhibitDtd = true;
951 1134
952 // Loaded metadata will be empty if no information exists in the archive 1135 // Loaded metadata will be empty if no information exists in the archive
953 dearchivedScenes.LoadedCreationDateTime = 0; 1136 dearchivedScenes.LoadedCreationDateTime = 0;
@@ -955,16 +1138,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
955 1138
956 bool multiRegion = false; 1139 bool multiRegion = false;
957 1140
958 while (xtr.Read()) 1141 while (xtr.Read())
959 { 1142 {
960 if (xtr.NodeType == XmlNodeType.Element) 1143 if (xtr.NodeType == XmlNodeType.Element)
961 { 1144 {
962 if (xtr.Name.ToString() == "archive") 1145 if (xtr.Name.ToString() == "archive")
963 { 1146 {
964 int majorVersion = int.Parse(xtr["major_version"]); 1147 int majorVersion = int.Parse(xtr["major_version"]);
965 int minorVersion = int.Parse(xtr["minor_version"]); 1148 int minorVersion = int.Parse(xtr["minor_version"]);
966 string version = string.Format("{0}.{1}", majorVersion, minorVersion); 1149 string version = string.Format("{0}.{1}", majorVersion, minorVersion);
967 1150
968 if (majorVersion > MAX_MAJOR_VERSION) 1151 if (majorVersion > MAX_MAJOR_VERSION)
969 { 1152 {
970 throw new Exception( 1153 throw new Exception(
@@ -972,15 +1155,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
972 "The OAR you are trying to load has major version number of {0} but this version of OpenSim can only load OARs with major version number {1} and below", 1155 "The OAR you are trying to load has major version number of {0} but this version of OpenSim can only load OARs with major version number {1} and below",
973 majorVersion, MAX_MAJOR_VERSION)); 1156 majorVersion, MAX_MAJOR_VERSION));
974 } 1157 }
975 1158
976 m_log.InfoFormat("[ARCHIVER]: Loading OAR with version {0}", version); 1159 m_log.InfoFormat("[ARCHIVER]: Loading OAR with version {0}", version);
977 } 1160 }
978 if (xtr.Name.ToString() == "datetime") 1161 else if (xtr.Name.ToString() == "datetime")
979 { 1162 {
980 int value; 1163 int value;
981 if (Int32.TryParse(xtr.ReadElementContentAsString(), out value)) 1164 if (Int32.TryParse(xtr.ReadElementContentAsString(), out value))
982 dearchivedScenes.LoadedCreationDateTime = value; 1165 dearchivedScenes.LoadedCreationDateTime = value;
983 } 1166 }
984 else if (xtr.Name.ToString() == "row") 1167 else if (xtr.Name.ToString() == "row")
985 { 1168 {
986 multiRegion = true; 1169 multiRegion = true;
@@ -994,13 +1177,26 @@ namespace OpenSim.Region.CoreModules.World.Archiver
994 { 1177 {
995 string id = xtr.ReadElementContentAsString(); 1178 string id = xtr.ReadElementContentAsString();
996 dearchivedScenes.DefaultOriginalID = id; 1179 dearchivedScenes.DefaultOriginalID = id;
997 if (multiRegion) 1180 if(multiRegion)
998 dearchivedScenes.SetRegionOriginalID(id); 1181 dearchivedScenes.SetRegionOriginalID(id);
999 } 1182 }
1000 else if (xtr.Name.ToString() == "dir") 1183 else if (xtr.Name.ToString() == "dir")
1001 { 1184 {
1002 dearchivedScenes.SetRegionDirectory(xtr.ReadElementContentAsString()); 1185 dearchivedScenes.SetRegionDirectory(xtr.ReadElementContentAsString());
1003 } 1186 }
1187 else if (xtr.Name.ToString() == "size_in_meters")
1188 {
1189 Vector3 value;
1190 string size = "<" + xtr.ReadElementContentAsString() + ",0>";
1191 if (Vector3.TryParse(size, out value))
1192 {
1193 m_incomingRegionSize = value;
1194 if(multiRegion)
1195 dearchivedScenes.SetRegionSize(m_incomingRegionSize);
1196 m_log.DebugFormat("[ARCHIVER]: Found region_size info {0}",
1197 m_incomingRegionSize.ToString());
1198 }
1199 }
1004 } 1200 }
1005 } 1201 }
1006 1202
@@ -1012,9 +1208,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
1012 dearchivedScenes.StartRegion(); 1208 dearchivedScenes.StartRegion();
1013 dearchivedScenes.SetRegionOriginalID(dearchivedScenes.DefaultOriginalID); 1209 dearchivedScenes.SetRegionOriginalID(dearchivedScenes.DefaultOriginalID);
1014 dearchivedScenes.SetRegionDirectory(""); 1210 dearchivedScenes.SetRegionDirectory("");
1211 dearchivedScenes.SetRegionSize(m_incomingRegionSize);
1015 } 1212 }
1016 1213
1017 ControlFileLoaded = true; 1214 ControlFileLoaded = true;
1215 if(xtr != null)
1216 xtr.Close();
1018 1217
1019 return dearchivedScenes; 1218 return dearchivedScenes;
1020 } 1219 }