Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

0.7.4.1
Justin Clark-Casey (justincc) 2012-04-23 22:54:11 +01:00
commit b798b32b19
6 changed files with 123 additions and 61 deletions

View File

@ -51,10 +51,12 @@ namespace OpenSim.Framework
protected object m_senderObject; protected object m_senderObject;
protected ChatTypeEnum m_type; protected ChatTypeEnum m_type;
protected UUID m_fromID; protected UUID m_fromID;
protected UUID m_toID;
public OSChatMessage() public OSChatMessage()
{ {
m_position = new Vector3(); m_position = new Vector3();
m_toID = UUID.Zero;
} }
/// <summary> /// <summary>
@ -102,6 +104,15 @@ namespace OpenSim.Framework
set { m_from = value; } set { m_from = value; }
} }
/// <summary>
/// The name of the sender (needed for scripts)
/// </summary>
public string To
{
get { return m_from; }
set { m_from = value; }
}
#region IEventArgs Members #region IEventArgs Members
/// TODO: Sender and SenderObject should just be Sender and of /// TODO: Sender and SenderObject should just be Sender and of
@ -131,6 +142,15 @@ namespace OpenSim.Framework
set { m_fromID = value; } set { m_fromID = value; }
} }
/// <summary>
/// The single recipient or all if not set.
/// </summary>
public UUID TargetUUID
{
get { return m_toID; }
set { m_toID = value; }
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View File

@ -186,6 +186,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
{ {
string fromName = c.From; string fromName = c.From;
UUID fromID = UUID.Zero; UUID fromID = UUID.Zero;
UUID targetID = c.TargetUUID;
string message = c.Message; string message = c.Message;
IScene scene = c.Scene; IScene scene = c.Scene;
Vector3 fromPos = c.Position; Vector3 fromPos = c.Position;
@ -221,23 +222,37 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
message = message.Substring(0, 1000); message = message.Substring(0, 1000);
// m_log.DebugFormat( // m_log.DebugFormat(
// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}",
// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID);
HashSet<UUID> receiverIDs = new HashSet<UUID>(); HashSet<UUID> receiverIDs = new HashSet<UUID>();
foreach (Scene s in m_scenes) foreach (Scene s in m_scenes)
{
if (targetID == UUID.Zero)
{ {
// This should use ForEachClient, but clients don't have a position. // This should use ForEachClient, but clients don't have a position.
// If camera is moved into client, then camera position can be used // If camera is moved into client, then camera position can be used
s.ForEachRootScenePresence( s.ForEachRootScenePresence(
delegate(ScenePresence presence) delegate(ScenePresence presence)
{ {
if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType)) if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, false))
receiverIDs.Add(presence.UUID); receiverIDs.Add(presence.UUID);
} }
); );
} }
else
{
// This is a send to a specific client eg from llRegionSayTo
// no need to check distance etc, jand send is as say
ScenePresence presence = s.GetScenePresence(targetID);
if (presence != null && !presence.IsChildAgent)
{
if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, ChatTypeEnum.Say, message, sourceType, true))
receiverIDs.Add(presence.UUID);
}
}
}
(scene as Scene).EventManager.TriggerOnChatToClients( (scene as Scene).EventManager.TriggerOnChatToClients(
fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
@ -315,7 +330,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
/// precondition</returns> /// precondition</returns>
protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
UUID fromAgentID, string fromName, ChatTypeEnum type, UUID fromAgentID, string fromName, ChatTypeEnum type,
string message, ChatSourceType src) string message, ChatSourceType src, bool ignoreDistance)
{ {
// don't send stuff to child agents // don't send stuff to child agents
if (presence.IsChildAgent) return false; if (presence.IsChildAgent) return false;
@ -327,12 +342,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);
if (!ignoreDistance)
{
if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
type == ChatTypeEnum.Say && dis > m_saydistance || type == ChatTypeEnum.Say && dis > m_saydistance ||
type == ChatTypeEnum.Shout && dis > m_shoutdistance) type == ChatTypeEnum.Shout && dis > m_shoutdistance)
{ {
return false; return false;
} }
}
// TODO: should change so the message is sent through the avatar rather than direct to the ClientView // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,

