From 74447d14cda441408419bc90828975cf4b751692 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 2 Aug 2014 18:32:28 +0100
Subject: add some filters for NPCs
---
.../CoreModules/World/Land/LandManagementModule.cs | 4 ++
.../Region/CoreModules/World/Land/LandObject.cs | 3 ++
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 61 ++++++++++++++++------
3 files changed, 52 insertions(+), 16 deletions(-)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 3016bbe..d8e3082 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -1047,6 +1047,10 @@ namespace OpenSim.Region.CoreModules.World.Land
/// The object representing the client
public void SendParcelOverlay(IClientAPI remote_client)
{
+
+ if (remote_client.SceneAgent.PresenceType == PresenceType.Npc)
+ return;
+
const int LAND_BLOCKS_PER_PACKET = 1024;
byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET];
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 7de6365..29c2234 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -244,6 +244,9 @@ namespace OpenSim.Region.CoreModules.World.Land
public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client)
{
+ if (remote_client.SceneAgent.PresenceType == PresenceType.Npc)
+ return;
+
IEstateModule estateModule = m_scene.RequestModuleInterface();
uint regionFlags = 336723974 & ~((uint)(RegionFlags.AllowLandmark | RegionFlags.AllowSetHome));
if (estateModule != null)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 415dbcd..faaf74c 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -88,7 +88,17 @@ namespace OpenSim.Region.Framework.Scenes
m_scene.EventManager.TriggerScenePresenceUpdated(this);
}
- public PresenceType PresenceType { get; private set; }
+ public bool isNPC { get; private set; }
+
+ private PresenceType m_presenceType;
+ public PresenceType PresenceType {
+ get {return m_presenceType;}
+ private set
+ {
+ m_presenceType = value;
+ isNPC = (m_presenceType == PresenceType.Npc);
+ }
+ }
private ScenePresenceStateMachine m_stateMachine;
@@ -1258,6 +1268,7 @@ namespace OpenSim.Region.Framework.Scenes
// and it has already rezzed the attachments and started their scripts.
// We do the following only for non-login agents, because their scripts
// haven't started yet.
+/* moved down
if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0)
{
// Viewers which have a current outfit folder will actually rez their own attachments. However,
@@ -1273,6 +1284,7 @@ namespace OpenSim.Region.Framework.Scenes
});
}
else
+
{
// We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT
// and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently
@@ -1314,7 +1326,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
-
+*/
/*
SendAvatarDataToAllAgents();
@@ -1741,7 +1753,7 @@ namespace OpenSim.Region.Framework.Scenes
try
{
// Make sure it's not a login agent. We don't want to wait for updates during login
- if (PresenceType != PresenceType.Npc && (m_teleportFlags & TeleportFlags.ViaLogin) == 0)
+ if (!isNPC && (m_teleportFlags & TeleportFlags.ViaLogin) == 0)
{
// Let's wait until UpdateAgent (called by departing region) is done
if (!WaitForUpdateAgent(client))
@@ -1820,7 +1832,6 @@ namespace OpenSim.Region.Framework.Scenes
m_previusParcelUUID = UUID.Zero;
m_currentParcelHide = false;
m_currentParcelUUID = UUID.Zero;
-
// send initial land overlay and parcel
if (!IsChildAgent)
@@ -1842,28 +1853,48 @@ namespace OpenSim.Region.Framework.Scenes
ValidateAndSendAppearanceAndAgentData();
// Create child agents in neighbouring regions
- if (openChildAgents && !IsChildAgent)
+ if (openChildAgents && !IsChildAgent && !isNPC)
{
IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface();
if (m_agentTransfer != null)
m_agentTransfer.EnableChildAgents(this);
}
- // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region
- // If we do it a little bit earlier (e.g. when converting the child to a root agent) then this does not work.
- // This may be due to viewer code or it may be something we're not doing properly simulator side.
- lock (m_attachments)
+
+ // attachments
+ if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0)
{
- foreach (SceneObjectGroup sog in m_attachments)
- sog.ScheduleGroupForFullUpdate();
+ if (Scene.AttachmentsModule != null)
+ Util.FireAndForget(
+ o =>
+ {
+ Scene.AttachmentsModule.RezAttachments(this);
+ });
}
+ else
+ {
+ List attachments = GetAttachments();
+ if (attachments.Count > 0)
+ {
+ m_log.DebugFormat(
+ "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
+
+ // Resume scripts this possible should also be moved down after sending the avatar to viewer ?
+ foreach (SceneObjectGroup sog in attachments)
+ {
+ sog.ScheduleGroupForFullUpdate();
+ sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
+ sog.ResumeScripts();
+ }
+ }
+ }
// m_log.DebugFormat(
// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
// send the rest of the world
- if (m_teleportFlags > 0)
+ if (m_teleportFlags > 0 && !isNPC)
SendInitialDataToMe();
if (!IsChildAgent)
@@ -5488,7 +5519,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- if (killsToSendme.Count > 0)
+ if (killsToSendme.Count > 0 && PresenceType != PresenceType.Npc)
{
foreach (ScenePresence p in killsToSendme)
{
@@ -5509,7 +5540,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- if (viewsToSendme.Count > 0)
+ if (viewsToSendme.Count > 0 && PresenceType != PresenceType.Npc)
{
foreach (ScenePresence p in viewsToSendme)
{
@@ -5520,8 +5551,6 @@ namespace OpenSim.Region.Framework.Scenes
p.Animator.SendAnimPackToClient(ControllingClient);
}
}
-
-
}
}
}
--
cgit v1.1