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.cs490
1 files changed, 363 insertions, 127 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 8edf3d3..7f308da 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -84,6 +84,7 @@ namespace OpenSim.Region.Framework.Scenes
84 // TODO: need to figure out how allow client agents but deny 84 // TODO: need to figure out how allow client agents but deny
85 // root agents when ACL denies access to root agent 85 // root agents when ACL denies access to root agent
86 public bool m_strictAccessControl = true; 86 public bool m_strictAccessControl = true;
87 public bool m_seeIntoBannedRegion = false;
87 public int MaxUndoCount = 5; 88 public int MaxUndoCount = 5;
88 public bool LoginsDisabled = true; 89 public bool LoginsDisabled = true;
89 public bool LoadingPrims; 90 public bool LoadingPrims;
@@ -102,6 +103,7 @@ namespace OpenSim.Region.Framework.Scenes
102 protected ModuleLoader m_moduleLoader; 103 protected ModuleLoader m_moduleLoader;
103 protected AgentCircuitManager m_authenticateHandler; 104 protected AgentCircuitManager m_authenticateHandler;
104 protected SceneCommunicationService m_sceneGridService; 105 protected SceneCommunicationService m_sceneGridService;
106 protected ISnmpModule m_snmpService = null;
105 107
106 protected ISimulationDataService m_SimulationDataService; 108 protected ISimulationDataService m_SimulationDataService;
107 protected IEstateDataService m_EstateDataService; 109 protected IEstateDataService m_EstateDataService;
@@ -149,7 +151,7 @@ namespace OpenSim.Region.Framework.Scenes
149 private int m_update_events = 1; 151 private int m_update_events = 1;
150 private int m_update_backup = 200; 152 private int m_update_backup = 200;
151 private int m_update_terrain = 50; 153 private int m_update_terrain = 50;
152// private int m_update_land = 1; 154 private int m_update_land = 10;
153 private int m_update_coarse_locations = 50; 155 private int m_update_coarse_locations = 50;
154 156
155 private int frameMS; 157 private int frameMS;
@@ -163,6 +165,7 @@ namespace OpenSim.Region.Framework.Scenes
163 private int landMS; 165 private int landMS;
164 private int lastCompletedFrame; 166 private int lastCompletedFrame;
165 167
168 public bool CombineRegions = false;
166 private bool m_physics_enabled = true; 169 private bool m_physics_enabled = true;
167 private bool m_scripts_enabled = true; 170 private bool m_scripts_enabled = true;
168 private string m_defaultScriptEngine; 171 private string m_defaultScriptEngine;
@@ -171,6 +174,8 @@ namespace OpenSim.Region.Framework.Scenes
171 private volatile bool shuttingdown; 174 private volatile bool shuttingdown;
172 175
173 private int m_lastUpdate; 176 private int m_lastUpdate;
177 private int m_lastIncoming;
178 private int m_lastOutgoing;
174 private bool m_firstHeartbeat = true; 179 private bool m_firstHeartbeat = true;
175 180
176 private object m_deleting_scene_object = new object(); 181 private object m_deleting_scene_object = new object();
@@ -222,6 +227,19 @@ namespace OpenSim.Region.Framework.Scenes
222 get { return m_sceneGridService; } 227 get { return m_sceneGridService; }
223 } 228 }
224 229
230 public ISnmpModule SnmpService
231 {
232 get
233 {
234 if (m_snmpService == null)
235 {
236 m_snmpService = RequestModuleInterface<ISnmpModule>();
237 }
238
239 return m_snmpService;
240 }
241 }
242
225 public ISimulationDataService SimulationDataService 243 public ISimulationDataService SimulationDataService
226 { 244 {
227 get 245 get
@@ -547,6 +565,8 @@ namespace OpenSim.Region.Framework.Scenes
547 m_regionName = m_regInfo.RegionName; 565 m_regionName = m_regInfo.RegionName;
548 m_datastore = m_regInfo.DataStore; 566 m_datastore = m_regInfo.DataStore;
549 m_lastUpdate = Util.EnvironmentTickCount(); 567 m_lastUpdate = Util.EnvironmentTickCount();
568 m_lastIncoming = 0;
569 m_lastOutgoing = 0;
550 570
551 m_physicalPrim = physicalPrim; 571 m_physicalPrim = physicalPrim;
552 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; 572 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
@@ -560,6 +580,8 @@ namespace OpenSim.Region.Framework.Scenes
560 #region Region Settings 580 #region Region Settings
561 581
562 // Load region settings 582 // Load region settings
583 m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID);
584
563 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); 585 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID);
564 if (estateDataService != null) 586 if (estateDataService != null)
565 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); 587 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
@@ -619,9 +641,10 @@ namespace OpenSim.Region.Framework.Scenes
619 //Animation states 641 //Animation states
620 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 642 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
621 // TODO: Change default to true once the feature is supported 643 // TODO: Change default to true once the feature is supported
622 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 644 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
623
624 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 645 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
646
647 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
625 if (RegionInfo.NonphysPrimMax > 0) 648 if (RegionInfo.NonphysPrimMax > 0)
626 { 649 {
627 m_maxNonphys = RegionInfo.NonphysPrimMax; 650 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -653,6 +676,7 @@ namespace OpenSim.Region.Framework.Scenes
653 m_persistAfter *= 10000000; 676 m_persistAfter *= 10000000;
654 677
655 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 678 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
679 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
656 680
657 IConfig packetConfig = m_config.Configs["PacketPool"]; 681 IConfig packetConfig = m_config.Configs["PacketPool"];
658 if (packetConfig != null) 682 if (packetConfig != null)
@@ -662,6 +686,8 @@ namespace OpenSim.Region.Framework.Scenes
662 } 686 }
663 687
664 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 688 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
689 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
690 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
665 691
666 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 692 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
667 if (m_generateMaptiles) 693 if (m_generateMaptiles)
@@ -686,9 +712,9 @@ namespace OpenSim.Region.Framework.Scenes
686 } 712 }
687 } 713 }
688 } 714 }
689 catch 715 catch (Exception e)
690 { 716 {
691 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 717 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
692 } 718 }
693 719
694 #endregion Region Config 720 #endregion Region Config
@@ -1059,7 +1085,9 @@ namespace OpenSim.Region.Framework.Scenes
1059 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1085 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1060 if (HeartbeatThread != null) 1086 if (HeartbeatThread != null)
1061 { 1087 {
1088 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1062 HeartbeatThread.Abort(); 1089 HeartbeatThread.Abort();
1090 Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId);
1063 HeartbeatThread = null; 1091 HeartbeatThread = null;
1064 } 1092 }
1065 m_lastUpdate = Util.EnvironmentTickCount(); 1093 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1182,9 +1210,6 @@ namespace OpenSim.Region.Framework.Scenes
1182 try 1210 try
1183 { 1211 {
1184 Update(); 1212 Update();
1185
1186 m_lastUpdate = Util.EnvironmentTickCount();
1187 m_firstHeartbeat = false;
1188 } 1213 }
1189 catch (ThreadAbortException) 1214 catch (ThreadAbortException)
1190 { 1215 {
@@ -1299,12 +1324,12 @@ namespace OpenSim.Region.Framework.Scenes
1299 terrainMS = Util.EnvironmentTickCountSubtract(terMS); 1324 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1300 } 1325 }
1301 1326
1302 //if (m_frame % m_update_land == 0) 1327 if (m_frame % m_update_land == 0)
1303 //{ 1328 {
1304 // int ldMS = Util.EnvironmentTickCount(); 1329 int ldMS = Util.EnvironmentTickCount();
1305 // UpdateLand(); 1330 UpdateLand();
1306 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1331 landMS = Util.EnvironmentTickCountSubtract(ldMS);
1307 //} 1332 }
1308 1333
1309 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); 1334 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1310 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1335 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
@@ -1375,6 +1400,9 @@ namespace OpenSim.Region.Framework.Scenes
1375 1400
1376 // Tell the watchdog that this thread is still alive 1401 // Tell the watchdog that this thread is still alive
1377 Watchdog.UpdateThread(); 1402 Watchdog.UpdateThread();
1403
1404 m_lastUpdate = Util.EnvironmentTickCount();
1405 m_firstHeartbeat = false;
1378 } 1406 }
1379 } 1407 }
1380 1408
@@ -1394,9 +1422,9 @@ namespace OpenSim.Region.Framework.Scenes
1394 1422
1395 private void CheckAtTargets() 1423 private void CheckAtTargets()
1396 { 1424 {
1397 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1425 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1398 lock (m_groupsWithTargets) 1426 lock (m_groupsWithTargets)
1399 objs = m_groupsWithTargets.Values; 1427 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1400 1428
1401 foreach (SceneObjectGroup entry in objs) 1429 foreach (SceneObjectGroup entry in objs)
1402 entry.checkAtTargets(); 1430 entry.checkAtTargets();
@@ -1730,14 +1758,24 @@ namespace OpenSim.Region.Framework.Scenes
1730 /// <returns></returns> 1758 /// <returns></returns>
1731 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1759 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1732 { 1760 {
1761
1762 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1763 Vector3 wpos = Vector3.Zero;
1764 // Check for water surface intersection from above
1765 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1766 {
1767 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1768 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1769 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1770 wpos.Z = wheight;
1771 }
1772
1733 Vector3 pos = Vector3.Zero; 1773 Vector3 pos = Vector3.Zero;
1734 if (RayEndIsIntersection == (byte)1) 1774 if (RayEndIsIntersection == (byte)1)
1735 { 1775 {
1736 pos = RayEnd; 1776 pos = RayEnd;
1737 return pos;
1738 } 1777 }
1739 1778 else if (RayTargetID != UUID.Zero)
1740 if (RayTargetID != UUID.Zero)
1741 { 1779 {
1742 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1780 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1743 1781
@@ -1759,7 +1797,7 @@ namespace OpenSim.Region.Framework.Scenes
1759 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1797 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1760 1798
1761 // Un-comment out the following line to Get Raytrace results printed to the console. 1799 // Un-comment out the following line to Get Raytrace results printed to the console.
1762 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1800 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1763 float ScaleOffset = 0.5f; 1801 float ScaleOffset = 0.5f;
1764 1802
1765 // If we hit something 1803 // If we hit something
@@ -1782,13 +1820,10 @@ namespace OpenSim.Region.Framework.Scenes
1782 //pos.Z -= 0.25F; 1820 //pos.Z -= 0.25F;
1783 1821
1784 } 1822 }
1785
1786 return pos;
1787 } 1823 }
1788 else 1824 else
1789 { 1825 {
1790 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1826 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1791
1792 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1827 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1793 1828
1794 // Un-comment the following line to print the raytrace results to the console. 1829 // Un-comment the following line to print the raytrace results to the console.
@@ -1797,13 +1832,12 @@ namespace OpenSim.Region.Framework.Scenes
1797 if (ei.HitTF) 1832 if (ei.HitTF)
1798 { 1833 {
1799 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1834 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1800 } else 1835 }
1836 else
1801 { 1837 {
1802 // fall back to our stupid functionality 1838 // fall back to our stupid functionality
1803 pos = RayEnd; 1839 pos = RayEnd;
1804 } 1840 }
1805
1806 return pos;
1807 } 1841 }
1808 } 1842 }
1809 else 1843 else
@@ -1814,8 +1848,12 @@ namespace OpenSim.Region.Framework.Scenes
1814 //increase height so its above the ground. 1848 //increase height so its above the ground.
1815 //should be getting the normal of the ground at the rez point and using that? 1849 //should be getting the normal of the ground at the rez point and using that?
1816 pos.Z += scale.Z / 2f; 1850 pos.Z += scale.Z / 2f;
1817 return pos; 1851// return pos;
1818 } 1852 }
1853
1854 // check against posible water intercept
1855 if (wpos.Z > pos.Z) pos = wpos;
1856 return pos;
1819 } 1857 }
1820 1858
1821 1859
@@ -1895,7 +1933,10 @@ namespace OpenSim.Region.Framework.Scenes
1895 public bool AddRestoredSceneObject( 1933 public bool AddRestoredSceneObject(
1896 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1934 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1897 { 1935 {
1898 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1936 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1937 if (result)
1938 sceneObject.IsDeleted = false;
1939 return result;
1899 } 1940 }
1900 1941
1901 /// <summary> 1942 /// <summary>
@@ -1972,6 +2013,15 @@ namespace OpenSim.Region.Framework.Scenes
1972 /// </summary> 2013 /// </summary>
1973 public void DeleteAllSceneObjects() 2014 public void DeleteAllSceneObjects()
1974 { 2015 {
2016 DeleteAllSceneObjects(false);
2017 }
2018
2019 /// <summary>
2020 /// Delete every object from the scene. This does not include attachments worn by avatars.
2021 /// </summary>
2022 public void DeleteAllSceneObjects(bool exceptNoCopy)
2023 {
2024 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1975 lock (Entities) 2025 lock (Entities)
1976 { 2026 {
1977 EntityBase[] entities = Entities.GetEntities(); 2027 EntityBase[] entities = Entities.GetEntities();
@@ -1980,11 +2030,24 @@ namespace OpenSim.Region.Framework.Scenes
1980 if (e is SceneObjectGroup) 2030 if (e is SceneObjectGroup)
1981 { 2031 {
1982 SceneObjectGroup sog = (SceneObjectGroup)e; 2032 SceneObjectGroup sog = (SceneObjectGroup)e;
1983 if (!sog.IsAttachment) 2033 if (sog != null && !sog.IsAttachment)
1984 DeleteSceneObject((SceneObjectGroup)e, false); 2034 {
2035 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2036 {
2037 DeleteSceneObject((SceneObjectGroup)e, false);
2038 }
2039 else
2040 {
2041 toReturn.Add((SceneObjectGroup)e);
2042 }
2043 }
1985 } 2044 }
1986 } 2045 }
1987 } 2046 }
2047 if (toReturn.Count > 0)
2048 {
2049 returnObjects(toReturn.ToArray(), UUID.Zero);
2050 }
1988 } 2051 }
1989 2052
1990 /// <summary> 2053 /// <summary>
@@ -2033,6 +2096,8 @@ namespace OpenSim.Region.Framework.Scenes
2033 } 2096 }
2034 2097
2035 group.DeleteGroupFromScene(silent); 2098 group.DeleteGroupFromScene(silent);
2099 if (!silent)
2100 SendKillObject(new List<uint>() { group.LocalId });
2036 2101
2037// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2102// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2038 } 2103 }
@@ -2363,10 +2428,17 @@ namespace OpenSim.Region.Framework.Scenes
2363 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2428 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2364 public bool AddSceneObject(SceneObjectGroup sceneObject) 2429 public bool AddSceneObject(SceneObjectGroup sceneObject)
2365 { 2430 {
2431 if (sceneObject.OwnerID == UUID.Zero)
2432 {
2433 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2434 return false;
2435 }
2436
2366 // If the user is banned, we won't let any of their objects 2437 // If the user is banned, we won't let any of their objects
2367 // enter. Period. 2438 // enter. Period.
2368 // 2439 //
2369 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2440 int flags = GetUserFlags(sceneObject.OwnerID);
2441 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2370 { 2442 {
2371 m_log.Info("[INTERREGION]: Denied prim crossing for " + 2443 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2372 "banned avatar"); 2444 "banned avatar");
@@ -2410,15 +2482,28 @@ namespace OpenSim.Region.Framework.Scenes
2410 2482
2411 if (AttachmentsModule != null) 2483 if (AttachmentsModule != null)
2412 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2484 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2485
2486 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2413 } 2487 }
2414 else 2488 else
2415 { 2489 {
2490 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2416 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2491 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2417 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2492 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2418 } 2493 }
2494 if (sceneObject.OwnerID == UUID.Zero)
2495 {
2496 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2497 return false;
2498 }
2419 } 2499 }
2420 else 2500 else
2421 { 2501 {
2502 if (sceneObject.OwnerID == UUID.Zero)
2503 {
2504 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2505 return false;
2506 }
2422 AddRestoredSceneObject(sceneObject, true, false); 2507 AddRestoredSceneObject(sceneObject, true, false);
2423 2508
2424 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2509 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2457,6 +2542,22 @@ namespace OpenSim.Region.Framework.Scenes
2457 return 2; // StateSource.PrimCrossing 2542 return 2; // StateSource.PrimCrossing
2458 } 2543 }
2459 2544
2545 public int GetUserFlags(UUID user)
2546 {
2547 //Unfortunately the SP approach means that the value is cached until region is restarted
2548 /*
2549 ScenePresence sp;
2550 if (TryGetScenePresence(user, out sp))
2551 {
2552 return sp.UserFlags;
2553 }
2554 else
2555 {
2556 */
2557 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2558 return uac.UserFlags;
2559 //}
2560 }
2460 #endregion 2561 #endregion
2461 2562
2462 #region Add/Remove Avatar Methods 2563 #region Add/Remove Avatar Methods
@@ -2477,6 +2578,7 @@ namespace OpenSim.Region.Framework.Scenes
2477 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2578 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2478 2579
2479 CheckHeartbeat(); 2580 CheckHeartbeat();
2581 ScenePresence presence;
2480 2582
2481 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here 2583 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
2482 { 2584 {
@@ -2498,12 +2600,19 @@ namespace OpenSim.Region.Framework.Scenes
2498 } 2600 }
2499 } 2601 }
2500 2602
2501 if (GetScenePresence(client.AgentId) != null) 2603 if (TryGetScenePresence(client.AgentId, out presence))
2502 { 2604 {
2503 m_LastLogin = Util.EnvironmentTickCount(); 2605 m_LastLogin = Util.EnvironmentTickCount();
2504 EventManager.TriggerOnNewClient(client); 2606 EventManager.TriggerOnNewClient(client);
2505 if (vialogin) 2607 if (vialogin)
2608 {
2506 EventManager.TriggerOnClientLogin(client); 2609 EventManager.TriggerOnClientLogin(client);
2610
2611 // Send initial parcel data
2612 Vector3 pos = presence.AbsolutePosition;
2613 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2614 land.SendLandUpdateToClient(presence.ControllingClient);
2615 }
2507 } 2616 }
2508 } 2617 }
2509 2618
@@ -2554,19 +2663,12 @@ namespace OpenSim.Region.Framework.Scenes
2554 // and the scene presence and the client, if they exist 2663 // and the scene presence and the client, if they exist
2555 try 2664 try
2556 { 2665 {
2557 // We need to wait for the client to make UDP contact first. 2666 ScenePresence sp = GetScenePresence(agentID);
2558 // It's the UDP contact that creates the scene presence 2667 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2559 ScenePresence sp = WaitGetScenePresence(agentID); 2668
2560 if (sp != null) 2669 if (sp != null)
2561 {
2562 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2563
2564 sp.ControllingClient.Close(); 2670 sp.ControllingClient.Close();
2565 } 2671
2566 else
2567 {
2568 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2569 }
2570 // BANG! SLASH! 2672 // BANG! SLASH!
2571 m_authenticateHandler.RemoveCircuit(agentID); 2673 m_authenticateHandler.RemoveCircuit(agentID);
2572 2674
@@ -2666,6 +2768,7 @@ namespace OpenSim.Region.Framework.Scenes
2666 client.OnFetchInventory += HandleFetchInventory; 2768 client.OnFetchInventory += HandleFetchInventory;
2667 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2769 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2668 client.OnCopyInventoryItem += CopyInventoryItem; 2770 client.OnCopyInventoryItem += CopyInventoryItem;
2771 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2669 client.OnMoveInventoryItem += MoveInventoryItem; 2772 client.OnMoveInventoryItem += MoveInventoryItem;
2670 client.OnRemoveInventoryItem += RemoveInventoryItem; 2773 client.OnRemoveInventoryItem += RemoveInventoryItem;
2671 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2774 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2844,15 +2947,16 @@ namespace OpenSim.Region.Framework.Scenes
2844 /// </summary> 2947 /// </summary>
2845 /// <param name="agentId">The avatar's Unique ID</param> 2948 /// <param name="agentId">The avatar's Unique ID</param>
2846 /// <param name="client">The IClientAPI for the client</param> 2949 /// <param name="client">The IClientAPI for the client</param>
2847 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2950 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2848 { 2951 {
2849 if (m_teleportModule != null) 2952 if (m_teleportModule != null)
2850 m_teleportModule.TeleportHome(agentId, client); 2953 return m_teleportModule.TeleportHome(agentId, client);
2851 else 2954 else
2852 { 2955 {
2853 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 2956 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2854 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 2957 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2855 } 2958 }
2959 return false;
2856 } 2960 }
2857 2961
2858 /// <summary> 2962 /// <summary>
@@ -2951,6 +3055,16 @@ namespace OpenSim.Region.Framework.Scenes
2951 /// <param name="flags"></param> 3055 /// <param name="flags"></param>
2952 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3056 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
2953 { 3057 {
3058 //Add half the avatar's height so that the user doesn't fall through prims
3059 ScenePresence presence;
3060 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3061 {
3062 if (presence.Appearance != null)
3063 {
3064 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3065 }
3066 }
3067
2954 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3068 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
2955 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3069 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
2956 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3070 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3025,7 +3139,9 @@ namespace OpenSim.Region.Framework.Scenes
3025 regions.Remove(RegionInfo.RegionHandle); 3139 regions.Remove(RegionInfo.RegionHandle);
3026 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3140 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3027 } 3141 }
3142 m_log.Debug("[Scene] Beginning ClientClosed");
3028 m_eventManager.TriggerClientClosed(agentID, this); 3143 m_eventManager.TriggerClientClosed(agentID, this);
3144 m_log.Debug("[Scene] Finished ClientClosed");
3029 } 3145 }
3030 catch (NullReferenceException) 3146 catch (NullReferenceException)
3031 { 3147 {
@@ -3033,7 +3149,12 @@ namespace OpenSim.Region.Framework.Scenes
3033 // Avatar is already disposed :/ 3149 // Avatar is already disposed :/
3034 } 3150 }
3035 3151
3152 m_log.Debug("[Scene] Beginning OnRemovePresence");
3036 m_eventManager.TriggerOnRemovePresence(agentID); 3153 m_eventManager.TriggerOnRemovePresence(agentID);
3154 m_log.Debug("[Scene] Finished OnRemovePresence");
3155
3156 if (avatar != null && (!avatar.IsChildAgent))
3157 avatar.SaveChangedAttachments();
3037 3158
3038 if (avatar != null && (!avatar.IsChildAgent)) 3159 if (avatar != null && (!avatar.IsChildAgent))
3039 avatar.SaveChangedAttachments(); 3160 avatar.SaveChangedAttachments();
@@ -3042,7 +3163,7 @@ namespace OpenSim.Region.Framework.Scenes
3042 delegate(IClientAPI client) 3163 delegate(IClientAPI client)
3043 { 3164 {
3044 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3165 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3045 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3166 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3046 catch (NullReferenceException) { } 3167 catch (NullReferenceException) { }
3047 }); 3168 });
3048 3169
@@ -3053,8 +3174,11 @@ namespace OpenSim.Region.Framework.Scenes
3053 } 3174 }
3054 3175
3055 // Remove the avatar from the scene 3176 // Remove the avatar from the scene
3177 m_log.Debug("[Scene] Begin RemoveScenePresence");
3056 m_sceneGraph.RemoveScenePresence(agentID); 3178 m_sceneGraph.RemoveScenePresence(agentID);
3179 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3057 m_clientManager.Remove(agentID); 3180 m_clientManager.Remove(agentID);
3181 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3058 3182
3059 try 3183 try
3060 { 3184 {
@@ -3068,9 +3192,10 @@ namespace OpenSim.Region.Framework.Scenes
3068 { 3192 {
3069 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3193 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3070 } 3194 }
3071 3195 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3072 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3196 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3073 CleanDroppedAttachments(); 3197 CleanDroppedAttachments();
3198 m_log.Debug("[Scene] The avatar has left the building");
3074 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3199 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3075 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3200 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3076 } 3201 }
@@ -3101,18 +3226,24 @@ namespace OpenSim.Region.Framework.Scenes
3101 3226
3102 #region Entities 3227 #region Entities
3103 3228
3104 public void SendKillObject(uint localID) 3229 public void SendKillObject(List<uint> localIDs)
3105 { 3230 {
3106 SceneObjectPart part = GetSceneObjectPart(localID); 3231 List<uint> deleteIDs = new List<uint>();
3107 if (part != null) // It is a prim 3232
3233 foreach (uint localID in localIDs)
3108 { 3234 {
3109 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3235 SceneObjectPart part = GetSceneObjectPart(localID);
3236 if (part != null) // It is a prim
3110 { 3237 {
3111 if (part.ParentGroup.RootPart != part) // Child part 3238 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3112 return; 3239 {
3240 if (part.ParentGroup.RootPart != part) // Child part
3241 continue;
3242 }
3113 } 3243 }
3244 deleteIDs.Add(localID);
3114 } 3245 }
3115 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3246 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3116 } 3247 }
3117 3248
3118 #endregion 3249 #endregion
@@ -3130,7 +3261,6 @@ namespace OpenSim.Region.Framework.Scenes
3130 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3261 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3131 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3262 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3132 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3263 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3133 m_sceneGridService.KiPrimitive += SendKillObject;
3134 m_sceneGridService.OnGetLandData += GetLandData; 3264 m_sceneGridService.OnGetLandData += GetLandData;
3135 } 3265 }
3136 3266
@@ -3139,7 +3269,6 @@ namespace OpenSim.Region.Framework.Scenes
3139 /// </summary> 3269 /// </summary>
3140 public void UnRegisterRegionWithComms() 3270 public void UnRegisterRegionWithComms()
3141 { 3271 {
3142 m_sceneGridService.KiPrimitive -= SendKillObject;
3143 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3272 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3144 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3273 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3145 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3274 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3219,13 +3348,16 @@ namespace OpenSim.Region.Framework.Scenes
3219 sp = null; 3348 sp = null;
3220 } 3349 }
3221 3350
3222 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3223 3351
3224 //On login test land permisions 3352 //On login test land permisions
3225 if (vialogin) 3353 if (vialogin)
3226 { 3354 {
3227 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3355 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3356 if (cache != null)
3357 cache.Remove(agent.firstname + " " + agent.lastname);
3358 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3228 { 3359 {
3360 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3229 return false; 3361 return false;
3230 } 3362 }
3231 } 3363 }
@@ -3248,8 +3380,13 @@ namespace OpenSim.Region.Framework.Scenes
3248 3380
3249 try 3381 try
3250 { 3382 {
3251 if (!AuthorizeUser(agent, out reason)) 3383 // Always check estate if this is a login. Always
3252 return false; 3384 // check if banned regions are to be blacked out.
3385 if (vialogin || (!m_seeIntoBannedRegion))
3386 {
3387 if (!AuthorizeUser(agent.AgentID, out reason))
3388 return false;
3389 }
3253 } 3390 }
3254 catch (Exception e) 3391 catch (Exception e)
3255 { 3392 {
@@ -3347,6 +3484,8 @@ namespace OpenSim.Region.Framework.Scenes
3347 } 3484 }
3348 } 3485 }
3349 // Honor parcel landing type and position. 3486 // Honor parcel landing type and position.
3487 /*
3488 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3350 if (land != null) 3489 if (land != null)
3351 { 3490 {
3352 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3491 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3354,26 +3493,32 @@ namespace OpenSim.Region.Framework.Scenes
3354 agent.startpos = land.LandData.UserLocation; 3493 agent.startpos = land.LandData.UserLocation;
3355 } 3494 }
3356 } 3495 }
3496 */// This is now handled properly in ScenePresence.MakeRootAgent
3357 } 3497 }
3358 3498
3359 return true; 3499 return true;
3360 } 3500 }
3361 3501
3362 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3502 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3363 { 3503 {
3364 3504 reason = String.Empty;
3365 bool banned = land.IsBannedFromLand(agent.AgentID); 3505
3366 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3506 ILandObject land = LandChannel.GetLandObject(posX, posY);
3507 if (land == null)
3508 return false;
3509
3510 bool banned = land.IsBannedFromLand(agentID);
3511 bool restricted = land.IsRestrictedFromLand(agentID);
3367 3512
3368 if (banned || restricted) 3513 if (banned || restricted)
3369 { 3514 {
3370 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3515 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3371 if (nearestParcel != null) 3516 if (nearestParcel != null)
3372 { 3517 {
3373 //Move agent to nearest allowed 3518 //Move agent to nearest allowed
3374 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3519 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3375 agent.startpos.X = newPosition.X; 3520 posX = newPosition.X;
3376 agent.startpos.Y = newPosition.Y; 3521 posY = newPosition.Y;
3377 } 3522 }
3378 else 3523 else
3379 { 3524 {
@@ -3429,19 +3574,19 @@ namespace OpenSim.Region.Framework.Scenes
3429 /// <param name="reason">outputs the reason to this string</param> 3574 /// <param name="reason">outputs the reason to this string</param>
3430 /// <returns>True if the region accepts this agent. False if it does not. False will 3575 /// <returns>True if the region accepts this agent. False if it does not. False will
3431 /// also return a reason.</returns> 3576 /// also return a reason.</returns>
3432 protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) 3577 protected virtual bool AuthorizeUser(UUID agentID, out string reason)
3433 { 3578 {
3434 reason = String.Empty; 3579 reason = String.Empty;
3435 3580
3436 if (!m_strictAccessControl) return true; 3581 if (!m_strictAccessControl) return true;
3437 if (Permissions.IsGod(agent.AgentID)) return true; 3582 if (Permissions.IsGod(agentID)) return true;
3438 3583
3439 if (AuthorizationService != null) 3584 if (AuthorizationService != null)
3440 { 3585 {
3441 if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) 3586 if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason))
3442 { 3587 {
3443 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3588 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region",
3444 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3589 agentID, RegionInfo.RegionName);
3445 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); 3590 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName);
3446 return false; 3591 return false;
3447 } 3592 }
@@ -3449,10 +3594,26 @@ namespace OpenSim.Region.Framework.Scenes
3449 3594
3450 if (m_regInfo.EstateSettings != null) 3595 if (m_regInfo.EstateSettings != null)
3451 { 3596 {
3452 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3597 int flags = GetUserFlags(agentID);
3598 if (m_regInfo.EstateSettings.IsBanned(agentID, flags))
3453 { 3599 {
3454 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3600 //Add some more info to help users
3455 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3601 if (!m_regInfo.EstateSettings.IsBanned(agentID, 32))
3602 {
3603 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification",
3604 agentID, RegionInfo.RegionName);
3605 reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName);
3606 return false;
3607 }
3608 if (!m_regInfo.EstateSettings.IsBanned(agentID, 4))
3609 {
3610 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file",
3611 agentID, RegionInfo.RegionName);
3612 reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName);
3613 return false;
3614 }
3615 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist",
3616 agentID, RegionInfo.RegionName);
3456 reason = String.Format("Denied access to region {0}: You have been banned from that region.", 3617 reason = String.Format("Denied access to region {0}: You have been banned from that region.",
3457 RegionInfo.RegionName); 3618 RegionInfo.RegionName);
3458 return false; 3619 return false;
@@ -3469,7 +3630,7 @@ namespace OpenSim.Region.Framework.Scenes
3469 if (groupsModule != null) 3630 if (groupsModule != null)
3470 { 3631 {
3471 GroupMembershipData[] GroupMembership = 3632 GroupMembershipData[] GroupMembership =
3472 groupsModule.GetMembershipData(agent.AgentID); 3633 groupsModule.GetMembershipData(agentID);
3473 3634
3474 if (GroupMembership != null) 3635 if (GroupMembership != null)
3475 { 3636 {
@@ -3498,44 +3659,16 @@ namespace OpenSim.Region.Framework.Scenes
3498 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); 3659 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!");
3499 3660
3500 if (!m_regInfo.EstateSettings.PublicAccess && 3661 if (!m_regInfo.EstateSettings.PublicAccess &&
3501 !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && 3662 !m_regInfo.EstateSettings.HasAccess(agentID) &&
3502 !groupAccess) 3663 !groupAccess)
3503 { 3664 {
3504 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", 3665 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate",
3505 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3666 agentID, RegionInfo.RegionName);
3506 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", 3667 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3507 RegionInfo.RegionName); 3668 RegionInfo.RegionName);
3508 return false; 3669 return false;
3509 } 3670 }
3510 3671
3511 // TODO: estate/region settings are not properly hooked up
3512 // to ILandObject.isRestrictedFromLand()
3513 // if (null != LandChannel)
3514 // {
3515 // // region seems to have local Id of 1
3516 // ILandObject land = LandChannel.GetLandObject(1);
3517 // if (null != land)
3518 // {
3519 // if (land.isBannedFromLand(agent.AgentID))
3520 // {
3521 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land",
3522 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3523 // reason = String.Format("Denied access to private region {0}: You are banned from that region.",
3524 // RegionInfo.RegionName);
3525 // return false;
3526 // }
3527
3528 // if (land.isRestrictedFromLand(agent.AgentID))
3529 // {
3530 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3531 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3532 // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3533 // RegionInfo.RegionName);
3534 // return false;
3535 // }
3536 // }
3537 // }
3538
3539 return true; 3672 return true;
3540 } 3673 }
3541 3674
@@ -3639,6 +3772,13 @@ namespace OpenSim.Region.Framework.Scenes
3639 3772
3640 // We have to wait until the viewer contacts this region after receiving EAC. 3773 // We have to wait until the viewer contacts this region after receiving EAC.
3641 // That calls AddNewClient, which finally creates the ScenePresence 3774 // That calls AddNewClient, which finally creates the ScenePresence
3775 int flags = GetUserFlags(cAgentData.AgentID);
3776 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3777 {
3778 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3779 return false;
3780 }
3781
3642 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3782 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3643 if (nearestParcel == null) 3783 if (nearestParcel == null)
3644 { 3784 {
@@ -3646,6 +3786,14 @@ namespace OpenSim.Region.Framework.Scenes
3646 return false; 3786 return false;
3647 } 3787 }
3648 3788
3789 int num = m_sceneGraph.GetNumberOfScenePresences();
3790
3791 if (num >= RegionInfo.RegionSettings.AgentLimit)
3792 {
3793 if (!Permissions.IsAdministrator(cAgentData.AgentID))
3794 return false;
3795 }
3796
3649 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3797 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3650 3798
3651 if (childAgentUpdate != null) 3799 if (childAgentUpdate != null)
@@ -3712,12 +3860,22 @@ namespace OpenSim.Region.Framework.Scenes
3712 return false; 3860 return false;
3713 } 3861 }
3714 3862
3863 public bool IncomingCloseAgent(UUID agentID)
3864 {
3865 return IncomingCloseAgent(agentID, false);
3866 }
3867
3868 public bool IncomingCloseChildAgent(UUID agentID)
3869 {
3870 return IncomingCloseAgent(agentID, true);
3871 }
3872
3715 /// <summary> 3873 /// <summary>
3716 /// Tell a single agent to disconnect from the region. 3874 /// Tell a single agent to disconnect from the region.
3717 /// </summary> 3875 /// </summary>
3718 /// <param name="regionHandle"></param>
3719 /// <param name="agentID"></param> 3876 /// <param name="agentID"></param>
3720 public bool IncomingCloseAgent(UUID agentID) 3877 /// <param name="childOnly"></param>
3878 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3721 { 3879 {
3722 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3880 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3723 3881
@@ -3729,7 +3887,7 @@ namespace OpenSim.Region.Framework.Scenes
3729 { 3887 {
3730 m_sceneGraph.removeUserCount(false); 3888 m_sceneGraph.removeUserCount(false);
3731 } 3889 }
3732 else 3890 else if (!childOnly)
3733 { 3891 {
3734 m_sceneGraph.removeUserCount(true); 3892 m_sceneGraph.removeUserCount(true);
3735 } 3893 }
@@ -3745,9 +3903,12 @@ namespace OpenSim.Region.Framework.Scenes
3745 } 3903 }
3746 else 3904 else
3747 presence.ControllingClient.SendShutdownConnectionNotice(); 3905 presence.ControllingClient.SendShutdownConnectionNotice();
3906 presence.ControllingClient.Close(false);
3907 }
3908 else if (!childOnly)
3909 {
3910 presence.ControllingClient.Close(true);
3748 } 3911 }
3749
3750 presence.ControllingClient.Close();
3751 return true; 3912 return true;
3752 } 3913 }
3753 3914
@@ -4355,34 +4516,66 @@ namespace OpenSim.Region.Framework.Scenes
4355 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4516 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4356 } 4517 }
4357 4518
4358 public int GetHealth() 4519 public int GetHealth(out int flags, out string message)
4359 { 4520 {
4360 // Returns: 4521 // Returns:
4361 // 1 = sim is up and accepting http requests. The heartbeat has 4522 // 1 = sim is up and accepting http requests. The heartbeat has
4362 // stopped and the sim is probably locked up, but a remote 4523 // stopped and the sim is probably locked up, but a remote
4363 // admin restart may succeed 4524 // admin restart may succeed
4364 // 4525 //
4365 // 2 = Sim is up and the heartbeat is running. The sim is likely 4526 // 2 = Sim is up and the heartbeat is running. The sim is likely
4366 // usable for people within and logins _may_ work 4527 // usable for people within
4528 //
4529 // 3 = Sim is up and one packet thread is running. Sim is
4530 // unstable and will not accept new logins
4367 // 4531 //
4368 // 3 = We have seen a new user enter within the past 4 minutes 4532 // 4 = Sim is up and both packet threads are running. Sim is
4533 // likely usable
4534 //
4535 // 5 = We have seen a new user enter within the past 4 minutes
4369 // which can be seen as positive confirmation of sim health 4536 // which can be seen as positive confirmation of sim health
4370 // 4537 //
4538
4539 flags = 0;
4540 message = String.Empty;
4541
4542 CheckHeartbeat();
4543
4544 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4545 {
4546 // We're still starting
4547 // 0 means "in startup", it can't happen another way, since
4548 // to get here, we must be able to accept http connections
4549 return 0;
4550 }
4551
4371 int health=1; // Start at 1, means we're up 4552 int health=1; // Start at 1, means we're up
4372 4553
4373 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4554 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4555 {
4374 health+=1; 4556 health+=1;
4375 else 4557 flags |= 1;
4558 }
4559
4560 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4561 {
4562 health+=1;
4563 flags |= 2;
4564 }
4565
4566 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4567 {
4568 health+=1;
4569 flags |= 4;
4570 }
4571
4572 if (flags != 7)
4376 return health; 4573 return health;
4377 4574
4378 // A login in the last 4 mins? We can't be doing too badly 4575 // A login in the last 4 mins? We can't be doing too badly
4379 // 4576 //
4380 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4577 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4381 health++; 4578 health++;
4382 else
4383 return health;
4384
4385 CheckHeartbeat();
4386 4579
4387 return health; 4580 return health;
4388 } 4581 }
@@ -4575,7 +4768,7 @@ namespace OpenSim.Region.Framework.Scenes
4575 if (m_firstHeartbeat) 4768 if (m_firstHeartbeat)
4576 return; 4769 return;
4577 4770
4578 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4771 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000)
4579 StartTimer(); 4772 StartTimer();
4580 } 4773 }
4581 4774
@@ -4833,8 +5026,17 @@ namespace OpenSim.Region.Framework.Scenes
4833 { 5026 {
4834 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; 5027 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ;
4835 5028
5029 Vector3 vec = g.AbsolutePosition;
5030
4836 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); 5031 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
4837 5032
5033 ominX += vec.X;
5034 omaxX += vec.X;
5035 ominY += vec.Y;
5036 omaxY += vec.Y;
5037 ominZ += vec.Z;
5038 omaxZ += vec.Z;
5039
4838 if (minX > ominX) 5040 if (minX > ominX)
4839 minX = ominX; 5041 minX = ominX;
4840 if (minY > ominY) 5042 if (minY > ominY)
@@ -4904,10 +5106,28 @@ namespace OpenSim.Region.Framework.Scenes
4904 }); 5106 });
4905 } 5107 }
4906 5108
4907 foreach (SceneObjectGroup grp in objectsToDelete) 5109 if (objectsToDelete.Count > 0)
4908 { 5110 {
4909 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); 5111 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
4910 DeleteSceneObject(grp, true); 5112 foreach (SceneObjectGroup grp in objectsToDelete)
5113 {
5114 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5115 DeleteSceneObject(grp, true);
5116 }
5117 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5118 }
5119 }
5120
5121 public void ThreadAlive(int threadCode)
5122 {
5123 switch(threadCode)
5124 {
5125 case 1: // Incoming
5126 m_lastIncoming = Util.EnvironmentTickCount();
5127 break;
5128 case 2: // Incoming
5129 m_lastOutgoing = Util.EnvironmentTickCount();
5130 break;
4911 } 5131 }
4912 } 5132 }
4913 5133
@@ -4919,6 +5139,22 @@ namespace OpenSim.Region.Framework.Scenes
4919 // child agent creation, thereby emulating the SL behavior. 5139 // child agent creation, thereby emulating the SL behavior.
4920 public bool QueryAccess(UUID agentID) 5140 public bool QueryAccess(UUID agentID)
4921 { 5141 {
5142 string reason;
5143
5144 if (!AuthorizeUser(agentID, out reason))
5145 {
5146 m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5147 return false;
5148 }
5149
5150 float posX = 128.0f;
5151 float posY = 128.0f;
5152
5153 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5154 {
5155 m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5156 return false;
5157 }
4922 return true; 5158 return true;
4923 } 5159 }
4924 } 5160 }