From 966899249327f4055c6f1492447d665eb42d09d9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 6 Jan 2012 22:59:08 +0000 Subject: Add osNpcPlayAnimation and osNpcStopAnimation which respect ownership as well --- .../Shared/Api/Implementation/OSSL_Api.cs | 44 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 10 +++++ 3 files changed, 56 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index c1a700a..efb77ae 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -888,6 +888,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarPlayAnimation"); + AvatarPlayAnimation(avatar, animation); + } + + private void AvatarPlayAnimation(string avatar, string animation) + { UUID avatarID = (UUID)avatar; m_host.AddScriptLPS(1); @@ -921,6 +926,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarStopAnimation"); + AvatarStopAnimation(avatar, animation); + } + + private void AvatarStopAnimation(string avatar, string animation) + { UUID avatarID = (UUID)avatar; m_host.AddScriptLPS(1); @@ -2332,6 +2342,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public void osNpcPlayAnimation(LSL_Key npc, string animation) + { + CheckThreatLevel(ThreatLevel.High, "osPlayAnimation"); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + UUID npcID = new UUID(npc.m_string); + if (module.IsNPC(npcID)) + { + UUID ownerID = module.GetOwner(npcID); + if (ownerID == UUID.Zero || ownerID == m_host.OwnerID) + AvatarPlayAnimation(npcID.ToString(), animation); + } + } + } + + public void osNpcStopAnimation(LSL_Key npc, string animation) + { + CheckThreatLevel(ThreatLevel.High, "osNpcStopAnimation"); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + UUID npcID = new UUID(npc.m_string); + if (module.IsNPC(npcID)) + { + UUID ownerID = module.GetOwner(npcID); + if (ownerID == UUID.Zero || ownerID == m_host.OwnerID) + AvatarStopAnimation(npcID.ToString(), animation); + } + } + } + /// /// Save the current appearance of the script owner permanently to the named notecard. /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 1380ed4..d5e085d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -185,6 +185,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osNpcSit(key npc, key target, int options); void osNpcStand(LSL_Key npc); void osNpcRemove(key npc); + public void osNpcPlayAnimation(LSL_Key npc, string animation); + public void osNpcStopAnimation(LSL_Key npc, string animation); LSL_Key osOwnerSaveAppearance(string notecard); LSL_Key osAgentSaveAppearance(key agentId, string notecard); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 6572def..a94392a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -553,6 +553,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcRemove(npc); } + public void osNpcPlayAnimation(LSL_Key npc, string animation) + { + m_OSSL_Functions.osNpcPlayAnimation(npc, animation); + } + + public void osNpcStopAnimation(LSL_Key npc, string animation) + { + m_OSSL_Functions.osNpcStopAnimation(npc, animation); + } + public LSL_Key osOwnerSaveAppearance(string notecard) { return m_OSSL_Functions.osOwnerSaveAppearance(notecard); -- cgit v1.1 From 679d155a397567765d142e793a68679957866a6f Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 6 Jan 2012 22:33:51 +0100 Subject: Fix some syntax issues --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++-- OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index efb77ae..b3477ac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2350,7 +2350,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (module != null) { UUID npcID = new UUID(npc.m_string); - if (module.IsNPC(npcID)) + if (module.IsNPC(npcID, m_host.ParentGroup.Scene)) { UUID ownerID = module.GetOwner(npcID); if (ownerID == UUID.Zero || ownerID == m_host.OwnerID) @@ -2367,7 +2367,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (module != null) { UUID npcID = new UUID(npc.m_string); - if (module.IsNPC(npcID)) + if (module.IsNPC(npcID, m_host.ParentGroup.Scene)) { UUID ownerID = module.GetOwner(npcID); if (ownerID == UUID.Zero || ownerID == m_host.OwnerID) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index d5e085d..f92f51f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -185,8 +185,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osNpcSit(key npc, key target, int options); void osNpcStand(LSL_Key npc); void osNpcRemove(key npc); - public void osNpcPlayAnimation(LSL_Key npc, string animation); - public void osNpcStopAnimation(LSL_Key npc, string animation); + void osNpcPlayAnimation(LSL_Key npc, string animation); + void osNpcStopAnimation(LSL_Key npc, string animation); LSL_Key osOwnerSaveAppearance(string notecard); LSL_Key osAgentSaveAppearance(key agentId, string notecard); -- cgit v1.1 From c5c079f6aa731ae6505299c11792f4d1d6ea3e88 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 7 Jan 2012 00:17:40 +0000 Subject: Fix bug where tapping home to stop falling would stop any avatar movement other than falling again. Addresses http://opensimulator.org/mantis/view.php?id=5839 --- .../Framework/Scenes/Animation/ScenePresenceAnimator.cs | 13 ++++++------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index eda085f..ff5f731 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -223,7 +223,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_animTickFall = 0; m_animTickJump = 0; m_jumping = false; - m_falling = true; + m_falling = false; m_jumpVelocity = 0f; actor.Selected = false; m_fallHeight = actor.Position.Z; // save latest flying height @@ -238,10 +238,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation } else if (move.Z < 0f) { - if (actor != null && actor.IsColliding) - { + if (actor != null && actor.IsColliding) return "LAND"; - } else return "HOVER_DOWN"; } @@ -260,7 +258,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation float fallElapsed = (float)(Environment.TickCount - m_animTickFall); float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; - if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true; + if (!m_jumping && (fallVelocity < -3.0f)) + m_falling = true; if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) { @@ -297,9 +296,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation return "PREJUMP"; } - if(m_jumping) + if (m_jumping) { - if ( (jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) + if ((jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) { // end jumping m_jumping = false; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 42cd4be..8ebb7a6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1274,8 +1274,8 @@ namespace OpenSim.Region.Framework.Scenes public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) { // m_log.DebugFormat( -// "[SCENE PRESENCE]: In {0} received agent update from {1}", -// Scene.RegionInfo.RegionName, remoteClient.Name); +// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", +// Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags); if (IsChildAgent) { @@ -2312,6 +2312,8 @@ namespace OpenSim.Region.Framework.Scenes /// The vector in which to move. This is relative to the rotation argument public void AddNewMovement(Vector3 vec) { +// m_log.DebugFormat("[SCENE PRESENCE]: Adding new movement {0} for {1}", vec, Name); + Vector3 direc = vec * Rotation; direc.Normalize(); -- cgit v1.1 From ba163ab05b2f05bf9a316a5f209f64992d4f9a22 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 7 Jan 2012 00:29:55 +0000 Subject: Add method doc to SPA.Falling and use automatic private get property --- .../Scenes/Animation/ScenePresenceAnimator.cs | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index ff5f731..3584cda 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -61,11 +61,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation public bool m_jumping = false; public float m_jumpVelocity = 0f; // private int m_landing = 0; - public bool Falling - { - get { return m_falling; } - } - private bool m_falling = false; + + /// + /// Is the avatar falling? + /// + public bool Falling { get; private set; } + private float m_fallHeight; /// @@ -223,7 +224,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_animTickFall = 0; m_animTickJump = 0; m_jumping = false; - m_falling = false; + Falling = false; m_jumpVelocity = 0f; actor.Selected = false; m_fallHeight = actor.Position.Z; // save latest flying height @@ -259,7 +260,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; if (!m_jumping && (fallVelocity < -3.0f)) - m_falling = true; + Falling = true; if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) { @@ -289,7 +290,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation // Start jumping, prejump m_animTickFall = 0; m_jumping = true; - m_falling = false; + Falling = false; actor.Selected = true; // borrowed for jumping flag m_animTickJump = Environment.TickCount; m_jumpVelocity = 0.35f; @@ -302,7 +303,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation { // end jumping m_jumping = false; - m_falling = false; + Falling = false; actor.Selected = false; // borrowed for jumping flag m_jumpVelocity = 0f; m_animTickFall = Environment.TickCount; @@ -329,7 +330,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (CurrentMovementAnimation == "FALLDOWN") { - m_falling = false; + Falling = false; m_animTickFall = Environment.TickCount; // TODO: SOFT_LAND support float fallHeight = m_fallHeight - actor.Position.Z; @@ -363,7 +364,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (move.X != 0f || move.Y != 0f) { m_fallHeight = actor.Position.Z; // save latest flying height - m_falling = false; + Falling = false; // Walking / crouchwalking / running if (move.Z < 0f) return "CROUCHWALK"; @@ -374,7 +375,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation } else if (!m_jumping) { - m_falling = false; + Falling = false; // Not walking if (move.Z < 0) return "CROUCH"; @@ -387,7 +388,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation } #endregion Ground Movement - m_falling = false; + Falling = false; return CurrentMovementAnimation; } -- cgit v1.1 From f4231f06283dedc4ee9e898f969700d991575558 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 7 Jan 2012 00:32:32 +0000 Subject: minor: remove mono compiler warning --- OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs index c030bca..5c50936 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs @@ -66,7 +66,7 @@ namespace OpenSim.Services.Connectors m_ServerURI = m_ServerURI.TrimEnd('/') + "/helo/"; } } - catch (UriFormatException e) + catch (UriFormatException) { m_log.WarnFormat("[HELO SERVICE]: Malformed URL {0}", serverURI); } -- cgit v1.1 From 58cb7cd084c0ccaec753d1c508ebaa4529834b24 Mon Sep 17 00:00:00 2001 From: nebadon Date: Fri, 6 Jan 2012 23:07:48 -0700 Subject: fix a typo "osNpcCreated" to "osNpcCreate" in OSSL threat level check --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b3477ac..59107de 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2085,7 +2085,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) { - CheckThreatLevel(ThreatLevel.High, "osNpcCreated"); + CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); return NpcCreate(firstname, lastname, position, notecard, false); } -- cgit v1.1 From 6f19e231b69377e312425bfae284cc8de40ce0fb Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 7 Jan 2012 12:06:21 +0100 Subject: Don't try to save a NPCs attachment states on NPC delete --- .../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 280fdc7..2142d02 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -462,6 +462,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp) { + // Saving attachments for NPCs messes them up for the real owner! + INPCModule module = m_scene.RequestModuleInterface(); + if (module != null) + { + if (module.IsNPC(sp.UUID, m_scene)) + return; + } + if (grp.HasGroupChanged || grp.ContainsScripts()) { m_log.DebugFormat( -- cgit v1.1 From 32eb7ddc37d61e5615be33a8a1adfd15445f1f33 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 7 Jan 2012 12:29:59 +0100 Subject: Fix threat level setting on osNpcPlayAnimation --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 59107de..e2a045b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2344,7 +2344,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void osNpcPlayAnimation(LSL_Key npc, string animation) { - CheckThreatLevel(ThreatLevel.High, "osPlayAnimation"); + CheckThreatLevel(ThreatLevel.High, "osNpcPlayAnimation"); INPCModule module = World.RequestModuleInterface(); if (module != null) -- cgit v1.1