Look up the NPC module when the SensorRepeat class is created, rather than on every single sensor sweep.

0.7.3-extended
Justin Clark-Casey (justincc) 2012-08-01 00:39:37 +01:00
parent 1d0ff7da2a
commit 5772d23ff6
1 changed files with 6 additions and 5 deletions

View File

@ -60,8 +60,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
m_CmdManager = CmdManager; m_CmdManager = CmdManager;
maximumRange = CmdManager.m_ScriptEngine.Config.GetDouble("SensorMaxRange", 96.0d); maximumRange = CmdManager.m_ScriptEngine.Config.GetDouble("SensorMaxRange", 96.0d);
maximumToReturn = CmdManager.m_ScriptEngine.Config.GetInt("SensorMaxResults", 16); maximumToReturn = CmdManager.m_ScriptEngine.Config.GetInt("SensorMaxResults", 16);
m_npcModule = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<INPCModule>();
} }
private INPCModule m_npcModule;
private Object SenseLock = new Object(); private Object SenseLock = new Object();
private const int AGENT = 1; private const int AGENT = 1;
@ -441,8 +444,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) private List<SensedEntity> doAgentSensor(SenseRepeatClass ts)
{ {
INPCModule npcModule = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<INPCModule>();
List<SensedEntity> sensedEntities = new List<SensedEntity>(); List<SensedEntity> sensedEntities = new List<SensedEntity>();
// If nobody about quit fast // If nobody about quit fast
@ -468,7 +469,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0);
Vector3 toRegionPos; Vector3 toRegionPos;
double dis; double dis;
Action<ScenePresence> senseEntity = new Action<ScenePresence>(presence => Action<ScenePresence> senseEntity = new Action<ScenePresence>(presence =>
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
@ -477,7 +478,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc) if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc)
{ {
INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene);
if (npcData == null || !npcData.SenseAsAgent) if (npcData == null || !npcData.SenseAsAgent)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
@ -495,7 +496,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
} }
else else
{ {
INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene);
if (npcData != null && npcData.SenseAsAgent) if (npcData != null && npcData.SenseAsAgent)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(