diff options
author | Adam Johnson | 2008-06-07 17:43:07 +0000 |
---|---|---|
committer | Adam Johnson | 2008-06-07 17:43:07 +0000 |
commit | 990225a4ba79ca05bacc293c416bd4efb6954f48 (patch) | |
tree | da6bdb8d8a48f6aad23458953303c2c48011194f /OpenSim/Region/ScriptEngine | |
parent | Mantis#1476. Thank you kindly, Melanie for a patch that: (diff) | |
download | opensim-SC-990225a4ba79ca05bacc293c416bd4efb6954f48.zip opensim-SC-990225a4ba79ca05bacc293c416bd4efb6954f48.tar.gz opensim-SC-990225a4ba79ca05bacc293c416bd4efb6954f48.tar.bz2 opensim-SC-990225a4ba79ca05bacc293c416bd4efb6954f48.tar.xz |
Patch for mantis#1493: Several patches to xengine. Thanks Melanie!
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/Compiler.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs | 156 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs | 60 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 104 |
4 files changed, 278 insertions, 53 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs b/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs index 3ff7ce0..68fb1dd 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs | |||
@@ -257,7 +257,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
257 | // FilePrefix + "_compiled_" + asset + ".dll"); | 257 | // FilePrefix + "_compiled_" + asset + ".dll"); |
258 | 258 | ||
259 | if (File.Exists(OutFile)) | 259 | if (File.Exists(OutFile)) |
260 | { | ||
261 | m_scriptEngine.Log.DebugFormat("[XEngine] Returning existing assembly for {0}", asset); | ||
260 | return OutFile; | 262 | return OutFile; |
263 | } | ||
261 | 264 | ||
262 | if (!Directory.Exists(ScriptEnginesPath)) | 265 | if (!Directory.Exists(ScriptEnginesPath)) |
263 | { | 266 | { |
@@ -422,9 +425,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
422 | string srcFileName = FilePrefix + "_source_" + Path.GetFileNameWithoutExtension(OutFile) + ext; | 425 | string srcFileName = FilePrefix + "_source_" + Path.GetFileNameWithoutExtension(OutFile) + ext; |
423 | try | 426 | try |
424 | { | 427 | { |
425 | File.WriteAllText( | 428 | File.WriteAllText(Path.Combine(Path.Combine( |
426 | Path.Combine("ScriptEngines", srcFileName), | 429 | ScriptEnginesPath, |
427 | Script); | 430 | m_scriptEngine.World.RegionInfo.RegionID.ToString()), |
431 | srcFileName), Script); | ||
428 | } | 432 | } |
429 | catch (Exception ex) // NOTLEGIT - Should be just catching FileIOException | 433 | catch (Exception ex) // NOTLEGIT - Should be just catching FileIOException |
430 | { | 434 | { |
@@ -504,6 +508,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
504 | errtext += "No compile error. But not able to locate compiled file."; | 508 | errtext += "No compile error. But not able to locate compiled file."; |
505 | throw new Exception(errtext); | 509 | throw new Exception(errtext); |
506 | } | 510 | } |
511 | m_scriptEngine.Log.DebugFormat("[XEngine] Compiled new assembly for {0}", asset); | ||
507 | return OutFile; | 512 | return OutFile; |
508 | } | 513 | } |
509 | } | 514 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs index 3fb0ff9..bf0e14e 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs | |||
@@ -31,8 +31,10 @@ using System.Collections.Generic; | |||
31 | using System.Runtime.Remoting.Lifetime; | 31 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 32 | using System.Text; |
33 | using System.Threading; | 33 | using System.Threading; |
34 | using Nini.Config; | ||
34 | using Axiom.Math; | 35 | using Axiom.Math; |
35 | using libsecondlife; | 36 | using libsecondlife; |
37 | using OpenSim; | ||
36 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
37 | using OpenSim.Region.Environment; | 39 | using OpenSim.Region.Environment; |
38 | using OpenSim.Region.Environment.Interfaces; | 40 | using OpenSim.Region.Environment.Interfaces; |
@@ -973,6 +975,78 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
973 | } | 975 | } |
974 | } | 976 | } |
975 | 977 | ||
978 | private void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | ||
979 | float wind, float tension, LSL_Types.Vector3 Force) | ||
980 | { | ||
981 | if (part == null) | ||
982 | return; | ||
983 | |||
984 | bool needs_fakedelete = false; | ||
985 | if (flexi) | ||
986 | { | ||
987 | if (!part.Shape.FlexiEntry) | ||
988 | { | ||
989 | needs_fakedelete = true; | ||
990 | } | ||
991 | part.Shape.FlexiEntry = true; // this setting flexi true isn't working, but the below parameters do | ||
992 | // work once the prim is already flexi | ||
993 | part.Shape.FlexiSoftness = softness; | ||
994 | part.Shape.FlexiGravity = gravity; | ||
995 | part.Shape.FlexiDrag = friction; | ||
996 | part.Shape.FlexiWind = wind; | ||
997 | part.Shape.FlexiTension = tension; | ||
998 | part.Shape.FlexiForceX = (float)Force.x; | ||
999 | part.Shape.FlexiForceY = (float)Force.y; | ||
1000 | part.Shape.FlexiForceZ = (float)Force.z; | ||
1001 | part.Shape.PathCurve = 0x80; | ||
1002 | |||
1003 | } | ||
1004 | else | ||
1005 | { | ||
1006 | if (part.Shape.FlexiEntry) | ||
1007 | { | ||
1008 | needs_fakedelete = true; | ||
1009 | } | ||
1010 | part.Shape.FlexiEntry = false; | ||
1011 | } | ||
1012 | |||
1013 | needs_fakedelete = false; | ||
1014 | if (needs_fakedelete) | ||
1015 | { | ||
1016 | if (part.ParentGroup != null) | ||
1017 | { | ||
1018 | part.ParentGroup.FakeDeleteGroup(); | ||
1019 | } | ||
1020 | } | ||
1021 | |||
1022 | part.ScheduleFullUpdate(); | ||
1023 | } | ||
1024 | |||
1025 | private void SetPointLight(SceneObjectPart part, bool light, LSL_Types.Vector3 color, float intensity, float radius, float falloff) | ||
1026 | { | ||
1027 | if (part == null) | ||
1028 | return; | ||
1029 | |||
1030 | if (light) | ||
1031 | { | ||
1032 | part.Shape.LightEntry = true; | ||
1033 | part.Shape.LightColorR = (float)color.x; | ||
1034 | part.Shape.LightColorG = (float)color.y; | ||
1035 | part.Shape.LightColorB = (float)color.z; | ||
1036 | part.Shape.LightIntensity = intensity; | ||
1037 | part.Shape.LightRadius = radius; | ||
1038 | part.Shape.LightFalloff = falloff; | ||
1039 | } | ||
1040 | else | ||
1041 | { | ||
1042 | part.Shape.LightEntry = false; | ||
1043 | } | ||
1044 | |||
1045 | part.ScheduleFullUpdate(); | ||
1046 | } | ||
1047 | |||
1048 | |||
1049 | |||
976 | public LSL_Types.Vector3 llGetColor(int face) | 1050 | public LSL_Types.Vector3 llGetColor(int face) |
977 | { | 1051 | { |
978 | m_host.AddScriptLPS(1); | 1052 | m_host.AddScriptLPS(1); |
@@ -4516,7 +4590,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
4516 | SetPos(part, v); | 4590 | SetPos(part, v); |
4517 | 4591 | ||
4518 | break; | 4592 | break; |
4593 | case 7: // PRIM_SIZE | ||
4594 | if (remain < 1) | ||
4595 | return; | ||
4519 | 4596 | ||
4597 | v=new LSL_Types.Vector3(rules.Data[idx++].ToString()); | ||
4598 | SetScale(part, v); | ||
4599 | |||
4600 | break; | ||
4520 | case 8: // PRIM_ROTATION | 4601 | case 8: // PRIM_ROTATION |
4521 | if (remain < 1) | 4602 | if (remain < 1) |
4522 | return; | 4603 | return; |
@@ -4555,13 +4636,31 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
4555 | SetAlpha(part, alpha, face); | 4636 | SetAlpha(part, alpha, face); |
4556 | 4637 | ||
4557 | break; | 4638 | break; |
4558 | 4639 | case 21: // PRIM_FLEXI | |
4559 | case 7: // PRIM_SIZE | 4640 | if (remain < 7) |
4560 | if (remain < 1) | ||
4561 | return; | 4641 | return; |
4562 | 4642 | ||
4563 | v=new LSL_Types.Vector3(rules.Data[idx++].ToString()); | 4643 | int flexi = Convert.ToInt32(rules.Data[idx++]); |
4564 | SetScale(part, v); | 4644 | int softness = Convert.ToInt32(rules.Data[idx++]); |
4645 | float gravity = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4646 | float friction = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4647 | float wind = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4648 | float tension = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4649 | LSL_Types.Vector3 force =new LSL_Types.Vector3(rules.Data[idx++].ToString()); | ||
4650 | |||
4651 | SetFlexi(part, (flexi == 1), softness, gravity, friction, wind, tension, force); | ||
4652 | |||
4653 | break; | ||
4654 | case 23: // PRIM_POINT_LIGHT | ||
4655 | if (remain < 5) | ||
4656 | return; | ||
4657 | int light = Convert.ToInt32(rules.Data[idx++]); | ||
4658 | LSL_Types.Vector3 lightcolor =new LSL_Types.Vector3(rules.Data[idx++].ToString()); | ||
4659 | float intensity = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4660 | float radius = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4661 | float falloff = (float)Convert.ToDouble(rules.Data[idx++]); | ||
4662 | |||
4663 | SetPointLight(part, (light == 1), lightcolor, intensity, radius, falloff); | ||
4565 | 4664 | ||
4566 | break; | 4665 | break; |
4567 | } | 4666 | } |
@@ -5466,30 +5565,39 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
5466 | public void llSetObjectPermMask(int mask, int value) | 5565 | public void llSetObjectPermMask(int mask, int value) |
5467 | { | 5566 | { |
5468 | m_host.AddScriptLPS(1); | 5567 | m_host.AddScriptLPS(1); |
5469 | 5568 | IConfigSource config = new IniConfigSource(Application.iniFilePath); | |
5470 | if (mask == BuiltIn_Commands_BaseClass.MASK_BASE)//0 | 5569 | if (config.Configs["XEngine"] == null) |
5570 | config.AddConfig("XEngine"); | ||
5571 | |||
5572 | if (config.Configs["XEngine"].GetBoolean("AllowGodFunctions", false)) | ||
5471 | { | 5573 | { |
5472 | m_host.BaseMask = (uint)value; | 5574 | if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID)) |
5473 | } | 5575 | { |
5576 | if (mask == BuiltIn_Commands_BaseClass.MASK_BASE)//0 | ||
5577 | { | ||
5578 | m_host.BaseMask = (uint)value; | ||
5579 | } | ||
5474 | 5580 | ||
5475 | else if (mask == BuiltIn_Commands_BaseClass.MASK_OWNER)//1 | 5581 | else if (mask == BuiltIn_Commands_BaseClass.MASK_OWNER)//1 |
5476 | { | 5582 | { |
5477 | m_host.OwnerMask = (uint)value; | 5583 | m_host.OwnerMask = (uint)value; |
5478 | } | 5584 | } |
5479 | 5585 | ||
5480 | else if (mask == BuiltIn_Commands_BaseClass.MASK_GROUP)//2 | 5586 | else if (mask == BuiltIn_Commands_BaseClass.MASK_GROUP)//2 |
5481 | { | 5587 | { |
5482 | m_host.GroupMask = (uint)value; | 5588 | m_host.GroupMask = (uint)value; |
5483 | } | 5589 | } |
5484 | 5590 | ||
5485 | else if (mask == BuiltIn_Commands_BaseClass.MASK_EVERYONE)//3 | 5591 | else if (mask == BuiltIn_Commands_BaseClass.MASK_EVERYONE)//3 |
5486 | { | 5592 | { |
5487 | m_host.EveryoneMask = (uint)value; | 5593 | m_host.EveryoneMask = (uint)value; |
5488 | } | 5594 | } |
5489 | 5595 | ||
5490 | else if (mask == BuiltIn_Commands_BaseClass.MASK_NEXT)//4 | 5596 | else if (mask == BuiltIn_Commands_BaseClass.MASK_NEXT)//4 |
5491 | { | 5597 | { |
5492 | m_host.NextOwnerMask = (uint)value; | 5598 | m_host.NextOwnerMask = (uint)value; |
5599 | } | ||
5600 | } | ||
5493 | } | 5601 | } |
5494 | } | 5602 | } |
5495 | 5603 | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs b/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs index 107d493..a325629 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs | |||
@@ -425,6 +425,30 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script | |||
425 | return new list(tmp); | 425 | return new list(tmp); |
426 | } | 426 | } |
427 | 427 | ||
428 | private void ExtendAndAdd(object o) | ||
429 | { | ||
430 | Array.Resize(ref m_data, Length + 1); | ||
431 | m_data.SetValue(o, Length - 1); | ||
432 | } | ||
433 | |||
434 | public static list operator +(list a, string s) | ||
435 | { | ||
436 | a.ExtendAndAdd(s); | ||
437 | return a; | ||
438 | } | ||
439 | |||
440 | public static list operator +(list a, int i) | ||
441 | { | ||
442 | a.ExtendAndAdd(i); | ||
443 | return a; | ||
444 | } | ||
445 | |||
446 | public static list operator +(list a, double d) | ||
447 | { | ||
448 | a.ExtendAndAdd(d); | ||
449 | return a; | ||
450 | } | ||
451 | |||
428 | public void Add(object o) | 452 | public void Add(object o) |
429 | { | 453 | { |
430 | object[] tmp; | 454 | object[] tmp; |
@@ -1321,6 +1345,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script | |||
1321 | return (double)i.value; | 1345 | return (double)i.value; |
1322 | } | 1346 | } |
1323 | 1347 | ||
1348 | static public implicit operator LSLFloat(LSLInteger i) | ||
1349 | { | ||
1350 | return new LSLFloat((double)i.value); | ||
1351 | } | ||
1352 | |||
1324 | public static bool operator true(LSLInteger i) | 1353 | public static bool operator true(LSLInteger i) |
1325 | { | 1354 | { |
1326 | return i.value != 0; | 1355 | return i.value != 0; |
@@ -1370,12 +1399,28 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script | |||
1370 | 1399 | ||
1371 | public LSLFloat(int i) | 1400 | public LSLFloat(int i) |
1372 | { | 1401 | { |
1373 | this.value = (double)i; | 1402 | value = (double)i; |
1374 | } | 1403 | } |
1375 | 1404 | ||
1376 | public LSLFloat(double d) | 1405 | public LSLFloat(double d) |
1377 | { | 1406 | { |
1378 | this.value = d; | 1407 | value = d; |
1408 | } | ||
1409 | |||
1410 | public LSLFloat(string s) | ||
1411 | { | ||
1412 | value = double.Parse(s); | ||
1413 | } | ||
1414 | |||
1415 | public LSLFloat(Object o) | ||
1416 | { | ||
1417 | if(!((o is double) || (o is float))) | ||
1418 | { | ||
1419 | value = 0.0; | ||
1420 | return; | ||
1421 | } | ||
1422 | |||
1423 | value = (double)o; | ||
1379 | } | 1424 | } |
1380 | 1425 | ||
1381 | #endregion | 1426 | #endregion |
@@ -1445,11 +1490,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script | |||
1445 | { | 1490 | { |
1446 | return f.value; | 1491 | return f.value; |
1447 | } | 1492 | } |
1448 | 1493 | ||
1449 | //static public implicit operator System.Int32(LSLFloat f) | 1494 | static public explicit operator LSLString(LSLFloat f) |
1450 | //{ | 1495 | { |
1451 | // return (int)f.value; | 1496 | string v = String.Format("{0:0.000000}", f.value); |
1452 | //} | 1497 | return new LSLString(v); |
1498 | } | ||
1453 | 1499 | ||
1454 | #endregion | 1500 | #endregion |
1455 | 1501 | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 0a6de60..1b49baa 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -314,8 +314,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
314 | { | 314 | { |
315 | assembly = m_Compiler.PerformScriptCompile(script, | 315 | assembly = m_Compiler.PerformScriptCompile(script, |
316 | assetID.ToString()); | 316 | assetID.ToString()); |
317 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", | ||
318 | part.ParentGroup.RootPart.Name, item.Name); | ||
319 | } | 317 | } |
320 | catch (Exception e) | 318 | catch (Exception e) |
321 | { | 319 | { |
@@ -387,8 +385,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
387 | m_DomainScripts[appDomain].Add(itemID); | 385 | m_DomainScripts[appDomain].Add(itemID); |
388 | 386 | ||
389 | XScriptInstance instance = new XScriptInstance(this,localID, | 387 | XScriptInstance instance = new XScriptInstance(this,localID, |
390 | part.UUID, itemID, assetID, assembly, | 388 | part.UUID, itemID, assetID, assembly, |
391 | m_AppDomains[appDomain]); | 389 | m_AppDomains[appDomain], |
390 | part.ParentGroup.RootPart.Name, | ||
391 | item.Name); | ||
392 | |||
393 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", | ||
394 | part.ParentGroup.RootPart.Name, item.Name); | ||
392 | 395 | ||
393 | instance.AppDomain = appDomain; | 396 | instance.AppDomain = appDomain; |
394 | 397 | ||
@@ -450,6 +453,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
450 | UnloadAppDomain(instance.AppDomain); | 453 | UnloadAppDomain(instance.AppDomain); |
451 | } | 454 | } |
452 | 455 | ||
456 | instance.RemoveState(); | ||
457 | |||
453 | instance = null; | 458 | instance = null; |
454 | 459 | ||
455 | CleanAssemblies(); | 460 | CleanAssemblies(); |
@@ -706,6 +711,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
706 | private bool m_TimerQueued; | 711 | private bool m_TimerQueued; |
707 | private DateTime m_EventStart; | 712 | private DateTime m_EventStart; |
708 | private bool m_InEvent; | 713 | private bool m_InEvent; |
714 | private string m_PrimName; | ||
715 | private string m_ScriptName; | ||
716 | private string m_Assembly; | ||
709 | 717 | ||
710 | // Script state | 718 | // Script state |
711 | private string m_State="default"; | 719 | private string m_State="default"; |
@@ -715,6 +723,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
715 | public bool Running | 723 | public bool Running |
716 | { | 724 | { |
717 | get { return m_RunEvents; } | 725 | get { return m_RunEvents; } |
726 | set { m_RunEvents = value; } | ||
718 | } | 727 | } |
719 | 728 | ||
720 | public string State | 729 | public string State |
@@ -734,6 +743,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
734 | set { m_AppDomain = value; } | 743 | set { m_AppDomain = value; } |
735 | } | 744 | } |
736 | 745 | ||
746 | public string PrimName | ||
747 | { | ||
748 | get { return m_PrimName; } | ||
749 | } | ||
750 | |||
751 | public string ScriptName | ||
752 | { | ||
753 | get { return m_ScriptName; } | ||
754 | } | ||
755 | |||
737 | public LLUUID ItemID | 756 | public LLUUID ItemID |
738 | { | 757 | { |
739 | get { return m_ItemID; } | 758 | get { return m_ItemID; } |
@@ -766,7 +785,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
766 | } | 785 | } |
767 | 786 | ||
768 | public XScriptInstance(XEngine engine, uint localID, LLUUID objectID, | 787 | public XScriptInstance(XEngine engine, uint localID, LLUUID objectID, |
769 | LLUUID itemID, LLUUID assetID, string assembly, AppDomain dom) | 788 | LLUUID itemID, LLUUID assetID, string assembly, AppDomain dom, |
789 | string primName, string scriptName) | ||
770 | { | 790 | { |
771 | m_Engine = engine; | 791 | m_Engine = engine; |
772 | 792 | ||
@@ -774,6 +794,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
774 | m_ObjectID = objectID; | 794 | m_ObjectID = objectID; |
775 | m_ItemID = itemID; | 795 | m_ItemID = itemID; |
776 | m_AssetID = assetID; | 796 | m_AssetID = assetID; |
797 | m_PrimName = primName; | ||
798 | m_ScriptName = scriptName; | ||
799 | m_Assembly = assembly; | ||
777 | 800 | ||
778 | SceneObjectPart part=engine.World.GetSceneObjectPart(localID); | 801 | SceneObjectPart part=engine.World.GetSceneObjectPart(localID); |
779 | if (part == null) | 802 | if (part == null) |
@@ -811,10 +834,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
811 | } | 834 | } |
812 | catch (Exception e) | 835 | catch (Exception e) |
813 | { | 836 | { |
814 | m_Engine.Log.Error("Error loading script instance\n"+e.ToString()); | 837 | m_Engine.Log.Error("[XEngine] Error loading script instance\n"+e.ToString()); |
838 | return; | ||
815 | } | 839 | } |
816 | 840 | ||
817 | string savedState = assembly + ".state"; | 841 | string savedState = Path.Combine(Path.GetDirectoryName(assembly), |
842 | m_ItemID.ToString() + ".state"); | ||
818 | if (File.Exists(savedState)) | 843 | if (File.Exists(savedState)) |
819 | { | 844 | { |
820 | string xml = String.Empty; | 845 | string xml = String.Empty; |
@@ -841,28 +866,53 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
841 | m_Engine.m_ASYNCLSLCommandManager.CreateFromData( | 866 | m_Engine.m_ASYNCLSLCommandManager.CreateFromData( |
842 | m_LocalID, m_ItemID, m_ObjectID, | 867 | m_LocalID, m_ItemID, m_ObjectID, |
843 | PluginData); | 868 | PluginData); |
869 | |||
870 | m_Engine.Log.DebugFormat("[XEngine] Successfully retrieved state for script {0}.{1}", m_PrimName, m_ScriptName); | ||
871 | |||
872 | if(m_RunEvents) | ||
873 | { | ||
874 | m_RunEvents = false; | ||
875 | Start(); | ||
876 | } | ||
844 | } | 877 | } |
845 | } | 878 | } |
846 | else | 879 | else |
847 | { | 880 | { |
848 | m_Engine.Log.Error("Unable to load script state: Memory limit exceeded"); | 881 | m_Engine.Log.Error("[XEngine] Unable to load script state: Memory limit exceeded"); |
849 | PostEvent(new XEventParams("state_entry", | 882 | PostEvent(new XEventParams("state_entry", |
850 | new Object[0], new XDetectParams[0])); | 883 | new Object[0], new XDetectParams[0])); |
884 | Start(); | ||
851 | } | 885 | } |
852 | } | 886 | } |
853 | catch (Exception e) | 887 | catch (Exception e) |
854 | { | 888 | { |
855 | m_Engine.Log.ErrorFormat("Unable to load script state from xml: {0}\n"+e.ToString(), xml); | 889 | m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state from xml: {0}\n"+e.ToString(), xml); |
856 | PostEvent(new XEventParams("state_entry", | 890 | PostEvent(new XEventParams("state_entry", |
857 | new Object[0], new XDetectParams[0])); | 891 | new Object[0], new XDetectParams[0])); |
892 | Start(); | ||
858 | } | 893 | } |
859 | } | 894 | } |
860 | else | 895 | else |
861 | { | 896 | { |
897 | m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state, file not found"); | ||
862 | PostEvent(new XEventParams("state_entry", | 898 | PostEvent(new XEventParams("state_entry", |
863 | new Object[0], new XDetectParams[0])); | 899 | new Object[0], new XDetectParams[0])); |
900 | Start(); | ||
901 | } | ||
902 | } | ||
903 | |||
904 | public void RemoveState() | ||
905 | { | ||
906 | string savedState = Path.Combine(Path.GetDirectoryName(m_Assembly), | ||
907 | m_ItemID.ToString() + ".state"); | ||
908 | |||
909 | try | ||
910 | { | ||
911 | File.Delete(savedState); | ||
912 | } | ||
913 | catch(Exception) | ||
914 | { | ||
864 | } | 915 | } |
865 | Start(); | ||
866 | } | 916 | } |
867 | 917 | ||
868 | public void VarDump(Dictionary<string, object> vars) | 918 | public void VarDump(Dictionary<string, object> vars) |
@@ -935,16 +985,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
935 | 985 | ||
936 | result.Abort(); | 986 | result.Abort(); |
937 | 987 | ||
938 | if (SmartThreadPool.WaitAll(new IWorkItemResult[] {result}, new TimeSpan((long)10000000), false)) | 988 | lock (m_EventQueue) |
939 | { | 989 | { |
940 | lock (m_EventQueue) | 990 | m_CurrentResult = null; |
941 | { | ||
942 | m_CurrentResult = null; | ||
943 | } | ||
944 | return true; | ||
945 | } | 991 | } |
946 | 992 | ||
947 | m_Engine.Log.Error("[XEngine] Failed to reliably stop script"); | ||
948 | return true; | 993 | return true; |
949 | } | 994 | } |
950 | 995 | ||
@@ -960,6 +1005,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
960 | 1005 | ||
961 | public void PostEvent(XEventParams data) | 1006 | public void PostEvent(XEventParams data) |
962 | { | 1007 | { |
1008 | // m_Engine.Log.DebugFormat("[XEngine] Posted event {2} in state {3} to {0}.{1}", | ||
1009 | // m_PrimName, m_ScriptName, data.EventName, m_State); | ||
963 | lock (m_EventQueue) | 1010 | lock (m_EventQueue) |
964 | { | 1011 | { |
965 | if (m_EventQueue.Count >= m_Engine.MaxScriptQueue) | 1012 | if (m_EventQueue.Count >= m_Engine.MaxScriptQueue) |
@@ -1003,6 +1050,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1003 | 1050 | ||
1004 | if (data.EventName == "state") // Hardcoded state change | 1051 | if (data.EventName == "state") // Hardcoded state change |
1005 | { | 1052 | { |
1053 | // m_Engine.Log.DebugFormat("[XEngine] Script {0}.{1} state set to {2}", | ||
1054 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); | ||
1006 | m_State=data.Params[0].ToString(); | 1055 | m_State=data.Params[0].ToString(); |
1007 | m_Engine.m_ASYNCLSLCommandManager.RemoveScript( | 1056 | m_Engine.m_ASYNCLSLCommandManager.RemoveScript( |
1008 | m_LocalID, m_ItemID); | 1057 | m_LocalID, m_ItemID); |
@@ -1020,6 +1069,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1020 | // m_Engine.Log.DebugFormat("[XEngine] Processed event {0}", data.EventName); | 1069 | // m_Engine.Log.DebugFormat("[XEngine] Processed event {0}", data.EventName); |
1021 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 1070 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( |
1022 | m_LocalID); | 1071 | m_LocalID); |
1072 | // m_Engine.Log.DebugFormat("[XEngine] Delivered event {2} in state {3} to {0}.{1}", | ||
1073 | // m_PrimName, m_ScriptName, data.EventName, m_State); | ||
1074 | |||
1023 | try | 1075 | try |
1024 | { | 1076 | { |
1025 | m_EventStart = DateTime.Now; | 1077 | m_EventStart = DateTime.Now; |
@@ -1148,14 +1200,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1148 | 1200 | ||
1149 | try | 1201 | try |
1150 | { | 1202 | { |
1151 | FileStream fs = File.Create(assembly + ".state"); | 1203 | FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state")); |
1152 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | 1204 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); |
1153 | Byte[] buf = enc.GetBytes(xml); | 1205 | Byte[] buf = enc.GetBytes(xml); |
1154 | fs.Write(buf, 0, buf.Length); | 1206 | fs.Write(buf, 0, buf.Length); |
1155 | fs.Close(); | 1207 | fs.Close(); |
1156 | } | 1208 | } |
1157 | catch(Exception) | 1209 | catch(Exception e) |
1210 | { | ||
1211 | Console.WriteLine("Unable to save xml\n"+e.ToString()); | ||
1212 | } | ||
1213 | if(!File.Exists(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state"))) | ||
1158 | { | 1214 | { |
1215 | throw new Exception("Completed persistence save, but no file was created"); | ||
1159 | } | 1216 | } |
1160 | } | 1217 | } |
1161 | } | 1218 | } |
@@ -1181,6 +1238,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1181 | 1238 | ||
1182 | rootElement.AppendChild(state); | 1239 | rootElement.AppendChild(state); |
1183 | 1240 | ||
1241 | XmlElement running = xmldoc.CreateElement("", "Running", ""); | ||
1242 | running.AppendChild(xmldoc.CreateTextNode( | ||
1243 | instance.Running.ToString())); | ||
1244 | |||
1245 | rootElement.AppendChild(running); | ||
1246 | |||
1184 | Dictionary<string, Object> vars = instance.GetVars(); | 1247 | Dictionary<string, Object> vars = instance.GetVars(); |
1185 | 1248 | ||
1186 | XmlElement variables = xmldoc.CreateElement("", "Variables", ""); | 1249 | XmlElement variables = xmldoc.CreateElement("", "Variables", ""); |
@@ -1277,6 +1340,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1277 | case "State": | 1340 | case "State": |
1278 | instance.State=part.InnerText; | 1341 | instance.State=part.InnerText; |
1279 | break; | 1342 | break; |
1343 | case "Running": | ||
1344 | instance.Running=bool.Parse(part.InnerText); | ||
1345 | break; | ||
1280 | case "Variables": | 1346 | case "Variables": |
1281 | XmlNodeList varL = part.ChildNodes; | 1347 | XmlNodeList varL = part.ChildNodes; |
1282 | foreach (XmlNode var in varL) | 1348 | foreach (XmlNode var in varL) |