diff options
Diffstat (limited to 'OpenSim/Region')
6 files changed, 278 insertions, 215 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 0c4069f..619550c 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -41,6 +41,7 @@ using OpenSim.Framework.Serialization.External; | |||
41 | using OpenSim.Region.CoreModules.World.Terrain; | 41 | using OpenSim.Region.CoreModules.World.Terrain; |
42 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
44 | using OpenSim.Services.Interfaces; | 45 | using OpenSim.Services.Interfaces; |
45 | 46 | ||
46 | namespace OpenSim.Region.CoreModules.World.Archiver | 47 | namespace OpenSim.Region.CoreModules.World.Archiver |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 394ca27..5deaf52 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -292,6 +292,59 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
292 | } | 292 | } |
293 | 293 | ||
294 | /// <summary> | 294 | /// <summary> |
295 | /// Test loading an OpenSim Region Archive where the scene object parts are not ordered by link number (e.g. | ||
296 | /// 2 can come after 3). | ||
297 | /// </summary> | ||
298 | [Test] | ||
299 | public void TestLoadOarUnorderedParts() | ||
300 | { | ||
301 | TestHelpers.InMethod(); | ||
302 | |||
303 | UUID ownerId = TestHelpers.ParseTail(0xaaaa); | ||
304 | |||
305 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
306 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | ||
307 | |||
308 | tar.WriteFile( | ||
309 | ArchiveConstants.CONTROL_FILE_PATH, | ||
310 | new ArchiveWriteRequestPreparation(null, (Stream)null, Guid.Empty).CreateControlFile(new Dictionary<string, Object>())); | ||
311 | |||
312 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ownerId, "obj1-", 0x11); | ||
313 | SceneObjectPart sop2 | ||
314 | = SceneHelpers.CreateSceneObjectPart("obj1-Part2", TestHelpers.ParseTail(0x12), ownerId); | ||
315 | SceneObjectPart sop3 | ||
316 | = SceneHelpers.CreateSceneObjectPart("obj1-Part3", TestHelpers.ParseTail(0x13), ownerId); | ||
317 | |||
318 | // Add the parts so they will be written out in reverse order to the oar | ||
319 | sog1.AddPart(sop3); | ||
320 | sop3.LinkNum = 3; | ||
321 | sog1.AddPart(sop2); | ||
322 | sop2.LinkNum = 2; | ||
323 | |||
324 | tar.WriteFile( | ||
325 | ArchiveConstants.CreateOarObjectPath(sog1.Name, sog1.UUID, sog1.AbsolutePosition), | ||
326 | SceneObjectSerializer.ToXml2Format(sog1)); | ||
327 | |||
328 | tar.Close(); | ||
329 | |||
330 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
331 | |||
332 | lock (this) | ||
333 | { | ||
334 | m_scene.EventManager.OnOarFileLoaded += LoadCompleted; | ||
335 | m_archiverModule.DearchiveRegion(archiveReadStream); | ||
336 | } | ||
337 | |||
338 | Assert.That(m_lastErrorMessage, Is.Null); | ||
339 | |||
340 | SceneObjectPart part2 = m_scene.GetSceneObjectPart("obj1-Part2"); | ||
341 | Assert.That(part2.LinkNum, Is.EqualTo(2)); | ||
342 | |||
343 | SceneObjectPart part3 = m_scene.GetSceneObjectPart("obj1-Part3"); | ||
344 | Assert.That(part3.LinkNum, Is.EqualTo(3)); | ||
345 | } | ||
346 | |||
347 | /// <summary> | ||
295 | /// Test loading an OpenSim Region Archive. | 348 | /// Test loading an OpenSim Region Archive. |
296 | /// </summary> | 349 | /// </summary> |
297 | [Test] | 350 | [Test] |
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 5e928f3..830d9cb 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | |||
@@ -29,8 +29,10 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Text.RegularExpressions; | ||
32 | using log4net; | 33 | using log4net; |
33 | using Mono.Addins; | 34 | using Mono.Addins; |
35 | using NDesk.Options; | ||
34 | using Nini.Config; | 36 | using Nini.Config; |
35 | using OpenMetaverse; | 37 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
@@ -78,25 +80,31 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
78 | m_scene = scene; | 80 | m_scene = scene; |
79 | m_console = MainConsole.Instance; | 81 | m_console = MainConsole.Instance; |
80 | 82 | ||
81 | m_console.Commands.AddCommand("Objects", false, "delete object owner", | 83 | m_console.Commands.AddCommand( |
82 | "delete object owner <UUID>", | 84 | "Objects", false, "delete object owner", |
83 | "Delete a scene object by owner", HandleDeleteObject); | 85 | "delete object owner <UUID>", |
86 | "Delete a scene object by owner", HandleDeleteObject); | ||
84 | 87 | ||
85 | m_console.Commands.AddCommand("Objects", false, "delete object creator", | 88 | m_console.Commands.AddCommand( |
86 | "delete object creator <UUID>", | 89 | "Objects", false, "delete object creator", |
87 | "Delete a scene object by creator", HandleDeleteObject); | 90 | "delete object creator <UUID>", |
91 | "Delete a scene object by creator", HandleDeleteObject); | ||
88 | 92 | ||
89 | m_console.Commands.AddCommand("Objects", false, "delete object uuid", | 93 | m_console.Commands.AddCommand( |
90 | "delete object uuid <UUID>", | 94 | "Objects", false, "delete object uuid", |
91 | "Delete a scene object by uuid", HandleDeleteObject); | 95 | "delete object uuid <UUID>", |
96 | "Delete a scene object by uuid", HandleDeleteObject); | ||
92 | 97 | ||
93 | m_console.Commands.AddCommand("Objects", false, "delete object name", | 98 | m_console.Commands.AddCommand( |
94 | "delete object name <name>", | 99 | "Objects", false, "delete object name", |
95 | "Delete a scene object by name", HandleDeleteObject); | 100 | "delete object name [--regex] <name>", |
101 | "Delete a scene object by name.\nIf --regex is specified then the name is treatead as a regular expression", | ||
102 | HandleDeleteObject); | ||
96 | 103 | ||
97 | m_console.Commands.AddCommand("Objects", false, "delete object outside", | 104 | m_console.Commands.AddCommand( |
98 | "delete object outside", | 105 | "Objects", false, "delete object outside", |
99 | "Delete all scene objects outside region boundaries", HandleDeleteObject); | 106 | "delete object outside", |
107 | "Delete all scene objects outside region boundaries", HandleDeleteObject); | ||
100 | 108 | ||
101 | m_console.Commands.AddCommand( | 109 | m_console.Commands.AddCommand( |
102 | "Objects", | 110 | "Objects", |
@@ -109,8 +117,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
109 | "Objects", | 117 | "Objects", |
110 | false, | 118 | false, |
111 | "show object name", | 119 | "show object name", |
112 | "show object name <name>", | 120 | "show object name [--regex] <name>", |
113 | "Show details of scene objects with the given name", HandleShowObjectByName); | 121 | "Show details of scene objects with the given name.\nIf --regex is specified then the name is treatead as a regular expression", |
122 | HandleShowObjectByName); | ||
114 | 123 | ||
115 | m_console.Commands.AddCommand( | 124 | m_console.Commands.AddCommand( |
116 | "Objects", | 125 | "Objects", |
@@ -123,8 +132,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
123 | "Objects", | 132 | "Objects", |
124 | false, | 133 | false, |
125 | "show part name", | 134 | "show part name", |
126 | "show part name <name>", | 135 | "show part name [--regex] <name>", |
127 | "Show details of scene object parts with the given name", HandleShowPartByName); | 136 | "Show details of scene object parts with the given name.\nIf --regex is specified then the name is treatead as a regular expression", |
137 | HandleShowPartByName); | ||
128 | } | 138 | } |
129 | 139 | ||
130 | public void RemoveRegion(Scene scene) | 140 | public void RemoveRegion(Scene scene) |
@@ -169,22 +179,38 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
169 | m_console.OutputFormat(sb.ToString()); | 179 | m_console.OutputFormat(sb.ToString()); |
170 | } | 180 | } |
171 | 181 | ||
172 | private void HandleShowObjectByName(string module, string[] cmd) | 182 | private void HandleShowObjectByName(string module, string[] cmdparams) |
173 | { | 183 | { |
174 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) | 184 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) |
175 | return; | 185 | return; |
176 | 186 | ||
177 | if (cmd.Length < 4) | 187 | bool useRegex = false; |
188 | OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null ); | ||
189 | |||
190 | List<string> mainParams = options.Parse(cmdparams); | ||
191 | |||
192 | if (mainParams.Count < 4) | ||
178 | { | 193 | { |
179 | m_console.OutputFormat("Usage: show object name <name>"); | 194 | m_console.OutputFormat("Usage: show object name [--regex] <name>"); |
180 | return; | 195 | return; |
181 | } | 196 | } |
182 | 197 | ||
183 | string name = cmd[3]; | 198 | string name = mainParams[3]; |
184 | 199 | ||
185 | List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); | 200 | List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); |
201 | Action<SceneObjectGroup> searchAction; | ||
202 | |||
203 | if (useRegex) | ||
204 | { | ||
205 | Regex nameRegex = new Regex(name); | ||
206 | searchAction = so => { if (nameRegex.IsMatch(so.Name)) { sceneObjects.Add(so); }}; | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | searchAction = so => { if (so.Name == name) { sceneObjects.Add(so); }}; | ||
211 | } | ||
186 | 212 | ||
187 | m_scene.ForEachSOG(so => { if (so.Name == name) { sceneObjects.Add(so); }}); | 213 | m_scene.ForEachSOG(searchAction); |
188 | 214 | ||
189 | if (sceneObjects.Count == 0) | 215 | if (sceneObjects.Count == 0) |
190 | { | 216 | { |
@@ -235,22 +261,39 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
235 | m_console.OutputFormat(sb.ToString()); | 261 | m_console.OutputFormat(sb.ToString()); |
236 | } | 262 | } |
237 | 263 | ||
238 | private void HandleShowPartByName(string module, string[] cmd) | 264 | private void HandleShowPartByName(string module, string[] cmdparams) |
239 | { | 265 | { |
240 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) | 266 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) |
241 | return; | 267 | return; |
242 | 268 | ||
243 | if (cmd.Length < 4) | 269 | bool useRegex = false; |
270 | OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null ); | ||
271 | |||
272 | List<string> mainParams = options.Parse(cmdparams); | ||
273 | |||
274 | if (mainParams.Count < 4) | ||
244 | { | 275 | { |
245 | m_console.OutputFormat("Usage: show part name <name>"); | 276 | m_console.OutputFormat("Usage: show part name [--regex] <name>"); |
246 | return; | 277 | return; |
247 | } | 278 | } |
248 | 279 | ||
249 | string name = cmd[3]; | 280 | string name = mainParams[3]; |
250 | 281 | ||
251 | List<SceneObjectPart> parts = new List<SceneObjectPart>(); | 282 | List<SceneObjectPart> parts = new List<SceneObjectPart>(); |
252 | 283 | ||
253 | m_scene.ForEachSOG(so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } })); | 284 | Action<SceneObjectGroup> searchAction; |
285 | |||
286 | if (useRegex) | ||
287 | { | ||
288 | Regex nameRegex = new Regex(name); | ||
289 | searchAction = so => so.ForEachPart(sop => { if (nameRegex.IsMatch(sop.Name)) { parts.Add(sop); } }); | ||
290 | } | ||
291 | else | ||
292 | { | ||
293 | searchAction = so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } }); | ||
294 | } | ||
295 | |||
296 | m_scene.ForEachSOG(searchAction); | ||
254 | 297 | ||
255 | if (parts.Count == 0) | 298 | if (parts.Count == 0) |
256 | { | 299 | { |
@@ -312,105 +355,169 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
312 | o = cmd[3]; | 355 | o = cmd[3]; |
313 | } | 356 | } |
314 | 357 | ||
315 | List<SceneObjectGroup> deletes = new List<SceneObjectGroup>(); | 358 | List<SceneObjectGroup> deletes = null; |
316 | |||
317 | UUID match; | 359 | UUID match; |
360 | bool requireConfirmation = true; | ||
318 | 361 | ||
319 | switch (mode) | 362 | switch (mode) |
320 | { | 363 | { |
321 | case "owner": | 364 | case "owner": |
322 | if (!UUID.TryParse(o, out match)) | 365 | if (!UUID.TryParse(o, out match)) |
323 | return; | 366 | return; |
324 | |||
325 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | ||
326 | { | ||
327 | if (g.OwnerID == match && !g.IsAttachment) | ||
328 | deletes.Add(g); | ||
329 | }); | ||
330 | 367 | ||
331 | // if (deletes.Count == 0) | 368 | deletes = new List<SceneObjectGroup>(); |
332 | // m_console.OutputFormat("No objects were found with owner {0}", match); | ||
333 | 369 | ||
334 | break; | 370 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) |
371 | { | ||
372 | if (g.OwnerID == match && !g.IsAttachment) | ||
373 | deletes.Add(g); | ||
374 | }); | ||
375 | |||
376 | // if (deletes.Count == 0) | ||
377 | // m_console.OutputFormat("No objects were found with owner {0}", match); | ||
378 | |||
379 | break; | ||
380 | |||
381 | case "creator": | ||
382 | if (!UUID.TryParse(o, out match)) | ||
383 | return; | ||
335 | 384 | ||
336 | case "creator": | 385 | deletes = new List<SceneObjectGroup>(); |
337 | if (!UUID.TryParse(o, out match)) | ||
338 | return; | ||
339 | 386 | ||
340 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | 387 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) |
341 | { | 388 | { |
342 | if (g.RootPart.CreatorID == match && !g.IsAttachment) | 389 | if (g.RootPart.CreatorID == match && !g.IsAttachment) |
343 | deletes.Add(g); | 390 | deletes.Add(g); |
344 | }); | 391 | }); |
392 | |||
393 | // if (deletes.Count == 0) | ||
394 | // m_console.OutputFormat("No objects were found with creator {0}", match); | ||
395 | |||
396 | break; | ||
397 | |||
398 | case "uuid": | ||
399 | if (!UUID.TryParse(o, out match)) | ||
400 | return; | ||
345 | 401 | ||
346 | // if (deletes.Count == 0) | 402 | requireConfirmation = false; |
347 | // m_console.OutputFormat("No objects were found with creator {0}", match); | 403 | deletes = new List<SceneObjectGroup>(); |
404 | |||
405 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | ||
406 | { | ||
407 | if (g.UUID == match && !g.IsAttachment) | ||
408 | deletes.Add(g); | ||
409 | }); | ||
410 | |||
411 | // if (deletes.Count == 0) | ||
412 | // m_console.OutputFormat("No objects were found with uuid {0}", match); | ||
413 | |||
414 | break; | ||
415 | |||
416 | case "name": | ||
417 | deletes = GetDeleteCandidatesByName(module, cmd); | ||
418 | break; | ||
419 | |||
420 | case "outside": | ||
421 | deletes = new List<SceneObjectGroup>(); | ||
348 | 422 | ||
349 | break; | 423 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) |
424 | { | ||
425 | SceneObjectPart rootPart = g.RootPart; | ||
426 | bool delete = false; | ||
427 | |||
428 | if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0) | ||
429 | { | ||
430 | delete = true; | ||
431 | } | ||
432 | else | ||
433 | { | ||
434 | ILandObject parcel | ||
435 | = m_scene.LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y); | ||
436 | |||
437 | if (parcel == null || parcel.LandData.Name == "NO LAND") | ||
438 | delete = true; | ||
439 | } | ||
440 | |||
441 | if (delete && !g.IsAttachment && !deletes.Contains(g)) | ||
442 | deletes.Add(g); | ||
443 | }); | ||
444 | |||
445 | if (deletes.Count == 0) | ||
446 | m_console.OutputFormat("No objects were found outside region bounds"); | ||
447 | |||
448 | break; | ||
350 | 449 | ||
351 | case "uuid": | 450 | default: |
352 | if (!UUID.TryParse(o, out match)) | 451 | m_console.OutputFormat("Unrecognized mode {0}", mode); |
353 | return; | 452 | return; |
453 | } | ||
354 | 454 | ||
355 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | 455 | if (deletes == null || deletes.Count <= 0) |
356 | { | 456 | return; |
357 | if (g.UUID == match && !g.IsAttachment) | ||
358 | deletes.Add(g); | ||
359 | }); | ||
360 | |||
361 | // if (deletes.Count == 0) | ||
362 | // m_console.OutputFormat("No objects were found with uuid {0}", match); | ||
363 | |||
364 | break; | ||
365 | 457 | ||
366 | case "name": | 458 | if (requireConfirmation) |
367 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | 459 | { |
460 | string response = MainConsole.Instance.CmdPrompt( | ||
461 | string.Format( | ||
462 | "Are you sure that you want to delete {0} objects from {1}", | ||
463 | deletes.Count, m_scene.RegionInfo.RegionName), | ||
464 | "n"); | ||
465 | |||
466 | if (response.ToLower() != "y") | ||
368 | { | 467 | { |
369 | if (g.RootPart.Name == o && !g.IsAttachment) | 468 | MainConsole.Instance.OutputFormat( |
370 | deletes.Add(g); | 469 | "Aborting delete of {0} objects from {1}", deletes.Count, m_scene.RegionInfo.RegionName); |
371 | }); | ||
372 | |||
373 | // if (deletes.Count == 0) | ||
374 | // m_console.OutputFormat("No objects were found with name {0}", o); | ||
375 | 470 | ||
376 | break; | 471 | return; |
472 | } | ||
473 | } | ||
377 | 474 | ||
378 | case "outside": | 475 | m_console.OutputFormat("Deleting {0} objects in {1}", deletes.Count, m_scene.RegionInfo.RegionName); |
379 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | ||
380 | { | ||
381 | SceneObjectPart rootPart = g.RootPart; | ||
382 | bool delete = false; | ||
383 | 476 | ||
384 | if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0) | 477 | foreach (SceneObjectGroup g in deletes) |
385 | { | 478 | { |
386 | delete = true; | 479 | m_console.OutputFormat("Deleting object {0} {1}", g.UUID, g.Name); |
387 | } | 480 | m_scene.DeleteSceneObject(g, false); |
388 | else | 481 | } |
389 | { | 482 | } |
390 | ILandObject parcel | ||
391 | = m_scene.LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y); | ||
392 | 483 | ||
393 | if (parcel == null || parcel.LandData.Name == "NO LAND") | 484 | private List<SceneObjectGroup> GetDeleteCandidatesByName(string module, string[] cmdparams) |
394 | delete = true; | 485 | { |
395 | } | 486 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) |
487 | return null; | ||
396 | 488 | ||
397 | if (delete && !g.IsAttachment && !deletes.Contains(g)) | 489 | bool useRegex = false; |
398 | deletes.Add(g); | 490 | OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null ); |
399 | }); | ||
400 | 491 | ||
401 | // if (deletes.Count == 0) | 492 | List<string> mainParams = options.Parse(cmdparams); |
402 | // m_console.OutputFormat("No objects were found outside region bounds"); | ||
403 | 493 | ||
404 | break; | 494 | if (mainParams.Count < 4) |
495 | { | ||
496 | m_console.OutputFormat("Usage: delete object name [--regex] <name>"); | ||
497 | return null; | ||
405 | } | 498 | } |
406 | 499 | ||
407 | m_console.OutputFormat("Deleting {0} objects in {1}", deletes.Count, m_scene.RegionInfo.RegionName); | 500 | string name = mainParams[3]; |
408 | 501 | ||
409 | foreach (SceneObjectGroup g in deletes) | 502 | List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); |
503 | Action<SceneObjectGroup> searchAction; | ||
504 | |||
505 | if (useRegex) | ||
410 | { | 506 | { |
411 | m_console.OutputFormat("Deleting object {0} {1}", g.UUID, g.Name); | 507 | Regex nameRegex = new Regex(name); |
412 | m_scene.DeleteSceneObject(g, false); | 508 | searchAction = so => { if (nameRegex.IsMatch(so.Name)) { sceneObjects.Add(so); }}; |
509 | } | ||
510 | else | ||
511 | { | ||
512 | searchAction = so => { if (so.Name == name) { sceneObjects.Add(so); }}; | ||
413 | } | 513 | } |
514 | |||
515 | m_scene.ForEachSOG(searchAction); | ||
516 | |||
517 | if (sceneObjects.Count == 0) | ||
518 | m_console.OutputFormat("No objects with name {0} found in {1}", name, m_scene.RegionInfo.RegionName); | ||
519 | |||
520 | return sceneObjects; | ||
414 | } | 521 | } |
415 | } | 522 | } |
416 | } \ No newline at end of file | 523 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f62eef3..a1f434e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -1010,7 +1010,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1010 | public int LinkNum | 1010 | public int LinkNum |
1011 | { | 1011 | { |
1012 | get { return m_linkNum; } | 1012 | get { return m_linkNum; } |
1013 | set { m_linkNum = value; } | 1013 | set |
1014 | { | ||
1015 | // if (ParentGroup != null) | ||
1016 | // { | ||
1017 | // m_log.DebugFormat( | ||
1018 | // "[SCENE OBJECT PART]: Setting linknum of {0}@{1} to {2} from {3}", | ||
1019 | // Name, AbsolutePosition, value, m_linkNum); | ||
1020 | // Util.PrintCallStack(); | ||
1021 | // } | ||
1022 | |||
1023 | m_linkNum = value; | ||
1024 | } | ||
1014 | } | 1025 | } |
1015 | 1026 | ||
1016 | public byte ClickAction | 1027 | public byte ClickAction |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 151eba2..e223f47 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -1538,51 +1538,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1538 | } | 1538 | } |
1539 | } | 1539 | } |
1540 | 1540 | ||
1541 | //////// Read ///////// | ||
1542 | public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog) | ||
1543 | { | ||
1544 | reader.Read(); | ||
1545 | reader.ReadStartElement("SceneObjectGroup"); | ||
1546 | SceneObjectPart root = Xml2ToSOP(reader); | ||
1547 | if (root != null) | ||
1548 | sog.SetRootPart(root); | ||
1549 | else | ||
1550 | { | ||
1551 | return false; | ||
1552 | } | ||
1553 | |||
1554 | if (sog.UUID == UUID.Zero) | ||
1555 | sog.UUID = sog.RootPart.UUID; | ||
1556 | |||
1557 | reader.Read(); // OtherParts | ||
1558 | |||
1559 | while (!reader.EOF) | ||
1560 | { | ||
1561 | switch (reader.NodeType) | ||
1562 | { | ||
1563 | case XmlNodeType.Element: | ||
1564 | if (reader.Name == "SceneObjectPart") | ||
1565 | { | ||
1566 | SceneObjectPart child = Xml2ToSOP(reader); | ||
1567 | if (child != null) | ||
1568 | sog.AddPart(child); | ||
1569 | } | ||
1570 | else | ||
1571 | { | ||
1572 | //Logger.Log("Found unexpected prim XML element " + reader.Name, Helpers.LogLevel.Debug); | ||
1573 | reader.Read(); | ||
1574 | } | ||
1575 | break; | ||
1576 | case XmlNodeType.EndElement: | ||
1577 | default: | ||
1578 | reader.Read(); | ||
1579 | break; | ||
1580 | } | ||
1581 | |||
1582 | } | ||
1583 | return true; | ||
1584 | } | ||
1585 | |||
1586 | public static SceneObjectPart Xml2ToSOP(XmlTextReader reader) | 1541 | public static SceneObjectPart Xml2ToSOP(XmlTextReader reader) |
1587 | { | 1542 | { |
1588 | SceneObjectPart obj = new SceneObjectPart(); | 1543 | SceneObjectPart obj = new SceneObjectPart(); |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs index d214eba..a3485d2 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs | |||
@@ -223,50 +223,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
223 | 223 | ||
224 | public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString) | 224 | public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString) |
225 | { | 225 | { |
226 | XmlDocument doc = new XmlDocument(); | 226 | return SceneObjectSerializer.FromXml2Format(xmlString); |
227 | XmlNode rootNode; | ||
228 | |||
229 | XmlTextReader reader = new XmlTextReader(new StringReader(xmlString)); | ||
230 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
231 | doc.Load(reader); | ||
232 | reader.Close(); | ||
233 | rootNode = doc.FirstChild; | ||
234 | |||
235 | // This is to deal with neighbouring regions that are still surrounding the group xml with the <scene> | ||
236 | // tag. It should be possible to remove the first part of this if statement once we go past 0.5.9 (or | ||
237 | // when some other changes forces all regions to upgrade). | ||
238 | // This might seem rather pointless since prim crossing from this revision to an earlier revision remains | ||
239 | // broken. But it isn't much work to accomodate the old format here. | ||
240 | if (rootNode.LocalName.Equals("scene")) | ||
241 | { | ||
242 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | ||
243 | { | ||
244 | // There is only ever one prim. This oddity should be removeable post 0.5.9 | ||
245 | //return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml); | ||
246 | using (reader = new XmlTextReader(new StringReader(aPrimNode.OuterXml))) | ||
247 | { | ||
248 | SceneObjectGroup obj = new SceneObjectGroup(); | ||
249 | if (SceneObjectSerializer.Xml2ToSOG(reader, obj)) | ||
250 | return obj; | ||
251 | |||
252 | return null; | ||
253 | } | ||
254 | } | ||
255 | |||
256 | return null; | ||
257 | } | ||
258 | else | ||
259 | { | ||
260 | //return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml); | ||
261 | using (reader = new XmlTextReader(new StringReader(rootNode.OuterXml))) | ||
262 | { | ||
263 | SceneObjectGroup obj = new SceneObjectGroup(); | ||
264 | if (SceneObjectSerializer.Xml2ToSOG(reader, obj)) | ||
265 | return obj; | ||
266 | |||
267 | return null; | ||
268 | } | ||
269 | } | ||
270 | } | 227 | } |
271 | 228 | ||
272 | /// <summary> | 229 | /// <summary> |
@@ -307,8 +264,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
307 | ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); | 264 | ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); |
308 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | 265 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) |
309 | { | 266 | { |
310 | SceneObjectGroup obj = CreatePrimFromXml2(scene, aPrimNode.OuterXml); | 267 | SceneObjectGroup obj = DeserializeGroupFromXml2(aPrimNode.OuterXml); |
311 | if (obj != null && startScripts) | 268 | if (startScripts) |
312 | sceneObjects.Add(obj); | 269 | sceneObjects.Add(obj); |
313 | } | 270 | } |
314 | 271 | ||
@@ -319,27 +276,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
319 | } | 276 | } |
320 | } | 277 | } |
321 | 278 | ||
322 | /// <summary> | ||
323 | /// Create a prim from the xml2 representation. | ||
324 | /// </summary> | ||
325 | /// <param name="scene"></param> | ||
326 | /// <param name="xmlData"></param> | ||
327 | /// <returns>The scene object created. null if the scene object already existed</returns> | ||
328 | protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData) | ||
329 | { | ||
330 | //SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData); | ||
331 | using (XmlTextReader reader = new XmlTextReader(new StringReader(xmlData))) | ||
332 | { | ||
333 | SceneObjectGroup obj = new SceneObjectGroup(); | ||
334 | SceneObjectSerializer.Xml2ToSOG(reader, obj); | ||
335 | |||
336 | if (scene.AddRestoredSceneObject(obj, true, false)) | ||
337 | return obj; | ||
338 | else | ||
339 | return null; | ||
340 | } | ||
341 | } | ||
342 | |||
343 | #endregion | 279 | #endregion |
344 | } | 280 | } |
345 | } | 281 | } \ No newline at end of file |