aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs38
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs20
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs93
3 files changed, 68 insertions, 83 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0c373b9..3f630f4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5293,7 +5293,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5293 public LSL_Integer llGetRegionAgentCount() 5293 public LSL_Integer llGetRegionAgentCount()
5294 { 5294 {
5295 m_host.AddScriptLPS(1); 5295 m_host.AddScriptLPS(1);
5296 return new LSL_Integer(World.GetAvatars().Count); 5296 return new LSL_Integer(World.GetRootAgentCount());
5297 } 5297 }
5298 5298
5299 public LSL_Vector llGetRegionCorner() 5299 public LSL_Vector llGetRegionCorner()
@@ -9096,17 +9096,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9096 landObject.SetMediaUrl(url); 9096 landObject.SetMediaUrl(url);
9097 9097
9098 // now send to all (non-child) agents 9098 // now send to all (non-child) agents
9099 List<ScenePresence> agents = World.GetAvatars(); 9099 World.ForEachScenePresence(delegate(ScenePresence sp)
9100 foreach (ScenePresence agent in agents)
9101 { 9100 {
9102 agent.ControllingClient.SendParcelMediaUpdate(landData.MediaURL, 9101 if (!sp.IsChildAgent)
9103 landData.MediaID, 9102 {
9104 landData.MediaAutoScale, 9103 sp.ControllingClient.SendParcelMediaUpdate(landData.MediaURL,
9105 mediaType, 9104 landData.MediaID,
9106 description, 9105 landData.MediaAutoScale,
9107 width, height, 9106 mediaType,
9108 loop); 9107 description,
9109 } 9108 width, height,
9109 loop);
9110 }
9111 });
9110 } 9112 }
9111 else if (!presence.IsChildAgent) 9113 else if (!presence.IsChildAgent)
9112 { 9114 {
@@ -9127,13 +9129,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9127 if (presence == null) 9129 if (presence == null)
9128 { 9130 {
9129 // send to all (non-child) agents 9131 // send to all (non-child) agents
9130 List<ScenePresence> agents = World.GetAvatars(); 9132 World.ForEachScenePresence(delegate(ScenePresence sp)
9131 foreach (ScenePresence agent in agents)
9132 { 9133 {
9133 agent.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this? 9134 if (!sp.IsChildAgent)
9134 (ParcelMediaCommandEnum)commandToSend, 9135 {
9135 time); 9136 sp.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this?
9136 } 9137 (ParcelMediaCommandEnum)commandToSend,
9138 time);
9139 }
9140 });
9137 } 9141 }
9138 else if (!presence.IsChildAgent) 9142 else if (!presence.IsChildAgent)
9139 { 9143 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 845834e..9474bab 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -697,10 +697,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
697 CheckThreatLevel(ThreatLevel.None, "osGetAgents"); 697 CheckThreatLevel(ThreatLevel.None, "osGetAgents");
698 698
699 LSL_List result = new LSL_List(); 699 LSL_List result = new LSL_List();
700 foreach (ScenePresence avatar in World.GetAvatars()) 700 World.ForEachScenePresence(delegate(ScenePresence sp)
701 { 701 {
702 result.Add(avatar.Name); 702 if (!sp.IsChildAgent)
703 } 703 result.Add(sp.Name);
704 });
704 return result; 705 return result;
705 } 706 }
706 707
@@ -1989,19 +1990,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1989 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); 1990 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar");
1990 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) 1991 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
1991 { 1992 {
1992 foreach (ScenePresence presence in World.GetAvatars()) 1993 World.ForEachScenePresence(delegate(ScenePresence sp)
1993 { 1994 {
1994 if ((presence.Firstname == FirstName) && 1995 if (!sp.IsChildAgent &&
1995 presence.Lastname == SurName) 1996 sp.Firstname == FirstName &&
1997 sp.Lastname == SurName)
1996 { 1998 {
1997 // kick client... 1999 // kick client...
1998 if (alert != null) 2000 if (alert != null)
1999 presence.ControllingClient.Kick(alert); 2001 sp.ControllingClient.Kick(alert);
2000 2002
2001 // ...and close on our side 2003 // ...and close on our side
2002 presence.Scene.IncomingCloseAgent(presence.UUID); 2004 sp.Scene.IncomingCloseAgent(sp.UUID);
2003 } 2005 }
2004 } 2006 });
2005 } 2007 }
2006 } 2008 }
2007 2009
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 829fbb7..2296379 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -404,70 +404,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
404 404
405 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) 405 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts)
406 { 406 {
407 List<ScenePresence> presences;
408 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 407 List<SensedEntity> sensedEntities = new List<SensedEntity>();
409 408
410 // If this is an avatar sense by key try to get them directly
411 // rather than getting a list to scan through
412 if (ts.keyID != UUID.Zero)
413 {
414 ScenePresence p = m_CmdManager.m_ScriptEngine.World.GetScenePresence(ts.keyID);
415 if (p == null)
416 return sensedEntities;
417 presences = new List<ScenePresence>();
418 presences.Add(p);
419 }
420 else
421 {
422 presences = new List<ScenePresence>(m_CmdManager.m_ScriptEngine.World.GetScenePresences());
423 }
424
425 // If nobody about quit fast 409 // If nobody about quit fast
426 if (presences.Count == 0) 410 if(m_CmdManager.m_ScriptEngine.World.GetRootAgentCount() == 0)
427 return sensedEntities; 411 return sensedEntities;
428 412
429 SceneObjectPart SensePoint = ts.host; 413 SceneObjectPart SensePoint = ts.host;
430
431 Vector3 fromRegionPos = SensePoint.AbsolutePosition; 414 Vector3 fromRegionPos = SensePoint.AbsolutePosition;
432
433 Quaternion q = SensePoint.RotationOffset; 415 Quaternion q = SensePoint.RotationOffset;
434 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 416 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
435 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); 417 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
436 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 418 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
437
438 bool attached = (SensePoint.AttachmentPoint != 0); 419 bool attached = (SensePoint.AttachmentPoint != 0);
439 bool nameSearch = (ts.name != null && ts.name != "");
440 Vector3 toRegionPos; 420 Vector3 toRegionPos;
441 double dis; 421 double dis;
442 422
443 for (int i = 0; i < presences.Count; i++) 423 Action<ScenePresence> senseEntity = new Action<ScenePresence>(delegate(ScenePresence presence)
444 { 424 {
445 ScenePresence presence = presences[i]; 425 if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0)
446 bool keep = true; 426 return;
427
428 // if the object the script is in is attached and the avatar is the owner
429 // then this one is not wanted
430 if (attached && presence.UUID == SensePoint.OwnerID)
431 return;
447 432
448 if (presence.IsDeleted)
449 continue;
450
451 if (presence.IsChildAgent)
452 keep = false;
453 toRegionPos = presence.AbsolutePosition; 433 toRegionPos = presence.AbsolutePosition;
454
455 dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); 434 dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos));
456 435
457 // are they in range 436 // are they in range
458 if (keep && dis <= ts.range) 437 if (dis <= ts.range)
459 { 438 {
460 // if the object the script is in is attached and the avatar is the owner
461 // then this one is not wanted
462 if (attached && presence.UUID == SensePoint.OwnerID)
463 keep = false;
464
465 // check the name if needed
466 if (keep && nameSearch && ts.name != presence.Name)
467 keep = false;
468
469 // Are they in the required angle of view 439 // Are they in the required angle of view
470 if (keep && ts.arc < Math.PI) 440 if (ts.arc < Math.PI)
471 { 441 {
472 // not omni-directional. Can you see it ? 442 // not omni-directional. Can you see it ?
473 // vec forward_dir = llRot2Fwd(llGetRot()) 443 // vec forward_dir = llRot2Fwd(llGetRot())
@@ -488,26 +458,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
488 catch 458 catch
489 { 459 {
490 } 460 }
491 if (ang_obj > ts.arc) keep = false; 461 if (ang_obj <= ts.arc)
462 {
463 sensedEntities.Add(new SensedEntity(dis, presence.UUID));
464 }
492 } 465 }
493 } 466 }
494 else 467 });
495 {
496 keep = false;
497 }
498 468
499 // Do not report gods, not even minor ones 469 // If this is an avatar sense by key try to get them directly
500 if (keep && presence.GodLevel > 0.0) 470 // rather than getting a list to scan through
501 keep = false; 471 if (ts.keyID != UUID.Zero)
502 472 {
503 if (keep) // add to list with distance 473 ScenePresence sp;
504 { 474 // Try direct lookup by UUID
505 sensedEntities.Add(new SensedEntity(dis, presence.UUID)); 475 if(!m_CmdManager.m_ScriptEngine.World.TryGetScenePresence(ts.keyID, out sp))
506 }
507
508 // If this is a search by name and we have just found it then no more to do
509 if (nameSearch && ts.name == presence.Name)
510 return sensedEntities; 476 return sensedEntities;
477 senseEntity(sp);
478 }
479 else if (ts.name != null && ts.name != "")
480 {
481 ScenePresence sp;
482 // Try lookup by name will return if/when found
483 if (!m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp))
484 return sensedEntities;
485 senseEntity(sp);
486 }
487 else
488 {
489 m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(senseEntity);
511 } 490 }
512 return sensedEntities; 491 return sensedEntities;
513 } 492 }