Following on from 476a7d3e
(which wasn't enough), make chat across regions on different simulators work.
Also resolves an issue of multiple chatting if the originating simulators had more than one region and they were neighboursuser_profiles
parent
1f17ef6d3c
commit
c4d9a23f26
|
@ -50,7 +50,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||||
private int m_saydistance = 20;
|
private int m_saydistance = 20;
|
||||||
private int m_shoutdistance = 100;
|
private int m_shoutdistance = 100;
|
||||||
private int m_whisperdistance = 10;
|
private int m_whisperdistance = 10;
|
||||||
private List<Scene> m_scenes = new List<Scene>();
|
|
||||||
|
|
||||||
internal object m_syncy = new object();
|
internal object m_syncy = new object();
|
||||||
|
|
||||||
|
@ -82,18 +81,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||||
|
|
||||||
public virtual void AddRegion(Scene scene)
|
public virtual void AddRegion(Scene scene)
|
||||||
{
|
{
|
||||||
if (!m_enabled) return;
|
if (!m_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
lock (m_syncy)
|
scene.EventManager.OnNewClient += OnNewClient;
|
||||||
{
|
scene.EventManager.OnChatFromWorld += OnChatFromWorld;
|
||||||
if (!m_scenes.Contains(scene))
|
scene.EventManager.OnChatBroadcast += OnChatBroadcast;
|
||||||
{
|
|
||||||
m_scenes.Add(scene);
|
|
||||||
scene.EventManager.OnNewClient += OnNewClient;
|
|
||||||
scene.EventManager.OnChatFromWorld += OnChatFromWorld;
|
|
||||||
scene.EventManager.OnChatBroadcast += OnChatBroadcast;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName,
|
m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName,
|
||||||
m_whisperdistance, m_saydistance, m_shoutdistance);
|
m_whisperdistance, m_saydistance, m_shoutdistance);
|
||||||
|
@ -105,18 +98,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||||
|
|
||||||
public virtual void RemoveRegion(Scene scene)
|
public virtual void RemoveRegion(Scene scene)
|
||||||
{
|
{
|
||||||
if (!m_enabled) return;
|
if (!m_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
lock (m_syncy)
|
scene.EventManager.OnNewClient -= OnNewClient;
|
||||||
{
|
scene.EventManager.OnChatFromWorld -= OnChatFromWorld;
|
||||||
if (m_scenes.Contains(scene))
|
scene.EventManager.OnChatBroadcast -= OnChatBroadcast;
|
||||||
{
|
|
||||||
scene.EventManager.OnNewClient -= OnNewClient;
|
|
||||||
scene.EventManager.OnChatFromWorld -= OnChatFromWorld;
|
|
||||||
scene.EventManager.OnChatBroadcast -= OnChatBroadcast;
|
|
||||||
m_scenes.Remove(scene);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Close()
|
public virtual void Close()
|
||||||
|
@ -191,7 +178,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||||
UUID ownerID = UUID.Zero;
|
UUID ownerID = UUID.Zero;
|
||||||
UUID targetID = c.TargetUUID;
|
UUID targetID = c.TargetUUID;
|
||||||
string message = c.Message;
|
string message = c.Message;
|
||||||
IScene scene = c.Scene;
|
Scene scene = (Scene)c.Scene;
|
||||||
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);
|
||||||
|
@ -201,13 +188,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||||
switch (sourceType)
|
switch (sourceType)
|
||||||
{
|
{
|
||||||
case ChatSourceType.Agent:
|
case ChatSourceType.Agent:
|
||||||
if (!(scene is Scene))
|
ScenePresence avatar = scene.GetScenePresence(c.Sender.AgentId);
|
||||||
{
|
|
||||||
m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
|
|
||||||
scene.RegionInfo.RegionName, c.Sender.AgentId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
|
|
||||||
fromPos = avatar.AbsolutePosition;
|
fromPos = avatar.AbsolutePosition;
|
||||||
fromName = avatar.Name;
|
fromName = avatar.Name;
|
||||||
fromID = c.Sender.AgentId;
|
fromID = c.Sender.AgentId;
|
||||||
|
@ -234,36 +215,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||||
|
|
||||||
HashSet<UUID> receiverIDs = new HashSet<UUID>();
|
HashSet<UUID> receiverIDs = new HashSet<UUID>();
|
||||||
|
|
||||||
foreach (Scene s in m_scenes)
|
if (targetID == UUID.Zero)
|
||||||
{
|
{
|
||||||
if (targetID == UUID.Zero)
|
// This should use ForEachClient, but clients don't have a position.
|
||||||
{
|
// If camera is moved into client, then camera position can be used
|
||||||
// This should use ForEachClient, but clients don't have a position.
|
scene.ForEachScenePresence(
|
||||||
// If camera is moved into client, then camera position can be used
|
delegate(ScenePresence presence)
|
||||||
s.ForEachScenePresence(
|
|
||||||
delegate(ScenePresence presence)
|
|
||||||
{
|
|
||||||
if (TrySendChatMessage(
|
|
||||||
presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false))
|
|
||||||
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(
|
if (TrySendChatMessage(
|
||||||
presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true))
|
presence, fromPos, regionPos, fromID, ownerID, 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 = scene.GetScenePresence(targetID);
|
||||||
|
if (presence != null && !presence.IsChildAgent)
|
||||||
|
{
|
||||||
|
if (TrySendChatMessage(
|
||||||
|
presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true))
|
||||||
|
receiverIDs.Add(presence.UUID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(scene as Scene).EventManager.TriggerOnChatToClients(
|
scene.EventManager.TriggerOnChatToClients(
|
||||||
fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
|
fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,9 +326,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||||
UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type,
|
UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type,
|
||||||
string message, ChatSourceType src, bool ignoreDistance)
|
string message, ChatSourceType src, bool ignoreDistance)
|
||||||
{
|
{
|
||||||
// don't send stuff to child agents
|
|
||||||
if (presence.IsChildAgent) return false;
|
|
||||||
|
|
||||||
Vector3 fromRegionPos = fromPos + regionPos;
|
Vector3 fromRegionPos = fromPos + regionPos;
|
||||||
Vector3 toRegionPos = presence.AbsolutePosition +
|
Vector3 toRegionPos = presence.AbsolutePosition +
|
||||||
new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize,
|
new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize,
|
||||||
|
|
Loading…
Reference in New Issue