View File

@ -308,24 +308,29 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
/// <param name='msg'> /// <param name='msg'>
/// Message. /// Message.
/// </param> /// </param>
public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg)
{ {
error = null;
// Is id an avatar? // Is id an avatar?
ScenePresence sp = m_scene.GetScenePresence(target); ScenePresence sp = m_scene.GetScenePresence(target);
if (sp != null) if (sp != null)
{ {
// Send message to avatar // ignore if a child agent this is restricted to inside one region
if (sp.IsChildAgent)
return;
// Send message to the avatar.
// Channel zero only goes to the avatar
// non zero channel messages only go to the attachments
if (channel == 0) if (channel == 0)
{ {
m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false); m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false);
} }
else
{
List<SceneObjectGroup> attachments = sp.GetAttachments(); List<SceneObjectGroup> attachments = sp.GetAttachments();
if (attachments.Count == 0) if (attachments.Count == 0)
return true; return;
// Get uuid of attachments // Get uuid of attachments
List<UUID> targets = new List<UUID>(); List<UUID> targets = new List<UUID>();
@ -347,17 +352,12 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
if (targets.Contains(li.GetHostID())) if (targets.Contains(li.GetHostID()))
QueueMessage(new ListenerInfo(li, name, id, msg)); QueueMessage(new ListenerInfo(li, name, id, msg));
} }
return true;
} }
// Need to toss an error here return;
if (channel == 0)
{
error = "Cannot use llRegionSayTo to message objects on channel 0";
return false;
} }
// No avatar found so look for an object
foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg))
{ {
// Dont process if this message is from yourself! // Dont process if this message is from yourself!
@ -375,7 +375,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
} }
} }
return true; return;
} }
protected void QueueMessage(ListenerInfo li) protected void QueueMessage(ListenerInfo li)

View File

@ -103,7 +103,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name='msg'> /// <param name='msg'>
/// Message. /// Message.
/// </param> /// </param>
bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error); void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg);
/// <summary> /// <summary>
/// Are there any listen events ready to be dispatched? /// Are there any listen events ready to be dispatched?

View File

@ -38,8 +38,9 @@ namespace OpenSim.Region.Framework.Scenes
{ {
public partial class Scene public partial class Scene
{ {
protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
UUID fromID, bool fromAgent, bool broadcast) UUID fromID, UUID targetID, bool fromAgent, bool broadcast)
{ {
OSChatMessage args = new OSChatMessage(); OSChatMessage args = new OSChatMessage();
@ -63,7 +64,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
args.From = fromName; args.From = fromName;
//args. args.TargetUUID = targetID;
if (broadcast) if (broadcast)
EventManager.TriggerOnChatBroadcast(this, args); EventManager.TriggerOnChatBroadcast(this, args);
@ -71,6 +72,12 @@ namespace OpenSim.Region.Framework.Scenes
EventManager.TriggerOnChatFromWorld(this, args); EventManager.TriggerOnChatFromWorld(this, args);
} }
protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
UUID fromID, bool fromAgent, bool broadcast)
{
SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast);
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -108,6 +115,19 @@ namespace OpenSim.Region.Framework.Scenes
{ {
SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true);
} }
/// <summary>
///
/// </summary>
/// <param name="message"></param>
/// <param name="type"></param>
/// <param name="fromPos"></param>
/// <param name="fromName"></param>
/// <param name="fromAgentID"></param>
/// <param name="targetID"></param>
public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent)
{
SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false);
}
/// <summary> /// <summary>
/// Invoked when the client requests a prim. /// Invoked when the client requests a prim.

View File

@ -839,13 +839,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
if (channel == ScriptBaseClass.DEBUG_CHANNEL)
{
return;
}
UUID TargetID; UUID TargetID;
UUID.TryParse(target, out TargetID); UUID.TryParse(target, out TargetID);
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
if (wComm != null) if (wComm != null)
if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg);
LSLError(error);
} }
public LSL_Integer llListen(int channelID, string name, string ID, string msg) public LSL_Integer llListen(int channelID, string name, string ID, string msg)