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.cs561
1 files changed, 257 insertions, 304 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 3113831..6617995 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -53,107 +53,99 @@ namespace OpenSim.Region.Environment.Scenes
53 53
54 public partial class Scene : SceneBase 54 public partial class Scene : SceneBase
55 { 55 {
56 public delegate void SynchronizeSceneHandler(Scene scene); 56 #region Delegates
57 public SynchronizeSceneHandler SynchronizeScene = null;
58 public int splitID = 0;
59
60 #region Fields
61 57
62 protected Timer m_heartbeatTimer = new Timer(); 58 public delegate void SynchronizeSceneHandler(Scene scene);
63 protected Timer m_restartWaitTimer = new Timer();
64 59
65 protected SimStatsReporter m_statsReporter; 60 #endregion
66 61
67 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 62 public int splitID;
68 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 63 public SynchronizeSceneHandler SynchronizeScene;
69 64
70 public InnerScene m_innerScene; 65 #region Fields
71 66
72 private Random Rand = new Random();
73 private uint _primCount = 720000;
74 private readonly Mutex _primAllocateMutex = new Mutex(false); 67 private readonly Mutex _primAllocateMutex = new Mutex(false);
75 68
76 private int m_timePhase = 24;
77
78 private readonly Mutex updateLock;
79 public bool m_physicalPrim;
80 public bool m_seeIntoRegionFromNeighbor;
81 public int MaxUndoCount = 5;
82 private int m_RestartTimerCounter;
83 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 69 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
84 private int m_incrementsof15seconds = 0; 70 private readonly Mutex updateLock;
85 71 private uint _primCount = 720000;
86 public string m_simulatorVersion = "OpenSimulator 0.5";
87
88 protected ModuleLoader m_moduleLoader;
89 protected StorageManager m_storageManager;
90 protected AgentCircuitManager m_authenticateHandler;
91 public CommunicationsManager CommsManager; 72 public CommunicationsManager CommsManager;
73 private int frameMS;
74 protected AgentCircuitManager m_authenticateHandler;
92 // protected XferManager xferManager; 75 // protected XferManager xferManager;
93 protected SceneCommunicationService m_sceneGridService; 76 protected IAvatarFactory m_AvatarFactory;
94 protected SceneXmlLoader m_sceneXmlLoader;
95 77
96 /// <summary> 78 /// <summary>
97 /// Each agent has its own capabilities handler. 79 /// Each agent has its own capabilities handler.
98 /// </summary> 80 /// </summary>
99 protected Dictionary<LLUUID, Caps> m_capsHandlers = new Dictionary<LLUUID, Caps>(); 81 protected Dictionary<LLUUID, Caps> m_capsHandlers = new Dictionary<LLUUID, Caps>();
100
101 protected BaseHttpServer m_httpListener;
102
103 protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>();
104 public Dictionary<Type, object> ModuleInterfaces = new Dictionary<Type, object>();
105 protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>();
106 public Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>();
107
108 //API module interfaces
109
110 public IXfer XferManager;
111
112 protected IHttpRequests m_httpRequestModule;
113 protected ISimChat m_simChatModule;
114 protected IXMLRPC m_xmlrpcModule;
115 protected IWorldComm m_worldCommModule;
116 protected IAvatarFactory m_AvatarFactory;
117 82
118 // Central Update Loop 83 // Central Update Loop
119 84
120 protected int m_fps = 10; 85 protected int m_fps = 10;
121 protected int m_frame = 0; 86 protected int m_frame;
122 protected float m_timespan = 0.089f; 87 protected Timer m_heartbeatTimer = new Timer();
88 protected BaseHttpServer m_httpListener;
89 protected IHttpRequests m_httpRequestModule;
90 private int m_incrementsof15seconds;
91 public InnerScene m_innerScene;
123 protected DateTime m_lastupdate = DateTime.Now; 92 protected DateTime m_lastupdate = DateTime.Now;
93 public Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>();
94 protected ModuleLoader m_moduleLoader;
95 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
96 public bool m_physicalPrim;
97 private bool m_physics_enabled = true;
98 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
99 private int m_RestartTimerCounter;
100 protected Timer m_restartWaitTimer = new Timer();
101 protected SceneCommunicationService m_sceneGridService;
102 protected SceneXmlLoader m_sceneXmlLoader;
103 private bool m_scripts_enabled = true;
104 public bool m_seeIntoRegionFromNeighbor;
105 protected ISimChat m_simChatModule;
106 public string m_simulatorVersion = "OpenSimulator 0.5";
107 protected SimStatsReporter m_statsReporter;
108 protected StorageManager m_storageManager;
124 109
125 protected float m_timedilation = 1.0f; 110 protected float m_timedilation = 1.0f;
111 private int m_timePhase = 24;
112 protected float m_timespan = 0.089f;
113 private int m_update_backup = 200;
126 114
127 private int m_update_physics = 1;
128 private int m_update_entitymovement = 1;
129 private int m_update_entities = 1; // Run through all objects checking for updates 115 private int m_update_entities = 1; // Run through all objects checking for updates
130 private int m_update_entitiesquick = 200; // Run through objects that have scheduled updates checking for updates 116 private int m_update_entitiesquick = 200; // Run through objects that have scheduled updates checking for updates
131 private int m_update_presences = 1; // Update scene presence movements 117 private int m_update_entitymovement = 1;
132 private int m_update_events = 1; 118 private int m_update_events = 1;
133 private int m_update_backup = 200;
134 private int m_update_terrain = 50;
135 private int m_update_land = 1; 119 private int m_update_land = 1;
120 private int m_update_physics = 1;
121 private int m_update_presences = 1; // Update scene presence movements
122 private int m_update_terrain = 50;
123 protected IWorldComm m_worldCommModule;
124 protected IXMLRPC m_xmlrpcModule;
125 public int MaxUndoCount = 5;
126 protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>();
127 public Dictionary<Type, object> ModuleInterfaces = new Dictionary<Type, object>();
128 protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>();
136 129
137 private int frameMS = 0; 130 private int otherMS;
138 private int physicsMS2 = 0; 131 private int physicsMS;
139 private int physicsMS = 0; 132 private int physicsMS2;
140 private int otherMS = 0; 133 private Random Rand = new Random();
141 134 public IXfer XferManager;
142 private bool m_physics_enabled = true;
143 private bool m_scripts_enabled = true;
144
145
146 135
147 #endregion 136 #endregion
148 137
149 #region Properties 138 #region Properties
150 139
140 protected readonly EstateManager m_estateManager;
141 protected readonly PermissionManager m_permissionManager;
142 public int objectCapacity = 45000;
143
151 public AgentCircuitManager AuthenticateHandler 144 public AgentCircuitManager AuthenticateHandler
152 { 145 {
153 get { return m_authenticateHandler; } 146 get { return m_authenticateHandler; }
154 } 147 }
155 148
156 protected readonly EstateManager m_estateManager;
157 // an instance to the physics plugin's Scene object. 149 // an instance to the physics plugin's Scene object.
158 public PhysicsScene PhysicsScene 150 public PhysicsScene PhysicsScene
159 { 151 {
@@ -177,7 +169,6 @@ namespace OpenSim.Region.Environment.Scenes
177 get { return m_timedilation; } 169 get { return m_timedilation; }
178 } 170 }
179 171
180 protected readonly PermissionManager m_permissionManager;
181 // This is the instance to the permissions manager. 172 // This is the instance to the permissions manager.
182 // This manages permissions to clients on in world objects 173 // This manages permissions to clients on in world objects
183 174
@@ -215,14 +206,13 @@ namespace OpenSim.Region.Environment.Scenes
215 get { return m_innerScene.Entities; } 206 get { return m_innerScene.Entities; }
216 set { m_innerScene.Entities = value; } 207 set { m_innerScene.Entities = value; }
217 } 208 }
209
218 public Dictionary<LLUUID, ScenePresence> m_restorePresences 210 public Dictionary<LLUUID, ScenePresence> m_restorePresences
219 { 211 {
220 get { return m_innerScene.RestorePresences; } 212 get { return m_innerScene.RestorePresences; }
221 set { m_innerScene.RestorePresences = value; } 213 set { m_innerScene.RestorePresences = value; }
222 } 214 }
223 215
224 public int objectCapacity = 45000;
225
226 #endregion 216 #endregion
227 217
228 #region Constructors 218 #region Constructors
@@ -252,9 +242,9 @@ namespace OpenSim.Region.Environment.Scenes
252 242
253 //Bind Storage Manager functions to some land manager functions for this scene 243 //Bind Storage Manager functions to some land manager functions for this scene
254 EventManager.OnLandObjectAdded += 244 EventManager.OnLandObjectAdded +=
255 new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); 245 m_storageManager.DataStore.StoreLandObject;
256 EventManager.OnLandObjectRemoved += 246 EventManager.OnLandObjectRemoved +=
257 new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); 247 m_storageManager.DataStore.RemoveLandObject;
258 248
259 m_estateManager = new EstateManager(this, m_regInfo); 249 m_estateManager = new EstateManager(this, m_regInfo);
260 250
@@ -321,7 +311,7 @@ namespace OpenSim.Region.Environment.Scenes
321 OSString = OSString.Substring(0, 45); 311 OSString = OSString.Substring(0, 45);
322 } 312 }
323 313
324 m_simulatorVersion = "OpenSimulator v0.5-SVN on " + OSString + " ChilTasks:" + m_seeIntoRegionFromNeighbor.ToString() + " PhysPrim:" + m_physicalPrim.ToString(); 314 m_simulatorVersion = "OpenSimulator v0.5-SVN on " + OSString + " ChilTasks:" + m_seeIntoRegionFromNeighbor + " PhysPrim:" + m_physicalPrim;
325 } 315 }
326 316
327 #endregion 317 #endregion
@@ -382,23 +372,23 @@ namespace OpenSim.Region.Environment.Scenes
382 } 372 }
383 // If these are cast to INT because long + negative values + abs returns invalid data 373 // If these are cast to INT because long + negative values + abs returns invalid data
384 374
385 int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX); 375 int resultX = Math.Abs((int) otherRegion.RegionLocX - (int) RegionInfo.RegionLocX);
386 int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY); 376 int resultY = Math.Abs((int) otherRegion.RegionLocY - (int) RegionInfo.RegionLocY);
387 if ((resultX <= 1) && 377 if ((resultX <= 1) &&
388 (resultY <= 1)) 378 (resultY <= 1))
389 { 379 {
390 try 380 try
391 { 381 {
392 ForEachScenePresence(delegate(ScenePresence agent) 382 ForEachScenePresence(delegate(ScenePresence agent)
393 {
394 // If agent is a root agent.
395 if (!agent.IsChildAgent)
396 { 383 {
397 //agent.ControllingClient.new 384 // If agent is a root agent.
398 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 385 if (!agent.IsChildAgent)
399 InformClientOfNeighbor(agent, otherRegion); 386 {
387 //agent.ControllingClient.new
388 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
389 InformClientOfNeighbor(agent, otherRegion);
390 }
400 } 391 }
401 }
402 ); 392 );
403 } 393 }
404 catch (NullReferenceException) 394 catch (NullReferenceException)
@@ -410,9 +400,9 @@ namespace OpenSim.Region.Environment.Scenes
410 } 400 }
411 else 401 else
412 { 402 {
413 m_log.Info("[INTERGRID]: Got notice about far away Region: " + otherRegion.RegionName.ToString() + 403 m_log.Info("[INTERGRID]: Got notice about far away Region: " + otherRegion.RegionName +
414 " at (" + otherRegion.RegionLocX.ToString() + ", " + 404 " at (" + otherRegion.RegionLocX + ", " +
415 otherRegion.RegionLocY.ToString() + ")"); 405 otherRegion.RegionLocY + ")");
416 } 406 }
417 } 407 }
418 return true; 408 return true;
@@ -436,10 +426,10 @@ namespace OpenSim.Region.Environment.Scenes
436 { 426 {
437 // Now we figure out what to set the timer to that does the notifications and calls, RestartNow() 427 // Now we figure out what to set the timer to that does the notifications and calls, RestartNow()
438 m_restartTimer.Interval = 15000; 428 m_restartTimer.Interval = 15000;
439 m_incrementsof15seconds = (int)seconds / 15; 429 m_incrementsof15seconds = (int) seconds / 15;
440 m_RestartTimerCounter = 0; 430 m_RestartTimerCounter = 0;
441 m_restartTimer.AutoReset = true; 431 m_restartTimer.AutoReset = true;
442 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); 432 m_restartTimer.Elapsed += RestartTimer_Elapsed;
443 m_log.Error("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); 433 m_log.Error("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
444 m_restartTimer.Start(); 434 m_restartTimer.Start();
445 SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes"); 435 SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes");
@@ -458,7 +448,7 @@ namespace OpenSim.Region.Environment.Scenes
458 { 448 {
459 if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7) 449 if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7)
460 SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " + 450 SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " +
461 ((8 - m_RestartTimerCounter) * 15) + " seconds"); 451 ((8 - m_RestartTimerCounter) * 15) + " seconds");
462 452
463 // SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) + 453 // SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) +
464 //" seconds"); 454 //" seconds");
@@ -500,15 +490,15 @@ namespace OpenSim.Region.Environment.Scenes
500 try 490 try
501 { 491 {
502 ForEachScenePresence(delegate(ScenePresence agent) 492 ForEachScenePresence(delegate(ScenePresence agent)
503 {
504 // If agent is a root agent.
505 if (!agent.IsChildAgent)
506 { 493 {
507 //agent.ControllingClient.new 494 // If agent is a root agent.
508 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 495 if (!agent.IsChildAgent)
509 InformClientOfNeighbor(agent, region); 496 {
497 //agent.ControllingClient.new
498 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
499 InformClientOfNeighbor(agent, region);
500 }
510 } 501 }
511 }
512 ); 502 );
513 } 503 }
514 catch (NullReferenceException) 504 catch (NullReferenceException)
@@ -537,7 +527,7 @@ namespace OpenSim.Region.Environment.Scenes
537 { 527 {
538 if (ent is SceneObjectGroup) 528 if (ent is SceneObjectGroup)
539 { 529 {
540 ((SceneObjectGroup)ent).StopScripts(); 530 ((SceneObjectGroup) ent).StopScripts();
541 } 531 }
542 } 532 }
543 } 533 }
@@ -551,12 +541,10 @@ namespace OpenSim.Region.Environment.Scenes
551 { 541 {
552 if (ent is SceneObjectGroup) 542 if (ent is SceneObjectGroup)
553 { 543 {
554 ((SceneObjectGroup)ent).StartScripts(); 544 ((SceneObjectGroup) ent).StartScripts();
555 } 545 }
556 } 546 }
557 } 547 }
558
559
560 } 548 }
561 m_scripts_enabled = !ScriptEngine; 549 m_scripts_enabled = !ScriptEngine;
562 m_log.Info("[TOTEDD]: Here is the method to trigger disabling of the scripting engine"); 550 m_log.Info("[TOTEDD]: Here is the method to trigger disabling of the scripting engine");
@@ -564,9 +552,7 @@ namespace OpenSim.Region.Environment.Scenes
564 if (m_physics_enabled != !PhysicsEngine) 552 if (m_physics_enabled != !PhysicsEngine)
565 { 553 {
566 m_physics_enabled = !PhysicsEngine; 554 m_physics_enabled = !PhysicsEngine;
567
568 } 555 }
569
570 } 556 }
571 557
572 // This is the method that shuts down the scene. 558 // This is the method that shuts down the scene.
@@ -575,16 +561,16 @@ namespace OpenSim.Region.Environment.Scenes
575 m_log.Warn("[SCENE]: Closing down the single simulator: " + RegionInfo.RegionName); 561 m_log.Warn("[SCENE]: Closing down the single simulator: " + RegionInfo.RegionName);
576 // Kick all ROOT agents with the message, 'The simulator is going down' 562 // Kick all ROOT agents with the message, 'The simulator is going down'
577 ForEachScenePresence(delegate(ScenePresence avatar) 563 ForEachScenePresence(delegate(ScenePresence avatar)
578 { 564 {
579 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) 565 if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle))
580 avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle); 566 avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle);
581 567
582 if (!avatar.IsChildAgent) 568 if (!avatar.IsChildAgent)
583 avatar.ControllingClient.Kick("The simulator is going down."); 569 avatar.ControllingClient.Kick("The simulator is going down.");
584 570
585 avatar.ControllingClient.OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), 571 avatar.ControllingClient.OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator),
586 ThrottleOutPacketType.Task); 572 ThrottleOutPacketType.Task);
587 }); 573 });
588 574
589 // Wait here, or the kick messages won't actually get to the agents before the scene terminates. 575 // Wait here, or the kick messages won't actually get to the agents before the scene terminates.
590 Thread.Sleep(500); 576 Thread.Sleep(500);
@@ -619,8 +605,8 @@ namespace OpenSim.Region.Environment.Scenes
619 { 605 {
620 m_log.Debug("[SCENE]: Starting timer"); 606 m_log.Debug("[SCENE]: Starting timer");
621 m_heartbeatTimer.Enabled = true; 607 m_heartbeatTimer.Enabled = true;
622 m_heartbeatTimer.Interval = (int)(m_timespan * 1000); 608 m_heartbeatTimer.Interval = (int) (m_timespan * 1000);
623 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 609 m_heartbeatTimer.Elapsed += Heartbeat;
624 } 610 }
625 611
626 public void SetModuleInterfaces() 612 public void SetModuleInterfaces()
@@ -722,13 +708,13 @@ namespace OpenSim.Region.Environment.Scenes
722 { 708 {
723 if (m_frame % m_update_events == 0) 709 if (m_frame % m_update_events == 0)
724 UpdateEvents(); 710 UpdateEvents();
725 711
726 if (m_frame % m_update_backup == 0) 712 if (m_frame % m_update_backup == 0)
727 UpdateStorageBackup(); 713 UpdateStorageBackup();
728 714
729 if (m_frame % m_update_terrain == 0) 715 if (m_frame % m_update_terrain == 0)
730 UpdateTerrain(); 716 UpdateTerrain();
731 717
732 if (m_frame % m_update_land == 0) 718 if (m_frame % m_update_land == 0)
733 UpdateLand(); 719 UpdateLand();
734 otherMS = System.Environment.TickCount - otherMS; 720 otherMS = System.Environment.TickCount - otherMS;
@@ -756,28 +742,25 @@ namespace OpenSim.Region.Environment.Scenes
756 } 742 }
757 catch (AccessViolationException e) 743 catch (AccessViolationException e)
758 { 744 {
759 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 745 m_log.Error("[Scene]: Failed with exception " + e + " On Region: " + RegionInfo.RegionName);
760
761 } 746 }
762 catch (NullReferenceException e) 747 catch (NullReferenceException e)
763 { 748 {
764 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 749 m_log.Error("[Scene]: Failed with exception " + e + " On Region: " + RegionInfo.RegionName);
765
766 } 750 }
767 catch (InvalidOperationException e) 751 catch (InvalidOperationException e)
768 { 752 {
769 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 753 m_log.Error("[Scene]: Failed with exception " + e + " On Region: " + RegionInfo.RegionName);
770
771 } 754 }
772 catch (Exception e) 755 catch (Exception e)
773 { 756 {
774 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 757 m_log.Error("[Scene]: Failed with exception " + e + " On Region: " + RegionInfo.RegionName);
775 } 758 }
776 finally 759 finally
777 { 760 {
778 updateLock.ReleaseMutex(); 761 updateLock.ReleaseMutex();
779 // Get actual time dilation 762 // Get actual time dilation
780 float tmpval = (m_timespan / (float)SinceLastFrame.TotalSeconds); 763 float tmpval = (m_timespan / (float) SinceLastFrame.TotalSeconds);
781 764
782 // If actual time dilation is greater then one, we're catching up, so subtract 765 // If actual time dilation is greater then one, we're catching up, so subtract
783 // the amount that's greater then 1 from the time dilation 766 // the amount that's greater then 1 from the time dilation
@@ -786,7 +769,7 @@ namespace OpenSim.Region.Environment.Scenes
786 tmpval = tmpval - (tmpval - 1.0f); 769 tmpval = tmpval - (tmpval - 1.0f);
787 } 770 }
788 m_timedilation = tmpval; 771 m_timedilation = tmpval;
789 772
790 m_lastupdate = DateTime.Now; 773 m_lastupdate = DateTime.Now;
791 } 774 }
792 } 775 }
@@ -856,10 +839,10 @@ namespace OpenSim.Region.Environment.Scenes
856 public void ExportWorldMap(string fileName) 839 public void ExportWorldMap(string fileName)
857 { 840 {
858 List<MapBlockData> mapBlocks = 841 List<MapBlockData> mapBlocks =
859 m_sceneGridService.RequestNeighbourMapBlocks((int)(RegionInfo.RegionLocX - 9), 842 m_sceneGridService.RequestNeighbourMapBlocks((int) (RegionInfo.RegionLocX - 9),
860 (int)(RegionInfo.RegionLocY - 9), 843 (int) (RegionInfo.RegionLocY - 9),
861 (int)(RegionInfo.RegionLocX + 9), 844 (int) (RegionInfo.RegionLocX + 9),
862 (int)(RegionInfo.RegionLocY + 9)); 845 (int) (RegionInfo.RegionLocY + 9));
863 List<AssetBase> textures = new List<AssetBase>(); 846 List<AssetBase> textures = new List<AssetBase>();
864 List<Image> bitImages = new List<Image>(); 847 List<Image> bitImages = new List<Image>();
865 848
@@ -894,8 +877,8 @@ namespace OpenSim.Region.Environment.Scenes
894 877
895 for (int i = 0; i < mapBlocks.Count; i++) 878 for (int i = 0; i < mapBlocks.Count; i++)
896 { 879 {
897 ushort x = (ushort)((mapBlocks[i].X - RegionInfo.RegionLocX) + 10); 880 ushort x = (ushort) ((mapBlocks[i].X - RegionInfo.RegionLocX) + 10);
898 ushort y = (ushort)((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10); 881 ushort y = (ushort) ((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10);
899 g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128); 882 g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128);
900 } 883 }
901 mapTexture.Save(fileName, ImageFormat.Jpeg); 884 mapTexture.Save(fileName, ImageFormat.Jpeg);
@@ -926,11 +909,10 @@ namespace OpenSim.Region.Environment.Scenes
926 { 909 {
927 Heightmap = new TerrainChannel(map); 910 Heightmap = new TerrainChannel(map);
928 } 911 }
929
930 } 912 }
931 catch (Exception e) 913 catch (Exception e)
932 { 914 {
933 m_log.Warn("[terrain]: Scene.cs: LoadWorldMap() - Failed with exception " + e.ToString()); 915 m_log.Warn("[terrain]: Scene.cs: LoadWorldMap() - Failed with exception " + e);
934 } 916 }
935 } 917 }
936 918
@@ -991,7 +973,7 @@ namespace OpenSim.Region.Environment.Scenes
991 { 973 {
992 for (int y = 0; y < 256; y++) 974 for (int y = 0; y < 256; y++)
993 { 975 {
994 float hmval = (float)hm[x, y]; 976 float hmval = (float) hm[x, y];
995 if (hmval < low) 977 if (hmval < low)
996 low = hmval; 978 low = hmval;
997 if (hmval > high) 979 if (hmval > high)
@@ -1021,10 +1003,10 @@ namespace OpenSim.Region.Environment.Scenes
1021 //} 1003 //}
1022 //else 1004 //else
1023 //{ 1005 //{
1024 float tmpval = (float)hm[x, y]; 1006 float tmpval = (float) hm[x, y];
1025 heightvalue = (float)hm[x, y]; 1007 heightvalue = (float) hm[x, y];
1026 1008
1027 if ((float)heightvalue > m_regInfo.EstateSettings.waterHeight) 1009 if (heightvalue > m_regInfo.EstateSettings.waterHeight)
1028 { 1010 {
1029 // scale height value 1011 // scale height value
1030 heightvalue = low + mid * (heightvalue - low) / mid; 1012 heightvalue = low + mid * (heightvalue - low) / mid;
@@ -1036,7 +1018,7 @@ namespace OpenSim.Region.Environment.Scenes
1036 heightvalue = 0; 1018 heightvalue = 0;
1037 1019
1038 1020
1039 Color green = Color.FromArgb((int)heightvalue, 100, (int)heightvalue); 1021 Color green = Color.FromArgb((int) heightvalue, 100, (int) heightvalue);
1040 1022
1041 // Y flip the cordinates 1023 // Y flip the cordinates
1042 mapbmp.SetPixel(x, (256 - y) - 1, green); 1024 mapbmp.SetPixel(x, (256 - y) - 1, green);
@@ -1058,12 +1040,10 @@ namespace OpenSim.Region.Environment.Scenes
1058 if (heightvalue < 0) 1040 if (heightvalue < 0)
1059 heightvalue = 0; 1041 heightvalue = 0;
1060 1042
1061 Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255); 1043 Color water = Color.FromArgb((int) heightvalue, (int) heightvalue, 255);
1062 mapbmp.SetPixel(x, (256 - y) - 1, water); 1044 mapbmp.SetPixel(x, (256 - y) - 1, water);
1063 } 1045 }
1064 //} 1046 //}
1065
1066
1067 } 1047 }
1068 //tc = System.Environment.TickCount - tc; 1048 //tc = System.Environment.TickCount - tc;
1069 //m_log.Info("[MAPTILE]: Completed One row in " + tc + " ms"); 1049 //m_log.Info("[MAPTILE]: Completed One row in " + tc + " ms");
@@ -1087,7 +1067,6 @@ namespace OpenSim.Region.Environment.Scenes
1087 asset.Type = 0; 1067 asset.Type = 0;
1088 asset.Temporary = temporary; 1068 asset.Temporary = temporary;
1089 AssetCache.AddAsset(asset); 1069 AssetCache.AddAsset(asset);
1090
1091 } 1070 }
1092 else 1071 else
1093 { 1072 {
@@ -1105,7 +1084,6 @@ namespace OpenSim.Region.Environment.Scenes
1105 AssetCache.AddAsset(asset); 1084 AssetCache.AddAsset(asset);
1106 } 1085 }
1107 } 1086 }
1108
1109 } 1087 }
1110 1088
1111 #endregion 1089 #endregion
@@ -1143,14 +1121,14 @@ namespace OpenSim.Region.Environment.Scenes
1143 { 1121 {
1144 AddEntityFromStorage(group); 1122 AddEntityFromStorage(group);
1145 SceneObjectPart rootPart = group.GetChildPart(group.UUID); 1123 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
1146 rootPart.ObjectFlags &= ~(uint)LLObject.ObjectFlags.Scripted; 1124 rootPart.ObjectFlags &= ~(uint) LLObject.ObjectFlags.Scripted;
1147 rootPart.TrimPermissions(); 1125 rootPart.TrimPermissions();
1148 1126
1149 group.ApplyPhysics(m_physicalPrim); 1127 group.ApplyPhysics(m_physicalPrim);
1150 //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); 1128 //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
1151 } 1129 }
1152 1130
1153 m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); 1131 m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count + " SceneObject(s)");
1154 } 1132 }
1155 1133
1156 /// <summary> 1134 /// <summary>
@@ -1169,10 +1147,11 @@ namespace OpenSim.Region.Environment.Scenes
1169 return myID; 1147 return myID;
1170 } 1148 }
1171 1149
1172 public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, LLVector3 scale, bool FaceCenter) 1150 public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast,
1151 byte RayEndIsIntersection, bool frontFacesOnly, LLVector3 scale, bool FaceCenter)
1173 { 1152 {
1174 LLVector3 pos = LLVector3.Zero; 1153 LLVector3 pos = LLVector3.Zero;
1175 if (RayEndIsIntersection == (byte)1) 1154 if (RayEndIsIntersection == 1)
1176 { 1155 {
1177 pos = RayEnd; 1156 pos = RayEnd;
1178 return pos; 1157 return pos;
@@ -1180,7 +1159,7 @@ namespace OpenSim.Region.Environment.Scenes
1180 if (RayTargetID != LLUUID.Zero) 1159 if (RayTargetID != LLUUID.Zero)
1181 { 1160 {
1182 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1161 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1183 1162
1184 LLVector3 direction = LLVector3.Norm(RayEnd - RayStart); 1163 LLVector3 direction = LLVector3.Norm(RayEnd - RayStart);
1185 Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z); 1164 Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z);
1186 Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z); 1165 Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z);
@@ -1189,17 +1168,17 @@ namespace OpenSim.Region.Environment.Scenes
1189 { 1168 {
1190 pos = target.AbsolutePosition; 1169 pos = target.AbsolutePosition;
1191 //m_log.Info("[OBJECT_REZ]: TargetPos: " + pos.ToString() + ", RayStart: " + RayStart.ToString() + ", RayEnd: " + RayEnd.ToString() + ", Volume: " + Util.GetDistanceTo(RayStart,RayEnd).ToString() + ", mag1: " + Util.GetMagnitude(RayStart).ToString() + ", mag2: " + Util.GetMagnitude(RayEnd).ToString()); 1170 //m_log.Info("[OBJECT_REZ]: TargetPos: " + pos.ToString() + ", RayStart: " + RayStart.ToString() + ", RayEnd: " + RayEnd.ToString() + ", Volume: " + Util.GetDistanceTo(RayStart,RayEnd).ToString() + ", mag1: " + Util.GetMagnitude(RayStart).ToString() + ", mag2: " + Util.GetMagnitude(RayEnd).ToString());
1192 1171
1193 // TODO: Raytrace better here 1172 // TODO: Raytrace better here
1194 1173
1195 //EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection)); 1174 //EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection));
1196 Ray NewRay = new Ray(AXOrigin, AXdirection); 1175 Ray NewRay = new Ray(AXOrigin, AXdirection);
1197 1176
1198 // Ray Trace against target here 1177 // Ray Trace against target here
1199 EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1,0,0,0), frontFacesOnly, FaceCenter); 1178 EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, FaceCenter);
1200 1179
1201 // Un-comment out the following line to Get Raytrace results printed to the console. 1180 // Un-comment out the following line to Get Raytrace results printed to the console.
1202 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1181 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1203 float ScaleOffset = 0.5f; 1182 float ScaleOffset = 0.5f;
1204 1183
1205 // If we hit something 1184 // If we hit something
@@ -1215,13 +1194,12 @@ namespace OpenSim.Region.Environment.Scenes
1215 // Set the position to the intersection point 1194 // Set the position to the intersection point
1216 LLVector3 offset = (normal * (ScaleOffset / 2f)); 1195 LLVector3 offset = (normal * (ScaleOffset / 2f));
1217 pos = (intersectionpoint + offset); 1196 pos = (intersectionpoint + offset);
1218 1197
1219 // Un-offset the prim (it gets offset later by the consumer method) 1198 // Un-offset the prim (it gets offset later by the consumer method)
1220 pos.Z -= 0.25F; 1199 pos.Z -= 0.25F;
1221 1200 }
1222 } 1201
1223 1202
1224
1225 return pos; 1203 return pos;
1226 } 1204 }
1227 else 1205 else
@@ -1236,8 +1214,8 @@ namespace OpenSim.Region.Environment.Scenes
1236 if (ei.HitTF) 1214 if (ei.HitTF)
1237 { 1215 {
1238 pos = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); 1216 pos = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z);
1239 } 1217 }
1240 1218
1241 return pos; 1219 return pos;
1242 } 1220 }
1243 } 1221 }
@@ -1253,8 +1231,8 @@ namespace OpenSim.Region.Environment.Scenes
1253 byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID, 1231 byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID,
1254 byte RayEndIsIntersection) 1232 byte RayEndIsIntersection)
1255 { 1233 {
1256 1234 LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new LLVector3(0.5f, 0.5f, 0.5f),
1257 LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new LLVector3(0.5f,0.5f,0.5f), false); 1235 false);
1258 1236
1259 if (PermissionsMngr.CanRezObject(ownerID, pos)) 1237 if (PermissionsMngr.CanRezObject(ownerID, pos))
1260 { 1238 {
@@ -1274,7 +1252,7 @@ namespace OpenSim.Region.Environment.Scenes
1274 SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); 1252 SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
1275 // if grass or tree, make phantom 1253 // if grass or tree, make phantom
1276 //rootPart.TrimPermissions(); 1254 //rootPart.TrimPermissions();
1277 if ((rootPart.Shape.PCode == (byte)PCode.Grass) || (rootPart.Shape.PCode == (byte)PCode.Tree) || (rootPart.Shape.PCode == (byte)PCode.NewTree)) 1255 if ((rootPart.Shape.PCode == (byte) PCode.Grass) || (rootPart.Shape.PCode == (byte) PCode.Tree) || (rootPart.Shape.PCode == (byte) PCode.NewTree))
1278 { 1256 {
1279 rootPart.AddFlag(LLObject.ObjectFlags.Phantom); 1257 rootPart.AddFlag(LLObject.ObjectFlags.Phantom);
1280 //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; 1258 //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom;
@@ -1289,13 +1267,13 @@ namespace OpenSim.Region.Environment.Scenes
1289 public SceneObjectGroup AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position, 1267 public SceneObjectGroup AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position,
1290 Tree treeType, bool newTree) 1268 Tree treeType, bool newTree)
1291 { 1269 {
1292 LLUUID uuid = this.RegionInfo.MasterAvatarAssignedUUID; 1270 LLUUID uuid = RegionInfo.MasterAvatarAssignedUUID;
1293 PrimitiveBaseShape treeShape = new PrimitiveBaseShape(); 1271 PrimitiveBaseShape treeShape = new PrimitiveBaseShape();
1294 treeShape.PathCurve = 16; 1272 treeShape.PathCurve = 16;
1295 treeShape.PathEnd = 49900; 1273 treeShape.PathEnd = 49900;
1296 treeShape.PCode = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree; 1274 treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree;
1297 treeShape.Scale = scale; 1275 treeShape.Scale = scale;
1298 treeShape.State = (byte)treeType; 1276 treeShape.State = (byte) treeType;
1299 return AddNewPrim(uuid, position, rotation, treeShape); 1277 return AddNewPrim(uuid, position, rotation, treeShape);
1300 } 1278 }
1301 1279
@@ -1360,12 +1338,11 @@ namespace OpenSim.Region.Environment.Scenes
1360 /// </summary> 1338 /// </summary>
1361 /// <param name="position">current position of Group</param> 1339 /// <param name="position">current position of Group</param>
1362 /// <param name="grp">Scene Object Group that we're crossing</param> 1340 /// <param name="grp">Scene Object Group that we're crossing</param>
1363
1364 public void CrossPrimGroupIntoNewRegion(LLVector3 position, SceneObjectGroup grp) 1341 public void CrossPrimGroupIntoNewRegion(LLVector3 position, SceneObjectGroup grp)
1365 { 1342 {
1366 m_log.Warn("Prim crossing: " + grp.UUID.ToString()); 1343 m_log.Warn("Prim crossing: " + grp.UUID);
1367 int thisx = (int)RegionInfo.RegionLocX; 1344 int thisx = (int) RegionInfo.RegionLocX;
1368 int thisy = (int)RegionInfo.RegionLocY; 1345 int thisy = (int) RegionInfo.RegionLocY;
1369 1346
1370 ulong newRegionHandle = 0; 1347 ulong newRegionHandle = 0;
1371 LLVector3 pos = position; 1348 LLVector3 pos = position;
@@ -1374,43 +1351,44 @@ namespace OpenSim.Region.Environment.Scenes
1374 { 1351 {
1375 pos.X = ((pos.X - Constants.RegionSize)); 1352 pos.X = ((pos.X - Constants.RegionSize));
1376 1353
1377 newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); 1354 newRegionHandle = Util.UIntsToLong((uint) ((thisx + 1) * Constants.RegionSize), (uint) (thisy * Constants.RegionSize));
1378 1355
1379 // x + 1 1356 // x + 1
1380 } 1357 }
1381 else if (position.X < -0.1f) 1358 else if (position.X < -0.1f)
1382 { 1359 {
1383 pos.X = ((pos.X + Constants.RegionSize)); 1360 pos.X = ((pos.X + Constants.RegionSize));
1384 newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); 1361 newRegionHandle = Util.UIntsToLong((uint) ((thisx - 1) * Constants.RegionSize), (uint) (thisy * Constants.RegionSize));
1385 // x - 1 1362 // x - 1
1386 } 1363 }
1387 1364
1388 if (position.Y > Constants.RegionSize + 0.1f) 1365 if (position.Y > Constants.RegionSize + 0.1f)
1389 { 1366 {
1390 pos.Y = ((pos.Y - Constants.RegionSize)); 1367 pos.Y = ((pos.Y - Constants.RegionSize));
1391 newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); 1368 newRegionHandle = Util.UIntsToLong((uint) (thisx * Constants.RegionSize), (uint) ((thisy + 1) * Constants.RegionSize));
1392 // y + 1 1369 // y + 1
1393 } 1370 }
1394 else if (position.Y < -1f) 1371 else if (position.Y < -1f)
1395 { 1372 {
1396 pos.Y = ((pos.Y + Constants.RegionSize)); 1373 pos.Y = ((pos.Y + Constants.RegionSize));
1397 newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize)); 1374 newRegionHandle = Util.UIntsToLong((uint) (thisx * Constants.RegionSize), (uint) ((thisy - 1) * Constants.RegionSize));
1398 // y - 1 1375 // y - 1
1399 } 1376 }
1400 1377
1401 // Offset the positions for the new region across the border 1378 // Offset the positions for the new region across the border
1402 grp.OffsetForNewRegion(pos); 1379 grp.OffsetForNewRegion(pos);
1403
1404 CrossPrimGroupIntoNewRegion(newRegionHandle, grp);
1405 1380
1381 CrossPrimGroupIntoNewRegion(newRegionHandle, grp);
1406 } 1382 }
1383
1407 public void CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp) 1384 public void CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp)
1408 { 1385 {
1409 int primcrossingXMLmethod = 0; 1386 int primcrossingXMLmethod = 0;
1410 if (newRegionHandle != 0) 1387 if (newRegionHandle != 0)
1411 { 1388 {
1412 bool successYN = false; 1389 bool successYN = false;
1413 successYN = m_sceneGridService.PrimCrossToNeighboringRegion(newRegionHandle, grp.UUID, m_sceneXmlLoader.SavePrimGroupToXML2String(grp), primcrossingXMLmethod); 1390 successYN = m_sceneGridService.PrimCrossToNeighboringRegion(newRegionHandle, grp.UUID, m_sceneXmlLoader.SavePrimGroupToXML2String(grp),
1391 primcrossingXMLmethod);
1414 if (successYN) 1392 if (successYN)
1415 { 1393 {
1416 // We remove the object here 1394 // We remove the object here
@@ -1446,7 +1424,7 @@ namespace OpenSim.Region.Environment.Scenes
1446 SceneObjectPart RootPrim = GetSceneObjectPart(primID); 1424 SceneObjectPart RootPrim = GetSceneObjectPart(primID);
1447 if (RootPrim != null) 1425 if (RootPrim != null)
1448 { 1426 {
1449 if (RootPrim.Shape.PCode == (byte)PCode.Prim) 1427 if (RootPrim.Shape.PCode == (byte) PCode.Prim)
1450 { 1428 {
1451 SceneObjectGroup grp = RootPrim.ParentGroup; 1429 SceneObjectGroup grp = RootPrim.ParentGroup;
1452 if (grp != null) 1430 if (grp != null)
@@ -1462,12 +1440,10 @@ namespace OpenSim.Region.Environment.Scenes
1462 // with the deeded object, it goes back to them 1440 // with the deeded object, it goes back to them
1463 1441
1464 grp.SetFromAssetID(grp.RootPart.LastOwnerID); 1442 grp.SetFromAssetID(grp.RootPart.LastOwnerID);
1465 m_innerScene.AttachObject(sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition); 1443 m_innerScene.AttachObject(sp.ControllingClient, grp.LocalId, 0, grp.GroupRotation, grp.AbsolutePosition);
1466 } 1444 }
1467 } 1445 }
1468 } 1446 }
1469
1470
1471 } 1447 }
1472 } 1448 }
1473 return true; 1449 return true;
@@ -1476,7 +1452,6 @@ namespace OpenSim.Region.Environment.Scenes
1476 { 1452 {
1477 return false; 1453 return false;
1478 } 1454 }
1479
1480 } 1455 }
1481 1456
1482 #endregion 1457 #endregion
@@ -1491,9 +1466,9 @@ namespace OpenSim.Region.Environment.Scenes
1491 public override void AddNewClient(IClientAPI client, bool child) 1466 public override void AddNewClient(IClientAPI client, bool child)
1492 { 1467 {
1493 m_log.DebugFormat( 1468 m_log.DebugFormat(
1494 "[CONNECTION DEBUGGING]: Creating new client for {0} at {1}", 1469 "[CONNECTION DEBUGGING]: Creating new client for {0} at {1}",
1495 client.AgentId, RegionInfo.RegionName); 1470 client.AgentId, RegionInfo.RegionName);
1496 1471
1497 SubscribeToClientEvents(client); 1472 SubscribeToClientEvents(client);
1498 ScenePresence presence = null; 1473 ScenePresence presence = null;
1499 1474
@@ -1563,19 +1538,19 @@ namespace OpenSim.Region.Environment.Scenes
1563 client.OnObjectDuplicateOnRay += doObjectDuplicateOnRay; 1538 client.OnObjectDuplicateOnRay += doObjectDuplicateOnRay;
1564 client.OnUpdatePrimFlags += m_innerScene.UpdatePrimFlags; 1539 client.OnUpdatePrimFlags += m_innerScene.UpdatePrimFlags;
1565 client.OnRequestObjectPropertiesFamily += m_innerScene.RequestObjectPropertiesFamily; 1540 client.OnRequestObjectPropertiesFamily += m_innerScene.RequestObjectPropertiesFamily;
1566 client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(LandChannel.handleParcelPropertiesRequest); 1541 client.OnParcelPropertiesRequest += LandChannel.handleParcelPropertiesRequest;
1567 client.OnParcelDivideRequest += new ParcelDivideRequest(LandChannel.handleParcelDivideRequest); 1542 client.OnParcelDivideRequest += LandChannel.handleParcelDivideRequest;
1568 client.OnParcelJoinRequest += new ParcelJoinRequest(LandChannel.handleParcelJoinRequest); 1543 client.OnParcelJoinRequest += LandChannel.handleParcelJoinRequest;
1569 client.OnParcelPropertiesUpdateRequest += 1544 client.OnParcelPropertiesUpdateRequest +=
1570 new ParcelPropertiesUpdateRequest(LandChannel.handleParcelPropertiesUpdateRequest); 1545 LandChannel.handleParcelPropertiesUpdateRequest;
1571 client.OnParcelSelectObjects += new ParcelSelectObjects(LandChannel.handleParcelSelectObjectsRequest); 1546 client.OnParcelSelectObjects += LandChannel.handleParcelSelectObjectsRequest;
1572 client.OnParcelObjectOwnerRequest += 1547 client.OnParcelObjectOwnerRequest +=
1573 new ParcelObjectOwnerRequest(LandChannel.handleParcelObjectOwnersRequest); 1548 LandChannel.handleParcelObjectOwnersRequest;
1574 client.OnParcelAccessListRequest += new ParcelAccessListRequest(LandChannel.handleParcelAccessRequest); 1549 client.OnParcelAccessListRequest += LandChannel.handleParcelAccessRequest;
1575 client.OnParcelAccessListUpdateRequest += 1550 client.OnParcelAccessListUpdateRequest +=
1576 new ParcelAccessListUpdateRequest(LandChannel.handleParcelAccessUpdateRequest); 1551 LandChannel.handleParcelAccessUpdateRequest;
1577 1552
1578 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); 1553 client.OnEstateOwnerMessage += m_estateManager.handleEstateOwnerMessage;
1579 client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest; 1554 client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest;
1580 client.OnEstateCovenantRequest += m_estateManager.HandleEstateCovenantRequest; 1555 client.OnEstateCovenantRequest += m_estateManager.HandleEstateCovenantRequest;
1581 client.OnRequestGodlikePowers += handleRequestGodlikePowers; 1556 client.OnRequestGodlikePowers += handleRequestGodlikePowers;
@@ -1616,41 +1591,38 @@ namespace OpenSim.Region.Environment.Scenes
1616 1591
1617 client.OnSetStartLocationRequest += SetHomeRezPoint; 1592 client.OnSetStartLocationRequest += SetHomeRezPoint;
1618 client.OnUndo += m_innerScene.HandleUndo; 1593 client.OnUndo += m_innerScene.HandleUndo;
1619 1594
1620 EventManager.TriggerOnNewClient(client); 1595 EventManager.TriggerOnNewClient(client);
1621 } 1596 }
1597
1622 public virtual void TeleportClientHome(LLUUID AgentId, IClientAPI client) 1598 public virtual void TeleportClientHome(LLUUID AgentId, IClientAPI client)
1623 { 1599 {
1624 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(AgentId); 1600 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(AgentId);
1625 if (UserProfile != null) 1601 if (UserProfile != null)
1626 { 1602 {
1627 ulong homeRegion = UserProfile.HomeRegion; 1603 ulong homeRegion = UserProfile.HomeRegion;
1628 LLVector3 homePostion = new LLVector3(UserProfile.HomeLocationX,UserProfile.HomeLocationY,UserProfile.HomeLocationZ); 1604 LLVector3 homePostion = new LLVector3(UserProfile.HomeLocationX, UserProfile.HomeLocationY, UserProfile.HomeLocationZ);
1629 LLVector3 homeLookat = new LLVector3(UserProfile.HomeLookAt); 1605 LLVector3 homeLookat = new LLVector3(UserProfile.HomeLookAt);
1630 RequestTeleportLocation(client, homeRegion, homePostion,homeLookat,(uint)0); 1606 RequestTeleportLocation(client, homeRegion, homePostion, homeLookat, 0);
1631
1632 } 1607 }
1633
1634
1635 } 1608 }
1609
1636 public void doObjectDuplicateOnRay(uint localID, uint dupeFlags, LLUUID AgentID, LLUUID GroupID, 1610 public void doObjectDuplicateOnRay(uint localID, uint dupeFlags, LLUUID AgentID, LLUUID GroupID,
1637 LLUUID RayTargetObj, LLVector3 RayEnd, LLVector3 RayStart, 1611 LLUUID RayTargetObj, LLVector3 RayEnd, LLVector3 RayStart,
1638 bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates) 1612 bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates)
1639 { 1613 {
1640
1641 LLVector3 pos = LLVector3.Zero; 1614 LLVector3 pos = LLVector3.Zero;
1642 bool frontFacesOnly = true; 1615 bool frontFacesOnly = true;
1643 1616
1644 SceneObjectPart target = GetSceneObjectPart(localID); 1617 SceneObjectPart target = GetSceneObjectPart(localID);
1645 1618
1646 if (target != null) 1619 if (target != null)
1647 { 1620 {
1648
1649 LLVector3 direction = LLVector3.Norm(RayEnd - RayStart); 1621 LLVector3 direction = LLVector3.Norm(RayEnd - RayStart);
1650 Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z); 1622 Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z);
1651 Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z); 1623 Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z);
1652 1624
1653 1625
1654 if (target != null) 1626 if (target != null)
1655 { 1627 {
1656 if (target.ParentGroup != null) 1628 if (target.ParentGroup != null)
@@ -1680,9 +1652,8 @@ namespace OpenSim.Region.Environment.Scenes
1680 if (scaleComponent.Z != 0) ScaleOffset = scale.Z; 1652 if (scaleComponent.Z != 0) ScaleOffset = scale.Z;
1681 ScaleOffset = Math.Abs(ScaleOffset); 1653 ScaleOffset = Math.Abs(ScaleOffset);
1682 LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); 1654 LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z);
1683 1655
1684 1656
1685
1686 if (CopyCenters) 1657 if (CopyCenters)
1687 { 1658 {
1688 // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal. 1659 // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal.
@@ -1694,7 +1665,7 @@ namespace OpenSim.Region.Environment.Scenes
1694 if (ei2.HitTF) 1665 if (ei2.HitTF)
1695 { 1666 {
1696 //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString()); 1667 //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString());
1697 pos = new LLVector3(ei2.ipoint.x,ei2.ipoint.y,ei2.ipoint.z); 1668 pos = new LLVector3(ei2.ipoint.x, ei2.ipoint.y, ei2.ipoint.z);
1698 } 1669 }
1699 } 1670 }
1700 LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z); 1671 LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z);
@@ -1707,18 +1678,14 @@ namespace OpenSim.Region.Environment.Scenes
1707 m_innerScene.DuplicateObject(target.ParentGroup.LocalId, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID); 1678 m_innerScene.DuplicateObject(target.ParentGroup.LocalId, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID);
1708 } 1679 }
1709 1680
1710 1681
1711 return; 1682 return;
1712 } 1683 }
1713 return; 1684 return;
1714 } 1685 }
1715
1716 } 1686 }
1717
1718
1719
1720
1721 } 1687 }
1688
1722 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags) 1689 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags)
1723 { 1690 {
1724 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); 1691 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId);
@@ -1731,22 +1698,22 @@ namespace OpenSim.Region.Environment.Scenes
1731 // We cast these to an int so as not to cause a breaking change with old regions 1698 // We cast these to an int so as not to cause a breaking change with old regions
1732 // Newer regions treat this as a float on the ExpectUser method.. so we need to wait a few 1699 // Newer regions treat this as a float on the ExpectUser method.. so we need to wait a few
1733 // releases before setting these to floats. (r4257) 1700 // releases before setting these to floats. (r4257)
1734 UserProfile.HomeLocationX = (int)position.X; 1701 UserProfile.HomeLocationX = (int) position.X;
1735 UserProfile.HomeLocationY = (int)position.Y; 1702 UserProfile.HomeLocationY = (int) position.Y;
1736 UserProfile.HomeLocationZ = (int)position.Z; 1703 UserProfile.HomeLocationZ = (int) position.Z;
1737 UserProfile.HomeLookAtX = (int)lookAt.X; 1704 UserProfile.HomeLookAtX = (int) lookAt.X;
1738 UserProfile.HomeLookAtY = (int)lookAt.Y; 1705 UserProfile.HomeLookAtY = (int) lookAt.Y;
1739 UserProfile.HomeLookAtZ = (int)lookAt.Z; 1706 UserProfile.HomeLookAtZ = (int) lookAt.Z;
1740 CommsManager.UserService.UpdateUserProfileProperties(UserProfile); 1707 CommsManager.UserService.UpdateUserProfileProperties(UserProfile);
1741 1708
1742 remoteClient.SendAgentAlertMessage("Set home to here if supported by login service",false); 1709 remoteClient.SendAgentAlertMessage("Set home to here if supported by login service", false);
1743 } 1710 }
1744 else 1711 else
1745 { 1712 {
1746 remoteClient.SendAgentAlertMessage("Set Home request Failed",false); 1713 remoteClient.SendAgentAlertMessage("Set Home request Failed", false);
1747 } 1714 }
1748
1749 } 1715 }
1716
1750 protected virtual ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child) 1717 protected virtual ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child)
1751 { 1718 {
1752 ScenePresence avatar = null; 1719 ScenePresence avatar = null;
@@ -1812,7 +1779,7 @@ namespace OpenSim.Region.Environment.Scenes
1812 m_sceneGridService.SendCloseChildAgentConnections(agentID, childknownRegions); 1779 m_sceneGridService.SendCloseChildAgentConnections(agentID, childknownRegions);
1813 1780
1814 RemoveCapsHandler(agentID); 1781 RemoveCapsHandler(agentID);
1815 1782
1816 CommsManager.UserProfileCacheService.RemoveUser(agentID); 1783 CommsManager.UserProfileCacheService.RemoveUser(agentID);
1817 } 1784 }
1818 1785
@@ -1825,21 +1792,21 @@ namespace OpenSim.Region.Environment.Scenes
1825 } 1792 }
1826 m_eventManager.TriggerOnRemovePresence(agentID); 1793 m_eventManager.TriggerOnRemovePresence(agentID);
1827 Broadcast(delegate(IClientAPI client) 1794 Broadcast(delegate(IClientAPI client)
1828 {
1829 try
1830 {
1831 client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
1832 }
1833 catch (NullReferenceException)
1834 { 1795 {
1835 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. 1796 try
1836 } 1797 {
1837 }); 1798 client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
1799 }
1800 catch (NullReferenceException)
1801 {
1802 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
1803 }
1804 });
1838 1805
1839 ForEachScenePresence( 1806 ForEachScenePresence(
1840 delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); 1807 delegate(ScenePresence presence) { presence.CoarseLocationChange(); });
1841 1808
1842 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); 1809 IAgentAssetTransactions agentTransactions = RequestModuleInterface<IAgentAssetTransactions>();
1843 if (agentTransactions != null) 1810 if (agentTransactions != null)
1844 { 1811 {
1845 agentTransactions.RemoveAgentAssetTransactions(agentID); 1812 agentTransactions.RemoveAgentAssetTransactions(agentID);
@@ -1879,7 +1846,7 @@ namespace OpenSim.Region.Environment.Scenes
1879 } 1846 }
1880 catch (Exception e) 1847 catch (Exception e)
1881 { 1848 {
1882 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 1849 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e);
1883 } 1850 }
1884 1851
1885 // Remove client agent from profile, so new logins will work 1852 // Remove client agent from profile, so new logins will work
@@ -1899,14 +1866,12 @@ namespace OpenSim.Region.Environment.Scenes
1899 { 1866 {
1900 lock (av) 1867 lock (av)
1901 { 1868 {
1902
1903 for (int i = 0; i < regionslst.Count; i++) 1869 for (int i = 0; i < regionslst.Count; i++)
1904 { 1870 {
1905 av.KnownChildRegions.Remove(regionslst[i]); 1871 av.KnownChildRegions.Remove(regionslst[i]);
1906 } 1872 }
1907 } 1873 }
1908 } 1874 }
1909
1910 } 1875 }
1911 1876
1912 public override void CloseAllAgents(uint circuitcode) 1877 public override void CloseAllAgents(uint circuitcode)
@@ -1994,7 +1959,7 @@ namespace OpenSim.Region.Environment.Scenes
1994 if (regionHandle == m_regInfo.RegionHandle) 1959 if (regionHandle == m_regInfo.RegionHandle)
1995 { 1960 {
1996 capsPaths[agent.AgentID] = agent.CapsPath; 1961 capsPaths[agent.AgentID] = agent.CapsPath;
1997 1962
1998 if (!agent.child) 1963 if (!agent.child)
1999 { 1964 {
2000 AddCapsHandler(agent.AgentID); 1965 AddCapsHandler(agent.AgentID);
@@ -2003,26 +1968,26 @@ namespace OpenSim.Region.Environment.Scenes
2003 ILandObject land = LandChannel.getLandObject(agent.startpos.X, agent.startpos.Y); 1968 ILandObject land = LandChannel.getLandObject(agent.startpos.X, agent.startpos.Y);
2004 if (land != null) 1969 if (land != null)
2005 { 1970 {
2006 if (land.landData.landingType == (byte)1 && land.landData.userLocation != LLVector3.Zero) 1971 if (land.landData.landingType == 1 && land.landData.userLocation != LLVector3.Zero)
2007 { 1972 {
2008 agent.startpos = land.landData.userLocation; 1973 agent.startpos = land.landData.userLocation;
2009 } 1974 }
2010 } 1975 }
2011 } 1976 }
2012 1977
2013 m_log.DebugFormat( 1978 m_log.DebugFormat(
2014 "[CONNECTION DEBUGGING]: Creating new circuit code ({0}) for avatar {1} at {2}", 1979 "[CONNECTION DEBUGGING]: Creating new circuit code ({0}) for avatar {1} at {2}",
2015 agent.circuitcode, agent.AgentID, RegionInfo.RegionName); 1980 agent.circuitcode, agent.AgentID, RegionInfo.RegionName);
2016 1981
2017 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 1982 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
2018 } 1983 }
2019 else 1984 else
2020 { 1985 {
2021 m_log.WarnFormat( 1986 m_log.WarnFormat(
2022 "[CONNECTION DEBUGGING]: Skipping this region for welcoming avatar {0} [{1}] at {2}", 1987 "[CONNECTION DEBUGGING]: Skipping this region for welcoming avatar {0} [{1}] at {2}",
2023 agent.AgentID, regionHandle, RegionInfo.RegionName); 1988 agent.AgentID, regionHandle, RegionInfo.RegionName);
2024 } 1989 }
2025 } 1990 }
2026 1991
2027 /// <summary> 1992 /// <summary>
2028 /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent, 1993 /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent,
@@ -2035,18 +2000,18 @@ namespace OpenSim.Region.Environment.Scenes
2035 /// <param name="agentId"></param> 2000 /// <param name="agentId"></param>
2036 /// <param name="capsObjectPath"></param> 2001 /// <param name="capsObjectPath"></param>
2037 public void AddCapsHandler(LLUUID agentId) 2002 public void AddCapsHandler(LLUUID agentId)
2038 { 2003 {
2039 String capsObjectPath = GetCapsPath(agentId); 2004 String capsObjectPath = GetCapsPath(agentId);
2040 2005
2041 m_log.DebugFormat( 2006 m_log.DebugFormat(
2042 "[CAPS]: Setting up CAPS handler for root agent {0} in {1}", 2007 "[CAPS]: Setting up CAPS handler for root agent {0} in {1}",
2043 agentId, RegionInfo.RegionName); 2008 agentId, RegionInfo.RegionName);
2044 2009
2045 Caps cap = 2010 Caps cap =
2046 new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port, 2011 new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port,
2047 capsObjectPath, agentId, m_dumpAssetsToFile, RegionInfo.RegionName); 2012 capsObjectPath, agentId, m_dumpAssetsToFile, RegionInfo.RegionName);
2048 cap.RegisterHandlers(); 2013 cap.RegisterHandlers();
2049 2014
2050 EventManager.TriggerOnRegisterCaps(agentId, cap); 2015 EventManager.TriggerOnRegisterCaps(agentId, cap);
2051 2016
2052 cap.AddNewInventoryItem = AddInventoryItem; 2017 cap.AddNewInventoryItem = AddInventoryItem;
@@ -2055,7 +2020,7 @@ namespace OpenSim.Region.Environment.Scenes
2055 cap.CAPSFetchInventoryDescendents = CommsManager.UserProfileCacheService.HandleFetchInventoryDescendentsCAPS; 2020 cap.CAPSFetchInventoryDescendents = CommsManager.UserProfileCacheService.HandleFetchInventoryDescendentsCAPS;
2056 cap.GetClient = m_innerScene.GetControllingClient; 2021 cap.GetClient = m_innerScene.GetControllingClient;
2057 m_capsHandlers[agentId] = cap; 2022 m_capsHandlers[agentId] = cap;
2058 } 2023 }
2059 2024
2060 /// <summary> 2025 /// <summary>
2061 /// Remove the caps handler for a given agent. 2026 /// Remove the caps handler for a given agent.
@@ -2068,9 +2033,9 @@ namespace OpenSim.Region.Environment.Scenes
2068 if (m_capsHandlers.ContainsKey(agentId)) 2033 if (m_capsHandlers.ContainsKey(agentId))
2069 { 2034 {
2070 m_log.DebugFormat( 2035 m_log.DebugFormat(
2071 "[CAPS]: Removing CAPS handler for root agent {0} in {1}", 2036 "[CAPS]: Removing CAPS handler for root agent {0} in {1}",
2072 agentId, RegionInfo.RegionName); 2037 agentId, RegionInfo.RegionName);
2073 2038
2074 m_capsHandlers[agentId].DeregisterHandlers(); 2039 m_capsHandlers[agentId].DeregisterHandlers();
2075 EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]); 2040 EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]);
2076 2041
@@ -2105,7 +2070,7 @@ namespace OpenSim.Region.Environment.Scenes
2105 catch (Exception e) 2070 catch (Exception e)
2106 { 2071 {
2107 m_log.Info("[SCENE]: Unable to do Agent Crossing."); 2072 m_log.Info("[SCENE]: Unable to do Agent Crossing.");
2108 m_log.Debug("[SCENE]: " + e.ToString()); 2073 m_log.Debug("[SCENE]: " + e);
2109 } 2074 }
2110 //m_innerScene.SwapRootChildAgent(false); 2075 //m_innerScene.SwapRootChildAgent(false);
2111 } 2076 }
@@ -2121,15 +2086,14 @@ namespace OpenSim.Region.Environment.Scenes
2121 // however to avoid a race condition crossing borders.. 2086 // however to avoid a race condition crossing borders..
2122 if (childAgentUpdate.IsChildAgent) 2087 if (childAgentUpdate.IsChildAgent)
2123 { 2088 {
2124 uint rRegionX = (uint)(cAgentData.regionHandle >> 40); 2089 uint rRegionX = (uint) (cAgentData.regionHandle >> 40);
2125 uint rRegionY = (((uint)(cAgentData.regionHandle)) >> 8); 2090 uint rRegionY = (((uint) (cAgentData.regionHandle)) >> 8);
2126 uint tRegionX = RegionInfo.RegionLocX; 2091 uint tRegionX = RegionInfo.RegionLocX;
2127 uint tRegionY = RegionInfo.RegionLocY; 2092 uint tRegionY = RegionInfo.RegionLocY;
2128 //Send Data to ScenePresence 2093 //Send Data to ScenePresence
2129 childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); 2094 childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY);
2130 // Not Implemented: 2095 // Not Implemented:
2131 //TODO: Do we need to pass the message on to one of our neighbors? 2096 //TODO: Do we need to pass the message on to one of our neighbors?
2132
2133 } 2097 }
2134 return true; 2098 return true;
2135 } 2099 }
@@ -2157,7 +2121,7 @@ namespace OpenSim.Region.Environment.Scenes
2157 m_innerScene.removeUserCount(true); 2121 m_innerScene.removeUserCount(true);
2158 } 2122 }
2159 // Tell a single agent to disconnect from the region. 2123 // Tell a single agent to disconnect from the region.
2160 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator); 2124 DisableSimulatorPacket disable = (DisableSimulatorPacket) PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
2161 presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Unknown); 2125 presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Unknown);
2162 presence.ControllingClient.Close(true); 2126 presence.ControllingClient.Close(true);
2163 } 2127 }
@@ -2307,9 +2271,9 @@ namespace OpenSim.Region.Environment.Scenes
2307 /// <param name="mod"></param> 2271 /// <param name="mod"></param>
2308 public void RegisterModuleInterface<M>(M mod) 2272 public void RegisterModuleInterface<M>(M mod)
2309 { 2273 {
2310 if (!ModuleInterfaces.ContainsKey(typeof(M))) 2274 if (!ModuleInterfaces.ContainsKey(typeof (M)))
2311 { 2275 {
2312 ModuleInterfaces.Add(typeof(M), mod); 2276 ModuleInterfaces.Add(typeof (M), mod);
2313 } 2277 }
2314 } 2278 }
2315 2279
@@ -2319,9 +2283,9 @@ namespace OpenSim.Region.Environment.Scenes
2319 /// <returns></returns> 2283 /// <returns></returns>
2320 public T RequestModuleInterface<T>() 2284 public T RequestModuleInterface<T>()
2321 { 2285 {
2322 if (ModuleInterfaces.ContainsKey(typeof(T))) 2286 if (ModuleInterfaces.ContainsKey(typeof (T)))
2323 { 2287 {
2324 return (T)ModuleInterfaces[typeof(T)]; 2288 return (T) ModuleInterfaces[typeof (T)];
2325 } 2289 }
2326 else 2290 else
2327 { 2291 {
@@ -2336,14 +2300,12 @@ namespace OpenSim.Region.Environment.Scenes
2336 m_statsReporter.SetObjectCapacity(objects); 2300 m_statsReporter.SetObjectCapacity(objects);
2337 } 2301 }
2338 objectCapacity = objects; 2302 objectCapacity = objects;
2339
2340 } 2303 }
2341 2304
2342 public List<FriendListItem> GetFriendList(LLUUID avatarID) 2305 public List<FriendListItem> GetFriendList(LLUUID avatarID)
2343 { 2306 {
2344 return CommsManager.GetUserFriendList(avatarID); 2307 return CommsManager.GetUserFriendList(avatarID);
2345 } 2308 }
2346
2347 2309
2348 #endregion 2310 #endregion
2349 2311
@@ -2378,7 +2340,8 @@ namespace OpenSim.Region.Environment.Scenes
2378 } 2340 }
2379 } 2341 }
2380 2342
2381 public void SendDialogToUser(LLUUID avatarID, string objectName, LLUUID objectID, LLUUID ownerID, string message, LLUUID TextureID, int ch, string[] buttonlabels) 2343 public void SendDialogToUser(LLUUID avatarID, string objectName, LLUUID objectID, LLUUID ownerID, string message, LLUUID TextureID, int ch,
2344 string[] buttonlabels)
2382 { 2345 {
2383 if (m_scenePresences.ContainsKey(avatarID)) 2346 if (m_scenePresences.ContainsKey(avatarID))
2384 { 2347 {
@@ -2401,7 +2364,7 @@ namespace OpenSim.Region.Environment.Scenes
2401 } 2364 }
2402 return LLUUID.Zero; 2365 return LLUUID.Zero;
2403 } 2366 }
2404 2367
2405 2368
2406 /// <summary> 2369 /// <summary>
2407 /// This method is a way for the Friends Module to create an instant 2370 /// This method is a way for the Friends Module to create an instant
@@ -2436,6 +2399,7 @@ namespace OpenSim.Region.Environment.Scenes
2436 // TODO: m_sceneGridService.DoStuff; 2399 // TODO: m_sceneGridService.DoStuff;
2437 m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID); 2400 m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID);
2438 } 2401 }
2402
2439 public virtual List<FriendListItem> StoreGetFriendsForUser(LLUUID ownerID) 2403 public virtual List<FriendListItem> StoreGetFriendsForUser(LLUUID ownerID)
2440 { 2404 {
2441 // TODO: m_sceneGridService.DoStuff; 2405 // TODO: m_sceneGridService.DoStuff;
@@ -2448,11 +2412,13 @@ namespace OpenSim.Region.Environment.Scenes
2448 m_statsReporter.AddOutPackets(outPackets); 2412 m_statsReporter.AddOutPackets(outPackets);
2449 m_statsReporter.AddunAckedBytes(unAckedBytes); 2413 m_statsReporter.AddunAckedBytes(unAckedBytes);
2450 } 2414 }
2415
2451 public void AddAgentTime(int ms) 2416 public void AddAgentTime(int ms)
2452 { 2417 {
2453 m_statsReporter.addFrameMS(ms); 2418 m_statsReporter.addFrameMS(ms);
2454 m_statsReporter.addAgentMS(ms); 2419 m_statsReporter.addAgentMS(ms);
2455 } 2420 }
2421
2456 public void AddAgentUpdates(int count) 2422 public void AddAgentUpdates(int count)
2457 { 2423 {
2458 m_statsReporter.AddAgentUpdates(count); 2424 m_statsReporter.AddAgentUpdates(count);
@@ -2546,7 +2512,6 @@ namespace OpenSim.Region.Environment.Scenes
2546 /// <param name="Message">The Message being sent to the user</param> 2512 /// <param name="Message">The Message being sent to the user</param>
2547 public void SendRegionMessageFromEstateTools(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message) 2513 public void SendRegionMessageFromEstateTools(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message)
2548 { 2514 {
2549
2550 List<ScenePresence> presenceList = GetScenePresences(); 2515 List<ScenePresence> presenceList = GetScenePresences();
2551 2516
2552 foreach (ScenePresence presence in presenceList) 2517 foreach (ScenePresence presence in presenceList)
@@ -2566,11 +2531,7 @@ namespace OpenSim.Region.Environment.Scenes
2566 /// <param name="Message">The Message being sent to the user</param> 2531 /// <param name="Message">The Message being sent to the user</param>
2567 public void SendEstateMessageFromEstateTools(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message) 2532 public void SendEstateMessageFromEstateTools(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message)
2568 { 2533 {
2569 2534 ClientManager.ForEachClient(delegate(IClientAPI controller) { controller.SendBlueBoxMessage(FromAvatarID, fromSessionID, FromAvatarName, Message); }
2570 ClientManager.ForEachClient(delegate(IClientAPI controller)
2571 {
2572 controller.SendBlueBoxMessage(FromAvatarID, fromSessionID, FromAvatarName, Message);
2573 }
2574 ); 2535 );
2575 } 2536 }
2576 2537
@@ -2596,27 +2557,24 @@ namespace OpenSim.Region.Environment.Scenes
2596 if (agentID == kickUserID) 2557 if (agentID == kickUserID)
2597 { 2558 {
2598 ClientManager.ForEachClient(delegate(IClientAPI controller) 2559 ClientManager.ForEachClient(delegate(IClientAPI controller)
2599 { 2560 {
2600 if (controller.AgentId != godID) 2561 if (controller.AgentId != godID)
2601 controller.Kick(Helpers.FieldToUTF8String(reason)); 2562 controller.Kick(Helpers.FieldToUTF8String(reason));
2602 2563 }
2603
2604
2605 }
2606 ); 2564 );
2607 // This is a bit crude. It seems the client will be null before it actually stops the thread 2565 // This is a bit crude. It seems the client will be null before it actually stops the thread
2608 // The thread will kill itself eventually :/ 2566 // The thread will kill itself eventually :/
2609 // Is there another way to make sure *all* clients get this 'inter region' message? 2567 // Is there another way to make sure *all* clients get this 'inter region' message?
2610 ClientManager.ForEachClient(delegate(IClientAPI controller) 2568 ClientManager.ForEachClient(delegate(IClientAPI controller)
2611 {
2612 ScenePresence p = GetScenePresence(controller.AgentId);
2613 bool childagent = !p.Equals(null) && p.IsChildAgent;
2614 if (controller.AgentId != godID && !childagent)
2615 // Do we really want to kick the initiator of this madness?
2616 { 2569 {
2617 controller.Close(true); 2570 ScenePresence p = GetScenePresence(controller.AgentId);
2571 bool childagent = !p.Equals(null) && p.IsChildAgent;
2572 if (controller.AgentId != godID && !childagent)
2573 // Do we really want to kick the initiator of this madness?
2574 {
2575 controller.Close(true);
2576 }
2618 } 2577 }
2619 }
2620 ); 2578 );
2621 } 2579 }
2622 else 2580 else
@@ -2647,7 +2605,6 @@ namespace OpenSim.Region.Environment.Scenes
2647 // Check for spoofing.. since this is permissions we're talking about here! 2605 // Check for spoofing.. since this is permissions we're talking about here!
2648 if ((controller.SessionId == sessionID) && (controller.AgentId == agentID)) 2606 if ((controller.SessionId == sessionID) && (controller.AgentId == agentID))
2649 { 2607 {
2650
2651 // Tell the object to do permission update 2608 // Tell the object to do permission update
2652 if (localId != 0) 2609 if (localId != 0)
2653 { 2610 {
@@ -2657,7 +2614,6 @@ namespace OpenSim.Region.Environment.Scenes
2657 chObjectGroup.UpdatePermissions(agentID, field, localId, mask, set); 2614 chObjectGroup.UpdatePermissions(agentID, field, localId, mask, set);
2658 } 2615 }
2659 } 2616 }
2660
2661 } 2617 }
2662 } 2618 }
2663 2619
@@ -2723,7 +2679,7 @@ namespace OpenSim.Region.Environment.Scenes
2723 { 2679 {
2724 if (ent is SceneObjectGroup) 2680 if (ent is SceneObjectGroup)
2725 { 2681 {
2726 ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate(); 2682 ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate();
2727 } 2683 }
2728 } 2684 }
2729 } 2685 }
@@ -2743,7 +2699,7 @@ namespace OpenSim.Region.Environment.Scenes
2743 { 2699 {
2744 if (ent is SceneObjectGroup) 2700 if (ent is SceneObjectGroup)
2745 { 2701 {
2746 SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID); 2702 SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart((ent).UUID);
2747 if (part != null) 2703 if (part != null)
2748 { 2704 {
2749 if (part.Name == cmdparams[0]) 2705 if (part.Name == cmdparams[0])
@@ -2867,8 +2823,8 @@ namespace OpenSim.Region.Environment.Scenes
2867 2823
2868 #region Script Engine 2824 #region Script Engine
2869 2825
2870 private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>(); 2826 private readonly bool m_dumpAssetsToFile;
2871 private bool m_dumpAssetsToFile; 2827 private readonly List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>();
2872 2828
2873 /// <summary> 2829 /// <summary>
2874 /// 2830 ///
@@ -2882,13 +2838,11 @@ namespace OpenSim.Region.Environment.Scenes
2882 2838
2883 public void TriggerObjectChanged(uint localID, uint change) 2839 public void TriggerObjectChanged(uint localID, uint change)
2884 { 2840 {
2885
2886 m_eventManager.TriggerOnScriptChangedEvent(localID, change); 2841 m_eventManager.TriggerOnScriptChangedEvent(localID, change);
2887 } 2842 }
2888 2843
2889 public void TriggerAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 currentpos) 2844 public void TriggerAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 currentpos)
2890 { 2845 {
2891
2892 m_eventManager.TriggerAtTargetEvent(localID, handle, targetpos, currentpos); 2846 m_eventManager.TriggerAtTargetEvent(localID, handle, targetpos, currentpos);
2893 } 2847 }
2894 2848
@@ -2897,20 +2851,21 @@ namespace OpenSim.Region.Environment.Scenes
2897 m_eventManager.TriggerNotAtTargetEvent(localID); 2851 m_eventManager.TriggerNotAtTargetEvent(localID);
2898 } 2852 }
2899 2853
2900 private bool scriptDanger(SceneObjectPart part,LLVector3 pos) 2854 private bool scriptDanger(SceneObjectPart part, LLVector3 pos)
2901 { 2855 {
2902 ILandObject parcel = LandChannel.getLandObject(pos.X, pos.Y); 2856 ILandObject parcel = LandChannel.getLandObject(pos.X, pos.Y);
2903 if (part != null) 2857 if (part != null)
2904 { 2858 {
2905 if (parcel != null) 2859 if (parcel != null)
2906 { 2860 {
2907 if ((parcel.landData.landFlags & (uint)Parcel.ParcelFlags.AllowOtherScripts) != 0) 2861 if ((parcel.landData.landFlags & (uint) Parcel.ParcelFlags.AllowOtherScripts) != 0)
2908 { 2862 {
2909 return true; 2863 return true;
2910 } 2864 }
2911 else if ((parcel.landData.landFlags & (uint)Parcel.ParcelFlags.AllowGroupScripts) != 0) 2865 else if ((parcel.landData.landFlags & (uint) Parcel.ParcelFlags.AllowGroupScripts) != 0)
2912 { 2866 {
2913 if (part.OwnerID == parcel.landData.ownerID || (parcel.landData.isGroupOwned && part.GroupID == parcel.landData.groupID) || PermissionsMngr.GenericEstatePermission(part.OwnerID)) 2867 if (part.OwnerID == parcel.landData.ownerID || (parcel.landData.isGroupOwned && part.GroupID == parcel.landData.groupID) ||
2868 PermissionsMngr.GenericEstatePermission(part.OwnerID))
2914 { 2869 {
2915 return true; 2870 return true;
2916 } 2871 }
@@ -2918,7 +2873,7 @@ namespace OpenSim.Region.Environment.Scenes
2918 { 2873 {
2919 return false; 2874 return false;
2920 } 2875 }
2921 } 2876 }
2922 else 2877 else
2923 { 2878 {
2924 if (part.OwnerID == parcel.landData.ownerID) 2879 if (part.OwnerID == parcel.landData.ownerID)
@@ -2933,7 +2888,6 @@ namespace OpenSim.Region.Environment.Scenes
2933 } 2888 }
2934 else 2889 else
2935 { 2890 {
2936
2937 if (pos.X > 0f && pos.X < Constants.RegionSize && pos.Y > 0f && pos.Y < Constants.RegionSize) 2891 if (pos.X > 0f && pos.X < Constants.RegionSize && pos.Y > 0f && pos.Y < Constants.RegionSize)
2938 { 2892 {
2939 // The only time parcel != null when an object is inside a region is when 2893 // The only time parcel != null when an object is inside a region is when
@@ -2952,6 +2906,7 @@ namespace OpenSim.Region.Environment.Scenes
2952 return false; 2906 return false;
2953 } 2907 }
2954 } 2908 }
2909
2955 public bool scriptDanger(uint localID, LLVector3 pos) 2910 public bool scriptDanger(uint localID, LLVector3 pos)
2956 { 2911 {
2957 SceneObjectPart part = GetSceneObjectPart(localID); 2912 SceneObjectPart part = GetSceneObjectPart(localID);
@@ -2967,13 +2922,11 @@ namespace OpenSim.Region.Environment.Scenes
2967 2922
2968 public bool pipeEventsForScript(uint localID) 2923 public bool pipeEventsForScript(uint localID)
2969 { 2924 {
2970
2971 SceneObjectPart part = GetSceneObjectPart(localID); 2925 SceneObjectPart part = GetSceneObjectPart(localID);
2972 if (part != null) 2926 if (part != null)
2973 { 2927 {
2974 LLVector3 pos = part.GetWorldPosition(); 2928 LLVector3 pos = part.GetWorldPosition();
2975 return scriptDanger(part, pos); 2929 return scriptDanger(part, pos);
2976
2977 } 2930 }
2978 else 2931 else
2979 { 2932 {
@@ -3090,17 +3043,17 @@ namespace OpenSim.Region.Environment.Scenes
3090 } 3043 }
3091 catch (Exception e) 3044 catch (Exception e)
3092 { 3045 {
3093 m_log.Info("[BUG]: " + e.ToString()); 3046 m_log.Info("[BUG]: " + e);
3094 } 3047 }
3095 } 3048 }
3096 } 3049 }
3097 3050
3098 /// <summary> 3051 /// <summary>
3099 /// Delete this object from the scene. 3052 /// Delete this object from the scene.
3100 /// </summary> 3053 /// </summary>
3101 /// <param name="group"></param> 3054 /// <param name="group"></param>
3102 public void DeleteSceneObjectGroup(SceneObjectGroup group) 3055 public void DeleteSceneObjectGroup(SceneObjectGroup group)
3103 { 3056 {
3104 SceneObjectPart rootPart = (group).GetChildPart(group.UUID); 3057 SceneObjectPart rootPart = (group).GetChildPart(group.UUID);
3105 if (rootPart.PhysActor != null) 3058 if (rootPart.PhysActor != null)
3106 { 3059 {
@@ -3117,15 +3070,15 @@ namespace OpenSim.Region.Environment.Scenes
3117 m_innerScene.RemoveAPrimCount(); 3070 m_innerScene.RemoveAPrimCount();
3118 } 3071 }
3119 group.DeleteParts(); 3072 group.DeleteParts();
3120 3073
3121 // In case anybody else retains a reference to this group, signal deletion by changing the name 3074 // In case anybody else retains a reference to this group, signal deletion by changing the name
3122 // to null. We can't zero out the UUID because this is taken from the root part, which has already 3075 // to null. We can't zero out the UUID because this is taken from the root part, which has already
3123 // been removed. 3076 // been removed.
3124 // FIXME: This is a really poor temporary solution, since it still leaves plenty of scope for race 3077 // FIXME: This is a really poor temporary solution, since it still leaves plenty of scope for race
3125 // conditions where a user deletes an entity while it is being stored. Really, the update 3078 // conditions where a user deletes an entity while it is being stored. Really, the update
3126 // code needs a redesign. 3079 // code needs a redesign.
3127 group.Name = null; 3080 group.Name = null;
3128 } 3081 }
3129 3082
3130 /// <summary> 3083 /// <summary>
3131 /// 3084 ///
@@ -3145,7 +3098,6 @@ namespace OpenSim.Region.Environment.Scenes
3145 // action(presence); 3098 // action(presence);
3146 // } 3099 // }
3147 // } 3100 // }
3148
3149 /// <summary> 3101 /// <summary>
3150 /// 3102 ///
3151 /// </summary> 3103 /// </summary>
@@ -3235,6 +3187,7 @@ namespace OpenSim.Region.Environment.Scenes
3235 } 3187 }
3236 return visualParams; 3188 return visualParams;
3237 } 3189 }
3190
3238 #endregion 3191 #endregion
3239 } 3192 }
3240} 3193} \ No newline at end of file