diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | 49 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 73 |
2 files changed, 64 insertions, 58 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index 9379f8f..de5f92d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -663,9 +663,8 @@ namespace SecondLife | |||
663 | 663 | ||
664 | try | 664 | try |
665 | { | 665 | { |
666 | FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); | 666 | using (FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read)) |
667 | fs.Read(data, 0, data.Length); | 667 | fs.Read(data, 0, data.Length); |
668 | fs.Close(); | ||
669 | } | 668 | } |
670 | catch (Exception) | 669 | catch (Exception) |
671 | { | 670 | { |
@@ -680,9 +679,8 @@ namespace SecondLife | |||
680 | 679 | ||
681 | Byte[] buf = Encoding.ASCII.GetBytes(filetext); | 680 | Byte[] buf = Encoding.ASCII.GetBytes(filetext); |
682 | 681 | ||
683 | FileStream sfs = File.Create(assembly + ".text"); | 682 | using (FileStream sfs = File.Create(assembly + ".text")) |
684 | sfs.Write(buf, 0, buf.Length); | 683 | sfs.Write(buf, 0, buf.Length); |
685 | sfs.Close(); | ||
686 | 684 | ||
687 | return assembly; | 685 | return assembly; |
688 | } | 686 | } |
@@ -775,7 +773,6 @@ namespace SecondLife | |||
775 | return message; | 773 | return message; |
776 | } | 774 | } |
777 | 775 | ||
778 | |||
779 | private static void WriteMapFile(string filename, Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) | 776 | private static void WriteMapFile(string filename, Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) |
780 | { | 777 | { |
781 | string mapstring = String.Empty; | 778 | string mapstring = String.Empty; |
@@ -787,40 +784,42 @@ namespace SecondLife | |||
787 | } | 784 | } |
788 | 785 | ||
789 | Byte[] mapbytes = Encoding.ASCII.GetBytes(mapstring); | 786 | Byte[] mapbytes = Encoding.ASCII.GetBytes(mapstring); |
790 | FileStream mfs = File.Create(filename); | ||
791 | mfs.Write(mapbytes, 0, mapbytes.Length); | ||
792 | mfs.Close(); | ||
793 | } | ||
794 | 787 | ||
788 | using (FileStream mfs = File.Create(filename)) | ||
789 | mfs.Write(mapbytes, 0, mapbytes.Length); | ||
790 | } | ||
795 | 791 | ||
796 | private static Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> ReadMapFile(string filename) | 792 | private static Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> ReadMapFile(string filename) |
797 | { | 793 | { |
798 | Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap; | 794 | Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap; |
799 | try | 795 | try |
800 | { | 796 | { |
801 | StreamReader r = File.OpenText(filename); | 797 | using (StreamReader r = File.OpenText(filename)) |
802 | linemap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>(); | ||
803 | |||
804 | string line; | ||
805 | while ((line = r.ReadLine()) != null) | ||
806 | { | 798 | { |
807 | String[] parts = line.Split(new Char[] { ',' }); | 799 | linemap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>(); |
808 | int kk = System.Convert.ToInt32(parts[0]); | ||
809 | int kv = System.Convert.ToInt32(parts[1]); | ||
810 | int vk = System.Convert.ToInt32(parts[2]); | ||
811 | int vv = System.Convert.ToInt32(parts[3]); | ||
812 | 800 | ||
813 | KeyValuePair<int, int> k = new KeyValuePair<int, int>(kk, kv); | 801 | string line; |
814 | KeyValuePair<int, int> v = new KeyValuePair<int, int>(vk, vv); | 802 | while ((line = r.ReadLine()) != null) |
803 | { | ||
804 | String[] parts = line.Split(new Char[] { ',' }); | ||
805 | int kk = System.Convert.ToInt32(parts[0]); | ||
806 | int kv = System.Convert.ToInt32(parts[1]); | ||
807 | int vk = System.Convert.ToInt32(parts[2]); | ||
808 | int vv = System.Convert.ToInt32(parts[3]); | ||
809 | |||
810 | KeyValuePair<int, int> k = new KeyValuePair<int, int>(kk, kv); | ||
811 | KeyValuePair<int, int> v = new KeyValuePair<int, int>(vk, vv); | ||
815 | 812 | ||
816 | linemap[k] = v; | 813 | linemap[k] = v; |
814 | } | ||
817 | } | 815 | } |
818 | } | 816 | } |
819 | catch | 817 | catch |
820 | { | 818 | { |
821 | linemap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>(); | 819 | linemap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>(); |
822 | } | 820 | } |
821 | |||
823 | return linemap; | 822 | return linemap; |
824 | } | 823 | } |
825 | } | 824 | } |
826 | } | 825 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 9da2168..b983be9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -71,7 +71,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
71 | private bool m_TimerQueued; | 71 | private bool m_TimerQueued; |
72 | private DateTime m_EventStart; | 72 | private DateTime m_EventStart; |
73 | private bool m_InEvent; | 73 | private bool m_InEvent; |
74 | private string m_Assembly; | 74 | private string m_assemblyPath; |
75 | private string m_dataPath; | ||
75 | private string m_CurrentEvent = String.Empty; | 76 | private string m_CurrentEvent = String.Empty; |
76 | private bool m_InSelfDelete; | 77 | private bool m_InSelfDelete; |
77 | private int m_MaxScriptQueue; | 78 | private int m_MaxScriptQueue; |
@@ -244,12 +245,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
244 | /// </summary> | 245 | /// </summary> |
245 | /// <param name='dom'></param> | 246 | /// <param name='dom'></param> |
246 | /// <param name='assembly'></param> | 247 | /// <param name='assembly'></param> |
248 | /// <param name='dataPath'> | ||
249 | /// Path for all script associated data (state, etc.). In a multi-region set up | ||
250 | /// with all scripts loading into the same AppDomain this may not be the same place as the DLL itself. | ||
251 | /// </param> | ||
247 | /// <param name='stateSource'></param> | 252 | /// <param name='stateSource'></param> |
248 | /// <returns>false if load failed, true if suceeded</returns> | 253 | /// <returns>false if load failed, true if suceeded</returns> |
249 | public bool Load(AppDomain dom, Assembly scriptAssembly, StateSource stateSource) | 254 | public bool Load(AppDomain dom, Assembly scriptAssembly, string dataPath, StateSource stateSource) |
250 | { | 255 | { |
251 | //m_Assembly = scriptAssembly.CodeBase; | 256 | m_assemblyPath = scriptAssembly.Location; |
252 | m_Assembly = scriptAssembly.Location; | 257 | m_dataPath = dataPath; |
253 | m_stateSource = stateSource; | 258 | m_stateSource = stateSource; |
254 | 259 | ||
255 | try | 260 | try |
@@ -270,14 +275,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
270 | constructorParams = null; | 275 | constructorParams = null; |
271 | } | 276 | } |
272 | 277 | ||
273 | // m_log.DebugFormat( | ||
274 | // "[SCRIP | ||
275 | // scriptType.FullName, m_Assembly, Engine.World.Name); | ||
276 | |||
277 | if (dom != System.AppDomain.CurrentDomain) | 278 | if (dom != System.AppDomain.CurrentDomain) |
278 | m_Script | 279 | m_Script |
279 | = (IScript)dom.CreateInstanceAndUnwrap( | 280 | = (IScript)dom.CreateInstanceAndUnwrap( |
280 | Path.GetFileNameWithoutExtension(m_Assembly), | 281 | Path.GetFileNameWithoutExtension(m_assemblyPath), |
281 | scriptType.FullName, | 282 | scriptType.FullName, |
282 | false, | 283 | false, |
283 | BindingFlags.Default, | 284 | BindingFlags.Default, |
@@ -305,7 +306,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
305 | { | 306 | { |
306 | m_log.ErrorFormat( | 307 | m_log.ErrorFormat( |
307 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Error loading assembly {6}. Exception {7}{8}", | 308 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Error loading assembly {6}. Exception {7}{8}", |
308 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, m_Assembly, e.Message, e.StackTrace); | 309 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, scriptAssembly.Location, e.Message, e.StackTrace); |
309 | 310 | ||
310 | return false; | 311 | return false; |
311 | } | 312 | } |
@@ -340,10 +341,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
340 | 341 | ||
341 | m_SaveState = true; | 342 | m_SaveState = true; |
342 | 343 | ||
343 | string savedState = Path.Combine(Path.GetDirectoryName(m_Assembly), ItemID.ToString() + ".state"); | 344 | string savedState = Path.Combine(m_dataPath, ItemID.ToString() + ".state"); |
344 | 345 | ||
345 | if (File.Exists(savedState)) | 346 | if (File.Exists(savedState)) |
346 | { | 347 | { |
348 | // m_log.DebugFormat( | ||
349 | // "[SCRIPT INSTANCE]: Found state for script {0} for {1} ({2}) at {3} in {4}", | ||
350 | // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); | ||
351 | |||
347 | string xml = String.Empty; | 352 | string xml = String.Empty; |
348 | 353 | ||
349 | try | 354 | try |
@@ -385,12 +390,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
385 | m_startedFromSavedState = true; | 390 | m_startedFromSavedState = true; |
386 | } | 391 | } |
387 | } | 392 | } |
388 | else | 393 | // else |
389 | { | 394 | // { |
390 | m_log.WarnFormat( | 395 | // m_log.WarnFormat( |
391 | "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Unable to load script state file {6}. Memory limit exceeded.", | 396 | // "[SCRIPT INSTANCE]: Not starting script {0} (id {1}) in part {2} (id {3}) in object {4} in {5}. Unable to load script state file {6}. Memory limit exceeded.", |
392 | ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState); | 397 | // ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name, savedState); |
393 | } | 398 | // } |
394 | } | 399 | } |
395 | catch (Exception e) | 400 | catch (Exception e) |
396 | { | 401 | { |
@@ -401,11 +406,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
401 | } | 406 | } |
402 | // else | 407 | // else |
403 | // { | 408 | // { |
404 | // ScenePresence presence = Engine.World.GetScenePresence(part.OwnerID); | 409 | // m_log.DebugFormat( |
405 | 410 | // "[SCRIPT INSTANCE]: Did not find state for script {0} for {1} ({2}) at {3} in {4}", | |
406 | // if (presence != null && (!postOnRez)) | 411 | // ItemID, savedState, Part.Name, Part.ParentGroup.Name, Part.ParentGroup.Scene.Name); |
407 | // presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); | ||
408 | |||
409 | // } | 412 | // } |
410 | 413 | ||
411 | return true; | 414 | return true; |
@@ -498,8 +501,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
498 | 501 | ||
499 | public void RemoveState() | 502 | public void RemoveState() |
500 | { | 503 | { |
501 | string savedState = Path.Combine(Path.GetDirectoryName(m_Assembly), | 504 | string savedState = Path.Combine(m_dataPath, ItemID.ToString() + ".state"); |
502 | ItemID.ToString() + ".state"); | 505 | |
506 | // m_log.DebugFormat( | ||
507 | // "[SCRIPT INSTANCE]: Deleting state {0} for script {1} (id {2}) in part {3} (id {4}) in object {5} in {6}.", | ||
508 | // savedState, ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name); | ||
503 | 509 | ||
504 | try | 510 | try |
505 | { | 511 | { |
@@ -822,8 +828,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
822 | if (Engine.World.PipeEventsForScript(LocalID) || | 828 | if (Engine.World.PipeEventsForScript(LocalID) || |
823 | data.EventName == "control") // Don't freeze avies! | 829 | data.EventName == "control") // Don't freeze avies! |
824 | { | 830 | { |
825 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", | 831 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", |
826 | // PrimName, ScriptName, data.EventName, State); | 832 | // PrimName, ScriptName, data.EventName, State); |
827 | 833 | ||
828 | try | 834 | try |
829 | { | 835 | { |
@@ -849,7 +855,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
849 | // This will be the very first event we deliver | 855 | // This will be the very first event we deliver |
850 | // (state_entry) in default state | 856 | // (state_entry) in default state |
851 | // | 857 | // |
852 | SaveState(m_Assembly); | 858 | SaveState(); |
853 | 859 | ||
854 | m_SaveState = false; | 860 | m_SaveState = false; |
855 | } | 861 | } |
@@ -1043,7 +1049,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1043 | return m_DetectParams[idx].Key; | 1049 | return m_DetectParams[idx].Key; |
1044 | } | 1050 | } |
1045 | 1051 | ||
1046 | public void SaveState(string assembly) | 1052 | public void SaveState() |
1047 | { | 1053 | { |
1048 | // If we're currently in an event, just tell it to save upon return | 1054 | // If we're currently in an event, just tell it to save upon return |
1049 | // | 1055 | // |
@@ -1065,10 +1071,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1065 | { | 1071 | { |
1066 | try | 1072 | try |
1067 | { | 1073 | { |
1068 | FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state")); | 1074 | using (FileStream fs = File.Create(Path.Combine(m_dataPath, ItemID.ToString() + ".state"))) |
1069 | Byte[] buf = Util.UTF8NoBomEncoding.GetBytes(xml); | 1075 | { |
1070 | fs.Write(buf, 0, buf.Length); | 1076 | Byte[] buf = Util.UTF8NoBomEncoding.GetBytes(xml); |
1071 | fs.Close(); | 1077 | fs.Write(buf, 0, buf.Length); |
1078 | } | ||
1072 | } | 1079 | } |
1073 | catch(Exception) | 1080 | catch(Exception) |
1074 | { | 1081 | { |
@@ -1148,7 +1155,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1148 | 1155 | ||
1149 | public string GetAssemblyName() | 1156 | public string GetAssemblyName() |
1150 | { | 1157 | { |
1151 | return m_Assembly; | 1158 | return m_assemblyPath; |
1152 | } | 1159 | } |
1153 | 1160 | ||
1154 | public string GetXMLState() | 1161 | public string GetXMLState() |