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.cs531
1 files changed, 401 insertions, 130 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0e5a7d2..b288c8a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -93,6 +93,7 @@ namespace OpenSim.Region.Framework.Scenes
93 // TODO: need to figure out how allow client agents but deny 93 // TODO: need to figure out how allow client agents but deny
94 // root agents when ACL denies access to root agent 94 // root agents when ACL denies access to root agent
95 public bool m_strictAccessControl = true; 95 public bool m_strictAccessControl = true;
96 public bool m_seeIntoBannedRegion = false;
96 public int MaxUndoCount = 5; 97 public int MaxUndoCount = 5;
97 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 98 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
98 public bool LoginLock = false; 99 public bool LoginLock = false;
@@ -108,12 +109,14 @@ namespace OpenSim.Region.Framework.Scenes
108 109
109 protected int m_splitRegionID; 110 protected int m_splitRegionID;
110 protected Timer m_restartWaitTimer = new Timer(); 111 protected Timer m_restartWaitTimer = new Timer();
112 protected Timer m_timerWatchdog = new Timer();
111 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 113 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
112 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 114 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
113 protected string m_simulatorVersion = "OpenSimulator Server"; 115 protected string m_simulatorVersion = "OpenSimulator Server";
114 protected ModuleLoader m_moduleLoader; 116 protected ModuleLoader m_moduleLoader;
115 protected AgentCircuitManager m_authenticateHandler; 117 protected AgentCircuitManager m_authenticateHandler;
116 protected SceneCommunicationService m_sceneGridService; 118 protected SceneCommunicationService m_sceneGridService;
119 protected ISnmpModule m_snmpService = null;
117 120
118 protected ISimulationDataService m_SimulationDataService; 121 protected ISimulationDataService m_SimulationDataService;
119 protected IEstateDataService m_EstateDataService; 122 protected IEstateDataService m_EstateDataService;
@@ -170,7 +173,7 @@ namespace OpenSim.Region.Framework.Scenes
170 private int m_update_events = 1; 173 private int m_update_events = 1;
171 private int m_update_backup = 200; 174 private int m_update_backup = 200;
172 private int m_update_terrain = 50; 175 private int m_update_terrain = 50;
173// private int m_update_land = 1; 176 private int m_update_land = 10;
174 private int m_update_coarse_locations = 50; 177 private int m_update_coarse_locations = 50;
175 178
176 private int frameMS; 179 private int frameMS;
@@ -184,14 +187,17 @@ namespace OpenSim.Region.Framework.Scenes
184 private int landMS; 187 private int landMS;
185 private int lastCompletedFrame; 188 private int lastCompletedFrame;
186 189
190 public bool CombineRegions = false;
187 private bool m_physics_enabled = true; 191 private bool m_physics_enabled = true;
188 private bool m_scripts_enabled = true; 192 private bool m_scripts_enabled = true;
189 private string m_defaultScriptEngine; 193 private string m_defaultScriptEngine;
190 private int m_LastLogin; 194 private int m_LastLogin;
191 private Thread HeartbeatThread; 195 private Thread HeartbeatThread = null;
192 private volatile bool shuttingdown; 196 private volatile bool shuttingdown;
193 197
194 private int m_lastUpdate; 198 private int m_lastUpdate;
199 private int m_lastIncoming;
200 private int m_lastOutgoing;
195 private bool m_firstHeartbeat = true; 201 private bool m_firstHeartbeat = true;
196 202
197 private object m_deleting_scene_object = new object(); 203 private object m_deleting_scene_object = new object();
@@ -244,6 +250,19 @@ namespace OpenSim.Region.Framework.Scenes
244 get { return m_sceneGridService; } 250 get { return m_sceneGridService; }
245 } 251 }
246 252
253 public ISnmpModule SnmpService
254 {
255 get
256 {
257 if (m_snmpService == null)
258 {
259 m_snmpService = RequestModuleInterface<ISnmpModule>();
260 }
261
262 return m_snmpService;
263 }
264 }
265
247 public ISimulationDataService SimulationDataService 266 public ISimulationDataService SimulationDataService
248 { 267 {
249 get 268 get
@@ -572,7 +591,10 @@ namespace OpenSim.Region.Framework.Scenes
572 m_regInfo = regInfo; 591 m_regInfo = regInfo;
573 m_regionHandle = m_regInfo.RegionHandle; 592 m_regionHandle = m_regInfo.RegionHandle;
574 m_regionName = m_regInfo.RegionName; 593 m_regionName = m_regInfo.RegionName;
594 m_datastore = m_regInfo.DataStore;
575 m_lastUpdate = Util.EnvironmentTickCount(); 595 m_lastUpdate = Util.EnvironmentTickCount();
596 m_lastIncoming = 0;
597 m_lastOutgoing = 0;
576 598
577 m_physicalPrim = physicalPrim; 599 m_physicalPrim = physicalPrim;
578 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; 600 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
@@ -704,9 +726,10 @@ namespace OpenSim.Region.Framework.Scenes
704 //Animation states 726 //Animation states
705 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 727 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
706 // TODO: Change default to true once the feature is supported 728 // TODO: Change default to true once the feature is supported
707 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 729 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
708
709 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 730 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
731
732 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
710 if (RegionInfo.NonphysPrimMax > 0) 733 if (RegionInfo.NonphysPrimMax > 0)
711 { 734 {
712 m_maxNonphys = RegionInfo.NonphysPrimMax; 735 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -738,6 +761,7 @@ namespace OpenSim.Region.Framework.Scenes
738 m_persistAfter *= 10000000; 761 m_persistAfter *= 10000000;
739 762
740 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 763 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
764 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
741 765
742 IConfig packetConfig = m_config.Configs["PacketPool"]; 766 IConfig packetConfig = m_config.Configs["PacketPool"];
743 if (packetConfig != null) 767 if (packetConfig != null)
@@ -747,6 +771,8 @@ namespace OpenSim.Region.Framework.Scenes
747 } 771 }
748 772
749 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 773 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
774 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
775 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
750 776
751 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 777 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
752 if (m_generateMaptiles) 778 if (m_generateMaptiles)
@@ -771,9 +797,9 @@ namespace OpenSim.Region.Framework.Scenes
771 } 797 }
772 } 798 }
773 } 799 }
774 catch 800 catch (Exception e)
775 { 801 {
776 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 802 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
777 } 803 }
778 804
779 #endregion Region Config 805 #endregion Region Config
@@ -1150,7 +1176,9 @@ namespace OpenSim.Region.Framework.Scenes
1150 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1176 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1151 if (HeartbeatThread != null) 1177 if (HeartbeatThread != null)
1152 { 1178 {
1179 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1153 HeartbeatThread.Abort(); 1180 HeartbeatThread.Abort();
1181 Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId);
1154 HeartbeatThread = null; 1182 HeartbeatThread = null;
1155 } 1183 }
1156 m_lastUpdate = Util.EnvironmentTickCount(); 1184 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1193,9 +1221,6 @@ namespace OpenSim.Region.Framework.Scenes
1193 { 1221 {
1194 while (!shuttingdown) 1222 while (!shuttingdown)
1195 Update(); 1223 Update();
1196
1197 m_lastUpdate = Util.EnvironmentTickCount();
1198 m_firstHeartbeat = false;
1199 } 1224 }
1200 catch (ThreadAbortException) 1225 catch (ThreadAbortException)
1201 { 1226 {
@@ -1278,56 +1303,60 @@ namespace OpenSim.Region.Framework.Scenes
1278 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); 1303 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS);
1279 } 1304 }
1280 1305
1281 if (RegionStatus != RegionStatus.SlaveScene) 1306 if (Frame % m_update_events == 0)
1282 { 1307 {
1283 if (Frame % m_update_events == 0) 1308 int evMS = Util.EnvironmentTickCount();
1284 { 1309 UpdateEvents();
1285 int evMS = Util.EnvironmentTickCount(); 1310 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1286 UpdateEvents(); 1311 }
1287 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1288 }
1289
1290 if (Frame % m_update_backup == 0)
1291 {
1292 int backMS = Util.EnvironmentTickCount();
1293 UpdateStorageBackup();
1294 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1295 }
1296 1312
1297 if (Frame % m_update_terrain == 0) 1313 // if (Frame % m_update_land == 0)
1298 { 1314 // {
1299 int terMS = Util.EnvironmentTickCount(); 1315 // int ldMS = Util.EnvironmentTickCount();
1300 UpdateTerrain(); 1316 // UpdateLand();
1301 terrainMS = Util.EnvironmentTickCountSubtract(terMS); 1317 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1302 } 1318 // }
1303 1319
1304 //if (Frame % m_update_land == 0) 1320 if (Frame % m_update_backup == 0)
1305 //{ 1321 {
1306 // int ldMS = Util.EnvironmentTickCount(); 1322 int backMS = Util.EnvironmentTickCount();
1307 // UpdateLand(); 1323 UpdateStorageBackup();
1308 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1324 backupMS = Util.EnvironmentTickCountSubtract(backMS);
1309 //} 1325 }
1310 1326
1311 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); 1327 if (Frame % m_update_terrain == 0)
1312 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1328 {
1313 lastCompletedFrame = Util.EnvironmentTickCount(); 1329 int terMS = Util.EnvironmentTickCount();
1314 1330 UpdateTerrain();
1315 // if (Frame%m_update_avatars == 0) 1331 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1316 // UpdateInWorldTime();
1317 StatsReporter.AddPhysicsFPS(physicsFPS);
1318 StatsReporter.AddTimeDilation(TimeDilation);
1319 StatsReporter.AddFPS(1);
1320 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
1321 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
1322 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
1323 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1324 StatsReporter.addFrameMS(frameMS);
1325 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1326 StatsReporter.addOtherMS(otherMS);
1327 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1328 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1329 } 1332 }
1330 1333
1334 //if (Frame % m_update_land == 0)
1335 //{
1336 // int ldMS = Util.EnvironmentTickCount();
1337 // UpdateLand();
1338 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1339 //}
1340
1341 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1342 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1343 lastCompletedFrame = Util.EnvironmentTickCount();
1344
1345 // if (Frame%m_update_avatars == 0)
1346 // UpdateInWorldTime();
1347 StatsReporter.AddPhysicsFPS(physicsFPS);
1348 StatsReporter.AddTimeDilation(TimeDilation);
1349 StatsReporter.AddFPS(1);
1350 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
1351 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
1352 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
1353 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1354 StatsReporter.addFrameMS(frameMS);
1355 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1356 StatsReporter.addOtherMS(otherMS);
1357 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1358 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1359
1331 if (LoginsDisabled && Frame == 20) 1360 if (LoginsDisabled && Frame == 20)
1332 { 1361 {
1333 // In 99.9% of cases it is a bad idea to manually force garbage collection. However, 1362 // In 99.9% of cases it is a bad idea to manually force garbage collection. However,
@@ -1388,12 +1417,16 @@ namespace OpenSim.Region.Framework.Scenes
1388 maintc = Util.EnvironmentTickCountSubtract(maintc); 1417 maintc = Util.EnvironmentTickCountSubtract(maintc);
1389 maintc = (int)(m_timespan * 1000) - maintc; 1418 maintc = (int)(m_timespan * 1000) - maintc;
1390 1419
1420
1421 m_lastUpdate = Util.EnvironmentTickCount();
1422 m_firstHeartbeat = false;
1423
1391 if (maintc > 0) 1424 if (maintc > 0)
1392 Thread.Sleep(maintc); 1425 Thread.Sleep(maintc);
1393 1426
1394 // Tell the watchdog that this thread is still alive 1427 // Tell the watchdog that this thread is still alive
1395 Watchdog.UpdateThread(); 1428 Watchdog.UpdateThread();
1396 } 1429 }
1397 1430
1398 public void AddGroupTarget(SceneObjectGroup grp) 1431 public void AddGroupTarget(SceneObjectGroup grp)
1399 { 1432 {
@@ -1409,9 +1442,9 @@ namespace OpenSim.Region.Framework.Scenes
1409 1442
1410 private void CheckAtTargets() 1443 private void CheckAtTargets()
1411 { 1444 {
1412 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1445 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1413 lock (m_groupsWithTargets) 1446 lock (m_groupsWithTargets)
1414 objs = m_groupsWithTargets.Values; 1447 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1415 1448
1416 foreach (SceneObjectGroup entry in objs) 1449 foreach (SceneObjectGroup entry in objs)
1417 entry.checkAtTargets(); 1450 entry.checkAtTargets();
@@ -1731,14 +1764,24 @@ namespace OpenSim.Region.Framework.Scenes
1731 /// <returns></returns> 1764 /// <returns></returns>
1732 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1765 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1733 { 1766 {
1767
1768 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1769 Vector3 wpos = Vector3.Zero;
1770 // Check for water surface intersection from above
1771 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1772 {
1773 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1774 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1775 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1776 wpos.Z = wheight;
1777 }
1778
1734 Vector3 pos = Vector3.Zero; 1779 Vector3 pos = Vector3.Zero;
1735 if (RayEndIsIntersection == (byte)1) 1780 if (RayEndIsIntersection == (byte)1)
1736 { 1781 {
1737 pos = RayEnd; 1782 pos = RayEnd;
1738 return pos;
1739 } 1783 }
1740 1784 else if (RayTargetID != UUID.Zero)
1741 if (RayTargetID != UUID.Zero)
1742 { 1785 {
1743 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1786 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1744 1787
@@ -1760,7 +1803,7 @@ namespace OpenSim.Region.Framework.Scenes
1760 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1803 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1761 1804
1762 // Un-comment out the following line to Get Raytrace results printed to the console. 1805 // Un-comment out the following line to Get Raytrace results printed to the console.
1763 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1806 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1764 float ScaleOffset = 0.5f; 1807 float ScaleOffset = 0.5f;
1765 1808
1766 // If we hit something 1809 // If we hit something
@@ -1783,13 +1826,10 @@ namespace OpenSim.Region.Framework.Scenes
1783 //pos.Z -= 0.25F; 1826 //pos.Z -= 0.25F;
1784 1827
1785 } 1828 }
1786
1787 return pos;
1788 } 1829 }
1789 else 1830 else
1790 { 1831 {
1791 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1832 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1792
1793 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1833 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1794 1834
1795 // Un-comment the following line to print the raytrace results to the console. 1835 // Un-comment the following line to print the raytrace results to the console.
@@ -1798,13 +1838,12 @@ namespace OpenSim.Region.Framework.Scenes
1798 if (ei.HitTF) 1838 if (ei.HitTF)
1799 { 1839 {
1800 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1840 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1801 } else 1841 }
1842 else
1802 { 1843 {
1803 // fall back to our stupid functionality 1844 // fall back to our stupid functionality
1804 pos = RayEnd; 1845 pos = RayEnd;
1805 } 1846 }
1806
1807 return pos;
1808 } 1847 }
1809 } 1848 }
1810 else 1849 else
@@ -1815,8 +1854,12 @@ namespace OpenSim.Region.Framework.Scenes
1815 //increase height so its above the ground. 1854 //increase height so its above the ground.
1816 //should be getting the normal of the ground at the rez point and using that? 1855 //should be getting the normal of the ground at the rez point and using that?
1817 pos.Z += scale.Z / 2f; 1856 pos.Z += scale.Z / 2f;
1818 return pos; 1857// return pos;
1819 } 1858 }
1859
1860 // check against posible water intercept
1861 if (wpos.Z > pos.Z) pos = wpos;
1862 return pos;
1820 } 1863 }
1821 1864
1822 1865
@@ -1900,7 +1943,10 @@ namespace OpenSim.Region.Framework.Scenes
1900 public bool AddRestoredSceneObject( 1943 public bool AddRestoredSceneObject(
1901 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1944 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1902 { 1945 {
1903 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1946 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1947 if (result)
1948 sceneObject.IsDeleted = false;
1949 return result;
1904 } 1950 }
1905 1951
1906 /// <summary> 1952 /// <summary>
@@ -1990,6 +2036,15 @@ namespace OpenSim.Region.Framework.Scenes
1990 /// </summary> 2036 /// </summary>
1991 public void DeleteAllSceneObjects() 2037 public void DeleteAllSceneObjects()
1992 { 2038 {
2039 DeleteAllSceneObjects(false);
2040 }
2041
2042 /// <summary>
2043 /// Delete every object from the scene. This does not include attachments worn by avatars.
2044 /// </summary>
2045 public void DeleteAllSceneObjects(bool exceptNoCopy)
2046 {
2047 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1993 lock (Entities) 2048 lock (Entities)
1994 { 2049 {
1995 EntityBase[] entities = Entities.GetEntities(); 2050 EntityBase[] entities = Entities.GetEntities();
@@ -1998,11 +2053,24 @@ namespace OpenSim.Region.Framework.Scenes
1998 if (e is SceneObjectGroup) 2053 if (e is SceneObjectGroup)
1999 { 2054 {
2000 SceneObjectGroup sog = (SceneObjectGroup)e; 2055 SceneObjectGroup sog = (SceneObjectGroup)e;
2001 if (!sog.IsAttachment) 2056 if (sog != null && !sog.IsAttachment)
2002 DeleteSceneObject((SceneObjectGroup)e, false); 2057 {
2058 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2059 {
2060 DeleteSceneObject((SceneObjectGroup)e, false);
2061 }
2062 else
2063 {
2064 toReturn.Add((SceneObjectGroup)e);
2065 }
2066 }
2003 } 2067 }
2004 } 2068 }
2005 } 2069 }
2070 if (toReturn.Count > 0)
2071 {
2072 returnObjects(toReturn.ToArray(), UUID.Zero);
2073 }
2006 } 2074 }
2007 2075
2008 /// <summary> 2076 /// <summary>
@@ -2051,6 +2119,8 @@ namespace OpenSim.Region.Framework.Scenes
2051 } 2119 }
2052 2120
2053 group.DeleteGroupFromScene(silent); 2121 group.DeleteGroupFromScene(silent);
2122 if (!silent)
2123 SendKillObject(new List<uint>() { group.LocalId });
2054 2124
2055// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2125// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2056 } 2126 }
@@ -2405,10 +2475,17 @@ namespace OpenSim.Region.Framework.Scenes
2405 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2475 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2406 public bool AddSceneObject(SceneObjectGroup sceneObject) 2476 public bool AddSceneObject(SceneObjectGroup sceneObject)
2407 { 2477 {
2478 if (sceneObject.OwnerID == UUID.Zero)
2479 {
2480 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2481 return false;
2482 }
2483
2408 // If the user is banned, we won't let any of their objects 2484 // If the user is banned, we won't let any of their objects
2409 // enter. Period. 2485 // enter. Period.
2410 // 2486 //
2411 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2487 int flags = GetUserFlags(sceneObject.OwnerID);
2488 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2412 { 2489 {
2413 m_log.Info("[INTERREGION]: Denied prim crossing for " + 2490 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2414 "banned avatar"); 2491 "banned avatar");
@@ -2455,12 +2532,23 @@ namespace OpenSim.Region.Framework.Scenes
2455 } 2532 }
2456 else 2533 else
2457 { 2534 {
2535 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2458 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2536 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2459 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2537 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2460 } 2538 }
2539 if (sceneObject.OwnerID == UUID.Zero)
2540 {
2541 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2542 return false;
2543 }
2461 } 2544 }
2462 else 2545 else
2463 { 2546 {
2547 if (sceneObject.OwnerID == UUID.Zero)
2548 {
2549 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2550 return false;
2551 }
2464 AddRestoredSceneObject(sceneObject, true, false); 2552 AddRestoredSceneObject(sceneObject, true, false);
2465 2553
2466 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2554 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2490,6 +2578,24 @@ namespace OpenSim.Region.Framework.Scenes
2490 return 2; // StateSource.PrimCrossing 2578 return 2; // StateSource.PrimCrossing
2491 } 2579 }
2492 2580
2581 public int GetUserFlags(UUID user)
2582 {
2583 //Unfortunately the SP approach means that the value is cached until region is restarted
2584 /*
2585 ScenePresence sp;
2586 if (TryGetScenePresence(user, out sp))
2587 {
2588 return sp.UserFlags;
2589 }
2590 else
2591 {
2592 */
2593 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2594 if (uac == null)
2595 return 0;
2596 return uac.UserFlags;
2597 //}
2598 }
2493 #endregion 2599 #endregion
2494 2600
2495 #region Add/Remove Avatar Methods 2601 #region Add/Remove Avatar Methods
@@ -2511,6 +2617,7 @@ namespace OpenSim.Region.Framework.Scenes
2511 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2617 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2512 2618
2513 CheckHeartbeat(); 2619 CheckHeartbeat();
2620 ScenePresence presence;
2514 2621
2515 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here 2622 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
2516 { 2623 {
@@ -2544,7 +2651,14 @@ namespace OpenSim.Region.Framework.Scenes
2544 2651
2545 EventManager.TriggerOnNewClient(client); 2652 EventManager.TriggerOnNewClient(client);
2546 if (vialogin) 2653 if (vialogin)
2654 {
2547 EventManager.TriggerOnClientLogin(client); 2655 EventManager.TriggerOnClientLogin(client);
2656
2657 // Send initial parcel data
2658 Vector3 pos = createdSp.AbsolutePosition;
2659 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2660 land.SendLandUpdateToClient(client);
2661 }
2548 } 2662 }
2549 } 2663 }
2550 2664
@@ -2633,19 +2747,12 @@ namespace OpenSim.Region.Framework.Scenes
2633 // and the scene presence and the client, if they exist 2747 // and the scene presence and the client, if they exist
2634 try 2748 try
2635 { 2749 {
2636 // We need to wait for the client to make UDP contact first. 2750 ScenePresence sp = GetScenePresence(agentID);
2637 // It's the UDP contact that creates the scene presence 2751 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2638 ScenePresence sp = WaitGetScenePresence(agentID); 2752
2639 if (sp != null) 2753 if (sp != null)
2640 {
2641 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2642
2643 sp.ControllingClient.Close(); 2754 sp.ControllingClient.Close();
2644 } 2755
2645 else
2646 {
2647 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2648 }
2649 // BANG! SLASH! 2756 // BANG! SLASH!
2650 m_authenticateHandler.RemoveCircuit(agentID); 2757 m_authenticateHandler.RemoveCircuit(agentID);
2651 2758
@@ -2745,6 +2852,7 @@ namespace OpenSim.Region.Framework.Scenes
2745 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2852 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2746 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2853 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2747 client.OnCopyInventoryItem += CopyInventoryItem; 2854 client.OnCopyInventoryItem += CopyInventoryItem;
2855 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2748 client.OnMoveInventoryItem += MoveInventoryItem; 2856 client.OnMoveInventoryItem += MoveInventoryItem;
2749 client.OnRemoveInventoryItem += RemoveInventoryItem; 2857 client.OnRemoveInventoryItem += RemoveInventoryItem;
2750 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2858 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2922,15 +3030,16 @@ namespace OpenSim.Region.Framework.Scenes
2922 /// </summary> 3030 /// </summary>
2923 /// <param name="agentId">The avatar's Unique ID</param> 3031 /// <param name="agentId">The avatar's Unique ID</param>
2924 /// <param name="client">The IClientAPI for the client</param> 3032 /// <param name="client">The IClientAPI for the client</param>
2925 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3033 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2926 { 3034 {
2927 if (m_teleportModule != null) 3035 if (m_teleportModule != null)
2928 m_teleportModule.TeleportHome(agentId, client); 3036 return m_teleportModule.TeleportHome(agentId, client);
2929 else 3037 else
2930 { 3038 {
2931 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3039 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2932 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3040 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2933 } 3041 }
3042 return false;
2934 } 3043 }
2935 3044
2936 /// <summary> 3045 /// <summary>
@@ -3022,6 +3131,16 @@ namespace OpenSim.Region.Framework.Scenes
3022 /// <param name="flags"></param> 3131 /// <param name="flags"></param>
3023 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3132 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3024 { 3133 {
3134 //Add half the avatar's height so that the user doesn't fall through prims
3135 ScenePresence presence;
3136 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3137 {
3138 if (presence.Appearance != null)
3139 {
3140 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3141 }
3142 }
3143
3025 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3144 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3026 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3145 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3027 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3146 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3096,8 +3215,9 @@ namespace OpenSim.Region.Framework.Scenes
3096 regions.Remove(RegionInfo.RegionHandle); 3215 regions.Remove(RegionInfo.RegionHandle);
3097 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3216 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3098 } 3217 }
3099 3218 m_log.Debug("[Scene] Beginning ClientClosed");
3100 m_eventManager.TriggerClientClosed(agentID, this); 3219 m_eventManager.TriggerClientClosed(agentID, this);
3220 m_log.Debug("[Scene] Finished ClientClosed");
3101 } 3221 }
3102 catch (NullReferenceException) 3222 catch (NullReferenceException)
3103 { 3223 {
@@ -3105,7 +3225,12 @@ namespace OpenSim.Region.Framework.Scenes
3105 // Avatar is already disposed :/ 3225 // Avatar is already disposed :/
3106 } 3226 }
3107 3227
3228 m_log.Debug("[Scene] Beginning OnRemovePresence");
3108 m_eventManager.TriggerOnRemovePresence(agentID); 3229 m_eventManager.TriggerOnRemovePresence(agentID);
3230 m_log.Debug("[Scene] Finished OnRemovePresence");
3231
3232 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
3233 AttachmentsModule.SaveChangedAttachments(avatar);
3109 3234
3110 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) 3235 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
3111 AttachmentsModule.SaveChangedAttachments(avatar); 3236 AttachmentsModule.SaveChangedAttachments(avatar);
@@ -3114,7 +3239,7 @@ namespace OpenSim.Region.Framework.Scenes
3114 delegate(IClientAPI client) 3239 delegate(IClientAPI client)
3115 { 3240 {
3116 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3241 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3117 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3242 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3118 catch (NullReferenceException) { } 3243 catch (NullReferenceException) { }
3119 }); 3244 });
3120 3245
@@ -3125,8 +3250,11 @@ namespace OpenSim.Region.Framework.Scenes
3125 } 3250 }
3126 3251
3127 // Remove the avatar from the scene 3252 // Remove the avatar from the scene
3253 m_log.Debug("[Scene] Begin RemoveScenePresence");
3128 m_sceneGraph.RemoveScenePresence(agentID); 3254 m_sceneGraph.RemoveScenePresence(agentID);
3255 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3129 m_clientManager.Remove(agentID); 3256 m_clientManager.Remove(agentID);
3257 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3130 3258
3131 try 3259 try
3132 { 3260 {
@@ -3140,9 +3268,10 @@ namespace OpenSim.Region.Framework.Scenes
3140 { 3268 {
3141 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3269 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3142 } 3270 }
3143 3271 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3144 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3272 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3145// CleanDroppedAttachments(); 3273// CleanDroppedAttachments();
3274 m_log.Debug("[Scene] The avatar has left the building");
3146 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3275 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3147 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3276 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3148 } 3277 }
@@ -3173,19 +3302,24 @@ namespace OpenSim.Region.Framework.Scenes
3173 3302
3174 #region Entities 3303 #region Entities
3175 3304
3176 public void SendKillObject(uint localID) 3305 public void SendKillObject(List<uint> localIDs)
3177 { 3306 {
3178 SceneObjectPart part = GetSceneObjectPart(localID); 3307 List<uint> deleteIDs = new List<uint>();
3179 if (part != null) // It is a prim 3308
3309 foreach (uint localID in localIDs)
3180 { 3310 {
3181 if (!part.ParentGroup.IsDeleted) // Valid 3311 SceneObjectPart part = GetSceneObjectPart(localID);
3312 if (part != null) // It is a prim
3182 { 3313 {
3183 if (part.ParentGroup.RootPart != part) // Child part 3314 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3184 return; 3315 {
3316 if (part.ParentGroup.RootPart != part) // Child part
3317 continue;
3318 }
3185 } 3319 }
3320 deleteIDs.Add(localID);
3186 } 3321 }
3187 3322 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3188 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); });
3189 } 3323 }
3190 3324
3191 #endregion 3325 #endregion
@@ -3203,7 +3337,6 @@ namespace OpenSim.Region.Framework.Scenes
3203 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3337 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3204 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3338 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3205 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3339 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3206 m_sceneGridService.KiPrimitive += SendKillObject;
3207 m_sceneGridService.OnGetLandData += GetLandData; 3340 m_sceneGridService.OnGetLandData += GetLandData;
3208 } 3341 }
3209 3342
@@ -3212,7 +3345,6 @@ namespace OpenSim.Region.Framework.Scenes
3212 /// </summary> 3345 /// </summary>
3213 public void UnRegisterRegionWithComms() 3346 public void UnRegisterRegionWithComms()
3214 { 3347 {
3215 m_sceneGridService.KiPrimitive -= SendKillObject;
3216 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3348 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3217 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3349 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3218 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3350 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3292,13 +3424,16 @@ namespace OpenSim.Region.Framework.Scenes
3292 sp = null; 3424 sp = null;
3293 } 3425 }
3294 3426
3295 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3296 3427
3297 //On login test land permisions 3428 //On login test land permisions
3298 if (vialogin) 3429 if (vialogin)
3299 { 3430 {
3300 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3431 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3432 if (cache != null)
3433 cache.Remove(agent.firstname + " " + agent.lastname);
3434 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3301 { 3435 {
3436 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3302 return false; 3437 return false;
3303 } 3438 }
3304 } 3439 }
@@ -3321,8 +3456,13 @@ namespace OpenSim.Region.Framework.Scenes
3321 3456
3322 try 3457 try
3323 { 3458 {
3324 if (!AuthorizeUser(agent, out reason)) 3459 // Always check estate if this is a login. Always
3325 return false; 3460 // check if banned regions are to be blacked out.
3461 if (vialogin || (!m_seeIntoBannedRegion))
3462 {
3463 if (!AuthorizeUser(agent, out reason))
3464 return false;
3465 }
3326 } 3466 }
3327 catch (Exception e) 3467 catch (Exception e)
3328 { 3468 {
@@ -3424,6 +3564,8 @@ namespace OpenSim.Region.Framework.Scenes
3424 } 3564 }
3425 } 3565 }
3426 // Honor parcel landing type and position. 3566 // Honor parcel landing type and position.
3567 /*
3568 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3427 if (land != null) 3569 if (land != null)
3428 { 3570 {
3429 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3571 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3431,26 +3573,34 @@ namespace OpenSim.Region.Framework.Scenes
3431 agent.startpos = land.LandData.UserLocation; 3573 agent.startpos = land.LandData.UserLocation;
3432 } 3574 }
3433 } 3575 }
3576 */// This is now handled properly in ScenePresence.MakeRootAgent
3434 } 3577 }
3435 3578
3436 return true; 3579 return true;
3437 } 3580 }
3438 3581
3439 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3582 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3440 { 3583 {
3441 3584 reason = String.Empty;
3442 bool banned = land.IsBannedFromLand(agent.AgentID); 3585 if (Permissions.IsGod(agentID))
3443 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3586 return true;
3587
3588 ILandObject land = LandChannel.GetLandObject(posX, posY);
3589 if (land == null)
3590 return false;
3591
3592 bool banned = land.IsBannedFromLand(agentID);
3593 bool restricted = land.IsRestrictedFromLand(agentID);
3444 3594
3445 if (banned || restricted) 3595 if (banned || restricted)
3446 { 3596 {
3447 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3597 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3448 if (nearestParcel != null) 3598 if (nearestParcel != null)
3449 { 3599 {
3450 //Move agent to nearest allowed 3600 //Move agent to nearest allowed
3451 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3601 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3452 agent.startpos.X = newPosition.X; 3602 posX = newPosition.X;
3453 agent.startpos.Y = newPosition.Y; 3603 posY = newPosition.Y;
3454 } 3604 }
3455 else 3605 else
3456 { 3606 {
@@ -3512,7 +3662,7 @@ namespace OpenSim.Region.Framework.Scenes
3512 3662
3513 if (!m_strictAccessControl) return true; 3663 if (!m_strictAccessControl) return true;
3514 if (Permissions.IsGod(agent.AgentID)) return true; 3664 if (Permissions.IsGod(agent.AgentID)) return true;
3515 3665
3516 if (AuthorizationService != null) 3666 if (AuthorizationService != null)
3517 { 3667 {
3518 if (!AuthorizationService.IsAuthorizedForRegion( 3668 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3520,14 +3670,14 @@ namespace OpenSim.Region.Framework.Scenes
3520 { 3670 {
3521 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3671 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3522 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3672 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3523 3673
3524 return false; 3674 return false;
3525 } 3675 }
3526 } 3676 }
3527 3677
3528 if (m_regInfo.EstateSettings != null) 3678 if (m_regInfo.EstateSettings != null)
3529 { 3679 {
3530 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3680 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3531 { 3681 {
3532 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3682 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3533 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3683 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3717,6 +3867,13 @@ namespace OpenSim.Region.Framework.Scenes
3717 3867
3718 // We have to wait until the viewer contacts this region after receiving EAC. 3868 // We have to wait until the viewer contacts this region after receiving EAC.
3719 // That calls AddNewClient, which finally creates the ScenePresence 3869 // That calls AddNewClient, which finally creates the ScenePresence
3870 int flags = GetUserFlags(cAgentData.AgentID);
3871 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3872 {
3873 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3874 return false;
3875 }
3876
3720 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3877 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3721 if (nearestParcel == null) 3878 if (nearestParcel == null)
3722 { 3879 {
@@ -3732,7 +3889,6 @@ namespace OpenSim.Region.Framework.Scenes
3732 return false; 3889 return false;
3733 } 3890 }
3734 3891
3735
3736 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3892 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3737 3893
3738 if (childAgentUpdate != null) 3894 if (childAgentUpdate != null)
@@ -3799,12 +3955,22 @@ namespace OpenSim.Region.Framework.Scenes
3799 return false; 3955 return false;
3800 } 3956 }
3801 3957
3958 public bool IncomingCloseAgent(UUID agentID)
3959 {
3960 return IncomingCloseAgent(agentID, false);
3961 }
3962
3963 public bool IncomingCloseChildAgent(UUID agentID)
3964 {
3965 return IncomingCloseAgent(agentID, true);
3966 }
3967
3802 /// <summary> 3968 /// <summary>
3803 /// Tell a single agent to disconnect from the region. 3969 /// Tell a single agent to disconnect from the region.
3804 /// </summary> 3970 /// </summary>
3805 /// <param name="regionHandle"></param>
3806 /// <param name="agentID"></param> 3971 /// <param name="agentID"></param>
3807 public bool IncomingCloseAgent(UUID agentID) 3972 /// <param name="childOnly"></param>
3973 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3808 { 3974 {
3809 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3975 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3810 3976
@@ -3816,7 +3982,7 @@ namespace OpenSim.Region.Framework.Scenes
3816 { 3982 {
3817 m_sceneGraph.removeUserCount(false); 3983 m_sceneGraph.removeUserCount(false);
3818 } 3984 }
3819 else 3985 else if (!childOnly)
3820 { 3986 {
3821 m_sceneGraph.removeUserCount(true); 3987 m_sceneGraph.removeUserCount(true);
3822 } 3988 }
@@ -3832,9 +3998,12 @@ namespace OpenSim.Region.Framework.Scenes
3832 } 3998 }
3833 else 3999 else
3834 presence.ControllingClient.SendShutdownConnectionNotice(); 4000 presence.ControllingClient.SendShutdownConnectionNotice();
4001 presence.ControllingClient.Close(false);
4002 }
4003 else if (!childOnly)
4004 {
4005 presence.ControllingClient.Close(true);
3835 } 4006 }
3836
3837 presence.ControllingClient.Close();
3838 return true; 4007 return true;
3839 } 4008 }
3840 4009
@@ -4449,34 +4618,66 @@ namespace OpenSim.Region.Framework.Scenes
4449 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4618 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4450 } 4619 }
4451 4620
4452 public int GetHealth() 4621 public int GetHealth(out int flags, out string message)
4453 { 4622 {
4454 // Returns: 4623 // Returns:
4455 // 1 = sim is up and accepting http requests. The heartbeat has 4624 // 1 = sim is up and accepting http requests. The heartbeat has
4456 // stopped and the sim is probably locked up, but a remote 4625 // stopped and the sim is probably locked up, but a remote
4457 // admin restart may succeed 4626 // admin restart may succeed
4458 // 4627 //
4459 // 2 = Sim is up and the heartbeat is running. The sim is likely 4628 // 2 = Sim is up and the heartbeat is running. The sim is likely
4460 // usable for people within and logins _may_ work 4629 // usable for people within
4630 //
4631 // 3 = Sim is up and one packet thread is running. Sim is
4632 // unstable and will not accept new logins
4461 // 4633 //
4462 // 3 = We have seen a new user enter within the past 4 minutes 4634 // 4 = Sim is up and both packet threads are running. Sim is
4635 // likely usable
4636 //
4637 // 5 = We have seen a new user enter within the past 4 minutes
4463 // which can be seen as positive confirmation of sim health 4638 // which can be seen as positive confirmation of sim health
4464 // 4639 //
4640
4641 flags = 0;
4642 message = String.Empty;
4643
4644 CheckHeartbeat();
4645
4646 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4647 {
4648 // We're still starting
4649 // 0 means "in startup", it can't happen another way, since
4650 // to get here, we must be able to accept http connections
4651 return 0;
4652 }
4653
4465 int health=1; // Start at 1, means we're up 4654 int health=1; // Start at 1, means we're up
4466 4655
4467 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4656 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4657 {
4468 health+=1; 4658 health+=1;
4469 else 4659 flags |= 1;
4660 }
4661
4662 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4663 {
4664 health+=1;
4665 flags |= 2;
4666 }
4667
4668 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4669 {
4670 health+=1;
4671 flags |= 4;
4672 }
4673
4674 if (flags != 7)
4470 return health; 4675 return health;
4471 4676
4472 // A login in the last 4 mins? We can't be doing too badly 4677 // A login in the last 4 mins? We can't be doing too badly
4473 // 4678 //
4474 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4679 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4475 health++; 4680 health++;
4476 else
4477 return health;
4478
4479 CheckHeartbeat();
4480 4681
4481 return health; 4682 return health;
4482 } 4683 }
@@ -4669,7 +4870,7 @@ namespace OpenSim.Region.Framework.Scenes
4669 if (m_firstHeartbeat) 4870 if (m_firstHeartbeat)
4670 return; 4871 return;
4671 4872
4672 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4873 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4673 StartTimer(); 4874 StartTimer();
4674 } 4875 }
4675 4876
@@ -5118,6 +5319,19 @@ namespace OpenSim.Region.Framework.Scenes
5118// } 5319// }
5119// } 5320// }
5120 5321
5322 public void ThreadAlive(int threadCode)
5323 {
5324 switch(threadCode)
5325 {
5326 case 1: // Incoming
5327 m_lastIncoming = Util.EnvironmentTickCount();
5328 break;
5329 case 2: // Incoming
5330 m_lastOutgoing = Util.EnvironmentTickCount();
5331 break;
5332 }
5333 }
5334
5121 // This method is called across the simulation connector to 5335 // This method is called across the simulation connector to
5122 // determine if a given agent is allowed in this region 5336 // determine if a given agent is allowed in this region
5123 // AS A ROOT AGENT. Returning false here will prevent them 5337 // AS A ROOT AGENT. Returning false here will prevent them
@@ -5126,6 +5340,14 @@ namespace OpenSim.Region.Framework.Scenes
5126 // child agent creation, thereby emulating the SL behavior. 5340 // child agent creation, thereby emulating the SL behavior.
5127 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5341 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5128 { 5342 {
5343 reason = "You are banned from the region";
5344
5345 if (Permissions.IsGod(agentID))
5346 {
5347 reason = String.Empty;
5348 return true;
5349 }
5350
5129 int num = m_sceneGraph.GetNumberOfScenePresences(); 5351 int num = m_sceneGraph.GetNumberOfScenePresences();
5130 5352
5131 if (num >= RegionInfo.RegionSettings.AgentLimit) 5353 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5137,11 +5359,60 @@ namespace OpenSim.Region.Framework.Scenes
5137 } 5359 }
5138 } 5360 }
5139 5361
5362 try
5363 {
5364 if (!AuthorizeUser(GetScenePresence(agentID).ControllingClient.RequestClientInfo(), out reason))
5365 {
5366 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5367 return false;
5368 }
5369 }
5370 catch
5371 {
5372 return false;
5373 }
5374
5375 if (position == Vector3.Zero) // Teleport
5376 {
5377 float posX = 128.0f;
5378 float posY = 128.0f;
5379
5380 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5381 {
5382 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5383 return false;
5384 }
5385 }
5386 else // Walking
5387 {
5388 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5389 if (land == null)
5390 return false;
5391
5392 bool banned = land.IsBannedFromLand(agentID);
5393 bool restricted = land.IsRestrictedFromLand(agentID);
5394
5395 if (banned || restricted)
5396 return false;
5397 }
5398
5140 reason = String.Empty; 5399 reason = String.Empty;
5141 return true; 5400 return true;
5142 } 5401 }
5143 5402
5144 /// <summary> 5403 public void StartTimerWatchdog()
5404 {
5405 m_timerWatchdog.Interval = 1000;
5406 m_timerWatchdog.Elapsed += TimerWatchdog;
5407 m_timerWatchdog.AutoReset = true;
5408 m_timerWatchdog.Start();
5409 }
5410
5411 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5412 {
5413 CheckHeartbeat();
5414 }
5415
5145 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5416 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5146 /// autopilot that moves an avatar to a sit target!. 5417 /// autopilot that moves an avatar to a sit target!.
5147 /// </summary> 5418 /// </summary>