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