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.cs504
1 files changed, 375 insertions, 129 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 49fbe33..0d7894f 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
@@ -1080,7 +1107,9 @@ namespace OpenSim.Region.Framework.Scenes
1080 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1107 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1081 if (HeartbeatThread != null) 1108 if (HeartbeatThread != null)
1082 { 1109 {
1110 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1083 HeartbeatThread.Abort(); 1111 HeartbeatThread.Abort();
1112 Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId);
1084 HeartbeatThread = null; 1113 HeartbeatThread = null;
1085 } 1114 }
1086 m_lastUpdate = Util.EnvironmentTickCount(); 1115 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1204,9 +1233,6 @@ namespace OpenSim.Region.Framework.Scenes
1204 { 1233 {
1205 while (!shuttingdown) 1234 while (!shuttingdown)
1206 Update(); 1235 Update();
1207
1208 m_lastUpdate = Util.EnvironmentTickCount();
1209 m_firstHeartbeat = false;
1210 } 1236 }
1211 catch (ThreadAbortException) 1237 catch (ThreadAbortException)
1212 { 1238 {
@@ -1312,12 +1338,12 @@ namespace OpenSim.Region.Framework.Scenes
1312 terrainMS = Util.EnvironmentTickCountSubtract(terMS); 1338 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1313 } 1339 }
1314 1340
1315 //if (Frame % m_update_land == 0) 1341 // if (Frame % m_update_land == 0)
1316 //{ 1342 // {
1317 // int ldMS = Util.EnvironmentTickCount(); 1343 // int ldMS = Util.EnvironmentTickCount();
1318 // UpdateLand(); 1344 // UpdateLand();
1319 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1345 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1320 //} 1346 // }
1321 1347
1322 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); 1348 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1323 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1349 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
@@ -1383,12 +1409,16 @@ namespace OpenSim.Region.Framework.Scenes
1383 maintc = Util.EnvironmentTickCountSubtract(maintc); 1409 maintc = Util.EnvironmentTickCountSubtract(maintc);
1384 maintc = (int)(m_timespan * 1000) - maintc; 1410 maintc = (int)(m_timespan * 1000) - maintc;
1385 1411
1412
1413 m_lastUpdate = Util.EnvironmentTickCount();
1414 m_firstHeartbeat = false;
1415
1386 if (maintc > 0) 1416 if (maintc > 0)
1387 Thread.Sleep(maintc); 1417 Thread.Sleep(maintc);
1388 1418
1389 // Tell the watchdog that this thread is still alive 1419 // Tell the watchdog that this thread is still alive
1390 Watchdog.UpdateThread(); 1420 Watchdog.UpdateThread();
1391 } 1421 }
1392 1422
1393 public void AddGroupTarget(SceneObjectGroup grp) 1423 public void AddGroupTarget(SceneObjectGroup grp)
1394 { 1424 {
@@ -1404,9 +1434,9 @@ namespace OpenSim.Region.Framework.Scenes
1404 1434
1405 private void CheckAtTargets() 1435 private void CheckAtTargets()
1406 { 1436 {
1407 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1437 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1408 lock (m_groupsWithTargets) 1438 lock (m_groupsWithTargets)
1409 objs = m_groupsWithTargets.Values; 1439 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1410 1440
1411 foreach (SceneObjectGroup entry in objs) 1441 foreach (SceneObjectGroup entry in objs)
1412 entry.checkAtTargets(); 1442 entry.checkAtTargets();
@@ -1729,14 +1759,24 @@ namespace OpenSim.Region.Framework.Scenes
1729 /// <returns></returns> 1759 /// <returns></returns>
1730 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1760 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1731 { 1761 {
1762
1763 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1764 Vector3 wpos = Vector3.Zero;
1765 // Check for water surface intersection from above
1766 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1767 {
1768 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1769 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1770 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1771 wpos.Z = wheight;
1772 }
1773
1732 Vector3 pos = Vector3.Zero; 1774 Vector3 pos = Vector3.Zero;
1733 if (RayEndIsIntersection == (byte)1) 1775 if (RayEndIsIntersection == (byte)1)
1734 { 1776 {
1735 pos = RayEnd; 1777 pos = RayEnd;
1736 return pos;
1737 } 1778 }
1738 1779 else if (RayTargetID != UUID.Zero)
1739 if (RayTargetID != UUID.Zero)
1740 { 1780 {
1741 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1781 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1742 1782
@@ -1758,7 +1798,7 @@ namespace OpenSim.Region.Framework.Scenes
1758 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1798 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1759 1799
1760 // Un-comment out the following line to Get Raytrace results printed to the console. 1800 // Un-comment out the following line to Get Raytrace results printed to the console.
1761 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1801 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1762 float ScaleOffset = 0.5f; 1802 float ScaleOffset = 0.5f;
1763 1803
1764 // If we hit something 1804 // If we hit something
@@ -1781,13 +1821,10 @@ namespace OpenSim.Region.Framework.Scenes
1781 //pos.Z -= 0.25F; 1821 //pos.Z -= 0.25F;
1782 1822
1783 } 1823 }
1784
1785 return pos;
1786 } 1824 }
1787 else 1825 else
1788 { 1826 {
1789 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1827 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1790
1791 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1828 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1792 1829
1793 // Un-comment the following line to print the raytrace results to the console. 1830 // Un-comment the following line to print the raytrace results to the console.
@@ -1796,13 +1833,12 @@ namespace OpenSim.Region.Framework.Scenes
1796 if (ei.HitTF) 1833 if (ei.HitTF)
1797 { 1834 {
1798 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1835 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1799 } else 1836 }
1837 else
1800 { 1838 {
1801 // fall back to our stupid functionality 1839 // fall back to our stupid functionality
1802 pos = RayEnd; 1840 pos = RayEnd;
1803 } 1841 }
1804
1805 return pos;
1806 } 1842 }
1807 } 1843 }
1808 else 1844 else
@@ -1813,8 +1849,12 @@ namespace OpenSim.Region.Framework.Scenes
1813 //increase height so its above the ground. 1849 //increase height so its above the ground.
1814 //should be getting the normal of the ground at the rez point and using that? 1850 //should be getting the normal of the ground at the rez point and using that?
1815 pos.Z += scale.Z / 2f; 1851 pos.Z += scale.Z / 2f;
1816 return pos; 1852// return pos;
1817 } 1853 }
1854
1855 // check against posible water intercept
1856 if (wpos.Z > pos.Z) pos = wpos;
1857 return pos;
1818 } 1858 }
1819 1859
1820 1860
@@ -1894,7 +1934,10 @@ namespace OpenSim.Region.Framework.Scenes
1894 public bool AddRestoredSceneObject( 1934 public bool AddRestoredSceneObject(
1895 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1935 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1896 { 1936 {
1897 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1937 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1938 if (result)
1939 sceneObject.IsDeleted = false;
1940 return result;
1898 } 1941 }
1899 1942
1900 /// <summary> 1943 /// <summary>
@@ -1983,6 +2026,15 @@ namespace OpenSim.Region.Framework.Scenes
1983 /// </summary> 2026 /// </summary>
1984 public void DeleteAllSceneObjects() 2027 public void DeleteAllSceneObjects()
1985 { 2028 {
2029 DeleteAllSceneObjects(false);
2030 }
2031
2032 /// <summary>
2033 /// Delete every object from the scene. This does not include attachments worn by avatars.
2034 /// </summary>
2035 public void DeleteAllSceneObjects(bool exceptNoCopy)
2036 {
2037 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1986 lock (Entities) 2038 lock (Entities)
1987 { 2039 {
1988 EntityBase[] entities = Entities.GetEntities(); 2040 EntityBase[] entities = Entities.GetEntities();
@@ -1991,11 +2043,24 @@ namespace OpenSim.Region.Framework.Scenes
1991 if (e is SceneObjectGroup) 2043 if (e is SceneObjectGroup)
1992 { 2044 {
1993 SceneObjectGroup sog = (SceneObjectGroup)e; 2045 SceneObjectGroup sog = (SceneObjectGroup)e;
1994 if (!sog.IsAttachment) 2046 if (sog != null && !sog.IsAttachment)
1995 DeleteSceneObject((SceneObjectGroup)e, false); 2047 {
2048 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2049 {
2050 DeleteSceneObject((SceneObjectGroup)e, false);
2051 }
2052 else
2053 {
2054 toReturn.Add((SceneObjectGroup)e);
2055 }
2056 }
1996 } 2057 }
1997 } 2058 }
1998 } 2059 }
2060 if (toReturn.Count > 0)
2061 {
2062 returnObjects(toReturn.ToArray(), UUID.Zero);
2063 }
1999 } 2064 }
2000 2065
2001 /// <summary> 2066 /// <summary>
@@ -2044,6 +2109,8 @@ namespace OpenSim.Region.Framework.Scenes
2044 } 2109 }
2045 2110
2046 group.DeleteGroupFromScene(silent); 2111 group.DeleteGroupFromScene(silent);
2112 if (!silent)
2113 SendKillObject(new List<uint>() { group.LocalId });
2047 2114
2048// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2115// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2049 } 2116 }
@@ -2396,10 +2463,17 @@ namespace OpenSim.Region.Framework.Scenes
2396 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2463 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2397 public bool AddSceneObject(SceneObjectGroup sceneObject) 2464 public bool AddSceneObject(SceneObjectGroup sceneObject)
2398 { 2465 {
2466 if (sceneObject.OwnerID == UUID.Zero)
2467 {
2468 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2469 return false;
2470 }
2471
2399 // If the user is banned, we won't let any of their objects 2472 // If the user is banned, we won't let any of their objects
2400 // enter. Period. 2473 // enter. Period.
2401 // 2474 //
2402 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2475 int flags = GetUserFlags(sceneObject.OwnerID);
2476 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2403 { 2477 {
2404 m_log.Info("[INTERREGION]: Denied prim crossing for " + 2478 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2405 "banned avatar"); 2479 "banned avatar");
@@ -2443,15 +2517,28 @@ namespace OpenSim.Region.Framework.Scenes
2443 2517
2444 if (AttachmentsModule != null) 2518 if (AttachmentsModule != null)
2445 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2519 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2520
2521 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2446 } 2522 }
2447 else 2523 else
2448 { 2524 {
2525 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2449 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2526 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2450 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2527 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2451 } 2528 }
2529 if (sceneObject.OwnerID == UUID.Zero)
2530 {
2531 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2532 return false;
2533 }
2452 } 2534 }
2453 else 2535 else
2454 { 2536 {
2537 if (sceneObject.OwnerID == UUID.Zero)
2538 {
2539 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2540 return false;
2541 }
2455 AddRestoredSceneObject(sceneObject, true, false); 2542 AddRestoredSceneObject(sceneObject, true, false);
2456 2543
2457 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2544 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2481,6 +2568,24 @@ namespace OpenSim.Region.Framework.Scenes
2481 return 2; // StateSource.PrimCrossing 2568 return 2; // StateSource.PrimCrossing
2482 } 2569 }
2483 2570
2571 public int GetUserFlags(UUID user)
2572 {
2573 //Unfortunately the SP approach means that the value is cached until region is restarted
2574 /*
2575 ScenePresence sp;
2576 if (TryGetScenePresence(user, out sp))
2577 {
2578 return sp.UserFlags;
2579 }
2580 else
2581 {
2582 */
2583 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2584 if (uac == null)
2585 return 0;
2586 return uac.UserFlags;
2587 //}
2588 }
2484 #endregion 2589 #endregion
2485 2590
2486 #region Add/Remove Avatar Methods 2591 #region Add/Remove Avatar Methods
@@ -2501,6 +2606,7 @@ namespace OpenSim.Region.Framework.Scenes
2501 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2606 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2502 2607
2503 CheckHeartbeat(); 2608 CheckHeartbeat();
2609 ScenePresence presence;
2504 2610
2505 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here 2611 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
2506 { 2612 {
@@ -2524,12 +2630,19 @@ namespace OpenSim.Region.Framework.Scenes
2524 } 2630 }
2525 } 2631 }
2526 2632
2527 if (GetScenePresence(client.AgentId) != null) 2633 if (TryGetScenePresence(client.AgentId, out presence))
2528 { 2634 {
2529 m_LastLogin = Util.EnvironmentTickCount(); 2635 m_LastLogin = Util.EnvironmentTickCount();
2530 EventManager.TriggerOnNewClient(client); 2636 EventManager.TriggerOnNewClient(client);
2531 if (vialogin) 2637 if (vialogin)
2638 {
2532 EventManager.TriggerOnClientLogin(client); 2639 EventManager.TriggerOnClientLogin(client);
2640
2641 // Send initial parcel data
2642 Vector3 pos = presence.AbsolutePosition;
2643 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2644 land.SendLandUpdateToClient(presence.ControllingClient);
2645 }
2533 } 2646 }
2534 } 2647 }
2535 2648
@@ -2580,19 +2693,12 @@ namespace OpenSim.Region.Framework.Scenes
2580 // and the scene presence and the client, if they exist 2693 // and the scene presence and the client, if they exist
2581 try 2694 try
2582 { 2695 {
2583 // We need to wait for the client to make UDP contact first. 2696 ScenePresence sp = GetScenePresence(agentID);
2584 // It's the UDP contact that creates the scene presence 2697 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2585 ScenePresence sp = WaitGetScenePresence(agentID); 2698
2586 if (sp != null) 2699 if (sp != null)
2587 {
2588 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2589
2590 sp.ControllingClient.Close(); 2700 sp.ControllingClient.Close();
2591 } 2701
2592 else
2593 {
2594 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2595 }
2596 // BANG! SLASH! 2702 // BANG! SLASH!
2597 m_authenticateHandler.RemoveCircuit(agentID); 2703 m_authenticateHandler.RemoveCircuit(agentID);
2598 2704
@@ -2692,6 +2798,7 @@ namespace OpenSim.Region.Framework.Scenes
2692 client.OnFetchInventory += HandleFetchInventory; 2798 client.OnFetchInventory += HandleFetchInventory;
2693 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2799 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2694 client.OnCopyInventoryItem += CopyInventoryItem; 2800 client.OnCopyInventoryItem += CopyInventoryItem;
2801 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2695 client.OnMoveInventoryItem += MoveInventoryItem; 2802 client.OnMoveInventoryItem += MoveInventoryItem;
2696 client.OnRemoveInventoryItem += RemoveInventoryItem; 2803 client.OnRemoveInventoryItem += RemoveInventoryItem;
2697 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2804 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2870,15 +2977,16 @@ namespace OpenSim.Region.Framework.Scenes
2870 /// </summary> 2977 /// </summary>
2871 /// <param name="agentId">The avatar's Unique ID</param> 2978 /// <param name="agentId">The avatar's Unique ID</param>
2872 /// <param name="client">The IClientAPI for the client</param> 2979 /// <param name="client">The IClientAPI for the client</param>
2873 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2980 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2874 { 2981 {
2875 if (m_teleportModule != null) 2982 if (m_teleportModule != null)
2876 m_teleportModule.TeleportHome(agentId, client); 2983 return m_teleportModule.TeleportHome(agentId, client);
2877 else 2984 else
2878 { 2985 {
2879 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 2986 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2880 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 2987 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2881 } 2988 }
2989 return false;
2882 } 2990 }
2883 2991
2884 /// <summary> 2992 /// <summary>
@@ -2977,6 +3085,16 @@ namespace OpenSim.Region.Framework.Scenes
2977 /// <param name="flags"></param> 3085 /// <param name="flags"></param>
2978 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3086 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
2979 { 3087 {
3088 //Add half the avatar's height so that the user doesn't fall through prims
3089 ScenePresence presence;
3090 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3091 {
3092 if (presence.Appearance != null)
3093 {
3094 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3095 }
3096 }
3097
2980 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3098 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
2981 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3099 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
2982 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3100 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3053,7 +3171,9 @@ namespace OpenSim.Region.Framework.Scenes
3053 regions.Remove(RegionInfo.RegionHandle); 3171 regions.Remove(RegionInfo.RegionHandle);
3054 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3172 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3055 } 3173 }
3174 m_log.Debug("[Scene] Beginning ClientClosed");
3056 m_eventManager.TriggerClientClosed(agentID, this); 3175 m_eventManager.TriggerClientClosed(agentID, this);
3176 m_log.Debug("[Scene] Finished ClientClosed");
3057 } 3177 }
3058 catch (NullReferenceException) 3178 catch (NullReferenceException)
3059 { 3179 {
@@ -3061,7 +3181,12 @@ namespace OpenSim.Region.Framework.Scenes
3061 // Avatar is already disposed :/ 3181 // Avatar is already disposed :/
3062 } 3182 }
3063 3183
3184 m_log.Debug("[Scene] Beginning OnRemovePresence");
3064 m_eventManager.TriggerOnRemovePresence(agentID); 3185 m_eventManager.TriggerOnRemovePresence(agentID);
3186 m_log.Debug("[Scene] Finished OnRemovePresence");
3187
3188 if (avatar != null && (!avatar.IsChildAgent))
3189 avatar.SaveChangedAttachments();
3065 3190
3066 if (avatar != null && (!avatar.IsChildAgent)) 3191 if (avatar != null && (!avatar.IsChildAgent))
3067 avatar.SaveChangedAttachments(); 3192 avatar.SaveChangedAttachments();
@@ -3070,7 +3195,7 @@ namespace OpenSim.Region.Framework.Scenes
3070 delegate(IClientAPI client) 3195 delegate(IClientAPI client)
3071 { 3196 {
3072 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3197 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3073 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3198 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3074 catch (NullReferenceException) { } 3199 catch (NullReferenceException) { }
3075 }); 3200 });
3076 3201
@@ -3081,8 +3206,11 @@ namespace OpenSim.Region.Framework.Scenes
3081 } 3206 }
3082 3207
3083 // Remove the avatar from the scene 3208 // Remove the avatar from the scene
3209 m_log.Debug("[Scene] Begin RemoveScenePresence");
3084 m_sceneGraph.RemoveScenePresence(agentID); 3210 m_sceneGraph.RemoveScenePresence(agentID);
3211 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3085 m_clientManager.Remove(agentID); 3212 m_clientManager.Remove(agentID);
3213 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3086 3214
3087 try 3215 try
3088 { 3216 {
@@ -3096,9 +3224,10 @@ namespace OpenSim.Region.Framework.Scenes
3096 { 3224 {
3097 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3225 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3098 } 3226 }
3099 3227 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3100 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3228 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3101 CleanDroppedAttachments(); 3229 CleanDroppedAttachments();
3230 m_log.Debug("[Scene] The avatar has left the building");
3102 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3231 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3103 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3232 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3104 } 3233 }
@@ -3129,18 +3258,24 @@ namespace OpenSim.Region.Framework.Scenes
3129 3258
3130 #region Entities 3259 #region Entities
3131 3260
3132 public void SendKillObject(uint localID) 3261 public void SendKillObject(List<uint> localIDs)
3133 { 3262 {
3134 SceneObjectPart part = GetSceneObjectPart(localID); 3263 List<uint> deleteIDs = new List<uint>();
3135 if (part != null) // It is a prim 3264
3265 foreach (uint localID in localIDs)
3136 { 3266 {
3137 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3267 SceneObjectPart part = GetSceneObjectPart(localID);
3268 if (part != null) // It is a prim
3138 { 3269 {
3139 if (part.ParentGroup.RootPart != part) // Child part 3270 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3140 return; 3271 {
3272 if (part.ParentGroup.RootPart != part) // Child part
3273 continue;
3274 }
3141 } 3275 }
3276 deleteIDs.Add(localID);
3142 } 3277 }
3143 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3278 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3144 } 3279 }
3145 3280
3146 #endregion 3281 #endregion
@@ -3158,7 +3293,6 @@ namespace OpenSim.Region.Framework.Scenes
3158 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3293 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3159 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3294 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3160 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3295 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3161 m_sceneGridService.KiPrimitive += SendKillObject;
3162 m_sceneGridService.OnGetLandData += GetLandData; 3296 m_sceneGridService.OnGetLandData += GetLandData;
3163 } 3297 }
3164 3298
@@ -3167,7 +3301,6 @@ namespace OpenSim.Region.Framework.Scenes
3167 /// </summary> 3301 /// </summary>
3168 public void UnRegisterRegionWithComms() 3302 public void UnRegisterRegionWithComms()
3169 { 3303 {
3170 m_sceneGridService.KiPrimitive -= SendKillObject;
3171 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3304 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3172 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3305 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3173 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3306 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3247,13 +3380,16 @@ namespace OpenSim.Region.Framework.Scenes
3247 sp = null; 3380 sp = null;
3248 } 3381 }
3249 3382
3250 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3251 3383
3252 //On login test land permisions 3384 //On login test land permisions
3253 if (vialogin) 3385 if (vialogin)
3254 { 3386 {
3255 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3387 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3388 if (cache != null)
3389 cache.Remove(agent.firstname + " " + agent.lastname);
3390 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3256 { 3391 {
3392 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3257 return false; 3393 return false;
3258 } 3394 }
3259 } 3395 }
@@ -3276,8 +3412,13 @@ namespace OpenSim.Region.Framework.Scenes
3276 3412
3277 try 3413 try
3278 { 3414 {
3279 if (!AuthorizeUser(agent, out reason)) 3415 // Always check estate if this is a login. Always
3280 return false; 3416 // check if banned regions are to be blacked out.
3417 if (vialogin || (!m_seeIntoBannedRegion))
3418 {
3419 if (!AuthorizeUser(agent.AgentID, out reason))
3420 return false;
3421 }
3281 } 3422 }
3282 catch (Exception e) 3423 catch (Exception e)
3283 { 3424 {
@@ -3380,6 +3521,8 @@ namespace OpenSim.Region.Framework.Scenes
3380 } 3521 }
3381 } 3522 }
3382 // Honor parcel landing type and position. 3523 // Honor parcel landing type and position.
3524 /*
3525 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3383 if (land != null) 3526 if (land != null)
3384 { 3527 {
3385 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3528 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3387,26 +3530,34 @@ namespace OpenSim.Region.Framework.Scenes
3387 agent.startpos = land.LandData.UserLocation; 3530 agent.startpos = land.LandData.UserLocation;
3388 } 3531 }
3389 } 3532 }
3533 */// This is now handled properly in ScenePresence.MakeRootAgent
3390 } 3534 }
3391 3535
3392 return true; 3536 return true;
3393 } 3537 }
3394 3538
3395 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3539 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3396 { 3540 {
3397 3541 reason = String.Empty;
3398 bool banned = land.IsBannedFromLand(agent.AgentID); 3542 if (Permissions.IsGod(agentID))
3399 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3543 return true;
3544
3545 ILandObject land = LandChannel.GetLandObject(posX, posY);
3546 if (land == null)
3547 return false;
3548
3549 bool banned = land.IsBannedFromLand(agentID);
3550 bool restricted = land.IsRestrictedFromLand(agentID);
3400 3551
3401 if (banned || restricted) 3552 if (banned || restricted)
3402 { 3553 {
3403 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3554 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3404 if (nearestParcel != null) 3555 if (nearestParcel != null)
3405 { 3556 {
3406 //Move agent to nearest allowed 3557 //Move agent to nearest allowed
3407 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3558 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3408 agent.startpos.X = newPosition.X; 3559 posX = newPosition.X;
3409 agent.startpos.Y = newPosition.Y; 3560 posY = newPosition.Y;
3410 } 3561 }
3411 else 3562 else
3412 { 3563 {
@@ -3462,19 +3613,19 @@ namespace OpenSim.Region.Framework.Scenes
3462 /// <param name="reason">outputs the reason to this string</param> 3613 /// <param name="reason">outputs the reason to this string</param>
3463 /// <returns>True if the region accepts this agent. False if it does not. False will 3614 /// <returns>True if the region accepts this agent. False if it does not. False will
3464 /// also return a reason.</returns> 3615 /// also return a reason.</returns>
3465 protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) 3616 protected virtual bool AuthorizeUser(UUID agentID, out string reason)
3466 { 3617 {
3467 reason = String.Empty; 3618 reason = String.Empty;
3468 3619
3469 if (!m_strictAccessControl) return true; 3620 if (!m_strictAccessControl) return true;
3470 if (Permissions.IsGod(agent.AgentID)) return true; 3621 if (Permissions.IsGod(agentID)) return true;
3471 3622
3472 if (AuthorizationService != null) 3623 if (AuthorizationService != null)
3473 { 3624 {
3474 if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) 3625 if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason))
3475 { 3626 {
3476 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3627 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region",
3477 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3628 agentID, RegionInfo.RegionName);
3478 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); 3629 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName);
3479 return false; 3630 return false;
3480 } 3631 }
@@ -3482,10 +3633,26 @@ namespace OpenSim.Region.Framework.Scenes
3482 3633
3483 if (m_regInfo.EstateSettings != null) 3634 if (m_regInfo.EstateSettings != null)
3484 { 3635 {
3485 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3636 int flags = GetUserFlags(agentID);
3637 if (m_regInfo.EstateSettings.IsBanned(agentID, flags))
3486 { 3638 {
3487 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3639 //Add some more info to help users
3488 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3640 if (!m_regInfo.EstateSettings.IsBanned(agentID, 32))
3641 {
3642 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification",
3643 agentID, RegionInfo.RegionName);
3644 reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName);
3645 return false;
3646 }
3647 if (!m_regInfo.EstateSettings.IsBanned(agentID, 4))
3648 {
3649 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file",
3650 agentID, RegionInfo.RegionName);
3651 reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName);
3652 return false;
3653 }
3654 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist",
3655 agentID, RegionInfo.RegionName);
3489 reason = String.Format("Denied access to region {0}: You have been banned from that region.", 3656 reason = String.Format("Denied access to region {0}: You have been banned from that region.",
3490 RegionInfo.RegionName); 3657 RegionInfo.RegionName);
3491 return false; 3658 return false;
@@ -3502,7 +3669,7 @@ namespace OpenSim.Region.Framework.Scenes
3502 if (groupsModule != null) 3669 if (groupsModule != null)
3503 { 3670 {
3504 GroupMembershipData[] GroupMembership = 3671 GroupMembershipData[] GroupMembership =
3505 groupsModule.GetMembershipData(agent.AgentID); 3672 groupsModule.GetMembershipData(agentID);
3506 3673
3507 if (GroupMembership != null) 3674 if (GroupMembership != null)
3508 { 3675 {
@@ -3531,44 +3698,16 @@ namespace OpenSim.Region.Framework.Scenes
3531 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); 3698 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!");
3532 3699
3533 if (!m_regInfo.EstateSettings.PublicAccess && 3700 if (!m_regInfo.EstateSettings.PublicAccess &&
3534 !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && 3701 !m_regInfo.EstateSettings.HasAccess(agentID) &&
3535 !groupAccess) 3702 !groupAccess)
3536 { 3703 {
3537 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", 3704 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate",
3538 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3705 agentID, RegionInfo.RegionName);
3539 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", 3706 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3540 RegionInfo.RegionName); 3707 RegionInfo.RegionName);
3541 return false; 3708 return false;
3542 } 3709 }
3543 3710
3544 // TODO: estate/region settings are not properly hooked up
3545 // to ILandObject.isRestrictedFromLand()
3546 // if (null != LandChannel)
3547 // {
3548 // // region seems to have local Id of 1
3549 // ILandObject land = LandChannel.GetLandObject(1);
3550 // if (null != land)
3551 // {
3552 // if (land.isBannedFromLand(agent.AgentID))
3553 // {
3554 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land",
3555 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3556 // reason = String.Format("Denied access to private region {0}: You are banned from that region.",
3557 // RegionInfo.RegionName);
3558 // return false;
3559 // }
3560
3561 // if (land.isRestrictedFromLand(agent.AgentID))
3562 // {
3563 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3564 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3565 // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3566 // RegionInfo.RegionName);
3567 // return false;
3568 // }
3569 // }
3570 // }
3571
3572 return true; 3711 return true;
3573 } 3712 }
3574 3713
@@ -3672,6 +3811,13 @@ namespace OpenSim.Region.Framework.Scenes
3672 3811
3673 // We have to wait until the viewer contacts this region after receiving EAC. 3812 // We have to wait until the viewer contacts this region after receiving EAC.
3674 // That calls AddNewClient, which finally creates the ScenePresence 3813 // That calls AddNewClient, which finally creates the ScenePresence
3814 int flags = GetUserFlags(cAgentData.AgentID);
3815 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3816 {
3817 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3818 return false;
3819 }
3820
3675 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3821 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3676 if (nearestParcel == null) 3822 if (nearestParcel == null)
3677 { 3823 {
@@ -3687,7 +3833,6 @@ namespace OpenSim.Region.Framework.Scenes
3687 return false; 3833 return false;
3688 } 3834 }
3689 3835
3690
3691 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3836 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3692 3837
3693 if (childAgentUpdate != null) 3838 if (childAgentUpdate != null)
@@ -3754,12 +3899,22 @@ namespace OpenSim.Region.Framework.Scenes
3754 return false; 3899 return false;
3755 } 3900 }
3756 3901
3902 public bool IncomingCloseAgent(UUID agentID)
3903 {
3904 return IncomingCloseAgent(agentID, false);
3905 }
3906
3907 public bool IncomingCloseChildAgent(UUID agentID)
3908 {
3909 return IncomingCloseAgent(agentID, true);
3910 }
3911
3757 /// <summary> 3912 /// <summary>
3758 /// Tell a single agent to disconnect from the region. 3913 /// Tell a single agent to disconnect from the region.
3759 /// </summary> 3914 /// </summary>
3760 /// <param name="regionHandle"></param>
3761 /// <param name="agentID"></param> 3915 /// <param name="agentID"></param>
3762 public bool IncomingCloseAgent(UUID agentID) 3916 /// <param name="childOnly"></param>
3917 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3763 { 3918 {
3764 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3919 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3765 3920
@@ -3771,7 +3926,7 @@ namespace OpenSim.Region.Framework.Scenes
3771 { 3926 {
3772 m_sceneGraph.removeUserCount(false); 3927 m_sceneGraph.removeUserCount(false);
3773 } 3928 }
3774 else 3929 else if (!childOnly)
3775 { 3930 {
3776 m_sceneGraph.removeUserCount(true); 3931 m_sceneGraph.removeUserCount(true);
3777 } 3932 }
@@ -3787,9 +3942,12 @@ namespace OpenSim.Region.Framework.Scenes
3787 } 3942 }
3788 else 3943 else
3789 presence.ControllingClient.SendShutdownConnectionNotice(); 3944 presence.ControllingClient.SendShutdownConnectionNotice();
3945 presence.ControllingClient.Close(false);
3946 }
3947 else if (!childOnly)
3948 {
3949 presence.ControllingClient.Close(true);
3790 } 3950 }
3791
3792 presence.ControllingClient.Close();
3793 return true; 3951 return true;
3794 } 3952 }
3795 3953
@@ -4399,34 +4557,66 @@ namespace OpenSim.Region.Framework.Scenes
4399 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4557 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4400 } 4558 }
4401 4559
4402 public int GetHealth() 4560 public int GetHealth(out int flags, out string message)
4403 { 4561 {
4404 // Returns: 4562 // Returns:
4405 // 1 = sim is up and accepting http requests. The heartbeat has 4563 // 1 = sim is up and accepting http requests. The heartbeat has
4406 // stopped and the sim is probably locked up, but a remote 4564 // stopped and the sim is probably locked up, but a remote
4407 // admin restart may succeed 4565 // admin restart may succeed
4408 // 4566 //
4409 // 2 = Sim is up and the heartbeat is running. The sim is likely 4567 // 2 = Sim is up and the heartbeat is running. The sim is likely
4410 // usable for people within and logins _may_ work 4568 // usable for people within
4569 //
4570 // 3 = Sim is up and one packet thread is running. Sim is
4571 // unstable and will not accept new logins
4411 // 4572 //
4412 // 3 = We have seen a new user enter within the past 4 minutes 4573 // 4 = Sim is up and both packet threads are running. Sim is
4574 // likely usable
4575 //
4576 // 5 = We have seen a new user enter within the past 4 minutes
4413 // which can be seen as positive confirmation of sim health 4577 // which can be seen as positive confirmation of sim health
4414 // 4578 //
4579
4580 flags = 0;
4581 message = String.Empty;
4582
4583 CheckHeartbeat();
4584
4585 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4586 {
4587 // We're still starting
4588 // 0 means "in startup", it can't happen another way, since
4589 // to get here, we must be able to accept http connections
4590 return 0;
4591 }
4592
4415 int health=1; // Start at 1, means we're up 4593 int health=1; // Start at 1, means we're up
4416 4594
4417 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4595 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4596 {
4418 health+=1; 4597 health+=1;
4419 else 4598 flags |= 1;
4599 }
4600
4601 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4602 {
4603 health+=1;
4604 flags |= 2;
4605 }
4606
4607 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4608 {
4609 health+=1;
4610 flags |= 4;
4611 }
4612
4613 if (flags != 7)
4420 return health; 4614 return health;
4421 4615
4422 // A login in the last 4 mins? We can't be doing too badly 4616 // A login in the last 4 mins? We can't be doing too badly
4423 // 4617 //
4424 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4618 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4425 health++; 4619 health++;
4426 else
4427 return health;
4428
4429 CheckHeartbeat();
4430 4620
4431 return health; 4621 return health;
4432 } 4622 }
@@ -4619,7 +4809,7 @@ namespace OpenSim.Region.Framework.Scenes
4619 if (m_firstHeartbeat) 4809 if (m_firstHeartbeat)
4620 return; 4810 return;
4621 4811
4622 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4812 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000)
4623 StartTimer(); 4813 StartTimer();
4624 } 4814 }
4625 4815
@@ -4974,10 +5164,28 @@ namespace OpenSim.Region.Framework.Scenes
4974 }); 5164 });
4975 } 5165 }
4976 5166
4977 foreach (SceneObjectGroup grp in objectsToDelete) 5167 if (objectsToDelete.Count > 0)
4978 { 5168 {
4979 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); 5169 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
4980 DeleteSceneObject(grp, true); 5170 foreach (SceneObjectGroup grp in objectsToDelete)
5171 {
5172 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5173 DeleteSceneObject(grp, true);
5174 }
5175 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5176 }
5177 }
5178
5179 public void ThreadAlive(int threadCode)
5180 {
5181 switch(threadCode)
5182 {
5183 case 1: // Incoming
5184 m_lastIncoming = Util.EnvironmentTickCount();
5185 break;
5186 case 2: // Incoming
5187 m_lastOutgoing = Util.EnvironmentTickCount();
5188 break;
4981 } 5189 }
4982 } 5190 }
4983 5191
@@ -4989,6 +5197,14 @@ namespace OpenSim.Region.Framework.Scenes
4989 // child agent creation, thereby emulating the SL behavior. 5197 // child agent creation, thereby emulating the SL behavior.
4990 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5198 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
4991 { 5199 {
5200 reason = "You are banned from the region";
5201
5202 if (Permissions.IsGod(agentID))
5203 {
5204 reason = String.Empty;
5205 return true;
5206 }
5207
4992 int num = m_sceneGraph.GetNumberOfScenePresences(); 5208 int num = m_sceneGraph.GetNumberOfScenePresences();
4993 5209
4994 if (num >= RegionInfo.RegionSettings.AgentLimit) 5210 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5000,6 +5216,36 @@ namespace OpenSim.Region.Framework.Scenes
5000 } 5216 }
5001 } 5217 }
5002 5218
5219 if (!AuthorizeUser(agentID, out reason))
5220 {
5221 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5222 return false;
5223 }
5224
5225 if (position == Vector3.Zero) // Teleport
5226 {
5227 float posX = 128.0f;
5228 float posY = 128.0f;
5229
5230 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5231 {
5232 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5233 return false;
5234 }
5235 }
5236 else // Walking
5237 {
5238 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5239 if (land == null)
5240 return false;
5241
5242 bool banned = land.IsBannedFromLand(agentID);
5243 bool restricted = land.IsRestrictedFromLand(agentID);
5244
5245 if (banned || restricted)
5246 return false;
5247 }
5248
5003 reason = String.Empty; 5249 reason = String.Empty;
5004 return true; 5250 return true;
5005 } 5251 }