aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs39
1 files changed, 31 insertions, 8 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ea4e609..d47fd6b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -83,10 +83,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
83 public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi 83 public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi
84 { 84 {
85 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 85 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
86
86 protected IScriptEngine m_ScriptEngine; 87 protected IScriptEngine m_ScriptEngine;
87 protected SceneObjectPart m_host; 88 protected SceneObjectPart m_host;
88 89
89 /// <summary> 90 /// <summary>
91 /// Used for script sleeps when we are using co-operative script termination.
92 /// </summary>
93 /// <remarks>null if co-operative script termination is not active</remarks>
94 EventWaitHandle m_coopSleepHandle;
95
96 /// <summary>
90 /// The item that hosts this script 97 /// The item that hosts this script
91 /// </summary> 98 /// </summary>
92 protected TaskInventoryItem m_item; 99 protected TaskInventoryItem m_item;
@@ -110,24 +117,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
110 protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. 117 protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp.
111 protected ISoundModule m_SoundModule = null; 118 protected ISoundModule m_SoundModule = null;
112 119
113 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) 120 public void Initialize(
121 IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, EventWaitHandle coopSleepHandle)
114 { 122 {
115 m_ScriptEngine = ScriptEngine; 123 m_ScriptEngine = scriptEngine;
116 m_host = host; 124 m_host = host;
117 m_item = item; 125 m_item = item;
126 m_coopSleepHandle = coopSleepHandle;
118 127
119 LoadLimits(); // read script limits from config. 128 LoadConfig();
120 129
121 m_TransferModule = 130 m_TransferModule =
122 m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); 131 m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>();
123 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); 132 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
124 m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>(); 133 m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>();
125 134
126 AsyncCommands = new AsyncCommandManager(ScriptEngine); 135 AsyncCommands = new AsyncCommandManager(m_ScriptEngine);
127 } 136 }
128 137
129 /* load configuration items that affect script, object and run-time behavior. */ 138 /// <summary>
130 private void LoadLimits() 139 /// Load configuration items that affect script, object and run-time behavior. */
140 /// </summary>
141 private void LoadConfig()
131 { 142 {
132 m_ScriptDelayFactor = 143 m_ScriptDelayFactor =
133 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); 144 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
@@ -141,12 +152,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
141 m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255); 152 m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255);
142 if (m_notecardLineReadCharsMax > 65535) 153 if (m_notecardLineReadCharsMax > 65535)
143 m_notecardLineReadCharsMax = 65535; 154 m_notecardLineReadCharsMax = 65535;
155
144 // load limits for particular subsystems. 156 // load limits for particular subsystems.
145 IConfig SMTPConfig; 157 IConfig SMTPConfig;
146 if ((SMTPConfig = m_ScriptEngine.ConfigSource.Configs["SMTP"]) != null) { 158 if ((SMTPConfig = m_ScriptEngine.ConfigSource.Configs["SMTP"]) != null) {
147 // there's an smtp config, so load in the snooze time. 159 // there's an smtp config, so load in the snooze time.
148 EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME); 160 EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME);
149 } 161 }
162
150 // Rezzing an object with a velocity can create recoil. This feature seems to have been 163 // Rezzing an object with a velocity can create recoil. This feature seems to have been
151 // removed from recent versions of SL. The code computes recoil (vel*mass) and scales 164 // removed from recent versions of SL. The code computes recoil (vel*mass) and scales
152 // it by this factor. May be zero to turn off recoil all together. 165 // it by this factor. May be zero to turn off recoil all together.
@@ -171,7 +184,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
171 delay = (int)((float)delay * m_ScriptDelayFactor); 184 delay = (int)((float)delay * m_ScriptDelayFactor);
172 if (delay == 0) 185 if (delay == 0)
173 return; 186 return;
174 System.Threading.Thread.Sleep(delay); 187
188 Sleep(delay);
189 }
190
191 protected virtual void Sleep(int delay)
192 {
193 if (m_coopSleepHandle == null)
194 System.Threading.Thread.Sleep(delay);
195 else if (m_coopSleepHandle.WaitOne(delay))
196 throw new ScriptCoopStopException();
175 } 197 }
176 198
177 public Scene World 199 public Scene World
@@ -2910,7 +2932,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2910 { 2932 {
2911// m_log.Info("llSleep snoozing " + sec + "s."); 2933// m_log.Info("llSleep snoozing " + sec + "s.");
2912 m_host.AddScriptLPS(1); 2934 m_host.AddScriptLPS(1);
2913 Thread.Sleep((int)(sec * 1000)); 2935
2936 Sleep((int)(sec * 1000));
2914 } 2937 }
2915 2938
2916 public LSL_Float llGetMass() 2939 public LSL_Float llGetMass()