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 ec6044b..e02a866 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 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 98 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
98 public bool LoginLock = false; 99 public bool LoginLock = false;
@@ -114,6 +115,7 @@ namespace OpenSim.Region.Framework.Scenes
114 protected ModuleLoader m_moduleLoader; 115 protected ModuleLoader m_moduleLoader;
115 protected AgentCircuitManager m_authenticateHandler; 116 protected AgentCircuitManager m_authenticateHandler;
116 protected SceneCommunicationService m_sceneGridService; 117 protected SceneCommunicationService m_sceneGridService;
118 protected ISnmpModule m_snmpService = null;
117 119
118 protected ISimulationDataService m_SimulationDataService; 120 protected ISimulationDataService m_SimulationDataService;
119 protected IEstateDataService m_EstateDataService; 121 protected IEstateDataService m_EstateDataService;
@@ -170,7 +172,7 @@ namespace OpenSim.Region.Framework.Scenes
170 private int m_update_events = 1; 172 private int m_update_events = 1;
171 private int m_update_backup = 200; 173 private int m_update_backup = 200;
172 private int m_update_terrain = 50; 174 private int m_update_terrain = 50;
173// private int m_update_land = 1; 175 private int m_update_land = 10;
174 private int m_update_coarse_locations = 50; 176 private int m_update_coarse_locations = 50;
175 177
176 private int frameMS; 178 private int frameMS;
@@ -184,6 +186,7 @@ namespace OpenSim.Region.Framework.Scenes
184 private int landMS; 186 private int landMS;
185 private int lastCompletedFrame; 187 private int lastCompletedFrame;
186 188
189 public bool CombineRegions = false;
187 private bool m_physics_enabled = true; 190 private bool m_physics_enabled = true;
188 private bool m_scripts_enabled = true; 191 private bool m_scripts_enabled = true;
189 private string m_defaultScriptEngine; 192 private string m_defaultScriptEngine;
@@ -192,6 +195,8 @@ namespace OpenSim.Region.Framework.Scenes
192 private volatile bool shuttingdown; 195 private volatile bool shuttingdown;
193 196
194 private int m_lastUpdate; 197 private int m_lastUpdate;
198 private int m_lastIncoming;
199 private int m_lastOutgoing;
195 private bool m_firstHeartbeat = true; 200 private bool m_firstHeartbeat = true;
196 201
197 private object m_deleting_scene_object = new object(); 202 private object m_deleting_scene_object = new object();
@@ -244,6 +249,19 @@ namespace OpenSim.Region.Framework.Scenes
244 get { return m_sceneGridService; } 249 get { return m_sceneGridService; }
245 } 250 }
246 251
252 public ISnmpModule SnmpService
253 {
254 get
255 {
256 if (m_snmpService == null)
257 {
258 m_snmpService = RequestModuleInterface<ISnmpModule>();
259 }
260
261 return m_snmpService;
262 }
263 }
264
247 public ISimulationDataService SimulationDataService 265 public ISimulationDataService SimulationDataService
248 { 266 {
249 get 267 get
@@ -572,7 +590,10 @@ namespace OpenSim.Region.Framework.Scenes
572 m_regInfo = regInfo; 590 m_regInfo = regInfo;
573 m_regionHandle = m_regInfo.RegionHandle; 591 m_regionHandle = m_regInfo.RegionHandle;
574 m_regionName = m_regInfo.RegionName; 592 m_regionName = m_regInfo.RegionName;
593 m_datastore = m_regInfo.DataStore;
575 m_lastUpdate = Util.EnvironmentTickCount(); 594 m_lastUpdate = Util.EnvironmentTickCount();
595 m_lastIncoming = 0;
596 m_lastOutgoing = 0;
576 597
577 m_physicalPrim = physicalPrim; 598 m_physicalPrim = physicalPrim;
578 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; 599 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
@@ -588,6 +609,8 @@ namespace OpenSim.Region.Framework.Scenes
588 #region Region Settings 609 #region Region Settings
589 610
590 // Load region settings 611 // Load region settings
612 m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID);
613
591 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); 614 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID);
592 if (estateDataService != null) 615 if (estateDataService != null)
593 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); 616 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
@@ -665,9 +688,10 @@ namespace OpenSim.Region.Framework.Scenes
665 //Animation states 688 //Animation states
666 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 689 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
667 // TODO: Change default to true once the feature is supported 690 // TODO: Change default to true once the feature is supported
668 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 691 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
669
670 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 692 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
693
694 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
671 if (RegionInfo.NonphysPrimMax > 0) 695 if (RegionInfo.NonphysPrimMax > 0)
672 { 696 {
673 m_maxNonphys = RegionInfo.NonphysPrimMax; 697 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -699,6 +723,7 @@ namespace OpenSim.Region.Framework.Scenes
699 m_persistAfter *= 10000000; 723 m_persistAfter *= 10000000;
700 724
701 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 725 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
726 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
702 727
703 IConfig packetConfig = m_config.Configs["PacketPool"]; 728 IConfig packetConfig = m_config.Configs["PacketPool"];
704 if (packetConfig != null) 729 if (packetConfig != null)
@@ -708,6 +733,8 @@ namespace OpenSim.Region.Framework.Scenes
708 } 733 }
709 734
710 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 735 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
736 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
737 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
711 738
712 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 739 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
713 if (m_generateMaptiles) 740 if (m_generateMaptiles)
@@ -732,9 +759,9 @@ namespace OpenSim.Region.Framework.Scenes
732 } 759 }
733 } 760 }
734 } 761 }
735 catch 762 catch (Exception e)
736 { 763 {
737 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 764 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
738 } 765 }
739 766
740 #endregion Region Config 767 #endregion Region Config
@@ -1109,7 +1136,9 @@ namespace OpenSim.Region.Framework.Scenes
1109 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1136 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1110 if (HeartbeatThread != null) 1137 if (HeartbeatThread != null)
1111 { 1138 {
1139 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1112 HeartbeatThread.Abort(); 1140 HeartbeatThread.Abort();
1141 Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId);
1113 HeartbeatThread = null; 1142 HeartbeatThread = null;
1114 } 1143 }
1115 m_lastUpdate = Util.EnvironmentTickCount(); 1144 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1233,9 +1262,6 @@ namespace OpenSim.Region.Framework.Scenes
1233 { 1262 {
1234 while (!shuttingdown) 1263 while (!shuttingdown)
1235 Update(); 1264 Update();
1236
1237 m_lastUpdate = Util.EnvironmentTickCount();
1238 m_firstHeartbeat = false;
1239 } 1265 }
1240 catch (ThreadAbortException) 1266 catch (ThreadAbortException)
1241 { 1267 {
@@ -1341,12 +1367,12 @@ namespace OpenSim.Region.Framework.Scenes
1341 terrainMS = Util.EnvironmentTickCountSubtract(terMS); 1367 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1342 } 1368 }
1343 1369
1344 //if (Frame % m_update_land == 0) 1370 // if (Frame % m_update_land == 0)
1345 //{ 1371 // {
1346 // int ldMS = Util.EnvironmentTickCount(); 1372 // int ldMS = Util.EnvironmentTickCount();
1347 // UpdateLand(); 1373 // UpdateLand();
1348 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1374 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1349 //} 1375 // }
1350 1376
1351 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); 1377 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1352 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1378 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
@@ -1428,12 +1454,16 @@ namespace OpenSim.Region.Framework.Scenes
1428 maintc = Util.EnvironmentTickCountSubtract(maintc); 1454 maintc = Util.EnvironmentTickCountSubtract(maintc);
1429 maintc = (int)(m_timespan * 1000) - maintc; 1455 maintc = (int)(m_timespan * 1000) - maintc;
1430 1456
1457
1458 m_lastUpdate = Util.EnvironmentTickCount();
1459 m_firstHeartbeat = false;
1460
1431 if (maintc > 0) 1461 if (maintc > 0)
1432 Thread.Sleep(maintc); 1462 Thread.Sleep(maintc);
1433 1463
1434 // Tell the watchdog that this thread is still alive 1464 // Tell the watchdog that this thread is still alive
1435 Watchdog.UpdateThread(); 1465 Watchdog.UpdateThread();
1436 } 1466 }
1437 1467
1438 public void AddGroupTarget(SceneObjectGroup grp) 1468 public void AddGroupTarget(SceneObjectGroup grp)
1439 { 1469 {
@@ -1449,9 +1479,9 @@ namespace OpenSim.Region.Framework.Scenes
1449 1479
1450 private void CheckAtTargets() 1480 private void CheckAtTargets()
1451 { 1481 {
1452 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1482 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1453 lock (m_groupsWithTargets) 1483 lock (m_groupsWithTargets)
1454 objs = m_groupsWithTargets.Values; 1484 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1455 1485
1456 foreach (SceneObjectGroup entry in objs) 1486 foreach (SceneObjectGroup entry in objs)
1457 entry.checkAtTargets(); 1487 entry.checkAtTargets();
@@ -1775,14 +1805,24 @@ namespace OpenSim.Region.Framework.Scenes
1775 /// <returns></returns> 1805 /// <returns></returns>
1776 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1806 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1777 { 1807 {
1808
1809 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1810 Vector3 wpos = Vector3.Zero;
1811 // Check for water surface intersection from above
1812 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1813 {
1814 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1815 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1816 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1817 wpos.Z = wheight;
1818 }
1819
1778 Vector3 pos = Vector3.Zero; 1820 Vector3 pos = Vector3.Zero;
1779 if (RayEndIsIntersection == (byte)1) 1821 if (RayEndIsIntersection == (byte)1)
1780 { 1822 {
1781 pos = RayEnd; 1823 pos = RayEnd;
1782 return pos;
1783 } 1824 }
1784 1825 else if (RayTargetID != UUID.Zero)
1785 if (RayTargetID != UUID.Zero)
1786 { 1826 {
1787 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1827 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1788 1828
@@ -1804,7 +1844,7 @@ namespace OpenSim.Region.Framework.Scenes
1804 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1844 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1805 1845
1806 // Un-comment out the following line to Get Raytrace results printed to the console. 1846 // Un-comment out the following line to Get Raytrace results printed to the console.
1807 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1847 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1808 float ScaleOffset = 0.5f; 1848 float ScaleOffset = 0.5f;
1809 1849
1810 // If we hit something 1850 // If we hit something
@@ -1827,13 +1867,10 @@ namespace OpenSim.Region.Framework.Scenes
1827 //pos.Z -= 0.25F; 1867 //pos.Z -= 0.25F;
1828 1868
1829 } 1869 }
1830
1831 return pos;
1832 } 1870 }
1833 else 1871 else
1834 { 1872 {
1835 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1873 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1836
1837 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1874 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1838 1875
1839 // Un-comment the following line to print the raytrace results to the console. 1876 // Un-comment the following line to print the raytrace results to the console.
@@ -1842,13 +1879,12 @@ namespace OpenSim.Region.Framework.Scenes
1842 if (ei.HitTF) 1879 if (ei.HitTF)
1843 { 1880 {
1844 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1881 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1845 } else 1882 }
1883 else
1846 { 1884 {
1847 // fall back to our stupid functionality 1885 // fall back to our stupid functionality
1848 pos = RayEnd; 1886 pos = RayEnd;
1849 } 1887 }
1850
1851 return pos;
1852 } 1888 }
1853 } 1889 }
1854 else 1890 else
@@ -1859,8 +1895,12 @@ namespace OpenSim.Region.Framework.Scenes
1859 //increase height so its above the ground. 1895 //increase height so its above the ground.
1860 //should be getting the normal of the ground at the rez point and using that? 1896 //should be getting the normal of the ground at the rez point and using that?
1861 pos.Z += scale.Z / 2f; 1897 pos.Z += scale.Z / 2f;
1862 return pos; 1898// return pos;
1863 } 1899 }
1900
1901 // check against posible water intercept
1902 if (wpos.Z > pos.Z) pos = wpos;
1903 return pos;
1864 } 1904 }
1865 1905
1866 1906
@@ -1944,7 +1984,10 @@ namespace OpenSim.Region.Framework.Scenes
1944 public bool AddRestoredSceneObject( 1984 public bool AddRestoredSceneObject(
1945 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1985 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1946 { 1986 {
1947 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1987 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1988 if (result)
1989 sceneObject.IsDeleted = false;
1990 return result;
1948 } 1991 }
1949 1992
1950 /// <summary> 1993 /// <summary>
@@ -2034,6 +2077,15 @@ namespace OpenSim.Region.Framework.Scenes
2034 /// </summary> 2077 /// </summary>
2035 public void DeleteAllSceneObjects() 2078 public void DeleteAllSceneObjects()
2036 { 2079 {
2080 DeleteAllSceneObjects(false);
2081 }
2082
2083 /// <summary>
2084 /// Delete every object from the scene. This does not include attachments worn by avatars.
2085 /// </summary>
2086 public void DeleteAllSceneObjects(bool exceptNoCopy)
2087 {
2088 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2037 lock (Entities) 2089 lock (Entities)
2038 { 2090 {
2039 EntityBase[] entities = Entities.GetEntities(); 2091 EntityBase[] entities = Entities.GetEntities();
@@ -2042,11 +2094,24 @@ namespace OpenSim.Region.Framework.Scenes
2042 if (e is SceneObjectGroup) 2094 if (e is SceneObjectGroup)
2043 { 2095 {
2044 SceneObjectGroup sog = (SceneObjectGroup)e; 2096 SceneObjectGroup sog = (SceneObjectGroup)e;
2045 if (!sog.IsAttachment) 2097 if (sog != null && !sog.IsAttachment)
2046 DeleteSceneObject((SceneObjectGroup)e, false); 2098 {
2099 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2100 {
2101 DeleteSceneObject((SceneObjectGroup)e, false);
2102 }
2103 else
2104 {
2105 toReturn.Add((SceneObjectGroup)e);
2106 }
2107 }
2047 } 2108 }
2048 } 2109 }
2049 } 2110 }
2111 if (toReturn.Count > 0)
2112 {
2113 returnObjects(toReturn.ToArray(), UUID.Zero);
2114 }
2050 } 2115 }
2051 2116
2052 /// <summary> 2117 /// <summary>
@@ -2095,6 +2160,8 @@ namespace OpenSim.Region.Framework.Scenes
2095 } 2160 }
2096 2161
2097 group.DeleteGroupFromScene(silent); 2162 group.DeleteGroupFromScene(silent);
2163 if (!silent)
2164 SendKillObject(new List<uint>() { group.LocalId });
2098 2165
2099// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2166// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2100 } 2167 }
@@ -2447,10 +2514,17 @@ namespace OpenSim.Region.Framework.Scenes
2447 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2514 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2448 public bool AddSceneObject(SceneObjectGroup sceneObject) 2515 public bool AddSceneObject(SceneObjectGroup sceneObject)
2449 { 2516 {
2517 if (sceneObject.OwnerID == UUID.Zero)
2518 {
2519 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2520 return false;
2521 }
2522
2450 // If the user is banned, we won't let any of their objects 2523 // If the user is banned, we won't let any of their objects
2451 // enter. Period. 2524 // enter. Period.
2452 // 2525 //
2453 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2526 int flags = GetUserFlags(sceneObject.OwnerID);
2527 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2454 { 2528 {
2455 m_log.Info("[INTERREGION]: Denied prim crossing for " + 2529 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2456 "banned avatar"); 2530 "banned avatar");
@@ -2494,15 +2568,28 @@ namespace OpenSim.Region.Framework.Scenes
2494 2568
2495 if (AttachmentsModule != null) 2569 if (AttachmentsModule != null)
2496 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2570 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2571
2572 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2497 } 2573 }
2498 else 2574 else
2499 { 2575 {
2576 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2500 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2577 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2501 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2578 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2502 } 2579 }
2580 if (sceneObject.OwnerID == UUID.Zero)
2581 {
2582 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2583 return false;
2584 }
2503 } 2585 }
2504 else 2586 else
2505 { 2587 {
2588 if (sceneObject.OwnerID == UUID.Zero)
2589 {
2590 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2591 return false;
2592 }
2506 AddRestoredSceneObject(sceneObject, true, false); 2593 AddRestoredSceneObject(sceneObject, true, false);
2507 2594
2508 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2595 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2532,6 +2619,24 @@ namespace OpenSim.Region.Framework.Scenes
2532 return 2; // StateSource.PrimCrossing 2619 return 2; // StateSource.PrimCrossing
2533 } 2620 }
2534 2621
2622 public int GetUserFlags(UUID user)
2623 {
2624 //Unfortunately the SP approach means that the value is cached until region is restarted
2625 /*
2626 ScenePresence sp;
2627 if (TryGetScenePresence(user, out sp))
2628 {
2629 return sp.UserFlags;
2630 }
2631 else
2632 {
2633 */
2634 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2635 if (uac == null)
2636 return 0;
2637 return uac.UserFlags;
2638 //}
2639 }
2535 #endregion 2640 #endregion
2536 2641
2537 #region Add/Remove Avatar Methods 2642 #region Add/Remove Avatar Methods
@@ -2552,6 +2657,7 @@ namespace OpenSim.Region.Framework.Scenes
2552 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2657 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2553 2658
2554 CheckHeartbeat(); 2659 CheckHeartbeat();
2660 ScenePresence presence;
2555 2661
2556 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here 2662 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
2557 { 2663 {
@@ -2575,7 +2681,7 @@ namespace OpenSim.Region.Framework.Scenes
2575 } 2681 }
2576 } 2682 }
2577 2683
2578 if (GetScenePresence(client.AgentId) != null) 2684 if (TryGetScenePresence(client.AgentId, out presence))
2579 { 2685 {
2580 m_LastLogin = Util.EnvironmentTickCount(); 2686 m_LastLogin = Util.EnvironmentTickCount();
2581 2687
@@ -2584,7 +2690,14 @@ namespace OpenSim.Region.Framework.Scenes
2584 2690
2585 EventManager.TriggerOnNewClient(client); 2691 EventManager.TriggerOnNewClient(client);
2586 if (vialogin) 2692 if (vialogin)
2693 {
2587 EventManager.TriggerOnClientLogin(client); 2694 EventManager.TriggerOnClientLogin(client);
2695
2696 // Send initial parcel data
2697 Vector3 pos = presence.AbsolutePosition;
2698 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2699 land.SendLandUpdateToClient(presence.ControllingClient);
2700 }
2588 } 2701 }
2589 } 2702 }
2590 2703
@@ -2660,19 +2773,12 @@ namespace OpenSim.Region.Framework.Scenes
2660 // and the scene presence and the client, if they exist 2773 // and the scene presence and the client, if they exist
2661 try 2774 try
2662 { 2775 {
2663 // We need to wait for the client to make UDP contact first. 2776 ScenePresence sp = GetScenePresence(agentID);
2664 // It's the UDP contact that creates the scene presence 2777 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2665 ScenePresence sp = WaitGetScenePresence(agentID); 2778
2666 if (sp != null) 2779 if (sp != null)
2667 {
2668 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2669
2670 sp.ControllingClient.Close(); 2780 sp.ControllingClient.Close();
2671 } 2781
2672 else
2673 {
2674 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2675 }
2676 // BANG! SLASH! 2782 // BANG! SLASH!
2677 m_authenticateHandler.RemoveCircuit(agentID); 2783 m_authenticateHandler.RemoveCircuit(agentID);
2678 2784
@@ -2771,6 +2877,7 @@ namespace OpenSim.Region.Framework.Scenes
2771 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2877 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2772 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2878 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2773 client.OnCopyInventoryItem += CopyInventoryItem; 2879 client.OnCopyInventoryItem += CopyInventoryItem;
2880 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2774 client.OnMoveInventoryItem += MoveInventoryItem; 2881 client.OnMoveInventoryItem += MoveInventoryItem;
2775 client.OnRemoveInventoryItem += RemoveInventoryItem; 2882 client.OnRemoveInventoryItem += RemoveInventoryItem;
2776 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2883 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2947,15 +3054,16 @@ namespace OpenSim.Region.Framework.Scenes
2947 /// </summary> 3054 /// </summary>
2948 /// <param name="agentId">The avatar's Unique ID</param> 3055 /// <param name="agentId">The avatar's Unique ID</param>
2949 /// <param name="client">The IClientAPI for the client</param> 3056 /// <param name="client">The IClientAPI for the client</param>
2950 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3057 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2951 { 3058 {
2952 if (m_teleportModule != null) 3059 if (m_teleportModule != null)
2953 m_teleportModule.TeleportHome(agentId, client); 3060 return m_teleportModule.TeleportHome(agentId, client);
2954 else 3061 else
2955 { 3062 {
2956 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3063 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2957 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3064 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2958 } 3065 }
3066 return false;
2959 } 3067 }
2960 3068
2961 /// <summary> 3069 /// <summary>
@@ -3054,6 +3162,16 @@ namespace OpenSim.Region.Framework.Scenes
3054 /// <param name="flags"></param> 3162 /// <param name="flags"></param>
3055 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3163 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3056 { 3164 {
3165 //Add half the avatar's height so that the user doesn't fall through prims
3166 ScenePresence presence;
3167 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3168 {
3169 if (presence.Appearance != null)
3170 {
3171 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3172 }
3173 }
3174
3057 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3175 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3058 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3176 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3059 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3177 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3130,7 +3248,9 @@ namespace OpenSim.Region.Framework.Scenes
3130 regions.Remove(RegionInfo.RegionHandle); 3248 regions.Remove(RegionInfo.RegionHandle);
3131 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3249 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3132 } 3250 }
3251 m_log.Debug("[Scene] Beginning ClientClosed");
3133 m_eventManager.TriggerClientClosed(agentID, this); 3252 m_eventManager.TriggerClientClosed(agentID, this);
3253 m_log.Debug("[Scene] Finished ClientClosed");
3134 } 3254 }
3135 catch (NullReferenceException) 3255 catch (NullReferenceException)
3136 { 3256 {
@@ -3138,7 +3258,12 @@ namespace OpenSim.Region.Framework.Scenes
3138 // Avatar is already disposed :/ 3258 // Avatar is already disposed :/
3139 } 3259 }
3140 3260
3261 m_log.Debug("[Scene] Beginning OnRemovePresence");
3141 m_eventManager.TriggerOnRemovePresence(agentID); 3262 m_eventManager.TriggerOnRemovePresence(agentID);
3263 m_log.Debug("[Scene] Finished OnRemovePresence");
3264
3265 if (avatar != null && (!avatar.IsChildAgent))
3266 avatar.SaveChangedAttachments();
3142 3267
3143 if (avatar != null && (!avatar.IsChildAgent)) 3268 if (avatar != null && (!avatar.IsChildAgent))
3144 avatar.SaveChangedAttachments(); 3269 avatar.SaveChangedAttachments();
@@ -3147,7 +3272,7 @@ namespace OpenSim.Region.Framework.Scenes
3147 delegate(IClientAPI client) 3272 delegate(IClientAPI client)
3148 { 3273 {
3149 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3274 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3150 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3275 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3151 catch (NullReferenceException) { } 3276 catch (NullReferenceException) { }
3152 }); 3277 });
3153 3278
@@ -3158,8 +3283,11 @@ namespace OpenSim.Region.Framework.Scenes
3158 } 3283 }
3159 3284
3160 // Remove the avatar from the scene 3285 // Remove the avatar from the scene
3286 m_log.Debug("[Scene] Begin RemoveScenePresence");
3161 m_sceneGraph.RemoveScenePresence(agentID); 3287 m_sceneGraph.RemoveScenePresence(agentID);
3288 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3162 m_clientManager.Remove(agentID); 3289 m_clientManager.Remove(agentID);
3290 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3163 3291
3164 try 3292 try
3165 { 3293 {
@@ -3173,9 +3301,10 @@ namespace OpenSim.Region.Framework.Scenes
3173 { 3301 {
3174 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3302 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3175 } 3303 }
3176 3304 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3177 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3305 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3178 CleanDroppedAttachments(); 3306 CleanDroppedAttachments();
3307 m_log.Debug("[Scene] The avatar has left the building");
3179 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3308 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3180 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3309 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3181 } 3310 }
@@ -3206,18 +3335,24 @@ namespace OpenSim.Region.Framework.Scenes
3206 3335
3207 #region Entities 3336 #region Entities
3208 3337
3209 public void SendKillObject(uint localID) 3338 public void SendKillObject(List<uint> localIDs)
3210 { 3339 {
3211 SceneObjectPart part = GetSceneObjectPart(localID); 3340 List<uint> deleteIDs = new List<uint>();
3212 if (part != null) // It is a prim 3341
3342 foreach (uint localID in localIDs)
3213 { 3343 {
3214 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3344 SceneObjectPart part = GetSceneObjectPart(localID);
3345 if (part != null) // It is a prim
3215 { 3346 {
3216 if (part.ParentGroup.RootPart != part) // Child part 3347 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3217 return; 3348 {
3349 if (part.ParentGroup.RootPart != part) // Child part
3350 continue;
3351 }
3218 } 3352 }
3353 deleteIDs.Add(localID);
3219 } 3354 }
3220 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3355 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3221 } 3356 }
3222 3357
3223 #endregion 3358 #endregion
@@ -3235,7 +3370,6 @@ namespace OpenSim.Region.Framework.Scenes
3235 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3370 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3236 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3371 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3237 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3372 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3238 m_sceneGridService.KiPrimitive += SendKillObject;
3239 m_sceneGridService.OnGetLandData += GetLandData; 3373 m_sceneGridService.OnGetLandData += GetLandData;
3240 } 3374 }
3241 3375
@@ -3244,7 +3378,6 @@ namespace OpenSim.Region.Framework.Scenes
3244 /// </summary> 3378 /// </summary>
3245 public void UnRegisterRegionWithComms() 3379 public void UnRegisterRegionWithComms()
3246 { 3380 {
3247 m_sceneGridService.KiPrimitive -= SendKillObject;
3248 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3381 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3249 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3382 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3250 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3383 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3324,13 +3457,16 @@ namespace OpenSim.Region.Framework.Scenes
3324 sp = null; 3457 sp = null;
3325 } 3458 }
3326 3459
3327 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3328 3460
3329 //On login test land permisions 3461 //On login test land permisions
3330 if (vialogin) 3462 if (vialogin)
3331 { 3463 {
3332 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3464 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3465 if (cache != null)
3466 cache.Remove(agent.firstname + " " + agent.lastname);
3467 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3333 { 3468 {
3469 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3334 return false; 3470 return false;
3335 } 3471 }
3336 } 3472 }
@@ -3353,8 +3489,13 @@ namespace OpenSim.Region.Framework.Scenes
3353 3489
3354 try 3490 try
3355 { 3491 {
3356 if (!AuthorizeUser(agent, out reason)) 3492 // Always check estate if this is a login. Always
3357 return false; 3493 // check if banned regions are to be blacked out.
3494 if (vialogin || (!m_seeIntoBannedRegion))
3495 {
3496 if (!AuthorizeUser(agent.AgentID, out reason))
3497 return false;
3498 }
3358 } 3499 }
3359 catch (Exception e) 3500 catch (Exception e)
3360 { 3501 {
@@ -3456,6 +3597,8 @@ namespace OpenSim.Region.Framework.Scenes
3456 } 3597 }
3457 } 3598 }
3458 // Honor parcel landing type and position. 3599 // Honor parcel landing type and position.
3600 /*
3601 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3459 if (land != null) 3602 if (land != null)
3460 { 3603 {
3461 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3604 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3463,26 +3606,34 @@ namespace OpenSim.Region.Framework.Scenes
3463 agent.startpos = land.LandData.UserLocation; 3606 agent.startpos = land.LandData.UserLocation;
3464 } 3607 }
3465 } 3608 }
3609 */// This is now handled properly in ScenePresence.MakeRootAgent
3466 } 3610 }
3467 3611
3468 return true; 3612 return true;
3469 } 3613 }
3470 3614
3471 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3615 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3472 { 3616 {
3473 3617 reason = String.Empty;
3474 bool banned = land.IsBannedFromLand(agent.AgentID); 3618 if (Permissions.IsGod(agentID))
3475 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3619 return true;
3620
3621 ILandObject land = LandChannel.GetLandObject(posX, posY);
3622 if (land == null)
3623 return false;
3624
3625 bool banned = land.IsBannedFromLand(agentID);
3626 bool restricted = land.IsRestrictedFromLand(agentID);
3476 3627
3477 if (banned || restricted) 3628 if (banned || restricted)
3478 { 3629 {
3479 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3630 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3480 if (nearestParcel != null) 3631 if (nearestParcel != null)
3481 { 3632 {
3482 //Move agent to nearest allowed 3633 //Move agent to nearest allowed
3483 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3634 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3484 agent.startpos.X = newPosition.X; 3635 posX = newPosition.X;
3485 agent.startpos.Y = newPosition.Y; 3636 posY = newPosition.Y;
3486 } 3637 }
3487 else 3638 else
3488 { 3639 {
@@ -3538,19 +3689,19 @@ namespace OpenSim.Region.Framework.Scenes
3538 /// <param name="reason">outputs the reason to this string</param> 3689 /// <param name="reason">outputs the reason to this string</param>
3539 /// <returns>True if the region accepts this agent. False if it does not. False will 3690 /// <returns>True if the region accepts this agent. False if it does not. False will
3540 /// also return a reason.</returns> 3691 /// also return a reason.</returns>
3541 protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) 3692 protected virtual bool AuthorizeUser(UUID agentID, out string reason)
3542 { 3693 {
3543 reason = String.Empty; 3694 reason = String.Empty;
3544 3695
3545 if (!m_strictAccessControl) return true; 3696 if (!m_strictAccessControl) return true;
3546 if (Permissions.IsGod(agent.AgentID)) return true; 3697 if (Permissions.IsGod(agentID)) return true;
3547 3698
3548 if (AuthorizationService != null) 3699 if (AuthorizationService != null)
3549 { 3700 {
3550 if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) 3701 if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason))
3551 { 3702 {
3552 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3703 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region",
3553 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3704 agentID, RegionInfo.RegionName);
3554 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); 3705 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName);
3555 return false; 3706 return false;
3556 } 3707 }
@@ -3558,10 +3709,26 @@ namespace OpenSim.Region.Framework.Scenes
3558 3709
3559 if (m_regInfo.EstateSettings != null) 3710 if (m_regInfo.EstateSettings != null)
3560 { 3711 {
3561 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3712 int flags = GetUserFlags(agentID);
3713 if (m_regInfo.EstateSettings.IsBanned(agentID, flags))
3562 { 3714 {
3563 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3715 //Add some more info to help users
3564 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3716 if (!m_regInfo.EstateSettings.IsBanned(agentID, 32))
3717 {
3718 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification",
3719 agentID, RegionInfo.RegionName);
3720 reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName);
3721 return false;
3722 }
3723 if (!m_regInfo.EstateSettings.IsBanned(agentID, 4))
3724 {
3725 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file",
3726 agentID, RegionInfo.RegionName);
3727 reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName);
3728 return false;
3729 }
3730 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist",
3731 agentID, RegionInfo.RegionName);
3565 reason = String.Format("Denied access to region {0}: You have been banned from that region.", 3732 reason = String.Format("Denied access to region {0}: You have been banned from that region.",
3566 RegionInfo.RegionName); 3733 RegionInfo.RegionName);
3567 return false; 3734 return false;
@@ -3578,7 +3745,7 @@ namespace OpenSim.Region.Framework.Scenes
3578 if (groupsModule != null) 3745 if (groupsModule != null)
3579 { 3746 {
3580 GroupMembershipData[] GroupMembership = 3747 GroupMembershipData[] GroupMembership =
3581 groupsModule.GetMembershipData(agent.AgentID); 3748 groupsModule.GetMembershipData(agentID);
3582 3749
3583 if (GroupMembership != null) 3750 if (GroupMembership != null)
3584 { 3751 {
@@ -3607,44 +3774,16 @@ namespace OpenSim.Region.Framework.Scenes
3607 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); 3774 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!");
3608 3775
3609 if (!m_regInfo.EstateSettings.PublicAccess && 3776 if (!m_regInfo.EstateSettings.PublicAccess &&
3610 !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && 3777 !m_regInfo.EstateSettings.HasAccess(agentID) &&
3611 !groupAccess) 3778 !groupAccess)
3612 { 3779 {
3613 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", 3780 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate",
3614 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3781 agentID, RegionInfo.RegionName);
3615 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", 3782 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3616 RegionInfo.RegionName); 3783 RegionInfo.RegionName);
3617 return false; 3784 return false;
3618 } 3785 }
3619 3786
3620 // TODO: estate/region settings are not properly hooked up
3621 // to ILandObject.isRestrictedFromLand()
3622 // if (null != LandChannel)
3623 // {
3624 // // region seems to have local Id of 1
3625 // ILandObject land = LandChannel.GetLandObject(1);
3626 // if (null != land)
3627 // {
3628 // if (land.isBannedFromLand(agent.AgentID))
3629 // {
3630 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land",
3631 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3632 // reason = String.Format("Denied access to private region {0}: You are banned from that region.",
3633 // RegionInfo.RegionName);
3634 // return false;
3635 // }
3636
3637 // if (land.isRestrictedFromLand(agent.AgentID))
3638 // {
3639 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3640 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3641 // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3642 // RegionInfo.RegionName);
3643 // return false;
3644 // }
3645 // }
3646 // }
3647
3648 return true; 3787 return true;
3649 } 3788 }
3650 3789
@@ -3748,6 +3887,13 @@ namespace OpenSim.Region.Framework.Scenes
3748 3887
3749 // We have to wait until the viewer contacts this region after receiving EAC. 3888 // We have to wait until the viewer contacts this region after receiving EAC.
3750 // That calls AddNewClient, which finally creates the ScenePresence 3889 // That calls AddNewClient, which finally creates the ScenePresence
3890 int flags = GetUserFlags(cAgentData.AgentID);
3891 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3892 {
3893 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3894 return false;
3895 }
3896
3751 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3897 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3752 if (nearestParcel == null) 3898 if (nearestParcel == null)
3753 { 3899 {
@@ -3763,7 +3909,6 @@ namespace OpenSim.Region.Framework.Scenes
3763 return false; 3909 return false;
3764 } 3910 }
3765 3911
3766
3767 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3912 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3768 3913
3769 if (childAgentUpdate != null) 3914 if (childAgentUpdate != null)
@@ -3830,12 +3975,22 @@ namespace OpenSim.Region.Framework.Scenes
3830 return false; 3975 return false;
3831 } 3976 }
3832 3977
3978 public bool IncomingCloseAgent(UUID agentID)
3979 {
3980 return IncomingCloseAgent(agentID, false);
3981 }
3982
3983 public bool IncomingCloseChildAgent(UUID agentID)
3984 {
3985 return IncomingCloseAgent(agentID, true);
3986 }
3987
3833 /// <summary> 3988 /// <summary>
3834 /// Tell a single agent to disconnect from the region. 3989 /// Tell a single agent to disconnect from the region.
3835 /// </summary> 3990 /// </summary>
3836 /// <param name="regionHandle"></param>
3837 /// <param name="agentID"></param> 3991 /// <param name="agentID"></param>
3838 public bool IncomingCloseAgent(UUID agentID) 3992 /// <param name="childOnly"></param>
3993 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3839 { 3994 {
3840 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3995 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3841 3996
@@ -3847,7 +4002,7 @@ namespace OpenSim.Region.Framework.Scenes
3847 { 4002 {
3848 m_sceneGraph.removeUserCount(false); 4003 m_sceneGraph.removeUserCount(false);
3849 } 4004 }
3850 else 4005 else if (!childOnly)
3851 { 4006 {
3852 m_sceneGraph.removeUserCount(true); 4007 m_sceneGraph.removeUserCount(true);
3853 } 4008 }
@@ -3863,9 +4018,12 @@ namespace OpenSim.Region.Framework.Scenes
3863 } 4018 }
3864 else 4019 else
3865 presence.ControllingClient.SendShutdownConnectionNotice(); 4020 presence.ControllingClient.SendShutdownConnectionNotice();
4021 presence.ControllingClient.Close(false);
4022 }
4023 else if (!childOnly)
4024 {
4025 presence.ControllingClient.Close(true);
3866 } 4026 }
3867
3868 presence.ControllingClient.Close();
3869 return true; 4027 return true;
3870 } 4028 }
3871 4029
@@ -4476,34 +4634,66 @@ namespace OpenSim.Region.Framework.Scenes
4476 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4634 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4477 } 4635 }
4478 4636
4479 public int GetHealth() 4637 public int GetHealth(out int flags, out string message)
4480 { 4638 {
4481 // Returns: 4639 // Returns:
4482 // 1 = sim is up and accepting http requests. The heartbeat has 4640 // 1 = sim is up and accepting http requests. The heartbeat has
4483 // stopped and the sim is probably locked up, but a remote 4641 // stopped and the sim is probably locked up, but a remote
4484 // admin restart may succeed 4642 // admin restart may succeed
4485 // 4643 //
4486 // 2 = Sim is up and the heartbeat is running. The sim is likely 4644 // 2 = Sim is up and the heartbeat is running. The sim is likely
4487 // usable for people within and logins _may_ work 4645 // usable for people within
4646 //
4647 // 3 = Sim is up and one packet thread is running. Sim is
4648 // unstable and will not accept new logins
4488 // 4649 //
4489 // 3 = We have seen a new user enter within the past 4 minutes 4650 // 4 = Sim is up and both packet threads are running. Sim is
4651 // likely usable
4652 //
4653 // 5 = We have seen a new user enter within the past 4 minutes
4490 // which can be seen as positive confirmation of sim health 4654 // which can be seen as positive confirmation of sim health
4491 // 4655 //
4656
4657 flags = 0;
4658 message = String.Empty;
4659
4660 CheckHeartbeat();
4661
4662 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4663 {
4664 // We're still starting
4665 // 0 means "in startup", it can't happen another way, since
4666 // to get here, we must be able to accept http connections
4667 return 0;
4668 }
4669
4492 int health=1; // Start at 1, means we're up 4670 int health=1; // Start at 1, means we're up
4493 4671
4494 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4672 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4673 {
4495 health+=1; 4674 health+=1;
4496 else 4675 flags |= 1;
4676 }
4677
4678 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4679 {
4680 health+=1;
4681 flags |= 2;
4682 }
4683
4684 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4685 {
4686 health+=1;
4687 flags |= 4;
4688 }
4689
4690 if (flags != 7)
4497 return health; 4691 return health;
4498 4692
4499 // A login in the last 4 mins? We can't be doing too badly 4693 // A login in the last 4 mins? We can't be doing too badly
4500 // 4694 //
4501 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4695 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4502 health++; 4696 health++;
4503 else
4504 return health;
4505
4506 CheckHeartbeat();
4507 4697
4508 return health; 4698 return health;
4509 } 4699 }
@@ -4696,7 +4886,7 @@ namespace OpenSim.Region.Framework.Scenes
4696 if (m_firstHeartbeat) 4886 if (m_firstHeartbeat)
4697 return; 4887 return;
4698 4888
4699 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4889 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000)
4700 StartTimer(); 4890 StartTimer();
4701 } 4891 }
4702 4892
@@ -5105,10 +5295,28 @@ namespace OpenSim.Region.Framework.Scenes
5105 }); 5295 });
5106 } 5296 }
5107 5297
5108 foreach (SceneObjectGroup grp in objectsToDelete) 5298 if (objectsToDelete.Count > 0)
5109 { 5299 {
5110 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); 5300 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
5111 DeleteSceneObject(grp, true); 5301 foreach (SceneObjectGroup grp in objectsToDelete)
5302 {
5303 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5304 DeleteSceneObject(grp, true);
5305 }
5306 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5307 }
5308 }
5309
5310 public void ThreadAlive(int threadCode)
5311 {
5312 switch(threadCode)
5313 {
5314 case 1: // Incoming
5315 m_lastIncoming = Util.EnvironmentTickCount();
5316 break;
5317 case 2: // Incoming
5318 m_lastOutgoing = Util.EnvironmentTickCount();
5319 break;
5112 } 5320 }
5113 } 5321 }
5114 5322
@@ -5120,6 +5328,14 @@ namespace OpenSim.Region.Framework.Scenes
5120 // child agent creation, thereby emulating the SL behavior. 5328 // child agent creation, thereby emulating the SL behavior.
5121 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5329 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5122 { 5330 {
5331 reason = "You are banned from the region";
5332
5333 if (Permissions.IsGod(agentID))
5334 {
5335 reason = String.Empty;
5336 return true;
5337 }
5338
5123 int num = m_sceneGraph.GetNumberOfScenePresences(); 5339 int num = m_sceneGraph.GetNumberOfScenePresences();
5124 5340
5125 if (num >= RegionInfo.RegionSettings.AgentLimit) 5341 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5131,6 +5347,36 @@ namespace OpenSim.Region.Framework.Scenes
5131 } 5347 }
5132 } 5348 }
5133 5349
5350 if (!AuthorizeUser(agentID, out reason))
5351 {
5352 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5353 return false;
5354 }
5355
5356 if (position == Vector3.Zero) // Teleport
5357 {
5358 float posX = 128.0f;
5359 float posY = 128.0f;
5360
5361 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5362 {
5363 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5364 return false;
5365 }
5366 }
5367 else // Walking
5368 {
5369 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5370 if (land == null)
5371 return false;
5372
5373 bool banned = land.IsBannedFromLand(agentID);
5374 bool restricted = land.IsRestrictedFromLand(agentID);
5375
5376 if (banned || restricted)
5377 return false;
5378 }
5379
5134 reason = String.Empty; 5380 reason = String.Empty;
5135 return true; 5381 return true;
5136 } 5382 }