diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Chat')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 102 |
1 files changed, 79 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 02f0968..9c8cbc6 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,15 @@ 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 | if (Presencecheck.IsEitherBannedOrRestricted(c.SenderUUID) != true) | ||
248 | { | ||
249 | TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix+fromName, c.Type, message, sourceType); | ||
250 | } | ||
251 | } | ||
252 | |||
231 | } | 253 | } |
232 | ); | 254 | ); |
233 | } | 255 | } |
@@ -270,25 +292,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
270 | } | 292 | } |
271 | 293 | ||
272 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); | 294 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); |
273 | 295 | if (c.Scene != null) | |
274 | ((Scene)c.Scene).ForEachScenePresence( | 296 | { |
275 | delegate(ScenePresence presence) | 297 | ((Scene)c.Scene).ForEachScenePresence |
276 | { | 298 | ( |
277 | // ignore chat from child agents | 299 | delegate(ScenePresence presence) |
278 | if (presence.IsChildAgent) return; | 300 | { |
279 | 301 | // ignore chat from child agents | |
280 | IClientAPI client = presence.ControllingClient; | 302 | if (presence.IsChildAgent) return; |
281 | 303 | ||
282 | // don't forward SayOwner chat from objects to | 304 | IClientAPI client = presence.ControllingClient; |
283 | // non-owner agents | 305 | |
284 | if ((c.Type == ChatTypeEnum.Owner) && | 306 | // don't forward SayOwner chat from objects to |
285 | (null != c.SenderObject) && | 307 | // non-owner agents |
286 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | 308 | if ((c.Type == ChatTypeEnum.Owner) && |
287 | return; | 309 | (null != c.SenderObject) && |
288 | 310 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | |
289 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, | 311 | return; |
290 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 312 | |
291 | }); | 313 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, |
314 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | ||
315 | } | ||
316 | ); | ||
317 | } | ||
292 | } | 318 | } |
293 | 319 | ||
294 | 320 | ||
@@ -317,5 +343,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
317 | presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, | 343 | presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, |
318 | fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully); | 344 | fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully); |
319 | } | 345 | } |
346 | |||
347 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | ||
348 | public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | ||
349 | { | ||
350 | System.Threading.Timer Timer; | ||
351 | if (flags == 0) | ||
352 | { | ||
353 | FreezeCache.Add(target.ToString()); | ||
354 | System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen); | ||
355 | Timer = new System.Threading.Timer(timeCB, target, 30000, 0); | ||
356 | Timers.Add(target, Timer); | ||
357 | } | ||
358 | else | ||
359 | { | ||
360 | FreezeCache.Remove(target.ToString()); | ||
361 | Timers.TryGetValue(target, out Timer); | ||
362 | Timers.Remove(target); | ||
363 | Timer.Dispose(); | ||
364 | } | ||
365 | } | ||
366 | |||
367 | private void OnEndParcelFrozen(object avatar) | ||
368 | { | ||
369 | UUID target = (UUID)avatar; | ||
370 | FreezeCache.Remove(target.ToString()); | ||
371 | System.Threading.Timer Timer; | ||
372 | Timers.TryGetValue(target, out Timer); | ||
373 | Timers.Remove(target); | ||
374 | Timer.Dispose(); | ||
375 | } | ||
320 | } | 376 | } |
321 | } | 377 | } |