diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Chat')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 104 |
1 files changed, 81 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index e4452fb..6ffc7e6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -49,7 +49,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
49 | private int m_shoutdistance = 100; | 49 | private int m_shoutdistance = 100; |
50 | private int m_whisperdistance = 10; | 50 | private int m_whisperdistance = 10; |
51 | private List<Scene> m_scenes = new List<Scene>(); | 51 | private List<Scene> m_scenes = new List<Scene>(); |
52 | 52 | private List<string> FreezeCache = new List<string>(); | |
53 | private string m_adminPrefix = ""; | ||
53 | internal object m_syncy = new object(); | 54 | internal object m_syncy = new object(); |
54 | 55 | ||
55 | internal IConfig m_config; | 56 | internal IConfig m_config; |
@@ -76,6 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
76 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); | 77 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); |
77 | m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); | 78 | m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); |
78 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); | 79 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); |
80 | m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", ""); | ||
79 | } | 81 | } |
80 | 82 | ||
81 | public virtual void AddRegion(Scene scene) | 83 | public virtual void AddRegion(Scene scene) |
@@ -171,7 +173,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
171 | return; | 173 | return; |
172 | } | 174 | } |
173 | 175 | ||
174 | DeliverChatToAvatars(ChatSourceType.Agent, c); | 176 | if (FreezeCache.Contains(c.Sender.AgentId.ToString())) |
177 | { | ||
178 | if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping) | ||
179 | c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false); | ||
180 | } | ||
181 | else | ||
182 | { | ||
183 | DeliverChatToAvatars(ChatSourceType.Agent, c); | ||
184 | } | ||
175 | } | 185 | } |
176 | 186 | ||
177 | public virtual void OnChatFromWorld(Object sender, OSChatMessage c) | 187 | public virtual void OnChatFromWorld(Object sender, OSChatMessage c) |
@@ -185,6 +195,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
185 | protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) | 195 | protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) |
186 | { | 196 | { |
187 | string fromName = c.From; | 197 | string fromName = c.From; |
198 | string fromNamePrefix = ""; | ||
188 | UUID fromID = UUID.Zero; | 199 | UUID fromID = UUID.Zero; |
189 | UUID targetID = c.TargetUUID; | 200 | UUID targetID = c.TargetUUID; |
190 | string message = c.Message; | 201 | string message = c.Message; |
@@ -208,7 +219,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
208 | fromPos = avatar.AbsolutePosition; | 219 | fromPos = avatar.AbsolutePosition; |
209 | fromName = avatar.Name; | 220 | fromName = avatar.Name; |
210 | fromID = c.Sender.AgentId; | 221 | fromID = c.Sender.AgentId; |
211 | 222 | if (avatar.GodLevel >= 200) | |
223 | { | ||
224 | fromNamePrefix = m_adminPrefix; | ||
225 | } | ||
212 | break; | 226 | break; |
213 | 227 | ||
214 | case ChatSourceType.Object: | 228 | case ChatSourceType.Object: |
@@ -248,8 +262,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
248 | ScenePresence presence = s.GetScenePresence(targetID); | 262 | ScenePresence presence = s.GetScenePresence(targetID); |
249 | if (presence != null && !presence.IsChildAgent) | 263 | if (presence != null && !presence.IsChildAgent) |
250 | { | 264 | { |
251 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, ChatTypeEnum.Say, message, sourceType, true)) | 265 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); |
252 | receiverIDs.Add(presence.UUID); | 266 | if (Presencecheck != null) |
267 | { | ||
268 | // This will pass all chat from objects. Not | ||
269 | // perfect, but it will do. For now. Better | ||
270 | // than the prior behavior of muting all | ||
271 | // objects on a parcel with access restrictions | ||
272 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) | ||
273 | { | ||
274 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType, false)) | ||
275 | receiverIDs.Add(presence.UUID); | ||
276 | } | ||
277 | } | ||
253 | } | 278 | } |
254 | } | 279 | } |
255 | } | 280 | } |
@@ -293,26 +318,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
293 | } | 318 | } |
294 | 319 | ||
295 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); | 320 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); |
296 | |||
297 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 321 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
298 | 322 | ||
299 | ((Scene)c.Scene).ForEachRootClient( | 323 | if (c.Scene != null) |
300 | delegate(IClientAPI client) | 324 | { |
301 | { | 325 | ((Scene)c.Scene).ForEachRootClient |
302 | // don't forward SayOwner chat from objects to | 326 | ( |
303 | // non-owner agents | 327 | delegate(IClientAPI client) |
304 | if ((c.Type == ChatTypeEnum.Owner) && | 328 | { |
305 | (null != c.SenderObject) && | 329 | // don't forward SayOwner chat from objects to |
306 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | 330 | // non-owner agents |
307 | return; | 331 | if ((c.Type == ChatTypeEnum.Owner) && |
308 | 332 | (null != c.SenderObject) && | |
309 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, | 333 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) |
310 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 334 | return; |
311 | receiverIDs.Add(client.AgentId); | 335 | |
312 | }); | 336 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, |
313 | 337 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | |
314 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( | 338 | receiverIDs.Add(client.AgentId); |
315 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | 339 | } |
340 | ); | ||
341 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( | ||
342 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | ||
343 | } | ||
316 | } | 344 | } |
317 | 345 | ||
318 | /// <summary> | 346 | /// <summary> |
@@ -358,5 +386,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
358 | 386 | ||
359 | return true; | 387 | return true; |
360 | } | 388 | } |
389 | |||
390 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | ||
391 | public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | ||
392 | { | ||
393 | System.Threading.Timer Timer; | ||
394 | if (flags == 0) | ||
395 | { | ||
396 | FreezeCache.Add(target.ToString()); | ||
397 | System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen); | ||
398 | Timer = new System.Threading.Timer(timeCB, target, 30000, 0); | ||
399 | Timers.Add(target, Timer); | ||
400 | } | ||
401 | else | ||
402 | { | ||
403 | FreezeCache.Remove(target.ToString()); | ||
404 | Timers.TryGetValue(target, out Timer); | ||
405 | Timers.Remove(target); | ||
406 | Timer.Dispose(); | ||
407 | } | ||
408 | } | ||
409 | |||
410 | private void OnEndParcelFrozen(object avatar) | ||
411 | { | ||
412 | UUID target = (UUID)avatar; | ||
413 | FreezeCache.Remove(target.ToString()); | ||
414 | System.Threading.Timer Timer; | ||
415 | Timers.TryGetValue(target, out Timer); | ||
416 | Timers.Remove(target); | ||
417 | Timer.Dispose(); | ||
418 | } | ||
361 | } | 419 | } |
362 | } | 420 | } |