aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs84
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs118
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs20
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs82
8 files changed, 222 insertions, 104 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 8e73eb1..3a7eb32 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -11182,19 +11182,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11182 break; 11182 break;
11183 // For the following 8 see the Object version below 11183 // For the following 8 see the Object version below
11184 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: 11184 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT:
11185 ret.Add(new LSL_Integer(0)); 11185 ret.Add(new LSL_Integer(av.RunningScriptCount()));
11186 break; 11186 break;
11187 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: 11187 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT:
11188 ret.Add(new LSL_Integer(0)); 11188 ret.Add(new LSL_Integer(av.ScriptCount()));
11189 break; 11189 break;
11190 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: 11190 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY:
11191 ret.Add(new LSL_Integer(0)); 11191 ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384));
11192 break; 11192 break;
11193 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 11193 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
11194 ret.Add(new LSL_Float(0)); 11194 ret.Add(new LSL_Float(av.ScriptExecutionTime() / 1000.0f));
11195 break; 11195 break;
11196 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 11196 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
11197 ret.Add(new LSL_Integer(0)); 11197 ret.Add(new LSL_Integer(1));
11198 break; 11198 break;
11199 case ScriptBaseClass.OBJECT_SERVER_COST: 11199 case ScriptBaseClass.OBJECT_SERVER_COST:
11200 ret.Add(new LSL_Float(0)); 11200 ret.Add(new LSL_Float(0));
@@ -11246,43 +11246,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11246 case ScriptBaseClass.OBJECT_CREATOR: 11246 case ScriptBaseClass.OBJECT_CREATOR:
11247 ret.Add(new LSL_String(obj.CreatorID.ToString())); 11247 ret.Add(new LSL_String(obj.CreatorID.ToString()));
11248 break; 11248 break;
11249 // The following 8 I have intentionaly coded to return zero. They are part of
11250 // "Land Impact" calculations. These calculations are probably not applicable
11251 // to OpenSim, required figures (cpu/memory usage) are not currently tracked
11252 // I have intentionally left these all at zero rather than return possibly
11253 // missleading numbers
11254 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: 11249 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT:
11255 // in SL this currently includes crashed scripts 11250 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount()));
11256 ret.Add(new LSL_Integer(0));
11257 break; 11251 break;
11258 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: 11252 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT:
11259 ret.Add(new LSL_Integer(0)); 11253 ret.Add(new LSL_Integer(obj.ParentGroup.ScriptCount()));
11260 break; 11254 break;
11261 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: 11255 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY:
11262 // The value returned in SL for mono scripts is 65536 * number of active scripts 11256 // The value returned in SL for mono scripts is 65536 * number of active scripts
11263 ret.Add(new LSL_Integer(0)); 11257 // and 16384 * number of active scripts for LSO. since llGetFreememory
11258 // is coded to give the LSO value use it here
11259 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384));
11264 break; 11260 break;
11265 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 11261 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
11266 // Average cpu time per simulator frame expended on all scripts in the objetc 11262 // Average cpu time in seconds per simulator frame expended on all scripts in the object
11267 ret.Add(new LSL_Float(0)); 11263 ret.Add(new LSL_Float(obj.ParentGroup.ScriptExecutionTime() / 1000.0f));
11268 break; 11264 break;
11269 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 11265 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
11270 // according to the SL wiki A prim or linkset will have prim 11266 // according to the SL wiki A prim or linkset will have prim
11271 // equivalent of the number of prims in a linkset if it does not 11267 // equivalent of the number of prims in a linkset if it does not
11272 // contain a mesh anywhere in the link set or is not a normal prim 11268 // contain a mesh anywhere in the link set or is not a normal prim
11273 // The value returned in SL for normal prims is prim count 11269 // The value returned in SL for normal prims is prim count
11274 ret.Add(new LSL_Integer(0)); 11270 ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount));
11275 break; 11271 break;
11272 // The following 3 costs I have intentionaly coded to return zero. They are part of
11273 // "Land Impact" calculations. These calculations are probably not applicable
11274 // to OpenSim and are not yet complete in SL
11276 case ScriptBaseClass.OBJECT_SERVER_COST: 11275 case ScriptBaseClass.OBJECT_SERVER_COST:
11277 // The value returned in SL for normal prims is prim count 11276 // The linden calculation is here
11277 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight
11278 // The value returned in SL for normal prims looks like the prim count
11278 ret.Add(new LSL_Float(0)); 11279 ret.Add(new LSL_Float(0));
11279 break; 11280 break;
11280 case ScriptBaseClass.OBJECT_STREAMING_COST: 11281 case ScriptBaseClass.OBJECT_STREAMING_COST:
11281 // The value returned in SL for normal prims is prim count * 0.06 11282 // The linden calculation is here
11283 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost
11284 // The value returned in SL for normal prims looks like the prim count * 0.06
11282 ret.Add(new LSL_Float(0)); 11285 ret.Add(new LSL_Float(0));
11283 break; 11286 break;
11284 case ScriptBaseClass.OBJECT_PHYSICS_COST: 11287 case ScriptBaseClass.OBJECT_PHYSICS_COST:
11285 // The value returned in SL for normal prims is prim count 11288 // The linden calculation is here
11289 // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics
11290 // The value returned in SL for normal prims looks like the prim count
11286 ret.Add(new LSL_Float(0)); 11291 ret.Add(new LSL_Float(0));
11287 break; 11292 break;
11288 default: 11293 default:
@@ -12099,35 +12104,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12099 return 1; 12104 return 1;
12100 } 12105 }
12101 12106
12102 #region Not Implemented 12107 public LSL_Integer llGetMemoryLimit()
12103 // 12108 {
12104 // Listing the unimplemented lsl functions here, please move 12109 m_host.AddScriptLPS(1);
12105 // them from this region as they are completed 12110 // The value returned for LSO scripts in SL
12106 // 12111 return 16384;
12112 }
12107 12113
12108 public void llGetEnv(LSL_String name) 12114 public LSL_Integer llSetMemoryLimit(LSL_Integer limit)
12109 { 12115 {
12110 m_host.AddScriptLPS(1); 12116 m_host.AddScriptLPS(1);
12111 NotImplemented("llGetEnv"); 12117 // Treat as an LSO script
12118 return ScriptBaseClass.FALSE;
12112 } 12119 }
12113 12120
12114 public void llGetSPMaxMemory() 12121 public LSL_Integer llGetSPMaxMemory()
12115 { 12122 {
12116 m_host.AddScriptLPS(1); 12123 m_host.AddScriptLPS(1);
12117 NotImplemented("llGetSPMaxMemory"); 12124 // The value returned for LSO scripts in SL
12125 return 16384;
12118 } 12126 }
12119 12127
12120 public virtual LSL_Integer llGetUsedMemory() 12128 public virtual LSL_Integer llGetUsedMemory()
12121 { 12129 {
12122 m_host.AddScriptLPS(1); 12130 m_host.AddScriptLPS(1);
12123 NotImplemented("llGetUsedMemory"); 12131 // The value returned for LSO scripts in SL
12124 return 0; 12132 return 16384;
12125 } 12133 }
12126 12134
12127 public void llScriptProfiler(LSL_Integer flags) 12135 public void llScriptProfiler(LSL_Integer flags)
12128 { 12136 {
12129 m_host.AddScriptLPS(1); 12137 m_host.AddScriptLPS(1);
12130 //NotImplemented("llScriptProfiler"); 12138 // This does nothing for LSO scripts in SL
12139 }
12140
12141 #region Not Implemented
12142 //
12143 // Listing the unimplemented lsl functions here, please move
12144 // them from this region as they are completed
12145 //
12146
12147 public void llGetEnv(LSL_String name)
12148 {
12149 m_host.AddScriptLPS(1);
12150 NotImplemented("llGetEnv");
12131 } 12151 }
12132 12152
12133 public void llSetSoundQueueing(int queue) 12153 public void llSetSoundQueueing(int queue)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 0dc2aa2..df49fd7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1186,12 +1186,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1186 CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); 1186 CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight");
1187 1187
1188 m_host.AddScriptLPS(1); 1188 m_host.AddScriptLPS(1);
1189 //Check to make sure that the script's owner is the estate manager/master 1189
1190 //World.Permissions.GenericEstatePermission( 1190 World.EventManager.TriggerRequestChangeWaterHeight((float)height);
1191 if (World.Permissions.IsGod(m_host.OwnerID))
1192 {
1193 World.EventManager.TriggerRequestChangeWaterHeight((float)height);
1194 }
1195 } 1191 }
1196 1192
1197 /// <summary> 1193 /// <summary>
@@ -1202,27 +1198,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1202 /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> 1198 /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param>
1203 public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) 1199 public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour)
1204 { 1200 {
1205 CheckThreatLevel(ThreatLevel.Nuisance, "osSetRegionSunSettings"); 1201 CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings");
1206 1202
1207 m_host.AddScriptLPS(1); 1203 m_host.AddScriptLPS(1);
1208 //Check to make sure that the script's owner is the estate manager/master
1209 //World.Permissions.GenericEstatePermission(
1210 if (World.Permissions.IsGod(m_host.OwnerID))
1211 {
1212 while (sunHour > 24.0)
1213 sunHour -= 24.0;
1214 1204
1215 while (sunHour < 0) 1205 while (sunHour > 24.0)
1216 sunHour += 24.0; 1206 sunHour -= 24.0;
1217 1207
1208 while (sunHour < 0)
1209 sunHour += 24.0;
1218 1210
1219 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; 1211 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun;
1220 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 1212 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30
1221 World.RegionInfo.RegionSettings.FixedSun = sunFixed; 1213 World.RegionInfo.RegionSettings.FixedSun = sunFixed;
1222 World.RegionInfo.RegionSettings.Save(); 1214 World.RegionInfo.RegionSettings.Save();
1223 1215
1224 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); 1216 World.EventManager.TriggerEstateToolsSunUpdate(
1225 } 1217 World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour);
1226 } 1218 }
1227 1219
1228 /// <summary> 1220 /// <summary>
@@ -1232,26 +1224,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1232 /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> 1224 /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param>
1233 public void osSetEstateSunSettings(bool sunFixed, double sunHour) 1225 public void osSetEstateSunSettings(bool sunFixed, double sunHour)
1234 { 1226 {
1235 CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings"); 1227 CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings");
1236 1228
1237 m_host.AddScriptLPS(1); 1229 m_host.AddScriptLPS(1);
1238 //Check to make sure that the script's owner is the estate manager/master
1239 //World.Permissions.GenericEstatePermission(
1240 if (World.Permissions.IsGod(m_host.OwnerID))
1241 {
1242 while (sunHour > 24.0)
1243 sunHour -= 24.0;
1244 1230
1245 while (sunHour < 0) 1231 while (sunHour > 24.0)
1246 sunHour += 24.0; 1232 sunHour -= 24.0;
1247 1233
1248 World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; 1234 while (sunHour < 0)
1249 World.RegionInfo.EstateSettings.SunPosition = sunHour; 1235 sunHour += 24.0;
1250 World.RegionInfo.EstateSettings.FixedSun = sunFixed;
1251 World.RegionInfo.EstateSettings.Save();
1252 1236
1253 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); 1237 World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed;
1254 } 1238 World.RegionInfo.EstateSettings.SunPosition = sunHour;
1239 World.RegionInfo.EstateSettings.FixedSun = sunFixed;
1240 World.RegionInfo.EstateSettings.Save();
1241
1242 World.EventManager.TriggerEstateToolsSunUpdate(
1243 World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour);
1255 } 1244 }
1256 1245
1257 /// <summary> 1246 /// <summary>
@@ -2555,7 +2544,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2555 2544
2556 public void osNpcStopMoveToTarget(LSL_Key npc) 2545 public void osNpcStopMoveToTarget(LSL_Key npc)
2557 { 2546 {
2558 CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); 2547 CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget");
2559 m_host.AddScriptLPS(1); 2548 m_host.AddScriptLPS(1);
2560 2549
2561 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2550 INPCModule module = World.RequestModuleInterface<INPCModule>();
@@ -3095,5 +3084,60 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3095 3084
3096 return ScriptBaseClass.TRUE; 3085 return ScriptBaseClass.TRUE;
3097 } 3086 }
3087
3088 /// <summary>
3089 /// Sets terrain estate texture
3090 /// </summary>
3091 /// <param name="level"></param>
3092 /// <param name="texture"></param>
3093 /// <returns></returns>
3094 public void osSetTerrainTexture(int level, LSL_Key texture)
3095 {
3096 CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture");
3097
3098 m_host.AddScriptLPS(1);
3099 //Check to make sure that the script's owner is the estate manager/master
3100 //World.Permissions.GenericEstatePermission(
3101 if (World.Permissions.IsGod(m_host.OwnerID))
3102 {
3103 if (level < 0 || level > 3)
3104 return;
3105
3106 UUID textureID = new UUID();
3107 if (!UUID.TryParse(texture, out textureID))
3108 return;
3109
3110 // estate module is required
3111 IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
3112 if (estate != null)
3113 estate.setEstateTerrainBaseTexture(level, textureID);
3114 }
3115 }
3116
3117 /// <summary>
3118 /// Sets terrain heights of estate
3119 /// </summary>
3120 /// <param name="corner"></param>
3121 /// <param name="low"></param>
3122 /// <param name="high"></param>
3123 /// <returns></returns>
3124 public void osSetTerrainTextureHeight(int corner, double low, double high)
3125 {
3126 CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight");
3127
3128 m_host.AddScriptLPS(1);
3129 //Check to make sure that the script's owner is the estate manager/master
3130 //World.Permissions.GenericEstatePermission(
3131 if (World.Permissions.IsGod(m_host.OwnerID))
3132 {
3133 if (corner < 0 || corner > 3)
3134 return;
3135
3136 // estate module is required
3137 IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
3138 if (estate != null)
3139 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
3140 }
3141 }
3098 } 3142 }
3099} 3143}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 5c528977..eab6851 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -149,7 +149,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
149 LSL_Rotation llGetLocalRot(); 149 LSL_Rotation llGetLocalRot();
150 LSL_Float llGetMass(); 150 LSL_Float llGetMass();
151 LSL_Float llGetMassMKS(); 151 LSL_Float llGetMassMKS();
152 void llGetNextEmail(string address, string subject); 152 LSL_Integer llGetMemoryLimit();
153 void llGetNextEmail(string address, string subject);
153 LSL_String llGetNotecardLine(string name, int line); 154 LSL_String llGetNotecardLine(string name, int line);
154 LSL_Key llGetNumberOfNotecardLines(string name); 155 LSL_Key llGetNumberOfNotecardLines(string name);
155 LSL_Integer llGetNumberOfPrims(); 156 LSL_Integer llGetNumberOfPrims();
@@ -187,6 +188,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
187 LSL_String llGetScriptName(); 188 LSL_String llGetScriptName();
188 LSL_Integer llGetScriptState(string name); 189 LSL_Integer llGetScriptState(string name);
189 LSL_String llGetSimulatorHostname(); 190 LSL_String llGetSimulatorHostname();
191 LSL_Integer llGetSPMaxMemory();
190 LSL_Integer llGetStartParameter(); 192 LSL_Integer llGetStartParameter();
191 LSL_Integer llGetStatus(int status); 193 LSL_Integer llGetStatus(int status);
192 LSL_String llGetSubString(string src, int start, int end); 194 LSL_String llGetSubString(string src, int start, int end);
@@ -322,6 +324,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
322 void llSay(int channelID, string text); 324 void llSay(int channelID, string text);
323 void llScaleTexture(double u, double v, int face); 325 void llScaleTexture(double u, double v, int face);
324 LSL_Integer llScriptDanger(LSL_Vector pos); 326 LSL_Integer llScriptDanger(LSL_Vector pos);
327 void llScriptProfiler(LSL_Integer flag);
325 LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata); 328 LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata);
326 void llSensor(string name, string id, int type, double range, double arc); 329 void llSensor(string name, string id, int type, double range, double arc);
327 void llSensorRemove(); 330 void llSensorRemove();
@@ -345,6 +348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
345 void llSetLinkTexture(int linknumber, string texture, int face); 348 void llSetLinkTexture(int linknumber, string texture, int face);
346 void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate); 349 void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate);
347 void llSetLocalRot(LSL_Rotation rot); 350 void llSetLocalRot(LSL_Rotation rot);
351 LSL_Integer llSetMemoryLimit(LSL_Integer limit);
348 void llSetObjectDesc(string desc); 352 void llSetObjectDesc(string desc);
349 void llSetObjectName(string name); 353 void llSetObjectName(string name);
350 void llSetObjectPermMask(int mask, int value); 354 void llSetObjectPermMask(int mask, int value);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 444a681..2fcc443 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -234,5 +234,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
234 234
235 LSL_Integer osInviteToGroup(LSL_Key agentId); 235 LSL_Integer osInviteToGroup(LSL_Key agentId);
236 LSL_Integer osEjectFromGroup(LSL_Key agentId); 236 LSL_Integer osEjectFromGroup(LSL_Key agentId);
237
238 void osSetTerrainTexture(int level, LSL_Key texture);
239 void osSetTerrainTextureHeight(int corner, double low, double high);
237 } 240 }
238} 241}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 6246b57..23b4336 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -383,6 +383,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
383 public const int PRIM_SCULPT_FLAG_INVERT = 64; 383 public const int PRIM_SCULPT_FLAG_INVERT = 64;
384 public const int PRIM_SCULPT_FLAG_MIRROR = 128; 384 public const int PRIM_SCULPT_FLAG_MIRROR = 128;
385 385
386 public const int PROFILE_NONE = 0;
387 public const int PROFILE_SCRIPT_MEMORY = 1;
388
386 public const int MASK_BASE = 0; 389 public const int MASK_BASE = 0;
387 public const int MASK_OWNER = 1; 390 public const int MASK_OWNER = 1;
388 public const int MASK_GROUP = 2; 391 public const int MASK_GROUP = 2;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 70c5fcd..9446099 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -586,6 +586,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
586 return m_LSL_Functions.llGetMassMKS(); 586 return m_LSL_Functions.llGetMassMKS();
587 } 587 }
588 588
589 public LSL_Integer llGetMemoryLimit()
590 {
591 return m_LSL_Functions.llGetMemoryLimit();
592 }
593
589 public void llGetNextEmail(string address, string subject) 594 public void llGetNextEmail(string address, string subject)
590 { 595 {
591 m_LSL_Functions.llGetNextEmail(address, subject); 596 m_LSL_Functions.llGetNextEmail(address, subject);
@@ -776,6 +781,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
776 return m_LSL_Functions.llGetSimulatorHostname(); 781 return m_LSL_Functions.llGetSimulatorHostname();
777 } 782 }
778 783
784 public LSL_Integer llGetSPMaxMemory()
785 {
786 return m_LSL_Functions.llGetSPMaxMemory();
787 }
788
779 public LSL_Integer llGetStartParameter() 789 public LSL_Integer llGetStartParameter()
780 { 790 {
781 return m_LSL_Functions.llGetStartParameter(); 791 return m_LSL_Functions.llGetStartParameter();
@@ -1445,6 +1455,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1445 return m_LSL_Functions.llScriptDanger(pos); 1455 return m_LSL_Functions.llScriptDanger(pos);
1446 } 1456 }
1447 1457
1458 public void llScriptProfiler(LSL_Integer flags)
1459 {
1460 m_LSL_Functions.llScriptProfiler(flags);
1461 }
1462
1448 public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata) 1463 public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata)
1449 { 1464 {
1450 return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); 1465 return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata);
@@ -1555,6 +1570,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1555 m_LSL_Functions.llSetLocalRot(rot); 1570 m_LSL_Functions.llSetLocalRot(rot);
1556 } 1571 }
1557 1572
1573 public LSL_Integer llSetMemoryLimit(LSL_Integer limit)
1574 {
1575 return m_LSL_Functions.llSetMemoryLimit(limit);
1576 }
1577
1558 public void llSetObjectDesc(string desc) 1578 public void llSetObjectDesc(string desc)
1559 { 1579 {
1560 m_LSL_Functions.llSetObjectDesc(desc); 1580 m_LSL_Functions.llSetObjectDesc(desc);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 680cefb4..b94b9bf 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -878,5 +878,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
878 { 878 {
879 return m_OSSL_Functions.osEjectFromGroup(agentId); 879 return m_OSSL_Functions.osEjectFromGroup(agentId);
880 } 880 }
881
882 public void osSetTerrainTexture(int level, LSL_Key texture)
883 {
884 m_OSSL_Functions.osSetTerrainTexture(level, texture);
885 }
886
887 public void osSetTerrainTextureHeight(int corner, double low, double high)
888 {
889 m_OSSL_Functions.osSetTerrainTextureHeight(corner, low, high);
890 }
881 } 891 }
882} 892}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 1e0f01f..bfe7418 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1997,45 +1997,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1997 if (!topScripts.ContainsKey(si.LocalID)) 1997 if (!topScripts.ContainsKey(si.LocalID))
1998 topScripts[si.RootLocalID] = 0; 1998 topScripts[si.RootLocalID] = 0;
1999 1999
2000// long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; 2000 topScripts[si.RootLocalID] += CalculateAdjustedExectionTime(si, tickNow);
2001// float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond); 2001 }
2002 2002 }
2003 // Execution time of the script adjusted by it's measurement period to make scripts started at
2004 // different times comparable.
2005// float adjustedExecutionTime
2006// = (float)si.MeasurementPeriodExecutionTime
2007// / ((float)(tickNow - si.MeasurementPeriodTickStart) / ScriptInstance.MaxMeasurementPeriod)
2008// / TimeSpan.TicksPerMillisecond;
2009
2010 long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
2011
2012 // Avoid divide by zerp
2013 if (ticksElapsed == 0)
2014 ticksElapsed = 1;
2015 2003
2016 // Scale execution time to the ideal 55 fps frame time for these reasons. 2004 return topScripts;
2017 // 2005 }
2018 // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no
2019 // 'script execution time per frame', which is the original purpose of this value.
2020 //
2021 // 2) Giving the raw execution times is misleading since scripts start at different times, making
2022 // it impossible to compare scripts.
2023 //
2024 // 3) Scaling the raw execution time to the time that the script has been running is better but
2025 // is still misleading since a script that has just been rezzed may appear to have been running
2026 // for much longer.
2027 //
2028 // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect
2029 // since the figure does not represent actual execution time and very hard running scripts will
2030 // never exceed 18ms (though this is a very high number for script execution so is a warning sign).
2031 float adjustedExecutionTime
2032 = ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f;
2033 2006
2034 topScripts[si.RootLocalID] += adjustedExecutionTime; 2007 public float GetScriptExecutionTime(List<UUID> itemIDs)
2008 {
2009 if (itemIDs == null|| itemIDs.Count == 0)
2010 {
2011 return 0.0f;
2012 }
2013 float time = 0.0f;
2014 long tickNow = Util.EnvironmentTickCount();
2015 IScriptInstance si;
2016 // Calculate the time for all scripts that this engine is executing
2017 // Ignore any others
2018 foreach (UUID id in itemIDs)
2019 {
2020 si = GetInstance(id);
2021 if (si != null && si.Running)
2022 {
2023 time += CalculateAdjustedExectionTime(si, tickNow);
2035 } 2024 }
2036 } 2025 }
2026 return time;
2027 }
2037 2028
2038 return topScripts; 2029 private float CalculateAdjustedExectionTime(IScriptInstance si, long tickNow)
2030 {
2031 long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
2032
2033 // Avoid divide by zero
2034 if (ticksElapsed == 0)
2035 ticksElapsed = 1;
2036
2037 // Scale execution time to the ideal 55 fps frame time for these reasons.
2038 //
2039 // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no
2040 // 'script execution time per frame', which is the original purpose of this value.
2041 //
2042 // 2) Giving the raw execution times is misleading since scripts start at different times, making
2043 // it impossible to compare scripts.
2044 //
2045 // 3) Scaling the raw execution time to the time that the script has been running is better but
2046 // is still misleading since a script that has just been rezzed may appear to have been running
2047 // for much longer.
2048 //
2049 // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect
2050 // since the figure does not represent actual execution time and very hard running scripts will
2051 // never exceed 18ms (though this is a very high number for script execution so is a warning sign).
2052 return ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f;
2039 } 2053 }
2040 2054
2041 public void SuspendScript(UUID itemID) 2055 public void SuspendScript(UUID itemID)