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.cs520
1 files changed, 392 insertions, 128 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 353b7c2..4eb5d64 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -93,6 +93,7 @@ namespace OpenSim.Region.Framework.Scenes
93 // TODO: need to figure out how allow client agents but deny 93 // TODO: need to figure out how allow client agents but deny
94 // root agents when ACL denies access to root agent 94 // root agents when ACL denies access to root agent
95 public bool m_strictAccessControl = true; 95 public bool m_strictAccessControl = true;
96 public bool m_seeIntoBannedRegion = false;
96 public int MaxUndoCount = 5; 97 public int MaxUndoCount = 5;
97 public bool LoginsDisabled = true; 98 public bool LoginsDisabled = true;
98 public bool LoadingPrims; 99 public bool LoadingPrims;
@@ -111,6 +112,7 @@ namespace OpenSim.Region.Framework.Scenes
111 protected ModuleLoader m_moduleLoader; 112 protected ModuleLoader m_moduleLoader;
112 protected AgentCircuitManager m_authenticateHandler; 113 protected AgentCircuitManager m_authenticateHandler;
113 protected SceneCommunicationService m_sceneGridService; 114 protected SceneCommunicationService m_sceneGridService;
115 protected ISnmpModule m_snmpService = null;
114 116
115 protected ISimulationDataService m_SimulationDataService; 117 protected ISimulationDataService m_SimulationDataService;
116 protected IEstateDataService m_EstateDataService; 118 protected IEstateDataService m_EstateDataService;
@@ -167,7 +169,7 @@ namespace OpenSim.Region.Framework.Scenes
167 private int m_update_events = 1; 169 private int m_update_events = 1;
168 private int m_update_backup = 200; 170 private int m_update_backup = 200;
169 private int m_update_terrain = 50; 171 private int m_update_terrain = 50;
170// private int m_update_land = 1; 172 private int m_update_land = 10;
171 private int m_update_coarse_locations = 50; 173 private int m_update_coarse_locations = 50;
172 174
173 private int frameMS; 175 private int frameMS;
@@ -181,6 +183,7 @@ namespace OpenSim.Region.Framework.Scenes
181 private int landMS; 183 private int landMS;
182 private int lastCompletedFrame; 184 private int lastCompletedFrame;
183 185
186 public bool CombineRegions = false;
184 private bool m_physics_enabled = true; 187 private bool m_physics_enabled = true;
185 private bool m_scripts_enabled = true; 188 private bool m_scripts_enabled = true;
186 private string m_defaultScriptEngine; 189 private string m_defaultScriptEngine;
@@ -189,6 +192,8 @@ namespace OpenSim.Region.Framework.Scenes
189 private volatile bool shuttingdown; 192 private volatile bool shuttingdown;
190 193
191 private int m_lastUpdate; 194 private int m_lastUpdate;
195 private int m_lastIncoming;
196 private int m_lastOutgoing;
192 private bool m_firstHeartbeat = true; 197 private bool m_firstHeartbeat = true;
193 198
194 private object m_deleting_scene_object = new object(); 199 private object m_deleting_scene_object = new object();
@@ -240,6 +245,19 @@ namespace OpenSim.Region.Framework.Scenes
240 get { return m_sceneGridService; } 245 get { return m_sceneGridService; }
241 } 246 }
242 247
248 public ISnmpModule SnmpService
249 {
250 get
251 {
252 if (m_snmpService == null)
253 {
254 m_snmpService = RequestModuleInterface<ISnmpModule>();
255 }
256
257 return m_snmpService;
258 }
259 }
260
243 public ISimulationDataService SimulationDataService 261 public ISimulationDataService SimulationDataService
244 { 262 {
245 get 263 get
@@ -563,7 +581,10 @@ namespace OpenSim.Region.Framework.Scenes
563 m_regInfo = regInfo; 581 m_regInfo = regInfo;
564 m_regionHandle = m_regInfo.RegionHandle; 582 m_regionHandle = m_regInfo.RegionHandle;
565 m_regionName = m_regInfo.RegionName; 583 m_regionName = m_regInfo.RegionName;
584 m_datastore = m_regInfo.DataStore;
566 m_lastUpdate = Util.EnvironmentTickCount(); 585 m_lastUpdate = Util.EnvironmentTickCount();
586 m_lastIncoming = 0;
587 m_lastOutgoing = 0;
567 588
568 m_physicalPrim = physicalPrim; 589 m_physicalPrim = physicalPrim;
569 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; 590 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
@@ -577,6 +598,8 @@ namespace OpenSim.Region.Framework.Scenes
577 #region Region Settings 598 #region Region Settings
578 599
579 // Load region settings 600 // Load region settings
601 m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID);
602
580 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); 603 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID);
581 if (estateDataService != null) 604 if (estateDataService != null)
582 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); 605 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
@@ -638,9 +661,10 @@ namespace OpenSim.Region.Framework.Scenes
638 //Animation states 661 //Animation states
639 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 662 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
640 // TODO: Change default to true once the feature is supported 663 // TODO: Change default to true once the feature is supported
641 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 664 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
642
643 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 665 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
666
667 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
644 if (RegionInfo.NonphysPrimMax > 0) 668 if (RegionInfo.NonphysPrimMax > 0)
645 { 669 {
646 m_maxNonphys = RegionInfo.NonphysPrimMax; 670 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -672,6 +696,7 @@ namespace OpenSim.Region.Framework.Scenes
672 m_persistAfter *= 10000000; 696 m_persistAfter *= 10000000;
673 697
674 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 698 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
699 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
675 700
676 IConfig packetConfig = m_config.Configs["PacketPool"]; 701 IConfig packetConfig = m_config.Configs["PacketPool"];
677 if (packetConfig != null) 702 if (packetConfig != null)
@@ -681,6 +706,8 @@ namespace OpenSim.Region.Framework.Scenes
681 } 706 }
682 707
683 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 708 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
709 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
710 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
684 711
685 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 712 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
686 if (m_generateMaptiles) 713 if (m_generateMaptiles)
@@ -705,9 +732,9 @@ namespace OpenSim.Region.Framework.Scenes
705 } 732 }
706 } 733 }
707 } 734 }
708 catch 735 catch (Exception e)
709 { 736 {
710 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 737 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
711 } 738 }
712 739
713 #endregion Region Config 740 #endregion Region Config
@@ -1078,7 +1105,9 @@ namespace OpenSim.Region.Framework.Scenes
1078 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1105 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1079 if (HeartbeatThread != null) 1106 if (HeartbeatThread != null)
1080 { 1107 {
1108 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1081 HeartbeatThread.Abort(); 1109 HeartbeatThread.Abort();
1110 Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId);
1082 HeartbeatThread = null; 1111 HeartbeatThread = null;
1083 } 1112 }
1084 m_lastUpdate = Util.EnvironmentTickCount(); 1113 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1202,9 +1231,6 @@ namespace OpenSim.Region.Framework.Scenes
1202 { 1231 {
1203 while (!shuttingdown) 1232 while (!shuttingdown)
1204 Update(); 1233 Update();
1205
1206 m_lastUpdate = Util.EnvironmentTickCount();
1207 m_firstHeartbeat = false;
1208 } 1234 }
1209 catch (ThreadAbortException) 1235 catch (ThreadAbortException)
1210 { 1236 {
@@ -1311,12 +1337,12 @@ namespace OpenSim.Region.Framework.Scenes
1311 terrainMS = Util.EnvironmentTickCountSubtract(terMS); 1337 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1312 } 1338 }
1313 1339
1314 //if (Frame % m_update_land == 0) 1340 if (Frame % m_update_land == 0)
1315 //{ 1341 {
1316 // int ldMS = Util.EnvironmentTickCount(); 1342 int ldMS = Util.EnvironmentTickCount();
1317 // UpdateLand(); 1343 UpdateLand();
1318 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1344 landMS = Util.EnvironmentTickCountSubtract(ldMS);
1319 //} 1345 }
1320 1346
1321 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); 1347 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1322 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1348 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
@@ -1382,12 +1408,16 @@ namespace OpenSim.Region.Framework.Scenes
1382 maintc = Util.EnvironmentTickCountSubtract(maintc); 1408 maintc = Util.EnvironmentTickCountSubtract(maintc);
1383 maintc = (int)(m_timespan * 1000) - maintc; 1409 maintc = (int)(m_timespan * 1000) - maintc;
1384 1410
1411
1412 m_lastUpdate = Util.EnvironmentTickCount();
1413 m_firstHeartbeat = false;
1414
1385 if (maintc > 0) 1415 if (maintc > 0)
1386 Thread.Sleep(maintc); 1416 Thread.Sleep(maintc);
1387 1417
1388 // Tell the watchdog that this thread is still alive 1418 // Tell the watchdog that this thread is still alive
1389 Watchdog.UpdateThread(); 1419 Watchdog.UpdateThread();
1390 } 1420 }
1391 1421
1392 public void AddGroupTarget(SceneObjectGroup grp) 1422 public void AddGroupTarget(SceneObjectGroup grp)
1393 { 1423 {
@@ -1403,9 +1433,9 @@ namespace OpenSim.Region.Framework.Scenes
1403 1433
1404 private void CheckAtTargets() 1434 private void CheckAtTargets()
1405 { 1435 {
1406 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1436 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1407 lock (m_groupsWithTargets) 1437 lock (m_groupsWithTargets)
1408 objs = m_groupsWithTargets.Values; 1438 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1409 1439
1410 foreach (SceneObjectGroup entry in objs) 1440 foreach (SceneObjectGroup entry in objs)
1411 entry.checkAtTargets(); 1441 entry.checkAtTargets();
@@ -1739,14 +1769,24 @@ namespace OpenSim.Region.Framework.Scenes
1739 /// <returns></returns> 1769 /// <returns></returns>
1740 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1770 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1741 { 1771 {
1772
1773 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1774 Vector3 wpos = Vector3.Zero;
1775 // Check for water surface intersection from above
1776 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1777 {
1778 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1779 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1780 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1781 wpos.Z = wheight;
1782 }
1783
1742 Vector3 pos = Vector3.Zero; 1784 Vector3 pos = Vector3.Zero;
1743 if (RayEndIsIntersection == (byte)1) 1785 if (RayEndIsIntersection == (byte)1)
1744 { 1786 {
1745 pos = RayEnd; 1787 pos = RayEnd;
1746 return pos;
1747 } 1788 }
1748 1789 else if (RayTargetID != UUID.Zero)
1749 if (RayTargetID != UUID.Zero)
1750 { 1790 {
1751 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1791 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1752 1792
@@ -1768,7 +1808,7 @@ namespace OpenSim.Region.Framework.Scenes
1768 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1808 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1769 1809
1770 // Un-comment out the following line to Get Raytrace results printed to the console. 1810 // Un-comment out the following line to Get Raytrace results printed to the console.
1771 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1811 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1772 float ScaleOffset = 0.5f; 1812 float ScaleOffset = 0.5f;
1773 1813
1774 // If we hit something 1814 // If we hit something
@@ -1791,13 +1831,10 @@ namespace OpenSim.Region.Framework.Scenes
1791 //pos.Z -= 0.25F; 1831 //pos.Z -= 0.25F;
1792 1832
1793 } 1833 }
1794
1795 return pos;
1796 } 1834 }
1797 else 1835 else
1798 { 1836 {
1799 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1837 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1800
1801 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1838 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1802 1839
1803 // Un-comment the following line to print the raytrace results to the console. 1840 // Un-comment the following line to print the raytrace results to the console.
@@ -1806,13 +1843,12 @@ namespace OpenSim.Region.Framework.Scenes
1806 if (ei.HitTF) 1843 if (ei.HitTF)
1807 { 1844 {
1808 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1845 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1809 } else 1846 }
1847 else
1810 { 1848 {
1811 // fall back to our stupid functionality 1849 // fall back to our stupid functionality
1812 pos = RayEnd; 1850 pos = RayEnd;
1813 } 1851 }
1814
1815 return pos;
1816 } 1852 }
1817 } 1853 }
1818 else 1854 else
@@ -1823,8 +1859,12 @@ namespace OpenSim.Region.Framework.Scenes
1823 //increase height so its above the ground. 1859 //increase height so its above the ground.
1824 //should be getting the normal of the ground at the rez point and using that? 1860 //should be getting the normal of the ground at the rez point and using that?
1825 pos.Z += scale.Z / 2f; 1861 pos.Z += scale.Z / 2f;
1826 return pos; 1862// return pos;
1827 } 1863 }
1864
1865 // check against posible water intercept
1866 if (wpos.Z > pos.Z) pos = wpos;
1867 return pos;
1828 } 1868 }
1829 1869
1830 1870
@@ -1904,7 +1944,10 @@ namespace OpenSim.Region.Framework.Scenes
1904 public bool AddRestoredSceneObject( 1944 public bool AddRestoredSceneObject(
1905 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1945 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1906 { 1946 {
1907 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1947 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1948 if (result)
1949 sceneObject.IsDeleted = false;
1950 return result;
1908 } 1951 }
1909 1952
1910 /// <summary> 1953 /// <summary>
@@ -1993,6 +2036,15 @@ namespace OpenSim.Region.Framework.Scenes
1993 /// </summary> 2036 /// </summary>
1994 public void DeleteAllSceneObjects() 2037 public void DeleteAllSceneObjects()
1995 { 2038 {
2039 DeleteAllSceneObjects(false);
2040 }
2041
2042 /// <summary>
2043 /// Delete every object from the scene. This does not include attachments worn by avatars.
2044 /// </summary>
2045 public void DeleteAllSceneObjects(bool exceptNoCopy)
2046 {
2047 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1996 lock (Entities) 2048 lock (Entities)
1997 { 2049 {
1998 EntityBase[] entities = Entities.GetEntities(); 2050 EntityBase[] entities = Entities.GetEntities();
@@ -2001,11 +2053,24 @@ namespace OpenSim.Region.Framework.Scenes
2001 if (e is SceneObjectGroup) 2053 if (e is SceneObjectGroup)
2002 { 2054 {
2003 SceneObjectGroup sog = (SceneObjectGroup)e; 2055 SceneObjectGroup sog = (SceneObjectGroup)e;
2004 if (!sog.IsAttachment) 2056 if (sog != null && !sog.IsAttachment)
2005 DeleteSceneObject((SceneObjectGroup)e, false); 2057 {
2058 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2059 {
2060 DeleteSceneObject((SceneObjectGroup)e, false);
2061 }
2062 else
2063 {
2064 toReturn.Add((SceneObjectGroup)e);
2065 }
2066 }
2006 } 2067 }
2007 } 2068 }
2008 } 2069 }
2070 if (toReturn.Count > 0)
2071 {
2072 returnObjects(toReturn.ToArray(), UUID.Zero);
2073 }
2009 } 2074 }
2010 2075
2011 /// <summary> 2076 /// <summary>
@@ -2054,6 +2119,8 @@ namespace OpenSim.Region.Framework.Scenes
2054 } 2119 }
2055 2120
2056 group.DeleteGroupFromScene(silent); 2121 group.DeleteGroupFromScene(silent);
2122 if (!silent)
2123 SendKillObject(new List<uint>() { group.LocalId });
2057 2124
2058// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2125// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2059 } 2126 }
@@ -2384,10 +2451,17 @@ namespace OpenSim.Region.Framework.Scenes
2384 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2451 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2385 public bool AddSceneObject(SceneObjectGroup sceneObject) 2452 public bool AddSceneObject(SceneObjectGroup sceneObject)
2386 { 2453 {
2454 if (sceneObject.OwnerID == UUID.Zero)
2455 {
2456 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2457 return false;
2458 }
2459
2387 // If the user is banned, we won't let any of their objects 2460 // If the user is banned, we won't let any of their objects
2388 // enter. Period. 2461 // enter. Period.
2389 // 2462 //
2390 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2463 int flags = GetUserFlags(sceneObject.OwnerID);
2464 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2391 { 2465 {
2392 m_log.Info("[INTERREGION]: Denied prim crossing for " + 2466 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2393 "banned avatar"); 2467 "banned avatar");
@@ -2431,15 +2505,28 @@ namespace OpenSim.Region.Framework.Scenes
2431 2505
2432 if (AttachmentsModule != null) 2506 if (AttachmentsModule != null)
2433 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2507 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2508
2509 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2434 } 2510 }
2435 else 2511 else
2436 { 2512 {
2513 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2437 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2514 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2438 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2515 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2439 } 2516 }
2517 if (sceneObject.OwnerID == UUID.Zero)
2518 {
2519 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2520 return false;
2521 }
2440 } 2522 }
2441 else 2523 else
2442 { 2524 {
2525 if (sceneObject.OwnerID == UUID.Zero)
2526 {
2527 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2528 return false;
2529 }
2443 AddRestoredSceneObject(sceneObject, true, false); 2530 AddRestoredSceneObject(sceneObject, true, false);
2444 2531
2445 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2532 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2478,6 +2565,24 @@ namespace OpenSim.Region.Framework.Scenes
2478 return 2; // StateSource.PrimCrossing 2565 return 2; // StateSource.PrimCrossing
2479 } 2566 }
2480 2567
2568 public int GetUserFlags(UUID user)
2569 {
2570 //Unfortunately the SP approach means that the value is cached until region is restarted
2571 /*
2572 ScenePresence sp;
2573 if (TryGetScenePresence(user, out sp))
2574 {
2575 return sp.UserFlags;
2576 }
2577 else
2578 {
2579 */
2580 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2581 if (uac == null)
2582 return 0;
2583 return uac.UserFlags;
2584 //}
2585 }
2481 #endregion 2586 #endregion
2482 2587
2483 #region Add/Remove Avatar Methods 2588 #region Add/Remove Avatar Methods
@@ -2498,6 +2603,7 @@ namespace OpenSim.Region.Framework.Scenes
2498 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2603 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2499 2604
2500 CheckHeartbeat(); 2605 CheckHeartbeat();
2606 ScenePresence presence;
2501 2607
2502 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here 2608 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
2503 { 2609 {
@@ -2521,12 +2627,19 @@ namespace OpenSim.Region.Framework.Scenes
2521 } 2627 }
2522 } 2628 }
2523 2629
2524 if (GetScenePresence(client.AgentId) != null) 2630 if (TryGetScenePresence(client.AgentId, out presence))
2525 { 2631 {
2526 m_LastLogin = Util.EnvironmentTickCount(); 2632 m_LastLogin = Util.EnvironmentTickCount();
2527 EventManager.TriggerOnNewClient(client); 2633 EventManager.TriggerOnNewClient(client);
2528 if (vialogin) 2634 if (vialogin)
2635 {
2529 EventManager.TriggerOnClientLogin(client); 2636 EventManager.TriggerOnClientLogin(client);
2637
2638 // Send initial parcel data
2639 Vector3 pos = presence.AbsolutePosition;
2640 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2641 land.SendLandUpdateToClient(presence.ControllingClient);
2642 }
2530 } 2643 }
2531 } 2644 }
2532 2645
@@ -2577,19 +2690,12 @@ namespace OpenSim.Region.Framework.Scenes
2577 // and the scene presence and the client, if they exist 2690 // and the scene presence and the client, if they exist
2578 try 2691 try
2579 { 2692 {
2580 // We need to wait for the client to make UDP contact first. 2693 ScenePresence sp = GetScenePresence(agentID);
2581 // It's the UDP contact that creates the scene presence 2694 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2582 ScenePresence sp = WaitGetScenePresence(agentID); 2695
2583 if (sp != null) 2696 if (sp != null)
2584 {
2585 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2586
2587 sp.ControllingClient.Close(); 2697 sp.ControllingClient.Close();
2588 } 2698
2589 else
2590 {
2591 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2592 }
2593 // BANG! SLASH! 2699 // BANG! SLASH!
2594 m_authenticateHandler.RemoveCircuit(agentID); 2700 m_authenticateHandler.RemoveCircuit(agentID);
2595 2701
@@ -2689,6 +2795,7 @@ namespace OpenSim.Region.Framework.Scenes
2689 client.OnFetchInventory += HandleFetchInventory; 2795 client.OnFetchInventory += HandleFetchInventory;
2690 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2796 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2691 client.OnCopyInventoryItem += CopyInventoryItem; 2797 client.OnCopyInventoryItem += CopyInventoryItem;
2798 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2692 client.OnMoveInventoryItem += MoveInventoryItem; 2799 client.OnMoveInventoryItem += MoveInventoryItem;
2693 client.OnRemoveInventoryItem += RemoveInventoryItem; 2800 client.OnRemoveInventoryItem += RemoveInventoryItem;
2694 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2801 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2867,15 +2974,16 @@ namespace OpenSim.Region.Framework.Scenes
2867 /// </summary> 2974 /// </summary>
2868 /// <param name="agentId">The avatar's Unique ID</param> 2975 /// <param name="agentId">The avatar's Unique ID</param>
2869 /// <param name="client">The IClientAPI for the client</param> 2976 /// <param name="client">The IClientAPI for the client</param>
2870 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2977 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2871 { 2978 {
2872 if (m_teleportModule != null) 2979 if (m_teleportModule != null)
2873 m_teleportModule.TeleportHome(agentId, client); 2980 return m_teleportModule.TeleportHome(agentId, client);
2874 else 2981 else
2875 { 2982 {
2876 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 2983 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2877 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 2984 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2878 } 2985 }
2986 return false;
2879 } 2987 }
2880 2988
2881 /// <summary> 2989 /// <summary>
@@ -2974,6 +3082,16 @@ namespace OpenSim.Region.Framework.Scenes
2974 /// <param name="flags"></param> 3082 /// <param name="flags"></param>
2975 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3083 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
2976 { 3084 {
3085 //Add half the avatar's height so that the user doesn't fall through prims
3086 ScenePresence presence;
3087 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3088 {
3089 if (presence.Appearance != null)
3090 {
3091 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3092 }
3093 }
3094
2977 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3095 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
2978 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3096 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
2979 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3097 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3050,7 +3168,9 @@ namespace OpenSim.Region.Framework.Scenes
3050 regions.Remove(RegionInfo.RegionHandle); 3168 regions.Remove(RegionInfo.RegionHandle);
3051 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3169 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3052 } 3170 }
3171 m_log.Debug("[Scene] Beginning ClientClosed");
3053 m_eventManager.TriggerClientClosed(agentID, this); 3172 m_eventManager.TriggerClientClosed(agentID, this);
3173 m_log.Debug("[Scene] Finished ClientClosed");
3054 } 3174 }
3055 catch (NullReferenceException) 3175 catch (NullReferenceException)
3056 { 3176 {
@@ -3058,7 +3178,12 @@ namespace OpenSim.Region.Framework.Scenes
3058 // Avatar is already disposed :/ 3178 // Avatar is already disposed :/
3059 } 3179 }
3060 3180
3181 m_log.Debug("[Scene] Beginning OnRemovePresence");
3061 m_eventManager.TriggerOnRemovePresence(agentID); 3182 m_eventManager.TriggerOnRemovePresence(agentID);
3183 m_log.Debug("[Scene] Finished OnRemovePresence");
3184
3185 if (avatar != null && (!avatar.IsChildAgent))
3186 avatar.SaveChangedAttachments();
3062 3187
3063 if (avatar != null && (!avatar.IsChildAgent)) 3188 if (avatar != null && (!avatar.IsChildAgent))
3064 avatar.SaveChangedAttachments(); 3189 avatar.SaveChangedAttachments();
@@ -3067,7 +3192,7 @@ namespace OpenSim.Region.Framework.Scenes
3067 delegate(IClientAPI client) 3192 delegate(IClientAPI client)
3068 { 3193 {
3069 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3194 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3070 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3195 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3071 catch (NullReferenceException) { } 3196 catch (NullReferenceException) { }
3072 }); 3197 });
3073 3198
@@ -3078,8 +3203,11 @@ namespace OpenSim.Region.Framework.Scenes
3078 } 3203 }
3079 3204
3080 // Remove the avatar from the scene 3205 // Remove the avatar from the scene
3206 m_log.Debug("[Scene] Begin RemoveScenePresence");
3081 m_sceneGraph.RemoveScenePresence(agentID); 3207 m_sceneGraph.RemoveScenePresence(agentID);
3208 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3082 m_clientManager.Remove(agentID); 3209 m_clientManager.Remove(agentID);
3210 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3083 3211
3084 try 3212 try
3085 { 3213 {
@@ -3093,9 +3221,10 @@ namespace OpenSim.Region.Framework.Scenes
3093 { 3221 {
3094 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3222 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3095 } 3223 }
3096 3224 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3097 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3225 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3098 CleanDroppedAttachments(); 3226 CleanDroppedAttachments();
3227 m_log.Debug("[Scene] The avatar has left the building");
3099 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3228 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3100 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3229 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3101 } 3230 }
@@ -3126,18 +3255,24 @@ namespace OpenSim.Region.Framework.Scenes
3126 3255
3127 #region Entities 3256 #region Entities
3128 3257
3129 public void SendKillObject(uint localID) 3258 public void SendKillObject(List<uint> localIDs)
3130 { 3259 {
3131 SceneObjectPart part = GetSceneObjectPart(localID); 3260 List<uint> deleteIDs = new List<uint>();
3132 if (part != null) // It is a prim 3261
3262 foreach (uint localID in localIDs)
3133 { 3263 {
3134 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3264 SceneObjectPart part = GetSceneObjectPart(localID);
3265 if (part != null) // It is a prim
3135 { 3266 {
3136 if (part.ParentGroup.RootPart != part) // Child part 3267 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3137 return; 3268 {
3269 if (part.ParentGroup.RootPart != part) // Child part
3270 continue;
3271 }
3138 } 3272 }
3273 deleteIDs.Add(localID);
3139 } 3274 }
3140 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3275 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3141 } 3276 }
3142 3277
3143 #endregion 3278 #endregion
@@ -3155,7 +3290,6 @@ namespace OpenSim.Region.Framework.Scenes
3155 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3290 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3156 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3291 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3157 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3292 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3158 m_sceneGridService.KiPrimitive += SendKillObject;
3159 m_sceneGridService.OnGetLandData += GetLandData; 3293 m_sceneGridService.OnGetLandData += GetLandData;
3160 } 3294 }
3161 3295
@@ -3164,7 +3298,6 @@ namespace OpenSim.Region.Framework.Scenes
3164 /// </summary> 3298 /// </summary>
3165 public void UnRegisterRegionWithComms() 3299 public void UnRegisterRegionWithComms()
3166 { 3300 {
3167 m_sceneGridService.KiPrimitive -= SendKillObject;
3168 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3301 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3169 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3302 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3170 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3303 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3244,13 +3377,16 @@ namespace OpenSim.Region.Framework.Scenes
3244 sp = null; 3377 sp = null;
3245 } 3378 }
3246 3379
3247 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3248 3380
3249 //On login test land permisions 3381 //On login test land permisions
3250 if (vialogin) 3382 if (vialogin)
3251 { 3383 {
3252 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3384 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3385 if (cache != null)
3386 cache.Remove(agent.firstname + " " + agent.lastname);
3387 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3253 { 3388 {
3389 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3254 return false; 3390 return false;
3255 } 3391 }
3256 } 3392 }
@@ -3273,8 +3409,13 @@ namespace OpenSim.Region.Framework.Scenes
3273 3409
3274 try 3410 try
3275 { 3411 {
3276 if (!AuthorizeUser(agent, out reason)) 3412 // Always check estate if this is a login. Always
3277 return false; 3413 // check if banned regions are to be blacked out.
3414 if (vialogin || (!m_seeIntoBannedRegion))
3415 {
3416 if (!AuthorizeUser(agent.AgentID, out reason))
3417 return false;
3418 }
3278 } 3419 }
3279 catch (Exception e) 3420 catch (Exception e)
3280 { 3421 {
@@ -3377,6 +3518,8 @@ namespace OpenSim.Region.Framework.Scenes
3377 } 3518 }
3378 } 3519 }
3379 // Honor parcel landing type and position. 3520 // Honor parcel landing type and position.
3521 /*
3522 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3380 if (land != null) 3523 if (land != null)
3381 { 3524 {
3382 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3525 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3384,26 +3527,34 @@ namespace OpenSim.Region.Framework.Scenes
3384 agent.startpos = land.LandData.UserLocation; 3527 agent.startpos = land.LandData.UserLocation;
3385 } 3528 }
3386 } 3529 }
3530 */// This is now handled properly in ScenePresence.MakeRootAgent
3387 } 3531 }
3388 3532
3389 return true; 3533 return true;
3390 } 3534 }
3391 3535
3392 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3536 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3393 { 3537 {
3394 3538 reason = String.Empty;
3395 bool banned = land.IsBannedFromLand(agent.AgentID); 3539 if (Permissions.IsGod(agentID))
3396 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3540 return true;
3541
3542 ILandObject land = LandChannel.GetLandObject(posX, posY);
3543 if (land == null)
3544 return false;
3545
3546 bool banned = land.IsBannedFromLand(agentID);
3547 bool restricted = land.IsRestrictedFromLand(agentID);
3397 3548
3398 if (banned || restricted) 3549 if (banned || restricted)
3399 { 3550 {
3400 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3551 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3401 if (nearestParcel != null) 3552 if (nearestParcel != null)
3402 { 3553 {
3403 //Move agent to nearest allowed 3554 //Move agent to nearest allowed
3404 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3555 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3405 agent.startpos.X = newPosition.X; 3556 posX = newPosition.X;
3406 agent.startpos.Y = newPosition.Y; 3557 posY = newPosition.Y;
3407 } 3558 }
3408 else 3559 else
3409 { 3560 {
@@ -3459,19 +3610,19 @@ namespace OpenSim.Region.Framework.Scenes
3459 /// <param name="reason">outputs the reason to this string</param> 3610 /// <param name="reason">outputs the reason to this string</param>
3460 /// <returns>True if the region accepts this agent. False if it does not. False will 3611 /// <returns>True if the region accepts this agent. False if it does not. False will
3461 /// also return a reason.</returns> 3612 /// also return a reason.</returns>
3462 protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) 3613 protected virtual bool AuthorizeUser(UUID agentID, out string reason)
3463 { 3614 {
3464 reason = String.Empty; 3615 reason = String.Empty;
3465 3616
3466 if (!m_strictAccessControl) return true; 3617 if (!m_strictAccessControl) return true;
3467 if (Permissions.IsGod(agent.AgentID)) return true; 3618 if (Permissions.IsGod(agentID)) return true;
3468 3619
3469 if (AuthorizationService != null) 3620 if (AuthorizationService != null)
3470 { 3621 {
3471 if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) 3622 if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason))
3472 { 3623 {
3473 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3624 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region",
3474 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3625 agentID, RegionInfo.RegionName);
3475 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); 3626 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName);
3476 return false; 3627 return false;
3477 } 3628 }
@@ -3479,10 +3630,26 @@ namespace OpenSim.Region.Framework.Scenes
3479 3630
3480 if (m_regInfo.EstateSettings != null) 3631 if (m_regInfo.EstateSettings != null)
3481 { 3632 {
3482 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3633 int flags = GetUserFlags(agentID);
3634 if (m_regInfo.EstateSettings.IsBanned(agentID, flags))
3483 { 3635 {
3484 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3636 //Add some more info to help users
3485 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3637 if (!m_regInfo.EstateSettings.IsBanned(agentID, 32))
3638 {
3639 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification",
3640 agentID, RegionInfo.RegionName);
3641 reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName);
3642 return false;
3643 }
3644 if (!m_regInfo.EstateSettings.IsBanned(agentID, 4))
3645 {
3646 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file",
3647 agentID, RegionInfo.RegionName);
3648 reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName);
3649 return false;
3650 }
3651 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist",
3652 agentID, RegionInfo.RegionName);
3486 reason = String.Format("Denied access to region {0}: You have been banned from that region.", 3653 reason = String.Format("Denied access to region {0}: You have been banned from that region.",
3487 RegionInfo.RegionName); 3654 RegionInfo.RegionName);
3488 return false; 3655 return false;
@@ -3499,7 +3666,7 @@ namespace OpenSim.Region.Framework.Scenes
3499 if (groupsModule != null) 3666 if (groupsModule != null)
3500 { 3667 {
3501 GroupMembershipData[] GroupMembership = 3668 GroupMembershipData[] GroupMembership =
3502 groupsModule.GetMembershipData(agent.AgentID); 3669 groupsModule.GetMembershipData(agentID);
3503 3670
3504 if (GroupMembership != null) 3671 if (GroupMembership != null)
3505 { 3672 {
@@ -3528,44 +3695,16 @@ namespace OpenSim.Region.Framework.Scenes
3528 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); 3695 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!");
3529 3696
3530 if (!m_regInfo.EstateSettings.PublicAccess && 3697 if (!m_regInfo.EstateSettings.PublicAccess &&
3531 !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && 3698 !m_regInfo.EstateSettings.HasAccess(agentID) &&
3532 !groupAccess) 3699 !groupAccess)
3533 { 3700 {
3534 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", 3701 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate",
3535 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3702 agentID, RegionInfo.RegionName);
3536 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", 3703 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3537 RegionInfo.RegionName); 3704 RegionInfo.RegionName);
3538 return false; 3705 return false;
3539 } 3706 }
3540 3707
3541 // TODO: estate/region settings are not properly hooked up
3542 // to ILandObject.isRestrictedFromLand()
3543 // if (null != LandChannel)
3544 // {
3545 // // region seems to have local Id of 1
3546 // ILandObject land = LandChannel.GetLandObject(1);
3547 // if (null != land)
3548 // {
3549 // if (land.isBannedFromLand(agent.AgentID))
3550 // {
3551 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land",
3552 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3553 // reason = String.Format("Denied access to private region {0}: You are banned from that region.",
3554 // RegionInfo.RegionName);
3555 // return false;
3556 // }
3557
3558 // if (land.isRestrictedFromLand(agent.AgentID))
3559 // {
3560 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3561 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3562 // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3563 // RegionInfo.RegionName);
3564 // return false;
3565 // }
3566 // }
3567 // }
3568
3569 return true; 3708 return true;
3570 } 3709 }
3571 3710
@@ -3669,6 +3808,13 @@ namespace OpenSim.Region.Framework.Scenes
3669 3808
3670 // We have to wait until the viewer contacts this region after receiving EAC. 3809 // We have to wait until the viewer contacts this region after receiving EAC.
3671 // That calls AddNewClient, which finally creates the ScenePresence 3810 // That calls AddNewClient, which finally creates the ScenePresence
3811 int flags = GetUserFlags(cAgentData.AgentID);
3812 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3813 {
3814 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3815 return false;
3816 }
3817
3672 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3818 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3673 if (nearestParcel == null) 3819 if (nearestParcel == null)
3674 { 3820 {
@@ -3676,6 +3822,14 @@ namespace OpenSim.Region.Framework.Scenes
3676 return false; 3822 return false;
3677 } 3823 }
3678 3824
3825 int num = m_sceneGraph.GetNumberOfScenePresences();
3826
3827 if (num >= RegionInfo.RegionSettings.AgentLimit)
3828 {
3829 if (!Permissions.IsAdministrator(cAgentData.AgentID))
3830 return false;
3831 }
3832
3679 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3833 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3680 3834
3681 if (childAgentUpdate != null) 3835 if (childAgentUpdate != null)
@@ -3742,12 +3896,22 @@ namespace OpenSim.Region.Framework.Scenes
3742 return false; 3896 return false;
3743 } 3897 }
3744 3898
3899 public bool IncomingCloseAgent(UUID agentID)
3900 {
3901 return IncomingCloseAgent(agentID, false);
3902 }
3903
3904 public bool IncomingCloseChildAgent(UUID agentID)
3905 {
3906 return IncomingCloseAgent(agentID, true);
3907 }
3908
3745 /// <summary> 3909 /// <summary>
3746 /// Tell a single agent to disconnect from the region. 3910 /// Tell a single agent to disconnect from the region.
3747 /// </summary> 3911 /// </summary>
3748 /// <param name="regionHandle"></param>
3749 /// <param name="agentID"></param> 3912 /// <param name="agentID"></param>
3750 public bool IncomingCloseAgent(UUID agentID) 3913 /// <param name="childOnly"></param>
3914 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3751 { 3915 {
3752 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3916 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3753 3917
@@ -3759,7 +3923,7 @@ namespace OpenSim.Region.Framework.Scenes
3759 { 3923 {
3760 m_sceneGraph.removeUserCount(false); 3924 m_sceneGraph.removeUserCount(false);
3761 } 3925 }
3762 else 3926 else if (!childOnly)
3763 { 3927 {
3764 m_sceneGraph.removeUserCount(true); 3928 m_sceneGraph.removeUserCount(true);
3765 } 3929 }
@@ -3775,9 +3939,12 @@ namespace OpenSim.Region.Framework.Scenes
3775 } 3939 }
3776 else 3940 else
3777 presence.ControllingClient.SendShutdownConnectionNotice(); 3941 presence.ControllingClient.SendShutdownConnectionNotice();
3942 presence.ControllingClient.Close(false);
3943 }
3944 else if (!childOnly)
3945 {
3946 presence.ControllingClient.Close(true);
3778 } 3947 }
3779
3780 presence.ControllingClient.Close();
3781 return true; 3948 return true;
3782 } 3949 }
3783 3950
@@ -4387,34 +4554,66 @@ namespace OpenSim.Region.Framework.Scenes
4387 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4554 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4388 } 4555 }
4389 4556
4390 public int GetHealth() 4557 public int GetHealth(out int flags, out string message)
4391 { 4558 {
4392 // Returns: 4559 // Returns:
4393 // 1 = sim is up and accepting http requests. The heartbeat has 4560 // 1 = sim is up and accepting http requests. The heartbeat has
4394 // stopped and the sim is probably locked up, but a remote 4561 // stopped and the sim is probably locked up, but a remote
4395 // admin restart may succeed 4562 // admin restart may succeed
4396 // 4563 //
4397 // 2 = Sim is up and the heartbeat is running. The sim is likely 4564 // 2 = Sim is up and the heartbeat is running. The sim is likely
4398 // usable for people within and logins _may_ work 4565 // usable for people within
4566 //
4567 // 3 = Sim is up and one packet thread is running. Sim is
4568 // unstable and will not accept new logins
4569 //
4570 // 4 = Sim is up and both packet threads are running. Sim is
4571 // likely usable
4399 // 4572 //
4400 // 3 = We have seen a new user enter within the past 4 minutes 4573 // 5 = We have seen a new user enter within the past 4 minutes
4401 // which can be seen as positive confirmation of sim health 4574 // which can be seen as positive confirmation of sim health
4402 // 4575 //
4576
4577 flags = 0;
4578 message = String.Empty;
4579
4580 CheckHeartbeat();
4581
4582 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4583 {
4584 // We're still starting
4585 // 0 means "in startup", it can't happen another way, since
4586 // to get here, we must be able to accept http connections
4587 return 0;
4588 }
4589
4403 int health=1; // Start at 1, means we're up 4590 int health=1; // Start at 1, means we're up
4404 4591
4405 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4592 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4593 {
4406 health+=1; 4594 health+=1;
4407 else 4595 flags |= 1;
4596 }
4597
4598 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4599 {
4600 health+=1;
4601 flags |= 2;
4602 }
4603
4604 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4605 {
4606 health+=1;
4607 flags |= 4;
4608 }
4609
4610 if (flags != 7)
4408 return health; 4611 return health;
4409 4612
4410 // A login in the last 4 mins? We can't be doing too badly 4613 // A login in the last 4 mins? We can't be doing too badly
4411 // 4614 //
4412 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4615 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4413 health++; 4616 health++;
4414 else
4415 return health;
4416
4417 CheckHeartbeat();
4418 4617
4419 return health; 4618 return health;
4420 } 4619 }
@@ -4607,7 +4806,7 @@ namespace OpenSim.Region.Framework.Scenes
4607 if (m_firstHeartbeat) 4806 if (m_firstHeartbeat)
4608 return; 4807 return;
4609 4808
4610 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4809 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000)
4611 StartTimer(); 4810 StartTimer();
4612 } 4811 }
4613 4812
@@ -4865,8 +5064,17 @@ namespace OpenSim.Region.Framework.Scenes
4865 { 5064 {
4866 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; 5065 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ;
4867 5066
5067 Vector3 vec = g.AbsolutePosition;
5068
4868 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); 5069 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
4869 5070
5071 ominX += vec.X;
5072 omaxX += vec.X;
5073 ominY += vec.Y;
5074 omaxY += vec.Y;
5075 ominZ += vec.Z;
5076 omaxZ += vec.Z;
5077
4870 if (minX > ominX) 5078 if (minX > ominX)
4871 minX = ominX; 5079 minX = ominX;
4872 if (minY > ominY) 5080 if (minY > ominY)
@@ -4936,10 +5144,28 @@ namespace OpenSim.Region.Framework.Scenes
4936 }); 5144 });
4937 } 5145 }
4938 5146
4939 foreach (SceneObjectGroup grp in objectsToDelete) 5147 if (objectsToDelete.Count > 0)
4940 { 5148 {
4941 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); 5149 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
4942 DeleteSceneObject(grp, true); 5150 foreach (SceneObjectGroup grp in objectsToDelete)
5151 {
5152 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5153 DeleteSceneObject(grp, true);
5154 }
5155 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5156 }
5157 }
5158
5159 public void ThreadAlive(int threadCode)
5160 {
5161 switch(threadCode)
5162 {
5163 case 1: // Incoming
5164 m_lastIncoming = Util.EnvironmentTickCount();
5165 break;
5166 case 2: // Incoming
5167 m_lastOutgoing = Util.EnvironmentTickCount();
5168 break;
4943 } 5169 }
4944 } 5170 }
4945 5171
@@ -4951,6 +5177,44 @@ namespace OpenSim.Region.Framework.Scenes
4951 // child agent creation, thereby emulating the SL behavior. 5177 // child agent creation, thereby emulating the SL behavior.
4952 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5178 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
4953 { 5179 {
5180 reason = "You are banned from the region";
5181
5182 if (Permissions.IsGod(agentID))
5183 {
5184 reason = String.Empty;
5185 return true;
5186 }
5187
5188 if (!AuthorizeUser(agentID, out reason))
5189 {
5190 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5191 return false;
5192 }
5193
5194 if (position == Vector3.Zero) // Teleport
5195 {
5196 float posX = 128.0f;
5197 float posY = 128.0f;
5198
5199 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5200 {
5201 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5202 return false;
5203 }
5204 }
5205 else // Walking
5206 {
5207 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5208 if (land == null)
5209 return false;
5210
5211 bool banned = land.IsBannedFromLand(agentID);
5212 bool restricted = land.IsRestrictedFromLand(agentID);
5213
5214 if (banned || restricted)
5215 return false;
5216 }
5217
4954 reason = String.Empty; 5218 reason = String.Empty;
4955 return true; 5219 return true;
4956 } 5220 }