From d92069fb8b0a4f1ca51a24599ae308458c424e19 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Thu, 13 Jan 2011 04:44:04 +0000 Subject: Add llLookAt() kinetic. Reduce StandUp +x offset to 0.3M. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- .../Shared/Api/Implementation/LSL_Api.cs | 24 +++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b8ad3ca..927f78d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1866,7 +1866,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion partIRot = Quaternion.Inverse(partRot); Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av - Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av + Vector3 avStandUp = new Vector3(0.3f, 0f, 0f) * avatarRot; // 0.3M infront of av if (m_physicsActor == null) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 47492ea..805b344 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3023,9 +3023,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); */ - // Send the target vector to RotLookAt method inside a 'rotation', the .w -99.9 value indicates it is really a LookAt. - Quaternion q = new Quaternion((float)target.x, (float)target.y, (float)target.z, -99.9f); - m_host.RotLookAt(q, (float)strength, (float)damping); + if (m_host.PhysActor != null && !m_host.PhysActor.IsPhysical) + { + // Part is non-phys, convert this to a llSetRot() + Vector3 tgt = new Vector3((float)target.x, (float)target.y, (float)target.z); + Vector3 dir = tgt - m_host.GroupPosition; + dir.Normalize(); + float tzrot = (float)Math.Atan2(dir.Y, dir.X); + float txy = (float)Math.Sqrt((dir.X * dir.X) + (dir.Y * dir.Y)); + float terot = (float)Math.Atan2(-dir.Z, txy); + LSL_Vector az = new LSL_Vector(0.0f, 0.0f, tzrot); + LSL_Vector ae = new LSL_Vector(0.0f, terot, 0.0f); + LSL_Types.Quaternion spin = llEuler2Rot(az); + LSL_Types.Quaternion rot = llEuler2Rot(ae) * spin; + llSetRot(rot); + } + else + { + // Physical, send the target vector to RotLookAt method inside a 'rotation', the .w -99.9 value indicates it is really a LookAt. + Quaternion q = new Quaternion((float)target.x, (float)target.y, (float)target.z, -99.9f); + m_host.RotLookAt(q, (float)strength, (float)damping); + } } -- cgit v1.1 From 69666be28c5700b94be54d6165c9f59d681a4f4f Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 13 Jan 2011 16:05:17 +0100 Subject: Implement kicking, freezing and unfreezing users in the same sim via profile god buttons. --- .../Region/CoreModules/Avatar/Gods/GodsModule.cs | 175 ++++++++++++++------- 1 file changed, 117 insertions(+), 58 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index 5ec64d5..9fd3318 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs @@ -31,16 +31,40 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; +using System; +using System.Reflection; +using System.Collections; +using System.Collections.Specialized; +using System.Reflection; +using System.IO; +using System.Web; +using System.Xml; +using log4net; +using Mono.Addins; +using OpenMetaverse.Messages.Linden; +using OpenMetaverse.StructuredData; +using OpenSim.Framework.Capabilities; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using Caps = OpenSim.Framework.Capabilities.Caps; +using OSDArray = OpenMetaverse.StructuredData.OSDArray; +using OSDMap = OpenMetaverse.StructuredData.OSDMap; namespace OpenSim.Region.CoreModules.Avatar.Gods { public class GodsModule : IRegionModule, IGodsModule { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// Special UUID for actions that apply to all agents private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); protected Scene m_scene; protected IDialogModule m_dialogModule; + + protected Dictionary m_capsDict = + new Dictionary(); public void Initialise(Scene scene, IConfigSource source) { @@ -48,6 +72,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods m_dialogModule = m_scene.RequestModuleInterface(); m_scene.RegisterModuleInterface(this); m_scene.EventManager.OnNewClient += SubscribeToClientEvents; + m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; + m_scene.EventManager.OnClientClosed += OnClientClosed; } public void PostInitialise() {} @@ -67,6 +93,50 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods client.OnRequestGodlikePowers -= RequestGodlikePowers; } + private void OnClientClosed(UUID agentID, Scene scene) + { + m_capsDict.Remove(agentID); + } + + private void OnRegisterCaps(UUID agentID, Caps caps) + { + string uri = "/CAPS/" + UUID.Random(); + m_capsDict[agentID] = uri; + + caps.RegisterHandler("UntrustedSimulatorMessage", + new RestStreamHandler("POST", uri, + HandleUntrustedSimulatorMessage)); + } + + private string HandleUntrustedSimulatorMessage(string request, + string path, string param, OSHttpRequest httpRequest, + OSHttpResponse httpResponse) + { + OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(request); + + string message = osd["message"].AsString(); + + if (message == "GodKickUser") + { + OSDMap body = (OSDMap)osd["body"]; + OSDArray userInfo = (OSDArray)body["UserInfo"]; + OSDMap userData = (OSDMap)userInfo[0]; + + UUID agentID = userData["AgentID"].AsUUID(); + UUID godID = userData["GodID"].AsUUID(); + UUID godSessionID = userData["GodSessionID"].AsUUID(); + uint kickFlags = userData["KickFlags"].AsUInteger(); + string reason = userData["Reason"].AsString(); + + KickUser(godID, godSessionID, agentID, kickFlags, Util.StringToBytes1024(reason)); + } + else + { + m_log.ErrorFormat("[GOD]: Unhandled UntrustedSimulatorMessage: {0}", message); + } + return String.Empty; + } + public void RequestGodlikePowers( UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) { @@ -115,71 +185,60 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods /// The message to send to the user after it's been turned into a field public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason) { - UUID kickUserID = ALL_AGENTS; - + if (!m_scene.Permissions.IsGod(godID)) + return; + + ScenePresence god = m_scene.GetScenePresence(godID); + if (god == null || god.ControllingClient.SessionId != sessionID) + return; + ScenePresence sp = m_scene.GetScenePresence(agentID); - if (sp != null || agentID == kickUserID) + switch (kickflags) { - if (m_scene.Permissions.IsGod(godID)) + case 0: + if (sp != null) { - if (kickflags == 0) - { - if (agentID == kickUserID) - { - string reasonStr = Utils.BytesToString(reason); - - m_scene.ForEachClient( - delegate(IClientAPI controller) - { - if (controller.AgentId != godID) - controller.Kick(reasonStr); - } - ); - - // This is a bit crude. It seems the client will be null before it actually stops the thread - // The thread will kill itself eventually :/ - // Is there another way to make sure *all* clients get this 'inter region' message? - m_scene.ForEachScenePresence( - delegate(ScenePresence p) - { - if (p.UUID != godID && !p.IsChildAgent) - { - // Possibly this should really be p.Close() though that method doesn't send a close - // to the client - p.ControllingClient.Close(); - } - } - ); - } - else - { - m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent); - - sp.ControllingClient.Kick(Utils.BytesToString(reason)); - sp.ControllingClient.Close(); - } - } - - if (kickflags == 1) - { - sp.AllowMovement = false; - m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); - m_dialogModule.SendAlertToUser(godID, "User Frozen"); - } - - if (kickflags == 2) - { - sp.AllowMovement = true; - m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); - m_dialogModule.SendAlertToUser(godID, "User Unfrozen"); - } + KickPresence(sp, Utils.BytesToString(reason)); } - else + else if (agentID == ALL_AGENTS) + { + m_scene.ForEachScenePresence( + delegate(ScenePresence p) + { + if (p.UUID != godID && (!m_scene.Permissions.IsGod(p.UUID))) + KickPresence(p, Utils.BytesToString(reason)); + } + ); + } + break; + case 1: + if (sp != null) { - m_dialogModule.SendAlertToUser(godID, "Kick request denied"); + sp.AllowMovement = false; + m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); + m_dialogModule.SendAlertToUser(godID, "User Frozen"); } + break; + case 2: + if (sp != null) + { + sp.AllowMovement = true; + m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); + m_dialogModule.SendAlertToUser(godID, "User Unfrozen"); + } + break; + default: + break; } } + + private void KickPresence(ScenePresence sp, string reason) + { + if (sp.IsChildAgent) + return; + sp.ControllingClient.Kick(reason); + sp.Scene.IncomingCloseAgent(sp.UUID); + } } -} \ No newline at end of file +} -- cgit v1.1