aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-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/CoreModules/World/Land/LandObject.cs3
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs22
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateModule.cs3
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs16
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs67
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs150
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs57
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs45
-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
16 files changed, 460 insertions, 122 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 1e743c3..366e02d 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -168,12 +168,18 @@ namespace OpenSim.Region.CoreModules.World.Estate
168 sendRegionInfoPacketToAll(); 168 sendRegionInfoPacketToAll();
169 } 169 }
170 170
171 public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int corner, UUID texture) 171 public void setEstateTerrainBaseTexture(int level, UUID texture)
172 {
173 setEstateTerrainBaseTexture(null, level, texture);
174 sendRegionHandshakeToAll();
175 }
176
177 public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int level, UUID texture)
172 { 178 {
173 if (texture == UUID.Zero) 179 if (texture == UUID.Zero)
174 return; 180 return;
175 181
176 switch (corner) 182 switch (level)
177 { 183 {
178 case 0: 184 case 0:
179 Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture; 185 Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
@@ -193,6 +199,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
193 sendRegionInfoPacketToAll(); 199 sendRegionInfoPacketToAll();
194 } 200 }
195 201
202 public void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue)
203 {
204 setEstateTerrainTextureHeights(null, corner, lowValue, highValue);
205 }
206
196 public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue) 207 public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue)
197 { 208 {
198 switch (corner) 209 switch (corner)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 509c4d7..9b2ddfd 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -447,7 +447,10 @@ namespace OpenSim.Region.CoreModules.World.Land
447 { 447 {
448 bool isMember; 448 bool isMember;
449 if (m_groupMemberCache.TryGetValue(avatar, out isMember)) 449 if (m_groupMemberCache.TryGetValue(avatar, out isMember))
450 {
451 m_groupMemberCache.Update(avatar, isMember, m_groupMemberCacheTimeout);
450 return isMember; 452 return isMember;
453 }
451 454
452 IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); 455 IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
453 if (groupsModule == null) 456 if (groupsModule == null)
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 32f4eea..8732ec0 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -174,7 +174,17 @@ namespace OpenSim.Region.Framework.Interfaces
174 /// If no inventory item has that name then an empty list is returned. 174 /// If no inventory item has that name then an empty list is returned.
175 /// </returns> 175 /// </returns>
176 List<TaskInventoryItem> GetInventoryItems(string name); 176 List<TaskInventoryItem> GetInventoryItems(string name);
177 177
178 /// <summary>
179 /// Get inventory items by type.
180 /// </summary>
181 /// <param type="name"></param>
182 /// <returns>
183 /// A list of inventory items of that type.
184 /// If no inventory items of that type then an empty list is returned.
185 /// </returns>
186 List<TaskInventoryItem> GetInventoryItems(InventoryType type);
187
178 /// <summary> 188 /// <summary>
179 /// Get the scene object referenced by an inventory item. 189 /// Get the scene object referenced by an inventory item.
180 /// </summary> 190 /// </summary>
@@ -228,6 +238,16 @@ namespace OpenSim.Region.Framework.Interfaces
228 bool ContainsScripts(); 238 bool ContainsScripts();
229 239
230 /// <summary> 240 /// <summary>
241 /// Returns the count of scripts contained
242 /// </summary></returns>
243 int ScriptCount();
244
245 /// <summary>
246 /// Returns the count of running scripts contained
247 /// </summary></returns>
248 int RunningScriptCount();
249
250 /// <summary>
231 /// Get the uuids of all items in this inventory 251 /// Get the uuids of all items in this inventory
232 /// </summary> 252 /// </summary>
233 /// <returns></returns> 253 /// <returns></returns>
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs
index 72e79ed..ca2ad94 100644
--- a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs
@@ -47,5 +47,8 @@ namespace OpenSim.Region.Framework.Interfaces
47 void sendRegionHandshakeToAll(); 47 void sendRegionHandshakeToAll();
48 void TriggerEstateInfoChange(); 48 void TriggerEstateInfoChange();
49 void TriggerRegionInfoChange(); 49 void TriggerRegionInfoChange();
50
51 void setEstateTerrainBaseTexture(int level, UUID texture);
52 void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue);
50 } 53 }
51} 54}
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index ce66100..143af48 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -71,6 +71,12 @@ namespace OpenSim.Region.Framework.Interfaces
71 71
72 bool HasScript(UUID itemID, out bool running); 72 bool HasScript(UUID itemID, out bool running);
73 73
74 /// <summary>
75 /// Returns true if a script is running.
76 /// </summary>
77 /// <param name="itemID">The item ID of the script.</param>
78 bool GetScriptState(UUID itemID);
79
74 void SaveAllState(); 80 void SaveAllState();
75 81
76 /// <summary> 82 /// <summary>
@@ -79,6 +85,14 @@ namespace OpenSim.Region.Framework.Interfaces
79 void StartProcessing(); 85 void StartProcessing();
80 86
81 /// <summary> 87 /// <summary>
88 /// Get the execution times of all scripts in the given array if they are currently running.
89 /// </summary>
90 /// <returns>
91 /// A float the value is a representative execution time in milliseconds of all scripts in that Array.
92 /// </returns>
93 float GetScriptExecutionTime(List<UUID> itemIDs);
94
95 /// <summary>
82 /// Get the execution times of all scripts in each object. 96 /// Get the execution times of all scripts in each object.
83 /// </summary> 97 /// </summary>
84 /// <returns> 98 /// <returns>
@@ -87,4 +101,4 @@ namespace OpenSim.Region.Framework.Interfaces
87 /// </returns> 101 /// </returns>
88 Dictionary<uint, float> GetObjectScriptsExecutionTimes(); 102 Dictionary<uint, float> GetObjectScriptsExecutionTimes();
89 } 103 }
90} \ No newline at end of file 104}
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index b806d91..77e808e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -156,7 +156,9 @@ namespace OpenSim.Region.Framework.Scenes
156 // that the region position is cached or performance will degrade 156 // that the region position is cached or performance will degrade
157 Utils.LongToUInts(regionHandle, out x, out y); 157 Utils.LongToUInts(regionHandle, out x, out y);
158 GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); 158 GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
159// bool v = true; 159 if (dest == null)
160 continue;
161
160 if (!simulatorList.Contains(dest.ServerURI)) 162 if (!simulatorList.Contains(dest.ServerURI))
161 { 163 {
162 // we havent seen this simulator before, add it to the list 164 // we havent seen this simulator before, add it to the list
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 3fd1f5e..6f3a084 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -4045,7 +4045,72 @@ namespace OpenSim.Region.Framework.Scenes
4045 for (int i = 0; i < parts.Length; i++) 4045 for (int i = 0; i < parts.Length; i++)
4046 parts[i].TriggerScriptChangedEvent(val); 4046 parts[i].TriggerScriptChangedEvent(val);
4047 } 4047 }
4048 4048
4049 /// <summary>
4050 /// Returns a count of the number of scripts in this groups parts.
4051 /// </summary>
4052 public int ScriptCount()
4053 {
4054 int count = 0;
4055 SceneObjectPart[] parts = m_parts.GetArray();
4056 for (int i = 0; i < parts.Length; i++)
4057 count += parts[i].Inventory.ScriptCount();
4058
4059 return count;
4060 }
4061
4062 /// <summary>
4063 /// A float the value is a representative execution time in milliseconds of all scripts in the link set.
4064 /// </summary>
4065 public float ScriptExecutionTime()
4066 {
4067 IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>();
4068
4069 if (engines.Length == 0) // No engine at all
4070 return 0.0f;
4071
4072 float time = 0.0f;
4073
4074 // get all the scripts in all parts
4075 SceneObjectPart[] parts = m_parts.GetArray();
4076 List<TaskInventoryItem> scripts = new List<TaskInventoryItem>();
4077 for (int i = 0; i < parts.Length; i++)
4078 {
4079 scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL));
4080 }
4081 // extract the UUIDs
4082 List<UUID> ids = new List<UUID>(scripts.Count);
4083 foreach (TaskInventoryItem script in scripts)
4084 {
4085 if (!ids.Contains(script.ItemID))
4086 {
4087 ids.Add(script.ItemID);
4088 }
4089 }
4090 // Offer the list of script UUIDs to each engine found and accumulate the time
4091 foreach (IScriptModule e in engines)
4092 {
4093 if (e != null)
4094 {
4095 time += e.GetScriptExecutionTime(ids);
4096 }
4097 }
4098 return time;
4099 }
4100
4101 /// <summary>
4102 /// Returns a count of the number of running scripts in this groups parts.
4103 /// </summary>
4104 public int RunningScriptCount()
4105 {
4106 int count = 0;
4107 SceneObjectPart[] parts = m_parts.GetArray();
4108 for (int i = 0; i < parts.Length; i++)
4109 count += parts[i].Inventory.RunningScriptCount();
4110
4111 return count;
4112 }
4113
4049 public override string ToString() 4114 public override string ToString()
4050 { 4115 {
4051 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); 4116 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index a2649ee..36cb09a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -267,14 +267,9 @@ namespace OpenSim.Region.Framework.Scenes
267 /// </summary> 267 /// </summary>
268 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) 268 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
269 { 269 {
270 Items.LockItemsForRead(true); 270 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
271 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 271 foreach (TaskInventoryItem item in scripts)
272 Items.LockItemsForRead(false); 272 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
273 foreach (TaskInventoryItem item in items)
274 {
275 if ((int)InventoryType.LSL == item.InvType)
276 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
277 }
278 } 273 }
279 274
280 public ArrayList GetScriptErrors(UUID itemID) 275 public ArrayList GetScriptErrors(UUID itemID)
@@ -305,17 +300,11 @@ namespace OpenSim.Region.Framework.Scenes
305 /// </param> 300 /// </param>
306 public void RemoveScriptInstances(bool sceneObjectBeingDeleted) 301 public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
307 { 302 {
308 Items.LockItemsForRead(true); 303 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
309 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 304 foreach (TaskInventoryItem item in scripts)
310 Items.LockItemsForRead(false);
311
312 foreach (TaskInventoryItem item in items)
313 { 305 {
314 if ((int)InventoryType.LSL == item.InvType) 306 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
315 { 307 m_part.RemoveScriptEvents(item.ItemID);
316 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
317 m_part.RemoveScriptEvents(item.ItemID);
318 }
319 } 308 }
320 } 309 }
321 310
@@ -1280,9 +1269,57 @@ namespace OpenSim.Region.Framework.Scenes
1280 return true; 1269 return true;
1281 } 1270 }
1282 } 1271 }
1272
1283 return false; 1273 return false;
1284 } 1274 }
1285 1275
1276 /// <summary>
1277 /// Returns the count of scripts in this parts inventory.
1278 /// </summary>
1279 /// <returns></returns>
1280 public int ScriptCount()
1281 {
1282 int count = 0;
1283 Items.LockItemsForRead(true);
1284 foreach (TaskInventoryItem item in m_items.Values)
1285 {
1286 if (item.InvType == (int)InventoryType.LSL)
1287 {
1288 count++;
1289 }
1290 }
1291 Items.LockItemsForRead(false);
1292 return count;
1293 }
1294 /// <summary>
1295 /// Returns the count of running scripts in this parts inventory.
1296 /// </summary>
1297 /// <returns></returns>
1298 public int RunningScriptCount()
1299 {
1300 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1301 if (engines.Length == 0)
1302 return 0;
1303
1304 int count = 0;
1305 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1306
1307 foreach (TaskInventoryItem item in scripts)
1308 {
1309 foreach (IScriptModule engine in engines)
1310 {
1311 if (engine != null)
1312 {
1313 if (engine.GetScriptState(item.ItemID))
1314 {
1315 count++;
1316 }
1317 }
1318 }
1319 }
1320 return count;
1321 }
1322
1286 public List<UUID> GetInventoryList() 1323 public List<UUID> GetInventoryList()
1287 { 1324 {
1288 List<UUID> ret = new List<UUID>(); 1325 List<UUID> ret = new List<UUID>();
@@ -1297,22 +1334,24 @@ namespace OpenSim.Region.Framework.Scenes
1297 { 1334 {
1298 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1335 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1299 1336
1300 lock (m_items) 1337 Items.LockItemsForRead(true);
1301 ret = new List<TaskInventoryItem>(m_items.Values); 1338 ret = new List<TaskInventoryItem>(m_items.Values);
1339 Items.LockItemsForRead(false);
1302 1340
1303 return ret; 1341 return ret;
1304 } 1342 }
1305 1343
1306 public List<TaskInventoryItem> GetInventoryScripts() 1344 public List<TaskInventoryItem> GetInventoryItems(InventoryType type)
1307 { 1345 {
1308 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1346 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1309 1347
1310 lock (m_items) 1348 Items.LockItemsForRead(true);
1311 { 1349
1312 foreach (TaskInventoryItem item in m_items.Values) 1350 foreach (TaskInventoryItem item in m_items.Values)
1313 if (item.InvType == (int)InventoryType.LSL) 1351 if (item.InvType == (int)type)
1314 ret.Add(item); 1352 ret.Add(item);
1315 } 1353
1354 Items.LockItemsForRead(false);
1316 1355
1317 return ret; 1356 return ret;
1318 } 1357 }
@@ -1334,35 +1373,32 @@ namespace OpenSim.Region.Framework.Scenes
1334 if (engines.Length == 0) // No engine at all 1373 if (engines.Length == 0) // No engine at all
1335 return ret; 1374 return ret;
1336 1375
1337 Items.LockItemsForRead(true); 1376 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1338 foreach (TaskInventoryItem item in m_items.Values) 1377
1378 foreach (TaskInventoryItem item in scripts)
1339 { 1379 {
1340 if (item.InvType == (int)InventoryType.LSL) 1380 foreach (IScriptModule e in engines)
1341 { 1381 {
1342 foreach (IScriptModule e in engines) 1382 if (e != null)
1343 { 1383 {
1344 if (e != null) 1384 string n = e.GetXMLState(item.ItemID);
1385 if (n != String.Empty)
1345 { 1386 {
1346 string n = e.GetXMLState(item.ItemID); 1387 if (oldIDs)
1347 if (n != String.Empty) 1388 {
1389 if (!ret.ContainsKey(item.OldItemID))
1390 ret[item.OldItemID] = n;
1391 }
1392 else
1348 { 1393 {
1349 if (oldIDs) 1394 if (!ret.ContainsKey(item.ItemID))
1350 { 1395 ret[item.ItemID] = n;
1351 if (!ret.ContainsKey(item.OldItemID))
1352 ret[item.OldItemID] = n;
1353 }
1354 else
1355 {
1356 if (!ret.ContainsKey(item.ItemID))
1357 ret[item.ItemID] = n;
1358 }
1359 break;
1360 } 1396 }
1397 break;
1361 } 1398 }
1362 } 1399 }
1363 } 1400 }
1364 } 1401 }
1365 Items.LockItemsForRead(false);
1366 return ret; 1402 return ret;
1367 } 1403 }
1368 1404
@@ -1372,27 +1408,21 @@ namespace OpenSim.Region.Framework.Scenes
1372 if (engines.Length == 0) 1408 if (engines.Length == 0)
1373 return; 1409 return;
1374 1410
1411 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1375 1412
1376 Items.LockItemsForRead(true); 1413 foreach (TaskInventoryItem item in scripts)
1377
1378 foreach (TaskInventoryItem item in m_items.Values)
1379 { 1414 {
1380 if (item.InvType == (int)InventoryType.LSL) 1415 foreach (IScriptModule engine in engines)
1381 { 1416 {
1382 foreach (IScriptModule engine in engines) 1417 if (engine != null)
1383 { 1418 {
1384 if (engine != null) 1419 if (item.OwnerChanged)
1385 { 1420 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
1386 if (item.OwnerChanged) 1421 item.OwnerChanged = false;
1387 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); 1422 engine.ResumeScript(item.ItemID);
1388 item.OwnerChanged = false;
1389 engine.ResumeScript(item.ItemID);
1390 }
1391 } 1423 }
1392 } 1424 }
1393 } 1425 }
1394
1395 Items.LockItemsForRead(false);
1396 } 1426 }
1397 } 1427 }
1398} 1428}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index b51d41b..fd7f7d8 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3521,6 +3521,63 @@ namespace OpenSim.Region.Framework.Scenes
3521 return m_attachments.Count > 0; 3521 return m_attachments.Count > 0;
3522 } 3522 }
3523 3523
3524 /// <summary>
3525 /// Returns the total count of scripts in all parts inventories.
3526 /// </summary>
3527 public int ScriptCount()
3528 {
3529 int count = 0;
3530 lock (m_attachments)
3531 {
3532 foreach (SceneObjectGroup gobj in m_attachments)
3533 {
3534 if (gobj != null)
3535 {
3536 count += gobj.ScriptCount();
3537 }
3538 }
3539 }
3540 return count;
3541 }
3542
3543 /// <summary>
3544 /// A float the value is a representative execution time in milliseconds of all scripts in all attachments.
3545 /// </summary>
3546 public float ScriptExecutionTime()
3547 {
3548 float time = 0.0f;
3549 lock (m_attachments)
3550 {
3551 foreach (SceneObjectGroup gobj in m_attachments)
3552 {
3553 if (gobj != null)
3554 {
3555 time += gobj.ScriptExecutionTime();
3556 }
3557 }
3558 }
3559 return time;
3560 }
3561
3562 /// <summary>
3563 /// Returns the total count of running scripts in all parts.
3564 /// </summary>
3565 public int RunningScriptCount()
3566 {
3567 int count = 0;
3568 lock (m_attachments)
3569 {
3570 foreach (SceneObjectGroup gobj in m_attachments)
3571 {
3572 if (gobj != null)
3573 {
3574 count += gobj.RunningScriptCount();
3575 }
3576 }
3577 }
3578 return count;
3579 }
3580
3524 public bool HasScriptedAttachments() 3581 public bool HasScriptedAttachments()
3525 { 3582 {
3526 lock (m_attachments) 3583 lock (m_attachments)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 2f61b70..23158b9 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:
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 0dc2aa2..2899774 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3095,5 +3095,60 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3095 3095
3096 return ScriptBaseClass.TRUE; 3096 return ScriptBaseClass.TRUE;
3097 } 3097 }
3098
3099 /// <summary>
3100 /// Sets terrain estate texture
3101 /// </summary>
3102 /// <param name="level"></param>
3103 /// <param name="texture"></param>
3104 /// <returns></returns>
3105 public void osSetTerrainTexture(int level, LSL_Key texture)
3106 {
3107 CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture");
3108
3109 m_host.AddScriptLPS(1);
3110 //Check to make sure that the script's owner is the estate manager/master
3111 //World.Permissions.GenericEstatePermission(
3112 if (World.Permissions.IsGod(m_host.OwnerID))
3113 {
3114 if (level < 0 || level > 3)
3115 return;
3116
3117 UUID textureID = new UUID();
3118 if (!UUID.TryParse(texture, out textureID))
3119 return;
3120
3121 // estate module is required
3122 IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
3123 if (estate != null)
3124 estate.setEstateTerrainBaseTexture(level, textureID);
3125 }
3126 }
3127
3128 /// <summary>
3129 /// Sets terrain heights of estate
3130 /// </summary>
3131 /// <param name="corner"></param>
3132 /// <param name="low"></param>
3133 /// <param name="high"></param>
3134 /// <returns></returns>
3135 public void osSetTerrainTextureHeight(int corner, double low, double high)
3136 {
3137 CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight");
3138
3139 m_host.AddScriptLPS(1);
3140 //Check to make sure that the script's owner is the estate manager/master
3141 //World.Permissions.GenericEstatePermission(
3142 if (World.Permissions.IsGod(m_host.OwnerID))
3143 {
3144 if (corner < 0 || corner > 3)
3145 return;
3146
3147 // estate module is required
3148 IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
3149 if (estate != null)
3150 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
3151 }
3152 }
3098 } 3153 }
3099} 3154}
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/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)