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.cs507
1 files changed, 380 insertions, 127 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4fca261..2424194 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,24 @@ 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 if (uac == null)
2559 return 0;
2560 return uac.UserFlags;
2561 //}
2562 }
2460 #endregion 2563 #endregion
2461 2564
2462 #region Add/Remove Avatar Methods 2565 #region Add/Remove Avatar Methods
@@ -2477,6 +2580,7 @@ namespace OpenSim.Region.Framework.Scenes
2477 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2580 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2478 2581
2479 CheckHeartbeat(); 2582 CheckHeartbeat();
2583 ScenePresence presence;
2480 2584
2481 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here 2585 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
2482 { 2586 {
@@ -2500,12 +2604,19 @@ namespace OpenSim.Region.Framework.Scenes
2500 } 2604 }
2501 } 2605 }
2502 2606
2503 if (GetScenePresence(client.AgentId) != null) 2607 if (TryGetScenePresence(client.AgentId, out presence))
2504 { 2608 {
2505 m_LastLogin = Util.EnvironmentTickCount(); 2609 m_LastLogin = Util.EnvironmentTickCount();
2506 EventManager.TriggerOnNewClient(client); 2610 EventManager.TriggerOnNewClient(client);
2507 if (vialogin) 2611 if (vialogin)
2612 {
2508 EventManager.TriggerOnClientLogin(client); 2613 EventManager.TriggerOnClientLogin(client);
2614
2615 // Send initial parcel data
2616 Vector3 pos = presence.AbsolutePosition;
2617 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2618 land.SendLandUpdateToClient(presence.ControllingClient);
2619 }
2509 } 2620 }
2510 } 2621 }
2511 2622
@@ -2556,19 +2667,12 @@ namespace OpenSim.Region.Framework.Scenes
2556 // and the scene presence and the client, if they exist 2667 // and the scene presence and the client, if they exist
2557 try 2668 try
2558 { 2669 {
2559 // We need to wait for the client to make UDP contact first. 2670 ScenePresence sp = GetScenePresence(agentID);
2560 // It's the UDP contact that creates the scene presence 2671 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2561 ScenePresence sp = WaitGetScenePresence(agentID); 2672
2562 if (sp != null) 2673 if (sp != null)
2563 {
2564 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2565
2566 sp.ControllingClient.Close(); 2674 sp.ControllingClient.Close();
2567 } 2675
2568 else
2569 {
2570 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2571 }
2572 // BANG! SLASH! 2676 // BANG! SLASH!
2573 m_authenticateHandler.RemoveCircuit(agentID); 2677 m_authenticateHandler.RemoveCircuit(agentID);
2574 2678
@@ -2668,6 +2772,7 @@ namespace OpenSim.Region.Framework.Scenes
2668 client.OnFetchInventory += HandleFetchInventory; 2772 client.OnFetchInventory += HandleFetchInventory;
2669 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2773 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2670 client.OnCopyInventoryItem += CopyInventoryItem; 2774 client.OnCopyInventoryItem += CopyInventoryItem;
2775 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2671 client.OnMoveInventoryItem += MoveInventoryItem; 2776 client.OnMoveInventoryItem += MoveInventoryItem;
2672 client.OnRemoveInventoryItem += RemoveInventoryItem; 2777 client.OnRemoveInventoryItem += RemoveInventoryItem;
2673 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2778 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2846,15 +2951,16 @@ namespace OpenSim.Region.Framework.Scenes
2846 /// </summary> 2951 /// </summary>
2847 /// <param name="agentId">The avatar's Unique ID</param> 2952 /// <param name="agentId">The avatar's Unique ID</param>
2848 /// <param name="client">The IClientAPI for the client</param> 2953 /// <param name="client">The IClientAPI for the client</param>
2849 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2954 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2850 { 2955 {
2851 if (m_teleportModule != null) 2956 if (m_teleportModule != null)
2852 m_teleportModule.TeleportHome(agentId, client); 2957 return m_teleportModule.TeleportHome(agentId, client);
2853 else 2958 else
2854 { 2959 {
2855 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 2960 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2856 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 2961 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2857 } 2962 }
2963 return false;
2858 } 2964 }
2859 2965
2860 /// <summary> 2966 /// <summary>
@@ -2953,6 +3059,16 @@ namespace OpenSim.Region.Framework.Scenes
2953 /// <param name="flags"></param> 3059 /// <param name="flags"></param>
2954 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3060 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
2955 { 3061 {
3062 //Add half the avatar's height so that the user doesn't fall through prims
3063 ScenePresence presence;
3064 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3065 {
3066 if (presence.Appearance != null)
3067 {
3068 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3069 }
3070 }
3071
2956 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3072 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
2957 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3073 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
2958 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3074 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3027,7 +3143,9 @@ namespace OpenSim.Region.Framework.Scenes
3027 regions.Remove(RegionInfo.RegionHandle); 3143 regions.Remove(RegionInfo.RegionHandle);
3028 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3144 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3029 } 3145 }
3146 m_log.Debug("[Scene] Beginning ClientClosed");
3030 m_eventManager.TriggerClientClosed(agentID, this); 3147 m_eventManager.TriggerClientClosed(agentID, this);
3148 m_log.Debug("[Scene] Finished ClientClosed");
3031 } 3149 }
3032 catch (NullReferenceException) 3150 catch (NullReferenceException)
3033 { 3151 {
@@ -3035,7 +3153,12 @@ namespace OpenSim.Region.Framework.Scenes
3035 // Avatar is already disposed :/ 3153 // Avatar is already disposed :/
3036 } 3154 }
3037 3155
3156 m_log.Debug("[Scene] Beginning OnRemovePresence");
3038 m_eventManager.TriggerOnRemovePresence(agentID); 3157 m_eventManager.TriggerOnRemovePresence(agentID);
3158 m_log.Debug("[Scene] Finished OnRemovePresence");
3159
3160 if (avatar != null && (!avatar.IsChildAgent))
3161 avatar.SaveChangedAttachments();
3039 3162
3040 if (avatar != null && (!avatar.IsChildAgent)) 3163 if (avatar != null && (!avatar.IsChildAgent))
3041 avatar.SaveChangedAttachments(); 3164 avatar.SaveChangedAttachments();
@@ -3044,7 +3167,7 @@ namespace OpenSim.Region.Framework.Scenes
3044 delegate(IClientAPI client) 3167 delegate(IClientAPI client)
3045 { 3168 {
3046 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3169 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3047 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3170 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3048 catch (NullReferenceException) { } 3171 catch (NullReferenceException) { }
3049 }); 3172 });
3050 3173
@@ -3055,8 +3178,11 @@ namespace OpenSim.Region.Framework.Scenes
3055 } 3178 }
3056 3179
3057 // Remove the avatar from the scene 3180 // Remove the avatar from the scene
3181 m_log.Debug("[Scene] Begin RemoveScenePresence");
3058 m_sceneGraph.RemoveScenePresence(agentID); 3182 m_sceneGraph.RemoveScenePresence(agentID);
3183 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3059 m_clientManager.Remove(agentID); 3184 m_clientManager.Remove(agentID);
3185 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3060 3186
3061 try 3187 try
3062 { 3188 {
@@ -3070,9 +3196,10 @@ namespace OpenSim.Region.Framework.Scenes
3070 { 3196 {
3071 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3197 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3072 } 3198 }
3073 3199 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3074 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3200 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3075 CleanDroppedAttachments(); 3201 CleanDroppedAttachments();
3202 m_log.Debug("[Scene] The avatar has left the building");
3076 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3203 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3077 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3204 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3078 } 3205 }
@@ -3103,18 +3230,24 @@ namespace OpenSim.Region.Framework.Scenes
3103 3230
3104 #region Entities 3231 #region Entities
3105 3232
3106 public void SendKillObject(uint localID) 3233 public void SendKillObject(List<uint> localIDs)
3107 { 3234 {
3108 SceneObjectPart part = GetSceneObjectPart(localID); 3235 List<uint> deleteIDs = new List<uint>();
3109 if (part != null) // It is a prim 3236
3237 foreach (uint localID in localIDs)
3110 { 3238 {
3111 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3239 SceneObjectPart part = GetSceneObjectPart(localID);
3240 if (part != null) // It is a prim
3112 { 3241 {
3113 if (part.ParentGroup.RootPart != part) // Child part 3242 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3114 return; 3243 {
3244 if (part.ParentGroup.RootPart != part) // Child part
3245 continue;
3246 }
3115 } 3247 }
3248 deleteIDs.Add(localID);
3116 } 3249 }
3117 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3250 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3118 } 3251 }
3119 3252
3120 #endregion 3253 #endregion
@@ -3132,7 +3265,6 @@ namespace OpenSim.Region.Framework.Scenes
3132 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3265 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3133 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3266 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3134 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3267 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3135 m_sceneGridService.KiPrimitive += SendKillObject;
3136 m_sceneGridService.OnGetLandData += GetLandData; 3268 m_sceneGridService.OnGetLandData += GetLandData;
3137 } 3269 }
3138 3270
@@ -3141,7 +3273,6 @@ namespace OpenSim.Region.Framework.Scenes
3141 /// </summary> 3273 /// </summary>
3142 public void UnRegisterRegionWithComms() 3274 public void UnRegisterRegionWithComms()
3143 { 3275 {
3144 m_sceneGridService.KiPrimitive -= SendKillObject;
3145 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3276 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3146 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3277 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3147 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3278 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3221,13 +3352,16 @@ namespace OpenSim.Region.Framework.Scenes
3221 sp = null; 3352 sp = null;
3222 } 3353 }
3223 3354
3224 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3225 3355
3226 //On login test land permisions 3356 //On login test land permisions
3227 if (vialogin) 3357 if (vialogin)
3228 { 3358 {
3229 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3359 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3360 if (cache != null)
3361 cache.Remove(agent.firstname + " " + agent.lastname);
3362 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3230 { 3363 {
3364 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3231 return false; 3365 return false;
3232 } 3366 }
3233 } 3367 }
@@ -3250,8 +3384,13 @@ namespace OpenSim.Region.Framework.Scenes
3250 3384
3251 try 3385 try
3252 { 3386 {
3253 if (!AuthorizeUser(agent, out reason)) 3387 // Always check estate if this is a login. Always
3254 return false; 3388 // check if banned regions are to be blacked out.
3389 if (vialogin || (!m_seeIntoBannedRegion))
3390 {
3391 if (!AuthorizeUser(agent.AgentID, out reason))
3392 return false;
3393 }
3255 } 3394 }
3256 catch (Exception e) 3395 catch (Exception e)
3257 { 3396 {
@@ -3349,6 +3488,8 @@ namespace OpenSim.Region.Framework.Scenes
3349 } 3488 }
3350 } 3489 }
3351 // Honor parcel landing type and position. 3490 // Honor parcel landing type and position.
3491 /*
3492 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3352 if (land != null) 3493 if (land != null)
3353 { 3494 {
3354 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3495 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3356,26 +3497,32 @@ namespace OpenSim.Region.Framework.Scenes
3356 agent.startpos = land.LandData.UserLocation; 3497 agent.startpos = land.LandData.UserLocation;
3357 } 3498 }
3358 } 3499 }
3500 */// This is now handled properly in ScenePresence.MakeRootAgent
3359 } 3501 }
3360 3502
3361 return true; 3503 return true;
3362 } 3504 }
3363 3505
3364 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3506 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3365 { 3507 {
3366 3508 reason = String.Empty;
3367 bool banned = land.IsBannedFromLand(agent.AgentID); 3509
3368 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3510 ILandObject land = LandChannel.GetLandObject(posX, posY);
3511 if (land == null)
3512 return false;
3513
3514 bool banned = land.IsBannedFromLand(agentID);
3515 bool restricted = land.IsRestrictedFromLand(agentID);
3369 3516
3370 if (banned || restricted) 3517 if (banned || restricted)
3371 { 3518 {
3372 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3519 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3373 if (nearestParcel != null) 3520 if (nearestParcel != null)
3374 { 3521 {
3375 //Move agent to nearest allowed 3522 //Move agent to nearest allowed
3376 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3523 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3377 agent.startpos.X = newPosition.X; 3524 posX = newPosition.X;
3378 agent.startpos.Y = newPosition.Y; 3525 posY = newPosition.Y;
3379 } 3526 }
3380 else 3527 else
3381 { 3528 {
@@ -3431,19 +3578,19 @@ namespace OpenSim.Region.Framework.Scenes
3431 /// <param name="reason">outputs the reason to this string</param> 3578 /// <param name="reason">outputs the reason to this string</param>
3432 /// <returns>True if the region accepts this agent. False if it does not. False will 3579 /// <returns>True if the region accepts this agent. False if it does not. False will
3433 /// also return a reason.</returns> 3580 /// also return a reason.</returns>
3434 protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) 3581 protected virtual bool AuthorizeUser(UUID agentID, out string reason)
3435 { 3582 {
3436 reason = String.Empty; 3583 reason = String.Empty;
3437 3584
3438 if (!m_strictAccessControl) return true; 3585 if (!m_strictAccessControl) return true;
3439 if (Permissions.IsGod(agent.AgentID)) return true; 3586 if (Permissions.IsGod(agentID)) return true;
3440 3587
3441 if (AuthorizationService != null) 3588 if (AuthorizationService != null)
3442 { 3589 {
3443 if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) 3590 if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason))
3444 { 3591 {
3445 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3592 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region",
3446 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3593 agentID, RegionInfo.RegionName);
3447 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); 3594 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName);
3448 return false; 3595 return false;
3449 } 3596 }
@@ -3451,10 +3598,26 @@ namespace OpenSim.Region.Framework.Scenes
3451 3598
3452 if (m_regInfo.EstateSettings != null) 3599 if (m_regInfo.EstateSettings != null)
3453 { 3600 {
3454 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3601 int flags = GetUserFlags(agentID);
3602 if (m_regInfo.EstateSettings.IsBanned(agentID, flags))
3455 { 3603 {
3456 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3604 //Add some more info to help users
3457 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3605 if (!m_regInfo.EstateSettings.IsBanned(agentID, 32))
3606 {
3607 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification",
3608 agentID, RegionInfo.RegionName);
3609 reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName);
3610 return false;
3611 }
3612 if (!m_regInfo.EstateSettings.IsBanned(agentID, 4))
3613 {
3614 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file",
3615 agentID, RegionInfo.RegionName);
3616 reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName);
3617 return false;
3618 }
3619 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist",
3620 agentID, RegionInfo.RegionName);
3458 reason = String.Format("Denied access to region {0}: You have been banned from that region.", 3621 reason = String.Format("Denied access to region {0}: You have been banned from that region.",
3459 RegionInfo.RegionName); 3622 RegionInfo.RegionName);
3460 return false; 3623 return false;
@@ -3471,7 +3634,7 @@ namespace OpenSim.Region.Framework.Scenes
3471 if (groupsModule != null) 3634 if (groupsModule != null)
3472 { 3635 {
3473 GroupMembershipData[] GroupMembership = 3636 GroupMembershipData[] GroupMembership =
3474 groupsModule.GetMembershipData(agent.AgentID); 3637 groupsModule.GetMembershipData(agentID);
3475 3638
3476 if (GroupMembership != null) 3639 if (GroupMembership != null)
3477 { 3640 {
@@ -3500,44 +3663,16 @@ namespace OpenSim.Region.Framework.Scenes
3500 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); 3663 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!");
3501 3664
3502 if (!m_regInfo.EstateSettings.PublicAccess && 3665 if (!m_regInfo.EstateSettings.PublicAccess &&
3503 !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && 3666 !m_regInfo.EstateSettings.HasAccess(agentID) &&
3504 !groupAccess) 3667 !groupAccess)
3505 { 3668 {
3506 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", 3669 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate",
3507 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3670 agentID, RegionInfo.RegionName);
3508 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", 3671 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3509 RegionInfo.RegionName); 3672 RegionInfo.RegionName);
3510 return false; 3673 return false;
3511 } 3674 }
3512 3675
3513 // TODO: estate/region settings are not properly hooked up
3514 // to ILandObject.isRestrictedFromLand()
3515 // if (null != LandChannel)
3516 // {
3517 // // region seems to have local Id of 1
3518 // ILandObject land = LandChannel.GetLandObject(1);
3519 // if (null != land)
3520 // {
3521 // if (land.isBannedFromLand(agent.AgentID))
3522 // {
3523 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land",
3524 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3525 // reason = String.Format("Denied access to private region {0}: You are banned from that region.",
3526 // RegionInfo.RegionName);
3527 // return false;
3528 // }
3529
3530 // if (land.isRestrictedFromLand(agent.AgentID))
3531 // {
3532 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3533 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3534 // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3535 // RegionInfo.RegionName);
3536 // return false;
3537 // }
3538 // }
3539 // }
3540
3541 return true; 3676 return true;
3542 } 3677 }
3543 3678
@@ -3641,6 +3776,13 @@ namespace OpenSim.Region.Framework.Scenes
3641 3776
3642 // We have to wait until the viewer contacts this region after receiving EAC. 3777 // We have to wait until the viewer contacts this region after receiving EAC.
3643 // That calls AddNewClient, which finally creates the ScenePresence 3778 // That calls AddNewClient, which finally creates the ScenePresence
3779 int flags = GetUserFlags(cAgentData.AgentID);
3780 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3781 {
3782 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3783 return false;
3784 }
3785
3644 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3786 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3645 if (nearestParcel == null) 3787 if (nearestParcel == null)
3646 { 3788 {
@@ -3648,6 +3790,14 @@ namespace OpenSim.Region.Framework.Scenes
3648 return false; 3790 return false;
3649 } 3791 }
3650 3792
3793 int num = m_sceneGraph.GetNumberOfScenePresences();
3794
3795 if (num >= RegionInfo.RegionSettings.AgentLimit)
3796 {
3797 if (!Permissions.IsAdministrator(cAgentData.AgentID))
3798 return false;
3799 }
3800
3651 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3801 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3652 3802
3653 if (childAgentUpdate != null) 3803 if (childAgentUpdate != null)
@@ -3714,12 +3864,22 @@ namespace OpenSim.Region.Framework.Scenes
3714 return false; 3864 return false;
3715 } 3865 }
3716 3866
3867 public bool IncomingCloseAgent(UUID agentID)
3868 {
3869 return IncomingCloseAgent(agentID, false);
3870 }
3871
3872 public bool IncomingCloseChildAgent(UUID agentID)
3873 {
3874 return IncomingCloseAgent(agentID, true);
3875 }
3876
3717 /// <summary> 3877 /// <summary>
3718 /// Tell a single agent to disconnect from the region. 3878 /// Tell a single agent to disconnect from the region.
3719 /// </summary> 3879 /// </summary>
3720 /// <param name="regionHandle"></param>
3721 /// <param name="agentID"></param> 3880 /// <param name="agentID"></param>
3722 public bool IncomingCloseAgent(UUID agentID) 3881 /// <param name="childOnly"></param>
3882 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3723 { 3883 {
3724 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3884 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3725 3885
@@ -3731,7 +3891,7 @@ namespace OpenSim.Region.Framework.Scenes
3731 { 3891 {
3732 m_sceneGraph.removeUserCount(false); 3892 m_sceneGraph.removeUserCount(false);
3733 } 3893 }
3734 else 3894 else if (!childOnly)
3735 { 3895 {
3736 m_sceneGraph.removeUserCount(true); 3896 m_sceneGraph.removeUserCount(true);
3737 } 3897 }
@@ -3747,9 +3907,12 @@ namespace OpenSim.Region.Framework.Scenes
3747 } 3907 }
3748 else 3908 else
3749 presence.ControllingClient.SendShutdownConnectionNotice(); 3909 presence.ControllingClient.SendShutdownConnectionNotice();
3910 presence.ControllingClient.Close(false);
3911 }
3912 else if (!childOnly)
3913 {
3914 presence.ControllingClient.Close(true);
3750 } 3915 }
3751
3752 presence.ControllingClient.Close();
3753 return true; 3916 return true;
3754 } 3917 }
3755 3918
@@ -4359,34 +4522,66 @@ namespace OpenSim.Region.Framework.Scenes
4359 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4522 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4360 } 4523 }
4361 4524
4362 public int GetHealth() 4525 public int GetHealth(out int flags, out string message)
4363 { 4526 {
4364 // Returns: 4527 // Returns:
4365 // 1 = sim is up and accepting http requests. The heartbeat has 4528 // 1 = sim is up and accepting http requests. The heartbeat has
4366 // stopped and the sim is probably locked up, but a remote 4529 // stopped and the sim is probably locked up, but a remote
4367 // admin restart may succeed 4530 // admin restart may succeed
4368 // 4531 //
4369 // 2 = Sim is up and the heartbeat is running. The sim is likely 4532 // 2 = Sim is up and the heartbeat is running. The sim is likely
4370 // usable for people within and logins _may_ work 4533 // usable for people within
4534 //
4535 // 3 = Sim is up and one packet thread is running. Sim is
4536 // unstable and will not accept new logins
4371 // 4537 //
4372 // 3 = We have seen a new user enter within the past 4 minutes 4538 // 4 = Sim is up and both packet threads are running. Sim is
4539 // likely usable
4540 //
4541 // 5 = We have seen a new user enter within the past 4 minutes
4373 // which can be seen as positive confirmation of sim health 4542 // which can be seen as positive confirmation of sim health
4374 // 4543 //
4544
4545 flags = 0;
4546 message = String.Empty;
4547
4548 CheckHeartbeat();
4549
4550 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4551 {
4552 // We're still starting
4553 // 0 means "in startup", it can't happen another way, since
4554 // to get here, we must be able to accept http connections
4555 return 0;
4556 }
4557
4375 int health=1; // Start at 1, means we're up 4558 int health=1; // Start at 1, means we're up
4376 4559
4377 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4560 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4561 {
4378 health+=1; 4562 health+=1;
4379 else 4563 flags |= 1;
4564 }
4565
4566 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4567 {
4568 health+=1;
4569 flags |= 2;
4570 }
4571
4572 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4573 {
4574 health+=1;
4575 flags |= 4;
4576 }
4577
4578 if (flags != 7)
4380 return health; 4579 return health;
4381 4580
4382 // A login in the last 4 mins? We can't be doing too badly 4581 // A login in the last 4 mins? We can't be doing too badly
4383 // 4582 //
4384 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4583 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4385 health++; 4584 health++;
4386 else
4387 return health;
4388
4389 CheckHeartbeat();
4390 4585
4391 return health; 4586 return health;
4392 } 4587 }
@@ -4579,7 +4774,7 @@ namespace OpenSim.Region.Framework.Scenes
4579 if (m_firstHeartbeat) 4774 if (m_firstHeartbeat)
4580 return; 4775 return;
4581 4776
4582 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4777 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000)
4583 StartTimer(); 4778 StartTimer();
4584 } 4779 }
4585 4780
@@ -4837,8 +5032,17 @@ namespace OpenSim.Region.Framework.Scenes
4837 { 5032 {
4838 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; 5033 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ;
4839 5034
5035 Vector3 vec = g.AbsolutePosition;
5036
4840 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); 5037 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
4841 5038
5039 ominX += vec.X;
5040 omaxX += vec.X;
5041 ominY += vec.Y;
5042 omaxY += vec.Y;
5043 ominZ += vec.Z;
5044 omaxZ += vec.Z;
5045
4842 if (minX > ominX) 5046 if (minX > ominX)
4843 minX = ominX; 5047 minX = ominX;
4844 if (minY > ominY) 5048 if (minY > ominY)
@@ -4908,10 +5112,28 @@ namespace OpenSim.Region.Framework.Scenes
4908 }); 5112 });
4909 } 5113 }
4910 5114
4911 foreach (SceneObjectGroup grp in objectsToDelete) 5115 if (objectsToDelete.Count > 0)
4912 { 5116 {
4913 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); 5117 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
4914 DeleteSceneObject(grp, true); 5118 foreach (SceneObjectGroup grp in objectsToDelete)
5119 {
5120 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5121 DeleteSceneObject(grp, true);
5122 }
5123 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5124 }
5125 }
5126
5127 public void ThreadAlive(int threadCode)
5128 {
5129 switch(threadCode)
5130 {
5131 case 1: // Incoming
5132 m_lastIncoming = Util.EnvironmentTickCount();
5133 break;
5134 case 2: // Incoming
5135 m_lastOutgoing = Util.EnvironmentTickCount();
5136 break;
4915 } 5137 }
4916 } 5138 }
4917 5139
@@ -4923,6 +5145,37 @@ namespace OpenSim.Region.Framework.Scenes
4923 // child agent creation, thereby emulating the SL behavior. 5145 // child agent creation, thereby emulating the SL behavior.
4924 public bool QueryAccess(UUID agentID, Vector3 position) 5146 public bool QueryAccess(UUID agentID, Vector3 position)
4925 { 5147 {
5148 string reason;
5149
5150 if (!AuthorizeUser(agentID, out reason))
5151 {
5152 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5153 return false;
5154 }
5155
5156 if (position == Vector3.Zero) // Teleport
5157 {
5158 float posX = 128.0f;
5159 float posY = 128.0f;
5160
5161 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5162 {
5163 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5164 return false;
5165 }
5166 }
5167 else // Walking
5168 {
5169 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5170 if (land == null)
5171 return false;
5172
5173 bool banned = land.IsBannedFromLand(agentID);
5174 bool restricted = land.IsRestrictedFromLand(agentID);
5175
5176 if (banned || restricted)
5177 return false;
5178 }
4926 return true; 5179 return true;
4927 } 5180 }
4928 } 5181 }