aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-04-13 22:34:36 +0100
committerJustin Clark-Casey (justincc)2012-04-13 22:34:36 +0100
commit1ad3fdb40ba86c6d0bcb9b06b5bb05004f670657 (patch)
treeccbd97c7ed18a0e6b9c5e6c771c6d7a2fca097e9 /OpenSim
parentRemove hardcoded god requirement from osSetRegionWaterHeight, osSetRegionSunS... (diff)
parentMantis 55025 Implement script time. (diff)
downloadopensim-SC_OLD-1ad3fdb40ba86c6d0bcb9b06b5bb05004f670657.zip
opensim-SC_OLD-1ad3fdb40ba86c6d0bcb9b06b5bb05004f670657.tar.gz
opensim-SC_OLD-1ad3fdb40ba86c6d0bcb9b06b5bb05004f670657.tar.bz2
opensim-SC_OLD-1ad3fdb40ba86c6d0bcb9b06b5bb05004f670657.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs46
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs15
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs12
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateModule.cs3
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs39
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs19
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs55
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs82
14 files changed, 267 insertions, 50 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index f64c161..fc6325d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -162,7 +162,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
162 } 162 }
163 } 163 }
164 164
165 protected void InitModule(IConfigSource config) 165 protected virtual void InitModule(IConfigSource config)
166 { 166 {
167 IConfig friendsConfig = config.Configs["Friends"]; 167 IConfig friendsConfig = config.Configs["Friends"];
168 if (friendsConfig != null) 168 if (friendsConfig != null)
@@ -546,7 +546,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
546 } 546 }
547 } 547 }
548 548
549 private void OnInstantMessage(IClientAPI client, GridInstantMessage im) 549 protected virtual void OnInstantMessage(IClientAPI client, GridInstantMessage im)
550 { 550 {
551 if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) 551 if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered)
552 { 552 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index 9a6d277..3728b85 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -50,6 +50,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
50 { 50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 private int m_levelHGFriends = 0;
54
53 IUserManagement m_uMan; 55 IUserManagement m_uMan;
54 public IUserManagement UserManagementModule 56 public IUserManagement UserManagementModule
55 { 57 {
@@ -87,6 +89,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
87 m_StatusNotifier = new HGStatusNotifier(this); 89 m_StatusNotifier = new HGStatusNotifier(this);
88 } 90 }
89 91
92 protected override void InitModule(IConfigSource config)
93 {
94 base.InitModule(config);
95
96 // Additionally to the base method
97 IConfig friendsConfig = config.Configs["HGFriendsModule"];
98 if (friendsConfig != null)
99 {
100 m_levelHGFriends = friendsConfig.GetInt("LevelHGFriends", 0);
101
102 // TODO: read in all config variables pertaining to
103 // HG friendship permissions
104 }
105 }
106
90 #endregion 107 #endregion
91 108
92 #region IFriendsSimConnector 109 #region IFriendsSimConnector
@@ -105,6 +122,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
105 122
106 #endregion 123 #endregion
107 124
125 protected override void OnInstantMessage(IClientAPI client, GridInstantMessage im)
126 {
127 if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered)
128 {
129 // we got a friendship offer
130 UUID principalID = new UUID(im.fromAgentID);
131 UUID friendID = new UUID(im.toAgentID);
132
133 // Check if friendID is foreigner and if principalID has the permission
134 // to request friendships with foreigners. If not, return immediately.
135 if (!UserManagementModule.IsLocalGridUser(friendID))
136 {
137 ScenePresence avatar = null;
138 ((Scene)client.Scene).TryGetScenePresence(principalID, out avatar);
139
140 if (avatar == null)
141 return;
142
143 if (avatar.UserLevel < m_levelHGFriends)
144 {
145 client.SendAgentAlertMessage("Unable to send friendship invitation to foreigner. Insufficient permissions.", false);
146 return;
147 }
148 }
149 }
150
151 base.OnInstantMessage(client, im);
152 }
153
108 protected override void OnApproveFriendRequest(IClientAPI client, UUID friendID, List<UUID> callingCardFolders) 154 protected override void OnApproveFriendRequest(IClientAPI client, UUID friendID, List<UUID> callingCardFolders)
109 { 155 {
110 // Update the local cache. Yes, we need to do it right here 156 // Update the local cache. Yes, we need to do it right here
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index fc217b0..124f01c 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -157,12 +157,18 @@ namespace OpenSim.Region.CoreModules.World.Estate
157 sendRegionInfoPacketToAll(); 157 sendRegionInfoPacketToAll();
158 } 158 }
159 159
160 public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int corner, UUID texture) 160 public void setEstateTerrainBaseTexture(int level, UUID texture)
161 {
162 setEstateTerrainBaseTexture(null, level, texture);
163 sendRegionHandshakeToAll();
164 }
165
166 public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int level, UUID texture)
161 { 167 {
162 if (texture == UUID.Zero) 168 if (texture == UUID.Zero)
163 return; 169 return;
164 170
165 switch (corner) 171 switch (level)
166 { 172 {
167 case 0: 173 case 0:
168 Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture; 174 Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
@@ -182,6 +188,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
182 sendRegionInfoPacketToAll(); 188 sendRegionInfoPacketToAll();
183 } 189 }
184 190
191 public void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue)
192 {
193 setEstateTerrainTextureHeights(null, corner, lowValue, highValue);
194 }
195
185 public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue) 196 public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue)
186 { 197 {
187 switch (corner) 198 switch (corner)
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index f5dda34..30ed7d1 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -172,7 +172,17 @@ namespace OpenSim.Region.Framework.Interfaces
172 /// If no inventory item has that name then an empty list is returned. 172 /// If no inventory item has that name then an empty list is returned.
173 /// </returns> 173 /// </returns>
174 List<TaskInventoryItem> GetInventoryItems(string name); 174 List<TaskInventoryItem> GetInventoryItems(string name);
175 175
176 /// <summary>
177 /// Get inventory items by type.
178 /// </summary>
179 /// <param type="name"></param>
180 /// <returns>
181 /// A list of inventory items of that type.
182 /// If no inventory items of that type then an empty list is returned.
183 /// </returns>
184 List<TaskInventoryItem> GetInventoryItems(InventoryType type);
185
176 /// <summary> 186 /// <summary>
177 /// Get the scene object referenced by an inventory item. 187 /// Get the scene object referenced by an inventory item.
178 /// </summary> 188 /// </summary>
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs
index 721f0ee..15cd238 100644
--- a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs
@@ -45,5 +45,8 @@ namespace OpenSim.Region.Framework.Interfaces
45 /// Tell all clients about the current state of the region (terrain textures, water height, etc.). 45 /// Tell all clients about the current state of the region (terrain textures, water height, etc.).
46 /// </summary> 46 /// </summary>
47 void sendRegionHandshakeToAll(); 47 void sendRegionHandshakeToAll();
48
49 void setEstateTerrainBaseTexture(int level, UUID texture);
50 void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue);
48 } 51 }
49} 52}
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index c0616ed..0d488df 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -83,6 +83,14 @@ namespace OpenSim.Region.Framework.Interfaces
83 void StartProcessing(); 83 void StartProcessing();
84 84
85 /// <summary> 85 /// <summary>
86 /// Get the execution times of all scripts in the given array if they are currently running.
87 /// </summary>
88 /// <returns>
89 /// A float the value is a representative execution time in milliseconds of all scripts in that Array.
90 /// </returns>
91 float GetScriptExecutionTime(List<UUID> itemIDs);
92
93 /// <summary>
86 /// Get the execution times of all scripts in each object. 94 /// Get the execution times of all scripts in each object.
87 /// </summary> 95 /// </summary>
88 /// <returns> 96 /// <returns>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 7d14814..a49ed13 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3270,6 +3270,45 @@ namespace OpenSim.Region.Framework.Scenes
3270 } 3270 }
3271 3271
3272 /// <summary> 3272 /// <summary>
3273 /// A float the value is a representative execution time in milliseconds of all scripts in the link set.
3274 /// </summary>
3275 public float ScriptExecutionTime()
3276 {
3277 IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>();
3278
3279 if (engines.Length == 0) // No engine at all
3280 return 0.0f;
3281
3282 float time = 0.0f;
3283
3284 // get all the scripts in all parts
3285 SceneObjectPart[] parts = m_parts.GetArray();
3286 List<TaskInventoryItem> scripts = new List<TaskInventoryItem>();
3287 for (int i = 0; i < parts.Length; i++)
3288 {
3289 scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL));
3290 }
3291 // extract the UUIDs
3292 List<UUID> ids = new List<UUID>(scripts.Count);
3293 foreach (TaskInventoryItem script in scripts)
3294 {
3295 if (!ids.Contains(script.ItemID))
3296 {
3297 ids.Add(script.ItemID);
3298 }
3299 }
3300 // Offer the list of script UUIDs to each engine found and accumulate the time
3301 foreach (IScriptModule e in engines)
3302 {
3303 if (e != null)
3304 {
3305 time += e.GetScriptExecutionTime(ids);
3306 }
3307 }
3308 return time;
3309 }
3310
3311 /// <summary>
3273 /// Returns a count of the number of running scripts in this groups parts. 3312 /// Returns a count of the number of running scripts in this groups parts.
3274 /// </summary> 3313 /// </summary>
3275 public int RunningScriptCount() 3314 public int RunningScriptCount()
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 9a04c65..aacad98 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -222,7 +222,7 @@ namespace OpenSim.Region.Framework.Scenes
222 /// </summary> 222 /// </summary>
223 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) 223 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
224 { 224 {
225 List<TaskInventoryItem> scripts = GetInventoryScripts(); 225 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
226 foreach (TaskInventoryItem item in scripts) 226 foreach (TaskInventoryItem item in scripts)
227 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); 227 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
228 } 228 }
@@ -255,7 +255,7 @@ namespace OpenSim.Region.Framework.Scenes
255 /// </param> 255 /// </param>
256 public void RemoveScriptInstances(bool sceneObjectBeingDeleted) 256 public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
257 { 257 {
258 List<TaskInventoryItem> scripts = GetInventoryScripts(); 258 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
259 foreach (TaskInventoryItem item in scripts) 259 foreach (TaskInventoryItem item in scripts)
260 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); 260 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
261 } 261 }
@@ -1116,7 +1116,7 @@ namespace OpenSim.Region.Framework.Scenes
1116 return 0; 1116 return 0;
1117 1117
1118 int count = 0; 1118 int count = 0;
1119 List<TaskInventoryItem> scripts = GetInventoryScripts(); 1119 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1120 1120
1121 foreach (TaskInventoryItem item in scripts) 1121 foreach (TaskInventoryItem item in scripts)
1122 { 1122 {
@@ -1157,14 +1157,14 @@ namespace OpenSim.Region.Framework.Scenes
1157 return ret; 1157 return ret;
1158 } 1158 }
1159 1159
1160 public List<TaskInventoryItem> GetInventoryScripts() 1160 public List<TaskInventoryItem> GetInventoryItems(InventoryType type)
1161 { 1161 {
1162 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1162 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1163 1163
1164 lock (m_items) 1164 lock (m_items)
1165 { 1165 {
1166 foreach (TaskInventoryItem item in m_items.Values) 1166 foreach (TaskInventoryItem item in m_items.Values)
1167 if (item.InvType == (int)InventoryType.LSL) 1167 if (item.InvType == (int)type)
1168 ret.Add(item); 1168 ret.Add(item);
1169 } 1169 }
1170 1170
@@ -1183,7 +1183,7 @@ namespace OpenSim.Region.Framework.Scenes
1183 if (engines.Length == 0) // No engine at all 1183 if (engines.Length == 0) // No engine at all
1184 return ret; 1184 return ret;
1185 1185
1186 List<TaskInventoryItem> scripts = GetInventoryScripts(); 1186 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1187 1187
1188 foreach (TaskInventoryItem item in scripts) 1188 foreach (TaskInventoryItem item in scripts)
1189 { 1189 {
@@ -1211,7 +1211,7 @@ namespace OpenSim.Region.Framework.Scenes
1211 if (engines.Length == 0) 1211 if (engines.Length == 0)
1212 return; 1212 return;
1213 1213
1214 List<TaskInventoryItem> scripts = GetInventoryScripts(); 1214 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1215 1215
1216 foreach (TaskInventoryItem item in scripts) 1216 foreach (TaskInventoryItem item in scripts)
1217 { 1217 {
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 8863df1..641d742 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3438,6 +3438,25 @@ namespace OpenSim.Region.Framework.Scenes
3438 } 3438 }
3439 3439
3440 /// <summary> 3440 /// <summary>
3441 /// A float the value is a representative execution time in milliseconds of all scripts in all attachments.
3442 /// </summary>
3443 public float ScriptExecutionTime()
3444 {
3445 float time = 0.0f;
3446 lock (m_attachments)
3447 {
3448 foreach (SceneObjectGroup gobj in m_attachments)
3449 {
3450 if (gobj != null)
3451 {
3452 time += gobj.ScriptExecutionTime();
3453 }
3454 }
3455 }
3456 return time;
3457 }
3458
3459 /// <summary>
3441 /// Returns the total count of running scripts in all parts. 3460 /// Returns the total count of running scripts in all parts.
3442 /// </summary> 3461 /// </summary>
3443 public int RunningScriptCount() 3462 public int RunningScriptCount()
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index c38a52e..078a22a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -10367,7 +10367,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10367 ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384)); 10367 ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384));
10368 break; 10368 break;
10369 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 10369 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
10370 ret.Add(new LSL_Float(0)); 10370 ret.Add(new LSL_Float(av.ScriptExecutionTime() / 1000.0f));
10371 break; 10371 break;
10372 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 10372 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
10373 ret.Add(new LSL_Integer(1)); 10373 ret.Add(new LSL_Integer(1));
@@ -10435,9 +10435,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10435 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384)); 10435 ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384));
10436 break; 10436 break;
10437 case ScriptBaseClass.OBJECT_SCRIPT_TIME: 10437 case ScriptBaseClass.OBJECT_SCRIPT_TIME:
10438 // Average cpu time per simulator frame expended on all scripts in the object 10438 // Average cpu time in seconds per simulator frame expended on all scripts in the object
10439 // Not currently available at Object level 10439 ret.Add(new LSL_Float(obj.ParentGroup.ScriptExecutionTime() / 1000.0f));
10440 ret.Add(new LSL_Float(0));
10441 break; 10440 break;
10442 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: 10441 case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
10443 // according to the SL wiki A prim or linkset will have prim 10442 // according to the SL wiki A prim or linkset will have prim
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 2c0de93..72c1bf6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3038,5 +3038,60 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3038 3038
3039 return ScriptBaseClass.TRUE; 3039 return ScriptBaseClass.TRUE;
3040 } 3040 }
3041
3042 /// <summary>
3043 /// Sets terrain estate texture
3044 /// </summary>
3045 /// <param name="level"></param>
3046 /// <param name="texture"></param>
3047 /// <returns></returns>
3048 public void osSetTerrainTexture(int level, LSL_Key texture)
3049 {
3050 CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture");
3051
3052 m_host.AddScriptLPS(1);
3053 //Check to make sure that the script's owner is the estate manager/master
3054 //World.Permissions.GenericEstatePermission(
3055 if (World.Permissions.IsGod(m_host.OwnerID))
3056 {
3057 if (level < 0 || level > 3)
3058 return;
3059
3060 UUID textureID = new UUID();
3061 if (!UUID.TryParse(texture, out textureID))
3062 return;
3063
3064 // estate module is required
3065 IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
3066 if (estate != null)
3067 estate.setEstateTerrainBaseTexture(level, textureID);
3068 }
3069 }
3070
3071 /// <summary>
3072 /// Sets terrain heights of estate
3073 /// </summary>
3074 /// <param name="corner"></param>
3075 /// <param name="low"></param>
3076 /// <param name="high"></param>
3077 /// <returns></returns>
3078 public void osSetTerrainTextureHeight(int corner, double low, double high)
3079 {
3080 CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight");
3081
3082 m_host.AddScriptLPS(1);
3083 //Check to make sure that the script's owner is the estate manager/master
3084 //World.Permissions.GenericEstatePermission(
3085 if (World.Permissions.IsGod(m_host.OwnerID))
3086 {
3087 if (corner < 0 || corner > 3)
3088 return;
3089
3090 // estate module is required
3091 IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
3092 if (estate != null)
3093 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
3094 }
3095 }
3041 } 3096 }
3042} \ No newline at end of file 3097} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 30bd3ef..545bbee 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/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 7712076..b7903d5 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1907,45 +1907,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1907 if (!topScripts.ContainsKey(si.LocalID)) 1907 if (!topScripts.ContainsKey(si.LocalID))
1908 topScripts[si.RootLocalID] = 0; 1908 topScripts[si.RootLocalID] = 0;
1909 1909
1910// long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; 1910 topScripts[si.RootLocalID] += CalculateAdjustedExectionTime(si, tickNow);
1911// float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond); 1911 }
1912 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 1913
1926 // Scale execution time to the ideal 55 fps frame time for these reasons. 1914 return topScripts;
1927 // 1915 }
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 1916
1944 topScripts[si.RootLocalID] += adjustedExecutionTime; 1917 public float GetScriptExecutionTime(List<UUID> itemIDs)
1918 {
1919 if (itemIDs == null|| itemIDs.Count == 0)
1920 {
1921 return 0.0f;
1922 }
1923 float time = 0.0f;
1924 long tickNow = Util.EnvironmentTickCount();
1925 IScriptInstance si;
1926 // Calculate the time for all scripts that this engine is executing
1927 // Ignore any others
1928 foreach (UUID id in itemIDs)
1929 {
1930 si = GetInstance(id);
1931 if (si != null && si.Running)
1932 {
1933 time += CalculateAdjustedExectionTime(si, tickNow);
1945 } 1934 }
1946 } 1935 }
1936 return time;
1937 }
1947 1938
1948 return topScripts; 1939 private float CalculateAdjustedExectionTime(IScriptInstance si, long tickNow)
1940 {
1941 long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
1942
1943 // Avoid divide by zero
1944 if (ticksElapsed == 0)
1945 ticksElapsed = 1;
1946
1947 // Scale execution time to the ideal 55 fps frame time for these reasons.
1948 //
1949 // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no
1950 // 'script execution time per frame', which is the original purpose of this value.
1951 //
1952 // 2) Giving the raw execution times is misleading since scripts start at different times, making
1953 // it impossible to compare scripts.
1954 //
1955 // 3) Scaling the raw execution time to the time that the script has been running is better but
1956 // is still misleading since a script that has just been rezzed may appear to have been running
1957 // for much longer.
1958 //
1959 // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect
1960 // since the figure does not represent actual execution time and very hard running scripts will
1961 // never exceed 18ms (though this is a very high number for script execution so is a warning sign).
1962 return ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f;
1949 } 1963 }
1950 1964
1951 public void SuspendScript(UUID itemID) 1965 public void SuspendScript(UUID itemID)