aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World
diff options
context:
space:
mode:
authorMelanie2012-05-16 12:40:45 +0100
committerMelanie2012-05-16 12:40:45 +0100
commit597f99bca7f0bbea9a1346b7c19c38a58f25257c (patch)
treefd267a58cd1ea2a3500c7b37253bd1ccfef279b9 /OpenSim/Region/CoreModules/World
parentMerge branch 'avination' into careminster (diff)
parentRoute OAR SOG loading through the common SceneObjectSerializer.FromXml2Format... (diff)
downloadopensim-SC-597f99bca7f0bbea9a1346b7c19c38a58f25257c.zip
opensim-SC-597f99bca7f0bbea9a1346b7c19c38a58f25257c.tar.gz
opensim-SC-597f99bca7f0bbea9a1346b7c19c38a58f25257c.tar.bz2
opensim-SC-597f99bca7f0bbea9a1346b7c19c38a58f25257c.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs53
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs309
3 files changed, 262 insertions, 101 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;
41using OpenSim.Region.CoreModules.World.Terrain; 41using OpenSim.Region.CoreModules.World.Terrain;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Services.Interfaces; 45using OpenSim.Services.Interfaces;
45 46
46namespace OpenSim.Region.CoreModules.World.Archiver 47namespace 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;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Text; 31using System.Text;
32using System.Text.RegularExpressions;
32using log4net; 33using log4net;
33using Mono.Addins; 34using Mono.Addins;
35using NDesk.Options;
34using Nini.Config; 36using Nini.Config;
35using OpenMetaverse; 37using OpenMetaverse;
36using OpenSim.Framework; 38using 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