aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs724
1 files changed, 554 insertions, 170 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 2bf3638..3e11db3 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -119,6 +119,7 @@ namespace OpenSim.Region.Framework.Scenes
119 // TODO: need to figure out how allow client agents but deny 119 // TODO: need to figure out how allow client agents but deny
120 // root agents when ACL denies access to root agent 120 // root agents when ACL denies access to root agent
121 public bool m_strictAccessControl = true; 121 public bool m_strictAccessControl = true;
122 public bool m_seeIntoBannedRegion = false;
122 public int MaxUndoCount = 5; 123 public int MaxUndoCount = 5;
123 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 124 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
124 public bool LoginLock = false; 125 public bool LoginLock = false;
@@ -134,12 +135,14 @@ namespace OpenSim.Region.Framework.Scenes
134 135
135 protected int m_splitRegionID; 136 protected int m_splitRegionID;
136 protected Timer m_restartWaitTimer = new Timer(); 137 protected Timer m_restartWaitTimer = new Timer();
138 protected Timer m_timerWatchdog = new Timer();
137 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 139 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
138 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 140 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
139 protected string m_simulatorVersion = "OpenSimulator Server"; 141 protected string m_simulatorVersion = "OpenSimulator Server";
140 protected ModuleLoader m_moduleLoader; 142 protected ModuleLoader m_moduleLoader;
141 protected AgentCircuitManager m_authenticateHandler; 143 protected AgentCircuitManager m_authenticateHandler;
142 protected SceneCommunicationService m_sceneGridService; 144 protected SceneCommunicationService m_sceneGridService;
145 protected ISnmpModule m_snmpService = null;
143 146
144 protected ISimulationDataService m_SimulationDataService; 147 protected ISimulationDataService m_SimulationDataService;
145 protected IEstateDataService m_EstateDataService; 148 protected IEstateDataService m_EstateDataService;
@@ -202,7 +205,7 @@ namespace OpenSim.Region.Framework.Scenes
202 private int m_update_events = 1; 205 private int m_update_events = 1;
203 private int m_update_backup = 200; 206 private int m_update_backup = 200;
204 private int m_update_terrain = 50; 207 private int m_update_terrain = 50;
205// private int m_update_land = 1; 208 private int m_update_land = 10;
206 private int m_update_coarse_locations = 50; 209 private int m_update_coarse_locations = 50;
207 210
208 private int agentMS; 211 private int agentMS;
@@ -221,6 +224,7 @@ namespace OpenSim.Region.Framework.Scenes
221 /// </summary> 224 /// </summary>
222 private int m_lastFrameTick; 225 private int m_lastFrameTick;
223 226
227 public bool CombineRegions = false;
224 /// <summary> 228 /// <summary>
225 /// Tick at which the last maintenance run occurred. 229 /// Tick at which the last maintenance run occurred.
226 /// </summary> 230 /// </summary>
@@ -251,6 +255,11 @@ namespace OpenSim.Region.Framework.Scenes
251 /// </summary> 255 /// </summary>
252 private int m_LastLogin; 256 private int m_LastLogin;
253 257
258 private int m_lastIncoming;
259 private int m_lastOutgoing;
260 private int m_hbRestarts = 0;
261
262
254 /// <summary> 263 /// <summary>
255 /// Thread that runs the scene loop. 264 /// Thread that runs the scene loop.
256 /// </summary> 265 /// </summary>
@@ -266,7 +275,7 @@ namespace OpenSim.Region.Framework.Scenes
266 private volatile bool m_shuttingDown; 275 private volatile bool m_shuttingDown;
267 276
268// private int m_lastUpdate; 277// private int m_lastUpdate;
269// private bool m_firstHeartbeat = true; 278 private bool m_firstHeartbeat = true;
270 279
271 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 280 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
272 private bool m_reprioritizationEnabled = true; 281 private bool m_reprioritizationEnabled = true;
@@ -311,6 +320,19 @@ namespace OpenSim.Region.Framework.Scenes
311 get { return m_sceneGridService; } 320 get { return m_sceneGridService; }
312 } 321 }
313 322
323 public ISnmpModule SnmpService
324 {
325 get
326 {
327 if (m_snmpService == null)
328 {
329 m_snmpService = RequestModuleInterface<ISnmpModule>();
330 }
331
332 return m_snmpService;
333 }
334 }
335
314 public ISimulationDataService SimulationDataService 336 public ISimulationDataService SimulationDataService
315 { 337 {
316 get 338 get
@@ -603,6 +625,8 @@ namespace OpenSim.Region.Framework.Scenes
603 m_EstateDataService = estateDataService; 625 m_EstateDataService = estateDataService;
604 m_regionHandle = m_regInfo.RegionHandle; 626 m_regionHandle = m_regInfo.RegionHandle;
605 m_regionName = m_regInfo.RegionName; 627 m_regionName = m_regInfo.RegionName;
628 m_lastIncoming = 0;
629 m_lastOutgoing = 0;
606 630
607 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 631 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
608 m_asyncSceneObjectDeleter.Enabled = true; 632 m_asyncSceneObjectDeleter.Enabled = true;
@@ -683,101 +707,110 @@ namespace OpenSim.Region.Framework.Scenes
683 707
684 // Region config overrides global config 708 // Region config overrides global config
685 // 709 //
686 if (m_config.Configs["Startup"] != null) 710 try
687 { 711 {
688 IConfig startupConfig = m_config.Configs["Startup"]; 712 if (m_config.Configs["Startup"] != null)
689
690 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance);
691 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
692 if (!m_useBackup)
693 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
694
695 //Animation states
696 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
697
698 PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims);
699 CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims);
700
701 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
702 if (RegionInfo.NonphysPrimMax > 0)
703 { 713 {
704 m_maxNonphys = RegionInfo.NonphysPrimMax; 714 IConfig startupConfig = m_config.Configs["Startup"];
705 }
706
707 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
708 715
709 if (RegionInfo.PhysPrimMax > 0) 716 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
710 { 717 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
711 m_maxPhys = RegionInfo.PhysPrimMax; 718 if (!m_useBackup)
712 } 719 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
720
721 //Animation states
722 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
713 723
714 // Here, if clamping is requested in either global or 724 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
715 // local config, it will be used 725 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
716 //
717 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
718 if (RegionInfo.ClampPrimSize)
719 {
720 m_clampPrimSize = true;
721 }
722 726
723 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); 727 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
724 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 728 if (RegionInfo.NonphysPrimMax > 0)
725 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 729 {
726 m_dontPersistBefore = 730 m_maxNonphys = RegionInfo.NonphysPrimMax;
727 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); 731 }
728 m_dontPersistBefore *= 10000000;
729 m_persistAfter =
730 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
731 m_persistAfter *= 10000000;
732 732
733 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 733 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
734 734
735 m_SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); 735 if (RegionInfo.PhysPrimMax > 0)
736 {
737 m_maxPhys = RegionInfo.PhysPrimMax;
738 }
736 739
737 IConfig packetConfig = m_config.Configs["PacketPool"]; 740 m_SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
738 if (packetConfig != null)
739 {
740 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
741 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
742 }
743 741
744 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 742 // Here, if clamping is requested in either global or
743 // local config, it will be used
744 //
745 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
746 if (RegionInfo.ClampPrimSize)
747 {
748 m_clampPrimSize = true;
749 }
745 750
746 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 751 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
747 if (m_generateMaptiles) 752 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
748 { 753 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
749 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); 754 m_dontPersistBefore =
750 if (maptileRefresh != 0) 755 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
756 m_dontPersistBefore *= 10000000;
757 m_persistAfter =
758 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
759 m_persistAfter *= 10000000;
760
761 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
762 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
763
764 IConfig packetConfig = m_config.Configs["PacketPool"];
765 if (packetConfig != null)
751 { 766 {
752 m_mapGenerationTimer.Interval = maptileRefresh * 1000; 767 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
753 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; 768 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
754 m_mapGenerationTimer.AutoReset = true;
755 m_mapGenerationTimer.Start();
756 } 769 }
757 }
758 else
759 {
760 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
761 UUID tileID;
762 770
763 if (UUID.TryParse(tile, out tileID)) 771 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
772 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
773 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
774
775 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
776 if (m_generateMaptiles)
764 { 777 {
765 RegionInfo.RegionSettings.TerrainImageID = tileID; 778 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
779 if (maptileRefresh != 0)
780 {
781 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
782 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
783 m_mapGenerationTimer.AutoReset = true;
784 m_mapGenerationTimer.Start();
785 }
766 } 786 }
767 } 787 else
788 {
789 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
790 UUID tileID;
768 791
769 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); 792 if (UUID.TryParse(tile, out tileID))
770 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); 793 {
771 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 794 RegionInfo.RegionSettings.TerrainImageID = tileID;
772 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); 795 }
773 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); 796 }
774 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
775 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
776 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
777 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
778 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
779 797
780 SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); 798 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
799 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
800 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
801 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
802 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
803 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
804 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
805 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
806 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
807 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
808 SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates);
809 }
810 }
811 catch (Exception e)
812 {
813 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
781 } 814 }
782 815
783 #endregion Region Config 816 #endregion Region Config
@@ -1204,7 +1237,22 @@ namespace OpenSim.Region.Framework.Scenes
1204 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1237 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1205 if (m_heartbeatThread != null) 1238 if (m_heartbeatThread != null)
1206 { 1239 {
1240 m_hbRestarts++;
1241 if(m_hbRestarts > 10)
1242 Environment.Exit(1);
1243 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1244
1245//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1246//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1247//proc.EnableRaisingEvents=false;
1248//proc.StartInfo.FileName = "/bin/kill";
1249//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1250//proc.Start();
1251//proc.WaitForExit();
1252//Thread.Sleep(1000);
1253//Environment.Exit(1);
1207 m_heartbeatThread.Abort(); 1254 m_heartbeatThread.Abort();
1255 Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId);
1208 m_heartbeatThread = null; 1256 m_heartbeatThread = null;
1209 } 1257 }
1210// m_lastUpdate = Util.EnvironmentTickCount(); 1258// m_lastUpdate = Util.EnvironmentTickCount();
@@ -1352,10 +1400,12 @@ namespace OpenSim.Region.Framework.Scenes
1352 int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; 1400 int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS;
1353 int previousFrameTick; 1401 int previousFrameTick;
1354 int maintc; 1402 int maintc;
1403 int sleepMS;
1404 int framestart;
1355 1405
1356 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1406 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1357 { 1407 {
1358 maintc = Util.EnvironmentTickCount(); 1408 framestart = Util.EnvironmentTickCount();
1359 ++Frame; 1409 ++Frame;
1360 1410
1361// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1411// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
@@ -1443,7 +1493,7 @@ namespace OpenSim.Region.Framework.Scenes
1443 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1493 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1444 //} 1494 //}
1445 1495
1446 frameMS = Util.EnvironmentTickCountSubtract(maintc); 1496 // frameMS = Util.EnvironmentTickCountSubtract(maintc);
1447 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1497 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1448 1498
1449 // if (Frame%m_update_avatars == 0) 1499 // if (Frame%m_update_avatars == 0)
@@ -1458,7 +1508,7 @@ namespace OpenSim.Region.Framework.Scenes
1458 1508
1459 // frameMS currently records work frame times, not total frame times (work + any required sleep to 1509 // frameMS currently records work frame times, not total frame times (work + any required sleep to
1460 // reach min frame time. 1510 // reach min frame time.
1461 StatsReporter.addFrameMS(frameMS); 1511 // StatsReporter.addFrameMS(frameMS);
1462 1512
1463 StatsReporter.addAgentMS(agentMS); 1513 StatsReporter.addAgentMS(agentMS);
1464 StatsReporter.addPhysicsMS(physicsMS + physicsMS2); 1514 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
@@ -1515,12 +1565,22 @@ namespace OpenSim.Region.Framework.Scenes
1515 1565
1516 previousFrameTick = m_lastFrameTick; 1566 previousFrameTick = m_lastFrameTick;
1517 m_lastFrameTick = Util.EnvironmentTickCount(); 1567 m_lastFrameTick = Util.EnvironmentTickCount();
1518 maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1568 maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart);
1519 maintc = (int)(MinFrameTime * 1000) - maintc; 1569 maintc = (int)(MinFrameTime * 1000) - maintc;
1520 1570
1571 m_firstHeartbeat = false;
1572
1573
1574 sleepMS = Util.EnvironmentTickCount();
1575
1521 if (maintc > 0) 1576 if (maintc > 0)
1522 Thread.Sleep(maintc); 1577 Thread.Sleep(maintc);
1523 1578
1579 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1580 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1581 StatsReporter.addSleepMS(sleepMS);
1582 StatsReporter.addFrameMS(frameMS);
1583
1524 // Optionally warn if a frame takes double the amount of time that it should. 1584 // Optionally warn if a frame takes double the amount of time that it should.
1525 if (DebugUpdates 1585 if (DebugUpdates
1526 && Util.EnvironmentTickCountSubtract( 1586 && Util.EnvironmentTickCountSubtract(
@@ -1547,9 +1607,9 @@ namespace OpenSim.Region.Framework.Scenes
1547 1607
1548 private void CheckAtTargets() 1608 private void CheckAtTargets()
1549 { 1609 {
1550 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1610 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1551 lock (m_groupsWithTargets) 1611 lock (m_groupsWithTargets)
1552 objs = m_groupsWithTargets.Values; 1612 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1553 1613
1554 foreach (SceneObjectGroup entry in objs) 1614 foreach (SceneObjectGroup entry in objs)
1555 entry.checkAtTargets(); 1615 entry.checkAtTargets();
@@ -1630,7 +1690,7 @@ namespace OpenSim.Region.Framework.Scenes
1630 msg.fromAgentName = "Server"; 1690 msg.fromAgentName = "Server";
1631 msg.dialog = (byte)19; // Object msg 1691 msg.dialog = (byte)19; // Object msg
1632 msg.fromGroup = false; 1692 msg.fromGroup = false;
1633 msg.offline = (byte)0; 1693 msg.offline = (byte)1;
1634 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1694 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1635 msg.Position = Vector3.Zero; 1695 msg.Position = Vector3.Zero;
1636 msg.RegionID = RegionInfo.RegionID.Guid; 1696 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1852,6 +1912,19 @@ namespace OpenSim.Region.Framework.Scenes
1852 EventManager.TriggerPrimsLoaded(this); 1912 EventManager.TriggerPrimsLoaded(this);
1853 } 1913 }
1854 1914
1915 public bool SuportsRayCastFiltered()
1916 {
1917 if (PhysicsScene == null)
1918 return false;
1919 return PhysicsScene.SuportsRaycastWorldFiltered();
1920 }
1921
1922 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
1923 {
1924 if (PhysicsScene == null)
1925 return null;
1926 return PhysicsScene.RaycastWorld(position, direction, length, Count,filter);
1927 }
1855 1928
1856 /// <summary> 1929 /// <summary>
1857 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. 1930 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed.
@@ -1868,14 +1941,24 @@ namespace OpenSim.Region.Framework.Scenes
1868 /// <returns></returns> 1941 /// <returns></returns>
1869 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1942 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1870 { 1943 {
1944
1945 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1946 Vector3 wpos = Vector3.Zero;
1947 // Check for water surface intersection from above
1948 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1949 {
1950 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1951 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1952 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1953 wpos.Z = wheight;
1954 }
1955
1871 Vector3 pos = Vector3.Zero; 1956 Vector3 pos = Vector3.Zero;
1872 if (RayEndIsIntersection == (byte)1) 1957 if (RayEndIsIntersection == (byte)1)
1873 { 1958 {
1874 pos = RayEnd; 1959 pos = RayEnd;
1875 return pos;
1876 } 1960 }
1877 1961 else if (RayTargetID != UUID.Zero)
1878 if (RayTargetID != UUID.Zero)
1879 { 1962 {
1880 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1963 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1881 1964
@@ -1897,7 +1980,7 @@ namespace OpenSim.Region.Framework.Scenes
1897 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1980 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1898 1981
1899 // Un-comment out the following line to Get Raytrace results printed to the console. 1982 // Un-comment out the following line to Get Raytrace results printed to the console.
1900 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1983 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1901 float ScaleOffset = 0.5f; 1984 float ScaleOffset = 0.5f;
1902 1985
1903 // If we hit something 1986 // If we hit something
@@ -1920,13 +2003,10 @@ namespace OpenSim.Region.Framework.Scenes
1920 //pos.Z -= 0.25F; 2003 //pos.Z -= 0.25F;
1921 2004
1922 } 2005 }
1923
1924 return pos;
1925 } 2006 }
1926 else 2007 else
1927 { 2008 {
1928 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2009 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1929
1930 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2010 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1931 2011
1932 // Un-comment the following line to print the raytrace results to the console. 2012 // Un-comment the following line to print the raytrace results to the console.
@@ -1935,13 +2015,12 @@ namespace OpenSim.Region.Framework.Scenes
1935 if (ei.HitTF) 2015 if (ei.HitTF)
1936 { 2016 {
1937 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2017 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1938 } else 2018 }
2019 else
1939 { 2020 {
1940 // fall back to our stupid functionality 2021 // fall back to our stupid functionality
1941 pos = RayEnd; 2022 pos = RayEnd;
1942 } 2023 }
1943
1944 return pos;
1945 } 2024 }
1946 } 2025 }
1947 else 2026 else
@@ -1952,8 +2031,12 @@ namespace OpenSim.Region.Framework.Scenes
1952 //increase height so its above the ground. 2031 //increase height so its above the ground.
1953 //should be getting the normal of the ground at the rez point and using that? 2032 //should be getting the normal of the ground at the rez point and using that?
1954 pos.Z += scale.Z / 2f; 2033 pos.Z += scale.Z / 2f;
1955 return pos; 2034// return pos;
1956 } 2035 }
2036
2037 // check against posible water intercept
2038 if (wpos.Z > pos.Z) pos = wpos;
2039 return pos;
1957 } 2040 }
1958 2041
1959 2042
@@ -2043,7 +2126,10 @@ namespace OpenSim.Region.Framework.Scenes
2043 public bool AddRestoredSceneObject( 2126 public bool AddRestoredSceneObject(
2044 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 2127 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
2045 { 2128 {
2046 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 2129 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
2130 if (result)
2131 sceneObject.IsDeleted = false;
2132 return result;
2047 } 2133 }
2048 2134
2049 /// <summary> 2135 /// <summary>
@@ -2135,6 +2221,15 @@ namespace OpenSim.Region.Framework.Scenes
2135 /// </summary> 2221 /// </summary>
2136 public void DeleteAllSceneObjects() 2222 public void DeleteAllSceneObjects()
2137 { 2223 {
2224 DeleteAllSceneObjects(false);
2225 }
2226
2227 /// <summary>
2228 /// Delete every object from the scene. This does not include attachments worn by avatars.
2229 /// </summary>
2230 public void DeleteAllSceneObjects(bool exceptNoCopy)
2231 {
2232 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2138 lock (Entities) 2233 lock (Entities)
2139 { 2234 {
2140 EntityBase[] entities = Entities.GetEntities(); 2235 EntityBase[] entities = Entities.GetEntities();
@@ -2143,11 +2238,24 @@ namespace OpenSim.Region.Framework.Scenes
2143 if (e is SceneObjectGroup) 2238 if (e is SceneObjectGroup)
2144 { 2239 {
2145 SceneObjectGroup sog = (SceneObjectGroup)e; 2240 SceneObjectGroup sog = (SceneObjectGroup)e;
2146 if (!sog.IsAttachment) 2241 if (sog != null && !sog.IsAttachment)
2147 DeleteSceneObject((SceneObjectGroup)e, false); 2242 {
2243 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2244 {
2245 DeleteSceneObject((SceneObjectGroup)e, false);
2246 }
2247 else
2248 {
2249 toReturn.Add((SceneObjectGroup)e);
2250 }
2251 }
2148 } 2252 }
2149 } 2253 }
2150 } 2254 }
2255 if (toReturn.Count > 0)
2256 {
2257 returnObjects(toReturn.ToArray(), UUID.Zero);
2258 }
2151 } 2259 }
2152 2260
2153 /// <summary> 2261 /// <summary>
@@ -2182,6 +2290,8 @@ namespace OpenSim.Region.Framework.Scenes
2182 } 2290 }
2183 2291
2184 group.DeleteGroupFromScene(silent); 2292 group.DeleteGroupFromScene(silent);
2293 if (!silent)
2294 SendKillObject(new List<uint>() { group.LocalId });
2185 2295
2186// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2296// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2187 } 2297 }
@@ -2471,6 +2581,8 @@ namespace OpenSim.Region.Framework.Scenes
2471 2581
2472 if (newPosition != Vector3.Zero) 2582 if (newPosition != Vector3.Zero)
2473 newObject.RootPart.GroupPosition = newPosition; 2583 newObject.RootPart.GroupPosition = newPosition;
2584 if (newObject.RootPart.KeyframeMotion != null)
2585 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2474 2586
2475 if (!AddSceneObject(newObject)) 2587 if (!AddSceneObject(newObject))
2476 { 2588 {
@@ -2539,10 +2651,17 @@ namespace OpenSim.Region.Framework.Scenes
2539 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2651 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2540 public bool AddSceneObject(SceneObjectGroup sceneObject) 2652 public bool AddSceneObject(SceneObjectGroup sceneObject)
2541 { 2653 {
2654 if (sceneObject.OwnerID == UUID.Zero)
2655 {
2656 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2657 return false;
2658 }
2659
2542 // If the user is banned, we won't let any of their objects 2660 // If the user is banned, we won't let any of their objects
2543 // enter. Period. 2661 // enter. Period.
2544 // 2662 //
2545 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2663 int flags = GetUserFlags(sceneObject.OwnerID);
2664 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2546 { 2665 {
2547 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); 2666 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2548 2667
@@ -2588,12 +2707,23 @@ namespace OpenSim.Region.Framework.Scenes
2588 } 2707 }
2589 else 2708 else
2590 { 2709 {
2710 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2591 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2711 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2592 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2712 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2593 } 2713 }
2714 if (sceneObject.OwnerID == UUID.Zero)
2715 {
2716 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2717 return false;
2718 }
2594 } 2719 }
2595 else 2720 else
2596 { 2721 {
2722 if (sceneObject.OwnerID == UUID.Zero)
2723 {
2724 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2725 return false;
2726 }
2597 AddRestoredSceneObject(sceneObject, true, false); 2727 AddRestoredSceneObject(sceneObject, true, false);
2598 2728
2599 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2729 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2622,6 +2752,24 @@ namespace OpenSim.Region.Framework.Scenes
2622 return 2; // StateSource.PrimCrossing 2752 return 2; // StateSource.PrimCrossing
2623 } 2753 }
2624 2754
2755 public int GetUserFlags(UUID user)
2756 {
2757 //Unfortunately the SP approach means that the value is cached until region is restarted
2758 /*
2759 ScenePresence sp;
2760 if (TryGetScenePresence(user, out sp))
2761 {
2762 return sp.UserFlags;
2763 }
2764 else
2765 {
2766 */
2767 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2768 if (uac == null)
2769 return 0;
2770 return uac.UserFlags;
2771 //}
2772 }
2625 #endregion 2773 #endregion
2626 2774
2627 #region Add/Remove Avatar Methods 2775 #region Add/Remove Avatar Methods
@@ -2635,7 +2783,7 @@ namespace OpenSim.Region.Framework.Scenes
2635 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2783 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2636 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2784 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2637 2785
2638// CheckHeartbeat(); 2786 CheckHeartbeat();
2639 2787
2640 ScenePresence sp = GetScenePresence(client.AgentId); 2788 ScenePresence sp = GetScenePresence(client.AgentId);
2641 2789
@@ -2688,7 +2836,13 @@ namespace OpenSim.Region.Framework.Scenes
2688 2836
2689 EventManager.TriggerOnNewClient(client); 2837 EventManager.TriggerOnNewClient(client);
2690 if (vialogin) 2838 if (vialogin)
2839 {
2691 EventManager.TriggerOnClientLogin(client); 2840 EventManager.TriggerOnClientLogin(client);
2841 // Send initial parcel data
2842 Vector3 pos = sp.AbsolutePosition;
2843 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2844 land.SendLandUpdateToClient(client);
2845 }
2692 2846
2693 return sp; 2847 return sp;
2694 } 2848 }
@@ -2778,19 +2932,12 @@ namespace OpenSim.Region.Framework.Scenes
2778 // and the scene presence and the client, if they exist 2932 // and the scene presence and the client, if they exist
2779 try 2933 try
2780 { 2934 {
2781 // We need to wait for the client to make UDP contact first. 2935 ScenePresence sp = GetScenePresence(agentID);
2782 // It's the UDP contact that creates the scene presence 2936 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2783 ScenePresence sp = WaitGetScenePresence(agentID); 2937
2784 if (sp != null) 2938 if (sp != null)
2785 {
2786 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2787
2788 sp.ControllingClient.Close(); 2939 sp.ControllingClient.Close();
2789 } 2940
2790 else
2791 {
2792 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2793 }
2794 // BANG! SLASH! 2941 // BANG! SLASH!
2795 m_authenticateHandler.RemoveCircuit(agentID); 2942 m_authenticateHandler.RemoveCircuit(agentID);
2796 2943
@@ -2835,6 +2982,8 @@ namespace OpenSim.Region.Framework.Scenes
2835 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 2982 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
2836 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 2983 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2837 2984
2985 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
2986
2838 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 2987 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
2839 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 2988 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
2840 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 2989 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -2891,6 +3040,7 @@ namespace OpenSim.Region.Framework.Scenes
2891 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3040 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2892 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3041 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2893 client.OnCopyInventoryItem += CopyInventoryItem; 3042 client.OnCopyInventoryItem += CopyInventoryItem;
3043 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2894 client.OnMoveInventoryItem += MoveInventoryItem; 3044 client.OnMoveInventoryItem += MoveInventoryItem;
2895 client.OnRemoveInventoryItem += RemoveInventoryItem; 3045 client.OnRemoveInventoryItem += RemoveInventoryItem;
2896 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3046 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2962,6 +3112,8 @@ namespace OpenSim.Region.Framework.Scenes
2962 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3112 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
2963 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3113 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
2964 3114
3115 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3116
2965 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3117 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
2966 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3118 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
2967 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3119 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3064,15 +3216,16 @@ namespace OpenSim.Region.Framework.Scenes
3064 /// </summary> 3216 /// </summary>
3065 /// <param name="agentId">The avatar's Unique ID</param> 3217 /// <param name="agentId">The avatar's Unique ID</param>
3066 /// <param name="client">The IClientAPI for the client</param> 3218 /// <param name="client">The IClientAPI for the client</param>
3067 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3219 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3068 { 3220 {
3069 if (m_teleportModule != null) 3221 if (m_teleportModule != null)
3070 m_teleportModule.TeleportHome(agentId, client); 3222 return m_teleportModule.TeleportHome(agentId, client);
3071 else 3223 else
3072 { 3224 {
3073 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3225 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3074 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3226 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3075 } 3227 }
3228 return false;
3076 } 3229 }
3077 3230
3078 /// <summary> 3231 /// <summary>
@@ -3182,6 +3335,16 @@ namespace OpenSim.Region.Framework.Scenes
3182 /// <param name="flags"></param> 3335 /// <param name="flags"></param>
3183 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3336 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3184 { 3337 {
3338 //Add half the avatar's height so that the user doesn't fall through prims
3339 ScenePresence presence;
3340 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3341 {
3342 if (presence.Appearance != null)
3343 {
3344 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3345 }
3346 }
3347
3185 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3348 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3186 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3349 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3187 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3350 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3250,8 +3413,9 @@ namespace OpenSim.Region.Framework.Scenes
3250 regions.Remove(RegionInfo.RegionHandle); 3413 regions.Remove(RegionInfo.RegionHandle);
3251 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3414 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3252 } 3415 }
3253 3416 m_log.Debug("[Scene] Beginning ClientClosed");
3254 m_eventManager.TriggerClientClosed(agentID, this); 3417 m_eventManager.TriggerClientClosed(agentID, this);
3418 m_log.Debug("[Scene] Finished ClientClosed");
3255 } 3419 }
3256 catch (NullReferenceException) 3420 catch (NullReferenceException)
3257 { 3421 {
@@ -3313,9 +3477,10 @@ namespace OpenSim.Region.Framework.Scenes
3313 { 3477 {
3314 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); 3478 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace);
3315 } 3479 }
3316 3480 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3317 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3481 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3318// CleanDroppedAttachments(); 3482// CleanDroppedAttachments();
3483 m_log.Debug("[Scene] The avatar has left the building");
3319 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3484 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3320 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3485 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3321 } 3486 }
@@ -3450,13 +3615,16 @@ namespace OpenSim.Region.Framework.Scenes
3450 sp = null; 3615 sp = null;
3451 } 3616 }
3452 3617
3453 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3454 3618
3455 //On login test land permisions 3619 //On login test land permisions
3456 if (vialogin) 3620 if (vialogin)
3457 { 3621 {
3458 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3622 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3623 if (cache != null)
3624 cache.Remove(agent.firstname + " " + agent.lastname);
3625 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3459 { 3626 {
3627 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3460 return false; 3628 return false;
3461 } 3629 }
3462 } 3630 }
@@ -3479,9 +3647,15 @@ namespace OpenSim.Region.Framework.Scenes
3479 3647
3480 try 3648 try
3481 { 3649 {
3482 if (!AuthorizeUser(agent, out reason)) 3650 // Always check estate if this is a login. Always
3483 return false; 3651 // check if banned regions are to be blacked out.
3484 } catch (Exception e) 3652 if (vialogin || (!m_seeIntoBannedRegion))
3653 {
3654 if (!AuthorizeUser(agent, out reason))
3655 return false;
3656 }
3657 }
3658 catch (Exception e)
3485 { 3659 {
3486 m_log.ErrorFormat( 3660 m_log.ErrorFormat(
3487 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); 3661 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
@@ -3612,6 +3786,8 @@ namespace OpenSim.Region.Framework.Scenes
3612 } 3786 }
3613 3787
3614 // Honor parcel landing type and position. 3788 // Honor parcel landing type and position.
3789 /*
3790 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3615 if (land != null) 3791 if (land != null)
3616 { 3792 {
3617 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3793 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3619,26 +3795,34 @@ namespace OpenSim.Region.Framework.Scenes
3619 agent.startpos = land.LandData.UserLocation; 3795 agent.startpos = land.LandData.UserLocation;
3620 } 3796 }
3621 } 3797 }
3798 */// This is now handled properly in ScenePresence.MakeRootAgent
3622 } 3799 }
3623 3800
3624 return true; 3801 return true;
3625 } 3802 }
3626 3803
3627 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3804 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3628 { 3805 {
3629 3806 reason = String.Empty;
3630 bool banned = land.IsBannedFromLand(agent.AgentID); 3807 if (Permissions.IsGod(agentID))
3631 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3808 return true;
3809
3810 ILandObject land = LandChannel.GetLandObject(posX, posY);
3811 if (land == null)
3812 return false;
3813
3814 bool banned = land.IsBannedFromLand(agentID);
3815 bool restricted = land.IsRestrictedFromLand(agentID);
3632 3816
3633 if (banned || restricted) 3817 if (banned || restricted)
3634 { 3818 {
3635 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3819 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3636 if (nearestParcel != null) 3820 if (nearestParcel != null)
3637 { 3821 {
3638 //Move agent to nearest allowed 3822 //Move agent to nearest allowed
3639 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3823 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3640 agent.startpos.X = newPosition.X; 3824 posX = newPosition.X;
3641 agent.startpos.Y = newPosition.Y; 3825 posY = newPosition.Y;
3642 } 3826 }
3643 else 3827 else
3644 { 3828 {
@@ -3700,7 +3884,7 @@ namespace OpenSim.Region.Framework.Scenes
3700 3884
3701 if (!m_strictAccessControl) return true; 3885 if (!m_strictAccessControl) return true;
3702 if (Permissions.IsGod(agent.AgentID)) return true; 3886 if (Permissions.IsGod(agent.AgentID)) return true;
3703 3887
3704 if (AuthorizationService != null) 3888 if (AuthorizationService != null)
3705 { 3889 {
3706 if (!AuthorizationService.IsAuthorizedForRegion( 3890 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3715,7 +3899,7 @@ namespace OpenSim.Region.Framework.Scenes
3715 3899
3716 if (m_regInfo.EstateSettings != null) 3900 if (m_regInfo.EstateSettings != null)
3717 { 3901 {
3718 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3902 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3719 { 3903 {
3720 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3904 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3721 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3905 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3907,6 +4091,13 @@ namespace OpenSim.Region.Framework.Scenes
3907 4091
3908 // We have to wait until the viewer contacts this region after receiving EAC. 4092 // We have to wait until the viewer contacts this region after receiving EAC.
3909 // That calls AddNewClient, which finally creates the ScenePresence 4093 // That calls AddNewClient, which finally creates the ScenePresence
4094 int flags = GetUserFlags(cAgentData.AgentID);
4095 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4096 {
4097 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4098 return false;
4099 }
4100
3910 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4101 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3911 if (nearestParcel == null) 4102 if (nearestParcel == null)
3912 { 4103 {
@@ -3991,12 +4182,22 @@ namespace OpenSim.Region.Framework.Scenes
3991 return false; 4182 return false;
3992 } 4183 }
3993 4184
4185 public bool IncomingCloseAgent(UUID agentID)
4186 {
4187 return IncomingCloseAgent(agentID, false);
4188 }
4189
4190 public bool IncomingCloseChildAgent(UUID agentID)
4191 {
4192 return IncomingCloseAgent(agentID, true);
4193 }
4194
3994 /// <summary> 4195 /// <summary>
3995 /// Tell a single agent to disconnect from the region. 4196 /// Tell a single agent to disconnect from the region.
3996 /// </summary> 4197 /// </summary>
3997 /// <param name="regionHandle"></param>
3998 /// <param name="agentID"></param> 4198 /// <param name="agentID"></param>
3999 public bool IncomingCloseAgent(UUID agentID) 4199 /// <param name="childOnly"></param>
4200 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
4000 { 4201 {
4001 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 4202 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
4002 4203
@@ -4008,7 +4209,7 @@ namespace OpenSim.Region.Framework.Scenes
4008 { 4209 {
4009 m_sceneGraph.removeUserCount(false); 4210 m_sceneGraph.removeUserCount(false);
4010 } 4211 }
4011 else 4212 else if (!childOnly)
4012 { 4213 {
4013 m_sceneGraph.removeUserCount(true); 4214 m_sceneGraph.removeUserCount(true);
4014 } 4215 }
@@ -4024,9 +4225,12 @@ namespace OpenSim.Region.Framework.Scenes
4024 } 4225 }
4025 else 4226 else
4026 presence.ControllingClient.SendShutdownConnectionNotice(); 4227 presence.ControllingClient.SendShutdownConnectionNotice();
4228 presence.ControllingClient.Close(false);
4229 }
4230 else if (!childOnly)
4231 {
4232 presence.ControllingClient.Close(true);
4027 } 4233 }
4028
4029 presence.ControllingClient.Close();
4030 return true; 4234 return true;
4031 } 4235 }
4032 4236
@@ -4608,35 +4812,81 @@ namespace OpenSim.Region.Framework.Scenes
4608 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4812 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4609 } 4813 }
4610 4814
4611 public int GetHealth() 4815 public int GetHealth(out int flags, out string message)
4612 { 4816 {
4613 // Returns: 4817 // Returns:
4614 // 1 = sim is up and accepting http requests. The heartbeat has 4818 // 1 = sim is up and accepting http requests. The heartbeat has
4615 // stopped and the sim is probably locked up, but a remote 4819 // stopped and the sim is probably locked up, but a remote
4616 // admin restart may succeed 4820 // admin restart may succeed
4617 // 4821 //
4618 // 2 = Sim is up and the heartbeat is running. The sim is likely 4822 // 2 = Sim is up and the heartbeat is running. The sim is likely
4619 // usable for people within and logins _may_ work 4823 // usable for people within
4824 //
4825 // 3 = Sim is up and one packet thread is running. Sim is
4826 // unstable and will not accept new logins
4620 // 4827 //
4621 // 3 = We have seen a new user enter within the past 4 minutes 4828 // 4 = Sim is up and both packet threads are running. Sim is
4829 // likely usable
4830 //
4831 // 5 = We have seen a new user enter within the past 4 minutes
4622 // which can be seen as positive confirmation of sim health 4832 // which can be seen as positive confirmation of sim health
4623 // 4833 //
4834
4835 flags = 0;
4836 message = String.Empty;
4837
4838 CheckHeartbeat();
4839
4840 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4841 {
4842 // We're still starting
4843 // 0 means "in startup", it can't happen another way, since
4844 // to get here, we must be able to accept http connections
4845 return 0;
4846 }
4847
4624 int health=1; // Start at 1, means we're up 4848 int health=1; // Start at 1, means we're up
4625 4849
4626 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 4850 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
4627 health += 1; 4851 {
4852 health+=1;
4853 flags |= 1;
4854 }
4855
4856 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4857 {
4858 health+=1;
4859 flags |= 2;
4860 }
4861
4862 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4863 {
4864 health+=1;
4865 flags |= 4;
4866 }
4628 else 4867 else
4868 {
4869int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
4870System.Diagnostics.Process proc = new System.Diagnostics.Process();
4871proc.EnableRaisingEvents=false;
4872proc.StartInfo.FileName = "/bin/kill";
4873proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
4874proc.Start();
4875proc.WaitForExit();
4876Thread.Sleep(1000);
4877Environment.Exit(1);
4878 }
4879
4880 if (flags != 7)
4629 return health; 4881 return health;
4630 4882
4631 // A login in the last 4 mins? We can't be doing too badly 4883 // A login in the last 4 mins? We can't be doing too badly
4632 // 4884 //
4633 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4885 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4634 health++; 4886 health++;
4635 else 4887 else
4636 return health; 4888 return health;
4637 4889
4638// CheckHeartbeat();
4639
4640 return health; 4890 return health;
4641 } 4891 }
4642 4892
@@ -4724,7 +4974,7 @@ namespace OpenSim.Region.Framework.Scenes
4724 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 4974 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
4725 if (wasUsingPhysics) 4975 if (wasUsingPhysics)
4726 { 4976 {
4727 jointProxyObject.UpdatePrimFlags(false, false, true, false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock 4977 jointProxyObject.UpdatePrimFlags(false, false, true, false,false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock
4728 } 4978 }
4729 } 4979 }
4730 4980
@@ -4823,14 +5073,14 @@ namespace OpenSim.Region.Framework.Scenes
4823 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5073 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
4824 } 5074 }
4825 5075
4826// private void CheckHeartbeat() 5076 private void CheckHeartbeat()
4827// { 5077 {
4828// if (m_firstHeartbeat) 5078 if (m_firstHeartbeat)
4829// return; 5079 return;
4830// 5080
4831// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5081 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
4832// StartTimer(); 5082 Start();
4833// } 5083 }
4834 5084
4835 public override ISceneObject DeserializeObject(string representation) 5085 public override ISceneObject DeserializeObject(string representation)
4836 { 5086 {
@@ -4842,9 +5092,14 @@ namespace OpenSim.Region.Framework.Scenes
4842 get { return m_allowScriptCrossings; } 5092 get { return m_allowScriptCrossings; }
4843 } 5093 }
4844 5094
4845 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 5095 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
5096 {
5097 return GetNearestAllowedPosition(avatar, null);
5098 }
5099
5100 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
4846 { 5101 {
4847 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 5102 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
4848 5103
4849 if (nearestParcel != null) 5104 if (nearestParcel != null)
4850 { 5105 {
@@ -4853,10 +5108,7 @@ namespace OpenSim.Region.Framework.Scenes
4853 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5108 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4854 if (nearestPoint != null) 5109 if (nearestPoint != null)
4855 { 5110 {
4856// m_log.DebugFormat( 5111 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
4857// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
4858// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
4859
4860 return nearestPoint.Value; 5112 return nearestPoint.Value;
4861 } 5113 }
4862 5114
@@ -4866,17 +5118,20 @@ namespace OpenSim.Region.Framework.Scenes
4866 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5118 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4867 if (nearestPoint != null) 5119 if (nearestPoint != null)
4868 { 5120 {
4869// m_log.DebugFormat( 5121 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
4870// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
4871
4872 return nearestPoint.Value; 5122 return nearestPoint.Value;
4873 } 5123 }
4874 5124
4875 //Ultimate backup if we have no idea where they are 5125 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
4876// m_log.DebugFormat( 5126 if (dest != excludeParcel)
4877// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); 5127 {
5128 // Ultimate backup if we have no idea where they are and
5129 // the last allowed position was in another parcel
5130 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5131 return avatar.lastKnownAllowedPosition;
5132 }
4878 5133
4879 return avatar.lastKnownAllowedPosition; 5134 // else fall through to region edge
4880 } 5135 }
4881 5136
4882 //Go to the edge, this happens in teleporting to a region with no available parcels 5137 //Go to the edge, this happens in teleporting to a region with no available parcels
@@ -4910,13 +5165,18 @@ namespace OpenSim.Region.Framework.Scenes
4910 5165
4911 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 5166 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
4912 { 5167 {
5168 return GetNearestAllowedParcel(avatarId, x, y, null);
5169 }
5170
5171 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5172 {
4913 List<ILandObject> all = AllParcels(); 5173 List<ILandObject> all = AllParcels();
4914 float minParcelDistance = float.MaxValue; 5174 float minParcelDistance = float.MaxValue;
4915 ILandObject nearestParcel = null; 5175 ILandObject nearestParcel = null;
4916 5176
4917 foreach (var parcel in all) 5177 foreach (var parcel in all)
4918 { 5178 {
4919 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 5179 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
4920 { 5180 {
4921 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5181 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
4922 if (parcelDistance < minParcelDistance) 5182 if (parcelDistance < minParcelDistance)
@@ -5158,7 +5418,55 @@ namespace OpenSim.Region.Framework.Scenes
5158 mapModule.GenerateMaptile(); 5418 mapModule.GenerateMaptile();
5159 } 5419 }
5160 5420
5161 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5421// public void CleanDroppedAttachments()
5422// {
5423// List<SceneObjectGroup> objectsToDelete =
5424// new List<SceneObjectGroup>();
5425//
5426// lock (m_cleaningAttachments)
5427// {
5428// ForEachSOG(delegate (SceneObjectGroup grp)
5429// {
5430// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5431// {
5432// UUID agentID = grp.OwnerID;
5433// if (agentID == UUID.Zero)
5434// {
5435// objectsToDelete.Add(grp);
5436// return;
5437// }
5438//
5439// ScenePresence sp = GetScenePresence(agentID);
5440// if (sp == null)
5441// {
5442// objectsToDelete.Add(grp);
5443// return;
5444// }
5445// }
5446// });
5447// }
5448//
5449// foreach (SceneObjectGroup grp in objectsToDelete)
5450// {
5451// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5452// DeleteSceneObject(grp, true);
5453// }
5454// }
5455
5456 public void ThreadAlive(int threadCode)
5457 {
5458 switch(threadCode)
5459 {
5460 case 1: // Incoming
5461 m_lastIncoming = Util.EnvironmentTickCount();
5462 break;
5463 case 2: // Incoming
5464 m_lastOutgoing = Util.EnvironmentTickCount();
5465 break;
5466 }
5467 }
5468
5469 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5162 { 5470 {
5163 RegenerateMaptile(); 5471 RegenerateMaptile();
5164 5472
@@ -5177,6 +5485,14 @@ namespace OpenSim.Region.Framework.Scenes
5177 // child agent creation, thereby emulating the SL behavior. 5485 // child agent creation, thereby emulating the SL behavior.
5178 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5486 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5179 { 5487 {
5488 reason = "You are banned from the region";
5489
5490 if (Permissions.IsGod(agentID))
5491 {
5492 reason = String.Empty;
5493 return true;
5494 }
5495
5180 int num = m_sceneGraph.GetNumberOfScenePresences(); 5496 int num = m_sceneGraph.GetNumberOfScenePresences();
5181 5497
5182 if (num >= RegionInfo.RegionSettings.AgentLimit) 5498 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5188,6 +5504,41 @@ namespace OpenSim.Region.Framework.Scenes
5188 } 5504 }
5189 } 5505 }
5190 5506
5507 ScenePresence presence = GetScenePresence(agentID);
5508 IClientAPI client = null;
5509 AgentCircuitData aCircuit = null;
5510
5511 if (presence != null)
5512 {
5513 client = presence.ControllingClient;
5514 if (client != null)
5515 aCircuit = client.RequestClientInfo();
5516 }
5517
5518 // We may be called before there is a presence or a client.
5519 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5520 if (client == null)
5521 {
5522 aCircuit = new AgentCircuitData();
5523 aCircuit.AgentID = agentID;
5524 aCircuit.firstname = String.Empty;
5525 aCircuit.lastname = String.Empty;
5526 }
5527
5528 try
5529 {
5530 if (!AuthorizeUser(aCircuit, out reason))
5531 {
5532 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5533 return false;
5534 }
5535 }
5536 catch (Exception e)
5537 {
5538 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5539 return false;
5540 }
5541
5191 if (position == Vector3.Zero) // Teleport 5542 if (position == Vector3.Zero) // Teleport
5192 { 5543 {
5193 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5544 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5216,13 +5567,46 @@ namespace OpenSim.Region.Framework.Scenes
5216 } 5567 }
5217 } 5568 }
5218 } 5569 }
5570
5571 float posX = 128.0f;
5572 float posY = 128.0f;
5573
5574 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5575 {
5576 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5577 return false;
5578 }
5579 }
5580 else // Walking
5581 {
5582 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5583 if (land == null)
5584 return false;
5585
5586 bool banned = land.IsBannedFromLand(agentID);
5587 bool restricted = land.IsRestrictedFromLand(agentID);
5588
5589 if (banned || restricted)
5590 return false;
5219 } 5591 }
5220 5592
5221 reason = String.Empty; 5593 reason = String.Empty;
5222 return true; 5594 return true;
5223 } 5595 }
5224 5596
5225 /// <summary> 5597 public void StartTimerWatchdog()
5598 {
5599 m_timerWatchdog.Interval = 1000;
5600 m_timerWatchdog.Elapsed += TimerWatchdog;
5601 m_timerWatchdog.AutoReset = true;
5602 m_timerWatchdog.Start();
5603 }
5604
5605 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5606 {
5607 CheckHeartbeat();
5608 }
5609
5226 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5610 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5227 /// autopilot that moves an avatar to a sit target!. 5611 /// autopilot that moves an avatar to a sit target!.
5228 /// </summary> 5612 /// </summary>