diff options
author | Justin Clark-Casey (justincc) | 2013-03-22 01:42:47 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-03-22 01:43:18 +0000 |
commit | c4d9a23f2666d0284f2e65d1ee757bc17c3f56ad (patch) | |
tree | 2b4276112ed5edd3a4f8a31b5ac0d3cd9feb2337 | |
parent | Take out a testing sleep I accidentally left in the teleport code from last c... (diff) | |
download | opensim-SC-c4d9a23f2666d0284f2e65d1ee757bc17c3f56ad.zip opensim-SC-c4d9a23f2666d0284f2e65d1ee757bc17c3f56ad.tar.gz opensim-SC-c4d9a23f2666d0284f2e65d1ee757bc17c3f56ad.tar.bz2 opensim-SC-c4d9a23f2666d0284f2e65d1ee757bc17c3f56ad.tar.xz |
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 neighbours
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 87 |
1 files changed, 31 insertions, 56 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 9032dd4..58f747b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -50,7 +50,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
50 | private int m_saydistance = 20; | 50 | private int m_saydistance = 20; |
51 | private int m_shoutdistance = 100; | 51 | private int m_shoutdistance = 100; |
52 | private int m_whisperdistance = 10; | 52 | private int m_whisperdistance = 10; |
53 | private List<Scene> m_scenes = new List<Scene>(); | ||
54 | 53 | ||
55 | internal object m_syncy = new object(); | 54 | internal object m_syncy = new object(); |
56 | 55 | ||
@@ -82,18 +81,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
82 | 81 | ||
83 | public virtual void AddRegion(Scene scene) | 82 | public virtual void AddRegion(Scene scene) |
84 | { | 83 | { |
85 | if (!m_enabled) return; | 84 | if (!m_enabled) |
85 | return; | ||
86 | 86 | ||
87 | lock (m_syncy) | 87 | scene.EventManager.OnNewClient += OnNewClient; |
88 | { | 88 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; |
89 | if (!m_scenes.Contains(scene)) | 89 | scene.EventManager.OnChatBroadcast += OnChatBroadcast; |
90 | { | ||
91 | m_scenes.Add(scene); | ||
92 | scene.EventManager.OnNewClient += OnNewClient; | ||
93 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | ||
94 | scene.EventManager.OnChatBroadcast += OnChatBroadcast; | ||
95 | } | ||
96 | } | ||
97 | 90 | ||
98 | m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName, | 91 | m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName, |
99 | m_whisperdistance, m_saydistance, m_shoutdistance); | 92 | m_whisperdistance, m_saydistance, m_shoutdistance); |
@@ -105,18 +98,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
105 | 98 | ||
106 | public virtual void RemoveRegion(Scene scene) | 99 | public virtual void RemoveRegion(Scene scene) |
107 | { | 100 | { |
108 | if (!m_enabled) return; | 101 | if (!m_enabled) |
102 | return; | ||
109 | 103 | ||
110 | lock (m_syncy) | 104 | scene.EventManager.OnNewClient -= OnNewClient; |
111 | { | 105 | scene.EventManager.OnChatFromWorld -= OnChatFromWorld; |
112 | if (m_scenes.Contains(scene)) | 106 | scene.EventManager.OnChatBroadcast -= OnChatBroadcast; |
113 | { | ||
114 | scene.EventManager.OnNewClient -= OnNewClient; | ||
115 | scene.EventManager.OnChatFromWorld -= OnChatFromWorld; | ||
116 | scene.EventManager.OnChatBroadcast -= OnChatBroadcast; | ||
117 | m_scenes.Remove(scene); | ||
118 | } | ||
119 | } | ||
120 | } | 107 | } |
121 | 108 | ||
122 | public virtual void Close() | 109 | public virtual void Close() |
@@ -191,7 +178,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
191 | UUID ownerID = UUID.Zero; | 178 | UUID ownerID = UUID.Zero; |
192 | UUID targetID = c.TargetUUID; | 179 | UUID targetID = c.TargetUUID; |
193 | string message = c.Message; | 180 | string message = c.Message; |
194 | IScene scene = c.Scene; | 181 | Scene scene = (Scene)c.Scene; |
195 | Vector3 fromPos = c.Position; | 182 | Vector3 fromPos = c.Position; |
196 | Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, | 183 | Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, |
197 | scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | 184 | scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
@@ -201,13 +188,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
201 | switch (sourceType) | 188 | switch (sourceType) |
202 | { | 189 | { |
203 | case ChatSourceType.Agent: | 190 | case ChatSourceType.Agent: |
204 | if (!(scene is Scene)) | 191 | ScenePresence avatar = scene.GetScenePresence(c.Sender.AgentId); |
205 | { | ||
206 | m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}", | ||
207 | scene.RegionInfo.RegionName, c.Sender.AgentId); | ||
208 | return; | ||
209 | } | ||
210 | ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId); | ||
211 | fromPos = avatar.AbsolutePosition; | 192 | fromPos = avatar.AbsolutePosition; |
212 | fromName = avatar.Name; | 193 | fromName = avatar.Name; |
213 | fromID = c.Sender.AgentId; | 194 | fromID = c.Sender.AgentId; |
@@ -234,36 +215,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
234 | 215 | ||
235 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 216 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
236 | 217 | ||
237 | foreach (Scene s in m_scenes) | 218 | if (targetID == UUID.Zero) |
238 | { | 219 | { |
239 | if (targetID == UUID.Zero) | 220 | // This should use ForEachClient, but clients don't have a position. |
240 | { | 221 | // If camera is moved into client, then camera position can be used |
241 | // This should use ForEachClient, but clients don't have a position. | 222 | scene.ForEachScenePresence( |
242 | // If camera is moved into client, then camera position can be used | 223 | delegate(ScenePresence presence) |
243 | s.ForEachScenePresence( | ||
244 | delegate(ScenePresence presence) | ||
245 | { | ||
246 | if (TrySendChatMessage( | ||
247 | presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false)) | ||
248 | receiverIDs.Add(presence.UUID); | ||
249 | } | ||
250 | ); | ||
251 | } | ||
252 | else | ||
253 | { | ||
254 | // This is a send to a specific client eg from llRegionSayTo | ||
255 | // no need to check distance etc, jand send is as say | ||
256 | ScenePresence presence = s.GetScenePresence(targetID); | ||
257 | if (presence != null && !presence.IsChildAgent) | ||
258 | { | 224 | { |
259 | if (TrySendChatMessage( | 225 | if (TrySendChatMessage( |
260 | presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true)) | 226 | presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false)) |
261 | receiverIDs.Add(presence.UUID); | 227 | receiverIDs.Add(presence.UUID); |
262 | } | 228 | } |
229 | ); | ||
230 | } | ||
231 | else | ||
232 | { | ||
233 | // This is a send to a specific client eg from llRegionSayTo | ||
234 | // no need to check distance etc, jand send is as say | ||
235 | ScenePresence presence = scene.GetScenePresence(targetID); | ||
236 | if (presence != null && !presence.IsChildAgent) | ||
237 | { | ||
238 | if (TrySendChatMessage( | ||
239 | presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true)) | ||
240 | receiverIDs.Add(presence.UUID); | ||
263 | } | 241 | } |
264 | } | 242 | } |
265 | 243 | ||
266 | (scene as Scene).EventManager.TriggerOnChatToClients( | 244 | scene.EventManager.TriggerOnChatToClients( |
267 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); | 245 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); |
268 | } | 246 | } |
269 | 247 | ||
@@ -348,9 +326,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
348 | UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type, | 326 | UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type, |
349 | string message, ChatSourceType src, bool ignoreDistance) | 327 | string message, ChatSourceType src, bool ignoreDistance) |
350 | { | 328 | { |
351 | // don't send stuff to child agents | ||
352 | if (presence.IsChildAgent) return false; | ||
353 | |||
354 | Vector3 fromRegionPos = fromPos + regionPos; | 329 | Vector3 fromRegionPos = fromPos + regionPos; |
355 | Vector3 toRegionPos = presence.AbsolutePosition + | 330 | Vector3 toRegionPos = presence.AbsolutePosition + |
356 | new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize, | 331 | new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize, |