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