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 objectsbulletsim
parent
d8f886ccdb
commit
c1a34cd8da
|
@ -72,10 +72,11 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Register the new client with the scene. The client starts off as a child agent - the later agent crossing
|
/// Register the new client with the scene. The client starts off as a child agent - the later agent crossing
|
||||||
/// will promote it to a root agent during login.
|
/// will promote it to a root agent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="client"></param
|
/// <param name="client"></param>
|
||||||
void AddNewClient(IClientAPI client);
|
/// <param name="type">The type of agent to add.</param>
|
||||||
|
void AddNewClient(IClientAPI client, PresenceType type);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove the given client from the scene.
|
/// Remove the given client from the scene.
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSimulator Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Indicate the type of ScenePresence.
|
||||||
|
/// </summary>
|
||||||
|
public enum PresenceType
|
||||||
|
{
|
||||||
|
User,
|
||||||
|
Npc
|
||||||
|
}
|
||||||
|
}
|
|
@ -692,7 +692,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
public virtual void Start()
|
public virtual void Start()
|
||||||
{
|
{
|
||||||
m_scene.AddNewClient(this);
|
m_scene.AddNewClient(this, PresenceType.User);
|
||||||
|
|
||||||
RefreshGroupMembership();
|
RefreshGroupMembership();
|
||||||
}
|
}
|
||||||
|
|
|
@ -501,10 +501,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update the attachment asset for the new sog details if they have changed.
|
/// Update the attachment asset for the new sog details if they have changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
///
|
/// <remarks>
|
||||||
/// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects,
|
/// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects,
|
||||||
/// these details are not stored on the region.
|
/// these details are not stored on the region.
|
||||||
///
|
/// </remarks>
|
||||||
/// <param name="remoteClient"></param>
|
/// <param name="remoteClient"></param>
|
||||||
/// <param name="grp"></param>
|
/// <param name="grp"></param>
|
||||||
/// <param name="itemID"></param>
|
/// <param name="itemID"></param>
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace OpenSim.Region.Examples.SimpleModule
|
||||||
for (int i = 0; i < 1; i++)
|
for (int i = 0; i < 1; i++)
|
||||||
{
|
{
|
||||||
MyNpcCharacter m_character = new MyNpcCharacter(m_scene);
|
MyNpcCharacter m_character = new MyNpcCharacter(m_scene);
|
||||||
m_scene.AddNewClient(m_character);
|
m_scene.AddNewClient(m_character, PresenceType.Npc);
|
||||||
m_scene.AgentCrossing(m_character.AgentId, Vector3.Zero, false);
|
m_scene.AgentCrossing(m_character.AgentId, Vector3.Zero, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2543,10 +2543,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
#region Add/Remove Avatar Methods
|
#region Add/Remove Avatar Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adding a New Client and Create a Presence for it.
|
/// Add a new client and create a child agent for it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="client"></param>
|
/// <param name="client"></param>
|
||||||
public override void AddNewClient(IClientAPI client)
|
/// <param name="type">The type of agent to add.</param>
|
||||||
|
public override void AddNewClient(IClientAPI client, PresenceType type)
|
||||||
{
|
{
|
||||||
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
|
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
|
||||||
bool vialogin = false;
|
bool vialogin = false;
|
||||||
|
@ -2566,7 +2567,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_clientManager.Add(client);
|
m_clientManager.Add(client);
|
||||||
SubscribeToClientEvents(client);
|
SubscribeToClientEvents(client);
|
||||||
|
|
||||||
ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance);
|
ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
|
||||||
m_eventManager.TriggerOnNewPresence(sp);
|
m_eventManager.TriggerOnNewPresence(sp);
|
||||||
|
|
||||||
sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags;
|
sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags;
|
||||||
|
@ -3149,7 +3150,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
m_eventManager.TriggerOnRemovePresence(agentID);
|
m_eventManager.TriggerOnRemovePresence(agentID);
|
||||||
|
|
||||||
if (avatar != null && (!avatar.IsChildAgent))
|
if (avatar != null && (!avatar.IsChildAgent) && avatar.PresenceType != PresenceType.Npc)
|
||||||
avatar.SaveChangedAttachments();
|
avatar.SaveChangedAttachments();
|
||||||
|
|
||||||
ForEachClient(
|
ForEachClient(
|
||||||
|
|
|
@ -175,7 +175,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
#region Add/Remove Agent/Avatar
|
#region Add/Remove Agent/Avatar
|
||||||
|
|
||||||
public abstract void AddNewClient(IClientAPI client);
|
public abstract void AddNewClient(IClientAPI client, PresenceType type);
|
||||||
public abstract void RemoveClient(UUID agentID, bool closeChildAgents);
|
public abstract void RemoveClient(UUID agentID, bool closeChildAgents);
|
||||||
|
|
||||||
public bool TryGetScenePresence(UUID agentID, out object scenePresence)
|
public bool TryGetScenePresence(UUID agentID, out object scenePresence)
|
||||||
|
|
|
@ -590,12 +590,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance)
|
protected internal ScenePresence CreateAndAddChildScenePresence(
|
||||||
|
IClientAPI client, AvatarAppearance appearance, PresenceType type)
|
||||||
{
|
{
|
||||||
ScenePresence newAvatar = null;
|
ScenePresence newAvatar = null;
|
||||||
|
|
||||||
// ScenePresence always defaults to child agent
|
// ScenePresence always defaults to child agent
|
||||||
newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance);
|
newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance, type);
|
||||||
|
|
||||||
AddScenePresence(newAvatar);
|
AddScenePresence(newAvatar);
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// What type of presence is this? User, NPC, etc.
|
||||||
|
/// </summary>
|
||||||
|
public PresenceType PresenceType { get; private set; }
|
||||||
|
|
||||||
// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes();
|
// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes();
|
||||||
private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags));
|
private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags));
|
||||||
private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f);
|
private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f);
|
||||||
|
@ -715,8 +720,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_animator = new ScenePresenceAnimator(this);
|
m_animator = new ScenePresenceAnimator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this()
|
private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, PresenceType type) : this()
|
||||||
{
|
{
|
||||||
|
PresenceType = type;
|
||||||
m_DrawDistance = world.DefaultDrawDistance;
|
m_DrawDistance = world.DefaultDrawDistance;
|
||||||
m_rootRegionHandle = reginfo.RegionHandle;
|
m_rootRegionHandle = reginfo.RegionHandle;
|
||||||
m_controllingClient = client;
|
m_controllingClient = client;
|
||||||
|
@ -764,8 +770,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
SetDirectionVectors();
|
SetDirectionVectors();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
|
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance, PresenceType type)
|
||||||
: this(client, world, reginfo)
|
: this(client, world, reginfo, type)
|
||||||
{
|
{
|
||||||
m_appearance = appearance;
|
m_appearance = appearance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
scene.NewUserConnection(acd1, 0, out reason);
|
scene.NewUserConnection(acd1, 0, out reason);
|
||||||
if (testclient == null)
|
if (testclient == null)
|
||||||
testclient = new TestClient(acd1, scene);
|
testclient = new TestClient(acd1, scene);
|
||||||
scene.AddNewClient(testclient);
|
scene.AddNewClient(testclient, PresenceType.User);
|
||||||
|
|
||||||
ScenePresence presence = scene.GetScenePresence(agent1);
|
ScenePresence presence = scene.GetScenePresence(agent1);
|
||||||
presence.MakeRootAgent(new Vector3(90,90,90),false);
|
presence.MakeRootAgent(new Vector3(90,90,90),false);
|
||||||
|
@ -257,7 +257,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
// Adding child agent to region 1001
|
// Adding child agent to region 1001
|
||||||
string reason;
|
string reason;
|
||||||
scene2.NewUserConnection(acd1,0, out reason);
|
scene2.NewUserConnection(acd1,0, out reason);
|
||||||
scene2.AddNewClient(testclient);
|
scene2.AddNewClient(testclient, PresenceType.User);
|
||||||
|
|
||||||
ScenePresence presence = scene.GetScenePresence(agent1);
|
ScenePresence presence = scene.GetScenePresence(agent1);
|
||||||
presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true);
|
presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true);
|
||||||
|
|
|
@ -893,7 +893,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
Scene.AddNewClient(this);
|
Scene.AddNewClient(this, PresenceType.User);
|
||||||
|
|
||||||
// Mimicking LLClientView which gets always set appearance from client.
|
// Mimicking LLClientView which gets always set appearance from client.
|
||||||
Scene scene = (Scene)Scene;
|
Scene scene = (Scene)Scene;
|
||||||
|
|
|
@ -190,7 +190,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
// }
|
// }
|
||||||
|
|
||||||
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
|
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
|
||||||
scene.AddNewClient(npcAvatar);
|
scene.AddNewClient(npcAvatar, PresenceType.Npc);
|
||||||
|
|
||||||
ScenePresence sp;
|
ScenePresence sp;
|
||||||
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
|
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
|
||||||
|
|
|
@ -379,7 +379,7 @@ namespace OpenSim.Tests.Common
|
||||||
|
|
||||||
// Stage 2: add the new client as a child agent to the scene
|
// Stage 2: add the new client as a child agent to the scene
|
||||||
TestClient client = new TestClient(agentData, scene);
|
TestClient client = new TestClient(agentData, scene);
|
||||||
scene.AddNewClient(client);
|
scene.AddNewClient(client, PresenceType.User);
|
||||||
|
|
||||||
// Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
|
// Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
|
||||||
ScenePresence scp = scene.GetScenePresence(agentData.AgentID);
|
ScenePresence scp = scene.GetScenePresence(agentData.AgentID);
|
||||||
|
|
|
@ -579,7 +579,7 @@ namespace OpenSim.Tests.Common.Mock
|
||||||
|
|
||||||
// Stage 2: add the new client as a child agent to the scene
|
// Stage 2: add the new client as a child agent to the scene
|
||||||
TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene);
|
TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene);
|
||||||
TeleportTargetScene.AddNewClient(TeleportSceneClient);
|
TeleportTargetScene.AddNewClient(TeleportSceneClient, PresenceType.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
|
public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
|
||||||
|
|
Loading…
Reference in New Issue