diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 264 |
2 files changed, 164 insertions, 104 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs index 09b79d0..0ac8b5c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | |||
@@ -356,9 +356,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
356 | // timer: not handled here | 356 | // timer: not handled here |
357 | // listen: not handled here | 357 | // listen: not handled here |
358 | 358 | ||
359 | public void control(uint localID, UUID itemID, UUID agentID, uint held, uint change) | 359 | public void control(UUID itemID, UUID agentID, uint held, uint change) |
360 | { | 360 | { |
361 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 361 | myScriptEngine.PostScriptEvent(itemID, new EventParams( |
362 | "control",new object[] { | 362 | "control",new object[] { |
363 | new LSL_Types.LSLString(agentID.ToString()), | 363 | new LSL_Types.LSLString(agentID.ToString()), |
364 | new LSL_Types.LSLInteger(held), | 364 | new LSL_Types.LSLInteger(held), |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 4715690..b050349 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -488,6 +488,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
488 | 488 | ||
489 | if (stateSource == (int)StateSource.ScriptedRez) | 489 | if (stateSource == (int)StateSource.ScriptedRez) |
490 | { | 490 | { |
491 | lock (m_CompileDict) | ||
492 | { | ||
493 | m_CompileDict[itemID] = 0; | ||
494 | } | ||
495 | |||
491 | DoOnRezScript(parms); | 496 | DoOnRezScript(parms); |
492 | } | 497 | } |
493 | else | 498 | else |
@@ -696,9 +701,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
696 | } | 701 | } |
697 | } | 702 | } |
698 | 703 | ||
704 | ScriptInstance instance = null; | ||
699 | lock (m_Scripts) | 705 | lock (m_Scripts) |
700 | { | 706 | { |
701 | ScriptInstance instance = null; | ||
702 | // Create the object record | 707 | // Create the object record |
703 | 708 | ||
704 | if ((!m_Scripts.ContainsKey(itemID)) || | 709 | if ((!m_Scripts.ContainsKey(itemID)) || |
@@ -765,8 +770,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
765 | item.Name, startParam, postOnRez, | 770 | item.Name, startParam, postOnRez, |
766 | stateSource, m_MaxScriptQueue); | 771 | stateSource, m_MaxScriptQueue); |
767 | 772 | ||
768 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}", | 773 | m_log.DebugFormat( |
769 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString()); | 774 | "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", |
775 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, | ||
776 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | ||
770 | 777 | ||
771 | if (presence != null) | 778 | if (presence != null) |
772 | { | 779 | { |
@@ -779,28 +786,29 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
779 | 786 | ||
780 | m_Scripts[itemID] = instance; | 787 | m_Scripts[itemID] = instance; |
781 | } | 788 | } |
789 | } | ||
782 | 790 | ||
783 | lock (m_PrimObjects) | 791 | lock (m_PrimObjects) |
784 | { | 792 | { |
785 | if (!m_PrimObjects.ContainsKey(localID)) | 793 | if (!m_PrimObjects.ContainsKey(localID)) |
786 | m_PrimObjects[localID] = new List<UUID>(); | 794 | m_PrimObjects[localID] = new List<UUID>(); |
787 | 795 | ||
788 | if (!m_PrimObjects[localID].Contains(itemID)) | 796 | if (!m_PrimObjects[localID].Contains(itemID)) |
789 | m_PrimObjects[localID].Add(itemID); | 797 | m_PrimObjects[localID].Add(itemID); |
790 | 798 | ||
791 | } | 799 | } |
792 | 800 | ||
793 | if (!m_Assemblies.ContainsKey(assetID)) | 801 | if (!m_Assemblies.ContainsKey(assetID)) |
794 | m_Assemblies[assetID] = assembly; | 802 | m_Assemblies[assetID] = assembly; |
795 | 803 | ||
796 | lock (m_AddingAssemblies) | 804 | lock (m_AddingAssemblies) |
797 | { | 805 | { |
798 | m_AddingAssemblies[assembly]--; | 806 | m_AddingAssemblies[assembly]--; |
799 | } | ||
800 | |||
801 | if (instance!=null) | ||
802 | instance.Init(); | ||
803 | } | 807 | } |
808 | |||
809 | if (instance != null) | ||
810 | instance.Init(); | ||
811 | |||
804 | return true; | 812 | return true; |
805 | } | 813 | } |
806 | 814 | ||
@@ -813,60 +821,60 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
813 | m_CompileDict.Remove(itemID); | 821 | m_CompileDict.Remove(itemID); |
814 | } | 822 | } |
815 | 823 | ||
824 | IScriptInstance instance = null; | ||
825 | |||
816 | lock (m_Scripts) | 826 | lock (m_Scripts) |
817 | { | 827 | { |
818 | // Do we even have it? | 828 | // Do we even have it? |
819 | if (!m_Scripts.ContainsKey(itemID)) | 829 | if (!m_Scripts.ContainsKey(itemID)) |
820 | return; | 830 | return; |
821 | 831 | ||
822 | IScriptInstance instance=m_Scripts[itemID]; | 832 | instance=m_Scripts[itemID]; |
823 | m_Scripts.Remove(itemID); | 833 | m_Scripts.Remove(itemID); |
834 | } | ||
824 | 835 | ||
825 | instance.ClearQueue(); | 836 | instance.ClearQueue(); |
826 | instance.Stop(0); | 837 | instance.Stop(0); |
827 | |||
828 | // bool objectRemoved = false; | 838 | // bool objectRemoved = false; |
829 | 839 | ||
830 | lock (m_PrimObjects) | 840 | lock (m_PrimObjects) |
841 | { | ||
842 | // Remove the script from it's prim | ||
843 | if (m_PrimObjects.ContainsKey(localID)) | ||
831 | { | 844 | { |
832 | // Remove the script from it's prim | 845 | // Remove inventory item record |
833 | if (m_PrimObjects.ContainsKey(localID)) | 846 | if (m_PrimObjects[localID].Contains(itemID)) |
834 | { | 847 | m_PrimObjects[localID].Remove(itemID); |
835 | // Remove inventory item record | ||
836 | if (m_PrimObjects[localID].Contains(itemID)) | ||
837 | m_PrimObjects[localID].Remove(itemID); | ||
838 | 848 | ||
839 | // If there are no more scripts, remove prim | 849 | // If there are no more scripts, remove prim |
840 | if (m_PrimObjects[localID].Count == 0) | 850 | if (m_PrimObjects[localID].Count == 0) |
841 | { | 851 | { |
842 | m_PrimObjects.Remove(localID); | 852 | m_PrimObjects.Remove(localID); |
843 | // objectRemoved = true; | 853 | // objectRemoved = true; |
844 | } | ||
845 | } | 854 | } |
846 | } | 855 | } |
856 | } | ||
847 | 857 | ||
848 | instance.RemoveState(); | 858 | instance.RemoveState(); |
849 | instance.DestroyScriptInstance(); | 859 | instance.DestroyScriptInstance(); |
850 | 860 | ||
851 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | 861 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
852 | if (m_DomainScripts[instance.AppDomain].Count == 0) | 862 | if (m_DomainScripts[instance.AppDomain].Count == 0) |
853 | { | 863 | { |
854 | m_DomainScripts.Remove(instance.AppDomain); | 864 | m_DomainScripts.Remove(instance.AppDomain); |
855 | UnloadAppDomain(instance.AppDomain); | 865 | UnloadAppDomain(instance.AppDomain); |
856 | } | 866 | } |
857 | 867 | ||
858 | instance = null; | 868 | instance = null; |
859 | 869 | ||
860 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 870 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
861 | if (handlerObjectRemoved != null) | 871 | if (handlerObjectRemoved != null) |
862 | { | 872 | { |
863 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | 873 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); |
864 | handlerObjectRemoved(part.UUID); | 874 | handlerObjectRemoved(part.UUID); |
865 | } | ||
866 | |||
867 | CleanAssemblies(); | ||
868 | } | 875 | } |
869 | 876 | ||
877 | |||
870 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; | 878 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; |
871 | if (handlerScriptRemoved != null) | 879 | if (handlerScriptRemoved != null) |
872 | handlerScriptRemoved(itemID); | 880 | handlerScriptRemoved(itemID); |
@@ -1000,26 +1008,33 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1000 | public bool PostObjectEvent(uint localID, EventParams p) | 1008 | public bool PostObjectEvent(uint localID, EventParams p) |
1001 | { | 1009 | { |
1002 | bool result = false; | 1010 | bool result = false; |
1003 | 1011 | List<UUID> uuids = null; | |
1012 | |||
1004 | lock (m_PrimObjects) | 1013 | lock (m_PrimObjects) |
1005 | { | 1014 | { |
1006 | if (!m_PrimObjects.ContainsKey(localID)) | 1015 | if (!m_PrimObjects.ContainsKey(localID)) |
1007 | return false; | 1016 | return false; |
1008 | 1017 | ||
1009 | 1018 | uuids = m_PrimObjects[localID]; | |
1010 | foreach (UUID itemID in m_PrimObjects[localID]) | 1019 | } |
1020 | |||
1021 | foreach (UUID itemID in uuids) | ||
1022 | { | ||
1023 | IScriptInstance instance = null; | ||
1024 | try | ||
1011 | { | 1025 | { |
1012 | if (m_Scripts.ContainsKey(itemID)) | 1026 | if (m_Scripts.ContainsKey(itemID)) |
1013 | { | 1027 | instance = m_Scripts[itemID]; |
1014 | IScriptInstance instance = m_Scripts[itemID]; | 1028 | } |
1015 | if (instance != null) | 1029 | catch { /* ignore race conditions */ } |
1016 | { | 1030 | |
1017 | instance.PostEvent(p); | 1031 | if (instance != null) |
1018 | result = true; | 1032 | { |
1019 | } | 1033 | instance.PostEvent(p); |
1020 | } | 1034 | result = true; |
1021 | } | 1035 | } |
1022 | } | 1036 | } |
1037 | |||
1023 | return result; | 1038 | return result; |
1024 | } | 1039 | } |
1025 | 1040 | ||
@@ -1336,10 +1351,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1336 | 1351 | ||
1337 | try | 1352 | try |
1338 | { | 1353 | { |
1339 | FileStream tfs = File.Open(assemName + ".text", | 1354 | using (FileStream tfs = File.Open(assemName + ".text", |
1340 | FileMode.Open, FileAccess.Read); | 1355 | FileMode.Open, FileAccess.Read)) |
1341 | tfs.Read(tdata, 0, tdata.Length); | 1356 | { |
1342 | tfs.Close(); | 1357 | tfs.Read(tdata, 0, tdata.Length); |
1358 | tfs.Close(); | ||
1359 | } | ||
1343 | 1360 | ||
1344 | assem = new System.Text.ASCIIEncoding().GetString(tdata); | 1361 | assem = new System.Text.ASCIIEncoding().GetString(tdata); |
1345 | } | 1362 | } |
@@ -1359,9 +1376,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1359 | 1376 | ||
1360 | try | 1377 | try |
1361 | { | 1378 | { |
1362 | FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); | 1379 | using (FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read)) |
1363 | fs.Read(data, 0, data.Length); | 1380 | { |
1364 | fs.Close(); | 1381 | fs.Read(data, 0, data.Length); |
1382 | fs.Close(); | ||
1383 | } | ||
1365 | 1384 | ||
1366 | assem = System.Convert.ToBase64String(data); | 1385 | assem = System.Convert.ToBase64String(data); |
1367 | } | 1386 | } |
@@ -1377,13 +1396,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1377 | 1396 | ||
1378 | if (File.Exists(fn + ".map")) | 1397 | if (File.Exists(fn + ".map")) |
1379 | { | 1398 | { |
1380 | FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read); | 1399 | using (FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read)) |
1381 | StreamReader msr = new StreamReader(mfs); | 1400 | { |
1382 | 1401 | using (StreamReader msr = new StreamReader(mfs)) | |
1383 | map = msr.ReadToEnd(); | 1402 | { |
1384 | 1403 | map = msr.ReadToEnd(); | |
1385 | msr.Close(); | 1404 | msr.Close(); |
1386 | mfs.Close(); | 1405 | } |
1406 | mfs.Close(); | ||
1407 | } | ||
1387 | } | 1408 | } |
1388 | 1409 | ||
1389 | XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); | 1410 | XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); |
@@ -1471,30 +1492,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1471 | { | 1492 | { |
1472 | Byte[] filedata = Convert.FromBase64String(base64); | 1493 | Byte[] filedata = Convert.FromBase64String(base64); |
1473 | 1494 | ||
1474 | FileStream fs = File.Create(path); | 1495 | try |
1475 | fs.Write(filedata, 0, filedata.Length); | 1496 | { |
1476 | fs.Close(); | 1497 | using (FileStream fs = File.Create(path)) |
1477 | 1498 | { | |
1478 | fs = File.Create(path + ".text"); | 1499 | fs.Write(filedata, 0, filedata.Length); |
1479 | StreamWriter sw = new StreamWriter(fs); | 1500 | fs.Close(); |
1480 | 1501 | } | |
1481 | sw.Write(base64); | 1502 | } |
1482 | 1503 | catch (IOException ex) | |
1483 | sw.Close(); | 1504 | { |
1484 | fs.Close(); | 1505 | // if there already exists a file at that location, it may be locked. |
1506 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); | ||
1507 | } | ||
1508 | try | ||
1509 | { | ||
1510 | using (FileStream fs = File.Create(path + ".text")) | ||
1511 | { | ||
1512 | using (StreamWriter sw = new StreamWriter(fs)) | ||
1513 | { | ||
1514 | sw.Write(base64); | ||
1515 | sw.Close(); | ||
1516 | } | ||
1517 | fs.Close(); | ||
1518 | } | ||
1519 | } | ||
1520 | catch (IOException ex) | ||
1521 | { | ||
1522 | // if there already exists a file at that location, it may be locked. | ||
1523 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); | ||
1524 | } | ||
1485 | } | 1525 | } |
1486 | } | 1526 | } |
1487 | 1527 | ||
1488 | string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | 1528 | string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); |
1489 | statepath = Path.Combine(statepath, itemID.ToString() + ".state"); | 1529 | statepath = Path.Combine(statepath, itemID.ToString() + ".state"); |
1490 | 1530 | ||
1491 | FileStream sfs = File.Create(statepath); | 1531 | try |
1492 | StreamWriter ssw = new StreamWriter(sfs); | 1532 | { |
1493 | 1533 | using (FileStream sfs = File.Create(statepath)) | |
1494 | ssw.Write(stateE.OuterXml); | 1534 | { |
1495 | 1535 | using (StreamWriter ssw = new StreamWriter(sfs)) | |
1496 | ssw.Close(); | 1536 | { |
1497 | sfs.Close(); | 1537 | ssw.Write(stateE.OuterXml); |
1538 | ssw.Close(); | ||
1539 | } | ||
1540 | sfs.Close(); | ||
1541 | } | ||
1542 | } | ||
1543 | catch (IOException ex) | ||
1544 | { | ||
1545 | // if there already exists a file at that location, it may be locked. | ||
1546 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); | ||
1547 | } | ||
1498 | 1548 | ||
1499 | XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); | 1549 | XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); |
1500 | if (mapL.Count > 0) | 1550 | if (mapL.Count > 0) |
@@ -1504,13 +1554,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1504 | string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | 1554 | string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); |
1505 | mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); | 1555 | mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); |
1506 | 1556 | ||
1507 | FileStream mfs = File.Create(mappath); | 1557 | try |
1508 | StreamWriter msw = new StreamWriter(mfs); | 1558 | { |
1509 | 1559 | using (FileStream mfs = File.Create(mappath)) | |
1510 | msw.Write(mapE.InnerText); | 1560 | { |
1511 | 1561 | using (StreamWriter msw = new StreamWriter(mfs)) | |
1512 | msw.Close(); | 1562 | { |
1513 | mfs.Close(); | 1563 | msw.Write(mapE.InnerText); |
1564 | msw.Close(); | ||
1565 | } | ||
1566 | mfs.Close(); | ||
1567 | } | ||
1568 | } | ||
1569 | catch (IOException ex) | ||
1570 | { | ||
1571 | // if there already exists a file at that location, it may be locked. | ||
1572 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); | ||
1573 | } | ||
1514 | } | 1574 | } |
1515 | 1575 | ||
1516 | return true; | 1576 | return true; |