diff options
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
28 files changed, 1298 insertions, 365 deletions
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index d3200d5..b04f6b6 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | |||
@@ -68,14 +68,48 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
68 | /// </summary> | 68 | /// </summary> |
69 | bool Suspended { get; set; } | 69 | bool Suspended { get; set; } |
70 | 70 | ||
71 | /// <summary> | ||
72 | /// Is the script shutting down? | ||
73 | /// </summary> | ||
71 | bool ShuttingDown { get; set; } | 74 | bool ShuttingDown { get; set; } |
75 | |||
76 | /// <summary> | ||
77 | /// Script state | ||
78 | /// </summary> | ||
72 | string State { get; set; } | 79 | string State { get; set; } |
80 | |||
81 | /// <summary> | ||
82 | /// Time the script was last started | ||
83 | /// </summary> | ||
84 | DateTime TimeStarted { get; } | ||
85 | |||
86 | /// <summary> | ||
87 | /// Tick the last measurement period was started. | ||
88 | /// </summary> | ||
89 | long MeasurementPeriodTickStart { get; } | ||
90 | |||
91 | /// <summary> | ||
92 | /// Ticks spent executing in the last measurement period. | ||
93 | /// </summary> | ||
94 | long MeasurementPeriodExecutionTime { get; } | ||
95 | |||
73 | IScriptEngine Engine { get; } | 96 | IScriptEngine Engine { get; } |
74 | UUID AppDomain { get; set; } | 97 | UUID AppDomain { get; set; } |
75 | string PrimName { get; } | 98 | string PrimName { get; } |
76 | string ScriptName { get; } | 99 | string ScriptName { get; } |
77 | UUID ItemID { get; } | 100 | UUID ItemID { get; } |
78 | UUID ObjectID { get; } | 101 | UUID ObjectID { get; } |
102 | |||
103 | /// <summary> | ||
104 | /// UUID of the root object for the linkset that the script is in. | ||
105 | /// </summary> | ||
106 | UUID RootObjectID { get; } | ||
107 | |||
108 | /// <summary> | ||
109 | /// Local id of the root object for the linkset that the script is in. | ||
110 | /// </summary> | ||
111 | uint RootLocalID { get; } | ||
112 | |||
79 | uint LocalID { get; } | 113 | uint LocalID { get; } |
80 | UUID AssetID { get; } | 114 | UUID AssetID { get; } |
81 | Queue EventQueue { get; } | 115 | Queue EventQueue { get; } |
@@ -89,7 +123,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
89 | void Start(); | 123 | void Start(); |
90 | 124 | ||
91 | /// <summary> | 125 | /// <summary> |
92 | /// Stop the script. | 126 | /// Stop the script instance. |
93 | /// </summary> | 127 | /// </summary> |
94 | /// <param name="timeout"></param> | 128 | /// <param name="timeout"></param> |
95 | /// <returns>true if the script was successfully stopped, false otherwise</returns> | 129 | /// <returns>true if the script was successfully stopped, false otherwise</returns> |
@@ -97,13 +131,17 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
97 | 131 | ||
98 | void SetState(string state); | 132 | void SetState(string state); |
99 | 133 | ||
134 | /// <summary> | ||
135 | /// Post an event to this script instance. | ||
136 | /// </summary> | ||
137 | /// <param name="data"></param> | ||
100 | void PostEvent(EventParams data); | 138 | void PostEvent(EventParams data); |
101 | 139 | ||
102 | void Suspend(); | 140 | void Suspend(); |
103 | void Resume(); | 141 | void Resume(); |
104 | 142 | ||
105 | /// <summary> | 143 | /// <summary> |
106 | /// Process the next event queued for this script | 144 | /// Process the next event queued for this script instance. |
107 | /// </summary> | 145 | /// </summary> |
108 | /// <returns></returns> | 146 | /// <returns></returns> |
109 | object EventProcessor(); | 147 | object EventProcessor(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 14edde4..993d10f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs | |||
@@ -247,7 +247,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
247 | 247 | ||
248 | // Remove Sensors | 248 | // Remove Sensors |
249 | m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); | 249 | m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); |
250 | } | ||
251 | |||
252 | /// <summary> | ||
253 | /// Get the sensor repeat plugin for this script engine. | ||
254 | /// </summary> | ||
255 | /// <param name="engine"></param> | ||
256 | /// <returns></returns> | ||
257 | public static SensorRepeat GetSensorRepeatPlugin(IScriptEngine engine) | ||
258 | { | ||
259 | if (m_SensorRepeat.ContainsKey(engine)) | ||
260 | return m_SensorRepeat[engine]; | ||
261 | else | ||
262 | return null; | ||
263 | } | ||
250 | 264 | ||
265 | /// <summary> | ||
266 | /// Get the dataserver plugin for this script engine. | ||
267 | /// </summary> | ||
268 | /// <param name="engine"></param> | ||
269 | /// <returns></returns> | ||
270 | public static Dataserver GetDataserverPlugin(IScriptEngine engine) | ||
271 | { | ||
272 | if (m_Dataserver.ContainsKey(engine)) | ||
273 | return m_Dataserver[engine]; | ||
274 | else | ||
275 | return null; | ||
276 | } | ||
277 | |||
278 | /// <summary> | ||
279 | /// Get the timer plugin for this script engine. | ||
280 | /// </summary> | ||
281 | /// <param name="engine"></param> | ||
282 | /// <returns></returns> | ||
283 | public static Timer GetTimerPlugin(IScriptEngine engine) | ||
284 | { | ||
285 | if (m_Timer.ContainsKey(engine)) | ||
286 | return m_Timer[engine]; | ||
287 | else | ||
288 | return null; | ||
289 | } | ||
290 | |||
291 | /// <summary> | ||
292 | /// Get the listener plugin for this script engine. | ||
293 | /// </summary> | ||
294 | /// <param name="engine"></param> | ||
295 | /// <returns></returns> | ||
296 | public static Listener GetListenerPlugin(IScriptEngine engine) | ||
297 | { | ||
298 | if (m_Listener.ContainsKey(engine)) | ||
299 | return m_Listener[engine]; | ||
300 | else | ||
301 | return null; | ||
251 | } | 302 | } |
252 | 303 | ||
253 | public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) | 304 | public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) |
@@ -270,7 +321,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
270 | data.AddRange(timers); | 321 | data.AddRange(timers); |
271 | } | 322 | } |
272 | 323 | ||
273 | Object[] sensors=m_SensorRepeat[engine].GetSerializationData(itemID); | 324 | Object[] sensors = m_SensorRepeat[engine].GetSerializationData(itemID); |
274 | if (sensors.Length > 0) | 325 | if (sensors.Length > 0) |
275 | { | 326 | { |
276 | data.Add("sensor"); | 327 | data.Add("sensor"); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0003515..d7a629b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -2771,64 +2771,69 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2771 | { | 2771 | { |
2772 | m_host.AddScriptLPS(1); | 2772 | m_host.AddScriptLPS(1); |
2773 | 2773 | ||
2774 | if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) | 2774 | Util.FireAndForget(delegate (object x) |
2775 | return; | 2775 | { |
2776 | float dist = (float)llVecDist(llGetPos(), pos); | 2776 | if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) |
2777 | return; | ||
2778 | float dist = (float)llVecDist(llGetPos(), pos); | ||
2777 | 2779 | ||
2778 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2780 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2779 | return; | 2781 | return; |
2780 | 2782 | ||
2781 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2783 | //Clone is thread-safe |
2784 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | ||
2782 | 2785 | ||
2783 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2786 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
2784 | { | ||
2785 | if (inv.Value.Name == inventory) | ||
2786 | { | 2787 | { |
2787 | // make sure we're an object. | 2788 | if (inv.Value.Name == inventory) |
2788 | if (inv.Value.InvType != (int)InventoryType.Object) | ||
2789 | { | 2789 | { |
2790 | llSay(0, "Unable to create requested object. Object is missing from database."); | 2790 | // make sure we're an object. |
2791 | return; | 2791 | if (inv.Value.InvType != (int)InventoryType.Object) |
2792 | } | 2792 | { |
2793 | llSay(0, "Unable to create requested object. Object is missing from database."); | ||
2794 | return; | ||
2795 | } | ||
2793 | 2796 | ||
2794 | Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); | 2797 | Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); |
2795 | Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); | 2798 | Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); |
2796 | 2799 | ||
2797 | // need the magnitude later | 2800 | // need the magnitude later |
2798 | float velmag = (float)Util.GetMagnitude(llvel); | 2801 | // float velmag = (float)Util.GetMagnitude(llvel); |
2799 | 2802 | ||
2800 | SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); | 2803 | SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); |
2801 | 2804 | ||
2802 | // If either of these are null, then there was an unknown error. | 2805 | // If either of these are null, then there was an unknown error. |
2803 | if (new_group == null) | 2806 | if (new_group == null) |
2804 | continue; | 2807 | continue; |
2805 | 2808 | ||
2806 | // objects rezzed with this method are die_at_edge by default. | 2809 | // objects rezzed with this method are die_at_edge by default. |
2807 | new_group.RootPart.SetDieAtEdge(true); | 2810 | new_group.RootPart.SetDieAtEdge(true); |
2808 | 2811 | ||
2809 | new_group.ResumeScripts(); | 2812 | new_group.ResumeScripts(); |
2810 | 2813 | ||
2811 | m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( | 2814 | m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( |
2812 | "object_rez", new Object[] { | 2815 | "object_rez", new Object[] { |
2813 | new LSL_String( | 2816 | new LSL_String( |
2814 | new_group.RootPart.UUID.ToString()) }, | 2817 | new_group.RootPart.UUID.ToString()) }, |
2815 | new DetectParams[0])); | 2818 | new DetectParams[0])); |
2816 | 2819 | ||
2817 | float groupmass = new_group.GetMass(); | 2820 | float groupmass = new_group.GetMass(); |
2818 | 2821 | ||
2819 | if (new_group.RootPart.PhysActor != null && new_group.RootPart.PhysActor.IsPhysical && llvel != Vector3.Zero) | 2822 | if (new_group.RootPart.PhysActor != null && new_group.RootPart.PhysActor.IsPhysical && llvel != Vector3.Zero) |
2820 | { | 2823 | { |
2821 | //Recoil. | 2824 | //Recoil. |
2822 | llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); | 2825 | llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); |
2826 | } | ||
2827 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) | ||
2828 | return; | ||
2823 | } | 2829 | } |
2824 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) | ||
2825 | ScriptSleep((int)((groupmass * velmag) / 10)); | ||
2826 | ScriptSleep(100); | ||
2827 | return; | ||
2828 | } | 2830 | } |
2829 | } | ||
2830 | 2831 | ||
2831 | llSay(0, "Could not find object " + inventory); | 2832 | llSay(0, "Could not find object " + inventory); |
2833 | }); | ||
2834 | |||
2835 | //ScriptSleep((int)((groupmass * velmag) / 10)); | ||
2836 | ScriptSleep(100); | ||
2832 | } | 2837 | } |
2833 | 2838 | ||
2834 | public void llRezObject(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) | 2839 | public void llRezObject(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) |
@@ -3820,7 +3825,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3820 | List<String> nametable = new List<String>(); | 3825 | List<String> nametable = new List<String>(); |
3821 | World.ForEachRootScenePresence(delegate(ScenePresence presence) | 3826 | World.ForEachRootScenePresence(delegate(ScenePresence presence) |
3822 | { | 3827 | { |
3823 | if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) | 3828 | SceneObjectPart sitPart = presence.ParentPart; |
3829 | if (sitPart != null && m_host.ParentGroup.HasChildPrim(sitPart.LocalId)) | ||
3824 | nametable.Add(presence.ControllingClient.Name); | 3830 | nametable.Add(presence.ControllingClient.Name); |
3825 | }); | 3831 | }); |
3826 | 3832 | ||
@@ -4308,7 +4314,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4308 | 4314 | ||
4309 | if (m_host.RegionHandle == presence.RegionHandle) | 4315 | if (m_host.RegionHandle == presence.RegionHandle) |
4310 | { | 4316 | { |
4311 | Dictionary<UUID, string> animationstateNames = AnimationSet.Animations.AnimStateNames; | 4317 | Dictionary<UUID, string> animationstateNames = DefaultAvatarAnimations.AnimStateNames; |
4312 | 4318 | ||
4313 | if (presence != null) | 4319 | if (presence != null) |
4314 | { | 4320 | { |
@@ -4388,22 +4394,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4388 | 4394 | ||
4389 | // Find pushee position | 4395 | // Find pushee position |
4390 | // Pushee Linked? | 4396 | // Pushee Linked? |
4391 | if (pusheeav.ParentID != 0) | 4397 | SceneObjectPart sitPart = pusheeav.ParentPart; |
4392 | { | 4398 | if (sitPart != null) |
4393 | SceneObjectPart parentobj = World.GetSceneObjectPart(pusheeav.ParentID); | 4399 | PusheePos = sitPart.AbsolutePosition; |
4394 | if (parentobj != null) | ||
4395 | { | ||
4396 | PusheePos = parentobj.AbsolutePosition; | ||
4397 | } | ||
4398 | else | ||
4399 | { | ||
4400 | PusheePos = pusheeav.AbsolutePosition; | ||
4401 | } | ||
4402 | } | ||
4403 | else | 4400 | else |
4404 | { | ||
4405 | PusheePos = pusheeav.AbsolutePosition; | 4401 | PusheePos = pusheeav.AbsolutePosition; |
4406 | } | ||
4407 | } | 4402 | } |
4408 | 4403 | ||
4409 | if (!pusheeIsAvatar) | 4404 | if (!pusheeIsAvatar) |
@@ -5598,14 +5593,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5598 | flags |= ScriptBaseClass.AGENT_IN_AIR; | 5593 | flags |= ScriptBaseClass.AGENT_IN_AIR; |
5599 | } | 5594 | } |
5600 | 5595 | ||
5601 | if (agent.ParentID != 0) | 5596 | if (agent.ParentPart != null) |
5602 | { | 5597 | { |
5603 | flags |= ScriptBaseClass.AGENT_ON_OBJECT; | 5598 | flags |= ScriptBaseClass.AGENT_ON_OBJECT; |
5604 | flags |= ScriptBaseClass.AGENT_SITTING; | 5599 | flags |= ScriptBaseClass.AGENT_SITTING; |
5605 | } | 5600 | } |
5606 | 5601 | ||
5607 | if (agent.Animator.Animations.DefaultAnimation.AnimID | 5602 | if (agent.Animator.Animations.DefaultAnimation.AnimID |
5608 | == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 5603 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) |
5609 | { | 5604 | { |
5610 | flags |= ScriptBaseClass.AGENT_SITTING; | 5605 | flags |= ScriptBaseClass.AGENT_SITTING; |
5611 | } | 5606 | } |
@@ -7687,7 +7682,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7687 | World.ForEachRootScenePresence(delegate(ScenePresence presence) | 7682 | World.ForEachRootScenePresence(delegate(ScenePresence presence) |
7688 | { | 7683 | { |
7689 | if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) | 7684 | if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) |
7690 | avatarCount++; | 7685 | avatarCount++; |
7691 | }); | 7686 | }); |
7692 | 7687 | ||
7693 | return m_host.ParentGroup.PrimCount + avatarCount; | 7688 | return m_host.ParentGroup.PrimCount + avatarCount; |
@@ -7719,7 +7714,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7719 | LSL_Vector lower; | 7714 | LSL_Vector lower; |
7720 | LSL_Vector upper; | 7715 | LSL_Vector upper; |
7721 | if (presence.Animator.Animations.DefaultAnimation.AnimID | 7716 | if (presence.Animator.Animations.DefaultAnimation.AnimID |
7722 | == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 7717 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) |
7723 | { | 7718 | { |
7724 | // This is for ground sitting avatars | 7719 | // This is for ground sitting avatars |
7725 | float height = presence.Appearance.AvatarHeight / 2.66666667f; | 7720 | float height = presence.Appearance.AvatarHeight / 2.66666667f; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index d4facdd..7c07e15 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -116,6 +116,159 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
116 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | 116 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); |
117 | } | 117 | } |
118 | 118 | ||
119 | /// <summary> | ||
120 | /// | ||
121 | /// </summary> | ||
122 | /// <param name="fname">The name of the function to invoke</param> | ||
123 | /// <param name="parms">List of parameters</param> | ||
124 | /// <returns>string result of the invocation</returns> | ||
125 | public void modInvokeN(string fname, params object[] parms) | ||
126 | { | ||
127 | Type returntype = m_comms.LookupReturnType(fname); | ||
128 | if (returntype != typeof(string)) | ||
129 | MODError(String.Format("return type mismatch for {0}",fname)); | ||
130 | |||
131 | modInvoke(fname,parms); | ||
132 | } | ||
133 | |||
134 | public LSL_String modInvokeS(string fname, params object[] parms) | ||
135 | { | ||
136 | Type returntype = m_comms.LookupReturnType(fname); | ||
137 | if (returntype != typeof(string)) | ||
138 | MODError(String.Format("return type mismatch for {0}",fname)); | ||
139 | |||
140 | string result = (string)modInvoke(fname,parms); | ||
141 | return new LSL_String(result); | ||
142 | } | ||
143 | |||
144 | public LSL_Integer modInvokeI(string fname, params object[] parms) | ||
145 | { | ||
146 | Type returntype = m_comms.LookupReturnType(fname); | ||
147 | if (returntype != typeof(int)) | ||
148 | MODError(String.Format("return type mismatch for {0}",fname)); | ||
149 | |||
150 | int result = (int)modInvoke(fname,parms); | ||
151 | return new LSL_Integer(result); | ||
152 | } | ||
153 | |||
154 | public LSL_Float modInvokeF(string fname, params object[] parms) | ||
155 | { | ||
156 | Type returntype = m_comms.LookupReturnType(fname); | ||
157 | if (returntype != typeof(float)) | ||
158 | MODError(String.Format("return type mismatch for {0}",fname)); | ||
159 | |||
160 | float result = (float)modInvoke(fname,parms); | ||
161 | return new LSL_Float(result); | ||
162 | } | ||
163 | |||
164 | public LSL_Key modInvokeK(string fname, params object[] parms) | ||
165 | { | ||
166 | Type returntype = m_comms.LookupReturnType(fname); | ||
167 | if (returntype != typeof(UUID)) | ||
168 | MODError(String.Format("return type mismatch for {0}",fname)); | ||
169 | |||
170 | UUID result = (UUID)modInvoke(fname,parms); | ||
171 | return new LSL_Key(result.ToString()); | ||
172 | } | ||
173 | |||
174 | public LSL_Vector modInvokeV(string fname, params object[] parms) | ||
175 | { | ||
176 | Type returntype = m_comms.LookupReturnType(fname); | ||
177 | if (returntype != typeof(OpenMetaverse.Vector3)) | ||
178 | MODError(String.Format("return type mismatch for {0}",fname)); | ||
179 | |||
180 | OpenMetaverse.Vector3 result = (OpenMetaverse.Vector3)modInvoke(fname,parms); | ||
181 | return new LSL_Vector(result.X,result.Y,result.Z); | ||
182 | } | ||
183 | |||
184 | public LSL_Rotation modInvokeR(string fname, params object[] parms) | ||
185 | { | ||
186 | Type returntype = m_comms.LookupReturnType(fname); | ||
187 | if (returntype != typeof(OpenMetaverse.Quaternion)) | ||
188 | MODError(String.Format("return type mismatch for {0}",fname)); | ||
189 | |||
190 | OpenMetaverse.Quaternion result = (OpenMetaverse.Quaternion)modInvoke(fname,parms); | ||
191 | return new LSL_Rotation(result.X,result.Y,result.Z,result.W); | ||
192 | } | ||
193 | |||
194 | public LSL_List modInvokeL(string fname, params object[] parms) | ||
195 | { | ||
196 | Type returntype = m_comms.LookupReturnType(fname); | ||
197 | if (returntype != typeof(object[])) | ||
198 | MODError(String.Format("return type mismatch for {0}",fname)); | ||
199 | |||
200 | object[] result = (object[])modInvoke(fname,parms); | ||
201 | object[] llist = new object[result.Length]; | ||
202 | for (int i = 0; i < result.Length; i++) | ||
203 | { | ||
204 | if (result[i] is string) | ||
205 | llist[i] = new LSL_String((string)result[i]); | ||
206 | else if (result[i] is int) | ||
207 | llist[i] = new LSL_Integer((int)result[i]); | ||
208 | else if (result[i] is float) | ||
209 | llist[i] = new LSL_Float((float)result[i]); | ||
210 | else if (result[i] is OpenMetaverse.Vector3) | ||
211 | { | ||
212 | OpenMetaverse.Vector3 vresult = (OpenMetaverse.Vector3)result[i]; | ||
213 | llist[i] = new LSL_Vector(vresult.X,vresult.Y,vresult.Z); | ||
214 | } | ||
215 | else if (result[i] is OpenMetaverse.Quaternion) | ||
216 | { | ||
217 | OpenMetaverse.Quaternion qresult = (OpenMetaverse.Quaternion)result[i]; | ||
218 | llist[i] = new LSL_Rotation(qresult.X,qresult.Y,qresult.Z,qresult.W); | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | MODError(String.Format("unknown list element returned by {0}",fname)); | ||
223 | } | ||
224 | } | ||
225 | |||
226 | return new LSL_List(llist); | ||
227 | } | ||
228 | |||
229 | /// <summary> | ||
230 | /// Invokes a preregistered function through the ScriptModuleComms class | ||
231 | /// </summary> | ||
232 | /// <param name="fname">The name of the function to invoke</param> | ||
233 | /// <param name="fname">List of parameters</param> | ||
234 | /// <returns>string result of the invocation</returns> | ||
235 | protected object modInvoke(string fname, params object[] parms) | ||
236 | { | ||
237 | if (!m_MODFunctionsEnabled) | ||
238 | { | ||
239 | MODShoutError("Module command functions not enabled"); | ||
240 | return ""; | ||
241 | } | ||
242 | |||
243 | Type[] signature = m_comms.LookupTypeSignature(fname); | ||
244 | if (signature.Length != parms.Length) | ||
245 | MODError(String.Format("wrong number of parameters to function {0}",fname)); | ||
246 | |||
247 | object[] convertedParms = new object[parms.Length]; | ||
248 | for (int i = 0; i < parms.Length; i++) | ||
249 | convertedParms[i] = ConvertFromLSL(parms[i],signature[i]); | ||
250 | |||
251 | // now call the function, the contract with the function is that it will always return | ||
252 | // non-null but don't trust it completely | ||
253 | try | ||
254 | { | ||
255 | object result = m_comms.InvokeOperation(m_host.UUID, m_itemID, fname, convertedParms); | ||
256 | if (result != null) | ||
257 | return result; | ||
258 | |||
259 | MODError(String.Format("Invocation of {0} failed; null return value",fname)); | ||
260 | } | ||
261 | catch (Exception e) | ||
262 | { | ||
263 | MODError(String.Format("Invocation of {0} failed; {1}",fname,e.Message)); | ||
264 | } | ||
265 | |||
266 | return null; | ||
267 | } | ||
268 | |||
269 | /// <summary> | ||
270 | /// Send a command to functions registered on an event | ||
271 | /// </summary> | ||
119 | public string modSendCommand(string module, string command, string k) | 272 | public string modSendCommand(string module, string command, string k) |
120 | { | 273 | { |
121 | if (!m_MODFunctionsEnabled) | 274 | if (!m_MODFunctionsEnabled) |
@@ -130,5 +283,101 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
130 | 283 | ||
131 | return req.ToString(); | 284 | return req.ToString(); |
132 | } | 285 | } |
286 | |||
287 | /// <summary> | ||
288 | /// </summary> | ||
289 | protected object ConvertFromLSL(object lslparm, Type type) | ||
290 | { | ||
291 | // ---------- String ---------- | ||
292 | if (lslparm is LSL_String) | ||
293 | { | ||
294 | if (type == typeof(string)) | ||
295 | return (string)(LSL_String)lslparm; | ||
296 | |||
297 | // Need to check for UUID since keys are often treated as strings | ||
298 | if (type == typeof(UUID)) | ||
299 | return new UUID((string)(LSL_String)lslparm); | ||
300 | } | ||
301 | |||
302 | // ---------- Integer ---------- | ||
303 | else if (lslparm is LSL_Integer) | ||
304 | { | ||
305 | if (type == typeof(int)) | ||
306 | return (int)(LSL_Integer)lslparm; | ||
307 | } | ||
308 | |||
309 | // ---------- Float ---------- | ||
310 | else if (lslparm is LSL_Float) | ||
311 | { | ||
312 | if (type == typeof(float)) | ||
313 | return (float)(LSL_Float)lslparm; | ||
314 | } | ||
315 | |||
316 | // ---------- Key ---------- | ||
317 | else if (lslparm is LSL_Key) | ||
318 | { | ||
319 | if (type == typeof(UUID)) | ||
320 | return new UUID((LSL_Key)lslparm); | ||
321 | } | ||
322 | |||
323 | // ---------- Rotation ---------- | ||
324 | else if (lslparm is LSL_Rotation) | ||
325 | { | ||
326 | if (type == typeof(OpenMetaverse.Quaternion)) | ||
327 | { | ||
328 | LSL_Rotation rot = (LSL_Rotation)lslparm; | ||
329 | return new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); | ||
330 | } | ||
331 | } | ||
332 | |||
333 | // ---------- Vector ---------- | ||
334 | else if (lslparm is LSL_Vector) | ||
335 | { | ||
336 | if (type == typeof(OpenMetaverse.Vector3)) | ||
337 | { | ||
338 | LSL_Vector vect = (LSL_Vector)lslparm; | ||
339 | return new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); | ||
340 | } | ||
341 | } | ||
342 | |||
343 | // ---------- List ---------- | ||
344 | else if (lslparm is LSL_List) | ||
345 | { | ||
346 | if (type == typeof(object[])) | ||
347 | { | ||
348 | object[] plist = (lslparm as LSL_List).Data; | ||
349 | object[] result = new object[plist.Length]; | ||
350 | for (int i = 0; i < plist.Length; i++) | ||
351 | { | ||
352 | if (plist[i] is LSL_String) | ||
353 | result[i] = (string)(LSL_String)plist[i]; | ||
354 | else if (plist[i] is LSL_Integer) | ||
355 | result[i] = (int)(LSL_Integer)plist[i]; | ||
356 | else if (plist[i] is LSL_Float) | ||
357 | result[i] = (float)(LSL_Float)plist[i]; | ||
358 | else if (plist[i] is LSL_Key) | ||
359 | result[i] = new UUID((LSL_Key)plist[i]); | ||
360 | else if (plist[i] is LSL_Rotation) | ||
361 | { | ||
362 | LSL_Rotation rot = (LSL_Rotation)plist[i]; | ||
363 | result[i] = new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); | ||
364 | } | ||
365 | else if (plist[i] is LSL_Vector) | ||
366 | { | ||
367 | LSL_Vector vect = (LSL_Vector)plist[i]; | ||
368 | result[i] = new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); | ||
369 | } | ||
370 | else | ||
371 | MODError("unknown LSL list element type"); | ||
372 | } | ||
373 | |||
374 | return result; | ||
375 | } | ||
376 | } | ||
377 | |||
378 | MODError(String.Format("parameter type mismatch; expecting {0}",type.Name)); | ||
379 | return null; | ||
380 | } | ||
381 | |||
133 | } | 382 | } |
134 | } | 383 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 8edd146..2ecd890 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2093,6 +2093,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2093 | return HomeURI; | 2093 | return HomeURI; |
2094 | } | 2094 | } |
2095 | 2095 | ||
2096 | public string osGetGridGatekeeperURI() | ||
2097 | { | ||
2098 | CheckThreatLevel(ThreatLevel.Moderate, "osGetGridGatekeeperURI"); | ||
2099 | m_host.AddScriptLPS(1); | ||
2100 | |||
2101 | string gatekeeperURI = String.Empty; | ||
2102 | IConfigSource config = m_ScriptEngine.ConfigSource; | ||
2103 | |||
2104 | if (config.Configs["GridService"] != null) | ||
2105 | gatekeeperURI = config.Configs["GridService"].GetString("Gatekeeper", gatekeeperURI); | ||
2106 | |||
2107 | return gatekeeperURI; | ||
2108 | } | ||
2109 | |||
2096 | public string osGetGridCustom(string key) | 2110 | public string osGetGridCustom(string key) |
2097 | { | 2111 | { |
2098 | CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom"); | 2112 | CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom"); |
@@ -2943,5 +2957,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2943 | 2957 | ||
2944 | return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); | 2958 | return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); |
2945 | } | 2959 | } |
2960 | |||
2961 | /// <summary> | ||
2962 | /// Get the description from an inventory item | ||
2963 | /// </summary> | ||
2964 | /// <param name="inventoryName"></param> | ||
2965 | /// <returns>Item description</returns> | ||
2966 | public LSL_String osGetInventoryDesc(string item) | ||
2967 | { | ||
2968 | m_host.AddScriptLPS(1); | ||
2969 | |||
2970 | lock (m_host.TaskInventory) | ||
2971 | { | ||
2972 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
2973 | { | ||
2974 | if (inv.Value.Name == item) | ||
2975 | { | ||
2976 | return inv.Value.Description.ToString(); | ||
2977 | } | ||
2978 | } | ||
2979 | } | ||
2980 | |||
2981 | return String.Empty; | ||
2982 | } | ||
2946 | } | 2983 | } |
2947 | } \ No newline at end of file | 2984 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs index 7fa19b1..9f78a49 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs | |||
@@ -38,6 +38,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
38 | { | 38 | { |
39 | public AsyncCommandManager m_CmdManager; | 39 | public AsyncCommandManager m_CmdManager; |
40 | 40 | ||
41 | public int DataserverRequestsCount | ||
42 | { | ||
43 | get | ||
44 | { | ||
45 | lock (DataserverRequests) | ||
46 | return DataserverRequests.Count; | ||
47 | } | ||
48 | } | ||
49 | |||
41 | private Dictionary<string, DataserverRequest> DataserverRequests = | 50 | private Dictionary<string, DataserverRequest> DataserverRequests = |
42 | new Dictionary<string, DataserverRequest>(); | 51 | new Dictionary<string, DataserverRequest>(); |
43 | 52 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs index 740816f..93e0261 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs | |||
@@ -42,22 +42,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
42 | 42 | ||
43 | public AsyncCommandManager m_CmdManager; | 43 | public AsyncCommandManager m_CmdManager; |
44 | 44 | ||
45 | private IWorldComm m_commsPlugin; | ||
46 | |||
47 | public int ListenerCount | ||
48 | { | ||
49 | get { return m_commsPlugin.ListenerCount; } | ||
50 | } | ||
51 | |||
45 | public Listener(AsyncCommandManager CmdManager) | 52 | public Listener(AsyncCommandManager CmdManager) |
46 | { | 53 | { |
47 | m_CmdManager = CmdManager; | 54 | m_CmdManager = CmdManager; |
55 | m_commsPlugin = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
48 | } | 56 | } |
49 | 57 | ||
50 | public void CheckListeners() | 58 | public void CheckListeners() |
51 | { | 59 | { |
52 | if (m_CmdManager.m_ScriptEngine.World == null) | 60 | if (m_CmdManager.m_ScriptEngine.World == null) |
53 | return; | 61 | return; |
54 | IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
55 | 62 | ||
56 | if (comms != null) | 63 | if (m_commsPlugin != null) |
57 | { | 64 | { |
58 | while (comms.HasMessages()) | 65 | while (m_commsPlugin.HasMessages()) |
59 | { | 66 | { |
60 | ListenerInfo lInfo = (ListenerInfo)comms.GetNextMessage(); | 67 | ListenerInfo lInfo = (ListenerInfo)m_commsPlugin.GetNextMessage(); |
61 | 68 | ||
62 | //Deliver data to prim's listen handler | 69 | //Deliver data to prim's listen handler |
63 | object[] resobj = new object[] | 70 | object[] resobj = new object[] |
@@ -81,17 +88,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
81 | 88 | ||
82 | public Object[] GetSerializationData(UUID itemID) | 89 | public Object[] GetSerializationData(UUID itemID) |
83 | { | 90 | { |
84 | IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 91 | return m_commsPlugin.GetSerializationData(itemID); |
85 | |||
86 | return comms.GetSerializationData(itemID); | ||
87 | } | 92 | } |
88 | 93 | ||
89 | public void CreateFromData(uint localID, UUID itemID, UUID hostID, | 94 | public void CreateFromData(uint localID, UUID itemID, UUID hostID, |
90 | Object[] data) | 95 | Object[] data) |
91 | { | 96 | { |
92 | IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 97 | m_commsPlugin.CreateFromData(localID, itemID, hostID, data); |
93 | |||
94 | comms.CreateFromData(localID, itemID, hostID, data); | ||
95 | } | 98 | } |
96 | } | 99 | } |
97 | } | 100 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index fbb7c39..1c272f8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -44,6 +44,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
44 | 44 | ||
45 | public AsyncCommandManager m_CmdManager; | 45 | public AsyncCommandManager m_CmdManager; |
46 | 46 | ||
47 | /// <summary> | ||
48 | /// Number of sensors active. | ||
49 | /// </summary> | ||
50 | public int SensorsCount | ||
51 | { | ||
52 | get | ||
53 | { | ||
54 | lock (SenseRepeatListLock) | ||
55 | return SenseRepeaters.Count; | ||
56 | } | ||
57 | } | ||
58 | |||
47 | public SensorRepeat(AsyncCommandManager CmdManager) | 59 | public SensorRepeat(AsyncCommandManager CmdManager) |
48 | { | 60 | { |
49 | m_CmdManager = CmdManager; | 61 | m_CmdManager = CmdManager; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index eeb59d9..bc63030 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs | |||
@@ -37,6 +37,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
37 | { | 37 | { |
38 | public AsyncCommandManager m_CmdManager; | 38 | public AsyncCommandManager m_CmdManager; |
39 | 39 | ||
40 | public int TimersCount | ||
41 | { | ||
42 | get | ||
43 | { | ||
44 | lock (TimerListLock) | ||
45 | return Timers.Count; | ||
46 | } | ||
47 | } | ||
48 | |||
40 | public Timer(AsyncCommandManager CmdManager) | 49 | public Timer(AsyncCommandManager CmdManager) |
41 | { | 50 | { |
42 | m_CmdManager = CmdManager; | 51 | m_CmdManager = CmdManager; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs index e08eca5..aa78aaa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs | |||
@@ -28,18 +28,28 @@ | |||
28 | using System.Collections; | 28 | using System.Collections; |
29 | using OpenSim.Region.ScriptEngine.Interfaces; | 29 | using OpenSim.Region.ScriptEngine.Interfaces; |
30 | 30 | ||
31 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 31 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; |
32 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | 32 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; |
33 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | 33 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
34 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | 34 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; |
35 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
35 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 36 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
36 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | 37 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; |
37 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
38 | 38 | ||
39 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | 39 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces |
40 | { | 40 | { |
41 | public interface IMOD_Api | 41 | public interface IMOD_Api |
42 | { | 42 | { |
43 | // Invocation functions | ||
44 | void modInvokeN(string fname, params object[] parms); | ||
45 | LSL_String modInvokeS(string fname, params object[] parms); | ||
46 | LSL_Integer modInvokeI(string fname, params object[] parms); | ||
47 | LSL_Float modInvokeF(string fname, params object[] parms); | ||
48 | LSL_Key modInvokeK(string fname, params object[] parms); | ||
49 | LSL_Vector modInvokeV(string fname, params object[] parms); | ||
50 | LSL_Rotation modInvokeR(string fname, params object[] parms); | ||
51 | LSL_List modInvokeL(string fname, params object[] parms); | ||
52 | |||
43 | //Module functions | 53 | //Module functions |
44 | string modSendCommand(string modules, string command, string k); | 54 | string modSendCommand(string modules, string command, string k); |
45 | } | 55 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 82a6caf..8f9efc0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -161,6 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
161 | string osGetGridName(); | 161 | string osGetGridName(); |
162 | string osGetGridLoginURI(); | 162 | string osGetGridLoginURI(); |
163 | string osGetGridHomeURI(); | 163 | string osGetGridHomeURI(); |
164 | string osGetGridGatekeeperURI(); | ||
164 | string osGetGridCustom(string key); | 165 | string osGetGridCustom(string key); |
165 | 166 | ||
166 | LSL_String osFormatString(string str, LSL_List strings); | 167 | LSL_String osFormatString(string str, LSL_List strings); |
@@ -228,5 +229,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
228 | LSL_List osGetAvatarList(); | 229 | LSL_List osGetAvatarList(); |
229 | 230 | ||
230 | LSL_String osUnixTimeToTimestamp(long time); | 231 | LSL_String osUnixTimeToTimestamp(long time); |
232 | |||
233 | LSL_String osGetInventoryDesc(string item); | ||
231 | } | 234 | } |
232 | } | 235 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs index 6525c76..1c47138 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs | |||
@@ -39,10 +39,14 @@ using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | |||
39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | 39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; |
40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | 40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; |
41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
42 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | 42 | |
43 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
44 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | 43 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; |
45 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | 44 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; |
45 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
46 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
47 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
48 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
49 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
46 | 50 | ||
47 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | 51 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase |
48 | { | 52 | { |
@@ -58,6 +62,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
58 | m_MOD_Functions = (IMOD_Api)api; | 62 | m_MOD_Functions = (IMOD_Api)api; |
59 | } | 63 | } |
60 | 64 | ||
65 | public void modInvokeN(string fname, params object[] parms) | ||
66 | { | ||
67 | m_MOD_Functions.modInvokeN(fname, parms); | ||
68 | } | ||
69 | |||
70 | public LSL_String modInvokeS(string fname, params object[] parms) | ||
71 | { | ||
72 | return m_MOD_Functions.modInvokeS(fname, parms); | ||
73 | } | ||
74 | |||
75 | public LSL_Integer modInvokeI(string fname, params object[] parms) | ||
76 | { | ||
77 | return m_MOD_Functions.modInvokeI(fname, parms); | ||
78 | } | ||
79 | |||
80 | public LSL_Float modInvokeF(string fname, params object[] parms) | ||
81 | { | ||
82 | return m_MOD_Functions.modInvokeF(fname, parms); | ||
83 | } | ||
84 | |||
85 | public LSL_Key modInvokeK(string fname, params object[] parms) | ||
86 | { | ||
87 | return m_MOD_Functions.modInvokeK(fname, parms); | ||
88 | } | ||
89 | |||
90 | public LSL_Vector modInvokeV(string fname, params object[] parms) | ||
91 | { | ||
92 | return m_MOD_Functions.modInvokeV(fname, parms); | ||
93 | } | ||
94 | |||
95 | public LSL_Rotation modInvokeR(string fname, params object[] parms) | ||
96 | { | ||
97 | return m_MOD_Functions.modInvokeR(fname, parms); | ||
98 | } | ||
99 | |||
100 | public LSL_List modInvokeL(string fname, params object[] parms) | ||
101 | { | ||
102 | return m_MOD_Functions.modInvokeL(fname, parms); | ||
103 | } | ||
104 | |||
61 | public string modSendCommand(string module, string command, string k) | 105 | public string modSendCommand(string module, string command, string k) |
62 | { | 106 | { |
63 | return m_MOD_Functions.modSendCommand(module, command, k); | 107 | return m_MOD_Functions.modSendCommand(module, command, k); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 4341246..09e5992 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -457,6 +457,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
457 | return m_OSSL_Functions.osGetGridHomeURI(); | 457 | return m_OSSL_Functions.osGetGridHomeURI(); |
458 | } | 458 | } |
459 | 459 | ||
460 | public string osGetGridGatekeeperURI() | ||
461 | { | ||
462 | return m_OSSL_Functions.osGetGridGatekeeperURI(); | ||
463 | } | ||
464 | |||
460 | public string osGetGridCustom(string key) | 465 | public string osGetGridCustom(string key) |
461 | { | 466 | { |
462 | return m_OSSL_Functions.osGetGridCustom(key); | 467 | return m_OSSL_Functions.osGetGridCustom(key); |
@@ -858,5 +863,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
858 | { | 863 | { |
859 | return m_OSSL_Functions.osUnixTimeToTimestamp(time); | 864 | return m_OSSL_Functions.osUnixTimeToTimestamp(time); |
860 | } | 865 | } |
866 | |||
867 | public LSL_String osGetInventoryDesc(string item) | ||
868 | { | ||
869 | return m_OSSL_Functions.osGetInventoryDesc(item); | ||
870 | } | ||
861 | } | 871 | } |
862 | } | 872 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs index 04357a9..09a9a08 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/IndexedAnswers.cs | |||
@@ -226,7 +226,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog | |||
226 | break; | 226 | break; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | int z = 0; | |
230 | try | 230 | try |
231 | { | 231 | { |
232 | if (gotMatch) | 232 | if (gotMatch) |
@@ -235,8 +235,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog | |||
235 | finally | 235 | finally |
236 | { | 236 | { |
237 | // Manually finalize all the iterators. | 237 | // Manually finalize all the iterators. |
238 | for (int i = 0; i < nIterators; ++i) | 238 | for (z = 0; z < nIterators; ++z) |
239 | iterators[i].Dispose(); | 239 | iterators[z].Dispose(); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs index d8f44c1..f2171dd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/YP.cs | |||
@@ -576,7 +576,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog | |||
576 | break; | 576 | break; |
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | int z = 0; | |
580 | try | 580 | try |
581 | { | 581 | { |
582 | if (gotMatch) | 582 | if (gotMatch) |
@@ -585,8 +585,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog | |||
585 | finally | 585 | finally |
586 | { | 586 | { |
587 | // Manually finalize all the iterators. | 587 | // Manually finalize all the iterators. |
588 | for (int i = 0; i < nIterators; ++i) | 588 | for (z = 0; z < nIterators; ++z) |
589 | iterators[i].Dispose(); | 589 | iterators[z].Dispose(); |
590 | } | 590 | } |
591 | } | 591 | } |
592 | 592 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index 8b88588..b24f016 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | |||
@@ -32,6 +32,8 @@ using System.Reflection; | |||
32 | using log4net; | 32 | using log4net; |
33 | using Tools; | 33 | using Tools; |
34 | 34 | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | |||
35 | namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | 37 | namespace OpenSim.Region.ScriptEngine.Shared.CodeTools |
36 | { | 38 | { |
37 | public class CSCodeGenerator : ICodeConverter | 39 | public class CSCodeGenerator : ICodeConverter |
@@ -45,12 +47,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
45 | private int m_CSharpLine; // the current line of generated C# code | 47 | private int m_CSharpLine; // the current line of generated C# code |
46 | private int m_CSharpCol; // the current column of generated C# code | 48 | private int m_CSharpCol; // the current column of generated C# code |
47 | private List<string> m_warnings = new List<string>(); | 49 | private List<string> m_warnings = new List<string>(); |
50 | private IScriptModuleComms m_comms = null; | ||
48 | 51 | ||
49 | /// <summary> | 52 | /// <summary> |
50 | /// Creates an 'empty' CSCodeGenerator instance. | 53 | /// Creates an 'empty' CSCodeGenerator instance. |
51 | /// </summary> | 54 | /// </summary> |
52 | public CSCodeGenerator() | 55 | public CSCodeGenerator() |
53 | { | 56 | { |
57 | m_comms = null; | ||
58 | ResetCounters(); | ||
59 | } | ||
60 | |||
61 | public CSCodeGenerator(IScriptModuleComms comms) | ||
62 | { | ||
63 | m_comms = comms; | ||
54 | ResetCounters(); | 64 | ResetCounters(); |
55 | } | 65 | } |
56 | 66 | ||
@@ -118,7 +128,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
118 | emessage = emessage.Substring(slinfo.Length+2); | 128 | emessage = emessage.Substring(slinfo.Length+2); |
119 | 129 | ||
120 | message = String.Format("({0},{1}) {2}", | 130 | message = String.Format("({0},{1}) {2}", |
121 | e.slInfo.lineNumber - 2, | 131 | e.slInfo.lineNumber - 1, |
122 | e.slInfo.charPosition - 1, emessage); | 132 | e.slInfo.charPosition - 1, emessage); |
123 | 133 | ||
124 | throw new Exception(message); | 134 | throw new Exception(message); |
@@ -866,8 +876,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
866 | { | 876 | { |
867 | string retstr = String.Empty; | 877 | string retstr = String.Empty; |
868 | 878 | ||
869 | retstr += Generate(String.Format("{0}(", CheckName(fc.Id)), fc); | 879 | string modinvoke = null; |
870 | 880 | if (m_comms != null) | |
881 | modinvoke = m_comms.LookupModInvocation(fc.Id); | ||
882 | |||
883 | if (modinvoke != null) | ||
884 | { | ||
885 | if (fc.kids[0] is ArgumentList) | ||
886 | { | ||
887 | if ((fc.kids[0] as ArgumentList).kids.Count == 0) | ||
888 | retstr += Generate(String.Format("{0}(\"{1}\"",modinvoke,fc.Id), fc); | ||
889 | else | ||
890 | retstr += Generate(String.Format("{0}(\"{1}\",",modinvoke,fc.Id), fc); | ||
891 | } | ||
892 | } | ||
893 | else | ||
894 | { | ||
895 | retstr += Generate(String.Format("{0}(", CheckName(fc.Id)), fc); | ||
896 | } | ||
897 | |||
871 | foreach (SYMBOL kid in fc.kids) | 898 | foreach (SYMBOL kid in fc.kids) |
872 | retstr += GenerateNode(kid); | 899 | retstr += GenerateNode(kid); |
873 | 900 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index c10143b..8f2ec49 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -35,6 +35,7 @@ using Microsoft.CSharp; | |||
35 | //using Microsoft.JScript; | 35 | //using Microsoft.JScript; |
36 | using Microsoft.VisualBasic; | 36 | using Microsoft.VisualBasic; |
37 | using log4net; | 37 | using log4net; |
38 | |||
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.ScriptEngine.Interfaces; | 40 | using OpenSim.Region.ScriptEngine.Interfaces; |
40 | using OpenMetaverse; | 41 | using OpenMetaverse; |
@@ -293,6 +294,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
293 | { | 294 | { |
294 | // m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script); | 295 | // m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script); |
295 | 296 | ||
297 | IScriptModuleComms comms = m_scriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); | ||
298 | |||
296 | linemap = null; | 299 | linemap = null; |
297 | m_warnings.Clear(); | 300 | m_warnings.Clear(); |
298 | 301 | ||
@@ -382,7 +385,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
382 | if (language == enumCompileType.lsl) | 385 | if (language == enumCompileType.lsl) |
383 | { | 386 | { |
384 | // Its LSL, convert it to C# | 387 | // Its LSL, convert it to C# |
385 | LSL_Converter = (ICodeConverter)new CSCodeGenerator(); | 388 | LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms); |
386 | compileScript = LSL_Converter.Convert(Script); | 389 | compileScript = LSL_Converter.Convert(Script); |
387 | 390 | ||
388 | // copy converter warnings into our warnings. | 391 | // copy converter warnings into our warnings. |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs index 63afb0b..7763619 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs | |||
@@ -29,6 +29,7 @@ using System.Collections.Generic; | |||
29 | using System.Text.RegularExpressions; | 29 | using System.Text.RegularExpressions; |
30 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; | 31 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; |
32 | using OpenSim.Tests.Common; | ||
32 | 33 | ||
33 | namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests | 34 | namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests |
34 | { | 35 | { |
@@ -43,6 +44,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests | |||
43 | [Test] | 44 | [Test] |
44 | public void TestDefaultState() | 45 | public void TestDefaultState() |
45 | { | 46 | { |
47 | TestHelpers.InMethod(); | ||
48 | |||
46 | string input = @"default | 49 | string input = @"default |
47 | { | 50 | { |
48 | state_entry() | 51 | state_entry() |
@@ -63,6 +66,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests | |||
63 | [Test] | 66 | [Test] |
64 | public void TestCustomState() | 67 | public void TestCustomState() |
65 | { | 68 | { |
69 | TestHelpers.InMethod(); | ||
70 | |||
66 | string input = @"default | 71 | string input = @"default |
67 | { | 72 | { |
68 | state_entry() | 73 | state_entry() |
@@ -93,6 +98,8 @@ state another_state | |||
93 | [Test] | 98 | [Test] |
94 | public void TestEventWithArguments() | 99 | public void TestEventWithArguments() |
95 | { | 100 | { |
101 | TestHelpers.InMethod(); | ||
102 | |||
96 | string input = @"default | 103 | string input = @"default |
97 | { | 104 | { |
98 | at_rot_target(integer tnum, rotation targetrot, rotation ourrot) | 105 | at_rot_target(integer tnum, rotation targetrot, rotation ourrot) |
@@ -113,6 +120,8 @@ state another_state | |||
113 | [Test] | 120 | [Test] |
114 | public void TestIntegerDeclaration() | 121 | public void TestIntegerDeclaration() |
115 | { | 122 | { |
123 | TestHelpers.InMethod(); | ||
124 | |||
116 | string input = @"default | 125 | string input = @"default |
117 | { | 126 | { |
118 | touch_start(integer num_detected) | 127 | touch_start(integer num_detected) |
@@ -135,6 +144,8 @@ state another_state | |||
135 | [Test] | 144 | [Test] |
136 | public void TestLoneIdent() | 145 | public void TestLoneIdent() |
137 | { | 146 | { |
147 | TestHelpers.InMethod(); | ||
148 | |||
138 | // A lone ident should be removed completely as it's an error in C# | 149 | // A lone ident should be removed completely as it's an error in C# |
139 | // (MONO at least). | 150 | // (MONO at least). |
140 | string input = @"default | 151 | string input = @"default |
@@ -161,6 +172,8 @@ state another_state | |||
161 | [Test] | 172 | [Test] |
162 | public void TestAssignments() | 173 | public void TestAssignments() |
163 | { | 174 | { |
175 | TestHelpers.InMethod(); | ||
176 | |||
164 | string input = @"default | 177 | string input = @"default |
165 | { | 178 | { |
166 | touch_start(integer num_detected) | 179 | touch_start(integer num_detected) |
@@ -187,6 +200,8 @@ state another_state | |||
187 | [Test] | 200 | [Test] |
188 | public void TestAdditionSubtractionOperator() | 201 | public void TestAdditionSubtractionOperator() |
189 | { | 202 | { |
203 | TestHelpers.InMethod(); | ||
204 | |||
190 | string input = @"default | 205 | string input = @"default |
191 | { | 206 | { |
192 | touch_start(integer num_detected) | 207 | touch_start(integer num_detected) |
@@ -215,6 +230,8 @@ state another_state | |||
215 | [Test] | 230 | [Test] |
216 | public void TestStrings() | 231 | public void TestStrings() |
217 | { | 232 | { |
233 | TestHelpers.InMethod(); | ||
234 | |||
218 | string input = @"default | 235 | string input = @"default |
219 | { | 236 | { |
220 | touch_start(integer num_detected) | 237 | touch_start(integer num_detected) |
@@ -242,6 +259,8 @@ state another_state | |||
242 | [Test] | 259 | [Test] |
243 | public void TestBinaryExpression() | 260 | public void TestBinaryExpression() |
244 | { | 261 | { |
262 | TestHelpers.InMethod(); | ||
263 | |||
245 | string input = @"default | 264 | string input = @"default |
246 | { | 265 | { |
247 | touch_start(integer num_detected) | 266 | touch_start(integer num_detected) |
@@ -284,6 +303,8 @@ state another_state | |||
284 | [Test] | 303 | [Test] |
285 | public void TestFloatConstants() | 304 | public void TestFloatConstants() |
286 | { | 305 | { |
306 | TestHelpers.InMethod(); | ||
307 | |||
287 | string input = @"default | 308 | string input = @"default |
288 | { | 309 | { |
289 | touch_start(integer num_detected) | 310 | touch_start(integer num_detected) |
@@ -336,6 +357,8 @@ state another_state | |||
336 | [Test] | 357 | [Test] |
337 | public void TestComments() | 358 | public void TestComments() |
338 | { | 359 | { |
360 | TestHelpers.InMethod(); | ||
361 | |||
339 | string input = @"// this test tests comments | 362 | string input = @"// this test tests comments |
340 | default | 363 | default |
341 | { | 364 | { |
@@ -358,6 +381,8 @@ default | |||
358 | [Test] | 381 | [Test] |
359 | public void TestStringsWithEscapedQuotesAndComments() | 382 | public void TestStringsWithEscapedQuotesAndComments() |
360 | { | 383 | { |
384 | TestHelpers.InMethod(); | ||
385 | |||
361 | string input = @"// this test tests strings, with escaped quotes and comments in strings | 386 | string input = @"// this test tests strings, with escaped quotes and comments in strings |
362 | default | 387 | default |
363 | { | 388 | { |
@@ -397,6 +422,8 @@ default | |||
397 | [Test] | 422 | [Test] |
398 | public void TestCStyleComments() | 423 | public void TestCStyleComments() |
399 | { | 424 | { |
425 | TestHelpers.InMethod(); | ||
426 | |||
400 | string input = @"/* this test tests comments | 427 | string input = @"/* this test tests comments |
401 | of the C variety | 428 | of the C variety |
402 | */ | 429 | */ |
@@ -426,6 +453,8 @@ default | |||
426 | [Test] | 453 | [Test] |
427 | public void TestGlobalDefinedFunctions() | 454 | public void TestGlobalDefinedFunctions() |
428 | { | 455 | { |
456 | TestHelpers.InMethod(); | ||
457 | |||
429 | string input = @"// this test tests custom defined functions | 458 | string input = @"// this test tests custom defined functions |
430 | 459 | ||
431 | string onefunc() | 460 | string onefunc() |
@@ -470,6 +499,8 @@ default | |||
470 | [Test] | 499 | [Test] |
471 | public void TestGlobalDeclaredVariables() | 500 | public void TestGlobalDeclaredVariables() |
472 | { | 501 | { |
502 | TestHelpers.InMethod(); | ||
503 | |||
473 | string input = @"// this test tests custom defined functions and global variables | 504 | string input = @"// this test tests custom defined functions and global variables |
474 | 505 | ||
475 | string globalString; | 506 | string globalString; |
@@ -525,6 +556,8 @@ default | |||
525 | [Test] | 556 | [Test] |
526 | public void TestMoreAssignments() | 557 | public void TestMoreAssignments() |
527 | { | 558 | { |
559 | TestHelpers.InMethod(); | ||
560 | |||
528 | string input = @"// this test tests +=, -=, *=, /=, %= | 561 | string input = @"// this test tests +=, -=, *=, /=, %= |
529 | 562 | ||
530 | string globalString; | 563 | string globalString; |
@@ -579,6 +612,8 @@ default | |||
579 | [Test] | 612 | [Test] |
580 | public void TestVectorConstantNotation() | 613 | public void TestVectorConstantNotation() |
581 | { | 614 | { |
615 | TestHelpers.InMethod(); | ||
616 | |||
582 | string input = @"default | 617 | string input = @"default |
583 | { | 618 | { |
584 | touch_start(integer num_detected) | 619 | touch_start(integer num_detected) |
@@ -606,6 +641,8 @@ default | |||
606 | [Test] | 641 | [Test] |
607 | public void TestVectorMemberAccess() | 642 | public void TestVectorMemberAccess() |
608 | { | 643 | { |
644 | TestHelpers.InMethod(); | ||
645 | |||
609 | string input = @"default | 646 | string input = @"default |
610 | { | 647 | { |
611 | touch_start(integer num_detected) | 648 | touch_start(integer num_detected) |
@@ -632,6 +669,8 @@ default | |||
632 | [Test] | 669 | [Test] |
633 | public void TestExpressionInParentheses() | 670 | public void TestExpressionInParentheses() |
634 | { | 671 | { |
672 | TestHelpers.InMethod(); | ||
673 | |||
635 | string input = @"default | 674 | string input = @"default |
636 | { | 675 | { |
637 | touch_start(integer num_detected) | 676 | touch_start(integer num_detected) |
@@ -660,6 +699,8 @@ default | |||
660 | [Test] | 699 | [Test] |
661 | public void TestIncrementDecrementOperator() | 700 | public void TestIncrementDecrementOperator() |
662 | { | 701 | { |
702 | TestHelpers.InMethod(); | ||
703 | |||
663 | string input = @"// here we'll test the ++ and -- operators | 704 | string input = @"// here we'll test the ++ and -- operators |
664 | 705 | ||
665 | default | 706 | default |
@@ -690,6 +731,8 @@ default | |||
690 | [Test] | 731 | [Test] |
691 | public void TestLists() | 732 | public void TestLists() |
692 | { | 733 | { |
734 | TestHelpers.InMethod(); | ||
735 | |||
693 | string input = @"// testing lists | 736 | string input = @"// testing lists |
694 | 737 | ||
695 | default | 738 | default |
@@ -718,6 +761,8 @@ default | |||
718 | [Test] | 761 | [Test] |
719 | public void TestIfStatement() | 762 | public void TestIfStatement() |
720 | { | 763 | { |
764 | TestHelpers.InMethod(); | ||
765 | |||
721 | string input = @"// let's test if statements | 766 | string input = @"// let's test if statements |
722 | 767 | ||
723 | default | 768 | default |
@@ -822,6 +867,8 @@ default | |||
822 | [Test] | 867 | [Test] |
823 | public void TestIfElseStatement() | 868 | public void TestIfElseStatement() |
824 | { | 869 | { |
870 | TestHelpers.InMethod(); | ||
871 | |||
825 | string input = @"// let's test complex logical expressions | 872 | string input = @"// let's test complex logical expressions |
826 | 873 | ||
827 | default | 874 | default |
@@ -928,6 +975,8 @@ default | |||
928 | [Test] | 975 | [Test] |
929 | public void TestWhileLoop() | 976 | public void TestWhileLoop() |
930 | { | 977 | { |
978 | TestHelpers.InMethod(); | ||
979 | |||
931 | string input = @"// let's test while loops | 980 | string input = @"// let's test while loops |
932 | 981 | ||
933 | default | 982 | default |
@@ -968,6 +1017,8 @@ default | |||
968 | [Test] | 1017 | [Test] |
969 | public void TestDoWhileLoop() | 1018 | public void TestDoWhileLoop() |
970 | { | 1019 | { |
1020 | TestHelpers.InMethod(); | ||
1021 | |||
971 | string input = @"// let's test do-while loops | 1022 | string input = @"// let's test do-while loops |
972 | 1023 | ||
973 | default | 1024 | default |
@@ -1012,6 +1063,8 @@ default | |||
1012 | [Test] | 1063 | [Test] |
1013 | public void TestForLoop() | 1064 | public void TestForLoop() |
1014 | { | 1065 | { |
1066 | TestHelpers.InMethod(); | ||
1067 | |||
1015 | string input = @"// let's test for loops | 1068 | string input = @"// let's test for loops |
1016 | 1069 | ||
1017 | default | 1070 | default |
@@ -1056,6 +1109,8 @@ default | |||
1056 | [Test] | 1109 | [Test] |
1057 | public void TestFloatsWithTrailingDecimal() | 1110 | public void TestFloatsWithTrailingDecimal() |
1058 | { | 1111 | { |
1112 | TestHelpers.InMethod(); | ||
1113 | |||
1059 | string input = @"// a curious feature of LSL that allows floats to be defined with a trailing dot | 1114 | string input = @"// a curious feature of LSL that allows floats to be defined with a trailing dot |
1060 | 1115 | ||
1061 | default | 1116 | default |
@@ -1108,6 +1163,8 @@ default | |||
1108 | [Test] | 1163 | [Test] |
1109 | public void TestUnaryAndBinaryOperators() | 1164 | public void TestUnaryAndBinaryOperators() |
1110 | { | 1165 | { |
1166 | TestHelpers.InMethod(); | ||
1167 | |||
1111 | string input = @"// let's test a few more operators | 1168 | string input = @"// let's test a few more operators |
1112 | 1169 | ||
1113 | default | 1170 | default |
@@ -1144,6 +1201,8 @@ default | |||
1144 | [Test] | 1201 | [Test] |
1145 | public void TestTypecasts() | 1202 | public void TestTypecasts() |
1146 | { | 1203 | { |
1204 | TestHelpers.InMethod(); | ||
1205 | |||
1147 | string input = @"// let's test typecasts | 1206 | string input = @"// let's test typecasts |
1148 | 1207 | ||
1149 | default | 1208 | default |
@@ -1189,6 +1248,8 @@ default | |||
1189 | [Test] | 1248 | [Test] |
1190 | public void TestStates() | 1249 | public void TestStates() |
1191 | { | 1250 | { |
1251 | TestHelpers.InMethod(); | ||
1252 | |||
1192 | string input = @"// let's test states | 1253 | string input = @"// let's test states |
1193 | 1254 | ||
1194 | default | 1255 | default |
@@ -1229,6 +1290,8 @@ state statetwo | |||
1229 | [Test] | 1290 | [Test] |
1230 | public void TestHexIntegerConstants() | 1291 | public void TestHexIntegerConstants() |
1231 | { | 1292 | { |
1293 | TestHelpers.InMethod(); | ||
1294 | |||
1232 | string input = @"// let's test hex integers | 1295 | string input = @"// let's test hex integers |
1233 | 1296 | ||
1234 | default | 1297 | default |
@@ -1261,6 +1324,8 @@ default | |||
1261 | [Test] | 1324 | [Test] |
1262 | public void TestJumps() | 1325 | public void TestJumps() |
1263 | { | 1326 | { |
1327 | TestHelpers.InMethod(); | ||
1328 | |||
1264 | string input = @"// let's test jumps | 1329 | string input = @"// let's test jumps |
1265 | 1330 | ||
1266 | default | 1331 | default |
@@ -1291,6 +1356,8 @@ default | |||
1291 | [Test] | 1356 | [Test] |
1292 | public void TestImplicitVariableInitialization() | 1357 | public void TestImplicitVariableInitialization() |
1293 | { | 1358 | { |
1359 | TestHelpers.InMethod(); | ||
1360 | |||
1294 | string input = @"// let's test implicitly initializing variables | 1361 | string input = @"// let's test implicitly initializing variables |
1295 | 1362 | ||
1296 | default | 1363 | default |
@@ -1334,6 +1401,8 @@ default | |||
1334 | [Test] | 1401 | [Test] |
1335 | public void TestMultipleEqualsExpression() | 1402 | public void TestMultipleEqualsExpression() |
1336 | { | 1403 | { |
1404 | TestHelpers.InMethod(); | ||
1405 | |||
1337 | string input = @"// let's test x = y = 5 type expressions | 1406 | string input = @"// let's test x = y = 5 type expressions |
1338 | 1407 | ||
1339 | default | 1408 | default |
@@ -1366,6 +1435,8 @@ default | |||
1366 | [Test] | 1435 | [Test] |
1367 | public void TestUnaryExpressionLastInVectorConstant() | 1436 | public void TestUnaryExpressionLastInVectorConstant() |
1368 | { | 1437 | { |
1438 | TestHelpers.InMethod(); | ||
1439 | |||
1369 | string input = @"// let's test unary expressions some more | 1440 | string input = @"// let's test unary expressions some more |
1370 | 1441 | ||
1371 | default | 1442 | default |
@@ -1390,6 +1461,8 @@ default | |||
1390 | [Test] | 1461 | [Test] |
1391 | public void TestVectorMemberPlusEquals() | 1462 | public void TestVectorMemberPlusEquals() |
1392 | { | 1463 | { |
1464 | TestHelpers.InMethod(); | ||
1465 | |||
1393 | string input = @"// let's test unary expressions some more | 1466 | string input = @"// let's test unary expressions some more |
1394 | 1467 | ||
1395 | default | 1468 | default |
@@ -1424,6 +1497,8 @@ default | |||
1424 | [Test] | 1497 | [Test] |
1425 | public void TestWhileLoopWithNoBody() | 1498 | public void TestWhileLoopWithNoBody() |
1426 | { | 1499 | { |
1500 | TestHelpers.InMethod(); | ||
1501 | |||
1427 | string input = @"default | 1502 | string input = @"default |
1428 | { | 1503 | { |
1429 | state_entry() | 1504 | state_entry() |
@@ -1447,6 +1522,8 @@ default | |||
1447 | [Test] | 1522 | [Test] |
1448 | public void TestDoWhileLoopWithNoBody() | 1523 | public void TestDoWhileLoopWithNoBody() |
1449 | { | 1524 | { |
1525 | TestHelpers.InMethod(); | ||
1526 | |||
1450 | string input = @"default | 1527 | string input = @"default |
1451 | { | 1528 | { |
1452 | state_entry() | 1529 | state_entry() |
@@ -1472,6 +1549,8 @@ default | |||
1472 | [Test] | 1549 | [Test] |
1473 | public void TestIfWithNoBody() | 1550 | public void TestIfWithNoBody() |
1474 | { | 1551 | { |
1552 | TestHelpers.InMethod(); | ||
1553 | |||
1475 | string input = @"default | 1554 | string input = @"default |
1476 | { | 1555 | { |
1477 | state_entry() | 1556 | state_entry() |
@@ -1495,6 +1574,8 @@ default | |||
1495 | [Test] | 1574 | [Test] |
1496 | public void TestIfElseWithNoBody() | 1575 | public void TestIfElseWithNoBody() |
1497 | { | 1576 | { |
1577 | TestHelpers.InMethod(); | ||
1578 | |||
1498 | string input = @"default | 1579 | string input = @"default |
1499 | { | 1580 | { |
1500 | state_entry() | 1581 | state_entry() |
@@ -1521,6 +1602,8 @@ default | |||
1521 | [Test] | 1602 | [Test] |
1522 | public void TestForLoopWithNoBody() | 1603 | public void TestForLoopWithNoBody() |
1523 | { | 1604 | { |
1605 | TestHelpers.InMethod(); | ||
1606 | |||
1524 | string input = @"default | 1607 | string input = @"default |
1525 | { | 1608 | { |
1526 | state_entry() | 1609 | state_entry() |
@@ -1544,6 +1627,8 @@ default | |||
1544 | [Test] | 1627 | [Test] |
1545 | public void TestForLoopWithNoAssignment() | 1628 | public void TestForLoopWithNoAssignment() |
1546 | { | 1629 | { |
1630 | TestHelpers.InMethod(); | ||
1631 | |||
1547 | string input = @"default | 1632 | string input = @"default |
1548 | { | 1633 | { |
1549 | state_entry() | 1634 | state_entry() |
@@ -1569,6 +1654,8 @@ default | |||
1569 | [Test] | 1654 | [Test] |
1570 | public void TestForLoopWithOnlyIdentInAssignment() | 1655 | public void TestForLoopWithOnlyIdentInAssignment() |
1571 | { | 1656 | { |
1657 | TestHelpers.InMethod(); | ||
1658 | |||
1572 | string input = @"default | 1659 | string input = @"default |
1573 | { | 1660 | { |
1574 | state_entry() | 1661 | state_entry() |
@@ -1594,6 +1681,8 @@ default | |||
1594 | [Test] | 1681 | [Test] |
1595 | public void TestAssignmentInIfWhileDoWhile() | 1682 | public void TestAssignmentInIfWhileDoWhile() |
1596 | { | 1683 | { |
1684 | TestHelpers.InMethod(); | ||
1685 | |||
1597 | string input = @"default | 1686 | string input = @"default |
1598 | { | 1687 | { |
1599 | state_entry() | 1688 | state_entry() |
@@ -1631,6 +1720,8 @@ default | |||
1631 | [Test] | 1720 | [Test] |
1632 | public void TestLSLListHack() | 1721 | public void TestLSLListHack() |
1633 | { | 1722 | { |
1723 | TestHelpers.InMethod(); | ||
1724 | |||
1634 | string input = @"default | 1725 | string input = @"default |
1635 | { | 1726 | { |
1636 | state_entry() | 1727 | state_entry() |
@@ -1653,9 +1744,12 @@ default | |||
1653 | } | 1744 | } |
1654 | 1745 | ||
1655 | [Test] | 1746 | [Test] |
1656 | [ExpectedException(typeof(System.Exception))] | ||
1657 | public void TestSyntaxError() | 1747 | public void TestSyntaxError() |
1658 | { | 1748 | { |
1749 | TestHelpers.InMethod(); | ||
1750 | |||
1751 | bool gotException = false; | ||
1752 | |||
1659 | string input = @"default | 1753 | string input = @"default |
1660 | { | 1754 | { |
1661 | state_entry() | 1755 | state_entry() |
@@ -1671,17 +1765,22 @@ default | |||
1671 | } | 1765 | } |
1672 | catch (System.Exception e) | 1766 | catch (System.Exception e) |
1673 | { | 1767 | { |
1674 | // The syntax error is on line 6, char 5 (expected ';', found | 1768 | // The syntax error is on line 5, char 4 (expected ';', found |
1675 | // '}'). | 1769 | // '}'). |
1676 | Assert.AreEqual("(4,4) syntax error", e.Message); | 1770 | Assert.AreEqual("(5,4) syntax error", e.Message); |
1677 | throw; | 1771 | gotException = true; |
1678 | } | 1772 | } |
1773 | |||
1774 | Assert.That(gotException, Is.True); | ||
1679 | } | 1775 | } |
1680 | 1776 | ||
1681 | [Test] | 1777 | [Test] |
1682 | [ExpectedException(typeof(System.Exception))] | ||
1683 | public void TestSyntaxErrorDeclaringVariableInForLoop() | 1778 | public void TestSyntaxErrorDeclaringVariableInForLoop() |
1684 | { | 1779 | { |
1780 | TestHelpers.InMethod(); | ||
1781 | |||
1782 | bool gotException = false; | ||
1783 | |||
1685 | string input = @"default | 1784 | string input = @"default |
1686 | { | 1785 | { |
1687 | state_entry() | 1786 | state_entry() |
@@ -1697,11 +1796,13 @@ default | |||
1697 | } | 1796 | } |
1698 | catch (System.Exception e) | 1797 | catch (System.Exception e) |
1699 | { | 1798 | { |
1700 | // The syntax error is on line 5, char 14 (Syntax error) | 1799 | // The syntax error is on line 4, char 13 (Syntax error) |
1701 | Assert.AreEqual("(3,13) syntax error", e.Message); | 1800 | Assert.AreEqual("(4,13) syntax error", e.Message); |
1702 | 1801 | ||
1703 | throw; | 1802 | gotException = true; |
1704 | } | 1803 | } |
1804 | |||
1805 | Assert.That(gotException, Is.True); | ||
1705 | } | 1806 | } |
1706 | } | 1807 | } |
1707 | } | 1808 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index c5483c8..1fa6954 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs | |||
@@ -31,6 +31,7 @@ using System.Collections.Generic; | |||
31 | using Microsoft.CSharp; | 31 | using Microsoft.CSharp; |
32 | using NUnit.Framework; | 32 | using NUnit.Framework; |
33 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; | 33 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; |
34 | using OpenSim.Tests.Common; | ||
34 | 35 | ||
35 | namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests | 36 | namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests |
36 | { | 37 | { |
@@ -92,6 +93,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests | |||
92 | //[Test] | 93 | //[Test] |
93 | public void TestUseUndeclaredVariable() | 94 | public void TestUseUndeclaredVariable() |
94 | { | 95 | { |
96 | TestHelpers.InMethod(); | ||
97 | |||
95 | m_compilerParameters.OutputAssembly = Path.Combine(m_testDir, Path.GetRandomFileName() + ".dll"); | 98 | m_compilerParameters.OutputAssembly = Path.Combine(m_testDir, Path.GetRandomFileName() + ".dll"); |
96 | 99 | ||
97 | string input = @"default | 100 | string input = @"default |
@@ -124,6 +127,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests | |||
124 | //[Test] | 127 | //[Test] |
125 | public void TestCastAndConcatString() | 128 | public void TestCastAndConcatString() |
126 | { | 129 | { |
130 | TestHelpers.InMethod(); | ||
131 | |||
127 | m_compilerParameters.OutputAssembly = Path.Combine(m_testDir, Path.GetRandomFileName() + ".dll"); | 132 | m_compilerParameters.OutputAssembly = Path.Combine(m_testDir, Path.GetRandomFileName() + ".dll"); |
128 | 133 | ||
129 | string input = @"string s = "" a string""; | 134 | string input = @"string s = "" a string""; |
@@ -150,4 +155,4 @@ default | |||
150 | Assert.AreEqual(0, m_compilerResults.Errors.Count); | 155 | Assert.AreEqual(0, m_compilerResults.Errors.Count); |
151 | } | 156 | } |
152 | } | 157 | } |
153 | } | 158 | } \ 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 bc1902b..6e36742 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -56,36 +56,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
56 | public class ScriptInstance : MarshalByRefObject, IScriptInstance | 56 | public class ScriptInstance : MarshalByRefObject, IScriptInstance |
57 | { | 57 | { |
58 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 58 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
59 | 59 | ||
60 | private IScriptEngine m_Engine; | 60 | /// <summary> |
61 | private IScriptWorkItem m_CurrentResult = null; | 61 | /// The current work item if an event for this script is running or waiting to run, |
62 | private Queue m_EventQueue = new Queue(32); | 62 | /// </summary> |
63 | private bool m_RunEvents = false; | 63 | /// <remarks> |
64 | private UUID m_ItemID; | 64 | /// Null if there is no running or waiting to run event. Must be changed only under an EventQueue lock. |
65 | private uint m_LocalID; | 65 | /// </remarks> |
66 | private UUID m_ObjectID; | 66 | private IScriptWorkItem m_CurrentWorkItem; |
67 | private UUID m_AssetID; | 67 | |
68 | private IScript m_Script; | 68 | private IScript m_Script; |
69 | private UUID m_AppDomain; | ||
70 | private DetectParams[] m_DetectParams; | 69 | private DetectParams[] m_DetectParams; |
71 | private bool m_TimerQueued; | 70 | private bool m_TimerQueued; |
72 | private DateTime m_EventStart; | 71 | private DateTime m_EventStart; |
73 | private bool m_InEvent; | 72 | private bool m_InEvent; |
74 | private string m_PrimName; | ||
75 | private string m_ScriptName; | ||
76 | private string m_Assembly; | 73 | private string m_Assembly; |
77 | private int m_StartParam; | ||
78 | private string m_CurrentEvent = String.Empty; | 74 | private string m_CurrentEvent = String.Empty; |
79 | private bool m_InSelfDelete; | 75 | private bool m_InSelfDelete; |
80 | private int m_MaxScriptQueue; | 76 | private int m_MaxScriptQueue; |
81 | private bool m_SaveState = true; | 77 | private bool m_SaveState = true; |
82 | private bool m_ShuttingDown; | ||
83 | private int m_ControlEventsInQueue; | 78 | private int m_ControlEventsInQueue; |
84 | private int m_LastControlLevel; | 79 | private int m_LastControlLevel; |
85 | private bool m_CollisionInQueue; | 80 | private bool m_CollisionInQueue; |
86 | private TaskInventoryItem m_thisScriptTask; | 81 | |
87 | // The following is for setting a minimum delay between events | 82 | // The following is for setting a minimum delay between events |
88 | private double m_minEventDelay; | 83 | private double m_minEventDelay; |
84 | |||
89 | private long m_eventDelayTicks; | 85 | private long m_eventDelayTicks; |
90 | private long m_nextEventTimeTicks; | 86 | private long m_nextEventTimeTicks; |
91 | private bool m_startOnInit = true; | 87 | private bool m_startOnInit = true; |
@@ -96,21 +92,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
96 | private UUID m_CurrentStateHash; | 92 | private UUID m_CurrentStateHash; |
97 | private UUID m_RegionID; | 93 | private UUID m_RegionID; |
98 | 94 | ||
99 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> | 95 | public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap { get; set; } |
100 | m_LineMap; | ||
101 | |||
102 | public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> | ||
103 | LineMap | ||
104 | { | ||
105 | get { return m_LineMap; } | ||
106 | set { m_LineMap = value; } | ||
107 | } | ||
108 | 96 | ||
109 | private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); | 97 | private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); |
110 | 98 | ||
111 | // Script state | ||
112 | private string m_State = "default"; | ||
113 | |||
114 | public Object[] PluginData = new Object[0]; | 99 | public Object[] PluginData = new Object[0]; |
115 | 100 | ||
116 | /// <summary> | 101 | /// <summary> |
@@ -133,11 +118,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
133 | } | 118 | } |
134 | } | 119 | } |
135 | 120 | ||
136 | public bool Running | 121 | public bool Running { get; set; } |
137 | { | ||
138 | get { return m_RunEvents; } | ||
139 | set { m_RunEvents = value; } | ||
140 | } | ||
141 | 122 | ||
142 | public bool Suspended | 123 | public bool Suspended |
143 | { | 124 | { |
@@ -153,11 +134,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
153 | 134 | ||
154 | if (wasSuspended && !m_Suspended) | 135 | if (wasSuspended && !m_Suspended) |
155 | { | 136 | { |
156 | lock (m_EventQueue) | 137 | lock (EventQueue) |
157 | { | 138 | { |
158 | // Need to place ourselves back in a work item if there are events to process | 139 | // Need to place ourselves back in a work item if there are events to process |
159 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 140 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
160 | m_CurrentResult = m_Engine.QueueEventHandler(this); | 141 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
161 | } | 142 | } |
162 | } | 143 | } |
163 | } | 144 | } |
@@ -165,79 +146,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
165 | } | 146 | } |
166 | private bool m_Suspended; | 147 | private bool m_Suspended; |
167 | 148 | ||
168 | public bool ShuttingDown | 149 | public bool ShuttingDown { get; set; } |
169 | { | ||
170 | get { return m_ShuttingDown; } | ||
171 | set { m_ShuttingDown = value; } | ||
172 | } | ||
173 | 150 | ||
174 | public string State | 151 | public string State { get; set; } |
175 | { | ||
176 | get { return m_State; } | ||
177 | set { m_State = value; } | ||
178 | } | ||
179 | 152 | ||
180 | public IScriptEngine Engine | 153 | public IScriptEngine Engine { get; private set; } |
181 | { | ||
182 | get { return m_Engine; } | ||
183 | } | ||
184 | 154 | ||
185 | public UUID AppDomain | 155 | public UUID AppDomain { get; set; } |
186 | { | ||
187 | get { return m_AppDomain; } | ||
188 | set { m_AppDomain = value; } | ||
189 | } | ||
190 | 156 | ||
191 | public string PrimName | 157 | public string PrimName { get; private set; } |
192 | { | ||
193 | get { return m_PrimName; } | ||
194 | } | ||
195 | 158 | ||
196 | public string ScriptName | 159 | public string ScriptName { get; private set; } |
197 | { | ||
198 | get { return m_ScriptName; } | ||
199 | } | ||
200 | 160 | ||
201 | public UUID ItemID | 161 | public UUID ItemID { get; private set; } |
202 | { | ||
203 | get { return m_ItemID; } | ||
204 | } | ||
205 | 162 | ||
206 | public UUID ObjectID | 163 | public UUID ObjectID { get; private set; } |
207 | { | ||
208 | get { return m_ObjectID; } | ||
209 | } | ||
210 | 164 | ||
211 | public uint LocalID | 165 | public uint LocalID { get; private set; } |
212 | { | ||
213 | get { return m_LocalID; } | ||
214 | } | ||
215 | 166 | ||
216 | public UUID AssetID | 167 | public UUID RootObjectID { get; private set; } |
217 | { | ||
218 | get { return m_AssetID; } | ||
219 | } | ||
220 | 168 | ||
221 | public Queue EventQueue | 169 | public uint RootLocalID { get; private set; } |
222 | { | ||
223 | get { return m_EventQueue; } | ||
224 | } | ||
225 | 170 | ||
226 | public void ClearQueue() | 171 | public UUID AssetID { get; private set; } |
227 | { | ||
228 | m_TimerQueued = false; | ||
229 | m_EventQueue.Clear(); | ||
230 | } | ||
231 | 172 | ||
232 | public int StartParam | 173 | public Queue EventQueue { get; private set; } |
233 | { | 174 | |
234 | get { return m_StartParam; } | 175 | public int StartParam { get; set; } |
235 | set { m_StartParam = value; } | 176 | |
236 | } | 177 | public TaskInventoryItem ScriptTask { get; private set; } |
178 | |||
179 | public DateTime TimeStarted { get; private set; } | ||
180 | |||
181 | public long MeasurementPeriodTickStart { get; private set; } | ||
237 | 182 | ||
238 | public TaskInventoryItem ScriptTask | 183 | public long MeasurementPeriodExecutionTime { get; private set; } |
184 | |||
185 | public static readonly long MaxMeasurementPeriod = 30 * TimeSpan.TicksPerMinute; | ||
186 | |||
187 | public void ClearQueue() | ||
239 | { | 188 | { |
240 | get { return m_thisScriptTask; } | 189 | m_TimerQueued = false; |
190 | EventQueue.Clear(); | ||
241 | } | 191 | } |
242 | 192 | ||
243 | public ScriptInstance(IScriptEngine engine, SceneObjectPart part, | 193 | public ScriptInstance(IScriptEngine engine, SceneObjectPart part, |
@@ -246,16 +196,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
246 | int startParam, bool postOnRez, StateSource stateSource, | 196 | int startParam, bool postOnRez, StateSource stateSource, |
247 | int maxScriptQueue) | 197 | int maxScriptQueue) |
248 | { | 198 | { |
249 | m_Engine = engine; | 199 | State = "default"; |
250 | 200 | EventQueue = new Queue(32); | |
251 | m_LocalID = part.LocalId; | 201 | |
252 | m_ObjectID = part.UUID; | 202 | Engine = engine; |
253 | m_ItemID = itemID; | 203 | LocalID = part.LocalId; |
254 | m_AssetID = assetID; | 204 | ObjectID = part.UUID; |
255 | m_PrimName = primName; | 205 | RootLocalID = part.ParentGroup.LocalId; |
256 | m_ScriptName = scriptName; | 206 | RootObjectID = part.ParentGroup.UUID; |
207 | ItemID = itemID; | ||
208 | AssetID = assetID; | ||
209 | PrimName = primName; | ||
210 | ScriptName = scriptName; | ||
257 | m_Assembly = assembly; | 211 | m_Assembly = assembly; |
258 | m_StartParam = startParam; | 212 | StartParam = startParam; |
259 | m_MaxScriptQueue = maxScriptQueue; | 213 | m_MaxScriptQueue = maxScriptQueue; |
260 | m_stateSource = stateSource; | 214 | m_stateSource = stateSource; |
261 | m_postOnRez = postOnRez; | 215 | m_postOnRez = postOnRez; |
@@ -266,9 +220,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
266 | { | 220 | { |
267 | lock (part.TaskInventory) | 221 | lock (part.TaskInventory) |
268 | { | 222 | { |
269 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 223 | if (part.TaskInventory.ContainsKey(ItemID)) |
270 | { | 224 | { |
271 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | 225 | ScriptTask = part.TaskInventory[ItemID]; |
272 | } | 226 | } |
273 | } | 227 | } |
274 | } | 228 | } |
@@ -278,20 +232,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
278 | foreach (string api in am.GetApis()) | 232 | foreach (string api in am.GetApis()) |
279 | { | 233 | { |
280 | m_Apis[api] = am.CreateApi(api); | 234 | m_Apis[api] = am.CreateApi(api); |
281 | m_Apis[api].Initialize(engine, part, m_LocalID, itemID); | 235 | m_Apis[api].Initialize(engine, part, LocalID, itemID); |
282 | } | 236 | } |
283 | 237 | ||
284 | try | 238 | try |
285 | { | 239 | { |
286 | if (dom != System.AppDomain.CurrentDomain) | 240 | if (dom != System.AppDomain.CurrentDomain) |
287 | m_Script = (IScript)dom.CreateInstanceAndUnwrap( | 241 | m_Script = (IScript)dom.CreateInstanceAndUnwrap( |
288 | Path.GetFileNameWithoutExtension(assembly), | 242 | Path.GetFileNameWithoutExtension(assembly), |
289 | "SecondLife.Script"); | 243 | "SecondLife.Script"); |
290 | else | 244 | else |
291 | m_Script = (IScript)Assembly.Load( | 245 | m_Script = (IScript)Assembly.Load( |
292 | Path.GetFileNameWithoutExtension(assembly)).CreateInstance( | 246 | Path.GetFileNameWithoutExtension(assembly)).CreateInstance( |
293 | "SecondLife.Script"); | 247 | "SecondLife.Script"); |
294 | |||
295 | 248 | ||
296 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 249 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
297 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 250 | //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
@@ -313,7 +266,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
313 | 266 | ||
314 | // // m_log.Debug("[Script] Script instance created"); | 267 | // // m_log.Debug("[Script] Script instance created"); |
315 | 268 | ||
316 | part.SetScriptEvents(m_ItemID, | 269 | part.SetScriptEvents(ItemID, |
317 | (int)m_Script.GetStateEventFlags(State)); | 270 | (int)m_Script.GetStateEventFlags(State)); |
318 | } | 271 | } |
319 | catch (Exception e) | 272 | catch (Exception e) |
@@ -328,7 +281,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
328 | m_SaveState = true; | 281 | m_SaveState = true; |
329 | 282 | ||
330 | string savedState = Path.Combine(Path.GetDirectoryName(assembly), | 283 | string savedState = Path.Combine(Path.GetDirectoryName(assembly), |
331 | m_ItemID.ToString() + ".state"); | 284 | ItemID.ToString() + ".state"); |
332 | if (File.Exists(savedState)) | 285 | if (File.Exists(savedState)) |
333 | { | 286 | { |
334 | string xml = String.Empty; | 287 | string xml = String.Empty; |
@@ -352,24 +305,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
352 | 305 | ||
353 | ScriptSerializer.Deserialize(xml, this); | 306 | ScriptSerializer.Deserialize(xml, this); |
354 | 307 | ||
355 | AsyncCommandManager.CreateFromData(m_Engine, | 308 | AsyncCommandManager.CreateFromData(Engine, |
356 | m_LocalID, m_ItemID, m_ObjectID, | 309 | LocalID, ItemID, ObjectID, |
357 | PluginData); | 310 | PluginData); |
358 | 311 | ||
359 | // m_log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", m_PrimName, m_ScriptName); | 312 | // m_log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", PrimName, m_ScriptName); |
360 | 313 | ||
361 | part.SetScriptEvents(m_ItemID, | 314 | part.SetScriptEvents(ItemID, |
362 | (int)m_Script.GetStateEventFlags(State)); | 315 | (int)m_Script.GetStateEventFlags(State)); |
363 | 316 | ||
364 | if (m_RunEvents && (!m_ShuttingDown)) | 317 | Running = false; |
365 | { | 318 | |
366 | m_RunEvents = false; | 319 | if (ShuttingDown) |
367 | } | ||
368 | else | ||
369 | { | ||
370 | m_RunEvents = false; | ||
371 | m_startOnInit = false; | 320 | m_startOnInit = false; |
372 | } | ||
373 | 321 | ||
374 | // we get new rez events on sim restart, too | 322 | // we get new rez events on sim restart, too |
375 | // but if there is state, then we fire the change | 323 | // but if there is state, then we fire the change |
@@ -378,7 +326,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
378 | // We loaded state, don't force a re-save | 326 | // We loaded state, don't force a re-save |
379 | m_SaveState = false; | 327 | m_SaveState = false; |
380 | m_startedFromSavedState = true; | 328 | m_startedFromSavedState = true; |
381 | |||
382 | } | 329 | } |
383 | } | 330 | } |
384 | else | 331 | else |
@@ -397,7 +344,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
397 | } | 344 | } |
398 | // else | 345 | // else |
399 | // { | 346 | // { |
400 | // ScenePresence presence = m_Engine.World.GetScenePresence(part.OwnerID); | 347 | // ScenePresence presence = Engine.World.GetScenePresence(part.OwnerID); |
401 | 348 | ||
402 | // if (presence != null && (!postOnRez)) | 349 | // if (presence != null && (!postOnRez)) |
403 | // presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); | 350 | // presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); |
@@ -415,7 +362,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
415 | if (m_postOnRez) | 362 | if (m_postOnRez) |
416 | { | 363 | { |
417 | PostEvent(new EventParams("on_rez", | 364 | PostEvent(new EventParams("on_rez", |
418 | new Object[] {new LSL_Types.LSLInteger(m_StartParam)}, new DetectParams[0])); | 365 | new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0])); |
419 | } | 366 | } |
420 | 367 | ||
421 | if (m_stateSource == StateSource.AttachedRez) | 368 | if (m_stateSource == StateSource.AttachedRez) |
@@ -449,7 +396,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
449 | if (m_postOnRez) | 396 | if (m_postOnRez) |
450 | { | 397 | { |
451 | PostEvent(new EventParams("on_rez", | 398 | PostEvent(new EventParams("on_rez", |
452 | new Object[] {new LSL_Types.LSLInteger(m_StartParam)}, new DetectParams[0])); | 399 | new Object[] {new LSL_Types.LSLInteger(StartParam)}, new DetectParams[0])); |
453 | } | 400 | } |
454 | 401 | ||
455 | if (m_stateSource == StateSource.AttachedRez) | 402 | if (m_stateSource == StateSource.AttachedRez) |
@@ -463,7 +410,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
463 | 410 | ||
464 | private void ReleaseControls() | 411 | private void ReleaseControls() |
465 | { | 412 | { |
466 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart(m_LocalID); | 413 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
467 | 414 | ||
468 | if (part != null) | 415 | if (part != null) |
469 | { | 416 | { |
@@ -471,18 +418,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
471 | UUID permsGranter; | 418 | UUID permsGranter; |
472 | lock (part.TaskInventory) | 419 | lock (part.TaskInventory) |
473 | { | 420 | { |
474 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 421 | if (!part.TaskInventory.ContainsKey(ItemID)) |
475 | return; | 422 | return; |
476 | 423 | ||
477 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | 424 | permsGranter = part.TaskInventory[ItemID].PermsGranter; |
478 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | 425 | permsMask = part.TaskInventory[ItemID].PermsMask; |
479 | } | 426 | } |
480 | 427 | ||
481 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 428 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
482 | { | 429 | { |
483 | ScenePresence presence = m_Engine.World.GetScenePresence(permsGranter); | 430 | ScenePresence presence = Engine.World.GetScenePresence(permsGranter); |
484 | if (presence != null) | 431 | if (presence != null) |
485 | presence.UnRegisterControlEventsToScript(m_LocalID, m_ItemID); | 432 | presence.UnRegisterControlEventsToScript(LocalID, ItemID); |
486 | } | 433 | } |
487 | } | 434 | } |
488 | } | 435 | } |
@@ -490,13 +437,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
490 | public void DestroyScriptInstance() | 437 | public void DestroyScriptInstance() |
491 | { | 438 | { |
492 | ReleaseControls(); | 439 | ReleaseControls(); |
493 | AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); | 440 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
494 | } | 441 | } |
495 | 442 | ||
496 | public void RemoveState() | 443 | public void RemoveState() |
497 | { | 444 | { |
498 | string savedState = Path.Combine(Path.GetDirectoryName(m_Assembly), | 445 | string savedState = Path.Combine(Path.GetDirectoryName(m_Assembly), |
499 | m_ItemID.ToString() + ".state"); | 446 | ItemID.ToString() + ".state"); |
500 | 447 | ||
501 | try | 448 | try |
502 | { | 449 | { |
@@ -509,7 +456,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
509 | 456 | ||
510 | public void VarDump(Dictionary<string, object> vars) | 457 | public void VarDump(Dictionary<string, object> vars) |
511 | { | 458 | { |
512 | // m_log.Info("Variable dump for script "+ m_ItemID.ToString()); | 459 | // m_log.Info("Variable dump for script "+ ItemID.ToString()); |
513 | // foreach (KeyValuePair<string, object> v in vars) | 460 | // foreach (KeyValuePair<string, object> v in vars) |
514 | // { | 461 | // { |
515 | // m_log.Info("Variable: "+v.Key+" = "+v.Value.ToString()); | 462 | // m_log.Info("Variable: "+v.Key+" = "+v.Value.ToString()); |
@@ -518,17 +465,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
518 | 465 | ||
519 | public void Start() | 466 | public void Start() |
520 | { | 467 | { |
521 | lock (m_EventQueue) | 468 | lock (EventQueue) |
522 | { | 469 | { |
523 | if (Running) | 470 | if (Running) |
524 | return; | 471 | return; |
525 | 472 | ||
526 | m_RunEvents = true; | 473 | Running = true; |
474 | |||
475 | TimeStarted = DateTime.Now; | ||
476 | MeasurementPeriodTickStart = Util.EnvironmentTickCount(); | ||
477 | MeasurementPeriodExecutionTime = 0; | ||
527 | 478 | ||
528 | if (m_EventQueue.Count > 0) | 479 | if (EventQueue.Count > 0) |
529 | { | 480 | { |
530 | if (m_CurrentResult == null) | 481 | if (m_CurrentWorkItem == null) |
531 | m_CurrentResult = m_Engine.QueueEventHandler(this); | 482 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
532 | // else | 483 | // else |
533 | // m_log.Error("[Script] Tried to start a script that was already queued"); | 484 | // m_log.Error("[Script] Tried to start a script that was already queued"); |
534 | } | 485 | } |
@@ -538,51 +489,63 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
538 | public bool Stop(int timeout) | 489 | public bool Stop(int timeout) |
539 | { | 490 | { |
540 | // m_log.DebugFormat( | 491 | // m_log.DebugFormat( |
541 | // "[SCRIPT INSTANCE]: Stopping script {0} {1} with timeout {2}", ScriptName, ItemID, timeout); | 492 | // "[SCRIPT INSTANCE]: Stopping script {0} {1} in {2} {3} with timeout {4} {5} {6}", |
493 | // ScriptName, ItemID, PrimName, ObjectID, timeout, m_InSelfDelete, DateTime.Now.Ticks); | ||
542 | 494 | ||
543 | IScriptWorkItem result; | 495 | IScriptWorkItem workItem; |
544 | 496 | ||
545 | lock (m_EventQueue) | 497 | lock (EventQueue) |
546 | { | 498 | { |
547 | if (!Running) | 499 | if (!Running) |
548 | return true; | 500 | return true; |
549 | 501 | ||
550 | if (m_CurrentResult == null) | 502 | // If we're not running or waiting to run an event then we can safely stop. |
503 | if (m_CurrentWorkItem == null) | ||
551 | { | 504 | { |
552 | m_RunEvents = false; | 505 | Running = false; |
553 | return true; | 506 | return true; |
554 | } | 507 | } |
555 | 508 | ||
556 | if (m_CurrentResult.Cancel()) | 509 | // If we are waiting to run an event then we can try to cancel it. |
510 | if (m_CurrentWorkItem.Cancel()) | ||
557 | { | 511 | { |
558 | m_CurrentResult = null; | 512 | m_CurrentWorkItem = null; |
559 | m_RunEvents = false; | 513 | Running = false; |
560 | return true; | 514 | return true; |
561 | } | 515 | } |
562 | 516 | ||
563 | result = m_CurrentResult; | 517 | workItem = m_CurrentWorkItem; |
564 | m_RunEvents = false; | 518 | Running = false; |
565 | } | 519 | } |
566 | 520 | ||
567 | if (result.Wait(new TimeSpan((long)timeout * 100000))) | 521 | // Wait for the current event to complete. |
522 | if (!m_InSelfDelete && workItem.Wait(new TimeSpan((long)timeout * 100000))) | ||
568 | { | 523 | { |
569 | return true; | 524 | return true; |
570 | } | 525 | } |
571 | 526 | ||
572 | lock (m_EventQueue) | 527 | lock (EventQueue) |
573 | { | 528 | { |
574 | result = m_CurrentResult; | 529 | workItem = m_CurrentWorkItem; |
575 | } | 530 | } |
576 | 531 | ||
577 | if (result == null) | 532 | if (workItem == null) |
578 | return true; | 533 | return true; |
579 | 534 | ||
535 | // If the event still hasn't stopped and we the stop isn't the result of script or object removal, then | ||
536 | // forcibly abort the work item (this aborts the underlying thread). | ||
580 | if (!m_InSelfDelete) | 537 | if (!m_InSelfDelete) |
581 | result.Abort(); | 538 | { |
539 | // m_log.ErrorFormat( | ||
540 | // "[SCRIPT INSTANCE]: Aborting script {0} {1} in prim {2} {3} {4} {5}", | ||
541 | // ScriptName, ItemID, PrimName, ObjectID, m_InSelfDelete, DateTime.Now.Ticks); | ||
542 | |||
543 | workItem.Abort(); | ||
544 | } | ||
582 | 545 | ||
583 | lock (m_EventQueue) | 546 | lock (EventQueue) |
584 | { | 547 | { |
585 | m_CurrentResult = null; | 548 | m_CurrentWorkItem = null; |
586 | } | 549 | } |
587 | 550 | ||
588 | return true; | 551 | return true; |
@@ -603,10 +566,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
603 | throw new EventAbortException(); | 566 | throw new EventAbortException(); |
604 | } | 567 | } |
605 | 568 | ||
569 | /// <summary> | ||
570 | /// Post an event to this script instance. | ||
571 | /// </summary> | ||
572 | /// <remarks> | ||
573 | /// The request to run the event is sent | ||
574 | /// </remarks> | ||
575 | /// <param name="data"></param> | ||
606 | public void PostEvent(EventParams data) | 576 | public void PostEvent(EventParams data) |
607 | { | 577 | { |
608 | // m_log.DebugFormat("[Script] Posted event {2} in state {3} to {0}.{1}", | 578 | // m_log.DebugFormat("[Script] Posted event {2} in state {3} to {0}.{1}", |
609 | // m_PrimName, m_ScriptName, data.EventName, m_State); | 579 | // PrimName, ScriptName, data.EventName, State); |
610 | 580 | ||
611 | if (!Running) | 581 | if (!Running) |
612 | return; | 582 | return; |
@@ -621,9 +591,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
621 | m_nextEventTimeTicks = DateTime.Now.Ticks + m_eventDelayTicks; | 591 | m_nextEventTimeTicks = DateTime.Now.Ticks + m_eventDelayTicks; |
622 | } | 592 | } |
623 | 593 | ||
624 | lock (m_EventQueue) | 594 | lock (EventQueue) |
625 | { | 595 | { |
626 | if (m_EventQueue.Count >= m_MaxScriptQueue) | 596 | if (EventQueue.Count >= m_MaxScriptQueue) |
627 | return; | 597 | return; |
628 | 598 | ||
629 | if (data.EventName == "timer") | 599 | if (data.EventName == "timer") |
@@ -667,11 +637,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
667 | m_CollisionInQueue = true; | 637 | m_CollisionInQueue = true; |
668 | } | 638 | } |
669 | 639 | ||
670 | m_EventQueue.Enqueue(data); | 640 | EventQueue.Enqueue(data); |
671 | 641 | ||
672 | if (m_CurrentResult == null) | 642 | if (m_CurrentWorkItem == null) |
673 | { | 643 | { |
674 | m_CurrentResult = m_Engine.QueueEventHandler(this); | 644 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
675 | } | 645 | } |
676 | } | 646 | } |
677 | } | 647 | } |
@@ -682,6 +652,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
682 | /// <returns></returns> | 652 | /// <returns></returns> |
683 | public object EventProcessor() | 653 | public object EventProcessor() |
684 | { | 654 | { |
655 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. | ||
656 | if (!Running) | ||
657 | return 0; | ||
658 | |||
685 | lock (m_Script) | 659 | lock (m_Script) |
686 | { | 660 | { |
687 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); | 661 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); |
@@ -691,18 +665,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
691 | 665 | ||
692 | EventParams data = null; | 666 | EventParams data = null; |
693 | 667 | ||
694 | lock (m_EventQueue) | 668 | lock (EventQueue) |
695 | { | 669 | { |
696 | data = (EventParams) m_EventQueue.Dequeue(); | 670 | data = (EventParams)EventQueue.Dequeue(); |
697 | if (data == null) // Shouldn't happen | 671 | if (data == null) // Shouldn't happen |
698 | { | 672 | { |
699 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 673 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
700 | { | 674 | { |
701 | m_CurrentResult = m_Engine.QueueEventHandler(this); | 675 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
702 | } | 676 | } |
703 | else | 677 | else |
704 | { | 678 | { |
705 | m_CurrentResult = null; | 679 | m_CurrentWorkItem = null; |
706 | } | 680 | } |
707 | return 0; | 681 | return 0; |
708 | } | 682 | } |
@@ -725,28 +699,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
725 | if (data.EventName == "state") // Hardcoded state change | 699 | if (data.EventName == "state") // Hardcoded state change |
726 | { | 700 | { |
727 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", | 701 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", |
728 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); | 702 | // PrimName, ScriptName, data.Params[0].ToString()); |
729 | m_State = data.Params[0].ToString(); | 703 | State = data.Params[0].ToString(); |
730 | AsyncCommandManager.RemoveScript(m_Engine, | 704 | AsyncCommandManager.RemoveScript(Engine, |
731 | m_LocalID, m_ItemID); | 705 | LocalID, ItemID); |
732 | 706 | ||
733 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 707 | SceneObjectPart part = Engine.World.GetSceneObjectPart( |
734 | m_LocalID); | 708 | LocalID); |
735 | if (part != null) | 709 | if (part != null) |
736 | { | 710 | { |
737 | part.SetScriptEvents(m_ItemID, | 711 | part.SetScriptEvents(ItemID, |
738 | (int)m_Script.GetStateEventFlags(State)); | 712 | (int)m_Script.GetStateEventFlags(State)); |
739 | } | 713 | } |
740 | } | 714 | } |
741 | else | 715 | else |
742 | { | 716 | { |
743 | if (m_Engine.World.PipeEventsForScript(m_LocalID) || | 717 | if (Engine.World.PipeEventsForScript(LocalID) || |
744 | data.EventName == "control") // Don't freeze avies! | 718 | data.EventName == "control") // Don't freeze avies! |
745 | { | 719 | { |
746 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 720 | SceneObjectPart part = Engine.World.GetSceneObjectPart( |
747 | m_LocalID); | 721 | LocalID); |
748 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", | 722 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", |
749 | // m_PrimName, m_ScriptName, data.EventName, m_State); | 723 | // PrimName, ScriptName, data.EventName, State); |
750 | 724 | ||
751 | try | 725 | try |
752 | { | 726 | { |
@@ -754,8 +728,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
754 | m_EventStart = DateTime.Now; | 728 | m_EventStart = DateTime.Now; |
755 | m_InEvent = true; | 729 | m_InEvent = true; |
756 | 730 | ||
731 | int start = Util.EnvironmentTickCount(); | ||
732 | |||
733 | // Reset the measurement period when we reach the end of the current one. | ||
734 | if (start - MeasurementPeriodTickStart > MaxMeasurementPeriod) | ||
735 | MeasurementPeriodTickStart = start; | ||
736 | |||
757 | m_Script.ExecuteEvent(State, data.EventName, data.Params); | 737 | m_Script.ExecuteEvent(State, data.EventName, data.Params); |
758 | 738 | ||
739 | MeasurementPeriodExecutionTime += Util.EnvironmentTickCount() - start; | ||
740 | |||
759 | m_InEvent = false; | 741 | m_InEvent = false; |
760 | m_CurrentEvent = String.Empty; | 742 | m_CurrentEvent = String.Empty; |
761 | 743 | ||
@@ -764,7 +746,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
764 | // This will be the very first event we deliver | 746 | // This will be the very first event we deliver |
765 | // (state_entry) in default state | 747 | // (state_entry) in default state |
766 | // | 748 | // |
767 | |||
768 | SaveState(m_Assembly); | 749 | SaveState(m_Assembly); |
769 | 750 | ||
770 | m_SaveState = false; | 751 | m_SaveState = false; |
@@ -788,7 +769,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
788 | 769 | ||
789 | if (text.Length > 1000) | 770 | if (text.Length > 1000) |
790 | text = text.Substring(0, 1000); | 771 | text = text.Substring(0, 1000); |
791 | m_Engine.World.SimChat(Utils.StringToBytes(text), | 772 | Engine.World.SimChat(Utils.StringToBytes(text), |
792 | ChatTypeEnum.DebugChannel, 2147483647, | 773 | ChatTypeEnum.DebugChannel, 2147483647, |
793 | part.AbsolutePosition, | 774 | part.AbsolutePosition, |
794 | part.Name, part.UUID, false); | 775 | part.Name, part.UUID, false); |
@@ -810,27 +791,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
810 | { | 791 | { |
811 | m_InSelfDelete = true; | 792 | m_InSelfDelete = true; |
812 | if (part != null) | 793 | if (part != null) |
813 | m_Engine.World.DeleteSceneObject(part.ParentGroup, false); | 794 | Engine.World.DeleteSceneObject(part.ParentGroup, false); |
814 | } | 795 | } |
815 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) | 796 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) |
816 | { | 797 | { |
817 | m_InSelfDelete = true; | 798 | m_InSelfDelete = true; |
818 | if (part != null) | 799 | if (part != null) |
819 | part.Inventory.RemoveInventoryItem(m_ItemID); | 800 | part.Inventory.RemoveInventoryItem(ItemID); |
820 | } | 801 | } |
821 | } | 802 | } |
822 | } | 803 | } |
823 | } | 804 | } |
824 | 805 | ||
825 | lock (m_EventQueue) | 806 | // If there are more events and we are currently running and not shutting down, then ask the |
807 | // script engine to run the next event. | ||
808 | lock (EventQueue) | ||
826 | { | 809 | { |
827 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 810 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
828 | { | 811 | { |
829 | m_CurrentResult = m_Engine.QueueEventHandler(this); | 812 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
830 | } | 813 | } |
831 | else | 814 | else |
832 | { | 815 | { |
833 | m_CurrentResult = null; | 816 | m_CurrentWorkItem = null; |
834 | } | 817 | } |
835 | } | 818 | } |
836 | 819 | ||
@@ -859,15 +842,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
859 | ReleaseControls(); | 842 | ReleaseControls(); |
860 | 843 | ||
861 | Stop(0); | 844 | Stop(0); |
862 | SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); | 845 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
863 | part.Inventory.GetInventoryItem(m_ItemID).PermsMask = 0; | 846 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
864 | part.Inventory.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero; | 847 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
865 | AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); | 848 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
866 | m_EventQueue.Clear(); | 849 | EventQueue.Clear(); |
867 | m_Script.ResetVars(); | 850 | m_Script.ResetVars(); |
868 | m_State = "default"; | 851 | State = "default"; |
869 | 852 | ||
870 | part.SetScriptEvents(m_ItemID, | 853 | part.SetScriptEvents(ItemID, |
871 | (int)m_Script.GetStateEventFlags(State)); | 854 | (int)m_Script.GetStateEventFlags(State)); |
872 | if (running) | 855 | if (running) |
873 | Start(); | 856 | Start(); |
@@ -884,16 +867,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
884 | ReleaseControls(); | 867 | ReleaseControls(); |
885 | 868 | ||
886 | m_Script.ResetVars(); | 869 | m_Script.ResetVars(); |
887 | SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); | 870 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
888 | part.Inventory.GetInventoryItem(m_ItemID).PermsMask = 0; | 871 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
889 | part.Inventory.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero; | 872 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
890 | AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); | 873 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
891 | 874 | ||
892 | m_EventQueue.Clear(); | 875 | EventQueue.Clear(); |
893 | m_Script.ResetVars(); | 876 | m_Script.ResetVars(); |
894 | m_State = "default"; | 877 | State = "default"; |
895 | 878 | ||
896 | part.SetScriptEvents(m_ItemID, | 879 | part.SetScriptEvents(ItemID, |
897 | (int)m_Script.GetStateEventFlags(State)); | 880 | (int)m_Script.GetStateEventFlags(State)); |
898 | 881 | ||
899 | if (m_CurrentEvent != "state_entry") | 882 | if (m_CurrentEvent != "state_entry") |
@@ -940,8 +923,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
940 | 923 | ||
941 | public void SaveState(string assembly) | 924 | public void SaveState(string assembly) |
942 | { | 925 | { |
943 | |||
944 | |||
945 | // If we're currently in an event, just tell it to save upon return | 926 | // If we're currently in an event, just tell it to save upon return |
946 | // | 927 | // |
947 | if (m_InEvent) | 928 | if (m_InEvent) |
@@ -950,7 +931,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
950 | return; | 931 | return; |
951 | } | 932 | } |
952 | 933 | ||
953 | PluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID); | 934 | PluginData = AsyncCommandManager.GetSerializationData(Engine, ItemID); |
954 | 935 | ||
955 | string xml = ScriptSerializer.Serialize(this); | 936 | string xml = ScriptSerializer.Serialize(this); |
956 | 937 | ||
@@ -962,7 +943,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
962 | { | 943 | { |
963 | try | 944 | try |
964 | { | 945 | { |
965 | FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state")); | 946 | FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state")); |
966 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | 947 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); |
967 | Byte[] buf = enc.GetBytes(xml); | 948 | Byte[] buf = enc.GetBytes(xml); |
968 | fs.Write(buf, 0, buf.Length); | 949 | fs.Write(buf, 0, buf.Length); |
@@ -972,7 +953,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
972 | { | 953 | { |
973 | // m_log.Error("Unable to save xml\n"+e.ToString()); | 954 | // m_log.Error("Unable to save xml\n"+e.ToString()); |
974 | } | 955 | } |
975 | //if (!File.Exists(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state"))) | 956 | //if (!File.Exists(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state"))) |
976 | //{ | 957 | //{ |
977 | // throw new Exception("Completed persistence save, but no file was created"); | 958 | // throw new Exception("Completed persistence save, but no file was created"); |
978 | //} | 959 | //} |
@@ -989,7 +970,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
989 | 970 | ||
990 | public override string ToString() | 971 | public override string ToString() |
991 | { | 972 | { |
992 | return String.Format("{0} {1} on {2}", m_ScriptName, m_ItemID, m_PrimName); | 973 | return String.Format("{0} {1} on {2}", ScriptName, ItemID, PrimName); |
993 | } | 974 | } |
994 | 975 | ||
995 | string FormatException(Exception e) | 976 | string FormatException(Exception e) |
@@ -1057,7 +1038,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1057 | 1038 | ||
1058 | // Force an update of the in-memory plugin data | 1039 | // Force an update of the in-memory plugin data |
1059 | // | 1040 | // |
1060 | PluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID); | 1041 | PluginData = AsyncCommandManager.GetSerializationData(Engine, ItemID); |
1061 | 1042 | ||
1062 | return ScriptSerializer.Serialize(this); | 1043 | return ScriptSerializer.Serialize(this); |
1063 | } | 1044 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs new file mode 100644 index 0000000..e2d0db2 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs | |||
@@ -0,0 +1,168 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.Assets; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | ||
40 | using OpenSim.Region.OptionalModules.World.NPC; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using OpenSim.Region.ScriptEngine.Shared; | ||
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
44 | using OpenSim.Services.Interfaces; | ||
45 | using OpenSim.Tests.Common; | ||
46 | using OpenSim.Tests.Common.Mock; | ||
47 | |||
48 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | ||
49 | { | ||
50 | /// <summary> | ||
51 | /// Tests for inventory functions in LSL | ||
52 | /// </summary> | ||
53 | [TestFixture] | ||
54 | public class LSL_ApiInventoryTests | ||
55 | { | ||
56 | protected Scene m_scene; | ||
57 | protected XEngine.XEngine m_engine; | ||
58 | |||
59 | [SetUp] | ||
60 | public void SetUp() | ||
61 | { | ||
62 | IConfigSource initConfigSource = new IniConfigSource(); | ||
63 | IConfig config = initConfigSource.AddConfig("XEngine"); | ||
64 | config.Set("Enabled", "true"); | ||
65 | |||
66 | m_scene = SceneHelpers.SetupScene(); | ||
67 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); | ||
68 | |||
69 | m_engine = new XEngine.XEngine(); | ||
70 | m_engine.Initialise(initConfigSource); | ||
71 | m_engine.AddRegion(m_scene); | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// Test giving inventory from an object to an object where both are owned by the same user. | ||
76 | /// </summary> | ||
77 | [Test] | ||
78 | public void TestLlGiveInventoryO2OSameOwner() | ||
79 | { | ||
80 | TestHelpers.InMethod(); | ||
81 | // log4net.Config.XmlConfigurator.Configure(); | ||
82 | |||
83 | UUID userId = TestHelpers.ParseTail(0x1); | ||
84 | string inventoryItemName = "item1"; | ||
85 | |||
86 | SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, userId, "so1", 0x10); | ||
87 | m_scene.AddSceneObject(so1); | ||
88 | |||
89 | // Create an object embedded inside the first | ||
90 | UUID itemId = TestHelpers.ParseTail(0x20); | ||
91 | TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, userId); | ||
92 | |||
93 | LSL_Api api = new LSL_Api(); | ||
94 | api.Initialize(m_engine, so1.RootPart, so1.RootPart.LocalId, so1.RootPart.UUID); | ||
95 | |||
96 | // Create a second object | ||
97 | SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, userId, "so2", 0x100); | ||
98 | m_scene.AddSceneObject(so2); | ||
99 | |||
100 | api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); | ||
101 | |||
102 | // Item has copy permissions so original should stay intact. | ||
103 | List<TaskInventoryItem> originalItems = so1.RootPart.Inventory.GetInventoryItems(); | ||
104 | Assert.That(originalItems.Count, Is.EqualTo(1)); | ||
105 | |||
106 | List<TaskInventoryItem> copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName); | ||
107 | Assert.That(copiedItems.Count, Is.EqualTo(1)); | ||
108 | Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName)); | ||
109 | } | ||
110 | |||
111 | /// <summary> | ||
112 | /// Test giving inventory from an object to an object where they have different owners | ||
113 | /// </summary> | ||
114 | [Test] | ||
115 | public void TestLlGiveInventoryO2ODifferentOwners() | ||
116 | { | ||
117 | TestHelpers.InMethod(); | ||
118 | // log4net.Config.XmlConfigurator.Configure(); | ||
119 | |||
120 | UUID user1Id = TestHelpers.ParseTail(0x1); | ||
121 | UUID user2Id = TestHelpers.ParseTail(0x2); | ||
122 | string inventoryItemName = "item1"; | ||
123 | |||
124 | SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); | ||
125 | m_scene.AddSceneObject(so1); | ||
126 | LSL_Api api = new LSL_Api(); | ||
127 | api.Initialize(m_engine, so1.RootPart, so1.RootPart.LocalId, so1.RootPart.UUID); | ||
128 | |||
129 | // Create an object embedded inside the first | ||
130 | UUID itemId = TestHelpers.ParseTail(0x20); | ||
131 | TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, user1Id); | ||
132 | |||
133 | // Create a second object | ||
134 | SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); | ||
135 | m_scene.AddSceneObject(so2); | ||
136 | LSL_Api api2 = new LSL_Api(); | ||
137 | api2.Initialize(m_engine, so2.RootPart, so2.RootPart.LocalId, so2.RootPart.UUID); | ||
138 | |||
139 | // *** Firstly, we test where llAllowInventoryDrop() has not been called. *** | ||
140 | api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); | ||
141 | |||
142 | { | ||
143 | // Item has copy permissions so original should stay intact. | ||
144 | List<TaskInventoryItem> originalItems = so1.RootPart.Inventory.GetInventoryItems(); | ||
145 | Assert.That(originalItems.Count, Is.EqualTo(1)); | ||
146 | |||
147 | // Should have not copied | ||
148 | List<TaskInventoryItem> copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName); | ||
149 | Assert.That(copiedItems.Count, Is.EqualTo(0)); | ||
150 | } | ||
151 | |||
152 | // *** Secondly, we turn on allow inventory drop in the target and retest. *** | ||
153 | api2.llAllowInventoryDrop(1); | ||
154 | api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); | ||
155 | |||
156 | { | ||
157 | // Item has copy permissions so original should stay intact. | ||
158 | List<TaskInventoryItem> originalItems = so1.RootPart.Inventory.GetInventoryItems(); | ||
159 | Assert.That(originalItems.Count, Is.EqualTo(1)); | ||
160 | |||
161 | // Should now have copied. | ||
162 | List<TaskInventoryItem> copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName); | ||
163 | Assert.That(copiedItems.Count, Is.EqualTo(1)); | ||
164 | Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName)); | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 3baa723..9cf9258 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | |||
@@ -46,7 +46,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
46 | [TestFixture, LongRunning] | 46 | [TestFixture, LongRunning] |
47 | public class LSL_ApiTest | 47 | public class LSL_ApiTest |
48 | { | 48 | { |
49 | |||
50 | private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; | 49 | private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; |
51 | private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; | 50 | private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; |
52 | private const float FLOAT_ACCURACY = 0.00005f; | 51 | private const float FLOAT_ACCURACY = 0.00005f; |
@@ -55,7 +54,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
55 | [SetUp] | 54 | [SetUp] |
56 | public void SetUp() | 55 | public void SetUp() |
57 | { | 56 | { |
58 | |||
59 | IConfigSource initConfigSource = new IniConfigSource(); | 57 | IConfigSource initConfigSource = new IniConfigSource(); |
60 | IConfig config = initConfigSource.AddConfig("XEngine"); | 58 | IConfig config = initConfigSource.AddConfig("XEngine"); |
61 | config.Set("Enabled", "true"); | 59 | config.Set("Enabled", "true"); |
@@ -75,6 +73,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
75 | [Test] | 73 | [Test] |
76 | public void TestllAngleBetween() | 74 | public void TestllAngleBetween() |
77 | { | 75 | { |
76 | TestHelpers.InMethod(); | ||
77 | |||
78 | CheckllAngleBetween(new Vector3(1, 0, 0), 0, 1, 1); | 78 | CheckllAngleBetween(new Vector3(1, 0, 0), 0, 1, 1); |
79 | CheckllAngleBetween(new Vector3(1, 0, 0), 90, 1, 1); | 79 | CheckllAngleBetween(new Vector3(1, 0, 0), 90, 1, 1); |
80 | CheckllAngleBetween(new Vector3(1, 0, 0), 180, 1, 1); | 80 | CheckllAngleBetween(new Vector3(1, 0, 0), 180, 1, 1); |
@@ -158,6 +158,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
158 | // llRot2Euler test. | 158 | // llRot2Euler test. |
159 | public void TestllRot2Euler() | 159 | public void TestllRot2Euler() |
160 | { | 160 | { |
161 | TestHelpers.InMethod(); | ||
162 | |||
161 | // 180, 90 and zero degree rotations. | 163 | // 180, 90 and zero degree rotations. |
162 | CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.0f, 1.0f)); | 164 | CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.0f, 1.0f)); |
163 | CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.707107f, 0.707107f)); | 165 | CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.707107f, 0.707107f)); |
@@ -256,6 +258,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
256 | // llSetPrimitiveParams and llGetPrimitiveParams test. | 258 | // llSetPrimitiveParams and llGetPrimitiveParams test. |
257 | public void TestllSetPrimitiveParams() | 259 | public void TestllSetPrimitiveParams() |
258 | { | 260 | { |
261 | TestHelpers.InMethod(); | ||
262 | |||
259 | // Create Prim1. | 263 | // Create Prim1. |
260 | Scene scene = SceneHelpers.SetupScene(); | 264 | Scene scene = SceneHelpers.SetupScene(); |
261 | string obj1Name = "Prim1"; | 265 | string obj1Name = "Prim1"; |
@@ -486,9 +490,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
486 | } | 490 | } |
487 | 491 | ||
488 | [Test] | 492 | [Test] |
489 | // llVecNorm test. | ||
490 | public void TestllVecNorm() | 493 | public void TestllVecNorm() |
491 | { | 494 | { |
495 | TestHelpers.InMethod(); | ||
496 | |||
492 | // Check special case for normalizing zero vector. | 497 | // Check special case for normalizing zero vector. |
493 | CheckllVecNorm(new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); | 498 | CheckllVecNorm(new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); |
494 | // Check various vectors. | 499 | // Check various vectors. |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs index 10b52cf..3ed2562 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs | |||
@@ -213,6 +213,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
213 | [Test] | 213 | [Test] |
214 | public void TestConstructFromInt() | 214 | public void TestConstructFromInt() |
215 | { | 215 | { |
216 | TestHelpers.InMethod(); | ||
217 | |||
216 | LSL_Types.LSLFloat testFloat; | 218 | LSL_Types.LSLFloat testFloat; |
217 | 219 | ||
218 | foreach (KeyValuePair<int, double> number in m_intDoubleSet) | 220 | foreach (KeyValuePair<int, double> number in m_intDoubleSet) |
@@ -228,6 +230,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
228 | [Test] | 230 | [Test] |
229 | public void TestConstructFromDouble() | 231 | public void TestConstructFromDouble() |
230 | { | 232 | { |
233 | TestHelpers.InMethod(); | ||
234 | |||
231 | LSL_Types.LSLFloat testFloat; | 235 | LSL_Types.LSLFloat testFloat; |
232 | 236 | ||
233 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) | 237 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) |
@@ -243,6 +247,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
243 | [Test] | 247 | [Test] |
244 | public void TestExplicitCastLSLFloatToInt() | 248 | public void TestExplicitCastLSLFloatToInt() |
245 | { | 249 | { |
250 | TestHelpers.InMethod(); | ||
251 | |||
246 | int testNumber; | 252 | int testNumber; |
247 | 253 | ||
248 | foreach (KeyValuePair<double, int> number in m_doubleIntSet) | 254 | foreach (KeyValuePair<double, int> number in m_doubleIntSet) |
@@ -258,6 +264,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
258 | [Test] | 264 | [Test] |
259 | public void TestExplicitCastLSLFloatToUint() | 265 | public void TestExplicitCastLSLFloatToUint() |
260 | { | 266 | { |
267 | TestHelpers.InMethod(); | ||
268 | |||
261 | uint testNumber; | 269 | uint testNumber; |
262 | 270 | ||
263 | foreach (KeyValuePair<double, int> number in m_doubleUintSet) | 271 | foreach (KeyValuePair<double, int> number in m_doubleUintSet) |
@@ -273,6 +281,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
273 | [Test] | 281 | [Test] |
274 | public void TestImplicitCastLSLFloatToBooleanTrue() | 282 | public void TestImplicitCastLSLFloatToBooleanTrue() |
275 | { | 283 | { |
284 | TestHelpers.InMethod(); | ||
285 | |||
276 | LSL_Types.LSLFloat testFloat; | 286 | LSL_Types.LSLFloat testFloat; |
277 | bool testBool; | 287 | bool testBool; |
278 | 288 | ||
@@ -291,6 +301,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
291 | [Test] | 301 | [Test] |
292 | public void TestImplicitCastLSLFloatToBooleanFalse() | 302 | public void TestImplicitCastLSLFloatToBooleanFalse() |
293 | { | 303 | { |
304 | TestHelpers.InMethod(); | ||
305 | |||
294 | LSL_Types.LSLFloat testFloat = new LSL_Types.LSLFloat(0.0); | 306 | LSL_Types.LSLFloat testFloat = new LSL_Types.LSLFloat(0.0); |
295 | bool testBool = testFloat; | 307 | bool testBool = testFloat; |
296 | 308 | ||
@@ -303,6 +315,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
303 | [Test] | 315 | [Test] |
304 | public void TestImplicitCastIntToLSLFloat() | 316 | public void TestImplicitCastIntToLSLFloat() |
305 | { | 317 | { |
318 | TestHelpers.InMethod(); | ||
319 | |||
306 | LSL_Types.LSLFloat testFloat; | 320 | LSL_Types.LSLFloat testFloat; |
307 | 321 | ||
308 | foreach (int number in m_intList) | 322 | foreach (int number in m_intList) |
@@ -318,6 +332,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
318 | [Test] | 332 | [Test] |
319 | public void TestImplicitCastLSLIntegerToLSLFloat() | 333 | public void TestImplicitCastLSLIntegerToLSLFloat() |
320 | { | 334 | { |
335 | TestHelpers.InMethod(); | ||
336 | |||
321 | LSL_Types.LSLFloat testFloat; | 337 | LSL_Types.LSLFloat testFloat; |
322 | 338 | ||
323 | foreach (int number in m_intList) | 339 | foreach (int number in m_intList) |
@@ -333,6 +349,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
333 | [Test] | 349 | [Test] |
334 | public void TestExplicitCastLSLIntegerToLSLFloat() | 350 | public void TestExplicitCastLSLIntegerToLSLFloat() |
335 | { | 351 | { |
352 | TestHelpers.InMethod(); | ||
353 | |||
336 | LSL_Types.LSLFloat testFloat; | 354 | LSL_Types.LSLFloat testFloat; |
337 | 355 | ||
338 | foreach (int number in m_intList) | 356 | foreach (int number in m_intList) |
@@ -348,6 +366,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
348 | [Test] | 366 | [Test] |
349 | public void TestExplicitCastStringToLSLFloat() | 367 | public void TestExplicitCastStringToLSLFloat() |
350 | { | 368 | { |
369 | TestHelpers.InMethod(); | ||
370 | |||
351 | LSL_Types.LSLFloat testFloat; | 371 | LSL_Types.LSLFloat testFloat; |
352 | 372 | ||
353 | foreach (KeyValuePair<string, double> number in m_stringDoubleSet) | 373 | foreach (KeyValuePair<string, double> number in m_stringDoubleSet) |
@@ -363,6 +383,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
363 | [Test] | 383 | [Test] |
364 | public void TestExplicitCastLSLStringToLSLFloat() | 384 | public void TestExplicitCastLSLStringToLSLFloat() |
365 | { | 385 | { |
386 | TestHelpers.InMethod(); | ||
387 | |||
366 | LSL_Types.LSLFloat testFloat; | 388 | LSL_Types.LSLFloat testFloat; |
367 | 389 | ||
368 | foreach (KeyValuePair<string, double> number in m_stringDoubleSet) | 390 | foreach (KeyValuePair<string, double> number in m_stringDoubleSet) |
@@ -378,6 +400,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
378 | [Test] | 400 | [Test] |
379 | public void TestImplicitCastDoubleToLSLFloat() | 401 | public void TestImplicitCastDoubleToLSLFloat() |
380 | { | 402 | { |
403 | TestHelpers.InMethod(); | ||
404 | |||
381 | LSL_Types.LSLFloat testFloat; | 405 | LSL_Types.LSLFloat testFloat; |
382 | 406 | ||
383 | foreach (double number in m_doubleList) | 407 | foreach (double number in m_doubleList) |
@@ -393,6 +417,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
393 | [Test] | 417 | [Test] |
394 | public void TestImplicitCastLSLFloatToDouble() | 418 | public void TestImplicitCastLSLFloatToDouble() |
395 | { | 419 | { |
420 | TestHelpers.InMethod(); | ||
421 | |||
396 | double testNumber; | 422 | double testNumber; |
397 | LSL_Types.LSLFloat testFloat; | 423 | LSL_Types.LSLFloat testFloat; |
398 | 424 | ||
@@ -411,19 +437,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
411 | [Test] | 437 | [Test] |
412 | public void TestExplicitCastLSLFloatToFloat() | 438 | public void TestExplicitCastLSLFloatToFloat() |
413 | { | 439 | { |
414 | float testFloat; | 440 | TestHelpers.InMethod(); |
415 | float numberAsFloat; | 441 | |
416 | LSL_Types.LSLFloat testLSLFloat; | 442 | float testFloat; |
417 | foreach (double number in m_doubleList) | 443 | float numberAsFloat; |
418 | { | 444 | LSL_Types.LSLFloat testLSLFloat; |
419 | testLSLFloat = new LSL_Types.LSLFloat(number); | ||
420 | numberAsFloat = (float)number; | ||
421 | testFloat = (float)testLSLFloat; | ||
422 | |||
423 | Assert.That((double)testFloat, new DoubleToleranceConstraint((double)numberAsFloat, _lowPrecisionTolerance)); | ||
424 | } | ||
425 | } | ||
426 | 445 | ||
446 | foreach (double number in m_doubleList) | ||
447 | { | ||
448 | testLSLFloat = new LSL_Types.LSLFloat(number); | ||
449 | numberAsFloat = (float)number; | ||
450 | testFloat = (float)testLSLFloat; | ||
451 | |||
452 | Assert.That((double)testFloat, new DoubleToleranceConstraint((double)numberAsFloat, _lowPrecisionTolerance)); | ||
453 | } | ||
454 | } | ||
427 | 455 | ||
428 | /// <summary> | 456 | /// <summary> |
429 | /// Tests the equality (==) operator. | 457 | /// Tests the equality (==) operator. |
@@ -431,6 +459,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
431 | [Test] | 459 | [Test] |
432 | public void TestEqualsOperator() | 460 | public void TestEqualsOperator() |
433 | { | 461 | { |
462 | TestHelpers.InMethod(); | ||
463 | |||
434 | LSL_Types.LSLFloat testFloatA, testFloatB; | 464 | LSL_Types.LSLFloat testFloatA, testFloatB; |
435 | 465 | ||
436 | foreach (double number in m_doubleList) | 466 | foreach (double number in m_doubleList) |
@@ -450,6 +480,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
450 | [Test] | 480 | [Test] |
451 | public void TestNotEqualOperator() | 481 | public void TestNotEqualOperator() |
452 | { | 482 | { |
483 | TestHelpers.InMethod(); | ||
484 | |||
453 | LSL_Types.LSLFloat testFloatA, testFloatB; | 485 | LSL_Types.LSLFloat testFloatA, testFloatB; |
454 | 486 | ||
455 | foreach (double number in m_doubleList) | 487 | foreach (double number in m_doubleList) |
@@ -469,6 +501,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
469 | [Test] | 501 | [Test] |
470 | public void TestIncrementOperator() | 502 | public void TestIncrementOperator() |
471 | { | 503 | { |
504 | TestHelpers.InMethod(); | ||
505 | |||
472 | LSL_Types.LSLFloat testFloat; | 506 | LSL_Types.LSLFloat testFloat; |
473 | double testNumber; | 507 | double testNumber; |
474 | 508 | ||
@@ -493,6 +527,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
493 | [Test] | 527 | [Test] |
494 | public void TestDecrementOperator() | 528 | public void TestDecrementOperator() |
495 | { | 529 | { |
530 | TestHelpers.InMethod(); | ||
531 | |||
496 | LSL_Types.LSLFloat testFloat; | 532 | LSL_Types.LSLFloat testFloat; |
497 | double testNumber; | 533 | double testNumber; |
498 | 534 | ||
@@ -517,6 +553,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
517 | [Test] | 553 | [Test] |
518 | public void TestToString() | 554 | public void TestToString() |
519 | { | 555 | { |
556 | TestHelpers.InMethod(); | ||
557 | |||
520 | LSL_Types.LSLFloat testFloat; | 558 | LSL_Types.LSLFloat testFloat; |
521 | 559 | ||
522 | foreach (KeyValuePair<double, string> number in m_doubleStringSet) | 560 | foreach (KeyValuePair<double, string> number in m_doubleStringSet) |
@@ -532,6 +570,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
532 | [Test] | 570 | [Test] |
533 | public void TestAddTwoLSLFloats() | 571 | public void TestAddTwoLSLFloats() |
534 | { | 572 | { |
573 | TestHelpers.InMethod(); | ||
574 | |||
535 | LSL_Types.LSLFloat testResult; | 575 | LSL_Types.LSLFloat testResult; |
536 | 576 | ||
537 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) | 577 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) |
@@ -547,6 +587,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
547 | [Test] | 587 | [Test] |
548 | public void TestSubtractTwoLSLFloats() | 588 | public void TestSubtractTwoLSLFloats() |
549 | { | 589 | { |
590 | TestHelpers.InMethod(); | ||
591 | |||
550 | LSL_Types.LSLFloat testResult; | 592 | LSL_Types.LSLFloat testResult; |
551 | 593 | ||
552 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) | 594 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) |
@@ -562,6 +604,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
562 | [Test] | 604 | [Test] |
563 | public void TestMultiplyTwoLSLFloats() | 605 | public void TestMultiplyTwoLSLFloats() |
564 | { | 606 | { |
607 | TestHelpers.InMethod(); | ||
608 | |||
565 | LSL_Types.LSLFloat testResult; | 609 | LSL_Types.LSLFloat testResult; |
566 | 610 | ||
567 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) | 611 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) |
@@ -577,6 +621,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
577 | [Test] | 621 | [Test] |
578 | public void TestDivideTwoLSLFloats() | 622 | public void TestDivideTwoLSLFloats() |
579 | { | 623 | { |
624 | TestHelpers.InMethod(); | ||
625 | |||
580 | LSL_Types.LSLFloat testResult; | 626 | LSL_Types.LSLFloat testResult; |
581 | 627 | ||
582 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) | 628 | foreach (KeyValuePair<double, double> number in m_doubleDoubleSet) |
@@ -595,6 +641,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
595 | [Test] | 641 | [Test] |
596 | public void TestImplicitCastBooleanToLSLFloat() | 642 | public void TestImplicitCastBooleanToLSLFloat() |
597 | { | 643 | { |
644 | TestHelpers.InMethod(); | ||
645 | |||
598 | LSL_Types.LSLFloat testFloat; | 646 | LSL_Types.LSLFloat testFloat; |
599 | 647 | ||
600 | testFloat = (1 == 0); | 648 | testFloat = (1 == 0); |
@@ -610,4 +658,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
610 | Assert.That(testFloat.value, new DoubleToleranceConstraint(1.0, _lowPrecisionTolerance)); | 658 | Assert.That(testFloat.value, new DoubleToleranceConstraint(1.0, _lowPrecisionTolerance)); |
611 | } | 659 | } |
612 | } | 660 | } |
613 | } | 661 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs index 3ad673b..8d1169a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs | |||
@@ -79,6 +79,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
79 | [Test] | 79 | [Test] |
80 | public void TestExplicitCastLSLFloatToLSLInteger() | 80 | public void TestExplicitCastLSLFloatToLSLInteger() |
81 | { | 81 | { |
82 | TestHelpers.InMethod(); | ||
83 | |||
82 | LSL_Types.LSLInteger testInteger; | 84 | LSL_Types.LSLInteger testInteger; |
83 | 85 | ||
84 | foreach (KeyValuePair<double, int> number in m_doubleIntSet) | 86 | foreach (KeyValuePair<double, int> number in m_doubleIntSet) |
@@ -94,6 +96,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
94 | [Test] | 96 | [Test] |
95 | public void TestExplicitCastStringToLSLInteger() | 97 | public void TestExplicitCastStringToLSLInteger() |
96 | { | 98 | { |
99 | TestHelpers.InMethod(); | ||
100 | |||
97 | LSL_Types.LSLInteger testInteger; | 101 | LSL_Types.LSLInteger testInteger; |
98 | 102 | ||
99 | foreach (KeyValuePair<string, int> number in m_stringIntSet) | 103 | foreach (KeyValuePair<string, int> number in m_stringIntSet) |
@@ -109,6 +113,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
109 | [Test] | 113 | [Test] |
110 | public void TestExplicitCastLSLStringToLSLInteger() | 114 | public void TestExplicitCastLSLStringToLSLInteger() |
111 | { | 115 | { |
116 | TestHelpers.InMethod(); | ||
117 | |||
112 | LSL_Types.LSLInteger testInteger; | 118 | LSL_Types.LSLInteger testInteger; |
113 | 119 | ||
114 | foreach (KeyValuePair<string, int> number in m_stringIntSet) | 120 | foreach (KeyValuePair<string, int> number in m_stringIntSet) |
@@ -124,6 +130,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
124 | [Test] | 130 | [Test] |
125 | public void TestImplicitCastBooleanToLSLInteger() | 131 | public void TestImplicitCastBooleanToLSLInteger() |
126 | { | 132 | { |
133 | TestHelpers.InMethod(); | ||
134 | |||
127 | LSL_Types.LSLInteger testInteger; | 135 | LSL_Types.LSLInteger testInteger; |
128 | 136 | ||
129 | testInteger = (1 == 0); | 137 | testInteger = (1 == 0); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs index fa976ed..c4ca1a8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs | |||
@@ -71,6 +71,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
71 | [Test] | 71 | [Test] |
72 | public void TestConstructFromLSLFloat() | 72 | public void TestConstructFromLSLFloat() |
73 | { | 73 | { |
74 | TestHelpers.InMethod(); | ||
75 | |||
74 | LSL_Types.LSLString testString; | 76 | LSL_Types.LSLString testString; |
75 | 77 | ||
76 | foreach (KeyValuePair<double, string> number in m_doubleStringSet) | 78 | foreach (KeyValuePair<double, string> number in m_doubleStringSet) |
@@ -86,6 +88,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
86 | [Test] | 88 | [Test] |
87 | public void TestExplicitCastLSLFloatToLSLString() | 89 | public void TestExplicitCastLSLFloatToLSLString() |
88 | { | 90 | { |
91 | TestHelpers.InMethod(); | ||
92 | |||
89 | LSL_Types.LSLString testString; | 93 | LSL_Types.LSLString testString; |
90 | 94 | ||
91 | foreach (KeyValuePair<double, string> number in m_doubleStringSet) | 95 | foreach (KeyValuePair<double, string> number in m_doubleStringSet) |
@@ -101,6 +105,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
101 | [Test] | 105 | [Test] |
102 | public void TestExplicitCastLSLStringToQuaternion() | 106 | public void TestExplicitCastLSLStringToQuaternion() |
103 | { | 107 | { |
108 | TestHelpers.InMethod(); | ||
109 | |||
104 | string quaternionString = "<0.00000, 0.70711, 0.00000, 0.70711>"; | 110 | string quaternionString = "<0.00000, 0.70711, 0.00000, 0.70711>"; |
105 | LSL_Types.LSLString quaternionLSLString = new LSL_Types.LSLString(quaternionString); | 111 | LSL_Types.LSLString quaternionLSLString = new LSL_Types.LSLString(quaternionString); |
106 | 112 | ||
@@ -118,6 +124,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
118 | [Test] | 124 | [Test] |
119 | public void TestImplicitCastBooleanToLSLFloat() | 125 | public void TestImplicitCastBooleanToLSLFloat() |
120 | { | 126 | { |
127 | TestHelpers.InMethod(); | ||
128 | |||
121 | LSL_Types.LSLString testString; | 129 | LSL_Types.LSLString testString; |
122 | 130 | ||
123 | testString = (LSL_Types.LSLString) (1 == 0); | 131 | testString = (LSL_Types.LSLString) (1 == 0); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs index 66a7329..b81225f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs | |||
@@ -44,6 +44,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
44 | [Test] | 44 | [Test] |
45 | public void TestConcatenateString() | 45 | public void TestConcatenateString() |
46 | { | 46 | { |
47 | TestHelpers.InMethod(); | ||
48 | |||
47 | LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test")); | 49 | LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test")); |
48 | testList += new LSL_Types.LSLString("addition"); | 50 | testList += new LSL_Types.LSLString("addition"); |
49 | 51 | ||
@@ -64,6 +66,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
64 | [Test] | 66 | [Test] |
65 | public void TestConcatenateInteger() | 67 | public void TestConcatenateInteger() |
66 | { | 68 | { |
69 | TestHelpers.InMethod(); | ||
70 | |||
67 | LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test")); | 71 | LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test")); |
68 | testList += new LSL_Types.LSLInteger(20); | 72 | testList += new LSL_Types.LSLInteger(20); |
69 | 73 | ||
@@ -84,6 +88,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
84 | [Test] | 88 | [Test] |
85 | public void TestConcatenateDouble() | 89 | public void TestConcatenateDouble() |
86 | { | 90 | { |
91 | TestHelpers.InMethod(); | ||
92 | |||
87 | LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test")); | 93 | LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test")); |
88 | testList += new LSL_Types.LSLFloat(2.0f); | 94 | testList += new LSL_Types.LSLFloat(2.0f); |
89 | 95 | ||
@@ -104,6 +110,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
104 | [Test] | 110 | [Test] |
105 | public void TestCastLSLIntegerItemToLSLInteger() | 111 | public void TestCastLSLIntegerItemToLSLInteger() |
106 | { | 112 | { |
113 | TestHelpers.InMethod(); | ||
114 | |||
107 | LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(123); | 115 | LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(123); |
108 | LSL_Types.list testList = new LSL_Types.list(testValue); | 116 | LSL_Types.list testList = new LSL_Types.list(testValue); |
109 | 117 | ||
@@ -116,6 +124,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
116 | [Test] | 124 | [Test] |
117 | public void TestCastLSLFloatItemToLSLFloat() | 125 | public void TestCastLSLFloatItemToLSLFloat() |
118 | { | 126 | { |
127 | TestHelpers.InMethod(); | ||
128 | |||
119 | LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(123.45678987); | 129 | LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(123.45678987); |
120 | LSL_Types.list testList = new LSL_Types.list(testValue); | 130 | LSL_Types.list testList = new LSL_Types.list(testValue); |
121 | 131 | ||
@@ -128,6 +138,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
128 | [Test] | 138 | [Test] |
129 | public void TestCastLSLStringItemToLSLString() | 139 | public void TestCastLSLStringItemToLSLString() |
130 | { | 140 | { |
141 | TestHelpers.InMethod(); | ||
142 | |||
131 | LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello there"); | 143 | LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello there"); |
132 | LSL_Types.list testList = new LSL_Types.list(testValue); | 144 | LSL_Types.list testList = new LSL_Types.list(testValue); |
133 | 145 | ||
@@ -140,6 +152,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
140 | [Test] | 152 | [Test] |
141 | public void TestCastVector3ItemToVector3() | 153 | public void TestCastVector3ItemToVector3() |
142 | { | 154 | { |
155 | TestHelpers.InMethod(); | ||
156 | |||
143 | LSL_Types.Vector3 testValue = new LSL_Types.Vector3(12.34, 56.987654, 0.00987); | 157 | LSL_Types.Vector3 testValue = new LSL_Types.Vector3(12.34, 56.987654, 0.00987); |
144 | LSL_Types.list testList = new LSL_Types.list(testValue); | 158 | LSL_Types.list testList = new LSL_Types.list(testValue); |
145 | 159 | ||
@@ -151,6 +165,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
151 | [Test] | 165 | [Test] |
152 | public void TestCastQuaternionItemToQuaternion() | 166 | public void TestCastQuaternionItemToQuaternion() |
153 | { | 167 | { |
168 | TestHelpers.InMethod(); | ||
169 | |||
154 | LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.34, 56.44323, 765.983421, 0.00987); | 170 | LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.34, 56.44323, 765.983421, 0.00987); |
155 | LSL_Types.list testList = new LSL_Types.list(testValue); | 171 | LSL_Types.list testList = new LSL_Types.list(testValue); |
156 | 172 | ||
@@ -165,6 +181,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
165 | [Test] | 181 | [Test] |
166 | public void TestGetLSLIntegerItemForLSLIntegerItem() | 182 | public void TestGetLSLIntegerItemForLSLIntegerItem() |
167 | { | 183 | { |
184 | TestHelpers.InMethod(); | ||
185 | |||
168 | LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(999911); | 186 | LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(999911); |
169 | LSL_Types.list testList = new LSL_Types.list(testValue); | 187 | LSL_Types.list testList = new LSL_Types.list(testValue); |
170 | 188 | ||
@@ -177,6 +195,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
177 | [Test] | 195 | [Test] |
178 | public void TestGetLSLFloatItemForLSLFloatItem() | 196 | public void TestGetLSLFloatItemForLSLFloatItem() |
179 | { | 197 | { |
198 | TestHelpers.InMethod(); | ||
199 | |||
180 | LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(321.45687876); | 200 | LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(321.45687876); |
181 | LSL_Types.list testList = new LSL_Types.list(testValue); | 201 | LSL_Types.list testList = new LSL_Types.list(testValue); |
182 | 202 | ||
@@ -189,11 +209,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
189 | [Test] | 209 | [Test] |
190 | public void TestGetLSLFloatItemForLSLIntegerItem() | 210 | public void TestGetLSLFloatItemForLSLIntegerItem() |
191 | { | 211 | { |
192 | LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(3060987); | 212 | TestHelpers.InMethod(); |
193 | LSL_Types.LSLFloat testFloatValue = new LSL_Types.LSLFloat(testValue); | 213 | |
194 | LSL_Types.list testList = new LSL_Types.list(testValue); | 214 | LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(3060987); |
215 | LSL_Types.LSLFloat testFloatValue = new LSL_Types.LSLFloat(testValue); | ||
216 | LSL_Types.list testList = new LSL_Types.list(testValue); | ||
195 | 217 | ||
196 | Assert.AreEqual(testFloatValue, testList.GetLSLFloatItem(0)); | 218 | Assert.AreEqual(testFloatValue, testList.GetLSLFloatItem(0)); |
197 | } | 219 | } |
198 | 220 | ||
199 | /// <summary> | 221 | /// <summary> |
@@ -202,6 +224,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
202 | [Test] | 224 | [Test] |
203 | public void TestGetLSLStringItemForLSLStringItem() | 225 | public void TestGetLSLStringItemForLSLStringItem() |
204 | { | 226 | { |
227 | TestHelpers.InMethod(); | ||
228 | |||
205 | LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello all"); | 229 | LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello all"); |
206 | LSL_Types.list testList = new LSL_Types.list(testValue); | 230 | LSL_Types.list testList = new LSL_Types.list(testValue); |
207 | 231 | ||
@@ -214,6 +238,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
214 | [Test] | 238 | [Test] |
215 | public void TestGetLSLStringItemForKeyItem() | 239 | public void TestGetLSLStringItemForKeyItem() |
216 | { | 240 | { |
241 | TestHelpers.InMethod(); | ||
242 | |||
217 | LSL_Types.key testValue | 243 | LSL_Types.key testValue |
218 | = new LSL_Types.key("98000000-0000-2222-3333-100000001000"); | 244 | = new LSL_Types.key("98000000-0000-2222-3333-100000001000"); |
219 | LSL_Types.LSLString testStringValue = new LSL_Types.LSLString(testValue); | 245 | LSL_Types.LSLString testStringValue = new LSL_Types.LSLString(testValue); |
@@ -228,6 +254,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
228 | [Test] | 254 | [Test] |
229 | public void TestGetVector3ItemForVector3Item() | 255 | public void TestGetVector3ItemForVector3Item() |
230 | { | 256 | { |
257 | TestHelpers.InMethod(); | ||
258 | |||
231 | LSL_Types.Vector3 testValue = new LSL_Types.Vector3(92.34, 58.98754, -0.10987); | 259 | LSL_Types.Vector3 testValue = new LSL_Types.Vector3(92.34, 58.98754, -0.10987); |
232 | LSL_Types.list testList = new LSL_Types.list(testValue); | 260 | LSL_Types.list testList = new LSL_Types.list(testValue); |
233 | 261 | ||
@@ -239,6 +267,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
239 | [Test] | 267 | [Test] |
240 | public void TestGetQuaternionItemForQuaternionItem() | 268 | public void TestGetQuaternionItemForQuaternionItem() |
241 | { | 269 | { |
270 | TestHelpers.InMethod(); | ||
271 | |||
242 | LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.64, 59.43723, 765.3421, 4.00987); | 272 | LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.64, 59.43723, 765.3421, 4.00987); |
243 | LSL_Types.list testList = new LSL_Types.list(testValue); | 273 | LSL_Types.list testList = new LSL_Types.list(testValue); |
244 | 274 | ||
@@ -251,6 +281,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
251 | [Test] | 281 | [Test] |
252 | public void TestGetKeyItemForKeyItem() | 282 | public void TestGetKeyItemForKeyItem() |
253 | { | 283 | { |
284 | TestHelpers.InMethod(); | ||
285 | |||
254 | LSL_Types.key testValue | 286 | LSL_Types.key testValue |
255 | = new LSL_Types.key("00000000-0000-2222-3333-100000001012"); | 287 | = new LSL_Types.key("00000000-0000-2222-3333-100000001012"); |
256 | LSL_Types.list testList = new LSL_Types.list(testValue); | 288 | LSL_Types.list testList = new LSL_Types.list(testValue); |
@@ -258,4 +290,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
258 | Assert.AreEqual(testValue, testList.GetKeyItem(0)); | 290 | Assert.AreEqual(testValue, testList.GetKeyItem(0)); |
259 | } | 291 | } |
260 | } | 292 | } |
261 | } | 293 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs index 195af7f..ebf8001 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs | |||
@@ -32,16 +32,17 @@ using OpenSim.Region.ScriptEngine.Shared; | |||
32 | 32 | ||
33 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | 33 | namespace OpenSim.Region.ScriptEngine.Shared.Tests |
34 | { | 34 | { |
35 | /// <summary> | ||
36 | /// Tests for Vector3 | ||
37 | /// </summary> | ||
35 | [TestFixture] | 38 | [TestFixture] |
36 | public class LSL_TypesTestVector3 | 39 | public class LSL_TypesTestVector3 |
37 | { | 40 | { |
38 | /// <summary> | ||
39 | /// Tests for Vector3 | ||
40 | /// </summary> | ||
41 | [Test] | 41 | [Test] |
42 | |||
43 | public void TestDotProduct() | 42 | public void TestDotProduct() |
44 | { | 43 | { |
44 | TestHelpers.InMethod(); | ||
45 | |||
45 | // The numbers we test for. | 46 | // The numbers we test for. |
46 | Dictionary<string, double> expectsSet = new Dictionary<string, double>(); | 47 | Dictionary<string, double> expectsSet = new Dictionary<string, double>(); |
47 | expectsSet.Add("<1, 2, 3> * <2, 3, 4>", 20.0); | 48 | expectsSet.Add("<1, 2, 3> * <2, 3, 4>", 20.0); |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index c68f03f..7712076 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -49,7 +49,10 @@ using OpenSim.Region.ScriptEngine.Shared; | |||
49 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | 49 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
50 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; | 50 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; |
51 | using OpenSim.Region.ScriptEngine.Shared.Instance; | 51 | using OpenSim.Region.ScriptEngine.Shared.Instance; |
52 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
53 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
52 | using OpenSim.Region.ScriptEngine.Interfaces; | 54 | using OpenSim.Region.ScriptEngine.Interfaces; |
55 | using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; | ||
53 | 56 | ||
54 | using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; | 57 | using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; |
55 | 58 | ||
@@ -173,12 +176,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
173 | get { return m_ConfigSource; } | 176 | get { return m_ConfigSource; } |
174 | } | 177 | } |
175 | 178 | ||
179 | /// <summary> | ||
180 | /// Event fired after the script engine has finished removing a script. | ||
181 | /// </summary> | ||
176 | public event ScriptRemoved OnScriptRemoved; | 182 | public event ScriptRemoved OnScriptRemoved; |
183 | |||
184 | /// <summary> | ||
185 | /// Event fired after the script engine has finished removing a script from an object. | ||
186 | /// </summary> | ||
177 | public event ObjectRemoved OnObjectRemoved; | 187 | public event ObjectRemoved OnObjectRemoved; |
178 | 188 | ||
179 | // | ||
180 | // IRegionModule functions | ||
181 | // | ||
182 | public void Initialise(IConfigSource configSource) | 189 | public void Initialise(IConfigSource configSource) |
183 | { | 190 | { |
184 | if (configSource.Configs["XEngine"] == null) | 191 | if (configSource.Configs["XEngine"] == null) |
@@ -274,22 +281,22 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
274 | } | 281 | } |
275 | 282 | ||
276 | MainConsole.Instance.Commands.AddCommand( | 283 | MainConsole.Instance.Commands.AddCommand( |
277 | "scripts", false, "xengine status", "xengine status", "Show status information", | 284 | "Scripts", false, "xengine status", "xengine status", "Show status information", |
278 | "Show status information on the script engine.", | 285 | "Show status information on the script engine.", |
279 | HandleShowStatus); | 286 | HandleShowStatus); |
280 | 287 | ||
281 | MainConsole.Instance.Commands.AddCommand( | 288 | MainConsole.Instance.Commands.AddCommand( |
282 | "scripts", false, "scripts show", "scripts show [<script-item-uuid>]", "Show script information", | 289 | "Scripts", false, "scripts show", "scripts show [<script-item-uuid>]", "Show script information", |
283 | "Show information on all scripts known to the script engine." | 290 | "Show information on all scripts known to the script engine." |
284 | + "If a <script-item-uuid> is given then only information on that script will be shown.", | 291 | + "If a <script-item-uuid> is given then only information on that script will be shown.", |
285 | HandleShowScripts); | 292 | HandleShowScripts); |
286 | 293 | ||
287 | MainConsole.Instance.Commands.AddCommand( | 294 | MainConsole.Instance.Commands.AddCommand( |
288 | "scripts", false, "show scripts", "show scripts [<script-item-uuid>]", "Show script information", | 295 | "Scripts", false, "show scripts", "show scripts [<script-item-uuid>]", "Show script information", |
289 | "Synonym for scripts show command", HandleShowScripts); | 296 | "Synonym for scripts show command", HandleShowScripts); |
290 | 297 | ||
291 | MainConsole.Instance.Commands.AddCommand( | 298 | MainConsole.Instance.Commands.AddCommand( |
292 | "scripts", false, "scripts suspend", "scripts suspend [<script-item-uuid>]", "Suspends all running scripts", | 299 | "Scripts", false, "scripts suspend", "scripts suspend [<script-item-uuid>]", "Suspends all running scripts", |
293 | "Suspends all currently running scripts. This only suspends event delivery, it will not suspend a" | 300 | "Suspends all currently running scripts. This only suspends event delivery, it will not suspend a" |
294 | + " script that is currently processing an event.\n" | 301 | + " script that is currently processing an event.\n" |
295 | + "Suspended scripts will continue to accumulate events but won't process them.\n" | 302 | + "Suspended scripts will continue to accumulate events but won't process them.\n" |
@@ -297,20 +304,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
297 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleSuspendScript)); | 304 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleSuspendScript)); |
298 | 305 | ||
299 | MainConsole.Instance.Commands.AddCommand( | 306 | MainConsole.Instance.Commands.AddCommand( |
300 | "scripts", false, "scripts resume", "scripts resume [<script-item-uuid>]", "Resumes all suspended scripts", | 307 | "Scripts", false, "scripts resume", "scripts resume [<script-item-uuid>]", "Resumes all suspended scripts", |
301 | "Resumes all currently suspended scripts.\n" | 308 | "Resumes all currently suspended scripts.\n" |
302 | + "Resumed scripts will process all events accumulated whilst suspended." | 309 | + "Resumed scripts will process all events accumulated whilst suspended." |
303 | + "If a <script-item-uuid> is given then only that script will be resumed. Otherwise, all suitable scripts are resumed.", | 310 | + "If a <script-item-uuid> is given then only that script will be resumed. Otherwise, all suitable scripts are resumed.", |
304 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleResumeScript)); | 311 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleResumeScript)); |
305 | 312 | ||
306 | MainConsole.Instance.Commands.AddCommand( | 313 | MainConsole.Instance.Commands.AddCommand( |
307 | "scripts", false, "scripts stop", "scripts stop [<script-item-uuid>]", "Stops all running scripts", | 314 | "Scripts", false, "scripts stop", "scripts stop [<script-item-uuid>]", "Stops all running scripts", |
308 | "Stops all running scripts." | 315 | "Stops all running scripts." |
309 | + "If a <script-item-uuid> is given then only that script will be stopped. Otherwise, all suitable scripts are stopped.", | 316 | + "If a <script-item-uuid> is given then only that script will be stopped. Otherwise, all suitable scripts are stopped.", |
310 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStopScript)); | 317 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStopScript)); |
311 | 318 | ||
312 | MainConsole.Instance.Commands.AddCommand( | 319 | MainConsole.Instance.Commands.AddCommand( |
313 | "scripts", false, "scripts start", "scripts start [<script-item-uuid>]", "Starts all stopped scripts", | 320 | "Scripts", false, "scripts start", "scripts start [<script-item-uuid>]", "Starts all stopped scripts", |
314 | "Starts all stopped scripts." | 321 | "Starts all stopped scripts." |
315 | + "If a <script-item-uuid> is given then only that script will be started. Otherwise, all suitable scripts are started.", | 322 | + "If a <script-item-uuid> is given then only that script will be started. Otherwise, all suitable scripts are started.", |
316 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); | 323 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); |
@@ -373,6 +380,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
373 | if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) | 380 | if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) |
374 | return; | 381 | return; |
375 | 382 | ||
383 | MainConsole.Instance.OutputFormat(GetStatusReport()); | ||
384 | } | ||
385 | |||
386 | public string GetStatusReport() | ||
387 | { | ||
376 | StringBuilder sb = new StringBuilder(); | 388 | StringBuilder sb = new StringBuilder(); |
377 | sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); | 389 | sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); |
378 | 390 | ||
@@ -381,12 +393,26 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
381 | 393 | ||
382 | sb.AppendFormat("Unique scripts : {0}\n", m_uniqueScripts.Count); | 394 | sb.AppendFormat("Unique scripts : {0}\n", m_uniqueScripts.Count); |
383 | sb.AppendFormat("Scripts waiting for load : {0}\n", m_CompileQueue.Count); | 395 | sb.AppendFormat("Scripts waiting for load : {0}\n", m_CompileQueue.Count); |
396 | sb.AppendFormat("Max threads : {0}\n", m_ThreadPool.MaxThreads); | ||
397 | sb.AppendFormat("Min threads : {0}\n", m_ThreadPool.MinThreads); | ||
384 | sb.AppendFormat("Allocated threads : {0}\n", m_ThreadPool.ActiveThreads); | 398 | sb.AppendFormat("Allocated threads : {0}\n", m_ThreadPool.ActiveThreads); |
385 | sb.AppendFormat("In use threads : {0}\n", m_ThreadPool.InUseThreads); | 399 | sb.AppendFormat("In use threads : {0}\n", m_ThreadPool.InUseThreads); |
386 | sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks); | 400 | sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks); |
387 | // sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count); | 401 | // sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count); |
388 | 402 | ||
389 | MainConsole.Instance.OutputFormat(sb.ToString()); | 403 | SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(this); |
404 | sb.AppendFormat("Sensors : {0}\n", sr != null ? sr.SensorsCount : 0); | ||
405 | |||
406 | Dataserver ds = AsyncCommandManager.GetDataserverPlugin(this); | ||
407 | sb.AppendFormat("Dataserver requests : {0}\n", ds != null ? ds.DataserverRequestsCount : 0); | ||
408 | |||
409 | Timer t = AsyncCommandManager.GetTimerPlugin(this); | ||
410 | sb.AppendFormat("Timers : {0}\n", t != null ? t.TimersCount : 0); | ||
411 | |||
412 | Listener l = AsyncCommandManager.GetListenerPlugin(this); | ||
413 | sb.AppendFormat("Listeners : {0}\n", l != null ? l.ListenerCount : 0); | ||
414 | |||
415 | return sb.ToString(); | ||
390 | } | 416 | } |
391 | 417 | ||
392 | public void HandleShowScripts(string module, string[] cmdparams) | 418 | public void HandleShowScripts(string module, string[] cmdparams) |
@@ -973,7 +999,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
973 | lock (m_Scripts) | 999 | lock (m_Scripts) |
974 | { | 1000 | { |
975 | // Create the object record | 1001 | // Create the object record |
976 | |||
977 | if ((!m_Scripts.ContainsKey(itemID)) || | 1002 | if ((!m_Scripts.ContainsKey(itemID)) || |
978 | (m_Scripts[itemID].AssetID != assetID)) | 1003 | (m_Scripts[itemID].AssetID != assetID)) |
979 | { | 1004 | { |
@@ -1063,7 +1088,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1063 | 1088 | ||
1064 | if (!m_PrimObjects[localID].Contains(itemID)) | 1089 | if (!m_PrimObjects[localID].Contains(itemID)) |
1065 | m_PrimObjects[localID].Add(itemID); | 1090 | m_PrimObjects[localID].Add(itemID); |
1066 | |||
1067 | } | 1091 | } |
1068 | 1092 | ||
1069 | if (!m_Assemblies.ContainsKey(assetID)) | 1093 | if (!m_Assemblies.ContainsKey(assetID)) |
@@ -1102,7 +1126,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1102 | } | 1126 | } |
1103 | 1127 | ||
1104 | instance.ClearQueue(); | 1128 | instance.ClearQueue(); |
1105 | instance.Stop(0); | 1129 | |
1130 | // Give the script some time to finish processing its last event. Simply aborting the script thread can | ||
1131 | // cause issues on mono 2.6, 2.10 and possibly later where locks are not released properly on abort. | ||
1132 | instance.Stop(1000); | ||
1133 | |||
1106 | // bool objectRemoved = false; | 1134 | // bool objectRemoved = false; |
1107 | 1135 | ||
1108 | lock (m_PrimObjects) | 1136 | lock (m_PrimObjects) |
@@ -1133,14 +1161,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1133 | UnloadAppDomain(instance.AppDomain); | 1161 | UnloadAppDomain(instance.AppDomain); |
1134 | } | 1162 | } |
1135 | 1163 | ||
1136 | instance = null; | ||
1137 | |||
1138 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 1164 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
1139 | if (handlerObjectRemoved != null) | 1165 | if (handlerObjectRemoved != null) |
1140 | { | 1166 | handlerObjectRemoved(instance.ObjectID); |
1141 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
1142 | handlerObjectRemoved(part.UUID); | ||
1143 | } | ||
1144 | 1167 | ||
1145 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; | 1168 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; |
1146 | if (handlerScriptRemoved != null) | 1169 | if (handlerScriptRemoved != null) |
@@ -1872,6 +1895,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1872 | } | 1895 | } |
1873 | } | 1896 | } |
1874 | 1897 | ||
1898 | public Dictionary<uint, float> GetObjectScriptsExecutionTimes() | ||
1899 | { | ||
1900 | long tickNow = Util.EnvironmentTickCount(); | ||
1901 | Dictionary<uint, float> topScripts = new Dictionary<uint, float>(); | ||
1902 | |||
1903 | lock (m_Scripts) | ||
1904 | { | ||
1905 | foreach (IScriptInstance si in m_Scripts.Values) | ||
1906 | { | ||
1907 | if (!topScripts.ContainsKey(si.LocalID)) | ||
1908 | topScripts[si.RootLocalID] = 0; | ||
1909 | |||
1910 | // long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | ||
1911 | // float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond); | ||
1912 | |||
1913 | // Execution time of the script adjusted by it's measurement period to make scripts started at | ||
1914 | // different times comparable. | ||
1915 | // float adjustedExecutionTime | ||
1916 | // = (float)si.MeasurementPeriodExecutionTime | ||
1917 | // / ((float)(tickNow - si.MeasurementPeriodTickStart) / ScriptInstance.MaxMeasurementPeriod) | ||
1918 | // / TimeSpan.TicksPerMillisecond; | ||
1919 | |||
1920 | long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | ||
1921 | |||
1922 | // Avoid divide by zerp | ||
1923 | if (ticksElapsed == 0) | ||
1924 | ticksElapsed = 1; | ||
1925 | |||
1926 | // Scale execution time to the ideal 55 fps frame time for these reasons. | ||
1927 | // | ||
1928 | // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no | ||
1929 | // 'script execution time per frame', which is the original purpose of this value. | ||
1930 | // | ||
1931 | // 2) Giving the raw execution times is misleading since scripts start at different times, making | ||
1932 | // it impossible to compare scripts. | ||
1933 | // | ||
1934 | // 3) Scaling the raw execution time to the time that the script has been running is better but | ||
1935 | // is still misleading since a script that has just been rezzed may appear to have been running | ||
1936 | // for much longer. | ||
1937 | // | ||
1938 | // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect | ||
1939 | // since the figure does not represent actual execution time and very hard running scripts will | ||
1940 | // never exceed 18ms (though this is a very high number for script execution so is a warning sign). | ||
1941 | float adjustedExecutionTime | ||
1942 | = ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f; | ||
1943 | |||
1944 | topScripts[si.RootLocalID] += adjustedExecutionTime; | ||
1945 | } | ||
1946 | } | ||
1947 | |||
1948 | return topScripts; | ||
1949 | } | ||
1950 | |||
1875 | public void SuspendScript(UUID itemID) | 1951 | public void SuspendScript(UUID itemID) |
1876 | { | 1952 | { |
1877 | // m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID); | 1953 | // m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID); |