Fix llRegionSayTo the right way

avinationmerge
Melanie 2012-06-28 21:23:42 +02:00
parent 8a03c153d5
commit c87f0ac226
4 changed files with 37 additions and 11 deletions

View File

@ -51,6 +51,7 @@ 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_destination = UUID.Zero;
public OSChatMessage() public OSChatMessage()
{ {
@ -131,6 +132,12 @@ namespace OpenSim.Framework
set { m_fromID = value; } set { m_fromID = value; }
} }
public UUID Destination
{
get { return m_destination; }
set { m_destination = value; }
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View File

@ -199,6 +199,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
UUID fromID = UUID.Zero; UUID fromID = UUID.Zero;
string message = c.Message; string message = c.Message;
IScene scene = c.Scene; IScene scene = c.Scene;
UUID destination = c.Destination;
Vector3 fromPos = c.Position; Vector3 fromPos = c.Position;
Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
@ -222,6 +223,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
{ {
fromNamePrefix = m_adminPrefix; fromNamePrefix = m_adminPrefix;
} }
destination = UUID.Zero; // Avatars cant "SayTo"
break; break;
case ChatSourceType.Object: case ChatSourceType.Object:
@ -244,9 +246,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
{ {
// 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
// MT: No, it can't, as chat is heard from the avatar position, not
// the camera position.
s.ForEachRootScenePresence( s.ForEachRootScenePresence(
delegate(ScenePresence presence) delegate(ScenePresence presence)
{ {
if (destination != UUID.Zero && presence.UUID != destination)
return;
ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
if (Presencecheck != null) if (Presencecheck != null)
{ {
@ -346,8 +352,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
UUID fromAgentID, string fromName, ChatTypeEnum type, UUID fromAgentID, string fromName, ChatTypeEnum type,
string message, ChatSourceType src) string message, ChatSourceType src)
{ {
// don't send stuff to child agents // don't send llRegionSay to child agents. Send normal chat because you
if (presence.IsChildAgent) return false; // can't talk across sim borders if it's not done
if (type == ChatTypeEnum.Broadcast && presence.IsChildAgent) return false;
Vector3 fromRegionPos = fromPos + regionPos; Vector3 fromRegionPos = fromPos + regionPos;
Vector3 toRegionPos = presence.AbsolutePosition + Vector3 toRegionPos = presence.AbsolutePosition +

View File

@ -90,6 +90,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
// private static readonly ILog m_log = // private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private const int DEBUG_CHANNEL = 2147483647;
private ListenerManager m_listenerManager; private ListenerManager m_listenerManager;
private Queue m_pending; private Queue m_pending;
private Queue m_pendingQ; private Queue m_pendingQ;
@ -311,6 +313,10 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error)
{ {
error = null; error = null;
if (channel == DEBUG_CHANNEL)
return true;
// Is id an avatar? // Is id an avatar?
ScenePresence sp = m_scene.GetScenePresence(target); ScenePresence sp = m_scene.GetScenePresence(target);
@ -319,7 +325,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
// Send message to avatar // Send message to avatar
if (channel == 0) if (channel == 0)
{ {
m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false); // Channel 0 goes to viewer ONLY
m_scene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false, false, target);
return true;
} }
List<SceneObjectGroup> attachments = sp.GetAttachments(); List<SceneObjectGroup> attachments = sp.GetAttachments();
@ -351,12 +359,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
return true; return true;
} }
// Need to toss an error here SceneObjectPart part = m_scene.GetSceneObjectPart(target);
if (channel == 0) if (part == null) // Not even an object
{ return true; // No error
error = "Cannot use llRegionSayTo to message objects on channel 0";
return false;
}
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))
{ {

View File

@ -38,8 +38,8 @@ 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, public void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
UUID fromID, bool fromAgent, bool broadcast) UUID fromID, bool fromAgent, bool broadcast, UUID destination)
{ {
OSChatMessage args = new OSChatMessage(); OSChatMessage args = new OSChatMessage();
@ -49,6 +49,7 @@ namespace OpenSim.Region.Framework.Scenes
args.Position = fromPos; args.Position = fromPos;
args.SenderUUID = fromID; args.SenderUUID = fromID;
args.Scene = this; args.Scene = this;
args.Destination = destination;
if (fromAgent) if (fromAgent)
{ {
@ -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, fromAgent, broadcast, UUID.Zero);
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>