diff options
Merge branch 'master' of ssh://dahlia@myConnection01/var/git/opensim
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
10 files changed, 288 insertions, 32 deletions
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/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 9d97cb2..ee32755 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs | |||
@@ -236,7 +236,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
236 | iHttpReq.StopHttpRequest(localID, itemID); | 236 | iHttpReq.StopHttpRequest(localID, itemID); |
237 | 237 | ||
238 | IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); | 238 | IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); |
239 | comms.DeleteListener(itemID); | 239 | if (comms != null) |
240 | comms.DeleteListener(itemID); | ||
240 | 241 | ||
241 | IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>(); | 242 | IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>(); |
242 | xmlrpc.DeleteChannels(itemID); | 243 | xmlrpc.DeleteChannels(itemID); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9c62775..d235bac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -734,7 +734,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
734 | ChatTypeEnum.Whisper, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, false); | 734 | ChatTypeEnum.Whisper, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, false); |
735 | 735 | ||
736 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 736 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
737 | wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); | 737 | if (wComm != null) |
738 | wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); | ||
738 | } | 739 | } |
739 | 740 | ||
740 | public void llSay(int channelID, string text) | 741 | public void llSay(int channelID, string text) |
@@ -754,7 +755,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
754 | ChatTypeEnum.Say, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, false); | 755 | ChatTypeEnum.Say, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, false); |
755 | 756 | ||
756 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 757 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
757 | wComm.DeliverMessage(ChatTypeEnum.Say, channelID, m_host.Name, m_host.UUID, text); | 758 | if (wComm != null) |
759 | wComm.DeliverMessage(ChatTypeEnum.Say, channelID, m_host.Name, m_host.UUID, text); | ||
758 | } | 760 | } |
759 | } | 761 | } |
760 | 762 | ||
@@ -769,7 +771,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
769 | ChatTypeEnum.Shout, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); | 771 | ChatTypeEnum.Shout, channelID, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); |
770 | 772 | ||
771 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 773 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
772 | wComm.DeliverMessage(ChatTypeEnum.Shout, channelID, m_host.Name, m_host.UUID, text); | 774 | if (wComm != null) |
775 | wComm.DeliverMessage(ChatTypeEnum.Shout, channelID, m_host.Name, m_host.UUID, text); | ||
773 | } | 776 | } |
774 | 777 | ||
775 | public void llRegionSay(int channelID, string text) | 778 | public void llRegionSay(int channelID, string text) |
@@ -786,7 +789,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
786 | m_host.AddScriptLPS(1); | 789 | m_host.AddScriptLPS(1); |
787 | 790 | ||
788 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 791 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
789 | wComm.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID, text); | 792 | if (wComm != null) |
793 | wComm.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID, text); | ||
790 | } | 794 | } |
791 | 795 | ||
792 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) | 796 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) |
@@ -795,21 +799,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
795 | UUID keyID; | 799 | UUID keyID; |
796 | UUID.TryParse(ID, out keyID); | 800 | UUID.TryParse(ID, out keyID); |
797 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 801 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
798 | return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg); | 802 | if (wComm != null) |
803 | return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg); | ||
804 | else | ||
805 | return -1; | ||
799 | } | 806 | } |
800 | 807 | ||
801 | public void llListenControl(int number, int active) | 808 | public void llListenControl(int number, int active) |
802 | { | 809 | { |
803 | m_host.AddScriptLPS(1); | 810 | m_host.AddScriptLPS(1); |
804 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 811 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
805 | wComm.ListenControl(m_itemID, number, active); | 812 | if (wComm != null) |
813 | wComm.ListenControl(m_itemID, number, active); | ||
806 | } | 814 | } |
807 | 815 | ||
808 | public void llListenRemove(int number) | 816 | public void llListenRemove(int number) |
809 | { | 817 | { |
810 | m_host.AddScriptLPS(1); | 818 | m_host.AddScriptLPS(1); |
811 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 819 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
812 | wComm.ListenRemove(m_itemID, number); | 820 | if (wComm != null) |
821 | wComm.ListenRemove(m_itemID, number); | ||
813 | } | 822 | } |
814 | 823 | ||
815 | public void llSensor(string name, string id, int type, double range, double arc) | 824 | public void llSensor(string name, string id, int type, double range, double arc) |
@@ -1037,7 +1046,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1037 | return detectedParams.TouchUV; | 1046 | return detectedParams.TouchUV; |
1038 | } | 1047 | } |
1039 | 1048 | ||
1040 | public void llDie() | 1049 | public virtual void llDie() |
1041 | { | 1050 | { |
1042 | m_host.AddScriptLPS(1); | 1051 | m_host.AddScriptLPS(1); |
1043 | throw new SelfDeleteException(); | 1052 | throw new SelfDeleteException(); |
@@ -1987,6 +1996,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1987 | 1996 | ||
1988 | //KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type | 1997 | //KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type |
1989 | // part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; | 1998 | // part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; |
1999 | |||
2000 | // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line | ||
2001 | // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt | ||
2002 | // It's perfectly okay when the object is not an active physical body though. | ||
2003 | // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against | ||
2004 | // but only if the object is not physial and active. This is important for rotating doors. | ||
2005 | // without the absoluteposition = absoluteposition happening, the doors do not move in the physics | ||
2006 | // scene | ||
2007 | if (part.PhysActor != null && !part.PhysActor.IsPhysical) | ||
2008 | { | ||
2009 | part.ParentGroup.ResetChildPrimPhysicsPositions(); | ||
2010 | } | ||
1990 | } | 2011 | } |
1991 | 2012 | ||
1992 | /// <summary> | 2013 | /// <summary> |
@@ -5772,6 +5793,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5772 | m_host.AddScriptLPS(1); | 5793 | m_host.AddScriptLPS(1); |
5773 | return World.SimulatorFPS; | 5794 | return World.SimulatorFPS; |
5774 | } | 5795 | } |
5796 | |||
5775 | 5797 | ||
5776 | /* particle system rules should be coming into this routine as doubles, that is | 5798 | /* particle system rules should be coming into this routine as doubles, that is |
5777 | rule[0] should be an integer from this list and rule[1] should be the arg | 5799 | rule[0] should be an integer from this list and rule[1] should be the arg |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index e72fa70..5501679 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -1948,5 +1948,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1948 | 1948 | ||
1949 | return key.ToString(); | 1949 | return key.ToString(); |
1950 | } | 1950 | } |
1951 | |||
1952 | /// <summary> | ||
1953 | /// Return information regarding various simulator statistics (sim fps, physics fps, time | ||
1954 | /// dilation, total number of prims, total number of active scripts, script lps, various | ||
1955 | /// timing data, packets in/out, etc. Basically much the information that's shown in the | ||
1956 | /// client's Statistics Bar (Ctrl-Shift-1) | ||
1957 | /// </summary> | ||
1958 | /// <returns>List of floats</returns> | ||
1959 | public LSL_List osGetRegionStats() | ||
1960 | { | ||
1961 | CheckThreatLevel(ThreatLevel.Moderate, "osGetRegionStats"); | ||
1962 | m_host.AddScriptLPS(1); | ||
1963 | LSL_List ret = new LSL_List(); | ||
1964 | float[] stats = World.SimulatorStats; | ||
1965 | |||
1966 | for (int i = 0; i < 21; i++) | ||
1967 | { | ||
1968 | ret.Add(new LSL_Float( stats[i] )); | ||
1969 | } | ||
1970 | return ret; | ||
1971 | } | ||
1972 | |||
1951 | } | 1973 | } |
1952 | } | 1974 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index 0716d45..eeb59d9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs | |||
@@ -166,7 +166,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
166 | ts.next = DateTime.Now.Ticks + (long)data[idx+1]; | 166 | ts.next = DateTime.Now.Ticks + (long)data[idx+1]; |
167 | idx += 2; | 167 | idx += 2; |
168 | 168 | ||
169 | Timers.Add(MakeTimerKey(localID,itemID), ts); | 169 | lock (TimerListLock) |
170 | { | ||
171 | Timers.Add(MakeTimerKey(localID, itemID), ts); | ||
172 | } | ||
170 | } | 173 | } |
171 | } | 174 | } |
172 | } | 175 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 470946a..0b0dc00 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -162,5 +162,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
162 | 162 | ||
163 | key osGetMapTexture(); | 163 | key osGetMapTexture(); |
164 | key osGetRegionMapTexture(string regionName); | 164 | key osGetRegionMapTexture(string regionName); |
165 | LSL_List osGetRegionStats(); | ||
165 | } | 166 | } |
166 | } | 167 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 753ca55..acff8fb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -515,6 +515,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
515 | public const string TEXTURE_PLYWOOD = "89556747-24cb-43ed-920b-47caed15465f"; | 515 | public const string TEXTURE_PLYWOOD = "89556747-24cb-43ed-920b-47caed15465f"; |
516 | public const string TEXTURE_TRANSPARENT = "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903"; | 516 | public const string TEXTURE_TRANSPARENT = "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903"; |
517 | public const string TEXTURE_MEDIA = "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361"; | 517 | public const string TEXTURE_MEDIA = "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361"; |
518 | |||
519 | // Constants for osGetRegionStats | ||
520 | public const int STATS_TIME_DILATION = 0; | ||
521 | public const int STATS_SIM_FPS = 1; | ||
522 | public const int STATS_PHYSICS_FPS = 2; | ||
523 | public const int STATS_AGENT_UPDATES = 3; | ||
524 | public const int STATS_ROOT_AGENTS = 4; | ||
525 | public const int STATS_CHILD_AGENTS = 5; | ||
526 | public const int STATS_TOTAL_PRIMS = 6; | ||
527 | public const int STATS_ACTIVE_PRIMS = 7; | ||
528 | public const int STATS_FRAME_MS = 8; | ||
529 | public const int STATS_NET_MS = 9; | ||
530 | public const int STATS_PHYSICS_MS = 10; | ||
531 | public const int STATS_IMAGE_MS = 11; | ||
532 | public const int STATS_OTHER_MS = 12; | ||
533 | public const int STATS_IN_PACKETS_PER_SECOND = 13; | ||
534 | public const int STATS_OUT_PACKETS_PER_SECOND = 14; | ||
535 | public const int STATS_UNACKED_BYTES = 15; | ||
536 | public const int STATS_AGENT_MS = 16; | ||
537 | public const int STATS_PENDING_DOWNLOADS = 17; | ||
538 | public const int STATS_PENDING_UPLOADS = 18; | ||
539 | public const int STATS_ACTIVE_SCRIPTS = 19; | ||
540 | public const int STATS_SCRIPT_LPS = 20; | ||
518 | 541 | ||
519 | } | 542 | } |
520 | } | 543 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 6b88834..519463e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -632,5 +632,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
632 | { | 632 | { |
633 | return m_OSSL_Functions.osGetRegionMapTexture(regionName); | 633 | return m_OSSL_Functions.osGetRegionMapTexture(regionName); |
634 | } | 634 | } |
635 | |||
636 | public LSL_List osGetRegionStats() | ||
637 | { | ||
638 | return m_OSSL_Functions.osGetRegionStats(); | ||
639 | } | ||
635 | } | 640 | } |
636 | } | 641 | } |
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 a60c0ba..9030a5c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1245,34 +1245,219 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1245 | } | 1245 | } |
1246 | } | 1246 | } |
1247 | 1247 | ||
1248 | public string GetAssemblyName(UUID itemID) | ||
1249 | { | ||
1250 | IScriptInstance instance = GetInstance(itemID); | ||
1251 | if (instance == null) | ||
1252 | return ""; | ||
1253 | return instance.GetAssemblyName(); | ||
1254 | } | ||
1255 | |||
1256 | public string GetXMLState(UUID itemID) | 1248 | public string GetXMLState(UUID itemID) |
1257 | { | 1249 | { |
1258 | IScriptInstance instance = GetInstance(itemID); | 1250 | IScriptInstance instance = GetInstance(itemID); |
1259 | if (instance == null) | 1251 | if (instance == null) |
1260 | return ""; | 1252 | return ""; |
1261 | return instance.GetXMLState(); | 1253 | string xml = instance.GetXMLState(); |
1262 | } | ||
1263 | 1254 | ||
1264 | public bool CanBeDeleted(UUID itemID) | 1255 | XmlDocument sdoc = new XmlDocument(); |
1265 | { | 1256 | sdoc.LoadXml(xml); |
1266 | IScriptInstance instance = GetInstance(itemID); | 1257 | XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); |
1267 | if (instance == null) | 1258 | XmlNode rootNode = rootL[0]; |
1268 | return true; | 1259 | |
1260 | // Create <State UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"> | ||
1261 | XmlDocument doc = new XmlDocument(); | ||
1262 | XmlElement stateData = doc.CreateElement("", "State", ""); | ||
1263 | XmlAttribute stateID = doc.CreateAttribute("", "UUID", ""); | ||
1264 | stateID.Value = itemID.ToString(); | ||
1265 | stateData.Attributes.Append(stateID); | ||
1266 | XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); | ||
1267 | assetID.Value = instance.AssetID.ToString(); | ||
1268 | stateData.Attributes.Append(assetID); | ||
1269 | doc.AppendChild(stateData); | ||
1270 | |||
1271 | // Add <ScriptState>...</ScriptState> | ||
1272 | XmlNode xmlstate = doc.ImportNode(rootNode, true); | ||
1273 | stateData.AppendChild(xmlstate); | ||
1274 | |||
1275 | string assemName = instance.GetAssemblyName(); | ||
1276 | |||
1277 | string fn = Path.GetFileName(assemName); | ||
1278 | |||
1279 | string assem = String.Empty; | ||
1280 | |||
1281 | if (File.Exists(assemName + ".text")) | ||
1282 | { | ||
1283 | FileInfo tfi = new FileInfo(assemName + ".text"); | ||
1284 | |||
1285 | if (tfi != null) | ||
1286 | { | ||
1287 | Byte[] tdata = new Byte[tfi.Length]; | ||
1288 | |||
1289 | try | ||
1290 | { | ||
1291 | FileStream tfs = File.Open(assemName + ".text", | ||
1292 | FileMode.Open, FileAccess.Read); | ||
1293 | tfs.Read(tdata, 0, tdata.Length); | ||
1294 | tfs.Close(); | ||
1295 | |||
1296 | assem = new System.Text.ASCIIEncoding().GetString(tdata); | ||
1297 | } | ||
1298 | catch (Exception e) | ||
1299 | { | ||
1300 | m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message); | ||
1301 | } | ||
1302 | } | ||
1303 | } | ||
1304 | else | ||
1305 | { | ||
1306 | FileInfo fi = new FileInfo(assemName); | ||
1307 | |||
1308 | if (fi != null) | ||
1309 | { | ||
1310 | Byte[] data = new Byte[fi.Length]; | ||
1311 | |||
1312 | try | ||
1313 | { | ||
1314 | FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); | ||
1315 | fs.Read(data, 0, data.Length); | ||
1316 | fs.Close(); | ||
1317 | |||
1318 | assem = System.Convert.ToBase64String(data); | ||
1319 | } | ||
1320 | catch (Exception e) | ||
1321 | { | ||
1322 | m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message); | ||
1323 | } | ||
1324 | |||
1325 | } | ||
1326 | } | ||
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 | |||
1341 | XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); | ||
1342 | XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); | ||
1343 | |||
1344 | assemblyName.Value = fn; | ||
1345 | assemblyData.Attributes.Append(assemblyName); | ||
1346 | |||
1347 | assemblyData.InnerText = assem; | ||
1348 | |||
1349 | stateData.AppendChild(assemblyData); | ||
1269 | 1350 | ||
1270 | return instance.CanBeDeleted(); | 1351 | XmlElement mapData = doc.CreateElement("", "LineMap", ""); |
1352 | XmlAttribute mapName = doc.CreateAttribute("", "Filename", ""); | ||
1353 | |||
1354 | mapName.Value = fn + ".map"; | ||
1355 | mapData.Attributes.Append(mapName); | ||
1356 | |||
1357 | mapData.InnerText = map; | ||
1358 | |||
1359 | stateData.AppendChild(mapData); | ||
1360 | return doc.InnerXml; | ||
1271 | } | 1361 | } |
1272 | 1362 | ||
1273 | private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled) | 1363 | private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled) |
1274 | { | 1364 | { |
1275 | return false; | 1365 | return false; |
1276 | } | 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(mfs); | ||
1456 | |||
1457 | msw.Write(mapE.InnerText); | ||
1458 | |||
1459 | msw.Close(); | ||
1460 | mfs.Close(); | ||
1461 | } | ||
1277 | } | 1462 | } |
1278 | } | 1463 | } |