Merge commit '0c041ce12f393367e2754e88d9b8dad5e45f88c4' into bigmerge

Conflicts:
	OpenSim/Region/Framework/Scenes/ScenePresence.cs
avinationmerge
Melanie 2011-10-25 02:26:56 +01:00
commit e2de57ca29
11 changed files with 74 additions and 15 deletions

View File

@ -94,6 +94,15 @@ namespace OpenSim.Region.Framework.Interfaces
/// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
bool Say(UUID agentID, Scene scene, string text);
/// <summary>
/// Sit the NPC.
/// </summary>
/// <param name="agentID"></param>
/// <param name="partID"></param>
/// <param name="scene"></param>
/// <returns>true if the sit succeeded, false if not</returns>
bool Sit(UUID agentID, UUID partID, Scene scene);
/// <summary>
/// Delete an NPC.
/// </summary>

View File

@ -493,8 +493,8 @@ namespace OpenSim.Region.Framework.Scenes
{
foreach (ScenePresence av in m_linkedAvatars)
{
SceneObjectPart p;
if (m_parts.TryGetValue(av.LinkedPrim, out p))
SceneObjectPart p = m_scene.GetSceneObjectPart(av.ParentID);
if (m_parts.TryGetValue(p.UUID, out p))
{
Vector3 offset = p.GetWorldPosition() - av.ParentPosition;
av.AbsolutePosition += offset;

View File

@ -776,7 +776,7 @@ namespace OpenSim.Region.Framework.Scenes
List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
foreach (ScenePresence av in avs)
{
if (av.LinkedPrim == m_uuid)
if (av.ParentID == m_localId)
{
Vector3 offset = (m_offsetPosition - oldpos);
av.AbsolutePosition += offset;
@ -1260,14 +1260,12 @@ namespace OpenSim.Region.Framework.Scenes
set { m_occupied = value; }
}
public UUID SitTargetAvatar
{
get { return m_sitTargetAvatar; }
set { m_sitTargetAvatar = value; }
}
public virtual UUID RegionID
{
get

View File

@ -671,19 +671,12 @@ namespace OpenSim.Region.Framework.Scenes
private uint m_parentID;
private UUID m_linkedPrim;
public uint ParentID
{
get { return m_parentID; }
set { m_parentID = value; }
}
public UUID LinkedPrim
{
get { return m_linkedPrim; }
set { m_linkedPrim = value; }
}
public float Health
{
@ -2056,7 +2049,6 @@ namespace OpenSim.Region.Framework.Scenes
m_parentPosition = Vector3.Zero;
m_parentID = 0;
m_linkedPrim = UUID.Zero;
m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f);
SendAvatarDataToAllAgents();
m_requestedSitTargetID = 0;
@ -2513,7 +2505,6 @@ namespace OpenSim.Region.Framework.Scenes
}
*/
public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)
{
if (!String.IsNullOrEmpty(m_nextSitAnimation))
@ -2616,7 +2607,6 @@ namespace OpenSim.Region.Framework.Scenes
m_parentID = m_requestedSitTargetID;
}
m_linkedPrim = part.UUID;
if (part.GetAvatarOnSitTarget() != UUID)
{
m_offsetRotation = m_offsetRotation / part.RotationOffset;

View File

@ -199,6 +199,24 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return false;
}
public bool Sit(UUID agentID, UUID partID, Scene scene)
{
lock (m_avatars)
{
if (m_avatars.ContainsKey(agentID))
{
ScenePresence sp;
scene.TryGetScenePresence(agentID, out sp);
sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero);
sp.HandleAgentSit(m_avatars[agentID], agentID);
return true;
}
}
return false;
}
public bool DeleteNPC(UUID agentID, Scene scene)
{
lock (m_avatars)

View File

@ -229,5 +229,29 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on second move");
Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
}
[Test]
public void TestSit()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
Vector3 startPos = new Vector3(128, 128, 30);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance);
ScenePresence npc = scene.GetScenePresence(npcId);
SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
// We must have a non Vector3.Zero sit target position otherwise part.SitTargetAvatar doesn't get set!
part.SitTargetPosition = new Vector3(0, 0, 1);
npcModule.Sit(npc.UUID, part.UUID, scene);
// Assertions?
Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId));
Assert.That(npc.ParentID, Is.EqualTo(part.LocalId));
}
}
}

View File

@ -687,6 +687,7 @@ namespace OpenSim.Region.Physics.OdePlugin
/// <param name="g2">another geometry or space</param>
private void near(IntPtr space, IntPtr g1, IntPtr g2)
{
// m_log.DebugFormat("[PHYSICS]: Colliding {0} and {1} in {2}", g1, g2, space);
// no lock here! It's invoked from within Simulate(), which is thread-locked
// Test if we're colliding a geom with a space.

View File

@ -2359,6 +2359,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
public void osNpcSit(LSL_Key npc, LSL_Key target, int options)
{
CheckThreatLevel(ThreatLevel.High, "osNpcSit");
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
module.Sit(new UUID(npc.m_string), new UUID(target.m_string), World);
}
}
public void osNpcRemove(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.High, "osNpcRemove");

View File

@ -178,6 +178,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void osNpcSetRot(LSL_Key npc, rotation rot);
void osNpcStopMoveToTarget(LSL_Key npc);
void osNpcSay(key npc, string message);
void osNpcSit(key npc, key target, int options);
void osNpcRemove(key npc);
LSL_Key osOwnerSaveAppearance(string notecard);

View File

@ -603,6 +603,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int OS_NPC_NO_FLY = 1;
public const int OS_NPC_LAND_AT_TARGET = 2;
public const int OS_NPC_SIT_IMMEDIATE = 0;
public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED";
public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED";

View File

@ -528,6 +528,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osNpcSay(npc, message);
}
public void osNpcSit(LSL_Key npc, LSL_Key target, int options)
{
m_OSSL_Functions.osNpcSit(npc, target, options);
}
public void osNpcRemove(key npc)
{
m_OSSL_Functions.osNpcRemove(npc);