diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Chat')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 106 |
1 files changed, 83 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index ef5efdd..2a590f1 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: |
@@ -227,7 +241,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
227 | s.ForEachScenePresence( | 241 | s.ForEachScenePresence( |
228 | delegate(ScenePresence presence) | 242 | delegate(ScenePresence presence) |
229 | { | 243 | { |
230 | TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType); | 244 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); |
245 | if (Presencecheck != null) | ||
246 | { | ||
247 | // This will pass all chat from objects. Not | ||
248 | // perfect, but it will do. For now. Better | ||
249 | // than the prior behavior of muting all | ||
250 | // objects on a parcel with access restrictions | ||
251 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) | ||
252 | { | ||
253 | TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix+fromName, c.Type, message, sourceType); | ||
254 | } | ||
255 | } | ||
256 | |||
231 | } | 257 | } |
232 | ); | 258 | ); |
233 | } | 259 | } |
@@ -268,25 +294,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
268 | } | 294 | } |
269 | 295 | ||
270 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); | 296 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); |
271 | 297 | if (c.Scene != null) | |
272 | ((Scene)c.Scene).ForEachScenePresence( | 298 | { |
273 | delegate(ScenePresence presence) | 299 | ((Scene)c.Scene).ForEachScenePresence |
274 | { | 300 | ( |
275 | // ignore chat from child agents | 301 | delegate(ScenePresence presence) |
276 | if (presence.IsChildAgent) return; | 302 | { |
277 | 303 | // ignore chat from child agents | |
278 | IClientAPI client = presence.ControllingClient; | 304 | if (presence.IsChildAgent) return; |
279 | 305 | ||
280 | // don't forward SayOwner chat from objects to | 306 | IClientAPI client = presence.ControllingClient; |
281 | // non-owner agents | 307 | |
282 | if ((c.Type == ChatTypeEnum.Owner) && | 308 | // don't forward SayOwner chat from objects to |
283 | (null != c.SenderObject) && | 309 | // non-owner agents |
284 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | 310 | if ((c.Type == ChatTypeEnum.Owner) && |
285 | return; | 311 | (null != c.SenderObject) && |
286 | 312 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | |
287 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, | 313 | return; |
288 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 314 | |
289 | }); | 315 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, |
316 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | ||
317 | } | ||
318 | ); | ||
319 | } | ||
290 | } | 320 | } |
291 | 321 | ||
292 | 322 | ||
@@ -315,5 +345,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
315 | presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, | 345 | presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, |
316 | fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully); | 346 | fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully); |
317 | } | 347 | } |
348 | |||
349 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | ||
350 | public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | ||
351 | { | ||
352 | System.Threading.Timer Timer; | ||
353 | if (flags == 0) | ||
354 | { | ||
355 | FreezeCache.Add(target.ToString()); | ||
356 | System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen); | ||
357 | Timer = new System.Threading.Timer(timeCB, target, 30000, 0); | ||
358 | Timers.Add(target, Timer); | ||
359 | } | ||
360 | else | ||
361 | { | ||
362 | FreezeCache.Remove(target.ToString()); | ||
363 | Timers.TryGetValue(target, out Timer); | ||
364 | Timers.Remove(target); | ||
365 | Timer.Dispose(); | ||
366 | } | ||
367 | } | ||
368 | |||
369 | private void OnEndParcelFrozen(object avatar) | ||
370 | { | ||
371 | UUID target = (UUID)avatar; | ||
372 | FreezeCache.Remove(target.ToString()); | ||
373 | System.Threading.Timer Timer; | ||
374 | Timers.TryGetValue(target, out Timer); | ||
375 | Timers.Remove(target); | ||
376 | Timer.Dispose(); | ||
377 | } | ||
318 | } | 378 | } |
319 | } | 379 | } |