aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation
diff options
context:
space:
mode:
authorRobert Adams2013-01-10 17:03:19 -0800
committerRobert Adams2013-01-11 16:47:35 -0800
commiteacc2561d14dbe9cba6966e3b32bfd776e044f8a (patch)
tree8ddaebdd22286becd5dd57a84d3582a1f582d1f2 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation
parentBulletSim: Add IsSelected attribute to physical objects. Have vehicles check ... (diff)
downloadopensim-SC_OLD-eacc2561d14dbe9cba6966e3b32bfd776e044f8a.zip
opensim-SC_OLD-eacc2561d14dbe9cba6966e3b32bfd776e044f8a.tar.gz
opensim-SC_OLD-eacc2561d14dbe9cba6966e3b32bfd776e044f8a.tar.bz2
opensim-SC_OLD-eacc2561d14dbe9cba6966e3b32bfd776e044f8a.tar.xz
BulletSim: add osGetPhysicsEngineType() LSL function and update
the physics engines to return the name that is specified in the INI file ("physics = XXX") as the type of engine. This os function is a little different than the others in that it does not throw an exception of one is not privilaged to use it. It merely returns an empty string.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs59
1 files changed, 48 insertions, 11 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 33c02ef..958a448 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -245,11 +245,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
245 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); 245 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
246 } 246 }
247 247
248 // Returns of the function is allowed. Throws a script exception if not allowed.
248 public void CheckThreatLevel(ThreatLevel level, string function) 249 public void CheckThreatLevel(ThreatLevel level, string function)
249 { 250 {
250 if (!m_OSFunctionsEnabled) 251 if (!m_OSFunctionsEnabled)
251 OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws 252 OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws
252 253
254 string reasonWhyNot = CheckThreatLevelTest(level, function);
255 if (!String.IsNullOrEmpty(reasonWhyNot))
256 {
257 OSSLError(reasonWhyNot);
258 }
259 }
260
261 // Check to see if function is allowed. Returns an empty string if function permitted
262 // or a string explaining why this function can't be used.
263 private string CheckThreatLevelTest(ThreatLevel level, string function)
264 {
253 if (!m_FunctionPerms.ContainsKey(function)) 265 if (!m_FunctionPerms.ContainsKey(function))
254 { 266 {
255 FunctionPerms perms = new FunctionPerms(); 267 FunctionPerms perms = new FunctionPerms();
@@ -329,10 +341,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
329 { 341 {
330 // Allow / disallow by threat level 342 // Allow / disallow by threat level
331 if (level > m_MaxThreatLevel) 343 if (level > m_MaxThreatLevel)
332 OSSLError( 344 return
333 String.Format( 345 String.Format(
334 "{0} permission denied. Allowed threat level is {1} but function threat level is {2}.", 346 "{0} permission denied. Allowed threat level is {1} but function threat level is {2}.",
335 function, m_MaxThreatLevel, level)); 347 function, m_MaxThreatLevel, level);
336 } 348 }
337 else 349 else
338 { 350 {
@@ -342,7 +354,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
342 if (m_FunctionPerms[function].AllowedOwners.Contains(m_host.OwnerID)) 354 if (m_FunctionPerms[function].AllowedOwners.Contains(m_host.OwnerID))
343 { 355 {
344 // prim owner is in the list of allowed owners 356 // prim owner is in the list of allowed owners
345 return; 357 return String.Empty;
346 } 358 }
347 359
348 UUID ownerID = m_item.OwnerID; 360 UUID ownerID = m_item.OwnerID;
@@ -354,7 +366,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
354 366
355 if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero) 367 if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero)
356 { 368 {
357 return; 369 return String.Empty;
358 } 370 }
359 } 371 }
360 372
@@ -365,7 +377,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
365 377
366 if (land.LandData.OwnerID == ownerID) 378 if (land.LandData.OwnerID == ownerID)
367 { 379 {
368 return; 380 return String.Empty;
369 } 381 }
370 } 382 }
371 383
@@ -375,7 +387,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
375 //Only Estate Managers may use the function 387 //Only Estate Managers may use the function
376 if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) 388 if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID)
377 { 389 {
378 return; 390 return String.Empty;
379 } 391 }
380 } 392 }
381 393
@@ -384,25 +396,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
384 { 396 {
385 if (World.RegionInfo.EstateSettings.EstateOwner == ownerID) 397 if (World.RegionInfo.EstateSettings.EstateOwner == ownerID)
386 { 398 {
387 return; 399 return String.Empty;
388 } 400 }
389 } 401 }
390 402
391 if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID)) 403 if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID))
392 OSSLError( 404 return(
393 String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", 405 String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.",
394 function)); 406 function));
395 407
396 if (m_item.CreatorID != ownerID) 408 if (m_item.CreatorID != ownerID)
397 { 409 {
398 if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0) 410 if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0)
399 OSSLError( 411 return String.Format("{0} permission denied. Script permissions error.", function);
400 String.Format("{0} permission denied. Script permissions error.",
401 function));
402 412
403 } 413 }
404 } 414 }
405 } 415 }
416 return String.Empty;
406 } 417 }
407 418
408 internal void OSSLDeprecated(string function, string replacement) 419 internal void OSSLDeprecated(string function, string replacement)
@@ -1558,6 +1569,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1558 } 1569 }
1559 } 1570 }
1560 1571
1572 public string osGetPhysicsEngineType()
1573 {
1574 // High because it can be used to target attacks to known weaknesses
1575 // This would allow a new class of griefer scripts that don't even
1576 // require their user to know what they are doing (see script
1577 // kiddie)
1578 // Because it would be nice if scripts didn't blow up if the information
1579 // about the physics engine, this function returns an empty string if
1580 // the user does not have permission to see it. This as opposed to
1581 // throwing an exception.
1582 m_host.AddScriptLPS(1);
1583 string ret = String.Empty;
1584 if (String.IsNullOrEmpty(CheckThreatLevelTest(ThreatLevel.High, "osGetPhysicsEngineType")))
1585 {
1586 if (m_ScriptEngine.World.PhysicsScene != null)
1587 {
1588 ret = m_ScriptEngine.World.PhysicsScene.EngineType;
1589 // An old physics engine might have an uninitialized engine type
1590 if (ret == null)
1591 ret = "unknown";
1592 }
1593 }
1594
1595 return ret;
1596 }
1597
1561 public string osGetSimulatorVersion() 1598 public string osGetSimulatorVersion()
1562 { 1599 {
1563 // High because it can be used to target attacks to known weaknesses 1600 // High because it can be used to target attacks to known weaknesses