aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs96
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs120
-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.cs92
9 files changed, 241 insertions, 115 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..425d2c5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -948,13 +948,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
948 948
949 m_host.AddScriptLPS(1); 949 m_host.AddScriptLPS(1);
950 950
951 if (channel == ScriptBaseClass.DEBUG_CHANNEL)
952 {
953 return;
954 }
955
951 UUID TargetID; 956 UUID TargetID;
952 UUID.TryParse(target, out TargetID); 957 UUID.TryParse(target, out TargetID);
953 958
954 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 959 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
955 if (wComm != null) 960 if (wComm != null)
956 if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) 961 wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg);
957 LSLError(error);
958 } 962 }
959 963
960 public LSL_Integer llListen(int channelID, string name, string ID, string msg) 964 public LSL_Integer llListen(int channelID, string name, string ID, string msg)
@@ -9990,7 +9994,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9990 // child agents have a mass of 1.0 9994 // child agents have a mass of 1.0
9991 return 1; 9995 return 1;
9992 else 9996 else
9993 return avatar.GetMass(); 9997 return (double)avatar.GetMass();
9994 } 9998 }
9995 catch (KeyNotFoundException) 9999 catch (KeyNotFoundException)
9996 { 10000 {
@@ -11182,19 +11186,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11182 break; 11186 break;
11183 // For the following 8 see the Object version below 11187 // For the following 8 see the Object version below
11184 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: 11188 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT:
11185 ret.Add(new LSL_Integer(0)); 11189 ret.Add(new LSL_Integer(av.RunningScriptCount()));
11186 break; 11190 break;
11187 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: 11191 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT:
11188 ret.Add(new LSL_Integer(0)); 11192 ret.Add(new LSL_Integer(av.ScriptCount()));
11189 break; 11193 break;
11190 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: 11194 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY:
11191 ret.Add(new LSL_Integer(0)); 11195 ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384));
11192 break; 11196 break;
11193 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 11197 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
11194 ret.Add(new LSL_Float(0)); 11198 ret.Add(new LSL_Float(av.ScriptExecutionTime() / 1000.0f));
11195 break; 11199 break;
11196 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 11200 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
11197 ret.Add(new LSL_Integer(0)); 11201 ret.Add(new LSL_Integer(1));
11198 break; 11202 break;
11199 case ScriptBaseClass.OBJECT_SERVER_COST: 11203 case ScriptBaseClass.OBJECT_SERVER_COST:
11200 ret.Add(new LSL_Float(0)); 11204 ret.Add(new LSL_Float(0));
@@ -11246,43 +11250,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11246 case ScriptBaseClass.OBJECT_CREATOR: 11250 case ScriptBaseClass.OBJECT_CREATOR:
11247 ret.Add(new LSL_String(obj.CreatorID.ToString())); 11251 ret.Add(new LSL_String(obj.CreatorID.ToString()));
11248 break; 11252 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: 11253 case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT:
11255 // in SL this currently includes crashed scripts 11254 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount()));
11256 ret.Add(new LSL_Integer(0));
11257 break; 11255 break;
11258 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: 11256 case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT:
11259 ret.Add(new LSL_Integer(0)); 11257 ret.Add(new LSL_Integer(obj.ParentGroup.ScriptCount()));
11260 break; 11258 break;
11261 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: 11259 case ScriptBaseClass.OBJECT_SCRIPT_MEMORY:
11262 // The value returned in SL for mono scripts is 65536 * number of active scripts 11260 // The value returned in SL for mono scripts is 65536 * number of active scripts
11263 ret.Add(new LSL_Integer(0)); 11261 // and 16384 * number of active scripts for LSO. since llGetFreememory
11262 // is coded to give the LSO value use it here
11263 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384));
11264 break; 11264 break;
11265 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 11265 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
11266 // Average cpu time per simulator frame expended on all scripts in the objetc 11266 // Average cpu time in seconds per simulator frame expended on all scripts in the object
11267 ret.Add(new LSL_Float(0)); 11267 ret.Add(new LSL_Float(obj.ParentGroup.ScriptExecutionTime() / 1000.0f));
11268 break; 11268 break;
11269 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 11269 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
11270 // according to the SL wiki A prim or linkset will have prim 11270 // 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 11271 // 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 11272 // 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 11273 // The value returned in SL for normal prims is prim count
11274 ret.Add(new LSL_Integer(0)); 11274 ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount));
11275 break; 11275 break;
11276 // The following 3 costs I have intentionaly coded to return zero. They are part of
11277 // "Land Impact" calculations. These calculations are probably not applicable
11278 // to OpenSim and are not yet complete in SL
11276 case ScriptBaseClass.OBJECT_SERVER_COST: 11279 case ScriptBaseClass.OBJECT_SERVER_COST:
11277 // The value returned in SL for normal prims is prim count 11280 // The linden calculation is here
11281 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight
11282 // The value returned in SL for normal prims looks like the prim count
11278 ret.Add(new LSL_Float(0)); 11283 ret.Add(new LSL_Float(0));
11279 break; 11284 break;
11280 case ScriptBaseClass.OBJECT_STREAMING_COST: 11285 case ScriptBaseClass.OBJECT_STREAMING_COST:
11281 // The value returned in SL for normal prims is prim count * 0.06 11286 // The linden calculation is here
11287 // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost
11288 // The value returned in SL for normal prims looks like the prim count * 0.06
11282 ret.Add(new LSL_Float(0)); 11289 ret.Add(new LSL_Float(0));
11283 break; 11290 break;
11284 case ScriptBaseClass.OBJECT_PHYSICS_COST: 11291 case ScriptBaseClass.OBJECT_PHYSICS_COST:
11285 // The value returned in SL for normal prims is prim count 11292 // The linden calculation is here
11293 // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics
11294 // The value returned in SL for normal prims looks like the prim count
11286 ret.Add(new LSL_Float(0)); 11295 ret.Add(new LSL_Float(0));
11287 break; 11296 break;
11288 default: 11297 default:
@@ -12037,7 +12046,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12037 bool isAccount = false; 12046 bool isAccount = false;
12038 bool isGroup = false; 12047 bool isGroup = false;
12039 12048
12040 if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManager(m_host.OwnerID)) 12049 if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID))
12041 return 0; 12050 return 0;
12042 12051
12043 UUID id = new UUID(); 12052 UUID id = new UUID();
@@ -12099,35 +12108,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12099 return 1; 12108 return 1;
12100 } 12109 }
12101 12110
12102 #region Not Implemented 12111 public LSL_Integer llGetMemoryLimit()
12103 // 12112 {
12104 // Listing the unimplemented lsl functions here, please move 12113 m_host.AddScriptLPS(1);
12105 // them from this region as they are completed 12114 // The value returned for LSO scripts in SL
12106 // 12115 return 16384;
12116 }
12107 12117
12108 public void llGetEnv(LSL_String name) 12118 public LSL_Integer llSetMemoryLimit(LSL_Integer limit)
12109 { 12119 {
12110 m_host.AddScriptLPS(1); 12120 m_host.AddScriptLPS(1);
12111 NotImplemented("llGetEnv"); 12121 // Treat as an LSO script
12122 return ScriptBaseClass.FALSE;
12112 } 12123 }
12113 12124
12114 public void llGetSPMaxMemory() 12125 public LSL_Integer llGetSPMaxMemory()
12115 { 12126 {
12116 m_host.AddScriptLPS(1); 12127 m_host.AddScriptLPS(1);
12117 NotImplemented("llGetSPMaxMemory"); 12128 // The value returned for LSO scripts in SL
12129 return 16384;
12118 } 12130 }
12119 12131
12120 public virtual LSL_Integer llGetUsedMemory() 12132 public virtual LSL_Integer llGetUsedMemory()
12121 { 12133 {
12122 m_host.AddScriptLPS(1); 12134 m_host.AddScriptLPS(1);
12123 NotImplemented("llGetUsedMemory"); 12135 // The value returned for LSO scripts in SL
12124 return 0; 12136 return 16384;
12125 } 12137 }
12126 12138
12127 public void llScriptProfiler(LSL_Integer flags) 12139 public void llScriptProfiler(LSL_Integer flags)
12128 { 12140 {
12129 m_host.AddScriptLPS(1); 12141 m_host.AddScriptLPS(1);
12130 //NotImplemented("llScriptProfiler"); 12142 // This does nothing for LSO scripts in SL
12143 }
12144
12145 #region Not Implemented
12146 //
12147 // Listing the unimplemented lsl functions here, please move
12148 // them from this region as they are completed
12149 //
12150
12151 public void llGetEnv(LSL_String name)
12152 {
12153 m_host.AddScriptLPS(1);
12154 NotImplemented("llGetEnv");
12131 } 12155 }
12132 12156
12133 public void llSetSoundQueueing(int queue) 12157 public void llSetSoundQueueing(int queue)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index 77a784d..df20126 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -449,7 +449,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
449 LSShoutError("LightShare functions are not enabled."); 449 LSShoutError("LightShare functions are not enabled.");
450 return 0; 450 return 0;
451 } 451 }
452 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 452 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
453 { 453 {
454 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); 454 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
455 return 0; 455 return 0;
@@ -477,7 +477,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
477 LSShoutError("LightShare functions are not enabled."); 477 LSShoutError("LightShare functions are not enabled.");
478 return; 478 return;
479 } 479 }
480 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 480 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
481 { 481 {
482 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); 482 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
483 return; 483 return;
@@ -500,7 +500,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
500 LSShoutError("LightShare functions are not enabled."); 500 LSShoutError("LightShare functions are not enabled.");
501 return 0; 501 return 0;
502 } 502 }
503 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 503 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
504 { 504 {
505 LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); 505 LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
506 return 0; 506 return 0;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 0dc2aa2..89e85a0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -378,7 +378,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
378 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) 378 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER"))
379 { 379 {
380 //Only Estate Managers may use the function 380 //Only Estate Managers may use the function
381 if (World.RegionInfo.EstateSettings.IsEstateManager(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) 381 if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID)
382 { 382 {
383 return; 383 return;
384 } 384 }
@@ -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..5a02d4c 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1089,11 +1089,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1089 1089
1090 AppDomain sandbox; 1090 AppDomain sandbox;
1091 if (m_AppDomainLoading) 1091 if (m_AppDomainLoading)
1092 {
1092 sandbox = AppDomain.CreateDomain( 1093 sandbox = AppDomain.CreateDomain(
1093 m_Scene.RegionInfo.RegionID.ToString(), 1094 m_Scene.RegionInfo.RegionID.ToString(),
1094 evidence, appSetup); 1095 evidence, appSetup);
1096 m_AppDomains[appDomain].AssemblyResolve +=
1097 new ResolveEventHandler(
1098 AssemblyResolver.OnAssemblyResolve);
1099 }
1095 else 1100 else
1101 {
1096 sandbox = AppDomain.CurrentDomain; 1102 sandbox = AppDomain.CurrentDomain;
1103 }
1097 1104
1098 //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); 1105 //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
1099 //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); 1106 //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
@@ -1105,9 +1112,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1105 1112
1106 m_AppDomains[appDomain] = sandbox; 1113 m_AppDomains[appDomain] = sandbox;
1107 1114
1108 m_AppDomains[appDomain].AssemblyResolve +=
1109 new ResolveEventHandler(
1110 AssemblyResolver.OnAssemblyResolve);
1111 m_DomainScripts[appDomain] = new List<UUID>(); 1115 m_DomainScripts[appDomain] = new List<UUID>();
1112 } 1116 }
1113 catch (Exception e) 1117 catch (Exception e)
@@ -1997,45 +2001,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1997 if (!topScripts.ContainsKey(si.LocalID)) 2001 if (!topScripts.ContainsKey(si.LocalID))
1998 topScripts[si.RootLocalID] = 0; 2002 topScripts[si.RootLocalID] = 0;
1999 2003
2000// long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; 2004 topScripts[si.RootLocalID] += CalculateAdjustedExectionTime(si, tickNow);
2001// float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond); 2005 }
2002 2006 }
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 2007
2016 // Scale execution time to the ideal 55 fps frame time for these reasons. 2008 return topScripts;
2017 // 2009 }
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 2010
2034 topScripts[si.RootLocalID] += adjustedExecutionTime; 2011 public float GetScriptExecutionTime(List<UUID> itemIDs)
2012 {
2013 if (itemIDs == null|| itemIDs.Count == 0)
2014 {
2015 return 0.0f;
2016 }
2017 float time = 0.0f;
2018 long tickNow = Util.EnvironmentTickCount();
2019 IScriptInstance si;
2020 // Calculate the time for all scripts that this engine is executing
2021 // Ignore any others
2022 foreach (UUID id in itemIDs)
2023 {
2024 si = GetInstance(id);
2025 if (si != null && si.Running)
2026 {
2027 time += CalculateAdjustedExectionTime(si, tickNow);
2035 } 2028 }
2036 } 2029 }
2030 return time;
2031 }
2037 2032
2038 return topScripts; 2033 private float CalculateAdjustedExectionTime(IScriptInstance si, long tickNow)
2034 {
2035 long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
2036
2037 // Avoid divide by zero
2038 if (ticksElapsed == 0)
2039 ticksElapsed = 1;
2040
2041 // Scale execution time to the ideal 55 fps frame time for these reasons.
2042 //
2043 // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no
2044 // 'script execution time per frame', which is the original purpose of this value.
2045 //
2046 // 2) Giving the raw execution times is misleading since scripts start at different times, making
2047 // it impossible to compare scripts.
2048 //
2049 // 3) Scaling the raw execution time to the time that the script has been running is better but
2050 // is still misleading since a script that has just been rezzed may appear to have been running
2051 // for much longer.
2052 //
2053 // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect
2054 // since the figure does not represent actual execution time and very hard running scripts will
2055 // never exceed 18ms (though this is a very high number for script execution so is a warning sign).
2056 return ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f;
2039 } 2057 }
2040 2058
2041 public void SuspendScript(UUID itemID) 2059 public void SuspendScript(UUID itemID)