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.cs697
1 files changed, 535 insertions, 162 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e488fe1..3e08128 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -118,6 +118,7 @@ namespace OpenSim.Region.Framework.Scenes
118 // TODO: need to figure out how allow client agents but deny 118 // TODO: need to figure out how allow client agents but deny
119 // root agents when ACL denies access to root agent 119 // root agents when ACL denies access to root agent
120 public bool m_strictAccessControl = true; 120 public bool m_strictAccessControl = true;
121 public bool m_seeIntoBannedRegion = false;
121 public int MaxUndoCount = 5; 122 public int MaxUndoCount = 5;
122 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 123 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
123 public bool LoginLock = false; 124 public bool LoginLock = false;
@@ -133,12 +134,14 @@ namespace OpenSim.Region.Framework.Scenes
133 134
134 protected int m_splitRegionID; 135 protected int m_splitRegionID;
135 protected Timer m_restartWaitTimer = new Timer(); 136 protected Timer m_restartWaitTimer = new Timer();
137 protected Timer m_timerWatchdog = new Timer();
136 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 138 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
137 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 139 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
138 protected string m_simulatorVersion = "OpenSimulator Server"; 140 protected string m_simulatorVersion = "OpenSimulator Server";
139 protected ModuleLoader m_moduleLoader; 141 protected ModuleLoader m_moduleLoader;
140 protected AgentCircuitManager m_authenticateHandler; 142 protected AgentCircuitManager m_authenticateHandler;
141 protected SceneCommunicationService m_sceneGridService; 143 protected SceneCommunicationService m_sceneGridService;
144 protected ISnmpModule m_snmpService = null;
142 145
143 protected ISimulationDataService m_SimulationDataService; 146 protected ISimulationDataService m_SimulationDataService;
144 protected IEstateDataService m_EstateDataService; 147 protected IEstateDataService m_EstateDataService;
@@ -201,7 +204,7 @@ namespace OpenSim.Region.Framework.Scenes
201 private int m_update_events = 1; 204 private int m_update_events = 1;
202 private int m_update_backup = 200; 205 private int m_update_backup = 200;
203 private int m_update_terrain = 50; 206 private int m_update_terrain = 50;
204// private int m_update_land = 1; 207 private int m_update_land = 10;
205 private int m_update_coarse_locations = 50; 208 private int m_update_coarse_locations = 50;
206 209
207 private int agentMS; 210 private int agentMS;
@@ -220,6 +223,7 @@ namespace OpenSim.Region.Framework.Scenes
220 /// </summary> 223 /// </summary>
221 private int m_lastFrameTick; 224 private int m_lastFrameTick;
222 225
226 public bool CombineRegions = false;
223 /// <summary> 227 /// <summary>
224 /// Tick at which the last maintenance run occurred. 228 /// Tick at which the last maintenance run occurred.
225 /// </summary> 229 /// </summary>
@@ -250,6 +254,11 @@ namespace OpenSim.Region.Framework.Scenes
250 /// </summary> 254 /// </summary>
251 private int m_LastLogin; 255 private int m_LastLogin;
252 256
257 private int m_lastIncoming;
258 private int m_lastOutgoing;
259 private int m_hbRestarts = 0;
260
261
253 /// <summary> 262 /// <summary>
254 /// Thread that runs the scene loop. 263 /// Thread that runs the scene loop.
255 /// </summary> 264 /// </summary>
@@ -265,7 +274,7 @@ namespace OpenSim.Region.Framework.Scenes
265 private volatile bool m_shuttingDown; 274 private volatile bool m_shuttingDown;
266 275
267// private int m_lastUpdate; 276// private int m_lastUpdate;
268// private bool m_firstHeartbeat = true; 277 private bool m_firstHeartbeat = true;
269 278
270 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 279 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
271 private bool m_reprioritizationEnabled = true; 280 private bool m_reprioritizationEnabled = true;
@@ -310,6 +319,19 @@ namespace OpenSim.Region.Framework.Scenes
310 get { return m_sceneGridService; } 319 get { return m_sceneGridService; }
311 } 320 }
312 321
322 public ISnmpModule SnmpService
323 {
324 get
325 {
326 if (m_snmpService == null)
327 {
328 m_snmpService = RequestModuleInterface<ISnmpModule>();
329 }
330
331 return m_snmpService;
332 }
333 }
334
313 public ISimulationDataService SimulationDataService 335 public ISimulationDataService SimulationDataService
314 { 336 {
315 get 337 get
@@ -592,6 +614,8 @@ namespace OpenSim.Region.Framework.Scenes
592 m_EstateDataService = estateDataService; 614 m_EstateDataService = estateDataService;
593 m_regionHandle = m_regInfo.RegionHandle; 615 m_regionHandle = m_regInfo.RegionHandle;
594 m_regionName = m_regInfo.RegionName; 616 m_regionName = m_regInfo.RegionName;
617 m_lastIncoming = 0;
618 m_lastOutgoing = 0;
595 619
596 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 620 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
597 m_asyncSceneObjectDeleter.Enabled = true; 621 m_asyncSceneObjectDeleter.Enabled = true;
@@ -672,98 +696,107 @@ namespace OpenSim.Region.Framework.Scenes
672 696
673 // Region config overrides global config 697 // Region config overrides global config
674 // 698 //
675 if (m_config.Configs["Startup"] != null) 699 try
676 { 700 {
677 IConfig startupConfig = m_config.Configs["Startup"]; 701 if (m_config.Configs["Startup"] != null)
678
679 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
680 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
681 if (!m_useBackup)
682 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
683
684 //Animation states
685 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
686
687 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
688 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
689
690 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
691 if (RegionInfo.NonphysPrimMax > 0)
692 { 702 {
693 m_maxNonphys = RegionInfo.NonphysPrimMax; 703 IConfig startupConfig = m_config.Configs["Startup"];
694 }
695 704
696 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 705 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
706 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
707 if (!m_useBackup)
708 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
709
710 //Animation states
711 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
697 712
698 if (RegionInfo.PhysPrimMax > 0) 713 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
699 { 714 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
700 m_maxPhys = RegionInfo.PhysPrimMax;
701 }
702 715
703 // Here, if clamping is requested in either global or 716 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
704 // local config, it will be used 717 if (RegionInfo.NonphysPrimMax > 0)
705 // 718 {
706 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); 719 m_maxNonphys = RegionInfo.NonphysPrimMax;
707 if (RegionInfo.ClampPrimSize) 720 }
708 {
709 m_clampPrimSize = true;
710 }
711 721
712 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 722 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
713 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
714 m_dontPersistBefore =
715 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
716 m_dontPersistBefore *= 10000000;
717 m_persistAfter =
718 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
719 m_persistAfter *= 10000000;
720 723
721 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 724 if (RegionInfo.PhysPrimMax > 0)
725 {
726 m_maxPhys = RegionInfo.PhysPrimMax;
727 }
722 728
723 IConfig packetConfig = m_config.Configs["PacketPool"]; 729 // Here, if clamping is requested in either global or
724 if (packetConfig != null) 730 // local config, it will be used
725 { 731 //
726 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); 732 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
727 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); 733 if (RegionInfo.ClampPrimSize)
728 } 734 {
735 m_clampPrimSize = true;
736 }
729 737
730 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 738 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
739 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
740 m_dontPersistBefore =
741 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
742 m_dontPersistBefore *= 10000000;
743 m_persistAfter =
744 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
745 m_persistAfter *= 10000000;
731 746
732 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 747 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
733 if (m_generateMaptiles) 748 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
734 { 749
735 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); 750 IConfig packetConfig = m_config.Configs["PacketPool"];
736 if (maptileRefresh != 0) 751 if (packetConfig != null)
737 { 752 {
738 m_mapGenerationTimer.Interval = maptileRefresh * 1000; 753 PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true);
739 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; 754 PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true);
740 m_mapGenerationTimer.AutoReset = true;
741 m_mapGenerationTimer.Start();
742 } 755 }
743 }
744 else
745 {
746 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
747 UUID tileID;
748 756
749 if (UUID.TryParse(tile, out tileID)) 757 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
758 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
759 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
760
761 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
762 if (m_generateMaptiles)
750 { 763 {
751 RegionInfo.RegionSettings.TerrainImageID = tileID; 764 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
765 if (maptileRefresh != 0)
766 {
767 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
768 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
769 m_mapGenerationTimer.AutoReset = true;
770 m_mapGenerationTimer.Start();
771 }
752 } 772 }
753 } 773 else
774 {
775 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString());
776 UUID tileID;
754 777
755 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); 778 if (UUID.TryParse(tile, out tileID))
756 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); 779 {
757 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 780 RegionInfo.RegionSettings.TerrainImageID = tileID;
758 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); 781 }
759 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); 782 }
760 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
761 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
762 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
763 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
764 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
765 783
766 SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); 784 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
785 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
786 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
787 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
788 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
789 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
790 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
791 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
792 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
793 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
794 SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates);
795 }
796 }
797 catch (Exception e)
798 {
799 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
767 } 800 }
768 801
769 #endregion Region Config 802 #endregion Region Config
@@ -1194,7 +1227,22 @@ namespace OpenSim.Region.Framework.Scenes
1194 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1227 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1195 if (m_heartbeatThread != null) 1228 if (m_heartbeatThread != null)
1196 { 1229 {
1230 m_hbRestarts++;
1231 if(m_hbRestarts > 10)
1232 Environment.Exit(1);
1233 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1234
1235//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1236//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1237//proc.EnableRaisingEvents=false;
1238//proc.StartInfo.FileName = "/bin/kill";
1239//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1240//proc.Start();
1241//proc.WaitForExit();
1242//Thread.Sleep(1000);
1243//Environment.Exit(1);
1197 m_heartbeatThread.Abort(); 1244 m_heartbeatThread.Abort();
1245 Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId);
1198 m_heartbeatThread = null; 1246 m_heartbeatThread = null;
1199 } 1247 }
1200// m_lastUpdate = Util.EnvironmentTickCount(); 1248// m_lastUpdate = Util.EnvironmentTickCount();
@@ -1507,6 +1555,8 @@ namespace OpenSim.Region.Framework.Scenes
1507 maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1555 maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc);
1508 maintc = (int)(MinFrameTime * 1000) - maintc; 1556 maintc = (int)(MinFrameTime * 1000) - maintc;
1509 1557
1558 m_firstHeartbeat = false;
1559
1510 if (maintc > 0) 1560 if (maintc > 0)
1511 Thread.Sleep(maintc); 1561 Thread.Sleep(maintc);
1512 1562
@@ -1536,9 +1586,9 @@ namespace OpenSim.Region.Framework.Scenes
1536 1586
1537 private void CheckAtTargets() 1587 private void CheckAtTargets()
1538 { 1588 {
1539 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1589 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1540 lock (m_groupsWithTargets) 1590 lock (m_groupsWithTargets)
1541 objs = m_groupsWithTargets.Values; 1591 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1542 1592
1543 foreach (SceneObjectGroup entry in objs) 1593 foreach (SceneObjectGroup entry in objs)
1544 entry.checkAtTargets(); 1594 entry.checkAtTargets();
@@ -1619,7 +1669,7 @@ namespace OpenSim.Region.Framework.Scenes
1619 msg.fromAgentName = "Server"; 1669 msg.fromAgentName = "Server";
1620 msg.dialog = (byte)19; // Object msg 1670 msg.dialog = (byte)19; // Object msg
1621 msg.fromGroup = false; 1671 msg.fromGroup = false;
1622 msg.offline = (byte)0; 1672 msg.offline = (byte)1;
1623 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1673 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1624 msg.Position = Vector3.Zero; 1674 msg.Position = Vector3.Zero;
1625 msg.RegionID = RegionInfo.RegionID.Guid; 1675 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1841,6 +1891,19 @@ namespace OpenSim.Region.Framework.Scenes
1841 EventManager.TriggerPrimsLoaded(this); 1891 EventManager.TriggerPrimsLoaded(this);
1842 } 1892 }
1843 1893
1894 public bool SuportsRayCastFiltered()
1895 {
1896 if (PhysicsScene == null)
1897 return false;
1898 return PhysicsScene.SuportsRaycastWorldFiltered();
1899 }
1900
1901 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
1902 {
1903 if (PhysicsScene == null)
1904 return null;
1905 return PhysicsScene.RaycastWorld(position, direction, length, Count,filter);
1906 }
1844 1907
1845 /// <summary> 1908 /// <summary>
1846 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. 1909 /// Gets a new rez location based on the raycast and the size of the object that is being rezzed.
@@ -1857,14 +1920,24 @@ namespace OpenSim.Region.Framework.Scenes
1857 /// <returns></returns> 1920 /// <returns></returns>
1858 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1921 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1859 { 1922 {
1923
1924 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1925 Vector3 wpos = Vector3.Zero;
1926 // Check for water surface intersection from above
1927 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1928 {
1929 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1930 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1931 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1932 wpos.Z = wheight;
1933 }
1934
1860 Vector3 pos = Vector3.Zero; 1935 Vector3 pos = Vector3.Zero;
1861 if (RayEndIsIntersection == (byte)1) 1936 if (RayEndIsIntersection == (byte)1)
1862 { 1937 {
1863 pos = RayEnd; 1938 pos = RayEnd;
1864 return pos;
1865 } 1939 }
1866 1940 else if (RayTargetID != UUID.Zero)
1867 if (RayTargetID != UUID.Zero)
1868 { 1941 {
1869 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1942 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1870 1943
@@ -1886,7 +1959,7 @@ namespace OpenSim.Region.Framework.Scenes
1886 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1959 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1887 1960
1888 // Un-comment out the following line to Get Raytrace results printed to the console. 1961 // Un-comment out the following line to Get Raytrace results printed to the console.
1889 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1962 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1890 float ScaleOffset = 0.5f; 1963 float ScaleOffset = 0.5f;
1891 1964
1892 // If we hit something 1965 // If we hit something
@@ -1909,13 +1982,10 @@ namespace OpenSim.Region.Framework.Scenes
1909 //pos.Z -= 0.25F; 1982 //pos.Z -= 0.25F;
1910 1983
1911 } 1984 }
1912
1913 return pos;
1914 } 1985 }
1915 else 1986 else
1916 { 1987 {
1917 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1988 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1918
1919 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1989 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1920 1990
1921 // Un-comment the following line to print the raytrace results to the console. 1991 // Un-comment the following line to print the raytrace results to the console.
@@ -1924,13 +1994,12 @@ namespace OpenSim.Region.Framework.Scenes
1924 if (ei.HitTF) 1994 if (ei.HitTF)
1925 { 1995 {
1926 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1996 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1927 } else 1997 }
1998 else
1928 { 1999 {
1929 // fall back to our stupid functionality 2000 // fall back to our stupid functionality
1930 pos = RayEnd; 2001 pos = RayEnd;
1931 } 2002 }
1932
1933 return pos;
1934 } 2003 }
1935 } 2004 }
1936 else 2005 else
@@ -1941,8 +2010,12 @@ namespace OpenSim.Region.Framework.Scenes
1941 //increase height so its above the ground. 2010 //increase height so its above the ground.
1942 //should be getting the normal of the ground at the rez point and using that? 2011 //should be getting the normal of the ground at the rez point and using that?
1943 pos.Z += scale.Z / 2f; 2012 pos.Z += scale.Z / 2f;
1944 return pos; 2013// return pos;
1945 } 2014 }
2015
2016 // check against posible water intercept
2017 if (wpos.Z > pos.Z) pos = wpos;
2018 return pos;
1946 } 2019 }
1947 2020
1948 2021
@@ -2032,7 +2105,10 @@ namespace OpenSim.Region.Framework.Scenes
2032 public bool AddRestoredSceneObject( 2105 public bool AddRestoredSceneObject(
2033 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 2106 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
2034 { 2107 {
2035 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 2108 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
2109 if (result)
2110 sceneObject.IsDeleted = false;
2111 return result;
2036 } 2112 }
2037 2113
2038 /// <summary> 2114 /// <summary>
@@ -2124,6 +2200,15 @@ namespace OpenSim.Region.Framework.Scenes
2124 /// </summary> 2200 /// </summary>
2125 public void DeleteAllSceneObjects() 2201 public void DeleteAllSceneObjects()
2126 { 2202 {
2203 DeleteAllSceneObjects(false);
2204 }
2205
2206 /// <summary>
2207 /// Delete every object from the scene. This does not include attachments worn by avatars.
2208 /// </summary>
2209 public void DeleteAllSceneObjects(bool exceptNoCopy)
2210 {
2211 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2127 lock (Entities) 2212 lock (Entities)
2128 { 2213 {
2129 EntityBase[] entities = Entities.GetEntities(); 2214 EntityBase[] entities = Entities.GetEntities();
@@ -2132,11 +2217,24 @@ namespace OpenSim.Region.Framework.Scenes
2132 if (e is SceneObjectGroup) 2217 if (e is SceneObjectGroup)
2133 { 2218 {
2134 SceneObjectGroup sog = (SceneObjectGroup)e; 2219 SceneObjectGroup sog = (SceneObjectGroup)e;
2135 if (!sog.IsAttachment) 2220 if (sog != null && !sog.IsAttachment)
2136 DeleteSceneObject((SceneObjectGroup)e, false); 2221 {
2222 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2223 {
2224 DeleteSceneObject((SceneObjectGroup)e, false);
2225 }
2226 else
2227 {
2228 toReturn.Add((SceneObjectGroup)e);
2229 }
2230 }
2137 } 2231 }
2138 } 2232 }
2139 } 2233 }
2234 if (toReturn.Count > 0)
2235 {
2236 returnObjects(toReturn.ToArray(), UUID.Zero);
2237 }
2140 } 2238 }
2141 2239
2142 /// <summary> 2240 /// <summary>
@@ -2171,6 +2269,8 @@ namespace OpenSim.Region.Framework.Scenes
2171 } 2269 }
2172 2270
2173 group.DeleteGroupFromScene(silent); 2271 group.DeleteGroupFromScene(silent);
2272 if (!silent)
2273 SendKillObject(new List<uint>() { group.LocalId });
2174 2274
2175// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2275// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2176 } 2276 }
@@ -2460,6 +2560,8 @@ namespace OpenSim.Region.Framework.Scenes
2460 2560
2461 if (newPosition != Vector3.Zero) 2561 if (newPosition != Vector3.Zero)
2462 newObject.RootPart.GroupPosition = newPosition; 2562 newObject.RootPart.GroupPosition = newPosition;
2563 if (newObject.RootPart.KeyframeMotion != null)
2564 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2463 2565
2464 if (!AddSceneObject(newObject)) 2566 if (!AddSceneObject(newObject))
2465 { 2567 {
@@ -2528,10 +2630,17 @@ namespace OpenSim.Region.Framework.Scenes
2528 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2630 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2529 public bool AddSceneObject(SceneObjectGroup sceneObject) 2631 public bool AddSceneObject(SceneObjectGroup sceneObject)
2530 { 2632 {
2633 if (sceneObject.OwnerID == UUID.Zero)
2634 {
2635 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2636 return false;
2637 }
2638
2531 // If the user is banned, we won't let any of their objects 2639 // If the user is banned, we won't let any of their objects
2532 // enter. Period. 2640 // enter. Period.
2533 // 2641 //
2534 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2642 int flags = GetUserFlags(sceneObject.OwnerID);
2643 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2535 { 2644 {
2536 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); 2645 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2537 2646
@@ -2577,12 +2686,23 @@ namespace OpenSim.Region.Framework.Scenes
2577 } 2686 }
2578 else 2687 else
2579 { 2688 {
2689 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2580 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2690 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2581 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2691 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2582 } 2692 }
2693 if (sceneObject.OwnerID == UUID.Zero)
2694 {
2695 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2696 return false;
2697 }
2583 } 2698 }
2584 else 2699 else
2585 { 2700 {
2701 if (sceneObject.OwnerID == UUID.Zero)
2702 {
2703 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2704 return false;
2705 }
2586 AddRestoredSceneObject(sceneObject, true, false); 2706 AddRestoredSceneObject(sceneObject, true, false);
2587 2707
2588 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2708 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2611,6 +2731,24 @@ namespace OpenSim.Region.Framework.Scenes
2611 return 2; // StateSource.PrimCrossing 2731 return 2; // StateSource.PrimCrossing
2612 } 2732 }
2613 2733
2734 public int GetUserFlags(UUID user)
2735 {
2736 //Unfortunately the SP approach means that the value is cached until region is restarted
2737 /*
2738 ScenePresence sp;
2739 if (TryGetScenePresence(user, out sp))
2740 {
2741 return sp.UserFlags;
2742 }
2743 else
2744 {
2745 */
2746 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2747 if (uac == null)
2748 return 0;
2749 return uac.UserFlags;
2750 //}
2751 }
2614 #endregion 2752 #endregion
2615 2753
2616 #region Add/Remove Avatar Methods 2754 #region Add/Remove Avatar Methods
@@ -2624,7 +2762,7 @@ namespace OpenSim.Region.Framework.Scenes
2624 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2762 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2625 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2763 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2626 2764
2627// CheckHeartbeat(); 2765 CheckHeartbeat();
2628 2766
2629 ScenePresence sp = GetScenePresence(client.AgentId); 2767 ScenePresence sp = GetScenePresence(client.AgentId);
2630 2768
@@ -2677,7 +2815,13 @@ namespace OpenSim.Region.Framework.Scenes
2677 2815
2678 EventManager.TriggerOnNewClient(client); 2816 EventManager.TriggerOnNewClient(client);
2679 if (vialogin) 2817 if (vialogin)
2818 {
2680 EventManager.TriggerOnClientLogin(client); 2819 EventManager.TriggerOnClientLogin(client);
2820 // Send initial parcel data
2821 Vector3 pos = sp.AbsolutePosition;
2822 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2823 land.SendLandUpdateToClient(client);
2824 }
2681 2825
2682 return sp; 2826 return sp;
2683 } 2827 }
@@ -2767,19 +2911,12 @@ namespace OpenSim.Region.Framework.Scenes
2767 // and the scene presence and the client, if they exist 2911 // and the scene presence and the client, if they exist
2768 try 2912 try
2769 { 2913 {
2770 // We need to wait for the client to make UDP contact first. 2914 ScenePresence sp = GetScenePresence(agentID);
2771 // It's the UDP contact that creates the scene presence 2915 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2772 ScenePresence sp = WaitGetScenePresence(agentID); 2916
2773 if (sp != null) 2917 if (sp != null)
2774 {
2775 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2776
2777 sp.ControllingClient.Close(); 2918 sp.ControllingClient.Close();
2778 } 2919
2779 else
2780 {
2781 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2782 }
2783 // BANG! SLASH! 2920 // BANG! SLASH!
2784 m_authenticateHandler.RemoveCircuit(agentID); 2921 m_authenticateHandler.RemoveCircuit(agentID);
2785 2922
@@ -2824,6 +2961,8 @@ namespace OpenSim.Region.Framework.Scenes
2824 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 2961 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
2825 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; 2962 client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition;
2826 2963
2964 client.onClientChangeObject += m_sceneGraph.ClientChangeObject;
2965
2827 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; 2966 client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation;
2828 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 2967 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
2829 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 2968 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
@@ -2880,6 +3019,7 @@ namespace OpenSim.Region.Framework.Scenes
2880 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 3019 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2881 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 3020 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2882 client.OnCopyInventoryItem += CopyInventoryItem; 3021 client.OnCopyInventoryItem += CopyInventoryItem;
3022 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2883 client.OnMoveInventoryItem += MoveInventoryItem; 3023 client.OnMoveInventoryItem += MoveInventoryItem;
2884 client.OnRemoveInventoryItem += RemoveInventoryItem; 3024 client.OnRemoveInventoryItem += RemoveInventoryItem;
2885 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 3025 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2951,6 +3091,8 @@ namespace OpenSim.Region.Framework.Scenes
2951 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; 3091 client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition;
2952 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; 3092 client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition;
2953 3093
3094 client.onClientChangeObject -= m_sceneGraph.ClientChangeObject;
3095
2954 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3096 client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation;
2955 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; 3097 client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation;
2956 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; 3098 client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation;
@@ -3053,15 +3195,16 @@ namespace OpenSim.Region.Framework.Scenes
3053 /// </summary> 3195 /// </summary>
3054 /// <param name="agentId">The avatar's Unique ID</param> 3196 /// <param name="agentId">The avatar's Unique ID</param>
3055 /// <param name="client">The IClientAPI for the client</param> 3197 /// <param name="client">The IClientAPI for the client</param>
3056 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3198 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3057 { 3199 {
3058 if (m_teleportModule != null) 3200 if (m_teleportModule != null)
3059 m_teleportModule.TeleportHome(agentId, client); 3201 return m_teleportModule.TeleportHome(agentId, client);
3060 else 3202 else
3061 { 3203 {
3062 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3204 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
3063 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3205 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
3064 } 3206 }
3207 return false;
3065 } 3208 }
3066 3209
3067 /// <summary> 3210 /// <summary>
@@ -3171,6 +3314,16 @@ namespace OpenSim.Region.Framework.Scenes
3171 /// <param name="flags"></param> 3314 /// <param name="flags"></param>
3172 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3315 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3173 { 3316 {
3317 //Add half the avatar's height so that the user doesn't fall through prims
3318 ScenePresence presence;
3319 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3320 {
3321 if (presence.Appearance != null)
3322 {
3323 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3324 }
3325 }
3326
3174 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3327 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3175 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3328 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3176 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3329 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3239,8 +3392,9 @@ namespace OpenSim.Region.Framework.Scenes
3239 regions.Remove(RegionInfo.RegionHandle); 3392 regions.Remove(RegionInfo.RegionHandle);
3240 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3393 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3241 } 3394 }
3242 3395 m_log.Debug("[Scene] Beginning ClientClosed");
3243 m_eventManager.TriggerClientClosed(agentID, this); 3396 m_eventManager.TriggerClientClosed(agentID, this);
3397 m_log.Debug("[Scene] Finished ClientClosed");
3244 } 3398 }
3245 catch (NullReferenceException) 3399 catch (NullReferenceException)
3246 { 3400 {
@@ -3302,9 +3456,10 @@ namespace OpenSim.Region.Framework.Scenes
3302 { 3456 {
3303 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); 3457 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace);
3304 } 3458 }
3305 3459 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3306 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3460 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3307// CleanDroppedAttachments(); 3461// CleanDroppedAttachments();
3462 m_log.Debug("[Scene] The avatar has left the building");
3308 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3463 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3309 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3464 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3310 } 3465 }
@@ -3426,13 +3581,16 @@ namespace OpenSim.Region.Framework.Scenes
3426 sp = null; 3581 sp = null;
3427 } 3582 }
3428 3583
3429 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3430 3584
3431 //On login test land permisions 3585 //On login test land permisions
3432 if (vialogin) 3586 if (vialogin)
3433 { 3587 {
3434 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3588 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3589 if (cache != null)
3590 cache.Remove(agent.firstname + " " + agent.lastname);
3591 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3435 { 3592 {
3593 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3436 return false; 3594 return false;
3437 } 3595 }
3438 } 3596 }
@@ -3456,8 +3614,13 @@ namespace OpenSim.Region.Framework.Scenes
3456 3614
3457 try 3615 try
3458 { 3616 {
3459 if (!AuthorizeUser(agent, out reason)) 3617 // Always check estate if this is a login. Always
3460 return false; 3618 // check if banned regions are to be blacked out.
3619 if (vialogin || (!m_seeIntoBannedRegion))
3620 {
3621 if (!AuthorizeUser(agent, out reason))
3622 return false;
3623 }
3461 } 3624 }
3462 catch (Exception e) 3625 catch (Exception e)
3463 { 3626 {
@@ -3583,6 +3746,8 @@ namespace OpenSim.Region.Framework.Scenes
3583 } 3746 }
3584 3747
3585 // Honor parcel landing type and position. 3748 // Honor parcel landing type and position.
3749 /*
3750 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3586 if (land != null) 3751 if (land != null)
3587 { 3752 {
3588 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3753 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3590,26 +3755,34 @@ namespace OpenSim.Region.Framework.Scenes
3590 agent.startpos = land.LandData.UserLocation; 3755 agent.startpos = land.LandData.UserLocation;
3591 } 3756 }
3592 } 3757 }
3758 */// This is now handled properly in ScenePresence.MakeRootAgent
3593 } 3759 }
3594 3760
3595 return true; 3761 return true;
3596 } 3762 }
3597 3763
3598 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3764 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3599 { 3765 {
3600 3766 reason = String.Empty;
3601 bool banned = land.IsBannedFromLand(agent.AgentID); 3767 if (Permissions.IsGod(agentID))
3602 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3768 return true;
3769
3770 ILandObject land = LandChannel.GetLandObject(posX, posY);
3771 if (land == null)
3772 return false;
3773
3774 bool banned = land.IsBannedFromLand(agentID);
3775 bool restricted = land.IsRestrictedFromLand(agentID);
3603 3776
3604 if (banned || restricted) 3777 if (banned || restricted)
3605 { 3778 {
3606 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3779 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3607 if (nearestParcel != null) 3780 if (nearestParcel != null)
3608 { 3781 {
3609 //Move agent to nearest allowed 3782 //Move agent to nearest allowed
3610 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3783 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3611 agent.startpos.X = newPosition.X; 3784 posX = newPosition.X;
3612 agent.startpos.Y = newPosition.Y; 3785 posY = newPosition.Y;
3613 } 3786 }
3614 else 3787 else
3615 { 3788 {
@@ -3671,7 +3844,7 @@ namespace OpenSim.Region.Framework.Scenes
3671 3844
3672 if (!m_strictAccessControl) return true; 3845 if (!m_strictAccessControl) return true;
3673 if (Permissions.IsGod(agent.AgentID)) return true; 3846 if (Permissions.IsGod(agent.AgentID)) return true;
3674 3847
3675 if (AuthorizationService != null) 3848 if (AuthorizationService != null)
3676 { 3849 {
3677 if (!AuthorizationService.IsAuthorizedForRegion( 3850 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3686,7 +3859,7 @@ namespace OpenSim.Region.Framework.Scenes
3686 3859
3687 if (m_regInfo.EstateSettings != null) 3860 if (m_regInfo.EstateSettings != null)
3688 { 3861 {
3689 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3862 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3690 { 3863 {
3691 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3864 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3692 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3865 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3878,6 +4051,13 @@ namespace OpenSim.Region.Framework.Scenes
3878 4051
3879 // We have to wait until the viewer contacts this region after receiving EAC. 4052 // We have to wait until the viewer contacts this region after receiving EAC.
3880 // That calls AddNewClient, which finally creates the ScenePresence 4053 // That calls AddNewClient, which finally creates the ScenePresence
4054 int flags = GetUserFlags(cAgentData.AgentID);
4055 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
4056 {
4057 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
4058 return false;
4059 }
4060
3881 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4061 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3882 if (nearestParcel == null) 4062 if (nearestParcel == null)
3883 { 4063 {
@@ -3959,12 +4139,22 @@ namespace OpenSim.Region.Framework.Scenes
3959 return false; 4139 return false;
3960 } 4140 }
3961 4141
4142 public bool IncomingCloseAgent(UUID agentID)
4143 {
4144 return IncomingCloseAgent(agentID, false);
4145 }
4146
4147 public bool IncomingCloseChildAgent(UUID agentID)
4148 {
4149 return IncomingCloseAgent(agentID, true);
4150 }
4151
3962 /// <summary> 4152 /// <summary>
3963 /// Tell a single agent to disconnect from the region. 4153 /// Tell a single agent to disconnect from the region.
3964 /// </summary> 4154 /// </summary>
3965 /// <param name="regionHandle"></param>
3966 /// <param name="agentID"></param> 4155 /// <param name="agentID"></param>
3967 public bool IncomingCloseAgent(UUID agentID) 4156 /// <param name="childOnly"></param>
4157 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3968 { 4158 {
3969 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 4159 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3970 4160
@@ -3976,7 +4166,7 @@ namespace OpenSim.Region.Framework.Scenes
3976 { 4166 {
3977 m_sceneGraph.removeUserCount(false); 4167 m_sceneGraph.removeUserCount(false);
3978 } 4168 }
3979 else 4169 else if (!childOnly)
3980 { 4170 {
3981 m_sceneGraph.removeUserCount(true); 4171 m_sceneGraph.removeUserCount(true);
3982 } 4172 }
@@ -3992,9 +4182,12 @@ namespace OpenSim.Region.Framework.Scenes
3992 } 4182 }
3993 else 4183 else
3994 presence.ControllingClient.SendShutdownConnectionNotice(); 4184 presence.ControllingClient.SendShutdownConnectionNotice();
4185 presence.ControllingClient.Close(false);
4186 }
4187 else if (!childOnly)
4188 {
4189 presence.ControllingClient.Close(true);
3995 } 4190 }
3996
3997 presence.ControllingClient.Close();
3998 return true; 4191 return true;
3999 } 4192 }
4000 4193
@@ -4576,35 +4769,81 @@ namespace OpenSim.Region.Framework.Scenes
4576 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4769 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4577 } 4770 }
4578 4771
4579 public int GetHealth() 4772 public int GetHealth(out int flags, out string message)
4580 { 4773 {
4581 // Returns: 4774 // Returns:
4582 // 1 = sim is up and accepting http requests. The heartbeat has 4775 // 1 = sim is up and accepting http requests. The heartbeat has
4583 // stopped and the sim is probably locked up, but a remote 4776 // stopped and the sim is probably locked up, but a remote
4584 // admin restart may succeed 4777 // admin restart may succeed
4585 // 4778 //
4586 // 2 = Sim is up and the heartbeat is running. The sim is likely 4779 // 2 = Sim is up and the heartbeat is running. The sim is likely
4587 // usable for people within and logins _may_ work 4780 // usable for people within
4781 //
4782 // 3 = Sim is up and one packet thread is running. Sim is
4783 // unstable and will not accept new logins
4784 //
4785 // 4 = Sim is up and both packet threads are running. Sim is
4786 // likely usable
4588 // 4787 //
4589 // 3 = We have seen a new user enter within the past 4 minutes 4788 // 5 = We have seen a new user enter within the past 4 minutes
4590 // which can be seen as positive confirmation of sim health 4789 // which can be seen as positive confirmation of sim health
4591 // 4790 //
4791
4792 flags = 0;
4793 message = String.Empty;
4794
4795 CheckHeartbeat();
4796
4797 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4798 {
4799 // We're still starting
4800 // 0 means "in startup", it can't happen another way, since
4801 // to get here, we must be able to accept http connections
4802 return 0;
4803 }
4804
4592 int health=1; // Start at 1, means we're up 4805 int health=1; // Start at 1, means we're up
4593 4806
4594 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 4807 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
4595 health += 1; 4808 {
4809 health+=1;
4810 flags |= 1;
4811 }
4812
4813 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4814 {
4815 health+=1;
4816 flags |= 2;
4817 }
4818
4819 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4820 {
4821 health+=1;
4822 flags |= 4;
4823 }
4596 else 4824 else
4825 {
4826int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
4827System.Diagnostics.Process proc = new System.Diagnostics.Process();
4828proc.EnableRaisingEvents=false;
4829proc.StartInfo.FileName = "/bin/kill";
4830proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
4831proc.Start();
4832proc.WaitForExit();
4833Thread.Sleep(1000);
4834Environment.Exit(1);
4835 }
4836
4837 if (flags != 7)
4597 return health; 4838 return health;
4598 4839
4599 // A login in the last 4 mins? We can't be doing too badly 4840 // A login in the last 4 mins? We can't be doing too badly
4600 // 4841 //
4601 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4842 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4602 health++; 4843 health++;
4603 else 4844 else
4604 return health; 4845 return health;
4605 4846
4606// CheckHeartbeat();
4607
4608 return health; 4847 return health;
4609 } 4848 }
4610 4849
@@ -4692,7 +4931,7 @@ namespace OpenSim.Region.Framework.Scenes
4692 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 4931 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
4693 if (wasUsingPhysics) 4932 if (wasUsingPhysics)
4694 { 4933 {
4695 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 4934 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
4696 } 4935 }
4697 } 4936 }
4698 4937
@@ -4791,14 +5030,14 @@ namespace OpenSim.Region.Framework.Scenes
4791 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5030 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
4792 } 5031 }
4793 5032
4794// private void CheckHeartbeat() 5033 private void CheckHeartbeat()
4795// { 5034 {
4796// if (m_firstHeartbeat) 5035 if (m_firstHeartbeat)
4797// return; 5036 return;
4798// 5037
4799// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5038 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000)
4800// StartTimer(); 5039 Start();
4801// } 5040 }
4802 5041
4803 public override ISceneObject DeserializeObject(string representation) 5042 public override ISceneObject DeserializeObject(string representation)
4804 { 5043 {
@@ -4810,9 +5049,14 @@ namespace OpenSim.Region.Framework.Scenes
4810 get { return m_allowScriptCrossings; } 5049 get { return m_allowScriptCrossings; }
4811 } 5050 }
4812 5051
4813 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 5052 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
4814 { 5053 {
4815 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 5054 return GetNearestAllowedPosition(avatar, null);
5055 }
5056
5057 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
5058 {
5059 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
4816 5060
4817 if (nearestParcel != null) 5061 if (nearestParcel != null)
4818 { 5062 {
@@ -4821,10 +5065,7 @@ namespace OpenSim.Region.Framework.Scenes
4821 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5065 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4822 if (nearestPoint != null) 5066 if (nearestPoint != null)
4823 { 5067 {
4824// m_log.DebugFormat( 5068 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
4825// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
4826// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
4827
4828 return nearestPoint.Value; 5069 return nearestPoint.Value;
4829 } 5070 }
4830 5071
@@ -4834,17 +5075,20 @@ namespace OpenSim.Region.Framework.Scenes
4834 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5075 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4835 if (nearestPoint != null) 5076 if (nearestPoint != null)
4836 { 5077 {
4837// m_log.DebugFormat( 5078 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
4838// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
4839
4840 return nearestPoint.Value; 5079 return nearestPoint.Value;
4841 } 5080 }
4842 5081
4843 //Ultimate backup if we have no idea where they are 5082 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
4844// m_log.DebugFormat( 5083 if (dest != excludeParcel)
4845// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); 5084 {
5085 // Ultimate backup if we have no idea where they are and
5086 // the last allowed position was in another parcel
5087 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5088 return avatar.lastKnownAllowedPosition;
5089 }
4846 5090
4847 return avatar.lastKnownAllowedPosition; 5091 // else fall through to region edge
4848 } 5092 }
4849 5093
4850 //Go to the edge, this happens in teleporting to a region with no available parcels 5094 //Go to the edge, this happens in teleporting to a region with no available parcels
@@ -4878,13 +5122,18 @@ namespace OpenSim.Region.Framework.Scenes
4878 5122
4879 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 5123 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
4880 { 5124 {
5125 return GetNearestAllowedParcel(avatarId, x, y, null);
5126 }
5127
5128 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5129 {
4881 List<ILandObject> all = AllParcels(); 5130 List<ILandObject> all = AllParcels();
4882 float minParcelDistance = float.MaxValue; 5131 float minParcelDistance = float.MaxValue;
4883 ILandObject nearestParcel = null; 5132 ILandObject nearestParcel = null;
4884 5133
4885 foreach (var parcel in all) 5134 foreach (var parcel in all)
4886 { 5135 {
4887 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 5136 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
4888 { 5137 {
4889 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5138 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
4890 if (parcelDistance < minParcelDistance) 5139 if (parcelDistance < minParcelDistance)
@@ -5126,7 +5375,55 @@ namespace OpenSim.Region.Framework.Scenes
5126 mapModule.GenerateMaptile(); 5375 mapModule.GenerateMaptile();
5127 } 5376 }
5128 5377
5129 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5378// public void CleanDroppedAttachments()
5379// {
5380// List<SceneObjectGroup> objectsToDelete =
5381// new List<SceneObjectGroup>();
5382//
5383// lock (m_cleaningAttachments)
5384// {
5385// ForEachSOG(delegate (SceneObjectGroup grp)
5386// {
5387// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5388// {
5389// UUID agentID = grp.OwnerID;
5390// if (agentID == UUID.Zero)
5391// {
5392// objectsToDelete.Add(grp);
5393// return;
5394// }
5395//
5396// ScenePresence sp = GetScenePresence(agentID);
5397// if (sp == null)
5398// {
5399// objectsToDelete.Add(grp);
5400// return;
5401// }
5402// }
5403// });
5404// }
5405//
5406// foreach (SceneObjectGroup grp in objectsToDelete)
5407// {
5408// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5409// DeleteSceneObject(grp, true);
5410// }
5411// }
5412
5413 public void ThreadAlive(int threadCode)
5414 {
5415 switch(threadCode)
5416 {
5417 case 1: // Incoming
5418 m_lastIncoming = Util.EnvironmentTickCount();
5419 break;
5420 case 2: // Incoming
5421 m_lastOutgoing = Util.EnvironmentTickCount();
5422 break;
5423 }
5424 }
5425
5426 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5130 { 5427 {
5131 RegenerateMaptile(); 5428 RegenerateMaptile();
5132 5429
@@ -5145,6 +5442,14 @@ namespace OpenSim.Region.Framework.Scenes
5145 // child agent creation, thereby emulating the SL behavior. 5442 // child agent creation, thereby emulating the SL behavior.
5146 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5443 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5147 { 5444 {
5445 reason = "You are banned from the region";
5446
5447 if (Permissions.IsGod(agentID))
5448 {
5449 reason = String.Empty;
5450 return true;
5451 }
5452
5148 int num = m_sceneGraph.GetNumberOfScenePresences(); 5453 int num = m_sceneGraph.GetNumberOfScenePresences();
5149 5454
5150 if (num >= RegionInfo.RegionSettings.AgentLimit) 5455 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5156,6 +5461,41 @@ namespace OpenSim.Region.Framework.Scenes
5156 } 5461 }
5157 } 5462 }
5158 5463
5464 ScenePresence presence = GetScenePresence(agentID);
5465 IClientAPI client = null;
5466 AgentCircuitData aCircuit = null;
5467
5468 if (presence != null)
5469 {
5470 client = presence.ControllingClient;
5471 if (client != null)
5472 aCircuit = client.RequestClientInfo();
5473 }
5474
5475 // We may be called before there is a presence or a client.
5476 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5477 if (client == null)
5478 {
5479 aCircuit = new AgentCircuitData();
5480 aCircuit.AgentID = agentID;
5481 aCircuit.firstname = String.Empty;
5482 aCircuit.lastname = String.Empty;
5483 }
5484
5485 try
5486 {
5487 if (!AuthorizeUser(aCircuit, out reason))
5488 {
5489 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5490 return false;
5491 }
5492 }
5493 catch (Exception e)
5494 {
5495 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5496 return false;
5497 }
5498
5159 if (position == Vector3.Zero) // Teleport 5499 if (position == Vector3.Zero) // Teleport
5160 { 5500 {
5161 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5501 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5184,13 +5524,46 @@ namespace OpenSim.Region.Framework.Scenes
5184 } 5524 }
5185 } 5525 }
5186 } 5526 }
5527
5528 float posX = 128.0f;
5529 float posY = 128.0f;
5530
5531 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5532 {
5533 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5534 return false;
5535 }
5536 }
5537 else // Walking
5538 {
5539 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5540 if (land == null)
5541 return false;
5542
5543 bool banned = land.IsBannedFromLand(agentID);
5544 bool restricted = land.IsRestrictedFromLand(agentID);
5545
5546 if (banned || restricted)
5547 return false;
5187 } 5548 }
5188 5549
5189 reason = String.Empty; 5550 reason = String.Empty;
5190 return true; 5551 return true;
5191 } 5552 }
5192 5553
5193 /// <summary> 5554 public void StartTimerWatchdog()
5555 {
5556 m_timerWatchdog.Interval = 1000;
5557 m_timerWatchdog.Elapsed += TimerWatchdog;
5558 m_timerWatchdog.AutoReset = true;
5559 m_timerWatchdog.Start();
5560 }
5561
5562 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5563 {
5564 CheckHeartbeat();
5565 }
5566
5194 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5567 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5195 /// autopilot that moves an avatar to a sit target!. 5568 /// autopilot that moves an avatar to a sit target!.
5196 /// </summary> 5569 /// </summary>