aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/Console/ConsoleDisplayTable.cs15
-rw-r--r--OpenSim/Region/Application/OpenSim.cs56
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs50
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs233
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs5
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs48
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs9
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs14
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScenePresence.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs41
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs62
-rw-r--r--OpenSim/Services/GridService/GridService.cs140
-rw-r--r--OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs5
-rw-r--r--OpenSim/Tests/Common/OpenSimTestCase.cs46
-rw-r--r--OpenSim/Tests/Common/TestHelpers.cs3
17 files changed, 507 insertions, 240 deletions
diff --git a/OpenSim/Framework/Console/ConsoleDisplayTable.cs b/OpenSim/Framework/Console/ConsoleDisplayTable.cs
index e9d1628..c620dfe 100644
--- a/OpenSim/Framework/Console/ConsoleDisplayTable.cs
+++ b/OpenSim/Framework/Console/ConsoleDisplayTable.cs
@@ -79,6 +79,16 @@ namespace OpenSim.Framework.Console
79 return sb.ToString(); 79 return sb.ToString();
80 } 80 }
81 81
82 public void AddColumn(string name, int width)
83 {
84 Columns.Add(new ConsoleDisplayTableColumn(name, width));
85 }
86
87 public void AddRow(params string[] cells)
88 {
89 Rows.Add(new ConsoleDisplayTableRow(cells));
90 }
91
82 public void AddToStringBuilder(StringBuilder sb) 92 public void AddToStringBuilder(StringBuilder sb)
83 { 93 {
84 string formatString = GetFormatString(); 94 string formatString = GetFormatString();
@@ -135,5 +145,10 @@ namespace OpenSim.Framework.Console
135 { 145 {
136 Cells = cells; 146 Cells = cells;
137 } 147 }
148
149 public ConsoleDisplayTableRow(params string[] cells) : this()
150 {
151 Cells = new List<string>(cells);
152 }
138 } 153 }
139} \ No newline at end of file 154} \ No newline at end of file
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 9c952aa..1458ff9 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -409,10 +409,6 @@ namespace OpenSim
409 m_console.Commands.AddCommand("General", false, "modules unload", 409 m_console.Commands.AddCommand("General", false, "modules unload",
410 "modules unload <name>", 410 "modules unload <name>",
411 "Unload a module", HandleModules); 411 "Unload a module", HandleModules);
412
413 m_console.Commands.AddCommand("Objects", false, "kill uuid",
414 "kill uuid <UUID>",
415 "Kill an object by UUID", KillUUID);
416 } 412 }
417 413
418 public override void ShutdownSpecific() 414 public override void ShutdownSpecific()
@@ -1309,58 +1305,6 @@ namespace OpenSim
1309 return result; 1305 return result;
1310 } 1306 }
1311 1307
1312 /// <summary>
1313 /// Kill an object given its UUID.
1314 /// </summary>
1315 /// <param name="cmdparams"></param>
1316 protected void KillUUID(string module, string[] cmdparams)
1317 {
1318 if (cmdparams.Length > 2)
1319 {
1320 UUID id = UUID.Zero;
1321 SceneObjectGroup grp = null;
1322 Scene sc = null;
1323
1324 if (!UUID.TryParse(cmdparams[2], out id))
1325 {
1326 MainConsole.Instance.Output("[KillUUID]: Error bad UUID format!");
1327 return;
1328 }
1329
1330 m_sceneManager.ForEachScene(
1331 delegate(Scene scene)
1332 {
1333 SceneObjectPart part = scene.GetSceneObjectPart(id);
1334 if (part == null)
1335 return;
1336
1337 grp = part.ParentGroup;
1338 sc = scene;
1339 });
1340
1341 if (grp == null)
1342 {
1343 MainConsole.Instance.Output(String.Format("[KillUUID]: Given UUID {0} not found!", id));
1344 }
1345 else
1346 {
1347 MainConsole.Instance.Output(String.Format("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName));
1348 try
1349 {
1350 sc.DeleteSceneObject(grp, false);
1351 }
1352 catch (Exception e)
1353 {
1354 m_log.ErrorFormat("[KillUUID]: Error while removing objects from scene: " + e);
1355 }
1356 }
1357 }
1358 else
1359 {
1360 MainConsole.Instance.Output("[KillUUID]: Usage: kill uuid <UUID>");
1361 }
1362 }
1363
1364 #endregion 1308 #endregion
1365 } 1309 }
1366} 1310}
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 54cff55..fcf682b 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -102,6 +102,56 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
102 102
103 #region IAttachmentsModule 103 #region IAttachmentsModule
104 104
105 public void CopyAttachments(IScenePresence sp, AgentData ad)
106 {
107 lock (sp.AttachmentsSyncLock)
108 {
109 // Attachment objects
110 List<SceneObjectGroup> attachments = sp.GetAttachments();
111 if (attachments.Count > 0)
112 {
113 ad.AttachmentObjects = new List<ISceneObject>();
114 ad.AttachmentObjectStates = new List<string>();
115 // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
116 sp.InTransitScriptStates.Clear();
117
118 foreach (SceneObjectGroup sog in attachments)
119 {
120 // We need to make a copy and pass that copy
121 // because of transfers withn the same sim
122 ISceneObject clone = sog.CloneForNewScene();
123 // Attachment module assumes that GroupPosition holds the offsets...!
124 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
125 ((SceneObjectGroup)clone).IsAttachment = false;
126 ad.AttachmentObjects.Add(clone);
127 string state = sog.GetStateSnapshot();
128 ad.AttachmentObjectStates.Add(state);
129 sp.InTransitScriptStates.Add(state);
130 // Let's remove the scripts of the original object here
131 sog.RemoveScriptInstances(true);
132 }
133 }
134 }
135 }
136
137 public void CopyAttachments(AgentData ad, IScenePresence sp)
138 {
139 if (ad.AttachmentObjects != null && ad.AttachmentObjects.Count > 0)
140 {
141 lock (sp.AttachmentsSyncLock)
142 sp.ClearAttachments();
143
144 int i = 0;
145 foreach (ISceneObject so in ad.AttachmentObjects)
146 {
147 ((SceneObjectGroup)so).LocalId = 0;
148 ((SceneObjectGroup)so).RootPart.ClearUpdateSchedule();
149 so.SetState(ad.AttachmentObjectStates[i++], m_scene);
150 m_scene.IncomingCreateObject(Vector3.Zero, so);
151 }
152 }
153 }
154
105 /// <summary> 155 /// <summary>
106 /// RezAttachments. This should only be called upon login on the first region. 156 /// RezAttachments. This should only be called upon login on the first region.
107 /// Attachment rezzings on crossings and TPs are done in a different way. 157 /// Attachment rezzings on crossings and TPs are done in a different way.
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 8969006..1c10422 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -38,11 +38,14 @@ using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
40using OpenSim.Region.CoreModules.Avatar.Attachments; 40using OpenSim.Region.CoreModules.Avatar.Attachments;
41using OpenSim.Region.CoreModules.Framework;
42using OpenSim.Region.CoreModules.Framework.EntityTransfer;
41using OpenSim.Region.CoreModules.Framework.InventoryAccess; 43using OpenSim.Region.CoreModules.Framework.InventoryAccess;
42using OpenSim.Region.CoreModules.World.Serialiser; 44using OpenSim.Region.CoreModules.World.Serialiser;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
44using OpenSim.Region.Framework.Scenes; 46using OpenSim.Region.Framework.Scenes;
45using OpenSim.Region.Framework.Interfaces; 47using OpenSim.Region.Framework.Interfaces;
48using OpenSim.Services.Interfaces;
46using OpenSim.Tests.Common; 49using OpenSim.Tests.Common;
47using OpenSim.Tests.Common.Mock; 50using OpenSim.Tests.Common.Mock;
48 51
@@ -52,27 +55,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
52 /// Attachment tests 55 /// Attachment tests
53 /// </summary> 56 /// </summary>
54 [TestFixture] 57 [TestFixture]
55 public class AttachmentsModuleTests 58 public class AttachmentsModuleTests : OpenSimTestCase
56 { 59 {
57 private Scene scene;
58 private AttachmentsModule m_attMod;
59 private ScenePresence m_presence;
60
61 /// <summary>
62 /// Standard user ID
63 /// </summary>
64 private UUID m_userId = TestHelpers.ParseTail(0x1);
65
66// /// <summary>
67// /// Standard attachment item ID
68// /// </summary>
69// private UUID m_attItemId = TestHelpers.ParseTail(0x10);
70//
71// /// <summary>
72// /// Standard attachment asset ID
73// /// </summary>
74// private UUID m_attAssetId = TestHelpers.ParseTail(0x11);
75
76 [TestFixtureSetUp] 60 [TestFixtureSetUp]
77 public void FixtureInit() 61 public void FixtureInit()
78 { 62 {
@@ -80,18 +64,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
80 Util.FireAndForgetMethod = FireAndForgetMethod.None; 64 Util.FireAndForgetMethod = FireAndForgetMethod.None;
81 } 65 }
82 66
83 [SetUp]
84 public void Init()
85 {
86 IConfigSource config = new IniConfigSource();
87 config.AddConfig("Modules");
88 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
89
90 scene = new SceneHelpers().SetupScene();
91 m_attMod = new AttachmentsModule();
92 SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule());
93 }
94
95 [TestFixtureTearDown] 67 [TestFixtureTearDown]
96 public void TearDown() 68 public void TearDown()
97 { 69 {
@@ -100,6 +72,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
100 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; 72 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
101 } 73 }
102 74
75 private Scene CreateDefaultTestScene()
76 {
77 IConfigSource config = new IniConfigSource();
78 config.AddConfig("Modules");
79 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
80
81 Scene scene = new SceneHelpers().SetupScene();
82 SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule());
83
84 return scene;
85 }
86
103 /// <summary> 87 /// <summary>
104 /// Creates an attachment item in the given user's inventory. Does not attach. 88 /// Creates an attachment item in the given user's inventory. Does not attach.
105 /// </summary> 89 /// </summary>
@@ -109,11 +93,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
109 /// <returns> 93 /// <returns>
110 /// The attachment item. 94 /// The attachment item.
111 /// </returns> 95 /// </returns>
96 /// <param name='scene'></param>
112 /// <param name='userId'></param> 97 /// <param name='userId'></param>
113 /// <param name='attName'></param> 98 /// <param name='attName'></param>
114 /// <param name='rawItemId'></param> 99 /// <param name='rawItemId'></param>
115 /// <param name='rawAssetId'></param> 100 /// <param name='rawAssetId'></param>
116 private InventoryItemBase CreateAttachmentItem(UUID userId, string attName, int rawItemId, int rawAssetId) 101 private InventoryItemBase CreateAttachmentItem(
102 Scene scene, UUID userId, string attName, int rawItemId, int rawAssetId)
117 { 103 {
118 return UserInventoryHelpers.CreateInventoryItem( 104 return UserInventoryHelpers.CreateInventoryItem(
119 scene, 105 scene,
@@ -130,18 +116,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
130 TestHelpers.InMethod(); 116 TestHelpers.InMethod();
131// TestHelpers.EnableLogging(); 117// TestHelpers.EnableLogging();
132 118
133 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 119 Scene scene = CreateDefaultTestScene();
134 m_presence = SceneHelpers.AddScenePresence(scene, m_userId); 120 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
121 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
135 122
136 string attName = "att"; 123 string attName = "att";
137 124
138 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, m_presence.UUID).ParentGroup; 125 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID).ParentGroup;
139 126
140 m_attMod.AttachObject(m_presence, so, (uint)AttachmentPoint.Chest, false, false); 127 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false);
141 128
142 // Check status on scene presence 129 // Check status on scene presence
143 Assert.That(m_presence.HasAttachments(), Is.True); 130 Assert.That(sp.HasAttachments(), Is.True);
144 List<SceneObjectGroup> attachments = m_presence.GetAttachments(); 131 List<SceneObjectGroup> attachments = sp.GetAttachments();
145 Assert.That(attachments.Count, Is.EqualTo(1)); 132 Assert.That(attachments.Count, Is.EqualTo(1));
146 SceneObjectGroup attSo = attachments[0]; 133 SceneObjectGroup attSo = attachments[0];
147 Assert.That(attSo.Name, Is.EqualTo(attName)); 134 Assert.That(attSo.Name, Is.EqualTo(attName));
@@ -152,14 +139,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
152 139
153 // Check item status 140 // Check item status
154 Assert.That( 141 Assert.That(
155 m_presence.Appearance.GetAttachpoint(attSo.FromItemID), 142 sp.Appearance.GetAttachpoint(attSo.FromItemID),
156 Is.EqualTo((int)AttachmentPoint.Chest)); 143 Is.EqualTo((int)AttachmentPoint.Chest));
157 144
158 InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID)); 145 InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
159 Assert.That(attachmentItem, Is.Not.Null); 146 Assert.That(attachmentItem, Is.Not.Null);
160 Assert.That(attachmentItem.Name, Is.EqualTo(attName)); 147 Assert.That(attachmentItem.Name, Is.EqualTo(attName));
161 148
162 InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(m_presence.UUID, AssetType.Object); 149 InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object);
163 Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID)); 150 Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));
164 151
165// TestHelpers.DisableLogging(); 152// TestHelpers.DisableLogging();
@@ -171,17 +158,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
171 TestHelpers.InMethod(); 158 TestHelpers.InMethod();
172// log4net.Config.XmlConfigurator.Configure(); 159// log4net.Config.XmlConfigurator.Configure();
173 160
174 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 161 Scene scene = CreateDefaultTestScene();
175 m_presence = SceneHelpers.AddScenePresence(scene, m_userId); 162 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
163 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
176 164
177 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); 165 InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
178 166
179 m_attMod.RezSingleAttachmentFromInventory( 167 scene.AttachmentsModule.RezSingleAttachmentFromInventory(
180 m_presence, attItem.ID, (uint)AttachmentPoint.Chest); 168 sp, attItem.ID, (uint)AttachmentPoint.Chest);
181 169
182 // Check scene presence status 170 // Check scene presence status
183 Assert.That(m_presence.HasAttachments(), Is.True); 171 Assert.That(sp.HasAttachments(), Is.True);
184 List<SceneObjectGroup> attachments = m_presence.GetAttachments(); 172 List<SceneObjectGroup> attachments = sp.GetAttachments();
185 Assert.That(attachments.Count, Is.EqualTo(1)); 173 Assert.That(attachments.Count, Is.EqualTo(1));
186 SceneObjectGroup attSo = attachments[0]; 174 SceneObjectGroup attSo = attachments[0];
187 Assert.That(attSo.Name, Is.EqualTo(attItem.Name)); 175 Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
@@ -191,8 +179,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
191 Assert.That(attSo.IsTemporary, Is.False); 179 Assert.That(attSo.IsTemporary, Is.False);
192 180
193 // Check appearance status 181 // Check appearance status
194 Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(1)); 182 Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
195 Assert.That(m_presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); 183 Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
196 } 184 }
197 185
198 [Test] 186 [Test]
@@ -201,23 +189,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
201 TestHelpers.InMethod(); 189 TestHelpers.InMethod();
202// log4net.Config.XmlConfigurator.Configure(); 190// log4net.Config.XmlConfigurator.Configure();
203 191
204 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 192 Scene scene = CreateDefaultTestScene();
205 m_presence = SceneHelpers.AddScenePresence(scene, m_userId); 193 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
194 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
206 195
207 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); 196 InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
208 197
209 ISceneEntity so 198 ISceneEntity so
210 = m_attMod.RezSingleAttachmentFromInventory( 199 = scene.AttachmentsModule.RezSingleAttachmentFromInventory(
211 m_presence, attItem.ID, (uint)AttachmentPoint.Chest); 200 sp, attItem.ID, (uint)AttachmentPoint.Chest);
212 m_attMod.DetachSingleAttachmentToGround(m_presence, so.LocalId); 201 scene.AttachmentsModule.DetachSingleAttachmentToGround(sp, so.LocalId);
213 202
214 // Check scene presence status 203 // Check scene presence status
215 Assert.That(m_presence.HasAttachments(), Is.False); 204 Assert.That(sp.HasAttachments(), Is.False);
216 List<SceneObjectGroup> attachments = m_presence.GetAttachments(); 205 List<SceneObjectGroup> attachments = sp.GetAttachments();
217 Assert.That(attachments.Count, Is.EqualTo(0)); 206 Assert.That(attachments.Count, Is.EqualTo(0));
218 207
219 // Check appearance status 208 // Check appearance status
220 Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(0)); 209 Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(0));
221 210
222 // Check item status 211 // Check item status
223 Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItem.ID)), Is.Null); 212 Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItem.ID)), Is.Null);
@@ -232,22 +221,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
232 TestHelpers.InMethod(); 221 TestHelpers.InMethod();
233// log4net.Config.XmlConfigurator.Configure(); 222// log4net.Config.XmlConfigurator.Configure();
234 223
235 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 224 Scene scene = CreateDefaultTestScene();
236 m_presence = SceneHelpers.AddScenePresence(scene, m_userId); 225 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
226 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
237 227
238 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); 228 InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
239 229
240 m_attMod.RezSingleAttachmentFromInventory( 230 scene.AttachmentsModule.RezSingleAttachmentFromInventory(
241 m_presence, attItem.ID, (uint)AttachmentPoint.Chest); 231 sp, attItem.ID, (uint)AttachmentPoint.Chest);
242 m_attMod.DetachSingleAttachmentToInv(m_presence, attItem.ID); 232 scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, attItem.ID);
243 233
244 // Check status on scene presence 234 // Check status on scene presence
245 Assert.That(m_presence.HasAttachments(), Is.False); 235 Assert.That(sp.HasAttachments(), Is.False);
246 List<SceneObjectGroup> attachments = m_presence.GetAttachments(); 236 List<SceneObjectGroup> attachments = sp.GetAttachments();
247 Assert.That(attachments.Count, Is.EqualTo(0)); 237 Assert.That(attachments.Count, Is.EqualTo(0));
248 238
249 // Check item status 239 // Check item status
250 Assert.That(m_presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0)); 240 Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0));
251 } 241 }
252 242
253 /// <summary> 243 /// <summary>
@@ -259,10 +249,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
259 TestHelpers.InMethod(); 249 TestHelpers.InMethod();
260// log4net.Config.XmlConfigurator.Configure(); 250// log4net.Config.XmlConfigurator.Configure();
261 251
262 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 252 Scene scene = CreateDefaultTestScene();
263 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); 253 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
254 InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
264 255
265 AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); 256 AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
266 acd.Appearance = new AvatarAppearance(); 257 acd.Appearance = new AvatarAppearance();
267 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); 258 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
268 ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); 259 ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
@@ -281,10 +272,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
281 TestHelpers.InMethod(); 272 TestHelpers.InMethod();
282// log4net.Config.XmlConfigurator.Configure(); 273// log4net.Config.XmlConfigurator.Configure();
283 274
284 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 275 Scene scene = CreateDefaultTestScene();
285 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); 276 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
277 InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
286 278
287 AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); 279 AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
288 acd.Appearance = new AvatarAppearance(); 280 acd.Appearance = new AvatarAppearance();
289 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); 281 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
290 ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); 282 ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
@@ -314,10 +306,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
314 { 306 {
315 TestHelpers.InMethod(); 307 TestHelpers.InMethod();
316 308
317 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 309 Scene scene = CreateDefaultTestScene();
318 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); 310 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
311 InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);
319 312
320 AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); 313 AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
321 acd.Appearance = new AvatarAppearance(); 314 acd.Appearance = new AvatarAppearance();
322 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); 315 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
323 ScenePresence sp = SceneHelpers.AddScenePresence(scene, acd); 316 ScenePresence sp = SceneHelpers.AddScenePresence(scene, acd);
@@ -332,6 +325,92 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
332 Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition)); 325 Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition));
333 } 326 }
334 327
328 [Test]
329 public void TestSameSimulatorNeighbouringRegionsTeleport()
330 {
331 TestHelpers.InMethod();
332// TestHelpers.EnableLogging();
333
334 AttachmentsModule attModA = new AttachmentsModule();
335 AttachmentsModule attModB = new AttachmentsModule();
336 EntityTransferModule etmA = new EntityTransferModule();
337 EntityTransferModule etmB = new EntityTransferModule();
338 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
339
340 IConfigSource config = new IniConfigSource();
341 IConfig modulesConfig = config.AddConfig("Modules");
342 modulesConfig.Set("EntityTransferModule", etmA.Name);
343 modulesConfig.Set("SimulationServices", lscm.Name);
344 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
345
346 // In order to run a single threaded regression test we do not want the entity transfer module waiting
347 // for a callback from the destination scene before removing its avatar data.
348 entityTransferConfig.Set("wait_for_callback", false);
349
350 modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule");
351
352 SceneHelpers sh = new SceneHelpers();
353 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
354 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
355
356 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
357 SceneHelpers.SetupSceneModules(
358 sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule());
359 SceneHelpers.SetupSceneModules(
360 sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule());
361
362 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1);
363 ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, ua1.PrincipalID, sh.SceneManager);
364 beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32);
365
366 InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20);
367
368 sceneA.AttachmentsModule.RezSingleAttachmentFromInventory(
369 beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest);
370
371 Vector3 teleportPosition = new Vector3(10, 11, 12);
372 Vector3 teleportLookAt = new Vector3(20, 21, 22);
373
374 sceneA.RequestTeleportLocation(
375 beforeTeleportSp.ControllingClient,
376 sceneB.RegionInfo.RegionHandle,
377 teleportPosition,
378 teleportLookAt,
379 (uint)TeleportFlags.ViaLocation);
380
381 ((TestClient)beforeTeleportSp.ControllingClient).CompleteTeleportClientSide();
382
383 // Check attachments have made it into sceneB
384 ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID);
385
386 // This is appearance data, as opposed to actually rezzed attachments
387 List<AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments();
388 Assert.That(sceneBAttachments.Count, Is.EqualTo(1));
389 Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
390 Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID));
391 Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
392 Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
393
394 // This is the actual attachment
395 List<SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments();
396 Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1));
397 SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0];
398 Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name));
399 Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest));
400
401 // Check attachments have been removed from sceneA
402 ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID);
403
404 // Since this is appearance data, it is still present on the child avatar!
405 List<AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments();
406 Assert.That(sceneAAttachments.Count, Is.EqualTo(1));
407 Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
408
409 // This is the actual attachment, which should no longer exist
410 List<SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments();
411 Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0));
412 }
413
335 // I'm commenting this test because scene setup NEEDS InventoryService to 414 // I'm commenting this test because scene setup NEEDS InventoryService to
336 // be non-null 415 // be non-null
337 //[Test] 416 //[Test]
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 875c073..89cc4f6 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -128,7 +128,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
128 /// <param name="visualParam"></param> 128 /// <param name="visualParam"></param>
129 public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams) 129 public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams)
130 { 130 {
131 // m_log.InfoFormat("[AVFACTORY]: start SetAppearance for {0}", client.AgentId); 131// m_log.DebugFormat(
132// "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}",
133// sp.Name, textureEntry, visualParams);
132 134
133 // TODO: This is probably not necessary any longer, just assume the 135 // TODO: This is probably not necessary any longer, just assume the
134 // textureEntry set implies that the appearance transaction is complete 136 // textureEntry set implies that the appearance transaction is complete
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
index 90ae69d..1056865 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs
@@ -48,7 +48,7 @@ using OpenSim.Tests.Common.Mock;
48namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests 48namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
49{ 49{
50 [TestFixture] 50 [TestFixture]
51 public class InventoryArchiveTestCase 51 public class InventoryArchiveTestCase : OpenSimTestCase
52 { 52 {
53 protected ManualResetEvent mre = new ManualResetEvent(false); 53 protected ManualResetEvent mre = new ManualResetEvent(false);
54 54
@@ -84,8 +84,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
84 protected string m_coaItemName = "Coalesced Item"; 84 protected string m_coaItemName = "Coalesced Item";
85 85
86 [SetUp] 86 [SetUp]
87 public virtual void SetUp() 87 public override void SetUp()
88 { 88 {
89 base.SetUp();
89 m_iarStream = new MemoryStream(m_iarStreamBytes); 90 m_iarStream = new MemoryStream(m_iarStreamBytes);
90 } 91 }
91 92
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 7b13213..560f807 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -709,6 +709,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
709 agent.CallbackURI, region.RegionName); 709 agent.CallbackURI, region.RegionName);
710 } 710 }
711 711
712 /// <summary>
713 /// Clean up operations once an agent has moved away through cross or teleport.
714 /// </summary>
715 /// <param name='sp'></param>
716 /// <param name='logout'></param>
712 protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) 717 protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout)
713 { 718 {
714 if (sp.Scene.AttachmentsModule != null) 719 if (sp.Scene.AttachmentsModule != null)
@@ -1622,6 +1627,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1622 #endregion 1627 #endregion
1623 1628
1624 #region Object Transfers 1629 #region Object Transfers
1630
1625 /// <summary> 1631 /// <summary>
1626 /// Move the given scene object into a new region depending on which region its absolute position has moved 1632 /// Move the given scene object into a new region depending on which region its absolute position has moved
1627 /// into. 1633 /// into.
@@ -1932,35 +1938,43 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1932 return successYN; 1938 return successYN;
1933 } 1939 }
1934 1940
1935 protected bool CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent) 1941 /// <summary>
1942 /// Cross the attachments for an avatar into the destination region.
1943 /// </summary>
1944 /// <remarks>
1945 /// This is only invoked for simulators released prior to April 2011. Versions of OpenSimulator since then
1946 /// transfer attachments in one go as part of the ChildAgentDataUpdate data passed in the update agent call.
1947 /// </remarks>
1948 /// <param name='destination'></param>
1949 /// <param name='sp'></param>
1950 /// <param name='silent'></param>
1951 protected void CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent)
1936 { 1952 {
1937 List<SceneObjectGroup> m_attachments = sp.GetAttachments(); 1953 List<SceneObjectGroup> attachments = sp.GetAttachments();
1938 1954
1939 // Validate 1955// m_log.DebugFormat(
1940// foreach (SceneObjectGroup gobj in m_attachments) 1956// "[ENTITY TRANSFER MODULE]: Crossing {0} attachments into {1} for {2}",
1941// { 1957// m_attachments.Count, destination.RegionName, sp.Name);
1942// if (gobj == null || gobj.IsDeleted)
1943// return false;
1944// }
1945 1958
1946 foreach (SceneObjectGroup gobj in m_attachments) 1959 foreach (SceneObjectGroup gobj in attachments)
1947 { 1960 {
1948 // If the prim group is null then something must have happened to it! 1961 // If the prim group is null then something must have happened to it!
1949 if (gobj != null && !gobj.IsDeleted) 1962 if (gobj != null && !gobj.IsDeleted)
1950 { 1963 {
1951 // Set the parent localID to 0 so it transfers over properly. 1964 SceneObjectGroup clone = (SceneObjectGroup)gobj.CloneForNewScene();
1952 gobj.RootPart.SetParentLocalId(0); 1965 clone.RootPart.GroupPosition = gobj.RootPart.AttachedPos;
1953 gobj.AbsolutePosition = gobj.RootPart.AttachedPos; 1966 clone.IsAttachment = false;
1954 gobj.IsAttachment = false; 1967
1955 //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); 1968 //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
1956 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); 1969 m_log.DebugFormat(
1957 CrossPrimGroupIntoNewRegion(destination, Vector3.Zero, gobj, silent); 1970 "[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}",
1971 clone.UUID, destination.RegionName);
1972
1973 CrossPrimGroupIntoNewRegion(destination, Vector3.Zero, clone, silent);
1958 } 1974 }
1959 } 1975 }
1960 1976
1961 sp.ClearAttachments(); 1977 sp.ClearAttachments();
1962
1963 return true;
1964 } 1978 }
1965 1979
1966 #endregion 1980 #endregion
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
index 830d9cb..e5cd3e2 100644
--- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
@@ -98,7 +98,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
98 m_console.Commands.AddCommand( 98 m_console.Commands.AddCommand(
99 "Objects", false, "delete object name", 99 "Objects", false, "delete object name",
100 "delete object name [--regex] <name>", 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", 101 "Delete a scene object by name.",
102 "If --regex is specified then the name is treatead as a regular expression",
102 HandleDeleteObject); 103 HandleDeleteObject);
103 104
104 m_console.Commands.AddCommand( 105 m_console.Commands.AddCommand(
@@ -118,7 +119,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
118 false, 119 false,
119 "show object name", 120 "show object name",
120 "show object name [--regex] <name>", 121 "show object name [--regex] <name>",
121 "Show details of scene objects with the given name.\nIf --regex is specified then the name is treatead as a regular expression", 122 "Show details of scene objects with the given name.",
123 "If --regex is specified then the name is treatead as a regular expression",
122 HandleShowObjectByName); 124 HandleShowObjectByName);
123 125
124 m_console.Commands.AddCommand( 126 m_console.Commands.AddCommand(
@@ -133,7 +135,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
133 false, 135 false,
134 "show part name", 136 "show part name",
135 "show part name [--regex] <name>", 137 "show part name [--regex] <name>",
136 "Show details of scene object parts with the given name.\nIf --regex is specified then the name is treatead as a regular expression", 138 "Show details of scene object parts with the given name.",
139 "If --regex is specified then the name is treatead as a regular expression",
137 HandleShowPartByName); 140 HandleShowPartByName);
138 } 141 }
139 142
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 70ea7cf..7446530 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -37,6 +37,20 @@ namespace OpenSim.Region.Framework.Interfaces
37 public interface IAttachmentsModule 37 public interface IAttachmentsModule
38 { 38 {
39 /// <summary> 39 /// <summary>
40 /// Copy attachment data from a ScenePresence into the AgentData structure for transmission to another simulator
41 /// </summary>
42 /// <param name='sp'></param>
43 /// <param name='ad'></param>
44 void CopyAttachments(IScenePresence sp, AgentData ad);
45
46 /// <summary>
47 /// Copy attachment data from an AgentData structure into a ScenePresence.
48 /// </summary>
49 /// <param name='ad'></param>
50 /// <param name='sp'></param>
51 void CopyAttachments(AgentData ad, IScenePresence sp);
52
53 /// <summary>
40 /// RezAttachments. This should only be called upon login on the first region. 54 /// RezAttachments. This should only be called upon login on the first region.
41 /// Attachment rezzings on crossings and TPs are done in a different way. 55 /// Attachment rezzings on crossings and TPs are done in a different way.
42 /// </summary> 56 /// </summary>
diff --git a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
index 5e43843..19a8236 100644
--- a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
@@ -41,6 +41,12 @@ namespace OpenSim.Region.Framework.Interfaces
41 public interface IScenePresence : ISceneAgent 41 public interface IScenePresence : ISceneAgent
42 { 42 {
43 /// <summary> 43 /// <summary>
44 /// Copy of the script states while the agent is in transit. This state may
45 /// need to be placed back in case of transfer fail.
46 /// </summary>
47 List<string> InTransitScriptStates { get; }
48
49 /// <summary>
44 /// The AttachmentsModule synchronizes on this to avoid race conditions between commands to add and remove attachments. 50 /// The AttachmentsModule synchronizes on this to avoid race conditions between commands to add and remove attachments.
45 /// </summary> 51 /// </summary>
46 /// <remarks> 52 /// <remarks>
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index f3e8377..159a92a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3279,31 +3279,8 @@ namespace OpenSim.Region.Framework.Scenes
3279 catch { } 3279 catch { }
3280 cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; 3280 cAgent.DefaultAnim = Animator.Animations.DefaultAnimation;
3281 3281
3282 // Attachment objects 3282 if (Scene.AttachmentsModule != null)
3283 List<SceneObjectGroup> attachments = GetAttachments(); 3283 Scene.AttachmentsModule.CopyAttachments(this, cAgent);
3284 if (attachments.Count > 0)
3285 {
3286 cAgent.AttachmentObjects = new List<ISceneObject>();
3287 cAgent.AttachmentObjectStates = new List<string>();
3288// IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
3289 InTransitScriptStates.Clear();
3290
3291 foreach (SceneObjectGroup sog in attachments)
3292 {
3293 // We need to make a copy and pass that copy
3294 // because of transfers withn the same sim
3295 ISceneObject clone = sog.CloneForNewScene();
3296 // Attachment module assumes that GroupPosition holds the offsets...!
3297 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
3298 ((SceneObjectGroup)clone).IsAttachment = false;
3299 cAgent.AttachmentObjects.Add(clone);
3300 string state = sog.GetStateSnapshot();
3301 cAgent.AttachmentObjectStates.Add(state);
3302 InTransitScriptStates.Add(state);
3303 // Let's remove the scripts of the original object here
3304 sog.RemoveScriptInstances(true);
3305 }
3306 }
3307 } 3284 }
3308 3285
3309 private void CopyFrom(AgentData cAgent) 3286 private void CopyFrom(AgentData cAgent)
@@ -3378,18 +3355,8 @@ namespace OpenSim.Region.Framework.Scenes
3378 if (cAgent.DefaultAnim != null) 3355 if (cAgent.DefaultAnim != null)
3379 Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); 3356 Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero);
3380 3357
3381 if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0) 3358 if (Scene.AttachmentsModule != null)
3382 { 3359 Scene.AttachmentsModule.CopyAttachments(cAgent, this);
3383 m_attachments = new List<SceneObjectGroup>();
3384 int i = 0;
3385 foreach (ISceneObject so in cAgent.AttachmentObjects)
3386 {
3387 ((SceneObjectGroup)so).LocalId = 0;
3388 ((SceneObjectGroup)so).RootPart.ClearUpdateSchedule();
3389 so.SetState(cAgent.AttachmentObjectStates[i++], m_scene);
3390 m_scene.IncomingCreateObject(Vector3.Zero, so);
3391 }
3392 }
3393 } 3360 }
3394 3361
3395 public bool CopyAgent(out IAgentData agent) 3362 public bool CopyAgent(out IAgentData agent)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 976969a..06f2c3c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -165,11 +165,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
165 m_LSL_Functions.llBreakLink(linknum); 165 m_LSL_Functions.llBreakLink(linknum);
166 } 166 }
167 167
168 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
169 {
170 return m_LSL_Functions.llCastRay(start, end, options);
171 }
172
173 public LSL_Integer llCeil(double f) 168 public LSL_Integer llCeil(double f)
174 { 169 {
175 return m_LSL_Functions.llCeil(f); 170 return m_LSL_Functions.llCeil(f);
@@ -971,6 +966,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
971 return m_LSL_Functions.llRequestDisplayName(id); 966 return m_LSL_Functions.llRequestDisplayName(id);
972 } 967 }
973 968
969 public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options)
970 {
971 return m_LSL_Functions.llCastRay(start, end, options);
972 }
973
974 public void llLinkParticleSystem(int linknum, LSL_List rules) 974 public void llLinkParticleSystem(int linknum, LSL_List rules)
975 { 975 {
976 m_LSL_Functions.llLinkParticleSystem(linknum, rules); 976 m_LSL_Functions.llLinkParticleSystem(linknum, rules);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index b1583b2..79d1944 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -835,35 +835,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine
835 int colon = firstline.IndexOf(':'); 835 int colon = firstline.IndexOf(':');
836 if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1) 836 if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1)
837 { 837 {
838 string engineName = firstline.Substring(2, colon-2); 838 string engineName = firstline.Substring(2, colon - 2);
839 839
840 if (names.Contains(engineName)) 840 if (names.Contains(engineName))
841 { 841 {
842 engine = engineName; 842 engine = engineName;
843 script = "//" + script.Substring(script.IndexOf(':')+1); 843 script = "//" + script.Substring(colon + 1);
844 } 844 }
845 else 845 else
846 { 846 {
847 if (engine == ScriptEngineName) 847 if (engine == ScriptEngineName)
848 { 848 {
849 SceneObjectPart part = 849 // If we are falling back on XEngine as the default engine, then only complain to the user
850 m_Scene.GetSceneObjectPart( 850 // if a script language has been explicitly set and it's one that we recognize. If it's
851 localID); 851 // explicitly not allowed or the script is not in LSL then the user will be informed by a later compiler message.
852 852 //
853 TaskInventoryItem item = 853 // This avoids the overwhelming number of false positives where we're in this code because
854 part.Inventory.GetInventoryItem(itemID); 854 // there's a colon in a comment in the first line of a script for entirely
855 855 // unrelated reasons (e.g. vim settings).
856 ScenePresence presence = 856 //
857 m_Scene.GetScenePresence( 857 // TODO: A better fix would be to deprecate simple : detection and look for some less likely
858 item.OwnerID); 858 // string to begin the comment (like #! in unix shell scripts).
859 859 bool scriptExplicitlyInXEngineLanguage = false;
860 if (presence != null) 860 string restOfScript = script.Substring(colon + 1);
861
862 // FIXME: These are hardcoded because they are currently hardcoded in Compiler.cs
863 if (restOfScript.StartsWith("c#")
864 || restOfScript.StartsWith("vb")
865 || restOfScript.StartsWith("lsl")
866 || restOfScript.StartsWith("js")
867 || restOfScript.StartsWith("yp"))
868 scriptExplicitlyInXEngineLanguage = true;
869
870 if (scriptExplicitlyInXEngineLanguage)
861 { 871 {
862 presence.ControllingClient.SendAgentAlertMessage( 872 SceneObjectPart part =
863 "Selected engine unavailable. "+ 873 m_Scene.GetSceneObjectPart(
864 "Running script on "+ 874 localID);
865 ScriptEngineName, 875
866 false); 876 TaskInventoryItem item =
877 part.Inventory.GetInventoryItem(itemID);
878
879 ScenePresence presence =
880 m_Scene.GetScenePresence(
881 item.OwnerID);
882
883 if (presence != null)
884 {
885 presence.ControllingClient.SendAgentAlertMessage(
886 "Selected engine unavailable. "+
887 "Running script on "+
888 ScriptEngineName,
889 false);
890 }
867 } 891 }
868 } 892 }
869 } 893 }
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 11897f8..aab403a 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -85,20 +85,39 @@ namespace OpenSim.Services.GridService
85 if (MainConsole.Instance != null) 85 if (MainConsole.Instance != null)
86 { 86 {
87 MainConsole.Instance.Commands.AddCommand("Regions", true, 87 MainConsole.Instance.Commands.AddCommand("Regions", true,
88 "deregister region", 88 "deregister region id",
89 "deregister region <Region UUID>", 89 "deregister region id <Region UUID>",
90 "Deregister a region manually.", 90 "Deregister a region manually.",
91 String.Empty, 91 String.Empty,
92 HandleDeregisterRegion); 92 HandleDeregisterRegion);
93 93
94 // A messy way of stopping this command being added if we are in standalone (since the simulator
95 // has an identically named command
96 //
97 // XXX: We're relying on the OpenSimulator version being registered first, which is not well defined.
98 if (MainConsole.Instance.Commands.Resolve(new string[] { "show", "regions" }).Length == 0)
99 MainConsole.Instance.Commands.AddCommand("Regions", true,
100 "show regions",
101 "show regions",
102 "Show details on all regions",
103 String.Empty,
104 HandleShowRegions);
105
94 MainConsole.Instance.Commands.AddCommand("Regions", true, 106 MainConsole.Instance.Commands.AddCommand("Regions", true,
95 "show region", 107 "show region name",
96 "show region <Region name>", 108 "show region name <Region name>",
97 "Show details on a region", 109 "Show details on a region",
98 String.Empty, 110 String.Empty,
99 HandleShowRegion); 111 HandleShowRegion);
100 112
101 MainConsole.Instance.Commands.AddCommand("Regions", true, 113 MainConsole.Instance.Commands.AddCommand("Regions", true,
114 "show region at",
115 "show region at <x-coord> <y-coord>",
116 "Show details on a region at the given co-ordinate.",
117 "For example, show region at 1000 1000",
118 HandleShowRegionAt);
119
120 MainConsole.Instance.Commands.AddCommand("Regions", true,
102 "set region flags", 121 "set region flags",
103 "set region flags <Region name> <flags>", 122 "set region flags <Region name> <flags>",
104 "Set database flags for region", 123 "Set database flags for region",
@@ -504,13 +523,13 @@ namespace OpenSim.Services.GridService
504 523
505 private void HandleDeregisterRegion(string module, string[] cmd) 524 private void HandleDeregisterRegion(string module, string[] cmd)
506 { 525 {
507 if (cmd.Length != 3) 526 if (cmd.Length != 4)
508 { 527 {
509 MainConsole.Instance.Output("Syntax: degregister region <Region UUID>"); 528 MainConsole.Instance.Output("Syntax: degregister region id <Region UUID>");
510 return; 529 return;
511 } 530 }
512 531
513 string rawRegionUuid = cmd[2]; 532 string rawRegionUuid = cmd[3];
514 UUID regionUuid; 533 UUID regionUuid;
515 534
516 if (!UUID.TryParse(rawRegionUuid, out regionUuid)) 535 if (!UUID.TryParse(rawRegionUuid, out regionUuid))
@@ -540,36 +559,113 @@ namespace OpenSim.Services.GridService
540 return; 559 return;
541 } 560 }
542 561
562 private void HandleShowRegions(string module, string[] cmd)
563 {
564 if (cmd.Length != 2)
565 {
566 MainConsole.Instance.Output("Syntax: show regions");
567 return;
568 }
569
570 List<RegionData> regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero);
571
572 OutputRegionsToConsoleSummary(regions);
573 }
574
575
543 private void HandleShowRegion(string module, string[] cmd) 576 private void HandleShowRegion(string module, string[] cmd)
544 { 577 {
545 if (cmd.Length != 3) 578 if (cmd.Length != 4)
546 { 579 {
547 MainConsole.Instance.Output("Syntax: show region <region name>"); 580 MainConsole.Instance.Output("Syntax: show region name <region name>");
548 return; 581 return;
549 } 582 }
550 List<RegionData> regions = m_Database.Get(cmd[2], UUID.Zero); 583
584 string regionName = cmd[3];
585
586 List<RegionData> regions = m_Database.Get(regionName, UUID.Zero);
551 if (regions == null || regions.Count < 1) 587 if (regions == null || regions.Count < 1)
552 { 588 {
553 MainConsole.Instance.Output("Region not found"); 589 MainConsole.Instance.Output("No region with name {0} found", regionName);
554 return; 590 return;
555 } 591 }
556 592
557 foreach (RegionData r in regions) 593 OutputRegionsToConsole(regions);
594 }
595
596 private void HandleShowRegionAt(string module, string[] cmd)
597 {
598 if (cmd.Length != 5)
558 { 599 {
559 OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); 600 MainConsole.Instance.Output("Syntax: show region at <x-coord> <y-coord>");
601 return;
602 }
603
604 int x, y;
605 if (!int.TryParse(cmd[3], out x))
606 {
607 MainConsole.Instance.Output("x-coord must be an integer");
608 return;
609 }
560 610
561 ConsoleDisplayList dispList = new ConsoleDisplayList(); 611 if (!int.TryParse(cmd[4], out y))
562 dispList.AddRow("Region Name", r.RegionName); 612 {
563 dispList.AddRow("Region ID", r.RegionID); 613 MainConsole.Instance.Output("y-coord must be an integer");
564 dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY)); 614 return;
565 dispList.AddRow("URI", r.Data["serverURI"]); 615 }
566 dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
567 dispList.AddRow("Flags", flags);
568 616
569 MainConsole.Instance.Output(dispList.ToString()); 617 RegionData region = m_Database.Get(x * (int)Constants.RegionSize, y * (int)Constants.RegionSize, UUID.Zero);
618 if (region == null)
619 {
620 MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y);
621 return;
570 } 622 }
571 623
572 return; 624 OutputRegionToConsole(region);
625 }
626
627 private void OutputRegionToConsole(RegionData r)
628 {
629 OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]);
630
631 ConsoleDisplayList dispList = new ConsoleDisplayList();
632 dispList.AddRow("Region Name", r.RegionName);
633 dispList.AddRow("Region ID", r.RegionID);
634 dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY));
635 dispList.AddRow("URI", r.Data["serverURI"]);
636 dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
637 dispList.AddRow("Flags", flags);
638
639 MainConsole.Instance.Output(dispList.ToString());
640 }
641
642 private void OutputRegionsToConsole(List<RegionData> regions)
643 {
644 foreach (RegionData r in regions)
645 OutputRegionToConsole(r);
646 }
647
648 private void OutputRegionsToConsoleSummary(List<RegionData> regions)
649 {
650 ConsoleDisplayTable dispTable = new ConsoleDisplayTable();
651 dispTable.AddColumn("Name", 16);
652 dispTable.AddColumn("ID", 36);
653 dispTable.AddColumn("Position", 11);
654 dispTable.AddColumn("Owner ID", 36);
655 dispTable.AddColumn("Flags", 60);
656
657 foreach (RegionData r in regions)
658 {
659 OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]);
660 dispTable.AddRow(
661 r.RegionName,
662 r.RegionID.ToString(),
663 string.Format("{0},{1}", r.coordX, r.coordY),
664 r.Data["owner_uuid"].ToString(),
665 flags.ToString());
666 }
667
668 MainConsole.Instance.Output(dispTable.ToString());
573 } 669 }
574 670
575 private int ParseFlags(int prev, string flags) 671 private int ParseFlags(int prev, string flags)
diff --git a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs
index b73df2c..3d3e65c 100644
--- a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs
@@ -126,6 +126,11 @@ namespace OpenSim.Tests.Common
126 return CreateUserWithInventory(scene, "Bill", "Bailey", userId, "troll"); 126 return CreateUserWithInventory(scene, "Bill", "Bailey", userId, "troll");
127 } 127 }
128 128
129 public static UserAccount CreateUserWithInventory(Scene scene, int userId)
130 {
131 return CreateUserWithInventory(scene, "Bill", "Bailey", TestHelpers.ParseTail(userId), "troll");
132 }
133
129 public static UserAccount CreateUserWithInventory( 134 public static UserAccount CreateUserWithInventory(
130 Scene scene, string firstName, string lastName, UUID userId, string pw) 135 Scene scene, string firstName, string lastName, UUID userId, string pw)
131 { 136 {
diff --git a/OpenSim/Tests/Common/OpenSimTestCase.cs b/OpenSim/Tests/Common/OpenSimTestCase.cs
new file mode 100644
index 0000000..8c40923
--- /dev/null
+++ b/OpenSim/Tests/Common/OpenSimTestCase.cs
@@ -0,0 +1,46 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using NUnit.Framework;
30
31namespace OpenSim.Tests.Common
32{
33 [TestFixture]
34 public class OpenSimTestCase
35 {
36 [SetUp]
37 public virtual void SetUp()
38 {
39// TestHelpers.InMethod();
40 // Disable logging for each test so that one where logging is enabled doesn't cause all subsequent tests
41 // to have logging on if it failed with an exception.
42 TestHelpers.DisableLogging();
43 }
44 }
45}
46
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs
index d38d692..30121fe 100644
--- a/OpenSim/Tests/Common/TestHelpers.cs
+++ b/OpenSim/Tests/Common/TestHelpers.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Tests.Common
58 </root> 58 </root>
59</log4net>")); 59</log4net>"));
60 60
61 private static Stream DisableLoggingConfigStream 61 private static MemoryStream DisableLoggingConfigStream
62 = new MemoryStream( 62 = new MemoryStream(
63 Encoding.UTF8.GetBytes( 63 Encoding.UTF8.GetBytes(
64// "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/><appender-ref ref=\"A1\"/></root></log4net></configuration>")); 64// "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/><appender-ref ref=\"A1\"/></root></log4net></configuration>"));
@@ -109,6 +109,7 @@ namespace OpenSim.Tests.Common
109 public static void DisableLogging() 109 public static void DisableLogging()
110 { 110 {
111 log4net.Config.XmlConfigurator.Configure(DisableLoggingConfigStream); 111 log4net.Config.XmlConfigurator.Configure(DisableLoggingConfigStream);
112 DisableLoggingConfigStream.Position = 0;
112 } 113 }
113 114
114 /// <summary> 115 /// <summary>