aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs400
1 files changed, 209 insertions, 191 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 0144c4c..c0fda61 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -27,27 +27,28 @@
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.Drawing;
31using System.Net; 31using System.Drawing.Imaging;
32using System.Threading; 32using System.Threading;
33using System.Timers; 33using System.Timers;
34using System.Xml;
35using Axiom.Math; 34using Axiom.Math;
36using libsecondlife; 35using libsecondlife;
36using libsecondlife.Packets;
37using OpenJPEGNet;
37using OpenSim.Framework; 38using OpenSim.Framework;
38using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache; 40using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Console; 41using OpenSim.Framework.Console;
41using OpenSim.Region.Environment.LandManagement;
42using OpenSim.Framework.Servers; 42using OpenSim.Framework.Servers;
43using OpenSim.Region.Capabilities;
44using OpenSim.Region.Environment.Interfaces; 43using OpenSim.Region.Environment.Interfaces;
44using OpenSim.Region.Environment.LandManagement;
45using OpenSim.Region.Environment.Modules; 45using OpenSim.Region.Environment.Modules;
46using OpenSim.Region.Environment.Scenes.Scripting; 46using OpenSim.Region.Environment.Scenes.Scripting;
47using OpenSim.Region.Environment.Types;
48using OpenSim.Region.Physics.Manager; 47using OpenSim.Region.Physics.Manager;
49using OpenSim.Region.Terrain; 48using OpenSim.Region.Terrain;
50using Timer = System.Timers.Timer; 49using Caps=OpenSim.Region.Capabilities.Caps;
50using Image=System.Drawing.Image;
51using Timer=System.Timers.Timer;
51 52
52namespace OpenSim.Region.Environment.Scenes 53namespace OpenSim.Region.Environment.Scenes
53{ 54{
@@ -56,6 +57,7 @@ namespace OpenSim.Region.Environment.Scenes
56 public partial class Scene : SceneBase 57 public partial class Scene : SceneBase
57 { 58 {
58 #region Fields 59 #region Fields
60
59 protected Timer m_heartbeatTimer = new Timer(); 61 protected Timer m_heartbeatTimer = new Timer();
60 protected Timer m_restartWaitTimer = new Timer(); 62 protected Timer m_restartWaitTimer = new Timer();
61 63
@@ -88,7 +90,7 @@ namespace OpenSim.Region.Environment.Scenes
88 protected SceneCommunicationService m_sceneGridService; 90 protected SceneCommunicationService m_sceneGridService;
89 protected SceneXmlLoader m_sceneXmlLoader; 91 protected SceneXmlLoader m_sceneXmlLoader;
90 92
91 protected Dictionary<LLUUID, OpenSim.Region.Capabilities.Caps> m_capsHandlers = new Dictionary<LLUUID, OpenSim.Region.Capabilities.Caps>(); 93 protected Dictionary<LLUUID, Caps> m_capsHandlers = new Dictionary<LLUUID, Caps>();
92 protected BaseHttpServer httpListener; 94 protected BaseHttpServer httpListener;
93 95
94 protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>(); 96 protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>();
@@ -122,6 +124,7 @@ namespace OpenSim.Region.Environment.Scenes
122 private int m_update_terrain = 50; 124 private int m_update_terrain = 50;
123 private int m_update_land = 1; 125 private int m_update_land = 1;
124 private int m_update_avatars = 1; 126 private int m_update_avatars = 1;
127
125 #endregion 128 #endregion
126 129
127 #region Properties 130 #region Properties
@@ -145,6 +148,7 @@ namespace OpenSim.Region.Environment.Scenes
145 set { m_innerScene.PhysicsScene = value; } 148 set { m_innerScene.PhysicsScene = value; }
146 get { return (m_innerScene.PhysicsScene); } 149 get { return (m_innerScene.PhysicsScene); }
147 } 150 }
151
148 // This gets locked so things stay thread safe. 152 // This gets locked so things stay thread safe.
149 public object SyncRoot 153 public object SyncRoot
150 { 154 {
@@ -204,7 +208,8 @@ namespace OpenSim.Region.Environment.Scenes
204 208
205 #region Constructors 209 #region Constructors
206 210
207 public Scene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, 211 public Scene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager,
212 CommunicationsManager commsMan, SceneCommunicationService sceneGridService,
208 AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, 213 AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer,
209 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SendTasksToChild) 214 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SendTasksToChild)
210 { 215 {
@@ -230,9 +235,11 @@ namespace OpenSim.Region.Environment.Scenes
230 m_LandManager = new LandManager(this, m_regInfo); 235 m_LandManager = new LandManager(this, m_regInfo);
231 236
232 //Bind Storage Manager functions to some land manager functions for this scene 237 //Bind Storage Manager functions to some land manager functions for this scene
233 EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); 238 EventManager.OnLandObjectAdded +=
234 EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); 239 new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject);
235 240 EventManager.OnLandObjectRemoved +=
241 new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject);
242
236 m_estateManager = new EstateManager(this, m_regInfo); 243 m_estateManager = new EstateManager(this, m_regInfo);
237 244
238 m_permissionManager = permissionManager; 245 m_permissionManager = permissionManager;
@@ -258,7 +265,7 @@ namespace OpenSim.Region.Environment.Scenes
258 m_sceneObjects = new Dictionary<LLUUID, SceneObjectGroup>(); 265 m_sceneObjects = new Dictionary<LLUUID, SceneObjectGroup>();
259 266
260 MainLog.Instance.Verbose("SCENE", "Creating LandMap"); 267 MainLog.Instance.Verbose("SCENE", "Creating LandMap");
261 Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY); 268 Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY);
262 269
263 ScenePresence.LoadAnims(); 270 ScenePresence.LoadAnims();
264 271
@@ -276,7 +283,7 @@ namespace OpenSim.Region.Environment.Scenes
276 protected virtual void RegisterDefaultSceneEvents() 283 protected virtual void RegisterDefaultSceneEvents()
277 { 284 {
278 m_eventManager.OnParcelPrimCountAdd += m_LandManager.addPrimToLandPrimCounts; 285 m_eventManager.OnParcelPrimCountAdd += m_LandManager.addPrimToLandPrimCounts;
279 m_eventManager.OnParcelPrimCountUpdate += this.addPrimsToParcelCounts; 286 m_eventManager.OnParcelPrimCountUpdate += addPrimsToParcelCounts;
280 m_eventManager.OnPermissionError += SendPermissionAlert; 287 m_eventManager.OnPermissionError += SendPermissionAlert;
281 } 288 }
282 289
@@ -295,68 +302,65 @@ namespace OpenSim.Region.Environment.Scenes
295 302
296 if (RegionInfo.RegionHandle != otherRegion.RegionHandle) 303 if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
297 { 304 {
298 for (int i = 0; i < m_neighbours.Count; i++) 305 for (int i = 0; i < m_neighbours.Count; i++)
306 {
307 // The purpose of this loop is to re-update the known neighbors
308 // when another region comes up on top of another one.
309 // The latest region in that location ends up in the
310 // 'known neighbors list'
311 // Additionally, the commFailTF property gets reset to false.
312 if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
299 { 313 {
300 // The purpose of this loop is to re-update the known neighbors 314 lock (m_neighbours)
301 // when another region comes up on top of another one.
302 // The latest region in that location ends up in the
303 // 'known neighbors list'
304 // Additionally, the commFailTF property gets reset to false.
305 if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
306 { 315 {
307 lock (m_neighbours) 316 m_neighbours[i] = otherRegion;
308 {
309 m_neighbours[i] = otherRegion;
310 }
311 } 317 }
312 } 318 }
319 }
313 320
314 // If the value isn't in the neighbours, add it. 321 // If the value isn't in the neighbours, add it.
315 // If the RegionInfo isn't exact but is for the same XY World location, 322 // If the RegionInfo isn't exact but is for the same XY World location,
316 // then the above loop will fix that. 323 // then the above loop will fix that.
317 324
318 if (!(m_neighbours.Contains(otherRegion))) 325 if (!(m_neighbours.Contains(otherRegion)))
326 {
327 lock (m_neighbours)
319 { 328 {
320 lock (m_neighbours) 329 m_neighbours.Add(otherRegion);
321 {
322 m_neighbours.Add(otherRegion);
323 }
324 } 330 }
325 if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1)) 331 }
332 if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) &&
333 (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1))
326 { 334 {
327 try 335 try
328 { 336 {
329
330 ForEachScenePresence(delegate(ScenePresence agent) 337 ForEachScenePresence(delegate(ScenePresence agent)
331 { 338 {
332 // If agent is a root agent. 339 // If agent is a root agent.
333 if (!agent.IsChildAgent) 340 if (!agent.IsChildAgent)
334 { 341 {
335 342 //agent.ControllingClient.new
336 //agent.ControllingClient.new 343 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
337 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 344 InformClientOfNeighbor(agent, otherRegion);
338 InformClientOfNeighbor(agent, otherRegion); 345 }
339 } 346 }
340 } 347 );
341
342 );
343 } 348 }
344 catch (System.NullReferenceException) 349 catch (NullReferenceException)
345 { 350 {
346 // This means that we're not booted up completely yet. 351 // This means that we're not booted up completely yet.
347 // This shouldn't happen too often anymore. 352 // This shouldn't happen too often anymore.
348 MainLog.Instance.Error("SCENE", "Couldn't inform client of regionup because we got a null reference exception"); 353 MainLog.Instance.Error("SCENE",
354 "Couldn't inform client of regionup because we got a null reference exception");
349 } 355 }
350 } 356 }
351 else 357 else
352 { 358 {
353 MainLog.Instance.Verbose("INTERGRID", "Got notice about far away Region: " + otherRegion.RegionName.ToString() + 359 MainLog.Instance.Verbose("INTERGRID",
354 " at (" + otherRegion.RegionLocX.ToString() + ", " + otherRegion.RegionLocY.ToString() + ")" ); 360 "Got notice about far away Region: " + otherRegion.RegionName.ToString() +
361 " at (" + otherRegion.RegionLocX.ToString() + ", " +
362 otherRegion.RegionLocY.ToString() + ")");
355 } 363 }
356
357
358
359
360 } 364 }
361 return true; 365 return true;
362 } 366 }
@@ -379,11 +383,11 @@ namespace OpenSim.Region.Environment.Scenes
379 { 383 {
380 // Now we figure out what to set the timer to that does the notifications and calls, RestartNow() 384 // Now we figure out what to set the timer to that does the notifications and calls, RestartNow()
381 m_restartTimer.Interval = 15000; 385 m_restartTimer.Interval = 15000;
382 m_incrementsof15seconds = (int)seconds / 15; 386 m_incrementsof15seconds = (int) seconds/15;
383 m_RestartTimerCounter = 0; 387 m_RestartTimerCounter = 0;
384 m_restartTimer.AutoReset = true; 388 m_restartTimer.AutoReset = true;
385 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); 389 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
386 MainLog.Instance.Error("REGION", "Restarting Region in " + (seconds / 60) + " minutes"); 390 MainLog.Instance.Error("REGION", "Restarting Region in " + (seconds/60) + " minutes");
387 m_restartTimer.Start(); 391 m_restartTimer.Start();
388 SendGeneralAlert(RegionInfo.RegionName + ": Restarting in 2 Minutes"); 392 SendGeneralAlert(RegionInfo.RegionName + ": Restarting in 2 Minutes");
389 } 393 }
@@ -399,7 +403,8 @@ namespace OpenSim.Region.Environment.Scenes
399 if (m_RestartTimerCounter <= m_incrementsof15seconds) 403 if (m_RestartTimerCounter <= m_incrementsof15seconds)
400 { 404 {
401 if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7) 405 if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7)
402 SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter) * 15) + " seconds"); 406 SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) +
407 " seconds");
403 } 408 }
404 else 409 else
405 { 410 {
@@ -432,21 +437,19 @@ namespace OpenSim.Region.Environment.Scenes
432 { 437 {
433 try 438 try
434 { 439 {
435
436 ForEachScenePresence(delegate(ScenePresence agent) 440 ForEachScenePresence(delegate(ScenePresence agent)
437 { 441 {
438 // If agent is a root agent. 442 // If agent is a root agent.
439 if (!agent.IsChildAgent) 443 if (!agent.IsChildAgent)
440 { 444 {
441 //agent.ControllingClient.new 445 //agent.ControllingClient.new
442 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 446 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
443 InformClientOfNeighbor(agent, region); 447 InformClientOfNeighbor(agent, region);
444 } 448 }
445 } 449 }
446 450 );
447 );
448 } 451 }
449 catch (System.NullReferenceException) 452 catch (NullReferenceException)
450 { 453 {
451 // This means that we're not booted up completely yet. 454 // This means that we're not booted up completely yet.
452 // This shouldn't happen too often anymore. 455 // This shouldn't happen too often anymore.
@@ -464,24 +467,22 @@ namespace OpenSim.Region.Environment.Scenes
464 MainLog.Instance.Warn("SCENE", "Closing down the single simulator: " + RegionInfo.RegionName); 467 MainLog.Instance.Warn("SCENE", "Closing down the single simulator: " + RegionInfo.RegionName);
465 // Kick all ROOT agents with the message, 'The simulator is going down' 468 // Kick all ROOT agents with the message, 'The simulator is going down'
466 ForEachScenePresence(delegate(ScenePresence avatar) 469 ForEachScenePresence(delegate(ScenePresence avatar)
467 { 470 {
468 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) 471 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle))
469 avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle); 472 avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle);
470 473
471 if (!avatar.IsChildAgent) 474 if (!avatar.IsChildAgent)
472 avatar.ControllingClient.Kick("The simulator is going down."); 475 avatar.ControllingClient.Kick("The simulator is going down.");
473 476
474 avatar.ControllingClient.OutPacket(new libsecondlife.Packets.DisableSimulatorPacket(), ThrottleOutPacketType.Task); 477 avatar.ControllingClient.OutPacket(new DisableSimulatorPacket(),
475 }); 478 ThrottleOutPacketType.Task);
479 });
476 480
477 // Wait here, or the kick messages won't actually get to the agents before the scene terminates. 481 // Wait here, or the kick messages won't actually get to the agents before the scene terminates.
478 Thread.Sleep(500); 482 Thread.Sleep(500);
479 483
480 // Stop all client threads. 484 // Stop all client threads.
481 ForEachScenePresence(delegate(ScenePresence avatar) 485 ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(true); });
482 {
483 avatar.ControllingClient.Close(true);
484 });
485 // Stop updating the scene objects and agents. 486 // Stop updating the scene objects and agents.
486 m_heartbeatTimer.Close(); 487 m_heartbeatTimer.Close();
487 // close the inner scene 488 // close the inner scene
@@ -509,7 +510,7 @@ namespace OpenSim.Region.Environment.Scenes
509 public void StartTimer() 510 public void StartTimer()
510 { 511 {
511 m_heartbeatTimer.Enabled = true; 512 m_heartbeatTimer.Enabled = true;
512 m_heartbeatTimer.Interval = (int)(m_timespan * 1000); 513 m_heartbeatTimer.Interval = (int) (m_timespan*1000);
513 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 514 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
514 } 515 }
515 516
@@ -555,30 +556,30 @@ namespace OpenSim.Region.Environment.Scenes
555 if (m_frame == Int32.MaxValue) 556 if (m_frame == Int32.MaxValue)
556 m_frame = 0; 557 m_frame = 0;
557 558
558 if (m_frame % m_update_physics == 0) 559 if (m_frame%m_update_physics == 0)
559 m_innerScene.UpdatePreparePhysics(); 560 m_innerScene.UpdatePreparePhysics();
560 561
561 if (m_frame % m_update_entitymovement == 0) 562 if (m_frame%m_update_entitymovement == 0)
562 m_innerScene.UpdateEntityMovement(); 563 m_innerScene.UpdateEntityMovement();
563 564
564 if (m_frame % m_update_physics == 0) 565 if (m_frame%m_update_physics == 0)
565 physicsFPS = m_innerScene.UpdatePhysics( 566 physicsFPS = m_innerScene.UpdatePhysics(
566 Math.Max(SinceLastFrame.TotalSeconds, m_timespan) 567 Math.Max(SinceLastFrame.TotalSeconds, m_timespan)
567 ); 568 );
568 569
569 if (m_frame % m_update_entities == 0) 570 if (m_frame%m_update_entities == 0)
570 m_innerScene.UpdateEntities(); 571 m_innerScene.UpdateEntities();
571 572
572 if (m_frame % m_update_events == 0) 573 if (m_frame%m_update_events == 0)
573 UpdateEvents(); 574 UpdateEvents();
574 575
575 if (m_frame % m_update_backup == 0) 576 if (m_frame%m_update_backup == 0)
576 UpdateStorageBackup(); 577 UpdateStorageBackup();
577 578
578 if (m_frame % m_update_terrain == 0) 579 if (m_frame%m_update_terrain == 0)
579 UpdateTerrain(); 580 UpdateTerrain();
580 581
581 if (m_frame % m_update_land == 0) 582 if (m_frame%m_update_land == 0)
582 UpdateLand(); 583 UpdateLand();
583 584
584 // if (m_frame%m_update_avatars == 0) 585 // if (m_frame%m_update_avatars == 0)
@@ -592,7 +593,6 @@ namespace OpenSim.Region.Environment.Scenes
592 m_statsReporter.SetChildAgents(m_innerScene.GetChildAgentCount()); 593 m_statsReporter.SetChildAgents(m_innerScene.GetChildAgentCount());
593 m_statsReporter.SetObjects(m_innerScene.GetTotalObjects()); 594 m_statsReporter.SetObjects(m_innerScene.GetTotalObjects());
594 m_statsReporter.SetActiveObjects(m_innerScene.GetActiveObjects()); 595 m_statsReporter.SetActiveObjects(m_innerScene.GetActiveObjects());
595
596 } 596 }
597 catch (NotImplementedException) 597 catch (NotImplementedException)
598 { 598 {
@@ -606,10 +606,11 @@ namespace OpenSim.Region.Environment.Scenes
606 { 606 {
607 updateLock.ReleaseMutex(); 607 updateLock.ReleaseMutex();
608 608
609 m_timedilation = m_timespan / (float)SinceLastFrame.TotalSeconds; 609 m_timedilation = m_timespan/(float) SinceLastFrame.TotalSeconds;
610 m_lastupdate = DateTime.Now; 610 m_lastupdate = DateTime.Now;
611 } 611 }
612 } 612 }
613
613 //Updates the time in the viewer. 614 //Updates the time in the viewer.
614 private void UpdateInWorldTime() 615 private void UpdateInWorldTime()
615 { 616 {
@@ -631,7 +632,7 @@ namespace OpenSim.Region.Environment.Scenes
631 } 632 }
632 } 633 }
633 634
634 private void SendSimStatsPackets(libsecondlife.Packets.SimStatsPacket pack) 635 private void SendSimStatsPackets(SimStatsPacket pack)
635 { 636 {
636 List<ScenePresence> StatSendAgents = GetScenePresences(); 637 List<ScenePresence> StatSendAgents = GetScenePresences();
637 foreach (ScenePresence agent in StatSendAgents) 638 foreach (ScenePresence agent in StatSendAgents)
@@ -639,11 +640,10 @@ namespace OpenSim.Region.Environment.Scenes
639 if (!agent.IsChildAgent) 640 if (!agent.IsChildAgent)
640 { 641 {
641 agent.ControllingClient.OutPacket(pack, ThrottleOutPacketType.Task); 642 agent.ControllingClient.OutPacket(pack, ThrottleOutPacketType.Task);
642
643 } 643 }
644 } 644 }
645
646 } 645 }
646
647 private void UpdateLand() 647 private void UpdateLand()
648 { 648 {
649 if (m_LandManager.landPrimCountTainted) 649 if (m_LandManager.landPrimCountTainted)
@@ -676,7 +676,7 @@ namespace OpenSim.Region.Environment.Scenes
676 { 676 {
677 for (int y = 0; y < 16; y++) 677 for (int y = 0; y < 16; y++)
678 { 678 {
679 if (Terrain.Tainted(x * 16, y * 16)) 679 if (Terrain.Tainted(x*16, y*16))
680 { 680 {
681 client.SendLayerData(x, y, terData); 681 client.SendLayerData(x, y, terData);
682 } 682 }
@@ -724,13 +724,17 @@ namespace OpenSim.Region.Environment.Scenes
724 724
725 public void ExportWorldMap(string fileName) 725 public void ExportWorldMap(string fileName)
726 { 726 {
727 List<MapBlockData> mapBlocks = this.CommsManager.GridService.RequestNeighbourMapBlocks((int)(this.RegionInfo.RegionLocX - 9), (int)(this.RegionInfo.RegionLocY - 9), (int)(this.RegionInfo.RegionLocX + 9), (int)(this.RegionInfo.RegionLocY + 9)); 727 List<MapBlockData> mapBlocks =
728 CommsManager.GridService.RequestNeighbourMapBlocks((int) (RegionInfo.RegionLocX - 9),
729 (int) (RegionInfo.RegionLocY - 9),
730 (int) (RegionInfo.RegionLocX + 9),
731 (int) (RegionInfo.RegionLocY + 9));
728 List<AssetBase> textures = new List<AssetBase>(); 732 List<AssetBase> textures = new List<AssetBase>();
729 List<System.Drawing.Image> bitImages = new List<System.Drawing.Image>(); 733 List<Image> bitImages = new List<Image>();
730 734
731 foreach (MapBlockData mapBlock in mapBlocks) 735 foreach (MapBlockData mapBlock in mapBlocks)
732 { 736 {
733 AssetBase texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true); 737 AssetBase texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true);
734 738
735 if (texAsset != null) 739 if (texAsset != null)
736 { 740 {
@@ -738,7 +742,7 @@ namespace OpenSim.Region.Environment.Scenes
738 } 742 }
739 else 743 else
740 { 744 {
741 texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true); 745 texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true);
742 if (texAsset != null) 746 if (texAsset != null)
743 { 747 {
744 textures.Add(texAsset); 748 textures.Add(texAsset);
@@ -748,22 +752,22 @@ namespace OpenSim.Region.Environment.Scenes
748 752
749 foreach (AssetBase asset in textures) 753 foreach (AssetBase asset in textures)
750 { 754 {
751 System.Drawing.Image image = OpenJPEGNet.OpenJPEG.DecodeToImage(asset.Data); 755 Image image = OpenJPEG.DecodeToImage(asset.Data);
752 bitImages.Add(image); 756 bitImages.Add(image);
753 } 757 }
754 758
755 System.Drawing.Bitmap mapTexture = new System.Drawing.Bitmap(2560, 2560); 759 Bitmap mapTexture = new Bitmap(2560, 2560);
756 System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(mapTexture); 760 Graphics g = Graphics.FromImage(mapTexture);
757 System.Drawing.SolidBrush sea = new System.Drawing.SolidBrush(System.Drawing.Color.DarkBlue); 761 SolidBrush sea = new SolidBrush(Color.DarkBlue);
758 g.FillRectangle(sea, 0, 0, 2560, 2560); 762 g.FillRectangle(sea, 0, 0, 2560, 2560);
759 763
760 for (int i = 0; i < mapBlocks.Count; i++) 764 for (int i = 0; i < mapBlocks.Count; i++)
761 { 765 {
762 ushort x = (ushort)((mapBlocks[i].X - this.RegionInfo.RegionLocX) + 10); 766 ushort x = (ushort) ((mapBlocks[i].X - RegionInfo.RegionLocX) + 10);
763 ushort y = (ushort)((mapBlocks[i].Y - this.RegionInfo.RegionLocY) + 10); 767 ushort y = (ushort) ((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10);
764 g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128); 768 g.DrawImage(bitImages[i], (x*128), (y*128), 128, 128);
765 } 769 }
766 mapTexture.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg); 770 mapTexture.Save(fileName, ImageFormat.Jpeg);
767 } 771 }
768 772
769 /// <summary> 773 /// <summary>
@@ -861,7 +865,7 @@ namespace OpenSim.Region.Environment.Scenes
861 public void loadAllLandObjectsFromStorage() 865 public void loadAllLandObjectsFromStorage()
862 { 866 {
863 MainLog.Instance.Verbose("SCENE", "Loading land objects from storage"); 867 MainLog.Instance.Verbose("SCENE", "Loading land objects from storage");
864 List<Framework.LandData> landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID); 868 List<LandData> landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID);
865 if (landData.Count == 0) 869 if (landData.Count == 0)
866 { 870 {
867 m_LandManager.NoLandDataFromStorage(); 871 m_LandManager.NoLandDataFromStorage();
@@ -871,7 +875,7 @@ namespace OpenSim.Region.Environment.Scenes
871 m_LandManager.IncomingLandObjectsFromStorage(landData); 875 m_LandManager.IncomingLandObjectsFromStorage(landData);
872 } 876 }
873 } 877 }
874 878
875 #endregion 879 #endregion
876 880
877 #region Primitives Methods 881 #region Primitives Methods
@@ -889,8 +893,8 @@ namespace OpenSim.Region.Environment.Scenes
889 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); 893 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID);
890 rootPart.ApplySanePermissions(); 894 rootPart.ApplySanePermissions();
891 895
892 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); 896 bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim);
893 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 897 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
894 rootPart.PhysActor = PhysicsScene.AddPrimShape( 898 rootPart.PhysActor = PhysicsScene.AddPrimShape(
895 rootPart.Name, 899 rootPart.Name,
896 rootPart.Shape, 900 rootPart.Shape,
@@ -931,9 +935,8 @@ namespace OpenSim.Region.Environment.Scenes
931 935
932 if (PermissionsMngr.CanRezObject(ownerID, pos)) 936 if (PermissionsMngr.CanRezObject(ownerID, pos))
933 { 937 {
934
935 EntityIntersection rayTracing = null; 938 EntityIntersection rayTracing = null;
936 ScenePresence presence = ((ScenePresence)GetScenePresence(ownerID)); 939 ScenePresence presence = ((ScenePresence) GetScenePresence(ownerID));
937 if (presence != null) 940 if (presence != null)
938 { 941 {
939 Vector3 CameraPosition = presence.CameraPosition; 942 Vector3 CameraPosition = presence.CameraPosition;
@@ -941,14 +944,13 @@ namespace OpenSim.Region.Environment.Scenes
941 944
942 float raydistance = m_innerScene.Vector3Distance(CameraPosition, rayEnd); 945 float raydistance = m_innerScene.Vector3Distance(CameraPosition, rayEnd);
943 946
944 Vector3 rayDirection = new Vector3(rayEnd.x / raydistance, rayEnd.y / raydistance, rayEnd.z / raydistance); 947 Vector3 rayDirection = new Vector3(rayEnd.x/raydistance, rayEnd.y/raydistance, rayEnd.z/raydistance);
945 948
946 Ray rezRay = new Ray(CameraPosition, rayDirection); 949 Ray rezRay = new Ray(CameraPosition, rayDirection);
947 950
948 Vector3 RezDirectionFromCamera = rezRay.Direction; 951 Vector3 RezDirectionFromCamera = rezRay.Direction;
949 952
950 rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay); 953 rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay);
951
952 } 954 }
953 955
954 if ((rayTracing != null) && (rayTracing.HitTF)) 956 if ((rayTracing != null) && (rayTracing.HitTF))
@@ -957,7 +959,8 @@ namespace OpenSim.Region.Environment.Scenes
957 // We will rez the object somewhere close to the prim. Better math needed. This is a Stub 959 // We will rez the object somewhere close to the prim. Better math needed. This is a Stub
958 //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z); 960 //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z);
959 Vector3 Newpos = rayTracing.ipoint; 961 Vector3 Newpos = rayTracing.ipoint;
960 Vector3 NewScale = new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); 962 Vector3 NewScale =
963 new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z);
961 964
962 Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation; 965 Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation;
963 //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z); 966 //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z);
@@ -965,7 +968,7 @@ namespace OpenSim.Region.Environment.Scenes
965 LLQuaternion primLocalRot = rayTracing.obj.RotationOffset; 968 LLQuaternion primLocalRot = rayTracing.obj.RotationOffset;
966 Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z); 969 Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z);
967 970
968 Quaternion NewRot = LocalRot * ParentRot; 971 Quaternion NewRot = LocalRot*ParentRot;
969 972
970 Vector3 RezPoint = Newpos; 973 Vector3 RezPoint = Newpos;
971 974
@@ -990,8 +993,8 @@ namespace OpenSim.Region.Environment.Scenes
990 //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; 993 //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom;
991 } 994 }
992 // if not phantom, add to physics 995 // if not phantom, add to physics
993 bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); 996 bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim);
994 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 997 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
995 { 998 {
996 rootPart.PhysActor = 999 rootPart.PhysActor =
997 PhysicsScene.AddPrimShape( 1000 PhysicsScene.AddPrimShape(
@@ -1007,14 +1010,14 @@ namespace OpenSim.Region.Environment.Scenes
1007 } 1010 }
1008 1011
1009 public void AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position, 1012 public void AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position,
1010 Tree treeType, bool newTree) 1013 Tree treeType, bool newTree)
1011 { 1014 {
1012 PrimitiveBaseShape treeShape = new PrimitiveBaseShape(); 1015 PrimitiveBaseShape treeShape = new PrimitiveBaseShape();
1013 treeShape.PathCurve = 16; 1016 treeShape.PathCurve = 16;
1014 treeShape.PathEnd = 49900; 1017 treeShape.PathEnd = 49900;
1015 treeShape.PCode = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree; 1018 treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree;
1016 treeShape.Scale = scale; 1019 treeShape.Scale = scale;
1017 treeShape.State = (byte)treeType; 1020 treeShape.State = (byte) treeType;
1018 AddNewPrim(LLUUID.Random(), position, rotation, treeShape); 1021 AddNewPrim(LLUUID.Random(), position, rotation, treeShape);
1019 } 1022 }
1020 1023
@@ -1135,7 +1138,8 @@ namespace OpenSim.Region.Environment.Scenes
1135 client.OnParcelObjectOwnerRequest += 1138 client.OnParcelObjectOwnerRequest +=
1136 new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest); 1139 new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest);
1137 client.OnParcelAccessListRequest += new ParcelAccessListRequest(m_LandManager.handleParcelAccessRequest); 1140 client.OnParcelAccessListRequest += new ParcelAccessListRequest(m_LandManager.handleParcelAccessRequest);
1138 client.OnParcelAccessListUpdateRequest += new ParcelAccessListUpdateRequest(m_LandManager.handleParcelAccessUpdateRequest); 1141 client.OnParcelAccessListUpdateRequest +=
1142 new ParcelAccessListUpdateRequest(m_LandManager.handleParcelAccessUpdateRequest);
1139 1143
1140 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); 1144 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
1141 client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest; 1145 client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest;
@@ -1157,8 +1161,8 @@ namespace OpenSim.Region.Environment.Scenes
1157 client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest; 1161 client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest;
1158 client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer; 1162 client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer;
1159 client.OnRezScript += RezScript; 1163 client.OnRezScript += RezScript;
1160 1164
1161 client.OnRequestTaskInventory += RequestTaskInventory; 1165 client.OnRequestTaskInventory += RequestTaskInventory;
1162 client.OnRemoveTaskItem += RemoveTaskInventory; 1166 client.OnRemoveTaskItem += RemoveTaskInventory;
1163 client.OnUpdateTaskInventory += UpdateTaskInventory; 1167 client.OnUpdateTaskInventory += UpdateTaskInventory;
1164 1168
@@ -1216,23 +1220,23 @@ namespace OpenSim.Region.Environment.Scenes
1216 m_innerScene.removeUserCount(true); 1220 m_innerScene.removeUserCount(true);
1217 } 1221 }
1218 } 1222 }
1219 catch (System.NullReferenceException) 1223 catch (NullReferenceException)
1220 { 1224 {
1221 // We don't know which count to remove it from 1225 // We don't know which count to remove it from
1222 // Avatar is already disposed :/ 1226 // Avatar is already disposed :/
1223 } 1227 }
1224 m_eventManager.TriggerOnRemovePresence(agentID); 1228 m_eventManager.TriggerOnRemovePresence(agentID);
1225 Broadcast(delegate(IClientAPI client) 1229 Broadcast(delegate(IClientAPI client)
1226 {
1227 try
1228 {
1229 client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
1230 }
1231 catch (System.NullReferenceException)
1232 { 1230 {
1233 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. 1231 try
1234 } 1232 {
1235 }); 1233 client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
1234 }
1235 catch (NullReferenceException)
1236 {
1237 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
1238 }
1239 });
1236 1240
1237 ForEachScenePresence( 1241 ForEachScenePresence(
1238 delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); 1242 delegate(ScenePresence presence) { presence.CoarseLocationChange(); });
@@ -1251,7 +1255,7 @@ namespace OpenSim.Region.Environment.Scenes
1251 { 1255 {
1252 avatar.Close(); 1256 avatar.Close();
1253 } 1257 }
1254 catch (System.NullReferenceException) 1258 catch (NullReferenceException)
1255 { 1259 {
1256 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. 1260 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
1257 } 1261 }
@@ -1263,19 +1267,22 @@ namespace OpenSim.Region.Environment.Scenes
1263 // Remove client agent from profile, so new logins will work 1267 // Remove client agent from profile, so new logins will work
1264 CommsManager.UserService.clearUserAgent(agentID); 1268 CommsManager.UserService.clearUserAgent(agentID);
1265 } 1269 }
1266 public override void CloseAllAgents(uint circuitcode) 1270
1271 public override void CloseAllAgents(uint circuitcode)
1267 { 1272 {
1268 // Called by ClientView to kill all circuit codes 1273 // Called by ClientView to kill all circuit codes
1269 ClientManager.CloseAllAgents(circuitcode); 1274 ClientManager.CloseAllAgents(circuitcode);
1270
1271 } 1275 }
1276
1272 public void NotifyMyCoarseLocationChange() 1277 public void NotifyMyCoarseLocationChange()
1273 { 1278 {
1274 ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); 1279 ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); });
1275 } 1280 }
1281
1276 #endregion 1282 #endregion
1277 1283
1278 #region Entities 1284 #region Entities
1285
1279 /// <summary> 1286 /// <summary>
1280 /// 1287 ///
1281 /// </summary> 1288 /// </summary>
@@ -1312,7 +1319,7 @@ namespace OpenSim.Region.Environment.Scenes
1312 m_sceneGridService.OnCloseAgentConnection += CloseConnection; 1319 m_sceneGridService.OnCloseAgentConnection += CloseConnection;
1313 m_sceneGridService.OnRegionUp += OtherRegionUp; 1320 m_sceneGridService.OnRegionUp += OtherRegionUp;
1314 m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 1321 m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
1315 1322
1316 1323
1317 m_sceneGridService.KillObject = SendKillObject; 1324 m_sceneGridService.KillObject = SendKillObject;
1318 } 1325 }
@@ -1321,17 +1328,16 @@ namespace OpenSim.Region.Environment.Scenes
1321 /// 1328 ///
1322 /// </summary> 1329 /// </summary>
1323 public void UnRegisterReginWithComms() 1330 public void UnRegisterReginWithComms()
1324 { 1331 {
1325
1326 m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 1332 m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
1327 m_sceneGridService.OnRegionUp -= OtherRegionUp; 1333 m_sceneGridService.OnRegionUp -= OtherRegionUp;
1328 m_sceneGridService.OnExpectUser -= NewUserConnection; 1334 m_sceneGridService.OnExpectUser -= NewUserConnection;
1329 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; 1335 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing;
1330 m_sceneGridService.OnCloseAgentConnection -= CloseConnection; 1336 m_sceneGridService.OnCloseAgentConnection -= CloseConnection;
1331 1337
1332 m_sceneGridService.Close(); 1338 m_sceneGridService.Close();
1333 } 1339 }
1334 1340
1335 1341
1336 /// <summary> 1342 /// <summary>
1337 /// 1343 ///
@@ -1344,18 +1350,19 @@ namespace OpenSim.Region.Environment.Scenes
1344 { 1350 {
1345 if (agent.CapsPath != "") 1351 if (agent.CapsPath != "")
1346 { 1352 {
1347 OpenSim.Region.Capabilities.Caps cap = 1353 Caps cap =
1348 new OpenSim.Region.Capabilities.Caps(AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, 1354 new Caps(AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port,
1349 agent.CapsPath, agent.AgentID, m_dumpAssetsToFile); 1355 agent.CapsPath, agent.AgentID, m_dumpAssetsToFile);
1350 1356
1351 Util.SetCapsURL(agent.AgentID, "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + 1357 Util.SetCapsURL(agent.AgentID,
1352 "/CAPS/" + agent.CapsPath + "0000/"); 1358 "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() +
1359 "/CAPS/" + agent.CapsPath + "0000/");
1353 cap.RegisterHandlers(); 1360 cap.RegisterHandlers();
1354 1361
1355 cap.AddNewInventoryItem = AddInventoryItem; 1362 cap.AddNewInventoryItem = AddInventoryItem;
1356 cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; 1363 cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset;
1357 cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset; 1364 cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset;
1358 1365
1359 if (m_capsHandlers.ContainsKey(agent.AgentID)) 1366 if (m_capsHandlers.ContainsKey(agent.AgentID))
1360 { 1367 {
1361 //MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " + 1368 //MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " +
@@ -1364,7 +1371,7 @@ namespace OpenSim.Region.Environment.Scenes
1364 { 1371 {
1365 m_capsHandlers[agent.AgentID] = cap; 1372 m_capsHandlers[agent.AgentID] = cap;
1366 } 1373 }
1367 catch (System.Collections.Generic.KeyNotFoundException) 1374 catch (KeyNotFoundException)
1368 { 1375 {
1369 // Fix for a potential race condition. 1376 // Fix for a potential race condition.
1370 m_capsHandlers.Add(agent.AgentID, cap); 1377 m_capsHandlers.Add(agent.AgentID, cap);
@@ -1396,10 +1403,10 @@ namespace OpenSim.Region.Environment.Scenes
1396 { 1403 {
1397 m_scenePresences[agentID].MakeRootAgent(position, isFlying); 1404 m_scenePresences[agentID].MakeRootAgent(position, isFlying);
1398 } 1405 }
1399 catch (System.Exception e) 1406 catch (Exception e)
1400 { 1407 {
1401 MainLog.Instance.Verbose("SCENE", "Unable to do Agent Crossing."); 1408 MainLog.Instance.Verbose("SCENE", "Unable to do Agent Crossing.");
1402 MainLog.Instance.Debug("SCENE",e.ToString()); 1409 MainLog.Instance.Debug("SCENE", e.ToString());
1403 } 1410 }
1404 //m_innerScene.SwapRootChildAgent(false); 1411 //m_innerScene.SwapRootChildAgent(false);
1405 } 1412 }
@@ -1419,11 +1426,11 @@ namespace OpenSim.Region.Environment.Scenes
1419 childAgentUpdate.ChildAgentDataUpdate(cAgentData); 1426 childAgentUpdate.ChildAgentDataUpdate(cAgentData);
1420 // Not Implemented: 1427 // Not Implemented:
1421 //TODO: Do we need to pass the message on to one of our neighbors? 1428 //TODO: Do we need to pass the message on to one of our neighbors?
1422
1423 } 1429 }
1424 } 1430 }
1425 return true; 1431 return true;
1426 } 1432 }
1433
1427 /// <summary> 1434 /// <summary>
1428 /// Tell a single agent to disconnect from the region. 1435 /// Tell a single agent to disconnect from the region.
1429 /// </summary> 1436 /// </summary>
@@ -1445,7 +1452,7 @@ namespace OpenSim.Region.Environment.Scenes
1445 m_innerScene.removeUserCount(true); 1452 m_innerScene.removeUserCount(true);
1446 } 1453 }
1447 // Tell a single agent to disconnect from the region. 1454 // Tell a single agent to disconnect from the region.
1448 libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); 1455 DisableSimulatorPacket disable = new DisableSimulatorPacket();
1449 presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task); 1456 presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task);
1450 } 1457 }
1451 } 1458 }
@@ -1511,7 +1518,8 @@ namespace OpenSim.Region.Environment.Scenes
1511 { 1518 {
1512 if (m_scenePresences.ContainsKey(remoteClient.AgentId)) 1519 if (m_scenePresences.ContainsKey(remoteClient.AgentId))
1513 { 1520 {
1514 m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle, position, lookAt, flags); 1521 m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle,
1522 position, lookAt, flags);
1515 } 1523 }
1516 } 1524 }
1517 1525
@@ -1551,9 +1559,9 @@ namespace OpenSim.Region.Environment.Scenes
1551 /// <param name="mod"></param> 1559 /// <param name="mod"></param>
1552 public void RegisterModuleInterface<M>(M mod) 1560 public void RegisterModuleInterface<M>(M mod)
1553 { 1561 {
1554 if (!ModuleInterfaces.ContainsKey(typeof(M))) 1562 if (!ModuleInterfaces.ContainsKey(typeof (M)))
1555 { 1563 {
1556 ModuleInterfaces.Add(typeof(M), mod); 1564 ModuleInterfaces.Add(typeof (M), mod);
1557 } 1565 }
1558 } 1566 }
1559 1567
@@ -1563,9 +1571,9 @@ namespace OpenSim.Region.Environment.Scenes
1563 /// <returns></returns> 1571 /// <returns></returns>
1564 public T RequestModuleInterface<T>() 1572 public T RequestModuleInterface<T>()
1565 { 1573 {
1566 if (ModuleInterfaces.ContainsKey(typeof(T))) 1574 if (ModuleInterfaces.ContainsKey(typeof (T)))
1567 { 1575 {
1568 return (T)ModuleInterfaces[typeof(T)]; 1576 return (T) ModuleInterfaces[typeof (T)];
1569 } 1577 }
1570 else 1578 else
1571 { 1579 {
@@ -1642,7 +1650,7 @@ namespace OpenSim.Region.Environment.Scenes
1642 { 1650 {
1643 if (obj is SceneObjectGroup) 1651 if (obj is SceneObjectGroup)
1644 { 1652 {
1645 m_eventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj); 1653 m_eventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj);
1646 } 1654 }
1647 } 1655 }
1648 } 1656 }
@@ -1650,6 +1658,7 @@ namespace OpenSim.Region.Environment.Scenes
1650 #endregion 1658 #endregion
1651 1659
1652 #region Console Commands 1660 #region Console Commands
1661
1653 #region Alert Methods 1662 #region Alert Methods
1654 1663
1655 private void SendPermissionAlert(LLUUID user, string reason) 1664 private void SendPermissionAlert(LLUUID user, string reason)
@@ -1692,7 +1701,8 @@ namespace OpenSim.Region.Environment.Scenes
1692 /// <param name="sessionID"></param> 1701 /// <param name="sessionID"></param>
1693 /// <param name="token"></param> 1702 /// <param name="token"></param>
1694 /// <param name="controllingClient"></param> 1703 /// <param name="controllingClient"></param>
1695 public void handleRequestGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token, IClientAPI controllingClient) 1704 public void handleRequestGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token,
1705 IClientAPI controllingClient)
1696 { 1706 {
1697 // First check that this is the sim owner 1707 // First check that this is the sim owner
1698 if (agentID == RegionInfo.MasterAvatarAssignedUUID) 1708 if (agentID == RegionInfo.MasterAvatarAssignedUUID)
@@ -1736,37 +1746,38 @@ namespace OpenSim.Region.Environment.Scenes
1736 if (agentID == kickUserID) 1746 if (agentID == kickUserID)
1737 { 1747 {
1738 ClientManager.ForEachClient(delegate(IClientAPI controller) 1748 ClientManager.ForEachClient(delegate(IClientAPI controller)
1739 {
1740 ScenePresence p = GetScenePresence(controller.AgentId);
1741 bool childagent = !p.Equals(null) && p.IsChildAgent;
1742 if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness?
1743 { 1749 {
1744 controller.Kick(Helpers.FieldToUTF8String(reason)); 1750 ScenePresence p = GetScenePresence(controller.AgentId);
1745 1751 bool childagent = !p.Equals(null) && p.IsChildAgent;
1746 if (childagent) 1752 if (controller.AgentId != godID && !childagent)
1753 // Do we really want to kick the initiator of this madness?
1747 { 1754 {
1748 m_innerScene.removeUserCount(false); 1755 controller.Kick(Helpers.FieldToUTF8String(reason));
1756
1757 if (childagent)
1758 {
1759 m_innerScene.removeUserCount(false);
1760 }
1761 else
1762 {
1763 m_innerScene.removeUserCount(true);
1764 }
1749 } 1765 }
1750 else
1751 {
1752 m_innerScene.removeUserCount(true);
1753 }
1754
1755 } 1766 }
1756 }
1757 ); 1767 );
1758 // This is a bit crude. It seems the client will be null before it actually stops the thread 1768 // This is a bit crude. It seems the client will be null before it actually stops the thread
1759 // The thread will kill itself eventually :/ 1769 // The thread will kill itself eventually :/
1760 // Is there another way to make sure *all* clients get this 'inter region' message? 1770 // Is there another way to make sure *all* clients get this 'inter region' message?
1761 ClientManager.ForEachClient(delegate(IClientAPI controller) 1771 ClientManager.ForEachClient(delegate(IClientAPI controller)
1762 {
1763 ScenePresence p = GetScenePresence(controller.AgentId);
1764 bool childagent = !p.Equals(null) && p.IsChildAgent;
1765 if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness?
1766 { 1772 {
1767 controller.Close(true); 1773 ScenePresence p = GetScenePresence(controller.AgentId);
1774 bool childagent = !p.Equals(null) && p.IsChildAgent;
1775 if (controller.AgentId != godID && !childagent)
1776 // Do we really want to kick the initiator of this madness?
1777 {
1778 controller.Close(true);
1779 }
1768 } 1780 }
1769 }
1770 ); 1781 );
1771 } 1782 }
1772 else 1783 else
@@ -1799,7 +1810,8 @@ namespace OpenSim.Region.Environment.Scenes
1799 /// <param name="agentID"></param> 1810 /// <param name="agentID"></param>
1800 /// <param name="sessionID"></param> 1811 /// <param name="sessionID"></param>
1801 /// <param name="permChanges"></param> 1812 /// <param name="permChanges"></param>
1802 public void HandleObjectPermissionsUpdate(IClientAPI controller, LLUUID agentID, LLUUID sessionID, List<libsecondlife.Packets.ObjectPermissionsPacket.ObjectDataBlock> permChanges) 1813 public void HandleObjectPermissionsUpdate(IClientAPI controller, LLUUID agentID, LLUUID sessionID,
1814 List<ObjectPermissionsPacket.ObjectDataBlock> permChanges)
1803 { 1815 {
1804 // Check for spoofing.. since this is permissions we're talking about here! 1816 // Check for spoofing.. since this is permissions we're talking about here!
1805 if ((controller.SessionId == sessionID) && (controller.AgentId == agentID)) 1817 if ((controller.SessionId == sessionID) && (controller.AgentId == agentID))
@@ -1879,7 +1891,7 @@ namespace OpenSim.Region.Environment.Scenes
1879 { 1891 {
1880 if (ent is SceneObjectGroup) 1892 if (ent is SceneObjectGroup)
1881 { 1893 {
1882 ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate(); 1894 ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate();
1883 } 1895 }
1884 } 1896 }
1885 } 1897 }
@@ -1899,7 +1911,7 @@ namespace OpenSim.Region.Environment.Scenes
1899 { 1911 {
1900 if (ent is SceneObjectGroup) 1912 if (ent is SceneObjectGroup)
1901 { 1913 {
1902 SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID); 1914 SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart(((SceneObjectGroup) ent).UUID);
1903 if (part != null) 1915 if (part != null)
1904 { 1916 {
1905 if (part.Name == cmdparams[0]) 1917 if (part.Name == cmdparams[0])
@@ -1967,10 +1979,12 @@ namespace OpenSim.Region.Environment.Scenes
1967 { 1979 {
1968 m_eventManager.TriggerOnPluginConsole(args); 1980 m_eventManager.TriggerOnPluginConsole(args);
1969 } 1981 }
1982
1970 public double GetLandHeight(int x, int y) 1983 public double GetLandHeight(int x, int y)
1971 { 1984 {
1972 return Terrain.GetHeight(x, y); 1985 return Terrain.GetHeight(x, y);
1973 } 1986 }
1987
1974 public LLUUID GetLandOwner(float x, float y) 1988 public LLUUID GetLandOwner(float x, float y)
1975 { 1989 {
1976 Land land = LandManager.getLandObject(x, y); 1990 Land land = LandManager.getLandObject(x, y);
@@ -1983,7 +1997,7 @@ namespace OpenSim.Region.Environment.Scenes
1983 return land.landData.ownerID; 1997 return land.landData.ownerID;
1984 } 1998 }
1985 } 1999 }
1986 2000
1987 public LandData GetLandData(float x, float y) 2001 public LandData GetLandData(float x, float y)
1988 { 2002 {
1989 return LandManager.getLandObject(x, y).landData; 2003 return LandManager.getLandObject(x, y).landData;
@@ -2034,6 +2048,7 @@ namespace OpenSim.Region.Environment.Scenes
2034 { 2048 {
2035 return m_innerScene.ConvertLocalIDToFullID(localID); 2049 return m_innerScene.ConvertLocalIDToFullID(localID);
2036 } 2050 }
2051
2037 public void SwapRootAgentCount(bool rootChildChildRootTF) 2052 public void SwapRootAgentCount(bool rootChildChildRootTF)
2038 { 2053 {
2039 m_innerScene.SwapRootChildAgent(rootChildChildRootTF); 2054 m_innerScene.SwapRootChildAgent(rootChildChildRootTF);
@@ -2108,13 +2123,16 @@ namespace OpenSim.Region.Environment.Scenes
2108 // We don't want to try to send messages if there are no avatar. 2123 // We don't want to try to send messages if there are no avatar.
2109 if (!(m_scenePresences.Equals(null))) 2124 if (!(m_scenePresences.Equals(null)))
2110 { 2125 {
2111 try { 2126 try
2112 List<ScenePresence> presenceList = GetScenePresences(); 2127 {
2128 List<ScenePresence> presenceList = GetScenePresences();
2113 foreach (ScenePresence presence in presenceList) 2129 foreach (ScenePresence presence in presenceList)
2114 { 2130 {
2115 action(presence); 2131 action(presence);
2116 } 2132 }
2117 } catch (Exception e) { 2133 }
2134 catch (Exception e)
2135 {
2118 MainLog.Instance.Verbose("BUG", e.ToString()); 2136 MainLog.Instance.Verbose("BUG", e.ToString());
2119 } 2137 }
2120 } 2138 }
@@ -2181,4 +2199,4 @@ namespace OpenSim.Region.Environment.Scenes
2181 2199
2182 #endregion 2200 #endregion
2183 } 2201 }
2184} 2202} \ No newline at end of file