aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2009-11-26 19:02:41 +0000
committerJustin Clark-Casey (justincc)2009-11-26 19:02:41 +0000
commit377bc27c1fdab6f45135194a53ba17cce1f3388f (patch)
tree51e2bbc45c30dfceed0311452ad9b30532d7bd13 /OpenSim/Region/Framework
parentBump trunk version number to 0.6.9. (diff)
parentFix a small bug. Trusted script crossings now work again (diff)
downloadopensim-SC_OLD-377bc27c1fdab6f45135194a53ba17cce1f3388f.zip
opensim-SC_OLD-377bc27c1fdab6f45135194a53ba17cce1f3388f.tar.gz
opensim-SC_OLD-377bc27c1fdab6f45135194a53ba17cce1f3388f.tar.bz2
opensim-SC_OLD-377bc27c1fdab6f45135194a53ba17cce1f3388f.tar.xz
Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs8
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs101
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs72
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs190
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs55
9 files changed, 41 insertions, 409 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 2c906a2..89a45da 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -185,19 +185,11 @@ namespace OpenSim.Region.Framework.Interfaces
185 List<UUID> GetInventoryList(); 185 List<UUID> GetInventoryList();
186 186
187 /// <summary> 187 /// <summary>
188 /// Get the names of the assemblies associated with scripts in this inventory.
189 /// </summary>
190 /// <returns></returns>
191 string[] GetScriptAssemblies();
192
193 /// <summary>
194 /// Get the xml representing the saved states of scripts in this inventory. 188 /// Get the xml representing the saved states of scripts in this inventory.
195 /// </summary> 189 /// </summary>
196 /// <returns> 190 /// <returns>
197 /// A <see cref="Dictionary`2"/> 191 /// A <see cref="Dictionary`2"/>
198 /// </returns> 192 /// </returns>
199 Dictionary<UUID, string> GetScriptStates(); 193 Dictionary<UUID, string> GetScriptStates();
200
201 bool CanBeDeleted();
202 } 194 }
203} 195}
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index 10835b9..f11e571 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -34,9 +34,8 @@ namespace OpenSim.Region.Framework.Interfaces
34 { 34 {
35 string ScriptEngineName { get; } 35 string ScriptEngineName { get; }
36 36
37 string GetAssemblyName(UUID itemID);
38 string GetXMLState(UUID itemID); 37 string GetXMLState(UUID itemID);
39 bool CanBeDeleted(UUID itemID); 38 void SetXMLState(UUID itemID, string xml);
40 39
41 bool PostScriptEvent(UUID itemID, string name, Object[] args); 40 bool PostScriptEvent(UUID itemID, string name, Object[] args);
42 bool PostObjectEvent(UUID itemID, string name, Object[] args); 41 bool PostObjectEvent(UUID itemID, string name, Object[] args);
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
index 5b571c7..9a7863b 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -131,11 +131,6 @@ namespace OpenSim.Region.Framework.Scenes
131 if (left > 0) 131 if (left > 0)
132 { 132 {
133 x = m_inventoryDeletes.Dequeue(); 133 x = m_inventoryDeletes.Dequeue();
134 if (!x.objectGroup.CanBeDeleted())
135 {
136 m_inventoryDeletes.Enqueue(x);
137 return true;
138 }
139 134
140 m_log.DebugFormat( 135 m_log.DebugFormat(
141 "[SCENE]: Sending object to user's inventory, {0} item(s) remaining.", left); 136 "[SCENE]: Sending object to user's inventory, {0} item(s) remaining.", left);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index f444e51..eb8567f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -618,7 +618,7 @@ namespace OpenSim.Region.Framework.Scenes
618 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); 618 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
619 m_persistAfter *= 10000000; 619 m_persistAfter *= 10000000;
620 620
621 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "DotNetEngine"); 621 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
622 622
623 IConfig packetConfig = m_config.Configs["PacketPool"]; 623 IConfig packetConfig = m_config.Configs["PacketPool"];
624 if (packetConfig != null) 624 if (packetConfig != null)
@@ -2381,103 +2381,6 @@ namespace OpenSim.Region.Framework.Scenes
2381 return successYN; 2381 return successYN;
2382 } 2382 }
2383 2383
2384 /// <summary>
2385 /// Handle a scene object that is crossing into this region from another.
2386 /// NOTE: Unused as of 2009-02-09. Soon to be deleted.
2387 /// </summary>
2388 /// <param name="regionHandle"></param>
2389 /// <param name="primID"></param>
2390 /// <param name="objXMLData"></param>
2391 /// <param name="XMLMethod"></param>
2392 /// <returns></returns>
2393 public bool IncomingInterRegionPrimGroup(UUID primID, string objXMLData, int XMLMethod)
2394 {
2395 if (XMLMethod == 0)
2396 {
2397 m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID);
2398 SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData);
2399 if (sceneObject.IsAttachment)
2400 sceneObject.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
2401
2402 return AddSceneObject(sceneObject);
2403 }
2404 else if ((XMLMethod == 100) && m_allowScriptCrossings)
2405 {
2406 m_log.Warn("[INTERREGION]: Prim state data arrived from a neighbor");
2407
2408 XmlDocument doc = new XmlDocument();
2409 doc.LoadXml(objXMLData);
2410
2411 XmlNodeList rootL = doc.GetElementsByTagName("ScriptData");
2412 if (rootL.Count == 1)
2413 {
2414 XmlNode rootNode = rootL[0];
2415 if (rootNode != null)
2416 {
2417 XmlNodeList partL = rootNode.ChildNodes;
2418
2419 foreach (XmlNode part in partL)
2420 {
2421 XmlNodeList nodeL = part.ChildNodes;
2422
2423 switch (part.Name)
2424 {
2425 case "Assemblies":
2426 foreach (XmlNode asm in nodeL)
2427 {
2428 string fn = asm.Attributes.GetNamedItem("Filename").Value;
2429
2430 Byte[] filedata = Convert.FromBase64String(asm.InnerText);
2431 string path = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString());
2432 path = Path.Combine(path, fn);
2433
2434 if (!File.Exists(path))
2435 {
2436 FileStream fs = File.Create(path);
2437 fs.Write(filedata, 0, filedata.Length);
2438 fs.Close();
2439 }
2440 }
2441 break;
2442 case "ScriptStates":
2443 foreach (XmlNode st in nodeL)
2444 {
2445 string id = st.Attributes.GetNamedItem("UUID").Value;
2446 UUID uuid = new UUID(id);
2447 XmlNode state = st.ChildNodes[0];
2448
2449 XmlDocument sdoc = new XmlDocument();
2450 XmlNode sxmlnode = sdoc.CreateNode(
2451 XmlNodeType.XmlDeclaration,
2452 "", "");
2453 sdoc.AppendChild(sxmlnode);
2454
2455 XmlNode newnode = sdoc.ImportNode(state, true);
2456 sdoc.AppendChild(newnode);
2457
2458 string spath = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString());
2459 spath = Path.Combine(spath, uuid.ToString());
2460 FileStream sfs = File.Create(spath + ".state");
2461 ASCIIEncoding enc = new ASCIIEncoding();
2462 Byte[] buf = enc.GetBytes(sdoc.InnerXml);
2463 sfs.Write(buf, 0, buf.Length);
2464 sfs.Close();
2465 }
2466 break;
2467 }
2468 }
2469 }
2470 }
2471
2472 SceneObjectPart RootPrim = GetSceneObjectPart(primID);
2473 RootPrim.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1);
2474
2475 return true;
2476 }
2477
2478 return true;
2479 }
2480
2481 public bool IncomingCreateObject(ISceneObject sog) 2384 public bool IncomingCreateObject(ISceneObject sog)
2482 { 2385 {
2483 //m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); 2386 //m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted);
@@ -3350,7 +3253,6 @@ namespace OpenSim.Region.Framework.Scenes
3350 m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; 3253 m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent;
3351 //m_eventManager.OnRegionUp += OtherRegionUp; 3254 //m_eventManager.OnRegionUp += OtherRegionUp;
3352 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3255 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3353 m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
3354 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3256 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3355 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3257 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3356 m_sceneGridService.KiPrimitive += SendKillObject; 3258 m_sceneGridService.KiPrimitive += SendKillObject;
@@ -3374,7 +3276,6 @@ namespace OpenSim.Region.Framework.Scenes
3374 m_sceneGridService.KiPrimitive -= SendKillObject; 3276 m_sceneGridService.KiPrimitive -= SendKillObject;
3375 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3277 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3376 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3278 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3377 m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
3378 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3279 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3379 //m_eventManager.OnRegionUp -= OtherRegionUp; 3280 //m_eventManager.OnRegionUp -= OtherRegionUp;
3380 m_sceneGridService.OnExpectUser -= HandleNewUserConnection; 3281 m_sceneGridService.OnExpectUser -= HandleNewUserConnection;
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 76c6cab..3892769 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -85,7 +85,6 @@ namespace OpenSim.Region.Framework.Scenes
85 /// <summary> 85 /// <summary>
86 /// A Prim will arrive shortly 86 /// A Prim will arrive shortly
87 /// </summary> 87 /// </summary>
88 public event ExpectPrimDelegate OnExpectPrim;
89 public event CloseAgentConnection OnCloseAgentConnection; 88 public event CloseAgentConnection OnCloseAgentConnection;
90 89
91 /// <summary> 90 /// <summary>
@@ -116,7 +115,6 @@ namespace OpenSim.Region.Framework.Scenes
116 115
117 private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion; 116 private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion;
118 private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser; 117 private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser;
119 private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
120 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; 118 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
121 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; 119 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
122 //private RegionUp handlerRegionUp = null; // OnRegionUp; 120 //private RegionUp handlerRegionUp = null; // OnRegionUp;
@@ -147,30 +145,6 @@ namespace OpenSim.Region.Framework.Scenes
147 /// <exception cref="System.Exception">Thrown if region registration fails.</exception> 145 /// <exception cref="System.Exception">Thrown if region registration fails.</exception>
148 public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos) 146 public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos)
149 { 147 {
150 //m_interregionCommsOut = comms_out;
151
152 //m_regionInfo = regionInfos;
153 //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
154 //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
155
156 //if (regionCommsHost != null)
157 //{
158 // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
159
160 // regionCommsHost.debugRegionName = regionInfos.RegionName;
161 // regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
162 // regionCommsHost.OnExpectUser += NewUserConnection;
163 // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
164 // regionCommsHost.OnCloseAgentConnection += CloseConnection;
165 // regionCommsHost.OnRegionUp += newRegionUp;
166 // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
167 // regionCommsHost.OnLogOffUser += GridLogOffUser;
168 // regionCommsHost.OnGetLandData += FetchLandData;
169 //}
170 //else
171 //{
172 // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
173 //}
174 } 148 }
175 149
176 /// <summary> 150 /// <summary>
@@ -179,31 +153,6 @@ namespace OpenSim.Region.Framework.Scenes
179 /// </summary> 153 /// </summary>
180 public void Close() 154 public void Close()
181 { 155 {
182
183 //if (regionCommsHost != null)
184 //{
185 // regionCommsHost.OnLogOffUser -= GridLogOffUser;
186 // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
187 // regionCommsHost.OnRegionUp -= newRegionUp;
188 // regionCommsHost.OnExpectUser -= NewUserConnection;
189 // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
190 // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
191 // regionCommsHost.OnCloseAgentConnection -= CloseConnection;
192 // regionCommsHost.OnGetLandData -= FetchLandData;
193
194 // try
195 // {
196 // m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
197 // }
198 // catch (Exception e)
199 // {
200 // m_log.ErrorFormat(
201 // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
202 // m_regionInfo.RegionName, e);
203 // }
204
205 // regionCommsHost = null;
206 //}
207 } 156 }
208 157
209 #region CommsManager Event handlers 158 #region CommsManager Event handlers
@@ -263,27 +212,6 @@ namespace OpenSim.Region.Framework.Scenes
263 } 212 }
264 } 213 }
265 214
266 /// <summary>
267 /// We have a new prim from a neighbor
268 /// </summary>
269 /// <param name="primID">unique ID for the primative</param>
270 /// <param name="objXMLData">XML2 encoded data of the primative</param>
271 /// <param name="XMLMethod">An Int that represents the version of the XMLMethod</param>
272 /// <returns>True if the prim was accepted, false if it was not</returns>
273 protected bool IncomingPrimCrossing(UUID primID, String objXMLData, int XMLMethod)
274 {
275 handlerExpectPrim = OnExpectPrim;
276 if (handlerExpectPrim != null)
277 {
278 return handlerExpectPrim(primID, objXMLData, XMLMethod);
279 }
280 else
281 {
282 return false;
283 }
284
285 }
286
287 protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical) 215 protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical)
288 { 216 {
289 handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion; 217 handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 3cec77f..5a06bdb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -309,26 +309,15 @@ namespace OpenSim.Region.Framework.Scenes
309 309
310 public string GetStateSnapshot() 310 public string GetStateSnapshot()
311 { 311 {
312 //m_log.Debug(" >>> GetStateSnapshot <<<");
313
314 List<string> assemblies = new List<string>();
315 Dictionary<UUID, string> states = new Dictionary<UUID, string>(); 312 Dictionary<UUID, string> states = new Dictionary<UUID, string>();
316 313
317 foreach (SceneObjectPart part in m_parts.Values) 314 foreach (SceneObjectPart part in m_parts.Values)
318 { 315 {
319 foreach (string a in part.Inventory.GetScriptAssemblies())
320 {
321 if (a != "" && !assemblies.Contains(a))
322 assemblies.Add(a);
323 }
324
325 foreach (KeyValuePair<UUID, string> s in part.Inventory.GetScriptStates()) 316 foreach (KeyValuePair<UUID, string> s in part.Inventory.GetScriptStates())
326 {
327 states[s.Key] = s.Value; 317 states[s.Key] = s.Value;
328 }
329 } 318 }
330 319
331 if (states.Count < 1 || assemblies.Count < 1) 320 if (states.Count < 1)
332 return ""; 321 return "";
333 322
334 XmlDocument xmldoc = new XmlDocument(); 323 XmlDocument xmldoc = new XmlDocument();
@@ -342,104 +331,49 @@ namespace OpenSim.Region.Framework.Scenes
342 331
343 xmldoc.AppendChild(rootElement); 332 xmldoc.AppendChild(rootElement);
344 333
345 XmlElement wrapper = xmldoc.CreateElement("", "Assemblies",
346 "");
347 334
348 rootElement.AppendChild(wrapper); 335 XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates",
349
350 foreach (string assembly in assemblies)
351 {
352 string fn = Path.GetFileName(assembly);
353 if (fn == String.Empty)
354 continue;
355
356 String filedata = String.Empty;
357
358 if (File.Exists(assembly+".text"))
359 {
360 FileInfo tfi = new FileInfo(assembly+".text");
361
362 if (tfi == null)
363 continue;
364
365 Byte[] tdata = new Byte[tfi.Length];
366
367 try
368 {
369 FileStream tfs = File.Open(assembly+".text", FileMode.Open, FileAccess.Read);
370 tfs.Read(tdata, 0, tdata.Length);
371 tfs.Close();
372 }
373 catch (Exception e)
374 {
375 m_log.DebugFormat("[SOG]: Unable to open script textfile {0}, reason: {1}", assembly+".text", e.Message);
376 }
377
378 filedata = new System.Text.ASCIIEncoding().GetString(tdata);
379 }
380 else
381 {
382 FileInfo fi = new FileInfo(assembly);
383
384 if (fi == null)
385 continue;
386
387 Byte[] data = new Byte[fi.Length];
388
389 try
390 {
391 FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read);
392 fs.Read(data, 0, data.Length);
393 fs.Close();
394 }
395 catch (Exception e)
396 {
397 m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message);
398 }
399
400 filedata = System.Convert.ToBase64String(data);
401 }
402 XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", "");
403 XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", "");
404 assemblyName.Value = fn;
405 assemblyData.Attributes.Append(assemblyName);
406
407 assemblyData.InnerText = filedata;
408
409 wrapper.AppendChild(assemblyData);
410 }
411
412 wrapper = xmldoc.CreateElement("", "ScriptStates",
413 ""); 336 "");
414 337
415 rootElement.AppendChild(wrapper); 338 rootElement.AppendChild(wrapper);
416 339
417 foreach (KeyValuePair<UUID, string> state in states) 340 foreach (KeyValuePair<UUID, string> state in states)
418 { 341 {
419 XmlElement stateData = xmldoc.CreateElement("", "State", "");
420
421 XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", "");
422 stateID.Value = state.Key.ToString();
423 stateData.Attributes.Append(stateID);
424
425 XmlDocument sdoc = new XmlDocument(); 342 XmlDocument sdoc = new XmlDocument();
426 sdoc.LoadXml(state.Value); 343 sdoc.LoadXml(state.Value);
427 XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); 344 XmlNodeList rootL = sdoc.GetElementsByTagName("State");
428 XmlNode rootNode = rootL[0]; 345 XmlNode rootNode = rootL[0];
429 346
430 XmlNode newNode = xmldoc.ImportNode(rootNode, true); 347 XmlNode newNode = xmldoc.ImportNode(rootNode, true);
431 stateData.AppendChild(newNode); 348 wrapper.AppendChild(newNode);
432 wrapper.AppendChild(stateData);
433 } 349 }
434 350
435 return xmldoc.InnerXml; 351 return xmldoc.InnerXml;
436 } 352 }
437 353
438 public void SetState(string objXMLData, UUID RegionID) 354 public void SetState(string objXMLData, IScene ins)
439 { 355 {
356 if (!(ins is Scene))
357 return;
358
359 Scene s = (Scene)ins;
360
440 if (objXMLData == String.Empty) 361 if (objXMLData == String.Empty)
441 return; 362 return;
442 363
364 IScriptModule scriptModule = null;
365
366 foreach (IScriptModule sm in s.RequestModuleInterfaces<IScriptModule>())
367 {
368 if (sm.ScriptEngineName == s.DefaultScriptEngine)
369 scriptModule = sm;
370 else if (scriptModule == null)
371 scriptModule = sm;
372 }
373
374 if (scriptModule == null)
375 return;
376
443 XmlDocument doc = new XmlDocument(); 377 XmlDocument doc = new XmlDocument();
444 try 378 try
445 { 379 {
@@ -457,69 +391,23 @@ namespace OpenSim.Region.Framework.Scenes
457 } 391 }
458 392
459 XmlNodeList rootL = doc.GetElementsByTagName("ScriptData"); 393 XmlNodeList rootL = doc.GetElementsByTagName("ScriptData");
460 if (rootL.Count == 1) 394 if (rootL.Count != 1)
395 return;
396
397 XmlElement rootE = (XmlElement)rootL[0];
398
399 XmlNodeList dataL = rootE.GetElementsByTagName("ScriptStates");
400 if (dataL.Count != 1)
401 return;
402
403 XmlElement dataE = (XmlElement)dataL[0];
404
405 foreach (XmlNode n in dataE.ChildNodes)
461 { 406 {
462 XmlNode rootNode = rootL[0]; 407 XmlElement stateE = (XmlElement)n;
463 if (rootNode != null) 408 UUID itemID = new UUID(stateE.GetAttribute("UUID"));
464 { 409
465 XmlNodeList partL = rootNode.ChildNodes; 410 scriptModule.SetXMLState(itemID, n.OuterXml);
466
467 foreach (XmlNode part in partL)
468 {
469 XmlNodeList nodeL = part.ChildNodes;
470
471 switch (part.Name)
472 {
473 case "Assemblies":
474 foreach (XmlNode asm in nodeL)
475 {
476 string fn = asm.Attributes.GetNamedItem("Filename").Value;
477
478 Byte[] filedata = Convert.FromBase64String(asm.InnerText);
479 string path = Path.Combine("ScriptEngines", RegionID.ToString());
480 path = Path.Combine(path, fn);
481
482 if (!File.Exists(path))
483 {
484 FileStream fs = File.Create(path);
485 fs.Write(filedata, 0, filedata.Length);
486 fs.Close();
487
488 Byte[] textbytes = new System.Text.ASCIIEncoding().GetBytes(asm.InnerText);
489 fs = File.Create(path+".text");
490 fs.Write(textbytes, 0, textbytes.Length);
491 fs.Close();
492 }
493 }
494 break;
495 case "ScriptStates":
496 foreach (XmlNode st in nodeL)
497 {
498 string id = st.Attributes.GetNamedItem("UUID").Value;
499 UUID uuid = new UUID(id);
500 XmlNode state = st.ChildNodes[0];
501
502 XmlDocument sdoc = new XmlDocument();
503 XmlNode sxmlnode = sdoc.CreateNode(
504 XmlNodeType.XmlDeclaration,
505 "", "");
506 sdoc.AppendChild(sxmlnode);
507
508 XmlNode newnode = sdoc.ImportNode(state, true);
509 sdoc.AppendChild(newnode);
510
511 string spath = Path.Combine("ScriptEngines", RegionID.ToString());
512 spath = Path.Combine(spath, uuid.ToString());
513 FileStream sfs = File.Create(spath + ".state");
514 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
515 Byte[] buf = enc.GetBytes(sdoc.InnerXml);
516 sfs.Write(buf, 0, buf.Length);
517 sfs.Close();
518 }
519 break;
520 }
521 }
522 }
523 } 411 }
524 } 412 }
525 } 413 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index bcc9b37..6ec2a01 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3341,17 +3341,6 @@ namespace OpenSim.Region.Framework.Scenes
3341 } 3341 }
3342 #endregion 3342 #endregion
3343 3343
3344 public bool CanBeDeleted()
3345 {
3346 foreach (SceneObjectPart part in Children.Values)
3347 {
3348 if (!part.CanBeDeleted())
3349 return false;
3350 }
3351
3352 return true;
3353 }
3354
3355 public double GetUpdatePriority(IClientAPI client) 3344 public double GetUpdatePriority(IClientAPI client)
3356 { 3345 {
3357 switch (Scene.UpdatePrioritizationScheme) 3346 switch (Scene.UpdatePrioritizationScheme)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 6f1b458..b6916f2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3797,10 +3797,5 @@ namespace OpenSim.Region.Framework.Scenes
3797 3797
3798 Inventory.ApplyNextOwnerPermissions(); 3798 Inventory.ApplyNextOwnerPermissions();
3799 } 3799 }
3800
3801 public bool CanBeDeleted()
3802 {
3803 return Inventory.CanBeDeleted();
3804 }
3805 } 3800 }
3806} 3801}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index f4ca877..7a0d7b7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -857,36 +857,6 @@ namespace OpenSim.Region.Framework.Scenes
857 return ret; 857 return ret;
858 } 858 }
859 859
860 public string[] GetScriptAssemblies()
861 {
862 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
863
864 List<string> ret = new List<string>();
865 if (engines == null) // No engine at all
866 return new string[0];
867
868 foreach (TaskInventoryItem item in m_items.Values)
869 {
870 if (item.InvType == (int)InventoryType.LSL)
871 {
872 foreach (IScriptModule e in engines)
873 {
874 if (e != null)
875 {
876 string n = e.GetAssemblyName(item.ItemID);
877 if (n != String.Empty)
878 {
879 if (!ret.Contains(n))
880 ret.Add(n);
881 break;
882 }
883 }
884 }
885 }
886 }
887 return ret.ToArray();
888 }
889
890 public Dictionary<UUID, string> GetScriptStates() 860 public Dictionary<UUID, string> GetScriptStates()
891 { 861 {
892 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); 862 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
@@ -916,30 +886,5 @@ namespace OpenSim.Region.Framework.Scenes
916 } 886 }
917 return ret; 887 return ret;
918 } 888 }
919
920 public bool CanBeDeleted()
921 {
922 if (!ContainsScripts())
923 return true;
924
925 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
926
927 if (engines == null) // No engine at all
928 return true;
929
930 foreach (TaskInventoryItem item in m_items.Values)
931 {
932 if (item.InvType == (int)InventoryType.LSL)
933 {
934 foreach (IScriptModule e in engines)
935 {
936 if (!e.CanBeDeleted(item.ItemID))
937 return false;
938 }
939 }
940 }
941
942 return true;
943 }
944 } 889 }
945} 890}