diff options
author | Melanie | 2009-11-26 17:03:09 +0000 |
---|---|---|
committer | Melanie | 2009-11-26 17:03:09 +0000 |
commit | 9d63f90467dbc60622a49f564a56fdd20de90f51 (patch) | |
tree | 277a246a036dfe70204d10f0d86140b2e8a3b901 | |
parent | Remove the old remoting-type interregion code for prim/script crossing (diff) | |
download | opensim-SC-9d63f90467dbc60622a49f564a56fdd20de90f51.zip opensim-SC-9d63f90467dbc60622a49f564a56fdd20de90f51.tar.gz opensim-SC-9d63f90467dbc60622a49f564a56fdd20de90f51.tar.bz2 opensim-SC-9d63f90467dbc60622a49f564a56fdd20de90f51.tar.xz |
Remove the old (Remoting) region crossing code. Fix the new code to
pass script state and assembly again properly. Reintroduce respecting tht
TrustBinaries flag. Changes the interregion protocol! No version bump
because it was broken anyway, so with a version mismatch it will simply
stay broken, but not crash. Region corssing still doesn't work because
there is still monkey business with both rezzed prims being pushed across
a border and attached prims when walking across a border. Teleport is
untested by may work.
Diffstat (limited to '')
14 files changed, 160 insertions, 138 deletions
diff --git a/OpenSim/Framework/ISceneObject.cs b/OpenSim/Framework/ISceneObject.cs index 4fc3e01..5147901 100644 --- a/OpenSim/Framework/ISceneObject.cs +++ b/OpenSim/Framework/ISceneObject.cs | |||
@@ -38,6 +38,6 @@ namespace OpenSim.Framework | |||
38 | string ExtraToXmlString(); | 38 | string ExtraToXmlString(); |
39 | void ExtraFromXmlString(string xmlstr); | 39 | void ExtraFromXmlString(string xmlstr); |
40 | string GetStateSnapshot(); | 40 | string GetStateSnapshot(); |
41 | void SetState(string xmlstr, UUID regionID); | 41 | void SetState(string xmlstr, IScene s); |
42 | } | 42 | } |
43 | } | 43 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs index ee809bd..d9f6e33 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs | |||
@@ -263,8 +263,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
263 | { | 263 | { |
264 | // We need to make a local copy of the object | 264 | // We need to make a local copy of the object |
265 | ISceneObject sogClone = sog.CloneForNewScene(); | 265 | ISceneObject sogClone = sog.CloneForNewScene(); |
266 | sogClone.SetState(sog.GetStateSnapshot(), | 266 | sogClone.SetState(sog.GetStateSnapshot(), s); |
267 | s.RegionInfo.RegionID); | ||
268 | return s.IncomingCreateObject(sogClone); | 267 | return s.IncomingCreateObject(sogClone); |
269 | } | 268 | } |
270 | else | 269 | else |
@@ -294,15 +293,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
294 | 293 | ||
295 | #region Misc | 294 | #region Misc |
296 | 295 | ||
297 | public UUID GetRegionID(ulong regionhandle) | 296 | public Scene GetScene(ulong regionhandle) |
298 | { | 297 | { |
299 | foreach (Scene s in m_sceneList) | 298 | foreach (Scene s in m_sceneList) |
300 | { | 299 | { |
301 | if (s.RegionInfo.RegionHandle == regionhandle) | 300 | if (s.RegionInfo.RegionHandle == regionhandle) |
302 | return s.RegionInfo.RegionID; | 301 | return s; |
303 | } | 302 | } |
304 | // ? weird. should not happen | 303 | // ? weird. should not happen |
305 | return m_sceneList[0].RegionInfo.RegionID; | 304 | return m_sceneList[0]; |
306 | } | 305 | } |
307 | 306 | ||
308 | public bool IsLocalRegion(ulong regionhandle) | 307 | public bool IsLocalRegion(ulong regionhandle) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index 696225c..710e3ca 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs | |||
@@ -641,7 +641,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
641 | if (args["extra"] != null) | 641 | if (args["extra"] != null) |
642 | extraStr = args["extra"].AsString(); | 642 | extraStr = args["extra"].AsString(); |
643 | 643 | ||
644 | UUID regionID = m_localBackend.GetRegionID(regionhandle); | 644 | IScene s = m_localBackend.GetScene(regionhandle); |
645 | SceneObjectGroup sog = null; | 645 | SceneObjectGroup sog = null; |
646 | try | 646 | try |
647 | { | 647 | { |
@@ -663,7 +663,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
663 | { | 663 | { |
664 | try | 664 | try |
665 | { | 665 | { |
666 | sog.SetState(stateXmlStr, regionID); | 666 | sog.SetState(stateXmlStr, s); |
667 | } | 667 | } |
668 | catch (Exception ex) | 668 | catch (Exception ex) |
669 | { | 669 | { |
@@ -695,8 +695,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion | |||
695 | if (args["itemid"] != null) | 695 | if (args["itemid"] != null) |
696 | itemID = args["itemid"].AsUUID(); | 696 | itemID = args["itemid"].AsUUID(); |
697 | 697 | ||
698 | //UUID regionID = m_localBackend.GetRegionID(regionhandle); | ||
699 | |||
700 | // This is the meaning of PUT object | 698 | // This is the meaning of PUT object |
701 | bool result = m_localBackend.SendCreateObject(regionhandle, userID, itemID); | 699 | bool result = m_localBackend.SendCreateObject(regionhandle, userID, itemID); |
702 | 700 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 2998f45..89a45da 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -191,7 +191,5 @@ namespace OpenSim.Region.Framework.Interfaces | |||
191 | /// A <see cref="Dictionary`2"/> | 191 | /// A <see cref="Dictionary`2"/> |
192 | /// </returns> | 192 | /// </returns> |
193 | Dictionary<UUID, string> GetScriptStates(); | 193 | Dictionary<UUID, string> GetScriptStates(); |
194 | |||
195 | bool CanBeDeleted(); | ||
196 | } | 194 | } |
197 | } | 195 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 72bb0f0..f11e571 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs | |||
@@ -35,7 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
35 | string ScriptEngineName { get; } | 35 | string ScriptEngineName { get; } |
36 | 36 | ||
37 | string GetXMLState(UUID itemID); | 37 | string GetXMLState(UUID itemID); |
38 | bool CanBeDeleted(UUID itemID); | 38 | void SetXMLState(UUID itemID, string xml); |
39 | 39 | ||
40 | bool PostScriptEvent(UUID itemID, string name, Object[] args); | 40 | bool PostScriptEvent(UUID itemID, string name, Object[] args); |
41 | 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 0ee818d..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) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 9a6f2b8..5a06bdb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -351,12 +351,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
351 | return xmldoc.InnerXml; | 351 | return xmldoc.InnerXml; |
352 | } | 352 | } |
353 | 353 | ||
354 | public void SetState(string objXMLData, UUID RegionID) | 354 | public void SetState(string objXMLData, IScene ins) |
355 | { | 355 | { |
356 | m_log.Debug("SetState called with " + objXMLData); | 356 | if (!(ins is Scene)) |
357 | return; | ||
358 | |||
359 | Scene s = (Scene)ins; | ||
360 | |||
357 | if (objXMLData == String.Empty) | 361 | if (objXMLData == String.Empty) |
358 | return; | 362 | return; |
359 | 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 | |||
360 | XmlDocument doc = new XmlDocument(); | 377 | XmlDocument doc = new XmlDocument(); |
361 | try | 378 | try |
362 | { | 379 | { |
@@ -374,69 +391,23 @@ m_log.Debug("SetState called with " + objXMLData); | |||
374 | } | 391 | } |
375 | 392 | ||
376 | XmlNodeList rootL = doc.GetElementsByTagName("ScriptData"); | 393 | XmlNodeList rootL = doc.GetElementsByTagName("ScriptData"); |
377 | 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) | ||
378 | { | 406 | { |
379 | XmlNode rootNode = rootL[0]; | 407 | XmlElement stateE = (XmlElement)n; |
380 | if (rootNode != null) | 408 | UUID itemID = new UUID(stateE.GetAttribute("UUID")); |
381 | { | 409 | |
382 | XmlNodeList partL = rootNode.ChildNodes; | 410 | scriptModule.SetXMLState(itemID, n.OuterXml); |
383 | |||
384 | foreach (XmlNode part in partL) | ||
385 | { | ||
386 | XmlNodeList nodeL = part.ChildNodes; | ||
387 | |||
388 | switch (part.Name) | ||
389 | { | ||
390 | case "Assemblies": | ||
391 | foreach (XmlNode asm in nodeL) | ||
392 | { | ||
393 | string fn = asm.Attributes.GetNamedItem("Filename").Value; | ||
394 | |||
395 | Byte[] filedata = Convert.FromBase64String(asm.InnerText); | ||
396 | string path = Path.Combine("ScriptEngines", RegionID.ToString()); | ||
397 | path = Path.Combine(path, fn); | ||
398 | |||
399 | if (!File.Exists(path)) | ||
400 | { | ||
401 | FileStream fs = File.Create(path); | ||
402 | fs.Write(filedata, 0, filedata.Length); | ||
403 | fs.Close(); | ||
404 | |||
405 | Byte[] textbytes = new System.Text.ASCIIEncoding().GetBytes(asm.InnerText); | ||
406 | fs = File.Create(path+".text"); | ||
407 | fs.Write(textbytes, 0, textbytes.Length); | ||
408 | fs.Close(); | ||
409 | } | ||
410 | } | ||
411 | break; | ||
412 | case "ScriptStates": | ||
413 | foreach (XmlNode st in nodeL) | ||
414 | { | ||
415 | string id = st.Attributes.GetNamedItem("UUID").Value; | ||
416 | UUID uuid = new UUID(id); | ||
417 | XmlNode state = st.ChildNodes[0]; | ||
418 | |||
419 | XmlDocument sdoc = new XmlDocument(); | ||
420 | XmlNode sxmlnode = sdoc.CreateNode( | ||
421 | XmlNodeType.XmlDeclaration, | ||
422 | "", ""); | ||
423 | sdoc.AppendChild(sxmlnode); | ||
424 | |||
425 | XmlNode newnode = sdoc.ImportNode(state, true); | ||
426 | sdoc.AppendChild(newnode); | ||
427 | |||
428 | string spath = Path.Combine("ScriptEngines", RegionID.ToString()); | ||
429 | spath = Path.Combine(spath, uuid.ToString()); | ||
430 | FileStream sfs = File.Create(spath + ".state"); | ||
431 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | ||
432 | Byte[] buf = enc.GetBytes(sdoc.InnerXml); | ||
433 | sfs.Write(buf, 0, buf.Length); | ||
434 | sfs.Close(); | ||
435 | } | ||
436 | break; | ||
437 | } | ||
438 | } | ||
439 | } | ||
440 | } | 411 | } |
441 | } | 412 | } |
442 | } | 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 7f49ced..7a0d7b7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -886,30 +886,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
886 | } | 886 | } |
887 | return ret; | 887 | return ret; |
888 | } | 888 | } |
889 | |||
890 | public bool CanBeDeleted() | ||
891 | { | ||
892 | if (!ContainsScripts()) | ||
893 | return true; | ||
894 | |||
895 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
896 | |||
897 | if (engines == null) // No engine at all | ||
898 | return true; | ||
899 | |||
900 | foreach (TaskInventoryItem item in m_items.Values) | ||
901 | { | ||
902 | if (item.InvType == (int)InventoryType.LSL) | ||
903 | { | ||
904 | foreach (IScriptModule e in engines) | ||
905 | { | ||
906 | if (!e.CanBeDeleted(item.ItemID)) | ||
907 | return false; | ||
908 | } | ||
909 | } | ||
910 | } | ||
911 | |||
912 | return true; | ||
913 | } | ||
914 | } | 889 | } |
915 | } | 890 | } |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index f49aea8..ae148a9 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | |||
@@ -96,7 +96,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
96 | UUID GetDetectID(int idx); | 96 | UUID GetDetectID(int idx); |
97 | void SaveState(string assembly); | 97 | void SaveState(string assembly); |
98 | void DestroyScriptInstance(); | 98 | void DestroyScriptInstance(); |
99 | bool CanBeDeleted(); | ||
100 | 99 | ||
101 | IScriptApi GetApi(string name); | 100 | IScriptApi GetApi(string name); |
102 | 101 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 41b5d49..5c5d57e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -1011,10 +1011,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1011 | { | 1011 | { |
1012 | get { return m_RegionID; } | 1012 | get { return m_RegionID; } |
1013 | } | 1013 | } |
1014 | |||
1015 | public bool CanBeDeleted() | ||
1016 | { | ||
1017 | return true; | ||
1018 | } | ||
1019 | } | 1014 | } |
1020 | } | 1015 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 0a9af2c..b099177 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1325,6 +1325,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1325 | } | 1325 | } |
1326 | } | 1326 | } |
1327 | 1327 | ||
1328 | string map = String.Empty; | ||
1329 | |||
1330 | if (File.Exists(fn + ".map")) | ||
1331 | { | ||
1332 | FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read); | ||
1333 | StreamReader msr = new StreamReader(mfs); | ||
1334 | |||
1335 | map = msr.ReadToEnd(); | ||
1336 | |||
1337 | msr.Close(); | ||
1338 | mfs.Close(); | ||
1339 | } | ||
1340 | |||
1328 | XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); | 1341 | XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); |
1329 | XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); | 1342 | XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); |
1330 | 1343 | ||
@@ -1335,21 +1348,116 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1335 | 1348 | ||
1336 | stateData.AppendChild(assemblyData); | 1349 | stateData.AppendChild(assemblyData); |
1337 | 1350 | ||
1338 | return doc.InnerXml; | 1351 | XmlElement mapData = doc.CreateElement("", "LineMap", ""); |
1339 | } | 1352 | XmlAttribute mapName = doc.CreateAttribute("", "Filename", ""); |
1340 | 1353 | ||
1341 | public bool CanBeDeleted(UUID itemID) | 1354 | mapName.Value = fn + ".map"; |
1342 | { | 1355 | mapData.Attributes.Append(mapName); |
1343 | IScriptInstance instance = GetInstance(itemID); | ||
1344 | if (instance == null) | ||
1345 | return true; | ||
1346 | 1356 | ||
1347 | return instance.CanBeDeleted(); | 1357 | mapData.InnerText = map; |
1358 | |||
1359 | stateData.AppendChild(mapData); | ||
1360 | return doc.InnerXml; | ||
1348 | } | 1361 | } |
1349 | 1362 | ||
1350 | private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled) | 1363 | private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled) |
1351 | { | 1364 | { |
1352 | return false; | 1365 | return false; |
1353 | } | 1366 | } |
1367 | |||
1368 | public void SetXMLState(UUID itemID, string xml) | ||
1369 | { | ||
1370 | if (xml == String.Empty) | ||
1371 | return; | ||
1372 | |||
1373 | XmlDocument doc = new XmlDocument(); | ||
1374 | |||
1375 | try | ||
1376 | { | ||
1377 | doc.LoadXml(xml); | ||
1378 | } | ||
1379 | catch (Exception) | ||
1380 | { | ||
1381 | m_log.Error("[XEngine]: Exception decoding XML data from region transfer"); | ||
1382 | return; | ||
1383 | } | ||
1384 | |||
1385 | XmlNodeList rootL = doc.GetElementsByTagName("State"); | ||
1386 | if (rootL.Count < 1) | ||
1387 | return; | ||
1388 | |||
1389 | XmlElement rootE = (XmlElement)rootL[0]; | ||
1390 | |||
1391 | if (rootE.GetAttribute("UUID") != itemID.ToString()) | ||
1392 | return; | ||
1393 | |||
1394 | string assetID = rootE.GetAttribute("Asset"); | ||
1395 | |||
1396 | XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState"); | ||
1397 | |||
1398 | if (stateL.Count != 1) | ||
1399 | return; | ||
1400 | |||
1401 | XmlElement stateE = (XmlElement)stateL[0]; | ||
1402 | |||
1403 | if (World.m_trustBinaries) | ||
1404 | { | ||
1405 | XmlNodeList assemL = rootE.GetElementsByTagName("Assembly"); | ||
1406 | |||
1407 | if (assemL.Count != 1) | ||
1408 | return; | ||
1409 | |||
1410 | XmlElement assemE = (XmlElement)assemL[0]; | ||
1411 | |||
1412 | string fn = assemE.GetAttribute("Filename"); | ||
1413 | string base64 = assemE.InnerText; | ||
1414 | |||
1415 | string path = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | ||
1416 | path = Path.Combine(path, fn); | ||
1417 | |||
1418 | if (!File.Exists(path)) | ||
1419 | { | ||
1420 | Byte[] filedata = Convert.FromBase64String(base64); | ||
1421 | |||
1422 | FileStream fs = File.Create(path); | ||
1423 | fs.Write(filedata, 0, filedata.Length); | ||
1424 | fs.Close(); | ||
1425 | |||
1426 | fs = File.Create(path + ".text"); | ||
1427 | StreamWriter sw = new StreamWriter(fs); | ||
1428 | |||
1429 | sw.Write(base64); | ||
1430 | |||
1431 | sw.Close(); | ||
1432 | fs.Close(); | ||
1433 | } | ||
1434 | } | ||
1435 | |||
1436 | string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | ||
1437 | statepath = Path.Combine(statepath, itemID.ToString() + ".state"); | ||
1438 | |||
1439 | FileStream sfs = File.Create(statepath); | ||
1440 | StreamWriter ssw = new StreamWriter(sfs); | ||
1441 | |||
1442 | ssw.Write(stateE.OuterXml); | ||
1443 | |||
1444 | ssw.Close(); | ||
1445 | sfs.Close(); | ||
1446 | |||
1447 | XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); | ||
1448 | |||
1449 | XmlElement mapE = (XmlElement)mapL[0]; | ||
1450 | |||
1451 | string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | ||
1452 | mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); | ||
1453 | |||
1454 | FileStream mfs = File.Create(mappath); | ||
1455 | StreamWriter msw = new StreamWriter(sfs); | ||
1456 | |||
1457 | msw.Write(mapE.InnerText); | ||
1458 | |||
1459 | msw.Close(); | ||
1460 | mfs.Close(); | ||
1461 | } | ||
1354 | } | 1462 | } |
1355 | } | 1463 | } |