aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-18 00:53:05 +0100
committerJustin Clark-Casey (justincc)2011-08-18 00:53:05 +0100
commitc1a34cd8da293e63d3cba70b5271c9a297789db2 (patch)
treef6d87f42151ca8891cb37ed1bf2a5d5361c86ddf
parentcomment out noisy attachments logging (diff)
downloadopensim-SC_OLD-c1a34cd8da293e63d3cba70b5271c9a297789db2.zip
opensim-SC_OLD-c1a34cd8da293e63d3cba70b5271c9a297789db2.tar.gz
opensim-SC_OLD-c1a34cd8da293e63d3cba70b5271c9a297789db2.tar.bz2
opensim-SC_OLD-c1a34cd8da293e63d3cba70b5271c9a297789db2.tar.xz
Don't try to save changed attachment states when an NPC with attachments is removed from the scene.
This is done by introducing a PresenceType enum into ScenePresence which currently has two values, User and Npc. This seems better than a SaveAttachments flag in terms of code comprehension, though I'm still slightly uneasy about introducing these semantics to core objects
-rw-r--r--OpenSim/Framework/IScene.cs7
-rw-r--r--OpenSim/Framework/PresenceType.cs39
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs4
-rw-r--r--OpenSim/Region/Examples/SimpleModule/RegionModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs2
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs2
14 files changed, 71 insertions, 23 deletions
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs
index b5f975b..8f7a2e5 100644
--- a/OpenSim/Framework/IScene.cs
+++ b/OpenSim/Framework/IScene.cs
@@ -72,10 +72,11 @@ namespace OpenSim.Framework
72 72
73 /// <summary> 73 /// <summary>
74 /// Register the new client with the scene. The client starts off as a child agent - the later agent crossing 74 /// Register the new client with the scene. The client starts off as a child agent - the later agent crossing
75 /// will promote it to a root agent during login. 75 /// will promote it to a root agent.
76 /// </summary> 76 /// </summary>
77 /// <param name="client"></param 77 /// <param name="client"></param>
78 void AddNewClient(IClientAPI client); 78 /// <param name="type">The type of agent to add.</param>
79 void AddNewClient(IClientAPI client, PresenceType type);
79 80
80 /// <summary> 81 /// <summary>
81 /// Remove the given client from the scene. 82 /// Remove the given client from the scene.
diff --git a/OpenSim/Framework/PresenceType.cs b/OpenSim/Framework/PresenceType.cs
new file mode 100644
index 0000000..8c4c6e6
--- /dev/null
+++ b/OpenSim/Framework/PresenceType.cs
@@ -0,0 +1,39 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28
29namespace OpenSim.Framework
30{
31 /// <summary>
32 /// Indicate the type of ScenePresence.
33 /// </summary>
34 public enum PresenceType
35 {
36 User,
37 Npc
38 }
39} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 1d35973..f71871e 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -692,7 +692,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
692 692
693 public virtual void Start() 693 public virtual void Start()
694 { 694 {
695 m_scene.AddNewClient(this); 695 m_scene.AddNewClient(this, PresenceType.User);
696 696
697 RefreshGroupMembership(); 697 RefreshGroupMembership();
698 } 698 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index a3639e8..97a1be6 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -501,10 +501,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
501 /// <summary> 501 /// <summary>
502 /// Update the attachment asset for the new sog details if they have changed. 502 /// Update the attachment asset for the new sog details if they have changed.
503 /// </summary> 503 /// </summary>
504 /// 504 /// <remarks>
505 /// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects, 505 /// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects,
506 /// these details are not stored on the region. 506 /// these details are not stored on the region.
507 /// 507 /// </remarks>
508 /// <param name="remoteClient"></param> 508 /// <param name="remoteClient"></param>
509 /// <param name="grp"></param> 509 /// <param name="grp"></param>
510 /// <param name="itemID"></param> 510 /// <param name="itemID"></param>
diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
index 088b818..3b8ce37 100644
--- a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
+++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
@@ -95,7 +95,7 @@ namespace OpenSim.Region.Examples.SimpleModule
95 for (int i = 0; i < 1; i++) 95 for (int i = 0; i < 1; i++)
96 { 96 {
97 MyNpcCharacter m_character = new MyNpcCharacter(m_scene); 97 MyNpcCharacter m_character = new MyNpcCharacter(m_scene);
98 m_scene.AddNewClient(m_character); 98 m_scene.AddNewClient(m_character, PresenceType.Npc);
99 m_scene.AgentCrossing(m_character.AgentId, Vector3.Zero, false); 99 m_scene.AgentCrossing(m_character.AgentId, Vector3.Zero, false);
100 } 100 }
101 101
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 13b4cbc..ae88a87 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2543,10 +2543,11 @@ namespace OpenSim.Region.Framework.Scenes
2543 #region Add/Remove Avatar Methods 2543 #region Add/Remove Avatar Methods
2544 2544
2545 /// <summary> 2545 /// <summary>
2546 /// Adding a New Client and Create a Presence for it. 2546 /// Add a new client and create a child agent for it.
2547 /// </summary> 2547 /// </summary>
2548 /// <param name="client"></param> 2548 /// <param name="client"></param>
2549 public override void AddNewClient(IClientAPI client) 2549 /// <param name="type">The type of agent to add.</param>
2550 public override void AddNewClient(IClientAPI client, PresenceType type)
2550 { 2551 {
2551 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); 2552 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
2552 bool vialogin = false; 2553 bool vialogin = false;
@@ -2566,7 +2567,7 @@ namespace OpenSim.Region.Framework.Scenes
2566 m_clientManager.Add(client); 2567 m_clientManager.Add(client);
2567 SubscribeToClientEvents(client); 2568 SubscribeToClientEvents(client);
2568 2569
2569 ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance); 2570 ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
2570 m_eventManager.TriggerOnNewPresence(sp); 2571 m_eventManager.TriggerOnNewPresence(sp);
2571 2572
2572 sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags; 2573 sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags;
@@ -3149,7 +3150,7 @@ namespace OpenSim.Region.Framework.Scenes
3149 3150
3150 m_eventManager.TriggerOnRemovePresence(agentID); 3151 m_eventManager.TriggerOnRemovePresence(agentID);
3151 3152
3152 if (avatar != null && (!avatar.IsChildAgent)) 3153 if (avatar != null && (!avatar.IsChildAgent) && avatar.PresenceType != PresenceType.Npc)
3153 avatar.SaveChangedAttachments(); 3154 avatar.SaveChangedAttachments();
3154 3155
3155 ForEachClient( 3156 ForEachClient(
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 2f1cdc1..ec94f10 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -175,7 +175,7 @@ namespace OpenSim.Region.Framework.Scenes
175 175
176 #region Add/Remove Agent/Avatar 176 #region Add/Remove Agent/Avatar
177 177
178 public abstract void AddNewClient(IClientAPI client); 178 public abstract void AddNewClient(IClientAPI client, PresenceType type);
179 public abstract void RemoveClient(UUID agentID, bool closeChildAgents); 179 public abstract void RemoveClient(UUID agentID, bool closeChildAgents);
180 180
181 public bool TryGetScenePresence(UUID agentID, out object scenePresence) 181 public bool TryGetScenePresence(UUID agentID, out object scenePresence)
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 65dc2c9..f40b373 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -590,12 +590,13 @@ namespace OpenSim.Region.Framework.Scenes
590 } 590 }
591 } 591 }
592 592
593 protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) 593 protected internal ScenePresence CreateAndAddChildScenePresence(
594 IClientAPI client, AvatarAppearance appearance, PresenceType type)
594 { 595 {
595 ScenePresence newAvatar = null; 596 ScenePresence newAvatar = null;
596 597
597 // ScenePresence always defaults to child agent 598 // ScenePresence always defaults to child agent
598 newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance); 599 newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance, type);
599 600
600 AddScenePresence(newAvatar); 601 AddScenePresence(newAvatar);
601 602
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 90c4706..e3bd393 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -75,6 +75,11 @@ namespace OpenSim.Region.Framework.Scenes
75 75
76 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 76 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
77 77
78 /// <summary>
79 /// What type of presence is this? User, NPC, etc.
80 /// </summary>
81 public PresenceType PresenceType { get; private set; }
82
78// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); 83// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes();
79 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); 84 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags));
80 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); 85 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f);
@@ -715,8 +720,9 @@ namespace OpenSim.Region.Framework.Scenes
715 m_animator = new ScenePresenceAnimator(this); 720 m_animator = new ScenePresenceAnimator(this);
716 } 721 }
717 722
718 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() 723 private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, PresenceType type) : this()
719 { 724 {
725 PresenceType = type;
720 m_DrawDistance = world.DefaultDrawDistance; 726 m_DrawDistance = world.DefaultDrawDistance;
721 m_rootRegionHandle = reginfo.RegionHandle; 727 m_rootRegionHandle = reginfo.RegionHandle;
722 m_controllingClient = client; 728 m_controllingClient = client;
@@ -764,8 +770,8 @@ namespace OpenSim.Region.Framework.Scenes
764 SetDirectionVectors(); 770 SetDirectionVectors();
765 } 771 }
766 772
767 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) 773 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance, PresenceType type)
768 : this(client, world, reginfo) 774 : this(client, world, reginfo, type)
769 { 775 {
770 m_appearance = appearance; 776 m_appearance = appearance;
771 } 777 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
index dd2c717..35b41fb 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
@@ -207,7 +207,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
207 scene.NewUserConnection(acd1, 0, out reason); 207 scene.NewUserConnection(acd1, 0, out reason);
208 if (testclient == null) 208 if (testclient == null)
209 testclient = new TestClient(acd1, scene); 209 testclient = new TestClient(acd1, scene);
210 scene.AddNewClient(testclient); 210 scene.AddNewClient(testclient, PresenceType.User);
211 211
212 ScenePresence presence = scene.GetScenePresence(agent1); 212 ScenePresence presence = scene.GetScenePresence(agent1);
213 presence.MakeRootAgent(new Vector3(90,90,90),false); 213 presence.MakeRootAgent(new Vector3(90,90,90),false);
@@ -257,7 +257,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
257 // Adding child agent to region 1001 257 // Adding child agent to region 1001
258 string reason; 258 string reason;
259 scene2.NewUserConnection(acd1,0, out reason); 259 scene2.NewUserConnection(acd1,0, out reason);
260 scene2.AddNewClient(testclient); 260 scene2.AddNewClient(testclient, PresenceType.User);
261 261
262 ScenePresence presence = scene.GetScenePresence(agent1); 262 ScenePresence presence = scene.GetScenePresence(agent1);
263 presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true); 263 presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true);
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 15201da..c413634 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -893,7 +893,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
893 893
894 public void Start() 894 public void Start()
895 { 895 {
896 Scene.AddNewClient(this); 896 Scene.AddNewClient(this, PresenceType.User);
897 897
898 // Mimicking LLClientView which gets always set appearance from client. 898 // Mimicking LLClientView which gets always set appearance from client.
899 Scene scene = (Scene)Scene; 899 Scene scene = (Scene)Scene;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 3b7ae9d..c1da803 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -190,7 +190,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
190// } 190// }
191 191
192 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); 192 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
193 scene.AddNewClient(npcAvatar); 193 scene.AddNewClient(npcAvatar, PresenceType.Npc);
194 194
195 ScenePresence sp; 195 ScenePresence sp;
196 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) 196 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index 8d2108c..03df7ab 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -379,7 +379,7 @@ namespace OpenSim.Tests.Common
379 379
380 // Stage 2: add the new client as a child agent to the scene 380 // Stage 2: add the new client as a child agent to the scene
381 TestClient client = new TestClient(agentData, scene); 381 TestClient client = new TestClient(agentData, scene);
382 scene.AddNewClient(client); 382 scene.AddNewClient(client, PresenceType.User);
383 383
384 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. 384 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
385 ScenePresence scp = scene.GetScenePresence(agentData.AgentID); 385 ScenePresence scp = scene.GetScenePresence(agentData.AgentID);
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 7b64947..b7cefeb 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -579,7 +579,7 @@ namespace OpenSim.Tests.Common.Mock
579 579
580 // Stage 2: add the new client as a child agent to the scene 580 // Stage 2: add the new client as a child agent to the scene
581 TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene); 581 TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene);
582 TeleportTargetScene.AddNewClient(TeleportSceneClient); 582 TeleportTargetScene.AddNewClient(TeleportSceneClient, PresenceType.User);
583 } 583 }
584 584
585 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, 585 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,