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.cs489
1 files changed, 416 insertions, 73 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 975d769..9b31fac 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -104,6 +104,7 @@ namespace OpenSim.Region.Framework.Scenes
104 // TODO: need to figure out how allow client agents but deny 104 // TODO: need to figure out how allow client agents but deny
105 // root agents when ACL denies access to root agent 105 // root agents when ACL denies access to root agent
106 public bool m_strictAccessControl = true; 106 public bool m_strictAccessControl = true;
107 public bool m_seeIntoBannedRegion = false;
107 public int MaxUndoCount = 5; 108 public int MaxUndoCount = 5;
108 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 109 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
109 public bool LoginLock = false; 110 public bool LoginLock = false;
@@ -119,12 +120,14 @@ namespace OpenSim.Region.Framework.Scenes
119 120
120 protected int m_splitRegionID; 121 protected int m_splitRegionID;
121 protected Timer m_restartWaitTimer = new Timer(); 122 protected Timer m_restartWaitTimer = new Timer();
123 protected Timer m_timerWatchdog = new Timer();
122 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 124 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
123 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 125 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
124 protected string m_simulatorVersion = "OpenSimulator Server"; 126 protected string m_simulatorVersion = "OpenSimulator Server";
125 protected ModuleLoader m_moduleLoader; 127 protected ModuleLoader m_moduleLoader;
126 protected AgentCircuitManager m_authenticateHandler; 128 protected AgentCircuitManager m_authenticateHandler;
127 protected SceneCommunicationService m_sceneGridService; 129 protected SceneCommunicationService m_sceneGridService;
130 protected ISnmpModule m_snmpService = null;
128 131
129 protected ISimulationDataService m_SimulationDataService; 132 protected ISimulationDataService m_SimulationDataService;
130 protected IEstateDataService m_EstateDataService; 133 protected IEstateDataService m_EstateDataService;
@@ -177,7 +180,7 @@ namespace OpenSim.Region.Framework.Scenes
177 private int m_update_events = 1; 180 private int m_update_events = 1;
178 private int m_update_backup = 200; 181 private int m_update_backup = 200;
179 private int m_update_terrain = 50; 182 private int m_update_terrain = 50;
180// private int m_update_land = 1; 183 private int m_update_land = 10;
181 private int m_update_coarse_locations = 50; 184 private int m_update_coarse_locations = 50;
182 185
183 private int agentMS; 186 private int agentMS;
@@ -192,6 +195,7 @@ namespace OpenSim.Region.Framework.Scenes
192 private int landMS; 195 private int landMS;
193 private int lastCompletedFrame; 196 private int lastCompletedFrame;
194 197
198 public bool CombineRegions = false;
195 /// <summary> 199 /// <summary>
196 /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched 200 /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched
197 /// asynchronously from the update loop. 201 /// asynchronously from the update loop.
@@ -214,11 +218,14 @@ namespace OpenSim.Region.Framework.Scenes
214 private bool m_scripts_enabled = true; 218 private bool m_scripts_enabled = true;
215 private string m_defaultScriptEngine; 219 private string m_defaultScriptEngine;
216 private int m_LastLogin; 220 private int m_LastLogin;
217 private Thread HeartbeatThread; 221 private Thread HeartbeatThread = null;
218 private volatile bool shuttingdown; 222 private volatile bool shuttingdown;
219 223
220 private int m_lastUpdate; 224 private int m_lastUpdate;
225 private int m_lastIncoming;
226 private int m_lastOutgoing;
221 private bool m_firstHeartbeat = true; 227 private bool m_firstHeartbeat = true;
228 private int m_hbRestarts = 0;
222 229
223 private object m_deleting_scene_object = new object(); 230 private object m_deleting_scene_object = new object();
224 231
@@ -265,6 +272,19 @@ namespace OpenSim.Region.Framework.Scenes
265 get { return m_sceneGridService; } 272 get { return m_sceneGridService; }
266 } 273 }
267 274
275 public ISnmpModule SnmpService
276 {
277 get
278 {
279 if (m_snmpService == null)
280 {
281 m_snmpService = RequestModuleInterface<ISnmpModule>();
282 }
283
284 return m_snmpService;
285 }
286 }
287
268 public ISimulationDataService SimulationDataService 288 public ISimulationDataService SimulationDataService
269 { 289 {
270 get 290 get
@@ -546,6 +566,9 @@ namespace OpenSim.Region.Framework.Scenes
546 m_EstateDataService = estateDataService; 566 m_EstateDataService = estateDataService;
547 m_regionHandle = m_regInfo.RegionHandle; 567 m_regionHandle = m_regInfo.RegionHandle;
548 m_regionName = m_regInfo.RegionName; 568 m_regionName = m_regInfo.RegionName;
569 m_lastUpdate = Util.EnvironmentTickCount();
570 m_lastIncoming = 0;
571 m_lastOutgoing = 0;
549 572
550 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 573 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
551 m_asyncSceneObjectDeleter.Enabled = true; 574 m_asyncSceneObjectDeleter.Enabled = true;
@@ -663,6 +686,7 @@ namespace OpenSim.Region.Framework.Scenes
663 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); 686 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
664 687
665 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 688 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
689
666 if (RegionInfo.NonphysPrimMax > 0) 690 if (RegionInfo.NonphysPrimMax > 0)
667 { 691 {
668 m_maxNonphys = RegionInfo.NonphysPrimMax; 692 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -694,6 +718,7 @@ namespace OpenSim.Region.Framework.Scenes
694 m_persistAfter *= 10000000; 718 m_persistAfter *= 10000000;
695 719
696 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 720 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
721 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
697 722
698 IConfig packetConfig = m_config.Configs["PacketPool"]; 723 IConfig packetConfig = m_config.Configs["PacketPool"];
699 if (packetConfig != null) 724 if (packetConfig != null)
@@ -703,6 +728,8 @@ namespace OpenSim.Region.Framework.Scenes
703 } 728 }
704 729
705 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 730 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
731 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
732 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
706 733
707 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 734 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
708 if (m_generateMaptiles) 735 if (m_generateMaptiles)
@@ -738,9 +765,9 @@ namespace OpenSim.Region.Framework.Scenes
738 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); 765 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
739 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); 766 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
740 } 767 }
741 catch 768 catch (Exception e)
742 { 769 {
743 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 770 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
744 } 771 }
745 772
746 #endregion Region Config 773 #endregion Region Config
@@ -1151,7 +1178,22 @@ namespace OpenSim.Region.Framework.Scenes
1151 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1178 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1152 if (HeartbeatThread != null) 1179 if (HeartbeatThread != null)
1153 { 1180 {
1181 m_hbRestarts++;
1182 if(m_hbRestarts > 10)
1183 Environment.Exit(1);
1184 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1185
1186//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1187//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1188//proc.EnableRaisingEvents=false;
1189//proc.StartInfo.FileName = "/bin/kill";
1190//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1191//proc.Start();
1192//proc.WaitForExit();
1193//Thread.Sleep(1000);
1194//Environment.Exit(1);
1154 HeartbeatThread.Abort(); 1195 HeartbeatThread.Abort();
1196 Watchdog.AbortThread(HeartbeatThread.ManagedThreadId);
1155 HeartbeatThread = null; 1197 HeartbeatThread = null;
1156 } 1198 }
1157 m_lastUpdate = Util.EnvironmentTickCount(); 1199 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1198,9 +1240,6 @@ namespace OpenSim.Region.Framework.Scenes
1198 m_eventManager.TriggerOnRegionStarted(this); 1240 m_eventManager.TriggerOnRegionStarted(this);
1199 while (!shuttingdown) 1241 while (!shuttingdown)
1200 Update(); 1242 Update();
1201
1202 m_lastUpdate = Util.EnvironmentTickCount();
1203 m_firstHeartbeat = false;
1204 } 1243 }
1205 catch (ThreadAbortException) 1244 catch (ThreadAbortException)
1206 { 1245 {
@@ -1298,6 +1337,13 @@ namespace OpenSim.Region.Framework.Scenes
1298 eventMS = Util.EnvironmentTickCountSubtract(evMS); ; 1337 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1299 } 1338 }
1300 1339
1340 // if (Frame % m_update_land == 0)
1341 // {
1342 // int ldMS = Util.EnvironmentTickCount();
1343 // UpdateLand();
1344 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1345 // }
1346
1301 if (Frame % m_update_backup == 0) 1347 if (Frame % m_update_backup == 0)
1302 { 1348 {
1303 int backMS = Util.EnvironmentTickCount(); 1349 int backMS = Util.EnvironmentTickCount();
@@ -1405,12 +1451,16 @@ namespace OpenSim.Region.Framework.Scenes
1405 maintc = Util.EnvironmentTickCountSubtract(maintc); 1451 maintc = Util.EnvironmentTickCountSubtract(maintc);
1406 maintc = (int)(MinFrameTime * 1000) - maintc; 1452 maintc = (int)(MinFrameTime * 1000) - maintc;
1407 1453
1454
1455 m_lastUpdate = Util.EnvironmentTickCount();
1456 m_firstHeartbeat = false;
1457
1408 if (maintc > 0) 1458 if (maintc > 0)
1409 Thread.Sleep(maintc); 1459 Thread.Sleep(maintc);
1410 1460
1411 // Tell the watchdog that this thread is still alive 1461 // Tell the watchdog that this thread is still alive
1412 Watchdog.UpdateThread(); 1462 Watchdog.UpdateThread();
1413 } 1463 }
1414 1464
1415 public void AddGroupTarget(SceneObjectGroup grp) 1465 public void AddGroupTarget(SceneObjectGroup grp)
1416 { 1466 {
@@ -1426,9 +1476,9 @@ namespace OpenSim.Region.Framework.Scenes
1426 1476
1427 private void CheckAtTargets() 1477 private void CheckAtTargets()
1428 { 1478 {
1429 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1479 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1430 lock (m_groupsWithTargets) 1480 lock (m_groupsWithTargets)
1431 objs = m_groupsWithTargets.Values; 1481 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1432 1482
1433 foreach (SceneObjectGroup entry in objs) 1483 foreach (SceneObjectGroup entry in objs)
1434 entry.checkAtTargets(); 1484 entry.checkAtTargets();
@@ -1510,7 +1560,7 @@ namespace OpenSim.Region.Framework.Scenes
1510 msg.fromAgentName = "Server"; 1560 msg.fromAgentName = "Server";
1511 msg.dialog = (byte)19; // Object msg 1561 msg.dialog = (byte)19; // Object msg
1512 msg.fromGroup = false; 1562 msg.fromGroup = false;
1513 msg.offline = (byte)0; 1563 msg.offline = (byte)1;
1514 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1564 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1515 msg.Position = Vector3.Zero; 1565 msg.Position = Vector3.Zero;
1516 msg.RegionID = RegionInfo.RegionID.Guid; 1566 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1741,14 +1791,24 @@ namespace OpenSim.Region.Framework.Scenes
1741 /// <returns></returns> 1791 /// <returns></returns>
1742 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1792 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1743 { 1793 {
1794
1795 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1796 Vector3 wpos = Vector3.Zero;
1797 // Check for water surface intersection from above
1798 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1799 {
1800 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1801 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1802 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1803 wpos.Z = wheight;
1804 }
1805
1744 Vector3 pos = Vector3.Zero; 1806 Vector3 pos = Vector3.Zero;
1745 if (RayEndIsIntersection == (byte)1) 1807 if (RayEndIsIntersection == (byte)1)
1746 { 1808 {
1747 pos = RayEnd; 1809 pos = RayEnd;
1748 return pos;
1749 } 1810 }
1750 1811 else if (RayTargetID != UUID.Zero)
1751 if (RayTargetID != UUID.Zero)
1752 { 1812 {
1753 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1813 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1754 1814
@@ -1770,7 +1830,7 @@ namespace OpenSim.Region.Framework.Scenes
1770 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1830 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1771 1831
1772 // Un-comment out the following line to Get Raytrace results printed to the console. 1832 // Un-comment out the following line to Get Raytrace results printed to the console.
1773 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1833 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1774 float ScaleOffset = 0.5f; 1834 float ScaleOffset = 0.5f;
1775 1835
1776 // If we hit something 1836 // If we hit something
@@ -1793,13 +1853,10 @@ namespace OpenSim.Region.Framework.Scenes
1793 //pos.Z -= 0.25F; 1853 //pos.Z -= 0.25F;
1794 1854
1795 } 1855 }
1796
1797 return pos;
1798 } 1856 }
1799 else 1857 else
1800 { 1858 {
1801 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1859 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1802
1803 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1860 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1804 1861
1805 // Un-comment the following line to print the raytrace results to the console. 1862 // Un-comment the following line to print the raytrace results to the console.
@@ -1808,13 +1865,12 @@ namespace OpenSim.Region.Framework.Scenes
1808 if (ei.HitTF) 1865 if (ei.HitTF)
1809 { 1866 {
1810 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1867 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1811 } else 1868 }
1869 else
1812 { 1870 {
1813 // fall back to our stupid functionality 1871 // fall back to our stupid functionality
1814 pos = RayEnd; 1872 pos = RayEnd;
1815 } 1873 }
1816
1817 return pos;
1818 } 1874 }
1819 } 1875 }
1820 else 1876 else
@@ -1825,8 +1881,12 @@ namespace OpenSim.Region.Framework.Scenes
1825 //increase height so its above the ground. 1881 //increase height so its above the ground.
1826 //should be getting the normal of the ground at the rez point and using that? 1882 //should be getting the normal of the ground at the rez point and using that?
1827 pos.Z += scale.Z / 2f; 1883 pos.Z += scale.Z / 2f;
1828 return pos; 1884// return pos;
1829 } 1885 }
1886
1887 // check against posible water intercept
1888 if (wpos.Z > pos.Z) pos = wpos;
1889 return pos;
1830 } 1890 }
1831 1891
1832 1892
@@ -1910,7 +1970,10 @@ namespace OpenSim.Region.Framework.Scenes
1910 public bool AddRestoredSceneObject( 1970 public bool AddRestoredSceneObject(
1911 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1971 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1912 { 1972 {
1913 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1973 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1974 if (result)
1975 sceneObject.IsDeleted = false;
1976 return result;
1914 } 1977 }
1915 1978
1916 /// <summary> 1979 /// <summary>
@@ -2002,6 +2065,15 @@ namespace OpenSim.Region.Framework.Scenes
2002 /// </summary> 2065 /// </summary>
2003 public void DeleteAllSceneObjects() 2066 public void DeleteAllSceneObjects()
2004 { 2067 {
2068 DeleteAllSceneObjects(false);
2069 }
2070
2071 /// <summary>
2072 /// Delete every object from the scene. This does not include attachments worn by avatars.
2073 /// </summary>
2074 public void DeleteAllSceneObjects(bool exceptNoCopy)
2075 {
2076 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2005 lock (Entities) 2077 lock (Entities)
2006 { 2078 {
2007 EntityBase[] entities = Entities.GetEntities(); 2079 EntityBase[] entities = Entities.GetEntities();
@@ -2010,11 +2082,24 @@ namespace OpenSim.Region.Framework.Scenes
2010 if (e is SceneObjectGroup) 2082 if (e is SceneObjectGroup)
2011 { 2083 {
2012 SceneObjectGroup sog = (SceneObjectGroup)e; 2084 SceneObjectGroup sog = (SceneObjectGroup)e;
2013 if (!sog.IsAttachment) 2085 if (sog != null && !sog.IsAttachment)
2014 DeleteSceneObject((SceneObjectGroup)e, false); 2086 {
2087 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2088 {
2089 DeleteSceneObject((SceneObjectGroup)e, false);
2090 }
2091 else
2092 {
2093 toReturn.Add((SceneObjectGroup)e);
2094 }
2095 }
2015 } 2096 }
2016 } 2097 }
2017 } 2098 }
2099 if (toReturn.Count > 0)
2100 {
2101 returnObjects(toReturn.ToArray(), UUID.Zero);
2102 }
2018 } 2103 }
2019 2104
2020 /// <summary> 2105 /// <summary>
@@ -2062,6 +2147,8 @@ namespace OpenSim.Region.Framework.Scenes
2062 } 2147 }
2063 2148
2064 group.DeleteGroupFromScene(silent); 2149 group.DeleteGroupFromScene(silent);
2150 if (!silent)
2151 SendKillObject(new List<uint>() { group.LocalId });
2065 2152
2066// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2153// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2067 } 2154 }
@@ -2416,10 +2503,17 @@ namespace OpenSim.Region.Framework.Scenes
2416 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2503 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2417 public bool AddSceneObject(SceneObjectGroup sceneObject) 2504 public bool AddSceneObject(SceneObjectGroup sceneObject)
2418 { 2505 {
2506 if (sceneObject.OwnerID == UUID.Zero)
2507 {
2508 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2509 return false;
2510 }
2511
2419 // If the user is banned, we won't let any of their objects 2512 // If the user is banned, we won't let any of their objects
2420 // enter. Period. 2513 // enter. Period.
2421 // 2514 //
2422 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2515 int flags = GetUserFlags(sceneObject.OwnerID);
2516 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2423 { 2517 {
2424 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); 2518 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2425 2519
@@ -2465,12 +2559,23 @@ namespace OpenSim.Region.Framework.Scenes
2465 } 2559 }
2466 else 2560 else
2467 { 2561 {
2562 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2468 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2563 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2469 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2564 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2470 } 2565 }
2566 if (sceneObject.OwnerID == UUID.Zero)
2567 {
2568 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2569 return false;
2570 }
2471 } 2571 }
2472 else 2572 else
2473 { 2573 {
2574 if (sceneObject.OwnerID == UUID.Zero)
2575 {
2576 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2577 return false;
2578 }
2474 AddRestoredSceneObject(sceneObject, true, false); 2579 AddRestoredSceneObject(sceneObject, true, false);
2475 2580
2476 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2581 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2499,6 +2604,24 @@ namespace OpenSim.Region.Framework.Scenes
2499 return 2; // StateSource.PrimCrossing 2604 return 2; // StateSource.PrimCrossing
2500 } 2605 }
2501 2606
2607 public int GetUserFlags(UUID user)
2608 {
2609 //Unfortunately the SP approach means that the value is cached until region is restarted
2610 /*
2611 ScenePresence sp;
2612 if (TryGetScenePresence(user, out sp))
2613 {
2614 return sp.UserFlags;
2615 }
2616 else
2617 {
2618 */
2619 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2620 if (uac == null)
2621 return 0;
2622 return uac.UserFlags;
2623 //}
2624 }
2502 #endregion 2625 #endregion
2503 2626
2504 #region Add/Remove Avatar Methods 2627 #region Add/Remove Avatar Methods
@@ -2513,6 +2636,7 @@ namespace OpenSim.Region.Framework.Scenes
2513 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2636 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2514 2637
2515 CheckHeartbeat(); 2638 CheckHeartbeat();
2639 ScenePresence presence;
2516 2640
2517 ScenePresence sp = GetScenePresence(client.AgentId); 2641 ScenePresence sp = GetScenePresence(client.AgentId);
2518 2642
@@ -2561,7 +2685,13 @@ namespace OpenSim.Region.Framework.Scenes
2561 2685
2562 EventManager.TriggerOnNewClient(client); 2686 EventManager.TriggerOnNewClient(client);
2563 if (vialogin) 2687 if (vialogin)
2688 {
2564 EventManager.TriggerOnClientLogin(client); 2689 EventManager.TriggerOnClientLogin(client);
2690 // Send initial parcel data
2691 Vector3 pos = sp.AbsolutePosition;
2692 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2693 land.SendLandUpdateToClient(client);
2694 }
2565 2695
2566 return sp; 2696 return sp;
2567 } 2697 }
@@ -2651,19 +2781,12 @@ namespace OpenSim.Region.Framework.Scenes
2651 // and the scene presence and the client, if they exist 2781 // and the scene presence and the client, if they exist
2652 try 2782 try
2653 { 2783 {
2654 // We need to wait for the client to make UDP contact first. 2784 ScenePresence sp = GetScenePresence(agentID);
2655 // It's the UDP contact that creates the scene presence 2785 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2656 ScenePresence sp = WaitGetScenePresence(agentID); 2786
2657 if (sp != null) 2787 if (sp != null)
2658 {
2659 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2660
2661 sp.ControllingClient.Close(); 2788 sp.ControllingClient.Close();
2662 } 2789
2663 else
2664 {
2665 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2666 }
2667 // BANG! SLASH! 2790 // BANG! SLASH!
2668 m_authenticateHandler.RemoveCircuit(agentID); 2791 m_authenticateHandler.RemoveCircuit(agentID);
2669 2792
@@ -2764,6 +2887,7 @@ namespace OpenSim.Region.Framework.Scenes
2764 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2887 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2765 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2888 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2766 client.OnCopyInventoryItem += CopyInventoryItem; 2889 client.OnCopyInventoryItem += CopyInventoryItem;
2890 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2767 client.OnMoveInventoryItem += MoveInventoryItem; 2891 client.OnMoveInventoryItem += MoveInventoryItem;
2768 client.OnRemoveInventoryItem += RemoveInventoryItem; 2892 client.OnRemoveInventoryItem += RemoveInventoryItem;
2769 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2893 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2939,15 +3063,16 @@ namespace OpenSim.Region.Framework.Scenes
2939 /// </summary> 3063 /// </summary>
2940 /// <param name="agentId">The avatar's Unique ID</param> 3064 /// <param name="agentId">The avatar's Unique ID</param>
2941 /// <param name="client">The IClientAPI for the client</param> 3065 /// <param name="client">The IClientAPI for the client</param>
2942 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3066 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2943 { 3067 {
2944 if (m_teleportModule != null) 3068 if (m_teleportModule != null)
2945 m_teleportModule.TeleportHome(agentId, client); 3069 return m_teleportModule.TeleportHome(agentId, client);
2946 else 3070 else
2947 { 3071 {
2948 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3072 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2949 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3073 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2950 } 3074 }
3075 return false;
2951 } 3076 }
2952 3077
2953 /// <summary> 3078 /// <summary>
@@ -3039,6 +3164,16 @@ namespace OpenSim.Region.Framework.Scenes
3039 /// <param name="flags"></param> 3164 /// <param name="flags"></param>
3040 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3165 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3041 { 3166 {
3167 //Add half the avatar's height so that the user doesn't fall through prims
3168 ScenePresence presence;
3169 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3170 {
3171 if (presence.Appearance != null)
3172 {
3173 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3174 }
3175 }
3176
3042 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3177 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3043 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3178 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3044 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3179 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3107,8 +3242,9 @@ namespace OpenSim.Region.Framework.Scenes
3107 regions.Remove(RegionInfo.RegionHandle); 3242 regions.Remove(RegionInfo.RegionHandle);
3108 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3243 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3109 } 3244 }
3110 3245 m_log.Debug("[Scene] Beginning ClientClosed");
3111 m_eventManager.TriggerClientClosed(agentID, this); 3246 m_eventManager.TriggerClientClosed(agentID, this);
3247 m_log.Debug("[Scene] Finished ClientClosed");
3112 } 3248 }
3113 catch (NullReferenceException) 3249 catch (NullReferenceException)
3114 { 3250 {
@@ -3160,9 +3296,10 @@ namespace OpenSim.Region.Framework.Scenes
3160 { 3296 {
3161 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); 3297 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace);
3162 } 3298 }
3163 3299 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3164 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3300 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3165// CleanDroppedAttachments(); 3301// CleanDroppedAttachments();
3302 m_log.Debug("[Scene] The avatar has left the building");
3166 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3303 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3167 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3304 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3168 } 3305 }
@@ -3281,13 +3418,16 @@ namespace OpenSim.Region.Framework.Scenes
3281 sp = null; 3418 sp = null;
3282 } 3419 }
3283 3420
3284 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3285 3421
3286 //On login test land permisions 3422 //On login test land permisions
3287 if (vialogin) 3423 if (vialogin)
3288 { 3424 {
3289 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3425 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3426 if (cache != null)
3427 cache.Remove(agent.firstname + " " + agent.lastname);
3428 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3290 { 3429 {
3430 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3291 return false; 3431 return false;
3292 } 3432 }
3293 } 3433 }
@@ -3311,8 +3451,13 @@ namespace OpenSim.Region.Framework.Scenes
3311 3451
3312 try 3452 try
3313 { 3453 {
3314 if (!AuthorizeUser(agent, out reason)) 3454 // Always check estate if this is a login. Always
3315 return false; 3455 // check if banned regions are to be blacked out.
3456 if (vialogin || (!m_seeIntoBannedRegion))
3457 {
3458 if (!AuthorizeUser(agent, out reason))
3459 return false;
3460 }
3316 } 3461 }
3317 catch (Exception e) 3462 catch (Exception e)
3318 { 3463 {
@@ -3415,6 +3560,8 @@ namespace OpenSim.Region.Framework.Scenes
3415 } 3560 }
3416 } 3561 }
3417 // Honor parcel landing type and position. 3562 // Honor parcel landing type and position.
3563 /*
3564 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3418 if (land != null) 3565 if (land != null)
3419 { 3566 {
3420 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3567 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3422,26 +3569,34 @@ namespace OpenSim.Region.Framework.Scenes
3422 agent.startpos = land.LandData.UserLocation; 3569 agent.startpos = land.LandData.UserLocation;
3423 } 3570 }
3424 } 3571 }
3572 */// This is now handled properly in ScenePresence.MakeRootAgent
3425 } 3573 }
3426 3574
3427 return true; 3575 return true;
3428 } 3576 }
3429 3577
3430 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3578 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3431 { 3579 {
3432 3580 reason = String.Empty;
3433 bool banned = land.IsBannedFromLand(agent.AgentID); 3581 if (Permissions.IsGod(agentID))
3434 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3582 return true;
3583
3584 ILandObject land = LandChannel.GetLandObject(posX, posY);
3585 if (land == null)
3586 return false;
3587
3588 bool banned = land.IsBannedFromLand(agentID);
3589 bool restricted = land.IsRestrictedFromLand(agentID);
3435 3590
3436 if (banned || restricted) 3591 if (banned || restricted)
3437 { 3592 {
3438 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3593 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3439 if (nearestParcel != null) 3594 if (nearestParcel != null)
3440 { 3595 {
3441 //Move agent to nearest allowed 3596 //Move agent to nearest allowed
3442 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3597 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3443 agent.startpos.X = newPosition.X; 3598 posX = newPosition.X;
3444 agent.startpos.Y = newPosition.Y; 3599 posY = newPosition.Y;
3445 } 3600 }
3446 else 3601 else
3447 { 3602 {
@@ -3503,7 +3658,7 @@ namespace OpenSim.Region.Framework.Scenes
3503 3658
3504 if (!m_strictAccessControl) return true; 3659 if (!m_strictAccessControl) return true;
3505 if (Permissions.IsGod(agent.AgentID)) return true; 3660 if (Permissions.IsGod(agent.AgentID)) return true;
3506 3661
3507 if (AuthorizationService != null) 3662 if (AuthorizationService != null)
3508 { 3663 {
3509 if (!AuthorizationService.IsAuthorizedForRegion( 3664 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3511,14 +3666,14 @@ namespace OpenSim.Region.Framework.Scenes
3511 { 3666 {
3512 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3667 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3513 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3668 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3514 3669
3515 return false; 3670 return false;
3516 } 3671 }
3517 } 3672 }
3518 3673
3519 if (m_regInfo.EstateSettings != null) 3674 if (m_regInfo.EstateSettings != null)
3520 { 3675 {
3521 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3676 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3522 { 3677 {
3523 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3678 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3524 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3679 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3710,6 +3865,13 @@ namespace OpenSim.Region.Framework.Scenes
3710 3865
3711 // We have to wait until the viewer contacts this region after receiving EAC. 3866 // We have to wait until the viewer contacts this region after receiving EAC.
3712 // That calls AddNewClient, which finally creates the ScenePresence 3867 // That calls AddNewClient, which finally creates the ScenePresence
3868 int flags = GetUserFlags(cAgentData.AgentID);
3869 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3870 {
3871 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3872 return false;
3873 }
3874
3713 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3875 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3714 if (nearestParcel == null) 3876 if (nearestParcel == null)
3715 { 3877 {
@@ -3791,12 +3953,22 @@ namespace OpenSim.Region.Framework.Scenes
3791 return false; 3953 return false;
3792 } 3954 }
3793 3955
3956 public bool IncomingCloseAgent(UUID agentID)
3957 {
3958 return IncomingCloseAgent(agentID, false);
3959 }
3960
3961 public bool IncomingCloseChildAgent(UUID agentID)
3962 {
3963 return IncomingCloseAgent(agentID, true);
3964 }
3965
3794 /// <summary> 3966 /// <summary>
3795 /// Tell a single agent to disconnect from the region. 3967 /// Tell a single agent to disconnect from the region.
3796 /// </summary> 3968 /// </summary>
3797 /// <param name="regionHandle"></param>
3798 /// <param name="agentID"></param> 3969 /// <param name="agentID"></param>
3799 public bool IncomingCloseAgent(UUID agentID) 3970 /// <param name="childOnly"></param>
3971 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3800 { 3972 {
3801 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3973 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3802 3974
@@ -3808,7 +3980,7 @@ namespace OpenSim.Region.Framework.Scenes
3808 { 3980 {
3809 m_sceneGraph.removeUserCount(false); 3981 m_sceneGraph.removeUserCount(false);
3810 } 3982 }
3811 else 3983 else if (!childOnly)
3812 { 3984 {
3813 m_sceneGraph.removeUserCount(true); 3985 m_sceneGraph.removeUserCount(true);
3814 } 3986 }
@@ -3824,9 +3996,12 @@ namespace OpenSim.Region.Framework.Scenes
3824 } 3996 }
3825 else 3997 else
3826 presence.ControllingClient.SendShutdownConnectionNotice(); 3998 presence.ControllingClient.SendShutdownConnectionNotice();
3999 presence.ControllingClient.Close(false);
4000 }
4001 else if (!childOnly)
4002 {
4003 presence.ControllingClient.Close(true);
3827 } 4004 }
3828
3829 presence.ControllingClient.Close();
3830 return true; 4005 return true;
3831 } 4006 }
3832 4007
@@ -4409,34 +4584,78 @@ namespace OpenSim.Region.Framework.Scenes
4409 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4584 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4410 } 4585 }
4411 4586
4412 public int GetHealth() 4587 public int GetHealth(out int flags, out string message)
4413 { 4588 {
4414 // Returns: 4589 // Returns:
4415 // 1 = sim is up and accepting http requests. The heartbeat has 4590 // 1 = sim is up and accepting http requests. The heartbeat has
4416 // stopped and the sim is probably locked up, but a remote 4591 // stopped and the sim is probably locked up, but a remote
4417 // admin restart may succeed 4592 // admin restart may succeed
4418 // 4593 //
4419 // 2 = Sim is up and the heartbeat is running. The sim is likely 4594 // 2 = Sim is up and the heartbeat is running. The sim is likely
4420 // usable for people within and logins _may_ work 4595 // usable for people within
4596 //
4597 // 3 = Sim is up and one packet thread is running. Sim is
4598 // unstable and will not accept new logins
4421 // 4599 //
4422 // 3 = We have seen a new user enter within the past 4 minutes 4600 // 4 = Sim is up and both packet threads are running. Sim is
4601 // likely usable
4602 //
4603 // 5 = We have seen a new user enter within the past 4 minutes
4423 // which can be seen as positive confirmation of sim health 4604 // which can be seen as positive confirmation of sim health
4424 // 4605 //
4606
4607 flags = 0;
4608 message = String.Empty;
4609
4610 CheckHeartbeat();
4611
4612 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4613 {
4614 // We're still starting
4615 // 0 means "in startup", it can't happen another way, since
4616 // to get here, we must be able to accept http connections
4617 return 0;
4618 }
4619
4425 int health=1; // Start at 1, means we're up 4620 int health=1; // Start at 1, means we're up
4426 4621
4427 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4622 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4623 {
4428 health+=1; 4624 health+=1;
4625 flags |= 1;
4626 }
4627
4628 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4629 {
4630 health+=1;
4631 flags |= 2;
4632 }
4633
4634 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4635 {
4636 health+=1;
4637 flags |= 4;
4638 }
4429 else 4639 else
4640 {
4641int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
4642System.Diagnostics.Process proc = new System.Diagnostics.Process();
4643proc.EnableRaisingEvents=false;
4644proc.StartInfo.FileName = "/bin/kill";
4645proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
4646proc.Start();
4647proc.WaitForExit();
4648Thread.Sleep(1000);
4649Environment.Exit(1);
4650 }
4651
4652 if (flags != 7)
4430 return health; 4653 return health;
4431 4654
4432 // A login in the last 4 mins? We can't be doing too badly 4655 // A login in the last 4 mins? We can't be doing too badly
4433 // 4656 //
4434 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4657 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4435 health++; 4658 health++;
4436 else
4437 return health;
4438
4439 CheckHeartbeat();
4440 4659
4441 return health; 4660 return health;
4442 } 4661 }
@@ -4629,7 +4848,7 @@ namespace OpenSim.Region.Framework.Scenes
4629 if (m_firstHeartbeat) 4848 if (m_firstHeartbeat)
4630 return; 4849 return;
4631 4850
4632 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4851 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4633 StartTimer(); 4852 StartTimer();
4634 } 4853 }
4635 4854
@@ -5039,7 +5258,55 @@ namespace OpenSim.Region.Framework.Scenes
5039 mapModule.GenerateMaptile(); 5258 mapModule.GenerateMaptile();
5040 } 5259 }
5041 5260
5042 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5261// public void CleanDroppedAttachments()
5262// {
5263// List<SceneObjectGroup> objectsToDelete =
5264// new List<SceneObjectGroup>();
5265//
5266// lock (m_cleaningAttachments)
5267// {
5268// ForEachSOG(delegate (SceneObjectGroup grp)
5269// {
5270// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5271// {
5272// UUID agentID = grp.OwnerID;
5273// if (agentID == UUID.Zero)
5274// {
5275// objectsToDelete.Add(grp);
5276// return;
5277// }
5278//
5279// ScenePresence sp = GetScenePresence(agentID);
5280// if (sp == null)
5281// {
5282// objectsToDelete.Add(grp);
5283// return;
5284// }
5285// }
5286// });
5287// }
5288//
5289// foreach (SceneObjectGroup grp in objectsToDelete)
5290// {
5291// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5292// DeleteSceneObject(grp, true);
5293// }
5294// }
5295
5296 public void ThreadAlive(int threadCode)
5297 {
5298 switch(threadCode)
5299 {
5300 case 1: // Incoming
5301 m_lastIncoming = Util.EnvironmentTickCount();
5302 break;
5303 case 2: // Incoming
5304 m_lastOutgoing = Util.EnvironmentTickCount();
5305 break;
5306 }
5307 }
5308
5309 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5043 { 5310 {
5044 RegenerateMaptile(); 5311 RegenerateMaptile();
5045 5312
@@ -5058,6 +5325,14 @@ namespace OpenSim.Region.Framework.Scenes
5058 // child agent creation, thereby emulating the SL behavior. 5325 // child agent creation, thereby emulating the SL behavior.
5059 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5326 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5060 { 5327 {
5328 reason = "You are banned from the region";
5329
5330 if (Permissions.IsGod(agentID))
5331 {
5332 reason = String.Empty;
5333 return true;
5334 }
5335
5061 int num = m_sceneGraph.GetNumberOfScenePresences(); 5336 int num = m_sceneGraph.GetNumberOfScenePresences();
5062 5337
5063 if (num >= RegionInfo.RegionSettings.AgentLimit) 5338 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5069,6 +5344,41 @@ namespace OpenSim.Region.Framework.Scenes
5069 } 5344 }
5070 } 5345 }
5071 5346
5347 ScenePresence presence = GetScenePresence(agentID);
5348 IClientAPI client = null;
5349 AgentCircuitData aCircuit = null;
5350
5351 if (presence != null)
5352 {
5353 client = presence.ControllingClient;
5354 if (client != null)
5355 aCircuit = client.RequestClientInfo();
5356 }
5357
5358 // We may be called before there is a presence or a client.
5359 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5360 if (client == null)
5361 {
5362 aCircuit = new AgentCircuitData();
5363 aCircuit.AgentID = agentID;
5364 aCircuit.firstname = String.Empty;
5365 aCircuit.lastname = String.Empty;
5366 }
5367
5368 try
5369 {
5370 if (!AuthorizeUser(aCircuit, out reason))
5371 {
5372 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5373 return false;
5374 }
5375 }
5376 catch (Exception e)
5377 {
5378 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5379 return false;
5380 }
5381
5072 if (position == Vector3.Zero) // Teleport 5382 if (position == Vector3.Zero) // Teleport
5073 { 5383 {
5074 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5384 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5097,13 +5407,46 @@ namespace OpenSim.Region.Framework.Scenes
5097 } 5407 }
5098 } 5408 }
5099 } 5409 }
5410
5411 float posX = 128.0f;
5412 float posY = 128.0f;
5413
5414 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5415 {
5416 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5417 return false;
5418 }
5419 }
5420 else // Walking
5421 {
5422 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5423 if (land == null)
5424 return false;
5425
5426 bool banned = land.IsBannedFromLand(agentID);
5427 bool restricted = land.IsRestrictedFromLand(agentID);
5428
5429 if (banned || restricted)
5430 return false;
5100 } 5431 }
5101 5432
5102 reason = String.Empty; 5433 reason = String.Empty;
5103 return true; 5434 return true;
5104 } 5435 }
5105 5436
5106 /// <summary> 5437 public void StartTimerWatchdog()
5438 {
5439 m_timerWatchdog.Interval = 1000;
5440 m_timerWatchdog.Elapsed += TimerWatchdog;
5441 m_timerWatchdog.AutoReset = true;
5442 m_timerWatchdog.Start();
5443 }
5444
5445 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5446 {
5447 CheckHeartbeat();
5448 }
5449
5107 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5450 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5108 /// autopilot that moves an avatar to a sit target!. 5451 /// autopilot that moves an avatar to a sit target!.
5109 /// </summary> 5452 /// </summary>