diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Chat')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 105 |
1 files changed, 82 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 10b4c37..4d8fb90 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 | string message = c.Message; | 200 | string message = c.Message; |
190 | IScene scene = c.Scene; | 201 | IScene scene = c.Scene; |
@@ -207,7 +218,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
207 | fromPos = avatar.AbsolutePosition; | 218 | fromPos = avatar.AbsolutePosition; |
208 | fromName = avatar.Name; | 219 | fromName = avatar.Name; |
209 | fromID = c.Sender.AgentId; | 220 | fromID = c.Sender.AgentId; |
210 | 221 | if (avatar.GodLevel >= 200) | |
222 | { | ||
223 | fromNamePrefix = m_adminPrefix; | ||
224 | } | ||
211 | break; | 225 | break; |
212 | 226 | ||
213 | case ChatSourceType.Object: | 227 | case ChatSourceType.Object: |
@@ -233,8 +247,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
233 | s.ForEachRootScenePresence( | 247 | s.ForEachRootScenePresence( |
234 | delegate(ScenePresence presence) | 248 | delegate(ScenePresence presence) |
235 | { | 249 | { |
236 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType)) | 250 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); |
237 | receiverIDs.Add(presence.UUID); | 251 | if (Presencecheck != null) |
252 | { | ||
253 | // This will pass all chat from objects. Not | ||
254 | // perfect, but it will do. For now. Better | ||
255 | // than the prior behavior of muting all | ||
256 | // objects on a parcel with access restrictions | ||
257 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) | ||
258 | { | ||
259 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType)) | ||
260 | receiverIDs.Add(presence.UUID); | ||
261 | } | ||
262 | } | ||
263 | |||
238 | } | 264 | } |
239 | ); | 265 | ); |
240 | } | 266 | } |
@@ -278,26 +304,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
278 | } | 304 | } |
279 | 305 | ||
280 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); | 306 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); |
281 | |||
282 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 307 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
283 | 308 | ||
284 | ((Scene)c.Scene).ForEachRootClient( | 309 | if (c.Scene != null) |
285 | delegate(IClientAPI client) | 310 | { |
286 | { | 311 | ((Scene)c.Scene).ForEachRootClient |
287 | // don't forward SayOwner chat from objects to | 312 | ( |
288 | // non-owner agents | 313 | delegate(IClientAPI client) |
289 | if ((c.Type == ChatTypeEnum.Owner) && | 314 | { |
290 | (null != c.SenderObject) && | 315 | // don't forward SayOwner chat from objects to |
291 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | 316 | // non-owner agents |
292 | return; | 317 | if ((c.Type == ChatTypeEnum.Owner) && |
293 | 318 | (null != c.SenderObject) && | |
294 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, | 319 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) |
295 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 320 | return; |
296 | receiverIDs.Add(client.AgentId); | 321 | |
297 | }); | 322 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, |
298 | 323 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | |
299 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( | 324 | receiverIDs.Add(client.AgentId); |
300 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | 325 | } |
326 | ); | ||
327 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( | ||
328 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | ||
329 | } | ||
301 | } | 330 | } |
302 | 331 | ||
303 | /// <summary> | 332 | /// <summary> |
@@ -340,5 +369,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
340 | 369 | ||
341 | return true; | 370 | return true; |
342 | } | 371 | } |
372 | |||
373 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | ||
374 | public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | ||
375 | { | ||
376 | System.Threading.Timer Timer; | ||
377 | if (flags == 0) | ||
378 | { | ||
379 | FreezeCache.Add(target.ToString()); | ||
380 | System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen); | ||
381 | Timer = new System.Threading.Timer(timeCB, target, 30000, 0); | ||
382 | Timers.Add(target, Timer); | ||
383 | } | ||
384 | else | ||
385 | { | ||
386 | FreezeCache.Remove(target.ToString()); | ||
387 | Timers.TryGetValue(target, out Timer); | ||
388 | Timers.Remove(target); | ||
389 | Timer.Dispose(); | ||
390 | } | ||
391 | } | ||
392 | |||
393 | private void OnEndParcelFrozen(object avatar) | ||
394 | { | ||
395 | UUID target = (UUID)avatar; | ||
396 | FreezeCache.Remove(target.ToString()); | ||
397 | System.Threading.Timer Timer; | ||
398 | Timers.TryGetValue(target, out Timer); | ||
399 | Timers.Remove(target); | ||
400 | Timer.Dispose(); | ||
401 | } | ||
343 | } | 402 | } |
344 | } | 403 | } |