Merge branch 'careminster-presence-refactor' of ssh://melanie@3dhosting.de/var/git/careminster into careminster-presence-refactor

avinationmerge
Melanie 2011-01-13 20:01:50 +00:00
commit ddb5f4e44a
4 changed files with 163 additions and 66 deletions

View File

@ -708,6 +708,11 @@ namespace OpenSim.Framework
return _lightColorR;
}
set {
if (value < 0)
_lightColorR = 0;
else if (value > 1.0f)
_lightColorR = 1.0f;
else
_lightColorR = value;
}
}
@ -717,6 +722,11 @@ namespace OpenSim.Framework
return _lightColorG;
}
set {
if (value < 0)
_lightColorG = 0;
else if (value > 1.0f)
_lightColorG = 1.0f;
else
_lightColorG = value;
}
}
@ -726,6 +736,11 @@ namespace OpenSim.Framework
return _lightColorB;
}
set {
if (value < 0)
_lightColorB = 0;
else if (value > 1.0f)
_lightColorB = 1.0f;
else
_lightColorB = value;
}
}
@ -735,6 +750,11 @@ namespace OpenSim.Framework
return _lightColorA;
}
set {
if (value < 0)
_lightColorA = 0;
else if (value > 1.0f)
_lightColorA = 1.0f;
else
_lightColorA = value;
}
}

View File

@ -31,23 +31,49 @@ 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);
/// <summary>Special UUID for actions that apply to all agents</summary>
private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb");
protected Scene m_scene;
protected IDialogModule m_dialogModule;
protected Dictionary<UUID, string> m_capsDict =
new Dictionary<UUID, string>();
public void Initialise(Scene scene, IConfigSource source)
{
m_scene = scene;
m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
m_scene.RegisterModuleInterface<IGodsModule>(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
/// <param name="reason">The message to send to the user after it's been turned into a field</param>
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);
KickPresence(sp, Utils.BytesToString(reason));
}
);
// 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?
else if (agentID == ALL_AGENTS)
{
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();
}
if (p.UUID != godID && (!m_scene.Permissions.IsGod(p.UUID)))
KickPresence(p, Utils.BytesToString(reason));
}
);
}
else
{
m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent);
sp.ControllingClient.Kick(Utils.BytesToString(reason));
sp.ControllingClient.Close();
}
}
if (kickflags == 1)
break;
case 1:
if (sp != null)
{
sp.AllowMovement = false;
m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
m_dialogModule.SendAlertToUser(godID, "User Frozen");
}
if (kickflags == 2)
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;
}
else
}
private void KickPresence(ScenePresence sp, string reason)
{
m_dialogModule.SendAlertToUser(godID, "Kick request denied");
}
}
if (sp.IsChildAgent)
return;
sp.ControllingClient.Kick(reason);
sp.Scene.IncomingCloseAgent(sp.UUID);
}
}
}

View File

@ -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)

View File

@ -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.
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);
}
}