aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-10-21 22:04:31 +0100
committerJustin Clark-Casey (justincc)2010-10-22 01:01:56 +0100
commit62a09103552cc87083f9107324dc4d6e4256b3d3 (patch)
treeafb74106363941341160458afae0585449749ee3 /OpenSim/Region/CoreModules/Avatar
parentThis fixes a delay in llSetLinkPrimitiveParamsFast (diff)
downloadopensim-SC-62a09103552cc87083f9107324dc4d6e4256b3d3.zip
opensim-SC-62a09103552cc87083f9107324dc4d6e4256b3d3.tar.gz
opensim-SC-62a09103552cc87083f9107324dc4d6e4256b3d3.tar.bz2
opensim-SC-62a09103552cc87083f9107324dc4d6e4256b3d3.tar.xz
Allow region modules to know which agents actually receive chat
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs44
1 files changed, 36 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index ef5efdd..d76ff47 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -167,7 +167,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
167 // sanity check: 167 // sanity check:
168 if (c.Sender == null) 168 if (c.Sender == null)
169 { 169 {
170 m_log.ErrorFormat("[CHAT] OnChatFromClient from {0} has empty Sender field!", sender); 170 m_log.ErrorFormat("[CHAT]: OnChatFromClient from {0} has empty Sender field!", sender);
171 return; 171 return;
172 } 172 }
173 173
@@ -220,17 +220,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
220 if (message.Length >= 1000) // libomv limit 220 if (message.Length >= 1000) // libomv limit
221 message = message.Substring(0, 1000); 221 message = message.Substring(0, 1000);
222 222
223 // m_log.DebugFormat("[CHAT]: DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType); 223// m_log.DebugFormat(
224// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}",
225// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType);
224 226
227 HashSet<UUID> receiverIDs = new HashSet<UUID>();
228
225 foreach (Scene s in m_scenes) 229 foreach (Scene s in m_scenes)
226 { 230 {
227 s.ForEachScenePresence( 231 s.ForEachScenePresence(
228 delegate(ScenePresence presence) 232 delegate(ScenePresence presence)
229 { 233 {
230 TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType); 234 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType))
235 receiverIDs.Add(presence.UUID);
231 } 236 }
232 ); 237 );
233 } 238 }
239
240 (scene as Scene).EventManager.TriggerOnChatToClients(
241 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
234 } 242 }
235 243
236 static private Vector3 CenterOfRegion = new Vector3(128, 128, 30); 244 static private Vector3 CenterOfRegion = new Vector3(128, 128, 30);
@@ -269,6 +277,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
269 277
270 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); 278 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
271 279
280 HashSet<UUID> receiverIDs = new HashSet<UUID>();
281
272 ((Scene)c.Scene).ForEachScenePresence( 282 ((Scene)c.Scene).ForEachScenePresence(
273 delegate(ScenePresence presence) 283 delegate(ScenePresence presence)
274 { 284 {
@@ -286,16 +296,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
286 296
287 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, 297 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
288 (byte)sourceType, (byte)ChatAudibleLevel.Fully); 298 (byte)sourceType, (byte)ChatAudibleLevel.Fully);
299 receiverIDs.Add(presence.UUID);
289 }); 300 });
301
302 (c.Scene as Scene).EventManager.TriggerOnChatToClients(
303 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully);
290 } 304 }
291 305
292 306 /// <summary>
293 protected virtual void TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, 307 /// Try to send a message to the given presence
308 /// </summary>
309 /// <param name="presence">The receiver</param>
310 /// <param name="fromPos"></param>
311 /// <param name="regionPos">/param>
312 /// <param name="fromAgentID"></param>
313 /// <param name="fromName"></param>
314 /// <param name="type"></param>
315 /// <param name="message"></param>
316 /// <param name="src"></param>
317 /// <returns>true if the message was sent to the receiver, false if it was not sent due to failing a
318 /// precondition</returns>
319 protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
294 UUID fromAgentID, string fromName, ChatTypeEnum type, 320 UUID fromAgentID, string fromName, ChatTypeEnum type,
295 string message, ChatSourceType src) 321 string message, ChatSourceType src)
296 { 322 {
297 // don't send stuff to child agents 323 // don't send stuff to child agents
298 if (presence.IsChildAgent) return; 324 if (presence.IsChildAgent) return false;
299 325
300 Vector3 fromRegionPos = fromPos + regionPos; 326 Vector3 fromRegionPos = fromPos + regionPos;
301 Vector3 toRegionPos = presence.AbsolutePosition + 327 Vector3 toRegionPos = presence.AbsolutePosition +
@@ -308,12 +334,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
308 type == ChatTypeEnum.Say && dis > m_saydistance || 334 type == ChatTypeEnum.Say && dis > m_saydistance ||
309 type == ChatTypeEnum.Shout && dis > m_shoutdistance) 335 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
310 { 336 {
311 return; 337 return false;
312 } 338 }
313 339
314 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView 340 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
315 presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, 341 presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,
316 fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully); 342 fromAgentID, (byte)src, (byte)ChatAudibleLevel.Fully);
343
344 return true;
317 } 345 }
318 } 346 }
319} 347}