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.cs707
1 files changed, 542 insertions, 165 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index ae35cb9..315b340 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -124,6 +124,7 @@ namespace OpenSim.Region.Framework.Scenes
124 // TODO: need to figure out how allow client agents but deny 124 // TODO: need to figure out how allow client agents but deny
125 // root agents when ACL denies access to root agent 125 // root agents when ACL denies access to root agent
126 public bool m_strictAccessControl = true; 126 public bool m_strictAccessControl = true;
127 public bool m_seeIntoBannedRegion = false;
127 public int MaxUndoCount = 5; 128 public int MaxUndoCount = 5;
128 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 129 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
129 public bool LoginLock = false; 130 public bool LoginLock = false;
@@ -139,12 +140,14 @@ namespace OpenSim.Region.Framework.Scenes
139 140
140 protected int m_splitRegionID; 141 protected int m_splitRegionID;
141 protected Timer m_restartWaitTimer = new Timer(); 142 protected Timer m_restartWaitTimer = new Timer();
143 protected Timer m_timerWatchdog = new Timer();
142 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 144 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
143 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 145 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
144 protected string m_simulatorVersion = "OpenSimulator Server"; 146 protected string m_simulatorVersion = "OpenSimulator Server";
145 protected ModuleLoader m_moduleLoader; 147 protected ModuleLoader m_moduleLoader;
146 protected AgentCircuitManager m_authenticateHandler; 148 protected AgentCircuitManager m_authenticateHandler;
147 protected SceneCommunicationService m_sceneGridService; 149 protected SceneCommunicationService m_sceneGridService;
150 protected ISnmpModule m_snmpService = null;
148 151
149 protected ISimulationDataService m_SimulationDataService; 152 protected ISimulationDataService m_SimulationDataService;
150 protected IEstateDataService m_EstateDataService; 153 protected IEstateDataService m_EstateDataService;
@@ -206,7 +209,7 @@ namespace OpenSim.Region.Framework.Scenes
206 private int m_update_events = 1; 209 private int m_update_events = 1;
207 private int m_update_backup = 200; 210 private int m_update_backup = 200;
208 private int m_update_terrain = 50; 211 private int m_update_terrain = 50;
209// private int m_update_land = 1; 212 private int m_update_land = 10;
210 private int m_update_coarse_locations = 50; 213 private int m_update_coarse_locations = 50;
211 214
212 private int agentMS; 215 private int agentMS;
@@ -226,6 +229,7 @@ namespace OpenSim.Region.Framework.Scenes
226 /// </summary> 229 /// </summary>
227 private int m_lastFrameTick; 230 private int m_lastFrameTick;
228 231
232 public bool CombineRegions = false;
229 /// <summary> 233 /// <summary>
230 /// Tick at which the last maintenance run occurred. 234 /// Tick at which the last maintenance run occurred.
231 /// </summary> 235 /// </summary>
@@ -256,6 +260,11 @@ namespace OpenSim.Region.Framework.Scenes
256 /// </summary> 260 /// </summary>
257 private int m_LastLogin; 261 private int m_LastLogin;
258 262
263 private int m_lastIncoming;
264 private int m_lastOutgoing;
265 private int m_hbRestarts = 0;
266
267
259 /// <summary> 268 /// <summary>
260 /// Thread that runs the scene loop. 269 /// Thread that runs the scene loop.
261 /// </summary> 270 /// </summary>
@@ -271,7 +280,7 @@ namespace OpenSim.Region.Framework.Scenes
271 private volatile bool m_shuttingDown; 280 private volatile bool m_shuttingDown;
272 281
273// private int m_lastUpdate; 282// private int m_lastUpdate;
274// private bool m_firstHeartbeat = true; 283 private bool m_firstHeartbeat = true;
275 284
276 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 285 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
277 private bool m_reprioritizationEnabled = true; 286 private bool m_reprioritizationEnabled = true;
@@ -316,6 +325,19 @@ namespace OpenSim.Region.Framework.Scenes
316 get { return m_sceneGridService; } 325 get { return m_sceneGridService; }
317 } 326 }
318 327
328 public ISnmpModule SnmpService
329 {
330 get
331 {
332 if (m_snmpService == null)
333 {
334 m_snmpService = RequestModuleInterface<ISnmpModule>();
335 }
336
337 return m_snmpService;
338 }
339 }
340
319 public ISimulationDataService SimulationDataService 341 public ISimulationDataService SimulationDataService
320 { 342 {
321 get 343 get
@@ -614,6 +636,8 @@ namespace OpenSim.Region.Framework.Scenes
614 m_EstateDataService = estateDataService; 636 m_EstateDataService = estateDataService;
615 m_regionHandle = m_regInfo.RegionHandle; 637 m_regionHandle = m_regInfo.RegionHandle;
616 m_regionName = m_regInfo.RegionName; 638 m_regionName = m_regInfo.RegionName;
639 m_lastIncoming = 0;
640 m_lastOutgoing = 0;
617 641
618 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 642 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
619 m_asyncSceneObjectDeleter.Enabled = true; 643 m_asyncSceneObjectDeleter.Enabled = true;
@@ -694,102 +718,111 @@ namespace OpenSim.Region.Framework.Scenes
694 718
695 // Region config overrides global config 719 // Region config overrides global config
696 // 720 //
697 if (m_config.Configs["Startup"] != null) 721 try
698 { 722 {
699 IConfig startupConfig = m_config.Configs["Startup"]; 723 if (m_config.Configs["Startup"] != null)
700
701 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance);
702 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
703 if (!m_useBackup)
704 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
705
706 //Animation states
707 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
708
709 PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims);
710 CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims);
711
712 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
713 if (RegionInfo.NonphysPrimMax > 0)
714 { 724 {
715 m_maxNonphys = RegionInfo.NonphysPrimMax; 725 IConfig startupConfig = m_config.Configs["Startup"];
716 }
717
718 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
719 726
720 if (RegionInfo.PhysPrimMax > 0) 727 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
721 { 728 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
722 m_maxPhys = RegionInfo.PhysPrimMax; 729 if (!m_useBackup)
723 } 730 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
731
732 //Animation states
733 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
724 734
725 // Here, if clamping is requested in either global or 735 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
726 // local config, it will be used 736 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
727 //
728 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
729 if (RegionInfo.ClampPrimSize)
730 {
731 m_clampPrimSize = true;
732 }
733 737
734 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); 738 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
735 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 739 if (RegionInfo.NonphysPrimMax > 0)
736 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 740 {
737 m_dontPersistBefore = 741 m_maxNonphys = RegionInfo.NonphysPrimMax;
738 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); 742 }
739 m_dontPersistBefore *= 10000000;
740 m_persistAfter =
741 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
742 m_persistAfter *= 10000000;
743 743
744 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 744 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
745 745
746 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); 746 if (RegionInfo.PhysPrimMax > 0)
747 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); 747 {
748 m_maxPhys = RegionInfo.PhysPrimMax;
749 }
748 750
749 IConfig packetConfig = m_config.Configs["PacketPool"]; 751 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
750 if (packetConfig != null) 752 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
751 {
752 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
753 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
754 }
755 753
756 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 754 // Here, if clamping is requested in either global or
755 // local config, it will be used
756 //
757 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
758 if (RegionInfo.ClampPrimSize)
759 {
760 m_clampPrimSize = true;
761 }
757 762
758 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 763 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
759 if (m_generateMaptiles) 764 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
760 { 765 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
761 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); 766 m_dontPersistBefore =
762 if (maptileRefresh != 0) 767 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
768 m_dontPersistBefore *= 10000000;
769 m_persistAfter =
770 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
771 m_persistAfter *= 10000000;
772
773 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
774 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
775
776 IConfig packetConfig = m_config.Configs["PacketPool"];
777 if (packetConfig != null)
763 { 778 {
764 m_mapGenerationTimer.Interval = maptileRefresh * 1000; 779 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
765 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; 780 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
766 m_mapGenerationTimer.AutoReset = true;
767 m_mapGenerationTimer.Start();
768 } 781 }
769 }
770 else
771 {
772 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
773 UUID tileID;
774 782
775 if (UUID.TryParse(tile, out tileID)) 783 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
784 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
785 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
786
787 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
788 if (m_generateMaptiles)
776 { 789 {
777 RegionInfo.RegionSettings.TerrainImageID = tileID; 790 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
791 if (maptileRefresh != 0)
792 {
793 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
794 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
795 m_mapGenerationTimer.AutoReset = true;
796 m_mapGenerationTimer.Start();
797 }
778 } 798 }
779 } 799 else
800 {
801 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
802 UUID tileID;
780 803
781 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); 804 if (UUID.TryParse(tile, out tileID))
782 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); 805 {
783 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 806 RegionInfo.RegionSettings.TerrainImageID = tileID;
784 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); 807 }
785 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); 808 }
786 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
787 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
788 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
789 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
790 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
791 809
792 SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); 810 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
811 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
812 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
813 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
814 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
815 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
816 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
817 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
818 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
819 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
820 SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates);
821 }
822 }
823 catch (Exception e)
824 {
825 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
793 } 826 }
794 827
795 #endregion Region Config 828 #endregion Region Config
@@ -1216,7 +1249,22 @@ namespace OpenSim.Region.Framework.Scenes
1216 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1249 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1217 if (m_heartbeatThread != null) 1250 if (m_heartbeatThread != null)
1218 { 1251 {
1252 m_hbRestarts++;
1253 if(m_hbRestarts > 10)
1254 Environment.Exit(1);
1255 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1256
1257//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1258//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1259//proc.EnableRaisingEvents=false;
1260//proc.StartInfo.FileName = "/bin/kill";
1261//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1262//proc.Start();
1263//proc.WaitForExit();
1264//Thread.Sleep(1000);
1265//Environment.Exit(1);
1219 m_heartbeatThread.Abort(); 1266 m_heartbeatThread.Abort();
1267 Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId);
1220 m_heartbeatThread = null; 1268 m_heartbeatThread = null;
1221 } 1269 }
1222// m_lastUpdate = Util.EnvironmentTickCount(); 1270// m_lastUpdate = Util.EnvironmentTickCount();
@@ -1505,6 +1553,8 @@ namespace OpenSim.Region.Framework.Scenes
1505 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1553 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc);
1506 tmpMS = (int)(MinFrameTime * 1000) - tmpMS; 1554 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1507 1555
1556 m_firstHeartbeat = false;
1557
1508 if (tmpMS > 0) 1558 if (tmpMS > 0)
1509 { 1559 {
1510 Thread.Sleep(tmpMS); 1560 Thread.Sleep(tmpMS);
@@ -1555,9 +1605,9 @@ namespace OpenSim.Region.Framework.Scenes
1555 1605
1556 private void CheckAtTargets() 1606 private void CheckAtTargets()
1557 { 1607 {
1558 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1608 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1559 lock (m_groupsWithTargets) 1609 lock (m_groupsWithTargets)
1560 objs = m_groupsWithTargets.Values; 1610 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1561 1611
1562 foreach (SceneObjectGroup entry in objs) 1612 foreach (SceneObjectGroup entry in objs)
1563 entry.checkAtTargets(); 1613 entry.checkAtTargets();
@@ -1638,7 +1688,7 @@ namespace OpenSim.Region.Framework.Scenes
1638 msg.fromAgentName = "Server"; 1688 msg.fromAgentName = "Server";
1639 msg.dialog = (byte)19; // Object msg 1689 msg.dialog = (byte)19; // Object msg
1640 msg.fromGroup = false; 1690 msg.fromGroup = false;
1641 msg.offline = (byte)0; 1691 msg.offline = (byte)1;
1642 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1692 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1643 msg.Position = Vector3.Zero; 1693 msg.Position = Vector3.Zero;
1644 msg.RegionID = RegionInfo.RegionID.Guid; 1694 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1860,6 +1910,19 @@ namespace OpenSim.Region.Framework.Scenes
1860 EventManager.TriggerPrimsLoaded(this); 1910 EventManager.TriggerPrimsLoaded(this);
1861 } 1911 }
1862 1912
1913 public bool SuportsRayCastFiltered()
1914 {
1915 if (PhysicsScene == null)
1916 return false;
1917 return PhysicsScene.SuportsRaycastWorldFiltered();
1918 }
1919
1920 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
1921 {
1922 if (PhysicsScene == null)
1923 return null;
1924 return PhysicsScene.RaycastWorld(position, direction, length, Count,filter);
1925 }
1863 1926
1864 /// <summary> 1927 /// <summary>
1865 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. 1928 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed.
@@ -1876,14 +1939,24 @@ namespace OpenSim.Region.Framework.Scenes
1876 /// <returns></returns> 1939 /// <returns></returns>
1877 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1940 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1878 { 1941 {
1942
1943 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1944 Vector3 wpos = Vector3.Zero;
1945 // Check for water surface intersection from above
1946 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1947 {
1948 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1949 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1950 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1951 wpos.Z = wheight;
1952 }
1953
1879 Vector3 pos = Vector3.Zero; 1954 Vector3 pos = Vector3.Zero;
1880 if (RayEndIsIntersection == (byte)1) 1955 if (RayEndIsIntersection == (byte)1)
1881 { 1956 {
1882 pos = RayEnd; 1957 pos = RayEnd;
1883 return pos;
1884 } 1958 }
1885 1959 else if (RayTargetID != UUID.Zero)
1886 if (RayTargetID != UUID.Zero)
1887 { 1960 {
1888 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1961 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1889 1962
@@ -1905,7 +1978,7 @@ namespace OpenSim.Region.Framework.Scenes
1905 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1978 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1906 1979
1907 // Un-comment out the following line to Get Raytrace results printed to the console. 1980 // Un-comment out the following line to Get Raytrace results printed to the console.
1908 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1981 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1909 float ScaleOffset = 0.5f; 1982 float ScaleOffset = 0.5f;
1910 1983
1911 // If we hit something 1984 // If we hit something
@@ -1928,13 +2001,10 @@ namespace OpenSim.Region.Framework.Scenes
1928 //pos.Z -= 0.25F; 2001 //pos.Z -= 0.25F;
1929 2002
1930 } 2003 }
1931
1932 return pos;
1933 } 2004 }
1934 else 2005 else
1935 { 2006 {
1936 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2007 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1937
1938 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2008 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1939 2009
1940 // Un-comment the following line to print the raytrace results to the console. 2010 // Un-comment the following line to print the raytrace results to the console.
@@ -1943,13 +2013,12 @@ namespace OpenSim.Region.Framework.Scenes
1943 if (ei.HitTF) 2013 if (ei.HitTF)
1944 { 2014 {
1945 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2015 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1946 } else 2016 }
2017 else
1947 { 2018 {
1948 // fall back to our stupid functionality 2019 // fall back to our stupid functionality
1949 pos = RayEnd; 2020 pos = RayEnd;
1950 } 2021 }
1951
1952 return pos;
1953 } 2022 }
1954 } 2023 }
1955 else 2024 else
@@ -1960,8 +2029,12 @@ namespace OpenSim.Region.Framework.Scenes
1960 //increase height so its above the ground. 2029 //increase height so its above the ground.
1961 //should be getting the normal of the ground at the rez point and using that? 2030 //should be getting the normal of the ground at the rez point and using that?
1962 pos.Z += scale.Z / 2f; 2031 pos.Z += scale.Z / 2f;
1963 return pos; 2032// return pos;
1964 } 2033 }
2034
2035 // check against posible water intercept
2036 if (wpos.Z > pos.Z) pos = wpos;
2037 return pos;
1965 } 2038 }
1966 2039
1967 2040
@@ -2051,7 +2124,10 @@ namespace OpenSim.Region.Framework.Scenes
2051 public bool AddRestoredSceneObject( 2124 public bool AddRestoredSceneObject(
2052 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 2125 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
2053 { 2126 {
2054 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 2127 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
2128 if (result)
2129 sceneObject.IsDeleted = false;
2130 return result;
2055 } 2131 }
2056 2132
2057 /// <summary> 2133 /// <summary>
@@ -2143,6 +2219,15 @@ namespace OpenSim.Region.Framework.Scenes
2143 /// </summary> 2219 /// </summary>
2144 public void DeleteAllSceneObjects() 2220 public void DeleteAllSceneObjects()
2145 { 2221 {
2222 DeleteAllSceneObjects(false);
2223 }
2224
2225 /// <summary>
2226 /// Delete every object from the scene. This does not include attachments worn by avatars.
2227 /// </summary>
2228 public void DeleteAllSceneObjects(bool exceptNoCopy)
2229 {
2230 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2146 lock (Entities) 2231 lock (Entities)
2147 { 2232 {
2148 EntityBase[] entities = Entities.GetEntities(); 2233 EntityBase[] entities = Entities.GetEntities();
@@ -2151,11 +2236,24 @@ namespace OpenSim.Region.Framework.Scenes
2151 if (e is SceneObjectGroup) 2236 if (e is SceneObjectGroup)
2152 { 2237 {
2153 SceneObjectGroup sog = (SceneObjectGroup)e; 2238 SceneObjectGroup sog = (SceneObjectGroup)e;
2154 if (!sog.IsAttachment) 2239 if (sog != null && !sog.IsAttachment)
2155 DeleteSceneObject((SceneObjectGroup)e, false); 2240 {
2241 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2242 {
2243 DeleteSceneObject((SceneObjectGroup)e, false);
2244 }
2245 else
2246 {
2247 toReturn.Add((SceneObjectGroup)e);
2248 }
2249 }
2156 } 2250 }
2157 } 2251 }
2158 } 2252 }
2253 if (toReturn.Count > 0)
2254 {
2255 returnObjects(toReturn.ToArray(), UUID.Zero);
2256 }
2159 } 2257 }
2160 2258
2161 /// <summary> 2259 /// <summary>
@@ -2190,6 +2288,8 @@ namespace OpenSim.Region.Framework.Scenes
2190 } 2288 }
2191 2289
2192 group.DeleteGroupFromScene(silent); 2290 group.DeleteGroupFromScene(silent);
2291 if (!silent)
2292 SendKillObject(new List<uint>() { group.LocalId });
2193 2293
2194// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2294// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2195 } 2295 }
@@ -2479,6 +2579,8 @@ namespace OpenSim.Region.Framework.Scenes
2479 2579
2480 if (newPosition != Vector3.Zero) 2580 if (newPosition != Vector3.Zero)
2481 newObject.RootPart.GroupPosition = newPosition; 2581 newObject.RootPart.GroupPosition = newPosition;
2582 if (newObject.RootPart.KeyframeMotion != null)
2583 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2482 2584
2483 if (!AddSceneObject(newObject)) 2585 if (!AddSceneObject(newObject))
2484 { 2586 {
@@ -2547,10 +2649,17 @@ namespace OpenSim.Region.Framework.Scenes
2547 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2649 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2548 public bool AddSceneObject(SceneObjectGroup sceneObject) 2650 public bool AddSceneObject(SceneObjectGroup sceneObject)
2549 { 2651 {
2652 if (sceneObject.OwnerID == UUID.Zero)
2653 {
2654 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2655 return false;
2656 }
2657
2550 // If the user is banned, we won't let any of their objects 2658 // If the user is banned, we won't let any of their objects
2551 // enter. Period. 2659 // enter. Period.
2552 // 2660 //
2553 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2661 int flags = GetUserFlags(sceneObject.OwnerID);
2662 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2554 { 2663 {
2555 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); 2664 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2556 2665
@@ -2596,12 +2705,23 @@ namespace OpenSim.Region.Framework.Scenes
2596 } 2705 }
2597 else 2706 else
2598 { 2707 {
2708 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2599 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2709 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2600 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2710 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2601 } 2711 }
2712 if (sceneObject.OwnerID == UUID.Zero)
2713 {
2714 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2715 return false;
2716 }
2602 } 2717 }
2603 else 2718 else
2604 { 2719 {
2720 if (sceneObject.OwnerID == UUID.Zero)
2721 {
2722 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2723 return false;
2724 }
2605 AddRestoredSceneObject(sceneObject, true, false); 2725 AddRestoredSceneObject(sceneObject, true, false);
2606 2726
2607 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2727 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2630,6 +2750,24 @@ namespace OpenSim.Region.Framework.Scenes
2630 return 2; // StateSource.PrimCrossing 2750 return 2; // StateSource.PrimCrossing
2631 } 2751 }
2632 2752
2753 public int GetUserFlags(UUID user)
2754 {
2755 //Unfortunately the SP approach means that the value is cached until region is restarted
2756 /*
2757 ScenePresence sp;
2758 if (TryGetScenePresence(user, out sp))
2759 {
2760 return sp.UserFlags;
2761 }
2762 else
2763 {
2764 */
2765 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2766 if (uac == null)
2767 return 0;
2768 return uac.UserFlags;
2769 //}
2770 }
2633 #endregion 2771 #endregion
2634 2772
2635 #region Add/Remove Avatar Methods 2773 #region Add/Remove Avatar Methods
@@ -2643,7 +2781,7 @@ namespace OpenSim.Region.Framework.Scenes
2643 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2781 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2644 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2782 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2645 2783
2646// CheckHeartbeat(); 2784 CheckHeartbeat();
2647 2785
2648 ScenePresence sp = GetScenePresence(client.AgentId); 2786 ScenePresence sp = GetScenePresence(client.AgentId);
2649 2787
@@ -2697,7 +2835,13 @@ namespace OpenSim.Region.Framework.Scenes
2697 2835
2698 EventManager.TriggerOnNewClient(client); 2836 EventManager.TriggerOnNewClient(client);
2699 if (vialogin) 2837 if (vialogin)
2838 {
2700 EventManager.TriggerOnClientLogin(client); 2839 EventManager.TriggerOnClientLogin(client);
2840 // Send initial parcel data
2841 Vector3 pos = sp.AbsolutePosition;
2842 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2843 land.SendLandUpdateToClient(client);
2844 }
2701 2845
2702 return sp; 2846 return sp;
2703 } 2847 }
@@ -2787,19 +2931,12 @@ namespace OpenSim.Region.Framework.Scenes
2787 // and the scene presence and the client, if they exist 2931 // and the scene presence and the client, if they exist
2788 try 2932 try
2789 { 2933 {
2790 // We need to wait for the client to make UDP contact first. 2934 ScenePresence sp = GetScenePresence(agentID);
2791 // It's the UDP contact that creates the scene presence 2935 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2792 ScenePresence sp = WaitGetScenePresence(agentID); 2936
2793 if (sp != null) 2937 if (sp != null)
2794 {
2795 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2796
2797 sp.ControllingClient.Close(); 2938 sp.ControllingClient.Close();
2798 } 2939
2799 else
2800 {
2801 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2802 }
2803 // BANG! SLASH! 2940 // BANG! SLASH!
2804 m_authenticateHandler.RemoveCircuit(agentID); 2941 m_authenticateHandler.RemoveCircuit(agentID);
2805 2942
@@ -2844,6 +2981,8 @@ namespace OpenSim.Region.Framework.Scenes
2844 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 2981 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
2845 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 2982 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2846 2983
2984 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
2985
2847 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 2986 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
2848 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 2987 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
2849 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 2988 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -2900,6 +3039,7 @@ namespace OpenSim.Region.Framework.Scenes
2900 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3039 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2901 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3040 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2902 client.OnCopyInventoryItem += CopyInventoryItem; 3041 client.OnCopyInventoryItem += CopyInventoryItem;
3042 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2903 client.OnMoveInventoryItem += MoveInventoryItem; 3043 client.OnMoveInventoryItem += MoveInventoryItem;
2904 client.OnRemoveInventoryItem += RemoveInventoryItem; 3044 client.OnRemoveInventoryItem += RemoveInventoryItem;
2905 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3045 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2971,6 +3111,8 @@ namespace OpenSim.Region.Framework.Scenes
2971 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3111 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
2972 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3112 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
2973 3113
3114 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3115
2974 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3116 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
2975 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3117 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
2976 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3118 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3073,7 +3215,7 @@ namespace OpenSim.Region.Framework.Scenes
3073 /// </summary> 3215 /// </summary>
3074 /// <param name="agentId">The avatar's Unique ID</param> 3216 /// <param name="agentId">The avatar's Unique ID</param>
3075 /// <param name="client">The IClientAPI for the client</param> 3217 /// <param name="client">The IClientAPI for the client</param>
3076 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3218 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3077 { 3219 {
3078 if (EntityTransferModule != null) 3220 if (EntityTransferModule != null)
3079 { 3221 {
@@ -3084,6 +3226,7 @@ namespace OpenSim.Region.Framework.Scenes
3084 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3226 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3085 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3227 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3086 } 3228 }
3229 return false;
3087 } 3230 }
3088 3231
3089 /// <summary> 3232 /// <summary>
@@ -3193,6 +3336,16 @@ namespace OpenSim.Region.Framework.Scenes
3193 /// <param name="flags"></param> 3336 /// <param name="flags"></param>
3194 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3337 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3195 { 3338 {
3339 //Add half the avatar's height so that the user doesn't fall through prims
3340 ScenePresence presence;
3341 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3342 {
3343 if (presence.Appearance != null)
3344 {
3345 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3346 }
3347 }
3348
3196 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3349 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3197 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3350 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3198 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3351 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3261,8 +3414,9 @@ namespace OpenSim.Region.Framework.Scenes
3261 regions.Remove(RegionInfo.RegionHandle); 3414 regions.Remove(RegionInfo.RegionHandle);
3262 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3415 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3263 } 3416 }
3264 3417 m_log.Debug("[Scene] Beginning ClientClosed");
3265 m_eventManager.TriggerClientClosed(agentID, this); 3418 m_eventManager.TriggerClientClosed(agentID, this);
3419 m_log.Debug("[Scene] Finished ClientClosed");
3266 } 3420 }
3267 catch (NullReferenceException) 3421 catch (NullReferenceException)
3268 { 3422 {
@@ -3324,9 +3478,10 @@ namespace OpenSim.Region.Framework.Scenes
3324 { 3478 {
3325 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); 3479 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace);
3326 } 3480 }
3327 3481 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3328 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3482 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3329// CleanDroppedAttachments(); 3483// CleanDroppedAttachments();
3484 m_log.Debug("[Scene] The avatar has left the building");
3330 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3485 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3331 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3486 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3332 } 3487 }
@@ -3461,13 +3616,16 @@ namespace OpenSim.Region.Framework.Scenes
3461 sp = null; 3616 sp = null;
3462 } 3617 }
3463 3618
3464 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3465 3619
3466 //On login test land permisions 3620 //On login test land permisions
3467 if (vialogin) 3621 if (vialogin)
3468 { 3622 {
3469 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3623 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3624 if (cache != null)
3625 cache.Remove(agent.firstname + " " + agent.lastname);
3626 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3470 { 3627 {
3628 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3471 return false; 3629 return false;
3472 } 3630 }
3473 } 3631 }
@@ -3490,9 +3648,15 @@ namespace OpenSim.Region.Framework.Scenes
3490 3648
3491 try 3649 try
3492 { 3650 {
3493 if (!AuthorizeUser(agent, out reason)) 3651 // Always check estate if this is a login. Always
3494 return false; 3652 // check if banned regions are to be blacked out.
3495 } catch (Exception e) 3653 if (vialogin || (!m_seeIntoBannedRegion))
3654 {
3655 if (!AuthorizeUser(agent, out reason))
3656 return false;
3657 }
3658 }
3659 catch (Exception e)
3496 { 3660 {
3497 m_log.ErrorFormat( 3661 m_log.ErrorFormat(
3498 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); 3662 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
@@ -3623,6 +3787,8 @@ namespace OpenSim.Region.Framework.Scenes
3623 } 3787 }
3624 3788
3625 // Honor parcel landing type and position. 3789 // Honor parcel landing type and position.
3790 /*
3791 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3626 if (land != null) 3792 if (land != null)
3627 { 3793 {
3628 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3794 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3630,25 +3796,34 @@ namespace OpenSim.Region.Framework.Scenes
3630 agent.startpos = land.LandData.UserLocation; 3796 agent.startpos = land.LandData.UserLocation;
3631 } 3797 }
3632 } 3798 }
3799 */// This is now handled properly in ScenePresence.MakeRootAgent
3633 } 3800 }
3634 3801
3635 return true; 3802 return true;
3636 } 3803 }
3637 3804
3638 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3805 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3639 { 3806 {
3640 bool banned = land.IsBannedFromLand(agent.AgentID); 3807 reason = String.Empty;
3641 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3808 if (Permissions.IsGod(agentID))
3809 return true;
3810
3811 ILandObject land = LandChannel.GetLandObject(posX, posY);
3812 if (land == null)
3813 return false;
3814
3815 bool banned = land.IsBannedFromLand(agentID);
3816 bool restricted = land.IsRestrictedFromLand(agentID);
3642 3817
3643 if (banned || restricted) 3818 if (banned || restricted)
3644 { 3819 {
3645 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3820 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3646 if (nearestParcel != null) 3821 if (nearestParcel != null)
3647 { 3822 {
3648 //Move agent to nearest allowed 3823 //Move agent to nearest allowed
3649 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3824 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3650 agent.startpos.X = newPosition.X; 3825 posX = newPosition.X;
3651 agent.startpos.Y = newPosition.Y; 3826 posY = newPosition.Y;
3652 } 3827 }
3653 else 3828 else
3654 { 3829 {
@@ -3710,7 +3885,7 @@ namespace OpenSim.Region.Framework.Scenes
3710 3885
3711 if (!m_strictAccessControl) return true; 3886 if (!m_strictAccessControl) return true;
3712 if (Permissions.IsGod(agent.AgentID)) return true; 3887 if (Permissions.IsGod(agent.AgentID)) return true;
3713 3888
3714 if (AuthorizationService != null) 3889 if (AuthorizationService != null)
3715 { 3890 {
3716 if (!AuthorizationService.IsAuthorizedForRegion( 3891 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3725,7 +3900,7 @@ namespace OpenSim.Region.Framework.Scenes
3725 3900
3726 if (m_regInfo.EstateSettings != null) 3901 if (m_regInfo.EstateSettings != null)
3727 { 3902 {
3728 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3903 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3729 { 3904 {
3730 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3905 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3731 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3906 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3915,6 +4090,15 @@ namespace OpenSim.Region.Framework.Scenes
3915 4090
3916 // XPTO: if this agent is not allowed here as root, always return false 4091 // XPTO: if this agent is not allowed here as root, always return false
3917 4092
4093 // We have to wait until the viewer contacts this region after receiving EAC.
4094 // That calls AddNewClient, which finally creates the ScenePresence
4095 int flags = GetUserFlags(cAgentData.AgentID);
4096 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4097 {
4098 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4099 return false;
4100 }
4101
3918 // TODO: This check should probably be in QueryAccess(). 4102 // TODO: This check should probably be in QueryAccess().
3919 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4103 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3920 if (nearestParcel == null) 4104 if (nearestParcel == null)
@@ -4008,12 +4192,22 @@ namespace OpenSim.Region.Framework.Scenes
4008 return false; 4192 return false;
4009 } 4193 }
4010 4194
4195 public bool IncomingCloseAgent(UUID agentID)
4196 {
4197 return IncomingCloseAgent(agentID, false);
4198 }
4199
4200 public bool IncomingCloseChildAgent(UUID agentID)
4201 {
4202 return IncomingCloseAgent(agentID, true);
4203 }
4204
4011 /// <summary> 4205 /// <summary>
4012 /// Tell a single agent to disconnect from the region. 4206 /// Tell a single agent to disconnect from the region.
4013 /// </summary> 4207 /// </summary>
4014 /// <param name="regionHandle"></param>
4015 /// <param name="agentID"></param> 4208 /// <param name="agentID"></param>
4016 public bool IncomingCloseAgent(UUID agentID) 4209 /// <param name="childOnly"></param>
4210 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
4017 { 4211 {
4018 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 4212 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
4019 4213
@@ -4025,7 +4219,7 @@ namespace OpenSim.Region.Framework.Scenes
4025 { 4219 {
4026 m_sceneGraph.removeUserCount(false); 4220 m_sceneGraph.removeUserCount(false);
4027 } 4221 }
4028 else 4222 else if (!childOnly)
4029 { 4223 {
4030 m_sceneGraph.removeUserCount(true); 4224 m_sceneGraph.removeUserCount(true);
4031 } 4225 }
@@ -4041,9 +4235,12 @@ namespace OpenSim.Region.Framework.Scenes
4041 } 4235 }
4042 else 4236 else
4043 presence.ControllingClient.SendShutdownConnectionNotice(); 4237 presence.ControllingClient.SendShutdownConnectionNotice();
4238 presence.ControllingClient.Close(false);
4239 }
4240 else if (!childOnly)
4241 {
4242 presence.ControllingClient.Close(true);
4044 } 4243 }
4045
4046 presence.ControllingClient.Close();
4047 return true; 4244 return true;
4048 } 4245 }
4049 4246
@@ -4629,35 +4826,81 @@ namespace OpenSim.Region.Framework.Scenes
4629 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4826 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4630 } 4827 }
4631 4828
4632 public int GetHealth() 4829 public int GetHealth(out int flags, out string message)
4633 { 4830 {
4634 // Returns: 4831 // Returns:
4635 // 1 = sim is up and accepting http requests. The heartbeat has 4832 // 1 = sim is up and accepting http requests. The heartbeat has
4636 // stopped and the sim is probably locked up, but a remote 4833 // stopped and the sim is probably locked up, but a remote
4637 // admin restart may succeed 4834 // admin restart may succeed
4638 // 4835 //
4639 // 2 = Sim is up and the heartbeat is running. The sim is likely 4836 // 2 = Sim is up and the heartbeat is running. The sim is likely
4640 // usable for people within and logins _may_ work 4837 // usable for people within
4838 //
4839 // 3 = Sim is up and one packet thread is running. Sim is
4840 // unstable and will not accept new logins
4841 //
4842 // 4 = Sim is up and both packet threads are running. Sim is
4843 // likely usable
4641 // 4844 //
4642 // 3 = We have seen a new user enter within the past 4 minutes 4845 // 5 = We have seen a new user enter within the past 4 minutes
4643 // which can be seen as positive confirmation of sim health 4846 // which can be seen as positive confirmation of sim health
4644 // 4847 //
4848
4849 flags = 0;
4850 message = String.Empty;
4851
4852 CheckHeartbeat();
4853
4854 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4855 {
4856 // We're still starting
4857 // 0 means "in startup", it can't happen another way, since
4858 // to get here, we must be able to accept http connections
4859 return 0;
4860 }
4861
4645 int health=1; // Start at 1, means we're up 4862 int health=1; // Start at 1, means we're up
4646 4863
4647 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 4864 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
4648 health += 1; 4865 {
4866 health+=1;
4867 flags |= 1;
4868 }
4869
4870 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4871 {
4872 health+=1;
4873 flags |= 2;
4874 }
4875
4876 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4877 {
4878 health+=1;
4879 flags |= 4;
4880 }
4649 else 4881 else
4882 {
4883int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
4884System.Diagnostics.Process proc = new System.Diagnostics.Process();
4885proc.EnableRaisingEvents=false;
4886proc.StartInfo.FileName = "/bin/kill";
4887proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
4888proc.Start();
4889proc.WaitForExit();
4890Thread.Sleep(1000);
4891Environment.Exit(1);
4892 }
4893
4894 if (flags != 7)
4650 return health; 4895 return health;
4651 4896
4652 // A login in the last 4 mins? We can't be doing too badly 4897 // A login in the last 4 mins? We can't be doing too badly
4653 // 4898 //
4654 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4899 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4655 health++; 4900 health++;
4656 else 4901 else
4657 return health; 4902 return health;
4658 4903
4659// CheckHeartbeat();
4660
4661 return health; 4904 return health;
4662 } 4905 }
4663 4906
@@ -4745,7 +4988,7 @@ namespace OpenSim.Region.Framework.Scenes
4745 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 4988 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
4746 if (wasUsingPhysics) 4989 if (wasUsingPhysics)
4747 { 4990 {
4748 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 4991 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
4749 } 4992 }
4750 } 4993 }
4751 4994
@@ -4844,14 +5087,14 @@ namespace OpenSim.Region.Framework.Scenes
4844 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5087 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
4845 } 5088 }
4846 5089
4847// private void CheckHeartbeat() 5090 private void CheckHeartbeat()
4848// { 5091 {
4849// if (m_firstHeartbeat) 5092 if (m_firstHeartbeat)
4850// return; 5093 return;
4851// 5094
4852// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5095 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
4853// StartTimer(); 5096 Start();
4854// } 5097 }
4855 5098
4856 public override ISceneObject DeserializeObject(string representation) 5099 public override ISceneObject DeserializeObject(string representation)
4857 { 5100 {
@@ -4863,9 +5106,14 @@ namespace OpenSim.Region.Framework.Scenes
4863 get { return m_allowScriptCrossings; } 5106 get { return m_allowScriptCrossings; }
4864 } 5107 }
4865 5108
4866 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 5109 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
4867 { 5110 {
4868 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 5111 return GetNearestAllowedPosition(avatar, null);
5112 }
5113
5114 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
5115 {
5116 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
4869 5117
4870 if (nearestParcel != null) 5118 if (nearestParcel != null)
4871 { 5119 {
@@ -4874,10 +5122,7 @@ namespace OpenSim.Region.Framework.Scenes
4874 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5122 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4875 if (nearestPoint != null) 5123 if (nearestPoint != null)
4876 { 5124 {
4877// m_log.DebugFormat( 5125 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
4878// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
4879// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
4880
4881 return nearestPoint.Value; 5126 return nearestPoint.Value;
4882 } 5127 }
4883 5128
@@ -4887,17 +5132,20 @@ namespace OpenSim.Region.Framework.Scenes
4887 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5132 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4888 if (nearestPoint != null) 5133 if (nearestPoint != null)
4889 { 5134 {
4890// m_log.DebugFormat( 5135 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
4891// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
4892
4893 return nearestPoint.Value; 5136 return nearestPoint.Value;
4894 } 5137 }
4895 5138
4896 //Ultimate backup if we have no idea where they are 5139 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
4897// m_log.DebugFormat( 5140 if (dest != excludeParcel)
4898// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); 5141 {
5142 // Ultimate backup if we have no idea where they are and
5143 // the last allowed position was in another parcel
5144 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5145 return avatar.lastKnownAllowedPosition;
5146 }
4899 5147
4900 return avatar.lastKnownAllowedPosition; 5148 // else fall through to region edge
4901 } 5149 }
4902 5150
4903 //Go to the edge, this happens in teleporting to a region with no available parcels 5151 //Go to the edge, this happens in teleporting to a region with no available parcels
@@ -4931,13 +5179,18 @@ namespace OpenSim.Region.Framework.Scenes
4931 5179
4932 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 5180 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
4933 { 5181 {
5182 return GetNearestAllowedParcel(avatarId, x, y, null);
5183 }
5184
5185 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5186 {
4934 List<ILandObject> all = AllParcels(); 5187 List<ILandObject> all = AllParcels();
4935 float minParcelDistance = float.MaxValue; 5188 float minParcelDistance = float.MaxValue;
4936 ILandObject nearestParcel = null; 5189 ILandObject nearestParcel = null;
4937 5190
4938 foreach (var parcel in all) 5191 foreach (var parcel in all)
4939 { 5192 {
4940 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 5193 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
4941 { 5194 {
4942 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5195 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
4943 if (parcelDistance < minParcelDistance) 5196 if (parcelDistance < minParcelDistance)
@@ -5179,7 +5432,55 @@ namespace OpenSim.Region.Framework.Scenes
5179 mapModule.GenerateMaptile(); 5432 mapModule.GenerateMaptile();
5180 } 5433 }
5181 5434
5182 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5435// public void CleanDroppedAttachments()
5436// {
5437// List<SceneObjectGroup> objectsToDelete =
5438// new List<SceneObjectGroup>();
5439//
5440// lock (m_cleaningAttachments)
5441// {
5442// ForEachSOG(delegate (SceneObjectGroup grp)
5443// {
5444// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5445// {
5446// UUID agentID = grp.OwnerID;
5447// if (agentID == UUID.Zero)
5448// {
5449// objectsToDelete.Add(grp);
5450// return;
5451// }
5452//
5453// ScenePresence sp = GetScenePresence(agentID);
5454// if (sp == null)
5455// {
5456// objectsToDelete.Add(grp);
5457// return;
5458// }
5459// }
5460// });
5461// }
5462//
5463// foreach (SceneObjectGroup grp in objectsToDelete)
5464// {
5465// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5466// DeleteSceneObject(grp, true);
5467// }
5468// }
5469
5470 public void ThreadAlive(int threadCode)
5471 {
5472 switch(threadCode)
5473 {
5474 case 1: // Incoming
5475 m_lastIncoming = Util.EnvironmentTickCount();
5476 break;
5477 case 2: // Incoming
5478 m_lastOutgoing = Util.EnvironmentTickCount();
5479 break;
5480 }
5481 }
5482
5483 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5183 { 5484 {
5184 RegenerateMaptile(); 5485 RegenerateMaptile();
5185 5486
@@ -5207,6 +5508,8 @@ namespace OpenSim.Region.Framework.Scenes
5207 /// <returns></returns> 5508 /// <returns></returns>
5208 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5509 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5209 { 5510 {
5511 reason = "You are banned from the region";
5512
5210 if (EntityTransferModule.IsInTransit(agentID)) 5513 if (EntityTransferModule.IsInTransit(agentID))
5211 { 5514 {
5212 reason = "Agent is still in transit from this region"; 5515 reason = "Agent is still in transit from this region";
@@ -5218,6 +5521,12 @@ namespace OpenSim.Region.Framework.Scenes
5218 return false; 5521 return false;
5219 } 5522 }
5220 5523
5524 if (Permissions.IsGod(agentID))
5525 {
5526 reason = String.Empty;
5527 return true;
5528 }
5529
5221 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. 5530 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5222 // However, the long term fix is to make sure root agent count is always accurate. 5531 // However, the long term fix is to make sure root agent count is always accurate.
5223 m_sceneGraph.RecalculateStats(); 5532 m_sceneGraph.RecalculateStats();
@@ -5238,6 +5547,41 @@ namespace OpenSim.Region.Framework.Scenes
5238 } 5547 }
5239 } 5548 }
5240 5549
5550 ScenePresence presence = GetScenePresence(agentID);
5551 IClientAPI client = null;
5552 AgentCircuitData aCircuit = null;
5553
5554 if (presence != null)
5555 {
5556 client = presence.ControllingClient;
5557 if (client != null)
5558 aCircuit = client.RequestClientInfo();
5559 }
5560
5561 // We may be called before there is a presence or a client.
5562 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5563 if (client == null)
5564 {
5565 aCircuit = new AgentCircuitData();
5566 aCircuit.AgentID = agentID;
5567 aCircuit.firstname = String.Empty;
5568 aCircuit.lastname = String.Empty;
5569 }
5570
5571 try
5572 {
5573 if (!AuthorizeUser(aCircuit, out reason))
5574 {
5575 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5576 return false;
5577 }
5578 }
5579 catch (Exception e)
5580 {
5581 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5582 return false;
5583 }
5584
5241 if (position == Vector3.Zero) // Teleport 5585 if (position == Vector3.Zero) // Teleport
5242 { 5586 {
5243 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5587 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5266,13 +5610,46 @@ namespace OpenSim.Region.Framework.Scenes
5266 } 5610 }
5267 } 5611 }
5268 } 5612 }
5613
5614 float posX = 128.0f;
5615 float posY = 128.0f;
5616
5617 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5618 {
5619 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5620 return false;
5621 }
5622 }
5623 else // Walking
5624 {
5625 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5626 if (land == null)
5627 return false;
5628
5629 bool banned = land.IsBannedFromLand(agentID);
5630 bool restricted = land.IsRestrictedFromLand(agentID);
5631
5632 if (banned || restricted)
5633 return false;
5269 } 5634 }
5270 5635
5271 reason = String.Empty; 5636 reason = String.Empty;
5272 return true; 5637 return true;
5273 } 5638 }
5274 5639
5275 /// <summary> 5640 public void StartTimerWatchdog()
5641 {
5642 m_timerWatchdog.Interval = 1000;
5643 m_timerWatchdog.Elapsed += TimerWatchdog;
5644 m_timerWatchdog.AutoReset = true;
5645 m_timerWatchdog.Start();
5646 }
5647
5648 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5649 {
5650 CheckHeartbeat();
5651 }
5652
5276 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5653 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5277 /// autopilot that moves an avatar to a sit target!. 5654 /// autopilot that moves an avatar to a sit target!.
5278 /// </summary> 5655 /// </summary>