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 neighbours0.7.4-extended
parent
0fa04289d5
commit
fa4ea2db17
|
@ -48,7 +48,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();
|
||||||
|
|
||||||
|
@ -80,18 +79,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)
|
|
||||||
{
|
|
||||||
if (!m_scenes.Contains(scene))
|
|
||||||
{
|
|
||||||
m_scenes.Add(scene);
|
|
||||||
scene.EventManager.OnNewClient += OnNewClient;
|
scene.EventManager.OnNewClient += OnNewClient;
|
||||||
scene.EventManager.OnChatFromWorld += OnChatFromWorld;
|
scene.EventManager.OnChatFromWorld += OnChatFromWorld;
|
||||||
scene.EventManager.OnChatBroadcast += OnChatBroadcast;
|
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);
|
||||||
|
@ -103,18 +96,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)
|
|
||||||
{
|
|
||||||
if (m_scenes.Contains(scene))
|
|
||||||
{
|
|
||||||
scene.EventManager.OnNewClient -= OnNewClient;
|
scene.EventManager.OnNewClient -= OnNewClient;
|
||||||
scene.EventManager.OnChatFromWorld -= OnChatFromWorld;
|
scene.EventManager.OnChatFromWorld -= OnChatFromWorld;
|
||||||
scene.EventManager.OnChatBroadcast -= OnChatBroadcast;
|
scene.EventManager.OnChatBroadcast -= OnChatBroadcast;
|
||||||
m_scenes.Remove(scene);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Close()
|
public virtual void Close()
|
||||||
|
@ -189,7 +176,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);
|
||||||
|
@ -199,13 +186,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;
|
||||||
|
@ -232,13 +213,11 @@ 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.
|
// 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.ForEachScenePresence(
|
scene.ForEachScenePresence(
|
||||||
delegate(ScenePresence presence)
|
delegate(ScenePresence presence)
|
||||||
{
|
{
|
||||||
if (TrySendChatMessage(
|
if (TrySendChatMessage(
|
||||||
|
@ -251,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||||
{
|
{
|
||||||
// This is a send to a specific client eg from llRegionSayTo
|
// This is a send to a specific client eg from llRegionSayTo
|
||||||
// no need to check distance etc, jand send is as say
|
// no need to check distance etc, jand send is as say
|
||||||
ScenePresence presence = s.GetScenePresence(targetID);
|
ScenePresence presence = scene.GetScenePresence(targetID);
|
||||||
if (presence != null && !presence.IsChildAgent)
|
if (presence != null && !presence.IsChildAgent)
|
||||||
{
|
{
|
||||||
if (TrySendChatMessage(
|
if (TrySendChatMessage(
|
||||||
|
@ -259,9 +238,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||||
receiverIDs.Add(presence.UUID);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,9 +324,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