diff options
author | Melanie | 2012-06-26 17:35:55 +0100 |
---|---|---|
committer | Melanie | 2012-06-26 17:35:55 +0100 |
commit | 7cc5b3d7d3350cbf47dab40f0c14627ef77ea4c9 (patch) | |
tree | 5492a786c85a7edd63fb8ad0c3c6f1da8d700741 /OpenSim/Region | |
parent | Merge branch 'master' into careminster (diff) | |
parent | When attachments are being saved and deleted for a closing root agent, delete... (diff) | |
download | opensim-SC-7cc5b3d7d3350cbf47dab40f0c14627ef77ea4c9.zip opensim-SC-7cc5b3d7d3350cbf47dab40f0c14627ef77ea4c9.tar.gz opensim-SC-7cc5b3d7d3350cbf47dab40f0c14627ef77ea4c9.tar.bz2 opensim-SC-7cc5b3d7d3350cbf47dab40f0c14627ef77ea4c9.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
Diffstat (limited to '')
13 files changed, 232 insertions, 136 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index c05ef3c..54cff55 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -198,31 +198,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | public void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted) | 201 | public void DeRezAttachments(IScenePresence sp, bool saveChanged, bool saveAllScripted) |
202 | { | 202 | { |
203 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name); | ||
204 | |||
205 | if (!Enabled) | 203 | if (!Enabled) |
206 | return; | 204 | return; |
207 | 205 | ||
208 | foreach (SceneObjectGroup grp in sp.GetAttachments()) | 206 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name); |
207 | |||
208 | lock (sp.AttachmentsSyncLock) | ||
209 | { | 209 | { |
210 | grp.IsAttachment = false; | 210 | foreach (SceneObjectGroup grp in sp.GetAttachments()) |
211 | grp.AbsolutePosition = grp.RootPart.AttachedPos; | 211 | { |
212 | UpdateKnownItem(sp, grp, saveAllScripted); | 212 | grp.Scene.DeleteSceneObject(grp, false); |
213 | grp.IsAttachment = true; | 213 | |
214 | if (saveChanged || saveAllScripted) | ||
215 | { | ||
216 | grp.IsAttachment = false; | ||
217 | grp.AbsolutePosition = grp.RootPart.AttachedPos; | ||
218 | UpdateKnownItem(sp, grp, saveAllScripted); | ||
219 | } | ||
220 | } | ||
221 | |||
222 | sp.ClearAttachments(); | ||
214 | } | 223 | } |
215 | } | 224 | } |
216 | 225 | ||
217 | public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent) | 226 | public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent) |
218 | { | 227 | { |
219 | // m_log.DebugFormat( | ||
220 | // "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}", | ||
221 | // m_scene.RegionInfo.RegionName, sp.Name, silent); | ||
222 | |||
223 | if (!Enabled) | 228 | if (!Enabled) |
224 | return; | 229 | return; |
225 | 230 | ||
231 | // m_log.DebugFormat( | ||
232 | // "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}", | ||
233 | // m_scene.RegionInfo.RegionName, sp.Name, silent); | ||
234 | |||
226 | foreach (SceneObjectGroup sop in sp.GetAttachments()) | 235 | foreach (SceneObjectGroup sop in sp.GetAttachments()) |
227 | { | 236 | { |
228 | sop.Scene.DeleteSceneObject(sop, silent); | 237 | sop.Scene.DeleteSceneObject(sop, silent); |
@@ -477,17 +486,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
477 | if (!Enabled) | 486 | if (!Enabled) |
478 | return; | 487 | return; |
479 | 488 | ||
480 | // First we save the | ||
481 | // attachment point information, then we update the relative | ||
482 | // positioning. Then we have to mark the object as NOT an | ||
483 | // attachment. This is necessary in order to correctly save | ||
484 | // and retrieve GroupPosition information for the attachment. | ||
485 | // Finally, we restore the object's attachment status. | ||
486 | uint attachmentPoint = sog.AttachmentPoint; | ||
487 | sog.UpdateGroupPosition(pos); | 489 | sog.UpdateGroupPosition(pos); |
488 | sog.IsAttachment = false; | ||
489 | sog.AbsolutePosition = sog.RootPart.AttachedPos; | ||
490 | sog.AttachmentPoint = attachmentPoint; | ||
491 | sog.HasGroupChanged = true; | 490 | sog.HasGroupChanged = true; |
492 | } | 491 | } |
493 | 492 | ||
@@ -770,6 +769,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
770 | { | 769 | { |
771 | m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); | 770 | m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); |
772 | sp.RemoveAttachment(group); | 771 | sp.RemoveAttachment(group); |
772 | m_scene.DeleteSceneObject(group, false); | ||
773 | 773 | ||
774 | // Prepare sog for storage | 774 | // Prepare sog for storage |
775 | group.AttachedAvatar = UUID.Zero; | 775 | group.AttachedAvatar = UUID.Zero; |
@@ -778,7 +778,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
778 | group.AbsolutePosition = group.RootPart.AttachedPos; | 778 | group.AbsolutePosition = group.RootPart.AttachedPos; |
779 | 779 | ||
780 | UpdateKnownItem(sp, group, true); | 780 | UpdateKnownItem(sp, group, true); |
781 | m_scene.DeleteSceneObject(group, false); | ||
782 | 781 | ||
783 | return; | 782 | return; |
784 | } | 783 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index acf0089..8969006 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -58,6 +58,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
58 | private AttachmentsModule m_attMod; | 58 | private AttachmentsModule m_attMod; |
59 | private ScenePresence m_presence; | 59 | private ScenePresence m_presence; |
60 | 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 | |||
61 | [TestFixtureSetUp] | 76 | [TestFixtureSetUp] |
62 | public void FixtureInit() | 77 | public void FixtureInit() |
63 | { | 78 | { |
@@ -86,13 +101,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
86 | } | 101 | } |
87 | 102 | ||
88 | /// <summary> | 103 | /// <summary> |
89 | /// Add the standard presence for a test. | 104 | /// Creates an attachment item in the given user's inventory. Does not attach. |
90 | /// </summary> | 105 | /// </summary> |
91 | private void AddPresence() | 106 | /// <remarks> |
107 | /// A user with the given ID and an inventory must already exist. | ||
108 | /// </remarks> | ||
109 | /// <returns> | ||
110 | /// The attachment item. | ||
111 | /// </returns> | ||
112 | /// <param name='userId'></param> | ||
113 | /// <param name='attName'></param> | ||
114 | /// <param name='rawItemId'></param> | ||
115 | /// <param name='rawAssetId'></param> | ||
116 | private InventoryItemBase CreateAttachmentItem(UUID userId, string attName, int rawItemId, int rawAssetId) | ||
92 | { | 117 | { |
93 | UUID userId = TestHelpers.ParseTail(0x1); | 118 | return UserInventoryHelpers.CreateInventoryItem( |
94 | UserAccountHelpers.CreateUserWithInventory(scene, userId); | 119 | scene, |
95 | m_presence = SceneHelpers.AddScenePresence(scene, userId); | 120 | attName, |
121 | TestHelpers.ParseTail(rawItemId), | ||
122 | TestHelpers.ParseTail(rawAssetId), | ||
123 | userId, | ||
124 | InventoryType.Object); | ||
96 | } | 125 | } |
97 | 126 | ||
98 | [Test] | 127 | [Test] |
@@ -101,7 +130,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
101 | TestHelpers.InMethod(); | 130 | TestHelpers.InMethod(); |
102 | // TestHelpers.EnableLogging(); | 131 | // TestHelpers.EnableLogging(); |
103 | 132 | ||
104 | AddPresence(); | 133 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); |
134 | m_presence = SceneHelpers.AddScenePresence(scene, m_userId); | ||
135 | |||
105 | string attName = "att"; | 136 | string attName = "att"; |
106 | 137 | ||
107 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, m_presence.UUID).ParentGroup; | 138 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, m_presence.UUID).ParentGroup; |
@@ -140,24 +171,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
140 | TestHelpers.InMethod(); | 171 | TestHelpers.InMethod(); |
141 | // log4net.Config.XmlConfigurator.Configure(); | 172 | // log4net.Config.XmlConfigurator.Configure(); |
142 | 173 | ||
143 | AddPresence(); | 174 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); |
144 | 175 | m_presence = SceneHelpers.AddScenePresence(scene, m_userId); | |
145 | UUID attItemId = TestHelpers.ParseTail(0x2); | ||
146 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
147 | string attName = "att"; | ||
148 | 176 | ||
149 | UserInventoryHelpers.CreateInventoryItem( | 177 | InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); |
150 | scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); | ||
151 | 178 | ||
152 | m_attMod.RezSingleAttachmentFromInventory( | 179 | m_attMod.RezSingleAttachmentFromInventory( |
153 | m_presence, attItemId, (uint)AttachmentPoint.Chest); | 180 | m_presence, attItem.ID, (uint)AttachmentPoint.Chest); |
154 | 181 | ||
155 | // Check scene presence status | 182 | // Check scene presence status |
156 | Assert.That(m_presence.HasAttachments(), Is.True); | 183 | Assert.That(m_presence.HasAttachments(), Is.True); |
157 | List<SceneObjectGroup> attachments = m_presence.GetAttachments(); | 184 | List<SceneObjectGroup> attachments = m_presence.GetAttachments(); |
158 | Assert.That(attachments.Count, Is.EqualTo(1)); | 185 | Assert.That(attachments.Count, Is.EqualTo(1)); |
159 | SceneObjectGroup attSo = attachments[0]; | 186 | SceneObjectGroup attSo = attachments[0]; |
160 | Assert.That(attSo.Name, Is.EqualTo(attName)); | 187 | Assert.That(attSo.Name, Is.EqualTo(attItem.Name)); |
161 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); | 188 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); |
162 | Assert.That(attSo.IsAttachment); | 189 | Assert.That(attSo.IsAttachment); |
163 | Assert.That(attSo.UsesPhysics, Is.False); | 190 | Assert.That(attSo.UsesPhysics, Is.False); |
@@ -165,7 +192,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
165 | 192 | ||
166 | // Check appearance status | 193 | // Check appearance status |
167 | Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(1)); | 194 | Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(1)); |
168 | Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); | 195 | Assert.That(m_presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); |
169 | } | 196 | } |
170 | 197 | ||
171 | [Test] | 198 | [Test] |
@@ -174,17 +201,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
174 | TestHelpers.InMethod(); | 201 | TestHelpers.InMethod(); |
175 | // log4net.Config.XmlConfigurator.Configure(); | 202 | // log4net.Config.XmlConfigurator.Configure(); |
176 | 203 | ||
177 | AddPresence(); | 204 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); |
178 | 205 | m_presence = SceneHelpers.AddScenePresence(scene, m_userId); | |
179 | UUID attItemId = TestHelpers.ParseTail(0x2); | ||
180 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
181 | string attName = "att"; | ||
182 | 206 | ||
183 | UserInventoryHelpers.CreateInventoryItem( | 207 | InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); |
184 | scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); | ||
185 | 208 | ||
186 | ISceneEntity so = m_attMod.RezSingleAttachmentFromInventory( | 209 | ISceneEntity so |
187 | m_presence, attItemId, (uint)AttachmentPoint.Chest); | 210 | = m_attMod.RezSingleAttachmentFromInventory( |
211 | m_presence, attItem.ID, (uint)AttachmentPoint.Chest); | ||
188 | m_attMod.DetachSingleAttachmentToGround(m_presence, so.LocalId); | 212 | m_attMod.DetachSingleAttachmentToGround(m_presence, so.LocalId); |
189 | 213 | ||
190 | // Check scene presence status | 214 | // Check scene presence status |
@@ -196,7 +220,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
196 | Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(0)); | 220 | Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(0)); |
197 | 221 | ||
198 | // Check item status | 222 | // Check item status |
199 | Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Null); | 223 | Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItem.ID)), Is.Null); |
200 | 224 | ||
201 | // Check object in scene | 225 | // Check object in scene |
202 | Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null); | 226 | Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null); |
@@ -208,18 +232,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
208 | TestHelpers.InMethod(); | 232 | TestHelpers.InMethod(); |
209 | // log4net.Config.XmlConfigurator.Configure(); | 233 | // log4net.Config.XmlConfigurator.Configure(); |
210 | 234 | ||
211 | AddPresence(); | 235 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); |
212 | 236 | m_presence = SceneHelpers.AddScenePresence(scene, m_userId); | |
213 | UUID attItemId = TestHelpers.ParseTail(0x2); | ||
214 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
215 | string attName = "att"; | ||
216 | 237 | ||
217 | UserInventoryHelpers.CreateInventoryItem( | 238 | InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); |
218 | scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); | ||
219 | 239 | ||
220 | m_attMod.RezSingleAttachmentFromInventory( | 240 | m_attMod.RezSingleAttachmentFromInventory( |
221 | m_presence, attItemId, (uint)AttachmentPoint.Chest); | 241 | m_presence, attItem.ID, (uint)AttachmentPoint.Chest); |
222 | m_attMod.DetachSingleAttachmentToInv(m_presence, attItemId); | 242 | m_attMod.DetachSingleAttachmentToInv(m_presence, attItem.ID); |
223 | 243 | ||
224 | // Check status on scene presence | 244 | // Check status on scene presence |
225 | Assert.That(m_presence.HasAttachments(), Is.False); | 245 | Assert.That(m_presence.HasAttachments(), Is.False); |
@@ -227,7 +247,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
227 | Assert.That(attachments.Count, Is.EqualTo(0)); | 247 | Assert.That(attachments.Count, Is.EqualTo(0)); |
228 | 248 | ||
229 | // Check item status | 249 | // Check item status |
230 | Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0)); | 250 | Assert.That(m_presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0)); |
231 | } | 251 | } |
232 | 252 | ||
233 | /// <summary> | 253 | /// <summary> |
@@ -239,17 +259,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
239 | TestHelpers.InMethod(); | 259 | TestHelpers.InMethod(); |
240 | // log4net.Config.XmlConfigurator.Configure(); | 260 | // log4net.Config.XmlConfigurator.Configure(); |
241 | 261 | ||
242 | UUID userId = TestHelpers.ParseTail(0x1); | 262 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); |
243 | UUID attItemId = TestHelpers.ParseTail(0x2); | 263 | InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); |
244 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
245 | string attName = "att"; | ||
246 | |||
247 | UserAccountHelpers.CreateUserWithInventory(scene, userId); | ||
248 | InventoryItemBase attItem | ||
249 | = UserInventoryHelpers.CreateInventoryItem( | ||
250 | scene, attName, attItemId, attAssetId, userId, InventoryType.Object); | ||
251 | 264 | ||
252 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); | 265 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); |
253 | acd.Appearance = new AvatarAppearance(); | 266 | acd.Appearance = new AvatarAppearance(); |
254 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); | 267 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); |
255 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); | 268 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); |
@@ -268,17 +281,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
268 | TestHelpers.InMethod(); | 281 | TestHelpers.InMethod(); |
269 | // log4net.Config.XmlConfigurator.Configure(); | 282 | // log4net.Config.XmlConfigurator.Configure(); |
270 | 283 | ||
271 | UUID userId = TestHelpers.ParseTail(0x1); | 284 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); |
272 | UUID attItemId = TestHelpers.ParseTail(0x2); | 285 | InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); |
273 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
274 | string attName = "att"; | ||
275 | 286 | ||
276 | UserAccountHelpers.CreateUserWithInventory(scene, userId); | 287 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); |
277 | InventoryItemBase attItem | ||
278 | = UserInventoryHelpers.CreateInventoryItem( | ||
279 | scene, attName, attItemId, attAssetId, userId, InventoryType.Object); | ||
280 | |||
281 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); | ||
282 | acd.Appearance = new AvatarAppearance(); | 288 | acd.Appearance = new AvatarAppearance(); |
283 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); | 289 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); |
284 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); | 290 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); |
@@ -288,7 +294,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
288 | 294 | ||
289 | Assert.That(attachments.Count, Is.EqualTo(1)); | 295 | Assert.That(attachments.Count, Is.EqualTo(1)); |
290 | SceneObjectGroup attSo = attachments[0]; | 296 | SceneObjectGroup attSo = attachments[0]; |
291 | Assert.That(attSo.Name, Is.EqualTo(attName)); | 297 | Assert.That(attSo.Name, Is.EqualTo(attItem.Name)); |
292 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); | 298 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); |
293 | Assert.That(attSo.IsAttachment); | 299 | Assert.That(attSo.IsAttachment); |
294 | Assert.That(attSo.UsesPhysics, Is.False); | 300 | Assert.That(attSo.UsesPhysics, Is.False); |
@@ -298,9 +304,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
298 | List<AvatarAttachment> retreivedAttachments = presence.Appearance.GetAttachments(); | 304 | List<AvatarAttachment> retreivedAttachments = presence.Appearance.GetAttachments(); |
299 | Assert.That(retreivedAttachments.Count, Is.EqualTo(1)); | 305 | Assert.That(retreivedAttachments.Count, Is.EqualTo(1)); |
300 | Assert.That(retreivedAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest)); | 306 | Assert.That(retreivedAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest)); |
301 | Assert.That(retreivedAttachments[0].ItemID, Is.EqualTo(attItemId)); | 307 | Assert.That(retreivedAttachments[0].ItemID, Is.EqualTo(attItem.ID)); |
302 | Assert.That(retreivedAttachments[0].AssetID, Is.EqualTo(attAssetId)); | 308 | Assert.That(retreivedAttachments[0].AssetID, Is.EqualTo(attItem.AssetID)); |
303 | Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); | 309 | Assert.That(presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); |
310 | } | ||
311 | |||
312 | [Test] | ||
313 | public void TestUpdateAttachmentPosition() | ||
314 | { | ||
315 | TestHelpers.InMethod(); | ||
316 | |||
317 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); | ||
318 | InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); | ||
319 | |||
320 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); | ||
321 | acd.Appearance = new AvatarAppearance(); | ||
322 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); | ||
323 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, acd); | ||
324 | |||
325 | SceneObjectGroup attSo = sp.GetAttachments()[0]; | ||
326 | |||
327 | Vector3 newPosition = new Vector3(1, 2, 4); | ||
328 | |||
329 | scene.SceneGraph.UpdatePrimGroupPosition(attSo.LocalId, newPosition, sp.ControllingClient); | ||
330 | |||
331 | Assert.That(attSo.AbsolutePosition, Is.EqualTo(sp.AbsolutePosition)); | ||
332 | Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition)); | ||
304 | } | 333 | } |
305 | 334 | ||
306 | // I'm commenting this test because scene setup NEEDS InventoryService to | 335 | // I'm commenting this test because scene setup NEEDS InventoryService to |
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index 0516cb1..70ea7cf 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | |||
@@ -44,10 +44,15 @@ namespace OpenSim.Region.Framework.Interfaces | |||
44 | void RezAttachments(IScenePresence sp); | 44 | void RezAttachments(IScenePresence sp); |
45 | 45 | ||
46 | /// <summary> | 46 | /// <summary> |
47 | /// Save the attachments that have change on this presence. | 47 | /// Derez the attachements for a scene presence that is closing. |
48 | /// </summary> | 48 | /// </summary> |
49 | /// <param name="sp"></param> | 49 | /// <remarks> |
50 | void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted); | 50 | /// Attachment changes are saved. |
51 | /// </remarks> | ||
52 | /// <param name="sp">The presence closing</param> | ||
53 | /// <param name="saveChanged">Save changed attachments.</param> | ||
54 | /// <param name="saveAllScripted">Save attachments with scripts even if they haven't changed.</para> | ||
55 | void DeRezAttachments(IScenePresence sp, bool saveChanged, bool saveAllScripted); | ||
51 | 56 | ||
52 | /// <summary> | 57 | /// <summary> |
53 | /// Delete all the presence's attachments from the scene | 58 | /// Delete all the presence's attachments from the scene |
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 143af48..42dbedc 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs | |||
@@ -77,6 +77,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
77 | /// <param name="itemID">The item ID of the script.</param> | 77 | /// <param name="itemID">The item ID of the script.</param> |
78 | bool GetScriptState(UUID itemID); | 78 | bool GetScriptState(UUID itemID); |
79 | 79 | ||
80 | void SetRunEnable(UUID instanceID, bool enable); | ||
81 | |||
80 | void SaveAllState(); | 82 | void SaveAllState(); |
81 | 83 | ||
82 | /// <summary> | 84 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 98b8fcc..9776a82 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -2298,10 +2298,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2298 | if (part == null) | 2298 | if (part == null) |
2299 | return; | 2299 | return; |
2300 | 2300 | ||
2301 | IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>(); | ||
2302 | |||
2301 | if (running) | 2303 | if (running) |
2304 | { | ||
2305 | foreach (IScriptModule engine in engines) | ||
2306 | { | ||
2307 | engine.SetRunEnable(itemID, true); | ||
2308 | } | ||
2302 | EventManager.TriggerStartScript(part.LocalId, itemID); | 2309 | EventManager.TriggerStartScript(part.LocalId, itemID); |
2310 | } | ||
2303 | else | 2311 | else |
2312 | { | ||
2313 | foreach (IScriptModule engine in engines) | ||
2314 | { | ||
2315 | engine.SetRunEnable(itemID, false); | ||
2316 | } | ||
2304 | EventManager.TriggerStopScript(part.LocalId, itemID); | 2317 | EventManager.TriggerStopScript(part.LocalId, itemID); |
2318 | } | ||
2305 | } | 2319 | } |
2306 | 2320 | ||
2307 | public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) | 2321 | public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 757ac9f..8591b09 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -522,6 +522,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
522 | public IAttachmentsModule AttachmentsModule { get; set; } | 522 | public IAttachmentsModule AttachmentsModule { get; set; } |
523 | public IEntityTransferModule EntityTransferModule { get; private set; } | 523 | public IEntityTransferModule EntityTransferModule { get; private set; } |
524 | public IAgentAssetTransactions AgentTransactionsModule { get; private set; } | 524 | public IAgentAssetTransactions AgentTransactionsModule { get; private set; } |
525 | public IUserManagement UserManagementModule { get; private set; } | ||
525 | 526 | ||
526 | public IAvatarFactoryModule AvatarFactory | 527 | public IAvatarFactoryModule AvatarFactory |
527 | { | 528 | { |
@@ -1291,6 +1292,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1291 | EntityTransferModule = RequestModuleInterface<IEntityTransferModule>(); | 1292 | EntityTransferModule = RequestModuleInterface<IEntityTransferModule>(); |
1292 | m_groupsModule = RequestModuleInterface<IGroupsModule>(); | 1293 | m_groupsModule = RequestModuleInterface<IGroupsModule>(); |
1293 | AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>(); | 1294 | AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>(); |
1295 | UserManagementModule = RequestModuleInterface<IUserManagement>(); | ||
1294 | } | 1296 | } |
1295 | 1297 | ||
1296 | #endregion | 1298 | #endregion |
@@ -2094,9 +2096,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2094 | sceneObject.SetGroup(groupID, null); | 2096 | sceneObject.SetGroup(groupID, null); |
2095 | } | 2097 | } |
2096 | 2098 | ||
2097 | IUserManagement uman = RequestModuleInterface<IUserManagement>(); | 2099 | if (UserManagementModule != null) |
2098 | if (uman != null) | 2100 | sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID); |
2099 | sceneObject.RootPart.CreatorIdentification = uman.GetUserUUI(ownerID); | ||
2100 | 2101 | ||
2101 | sceneObject.ScheduleGroupForFullUpdate(); | 2102 | sceneObject.ScheduleGroupForFullUpdate(); |
2102 | 2103 | ||
@@ -2855,14 +2856,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2855 | /// <param name="aCircuit"></param> | 2856 | /// <param name="aCircuit"></param> |
2856 | private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit) | 2857 | private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit) |
2857 | { | 2858 | { |
2858 | IUserManagement uMan = RequestModuleInterface<IUserManagement>(); | 2859 | if (UserManagementModule != null) |
2859 | if (uMan != null) | ||
2860 | { | 2860 | { |
2861 | string first = aCircuit.firstname, last = aCircuit.lastname; | 2861 | string first = aCircuit.firstname, last = aCircuit.lastname; |
2862 | 2862 | ||
2863 | if (sp.PresenceType == PresenceType.Npc) | 2863 | if (sp.PresenceType == PresenceType.Npc) |
2864 | { | 2864 | { |
2865 | uMan.AddUser(aCircuit.AgentID, first, last); | 2865 | UserManagementModule.AddUser(aCircuit.AgentID, first, last); |
2866 | } | 2866 | } |
2867 | else | 2867 | else |
2868 | { | 2868 | { |
@@ -2881,7 +2881,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2881 | } | 2881 | } |
2882 | } | 2882 | } |
2883 | 2883 | ||
2884 | uMan.AddUser(aCircuit.AgentID, first, last, homeURL); | 2884 | UserManagementModule.AddUser(aCircuit.AgentID, first, last, homeURL); |
2885 | } | 2885 | } |
2886 | } | 2886 | } |
2887 | } | 2887 | } |
@@ -3445,17 +3445,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
3445 | 3445 | ||
3446 | if (!isChildAgent) | 3446 | if (!isChildAgent) |
3447 | { | 3447 | { |
3448 | if (AttachmentsModule != null && avatar.PresenceType != PresenceType.Npc) | 3448 | if (AttachmentsModule != null) |
3449 | { | 3449 | { |
3450 | IUserManagement uMan = RequestModuleInterface<IUserManagement>(); | ||
3451 | // Don't save attachments for HG visitors, it | 3450 | // Don't save attachments for HG visitors, it |
3452 | // messes up their inventory. When a HG visitor logs | 3451 | // messes up their inventory. When a HG visitor logs |
3453 | // out on a foreign grid, their attachments will be | 3452 | // out on a foreign grid, their attachments will be |
3454 | // reloaded in the state they were in when they left | 3453 | // reloaded in the state they were in when they left |
3455 | // the home grid. This is best anyway as the visited | 3454 | // the home grid. This is best anyway as the visited |
3456 | // grid may use an incompatible script engine. | 3455 | // grid may use an incompatible script engine. |
3457 | if (uMan == null || uMan.IsLocalGridUser(avatar.UUID)) | 3456 | bool saveChanged |
3458 | AttachmentsModule.SaveChangedAttachments(avatar, false); | 3457 | = avatar.PresenceType != PresenceType.Npc |
3458 | && (UserManagementModule == null || UserManagementModule.IsLocalGridUser(avatar.UUID)); | ||
3459 | |||
3460 | AttachmentsModule.DeRezAttachments(avatar, saveChanged, false); | ||
3459 | } | 3461 | } |
3460 | 3462 | ||
3461 | ForEachClient( | 3463 | ForEachClient( |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 88afee7..11d703a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -3640,6 +3640,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3640 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); | 3640 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); |
3641 | } | 3641 | } |
3642 | 3642 | ||
3643 | if (IsAttachment) | ||
3644 | { | ||
3645 | m_rootPart.AttachedPos = pos; | ||
3646 | } | ||
3647 | |||
3643 | AbsolutePosition = pos; | 3648 | AbsolutePosition = pos; |
3644 | 3649 | ||
3645 | HasGroupChanged = true; | 3650 | HasGroupChanged = true; |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1fc9790..f3e8377 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3606,9 +3606,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3606 | 3606 | ||
3607 | public void Close() | 3607 | public void Close() |
3608 | { | 3608 | { |
3609 | if (!IsChildAgent && m_scene.AttachmentsModule != null) | ||
3610 | m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false); | ||
3611 | |||
3612 | // Clear known regions | 3609 | // Clear known regions |
3613 | KnownRegions = new Dictionary<ulong, string>(); | 3610 | KnownRegions = new Dictionary<ulong, string>(); |
3614 | 3611 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 453e077..81add43 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs | |||
@@ -187,8 +187,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
187 | 187 | ||
188 | TestScene scene = new SceneHelpers().SetupScene(); | 188 | TestScene scene = new SceneHelpers().SetupScene(); |
189 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); | 189 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); |
190 | |||
191 | Assert.That(part.ParentGroup.IsDeleted, Is.False); | ||
192 | |||
190 | scene.DeleteSceneObject(part.ParentGroup, false); | 193 | scene.DeleteSceneObject(part.ParentGroup, false); |
191 | 194 | ||
195 | Assert.That(part.ParentGroup.IsDeleted, Is.True); | ||
196 | |||
192 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | 197 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); |
193 | Assert.That(retrievedPart, Is.Null); | 198 | Assert.That(retrievedPart, Is.Null); |
194 | } | 199 | } |
@@ -219,8 +224,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
219 | 224 | ||
220 | Assert.That(retrievedPart, Is.Not.Null); | 225 | Assert.That(retrievedPart, Is.Not.Null); |
221 | 226 | ||
227 | Assert.That(part.ParentGroup.IsDeleted, Is.False); | ||
228 | |||
222 | sogd.InventoryDeQueueAndDelete(); | 229 | sogd.InventoryDeQueueAndDelete(); |
223 | 230 | ||
231 | Assert.That(part.ParentGroup.IsDeleted, Is.True); | ||
232 | |||
224 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); | 233 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); |
225 | Assert.That(retrievedPart2, Is.Null); | 234 | Assert.That(retrievedPart2, Is.Null); |
226 | } | 235 | } |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index b04f6b6..ec13b6c 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | |||
@@ -64,6 +64,16 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
64 | bool Running { get; set; } | 64 | bool Running { get; set; } |
65 | 65 | ||
66 | /// <summary> | 66 | /// <summary> |
67 | /// Gets or sets a value indicating whether this | ||
68 | /// <see cref="OpenSim.Region.ScriptEngine.Interfaces.IScriptInstance"/> is run. | ||
69 | /// For viewer script editor control | ||
70 | /// </summary> | ||
71 | /// <value> | ||
72 | /// <c>true</c> if run; otherwise, <c>false</c>. | ||
73 | /// </value> | ||
74 | bool Run { get; set; } | ||
75 | |||
76 | /// <summary> | ||
67 | /// Is the script suspended? | 77 | /// Is the script suspended? |
68 | /// </summary> | 78 | /// </summary> |
69 | bool Suspended { get; set; } | 79 | bool Suspended { get; set; } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 1c59d45..3797683 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -121,6 +121,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
121 | 121 | ||
122 | public bool Running { get; set; } | 122 | public bool Running { get; set; } |
123 | 123 | ||
124 | public bool Run { get; set; } | ||
125 | |||
124 | public bool Suspended | 126 | public bool Suspended |
125 | { | 127 | { |
126 | get { return m_Suspended; } | 128 | get { return m_Suspended; } |
@@ -216,6 +218,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
216 | m_postOnRez = postOnRez; | 218 | m_postOnRez = postOnRez; |
217 | m_AttachedAvatar = part.ParentGroup.AttachedAvatar; | 219 | m_AttachedAvatar = part.ParentGroup.AttachedAvatar; |
218 | m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; | 220 | m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; |
221 | Run = true; | ||
219 | 222 | ||
220 | if (part != null) | 223 | if (part != null) |
221 | { | 224 | { |
@@ -330,16 +333,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
330 | } | 333 | } |
331 | else | 334 | else |
332 | { | 335 | { |
333 | m_log.ErrorFormat( | 336 | m_log.WarnFormat( |
334 | "[SCRIPT INSTANCE]: Unable to load script state from assembly {0}: Memory limit exceeded", | 337 | "[SCRIPT INSTANCE]: Unable to load script state file {0} for script {1} {2} in {3} {4} (assembly {5}). Memory limit exceeded", |
335 | assembly); | 338 | savedState, ScriptName, ItemID, PrimName, ObjectID, assembly); |
336 | } | 339 | } |
337 | } | 340 | } |
338 | catch (Exception e) | 341 | catch (Exception e) |
339 | { | 342 | { |
340 | m_log.ErrorFormat( | 343 | m_log.ErrorFormat( |
341 | "[SCRIPT INSTANCE]: Unable to load script state from assembly {0}. XML is {1}. Exception {2}{3}", | 344 | "[SCRIPT INSTANCE]: Unable to load script state file {0} for script {1} {2} in {3} {4} (assembly {5}). XML is {6}. Exception {7}{8}", |
342 | assembly, xml, e.Message, e.StackTrace); | 345 | savedState, ScriptName, ItemID, PrimName, ObjectID, assembly, xml, e.Message, e.StackTrace); |
343 | } | 346 | } |
344 | } | 347 | } |
345 | // else | 348 | // else |
@@ -354,10 +357,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
354 | 357 | ||
355 | public void Init() | 358 | public void Init() |
356 | { | 359 | { |
357 | if (!m_startOnInit) return; | 360 | if (!m_startOnInit) |
361 | return; | ||
358 | 362 | ||
359 | if (m_startedFromSavedState) | 363 | if (m_startedFromSavedState) |
360 | { | 364 | { |
365 | if (!Run) | ||
366 | return; | ||
367 | |||
361 | Start(); | 368 | Start(); |
362 | if (m_postOnRez) | 369 | if (m_postOnRez) |
363 | { | 370 | { |
@@ -390,6 +397,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
390 | } | 397 | } |
391 | else | 398 | else |
392 | { | 399 | { |
400 | if (!Run) | ||
401 | return; | ||
402 | |||
393 | Start(); | 403 | Start(); |
394 | PostEvent(new EventParams("state_entry", | 404 | PostEvent(new EventParams("state_entry", |
395 | new Object[0], new DetectParams[0])); | 405 | new Object[0], new DetectParams[0])); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs index bcdc7bf..797bce3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs | |||
@@ -55,6 +55,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
55 | public static string Serialize(ScriptInstance instance) | 55 | public static string Serialize(ScriptInstance instance) |
56 | { | 56 | { |
57 | bool running = instance.Running; | 57 | bool running = instance.Running; |
58 | bool enabled = instance.Run; | ||
58 | 59 | ||
59 | XmlDocument xmldoc = new XmlDocument(); | 60 | XmlDocument xmldoc = new XmlDocument(); |
60 | 61 | ||
@@ -77,6 +78,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
77 | 78 | ||
78 | rootElement.AppendChild(run); | 79 | rootElement.AppendChild(run); |
79 | 80 | ||
81 | XmlElement run_enable = xmldoc.CreateElement("", "Run", ""); | ||
82 | run_enable.AppendChild(xmldoc.CreateTextNode( | ||
83 | enabled.ToString())); | ||
84 | |||
85 | rootElement.AppendChild(run_enable); | ||
86 | |||
80 | Dictionary<string, Object> vars = instance.GetVars(); | 87 | Dictionary<string, Object> vars = instance.GetVars(); |
81 | 88 | ||
82 | XmlElement variables = xmldoc.CreateElement("", "Variables", ""); | 89 | XmlElement variables = xmldoc.CreateElement("", "Variables", ""); |
@@ -225,6 +232,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
225 | { | 232 | { |
226 | object varValue; | 233 | object varValue; |
227 | XmlNodeList partL = rootNode.ChildNodes; | 234 | XmlNodeList partL = rootNode.ChildNodes; |
235 | instance.Run = true; | ||
228 | 236 | ||
229 | foreach (XmlNode part in partL) | 237 | foreach (XmlNode part in partL) |
230 | { | 238 | { |
@@ -236,6 +244,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
236 | case "Running": | 244 | case "Running": |
237 | instance.Running=bool.Parse(part.InnerText); | 245 | instance.Running=bool.Parse(part.InnerText); |
238 | break; | 246 | break; |
247 | case "Run": | ||
248 | instance.Run = bool.Parse(part.InnerText); | ||
249 | break; | ||
239 | case "Variables": | 250 | case "Variables": |
240 | XmlNodeList varL = part.ChildNodes; | 251 | XmlNodeList varL = part.ChildNodes; |
241 | foreach (XmlNode var in varL) | 252 | foreach (XmlNode var in varL) |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 01021c9..b1583b2 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -920,15 +920,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
920 | { | 920 | { |
921 | if (m_InitialStartup) | 921 | if (m_InitialStartup) |
922 | { | 922 | { |
923 | m_InitialStartup = false; | 923 | // This delay exists to stop mono problems where script compilation and startup would stop the sim |
924 | // working properly for the session. | ||
924 | System.Threading.Thread.Sleep(15000); | 925 | System.Threading.Thread.Sleep(15000); |
925 | |||
926 | if (m_CompileQueue.Count == 0) | ||
927 | { | ||
928 | // No scripts on region, so won't get triggered later | ||
929 | // by the queue becoming empty so we trigger it here | ||
930 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty); | ||
931 | } | ||
932 | } | 926 | } |
933 | 927 | ||
934 | object[] o; | 928 | object[] o; |
@@ -941,14 +935,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
941 | { | 935 | { |
942 | scriptsStarted++; | 936 | scriptsStarted++; |
943 | 937 | ||
944 | // if (scriptsStarted % 50 == 0) | 938 | if (m_InitialStartup) |
945 | // m_log.DebugFormat( | 939 | if (scriptsStarted % 50 == 0) |
946 | // "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); | 940 | m_log.InfoFormat( |
941 | "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); | ||
947 | } | 942 | } |
948 | } | 943 | } |
949 | 944 | ||
950 | // m_log.DebugFormat( | 945 | if (m_InitialStartup) |
951 | // "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); | 946 | m_log.InfoFormat( |
947 | "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); | ||
952 | 948 | ||
953 | // NOTE: Despite having a lockless queue, this lock is required | 949 | // NOTE: Despite having a lockless queue, this lock is required |
954 | // to make sure there is never no compile thread while there | 950 | // to make sure there is never no compile thread while there |
@@ -956,12 +952,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
956 | // due to a race condition | 952 | // due to a race condition |
957 | // | 953 | // |
958 | lock (m_CompileQueue) | 954 | lock (m_CompileQueue) |
959 | { | ||
960 | m_CurrentCompile = null; | 955 | m_CurrentCompile = null; |
961 | } | 956 | |
962 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, | 957 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, |
963 | m_ScriptErrorMessage); | 958 | m_ScriptErrorMessage); |
959 | |||
964 | m_ScriptFailCount = 0; | 960 | m_ScriptFailCount = 0; |
961 | m_InitialStartup = false; | ||
965 | 962 | ||
966 | return null; | 963 | return null; |
967 | } | 964 | } |
@@ -1451,25 +1448,24 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1451 | return false; | 1448 | return false; |
1452 | 1449 | ||
1453 | uuids = m_PrimObjects[localID]; | 1450 | uuids = m_PrimObjects[localID]; |
1454 | |||
1455 | |||
1456 | foreach (UUID itemID in uuids) | ||
1457 | { | ||
1458 | IScriptInstance instance = null; | ||
1459 | try | ||
1460 | { | ||
1461 | if (m_Scripts.ContainsKey(itemID)) | ||
1462 | instance = m_Scripts[itemID]; | ||
1463 | } | ||
1464 | catch { /* ignore race conditions */ } | ||
1465 | 1451 | ||
1466 | if (instance != null) | 1452 | foreach (UUID itemID in uuids) |
1467 | { | 1453 | { |
1468 | instance.PostEvent(p); | 1454 | IScriptInstance instance = null; |
1469 | result = true; | 1455 | try |
1456 | { | ||
1457 | if (m_Scripts.ContainsKey(itemID)) | ||
1458 | instance = m_Scripts[itemID]; | ||
1459 | } | ||
1460 | catch { /* ignore race conditions */ } | ||
1461 | |||
1462 | if (instance != null) | ||
1463 | { | ||
1464 | instance.PostEvent(p); | ||
1465 | result = true; | ||
1466 | } | ||
1470 | } | 1467 | } |
1471 | } | 1468 | } |
1472 | } | ||
1473 | 1469 | ||
1474 | return result; | 1470 | return result; |
1475 | } | 1471 | } |
@@ -1594,6 +1590,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1594 | } | 1590 | } |
1595 | } | 1591 | } |
1596 | 1592 | ||
1593 | public void SetRunEnable(UUID instanceID, bool enable) | ||
1594 | { | ||
1595 | IScriptInstance instance = GetInstance(instanceID); | ||
1596 | if (instance != null) | ||
1597 | instance.Run = enable; | ||
1598 | } | ||
1599 | |||
1597 | public bool GetScriptState(UUID itemID) | 1600 | public bool GetScriptState(UUID itemID) |
1598 | { | 1601 | { |
1599 | IScriptInstance instance = GetInstance(itemID); | 1602 | IScriptInstance instance = GetInstance(itemID); |