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.cs476
1 files changed, 402 insertions, 74 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 47450ed..c581b5f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -95,6 +95,7 @@ namespace OpenSim.Region.Framework.Scenes
95 // TODO: need to figure out how allow client agents but deny 95 // TODO: need to figure out how allow client agents but deny
96 // root agents when ACL denies access to root agent 96 // root agents when ACL denies access to root agent
97 public bool m_strictAccessControl = true; 97 public bool m_strictAccessControl = true;
98 public bool m_seeIntoBannedRegion = false;
98 public int MaxUndoCount = 5; 99 public int MaxUndoCount = 5;
99 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 100 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
100 public bool LoginLock = false; 101 public bool LoginLock = false;
@@ -110,12 +111,14 @@ namespace OpenSim.Region.Framework.Scenes
110 111
111 protected int m_splitRegionID; 112 protected int m_splitRegionID;
112 protected Timer m_restartWaitTimer = new Timer(); 113 protected Timer m_restartWaitTimer = new Timer();
114 protected Timer m_timerWatchdog = new Timer();
113 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 115 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
114 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 116 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
115 protected string m_simulatorVersion = "OpenSimulator Server"; 117 protected string m_simulatorVersion = "OpenSimulator Server";
116 protected ModuleLoader m_moduleLoader; 118 protected ModuleLoader m_moduleLoader;
117 protected AgentCircuitManager m_authenticateHandler; 119 protected AgentCircuitManager m_authenticateHandler;
118 protected SceneCommunicationService m_sceneGridService; 120 protected SceneCommunicationService m_sceneGridService;
121 protected ISnmpModule m_snmpService = null;
119 122
120 protected ISimulationDataService m_SimulationDataService; 123 protected ISimulationDataService m_SimulationDataService;
121 protected IEstateDataService m_EstateDataService; 124 protected IEstateDataService m_EstateDataService;
@@ -167,7 +170,7 @@ namespace OpenSim.Region.Framework.Scenes
167 private int m_update_events = 1; 170 private int m_update_events = 1;
168 private int m_update_backup = 200; 171 private int m_update_backup = 200;
169 private int m_update_terrain = 50; 172 private int m_update_terrain = 50;
170// private int m_update_land = 1; 173 private int m_update_land = 10;
171 private int m_update_coarse_locations = 50; 174 private int m_update_coarse_locations = 50;
172 175
173 private int agentMS; 176 private int agentMS;
@@ -182,6 +185,7 @@ namespace OpenSim.Region.Framework.Scenes
182 private int landMS; 185 private int landMS;
183 private int lastCompletedFrame; 186 private int lastCompletedFrame;
184 187
188 public bool CombineRegions = false;
185 /// <summary> 189 /// <summary>
186 /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched 190 /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched
187 /// asynchronously from the update loop. 191 /// asynchronously from the update loop.
@@ -204,10 +208,12 @@ namespace OpenSim.Region.Framework.Scenes
204 private bool m_scripts_enabled = true; 208 private bool m_scripts_enabled = true;
205 private string m_defaultScriptEngine; 209 private string m_defaultScriptEngine;
206 private int m_LastLogin; 210 private int m_LastLogin;
207 private Thread HeartbeatThread; 211 private Thread HeartbeatThread = null;
208 private volatile bool shuttingdown; 212 private volatile bool shuttingdown;
209 213
210 private int m_lastUpdate; 214 private int m_lastUpdate;
215 private int m_lastIncoming;
216 private int m_lastOutgoing;
211 private bool m_firstHeartbeat = true; 217 private bool m_firstHeartbeat = true;
212 218
213 private object m_deleting_scene_object = new object(); 219 private object m_deleting_scene_object = new object();
@@ -255,6 +261,19 @@ namespace OpenSim.Region.Framework.Scenes
255 get { return m_sceneGridService; } 261 get { return m_sceneGridService; }
256 } 262 }
257 263
264 public ISnmpModule SnmpService
265 {
266 get
267 {
268 if (m_snmpService == null)
269 {
270 m_snmpService = RequestModuleInterface<ISnmpModule>();
271 }
272
273 return m_snmpService;
274 }
275 }
276
258 public ISimulationDataService SimulationDataService 277 public ISimulationDataService SimulationDataService
259 { 278 {
260 get 279 get
@@ -536,6 +555,9 @@ namespace OpenSim.Region.Framework.Scenes
536 m_EstateDataService = estateDataService; 555 m_EstateDataService = estateDataService;
537 m_regionHandle = m_regInfo.RegionHandle; 556 m_regionHandle = m_regInfo.RegionHandle;
538 m_regionName = m_regInfo.RegionName; 557 m_regionName = m_regInfo.RegionName;
558 m_lastUpdate = Util.EnvironmentTickCount();
559 m_lastIncoming = 0;
560 m_lastOutgoing = 0;
539 561
540 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 562 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
541 m_asyncSceneObjectDeleter.Enabled = true; 563 m_asyncSceneObjectDeleter.Enabled = true;
@@ -652,6 +674,7 @@ namespace OpenSim.Region.Framework.Scenes
652 m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); 674 m_physicalPrim = startupConfig.GetBoolean("physical_prim", true);
653 675
654 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 676 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
677
655 if (RegionInfo.NonphysPrimMax > 0) 678 if (RegionInfo.NonphysPrimMax > 0)
656 { 679 {
657 m_maxNonphys = RegionInfo.NonphysPrimMax; 680 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -683,6 +706,7 @@ namespace OpenSim.Region.Framework.Scenes
683 m_persistAfter *= 10000000; 706 m_persistAfter *= 10000000;
684 707
685 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 708 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
709 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
686 710
687 IConfig packetConfig = m_config.Configs["PacketPool"]; 711 IConfig packetConfig = m_config.Configs["PacketPool"];
688 if (packetConfig != null) 712 if (packetConfig != null)
@@ -692,6 +716,8 @@ namespace OpenSim.Region.Framework.Scenes
692 } 716 }
693 717
694 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 718 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
719 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
720 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
695 721
696 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 722 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
697 if (m_generateMaptiles) 723 if (m_generateMaptiles)
@@ -727,9 +753,9 @@ namespace OpenSim.Region.Framework.Scenes
727 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); 753 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
728 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); 754 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
729 } 755 }
730 catch 756 catch (Exception e)
731 { 757 {
732 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 758 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
733 } 759 }
734 760
735 #endregion Region Config 761 #endregion Region Config
@@ -1140,7 +1166,9 @@ namespace OpenSim.Region.Framework.Scenes
1140 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1166 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1141 if (HeartbeatThread != null) 1167 if (HeartbeatThread != null)
1142 { 1168 {
1169 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1143 HeartbeatThread.Abort(); 1170 HeartbeatThread.Abort();
1171 Watchdog.AbortThread(HeartbeatThread.ManagedThreadId);
1144 HeartbeatThread = null; 1172 HeartbeatThread = null;
1145 } 1173 }
1146 m_lastUpdate = Util.EnvironmentTickCount(); 1174 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1185,9 +1213,6 @@ namespace OpenSim.Region.Framework.Scenes
1185 { 1213 {
1186 while (!shuttingdown) 1214 while (!shuttingdown)
1187 Update(); 1215 Update();
1188
1189 m_lastUpdate = Util.EnvironmentTickCount();
1190 m_firstHeartbeat = false;
1191 } 1216 }
1192 catch (ThreadAbortException) 1217 catch (ThreadAbortException)
1193 { 1218 {
@@ -1285,6 +1310,13 @@ namespace OpenSim.Region.Framework.Scenes
1285 eventMS = Util.EnvironmentTickCountSubtract(evMS); ; 1310 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1286 } 1311 }
1287 1312
1313 // if (Frame % m_update_land == 0)
1314 // {
1315 // int ldMS = Util.EnvironmentTickCount();
1316 // UpdateLand();
1317 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1318 // }
1319
1288 if (Frame % m_update_backup == 0) 1320 if (Frame % m_update_backup == 0)
1289 { 1321 {
1290 int backMS = Util.EnvironmentTickCount(); 1322 int backMS = Util.EnvironmentTickCount();
@@ -1386,12 +1418,16 @@ namespace OpenSim.Region.Framework.Scenes
1386 maintc = Util.EnvironmentTickCountSubtract(maintc); 1418 maintc = Util.EnvironmentTickCountSubtract(maintc);
1387 maintc = (int)(MinFrameTime * 1000) - maintc; 1419 maintc = (int)(MinFrameTime * 1000) - maintc;
1388 1420
1421
1422 m_lastUpdate = Util.EnvironmentTickCount();
1423 m_firstHeartbeat = false;
1424
1389 if (maintc > 0) 1425 if (maintc > 0)
1390 Thread.Sleep(maintc); 1426 Thread.Sleep(maintc);
1391 1427
1392 // Tell the watchdog that this thread is still alive 1428 // Tell the watchdog that this thread is still alive
1393 Watchdog.UpdateThread(); 1429 Watchdog.UpdateThread();
1394 } 1430 }
1395 1431
1396 public void AddGroupTarget(SceneObjectGroup grp) 1432 public void AddGroupTarget(SceneObjectGroup grp)
1397 { 1433 {
@@ -1407,9 +1443,9 @@ namespace OpenSim.Region.Framework.Scenes
1407 1443
1408 private void CheckAtTargets() 1444 private void CheckAtTargets()
1409 { 1445 {
1410 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1446 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1411 lock (m_groupsWithTargets) 1447 lock (m_groupsWithTargets)
1412 objs = m_groupsWithTargets.Values; 1448 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1413 1449
1414 foreach (SceneObjectGroup entry in objs) 1450 foreach (SceneObjectGroup entry in objs)
1415 entry.checkAtTargets(); 1451 entry.checkAtTargets();
@@ -1491,7 +1527,7 @@ namespace OpenSim.Region.Framework.Scenes
1491 msg.fromAgentName = "Server"; 1527 msg.fromAgentName = "Server";
1492 msg.dialog = (byte)19; // Object msg 1528 msg.dialog = (byte)19; // Object msg
1493 msg.fromGroup = false; 1529 msg.fromGroup = false;
1494 msg.offline = (byte)0; 1530 msg.offline = (byte)1;
1495 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1531 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1496 msg.Position = Vector3.Zero; 1532 msg.Position = Vector3.Zero;
1497 msg.RegionID = RegionInfo.RegionID.Guid; 1533 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1724,14 +1760,24 @@ namespace OpenSim.Region.Framework.Scenes
1724 /// <returns></returns> 1760 /// <returns></returns>
1725 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1761 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1726 { 1762 {
1763
1764 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1765 Vector3 wpos = Vector3.Zero;
1766 // Check for water surface intersection from above
1767 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1768 {
1769 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1770 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1771 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1772 wpos.Z = wheight;
1773 }
1774
1727 Vector3 pos = Vector3.Zero; 1775 Vector3 pos = Vector3.Zero;
1728 if (RayEndIsIntersection == (byte)1) 1776 if (RayEndIsIntersection == (byte)1)
1729 { 1777 {
1730 pos = RayEnd; 1778 pos = RayEnd;
1731 return pos;
1732 } 1779 }
1733 1780 else if (RayTargetID != UUID.Zero)
1734 if (RayTargetID != UUID.Zero)
1735 { 1781 {
1736 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1782 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1737 1783
@@ -1753,7 +1799,7 @@ namespace OpenSim.Region.Framework.Scenes
1753 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1799 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1754 1800
1755 // Un-comment out the following line to Get Raytrace results printed to the console. 1801 // Un-comment out the following line to Get Raytrace results printed to the console.
1756 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1802 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1757 float ScaleOffset = 0.5f; 1803 float ScaleOffset = 0.5f;
1758 1804
1759 // If we hit something 1805 // If we hit something
@@ -1776,13 +1822,10 @@ namespace OpenSim.Region.Framework.Scenes
1776 //pos.Z -= 0.25F; 1822 //pos.Z -= 0.25F;
1777 1823
1778 } 1824 }
1779
1780 return pos;
1781 } 1825 }
1782 else 1826 else
1783 { 1827 {
1784 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1828 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1785
1786 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1829 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1787 1830
1788 // Un-comment the following line to print the raytrace results to the console. 1831 // Un-comment the following line to print the raytrace results to the console.
@@ -1791,13 +1834,12 @@ namespace OpenSim.Region.Framework.Scenes
1791 if (ei.HitTF) 1834 if (ei.HitTF)
1792 { 1835 {
1793 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1836 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1794 } else 1837 }
1838 else
1795 { 1839 {
1796 // fall back to our stupid functionality 1840 // fall back to our stupid functionality
1797 pos = RayEnd; 1841 pos = RayEnd;
1798 } 1842 }
1799
1800 return pos;
1801 } 1843 }
1802 } 1844 }
1803 else 1845 else
@@ -1808,8 +1850,12 @@ namespace OpenSim.Region.Framework.Scenes
1808 //increase height so its above the ground. 1850 //increase height so its above the ground.
1809 //should be getting the normal of the ground at the rez point and using that? 1851 //should be getting the normal of the ground at the rez point and using that?
1810 pos.Z += scale.Z / 2f; 1852 pos.Z += scale.Z / 2f;
1811 return pos; 1853// return pos;
1812 } 1854 }
1855
1856 // check against posible water intercept
1857 if (wpos.Z > pos.Z) pos = wpos;
1858 return pos;
1813 } 1859 }
1814 1860
1815 1861
@@ -1893,7 +1939,10 @@ namespace OpenSim.Region.Framework.Scenes
1893 public bool AddRestoredSceneObject( 1939 public bool AddRestoredSceneObject(
1894 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1940 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1895 { 1941 {
1896 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1942 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1943 if (result)
1944 sceneObject.IsDeleted = false;
1945 return result;
1897 } 1946 }
1898 1947
1899 /// <summary> 1948 /// <summary>
@@ -1983,6 +2032,15 @@ namespace OpenSim.Region.Framework.Scenes
1983 /// </summary> 2032 /// </summary>
1984 public void DeleteAllSceneObjects() 2033 public void DeleteAllSceneObjects()
1985 { 2034 {
2035 DeleteAllSceneObjects(false);
2036 }
2037
2038 /// <summary>
2039 /// Delete every object from the scene. This does not include attachments worn by avatars.
2040 /// </summary>
2041 public void DeleteAllSceneObjects(bool exceptNoCopy)
2042 {
2043 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1986 lock (Entities) 2044 lock (Entities)
1987 { 2045 {
1988 EntityBase[] entities = Entities.GetEntities(); 2046 EntityBase[] entities = Entities.GetEntities();
@@ -1991,11 +2049,24 @@ namespace OpenSim.Region.Framework.Scenes
1991 if (e is SceneObjectGroup) 2049 if (e is SceneObjectGroup)
1992 { 2050 {
1993 SceneObjectGroup sog = (SceneObjectGroup)e; 2051 SceneObjectGroup sog = (SceneObjectGroup)e;
1994 if (!sog.IsAttachment) 2052 if (sog != null && !sog.IsAttachment)
1995 DeleteSceneObject((SceneObjectGroup)e, false); 2053 {
2054 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2055 {
2056 DeleteSceneObject((SceneObjectGroup)e, false);
2057 }
2058 else
2059 {
2060 toReturn.Add((SceneObjectGroup)e);
2061 }
2062 }
1996 } 2063 }
1997 } 2064 }
1998 } 2065 }
2066 if (toReturn.Count > 0)
2067 {
2068 returnObjects(toReturn.ToArray(), UUID.Zero);
2069 }
1999 } 2070 }
2000 2071
2001 /// <summary> 2072 /// <summary>
@@ -2043,6 +2114,8 @@ namespace OpenSim.Region.Framework.Scenes
2043 } 2114 }
2044 2115
2045 group.DeleteGroupFromScene(silent); 2116 group.DeleteGroupFromScene(silent);
2117 if (!silent)
2118 SendKillObject(new List<uint>() { group.LocalId });
2046 2119
2047// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2120// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2048 } 2121 }
@@ -2397,10 +2470,17 @@ namespace OpenSim.Region.Framework.Scenes
2397 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2470 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2398 public bool AddSceneObject(SceneObjectGroup sceneObject) 2471 public bool AddSceneObject(SceneObjectGroup sceneObject)
2399 { 2472 {
2473 if (sceneObject.OwnerID == UUID.Zero)
2474 {
2475 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2476 return false;
2477 }
2478
2400 // If the user is banned, we won't let any of their objects 2479 // If the user is banned, we won't let any of their objects
2401 // enter. Period. 2480 // enter. Period.
2402 // 2481 //
2403 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2482 int flags = GetUserFlags(sceneObject.OwnerID);
2483 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2404 { 2484 {
2405 m_log.Info("[INTERREGION]: Denied prim crossing for " + 2485 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2406 "banned avatar"); 2486 "banned avatar");
@@ -2447,12 +2527,23 @@ namespace OpenSim.Region.Framework.Scenes
2447 } 2527 }
2448 else 2528 else
2449 { 2529 {
2530 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2450 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2531 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2451 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2532 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2452 } 2533 }
2534 if (sceneObject.OwnerID == UUID.Zero)
2535 {
2536 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2537 return false;
2538 }
2453 } 2539 }
2454 else 2540 else
2455 { 2541 {
2542 if (sceneObject.OwnerID == UUID.Zero)
2543 {
2544 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2545 return false;
2546 }
2456 AddRestoredSceneObject(sceneObject, true, false); 2547 AddRestoredSceneObject(sceneObject, true, false);
2457 2548
2458 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2549 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2482,6 +2573,24 @@ namespace OpenSim.Region.Framework.Scenes
2482 return 2; // StateSource.PrimCrossing 2573 return 2; // StateSource.PrimCrossing
2483 } 2574 }
2484 2575
2576 public int GetUserFlags(UUID user)
2577 {
2578 //Unfortunately the SP approach means that the value is cached until region is restarted
2579 /*
2580 ScenePresence sp;
2581 if (TryGetScenePresence(user, out sp))
2582 {
2583 return sp.UserFlags;
2584 }
2585 else
2586 {
2587 */
2588 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2589 if (uac == null)
2590 return 0;
2591 return uac.UserFlags;
2592 //}
2593 }
2485 #endregion 2594 #endregion
2486 2595
2487 #region Add/Remove Avatar Methods 2596 #region Add/Remove Avatar Methods
@@ -2503,6 +2612,7 @@ namespace OpenSim.Region.Framework.Scenes
2503 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2612 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2504 2613
2505 CheckHeartbeat(); 2614 CheckHeartbeat();
2615 ScenePresence presence;
2506 2616
2507 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here 2617 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
2508 { 2618 {
@@ -2538,7 +2648,14 @@ namespace OpenSim.Region.Framework.Scenes
2538 2648
2539 EventManager.TriggerOnNewClient(client); 2649 EventManager.TriggerOnNewClient(client);
2540 if (vialogin) 2650 if (vialogin)
2651 {
2541 EventManager.TriggerOnClientLogin(client); 2652 EventManager.TriggerOnClientLogin(client);
2653
2654 // Send initial parcel data
2655 Vector3 pos = createdSp.AbsolutePosition;
2656 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2657 land.SendLandUpdateToClient(client);
2658 }
2542 } 2659 }
2543 2660
2544 // Send all scene object to the new client 2661 // Send all scene object to the new client
@@ -2638,19 +2755,12 @@ namespace OpenSim.Region.Framework.Scenes
2638 // and the scene presence and the client, if they exist 2755 // and the scene presence and the client, if they exist
2639 try 2756 try
2640 { 2757 {
2641 // We need to wait for the client to make UDP contact first. 2758 ScenePresence sp = GetScenePresence(agentID);
2642 // It's the UDP contact that creates the scene presence 2759 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2643 ScenePresence sp = WaitGetScenePresence(agentID); 2760
2644 if (sp != null) 2761 if (sp != null)
2645 {
2646 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2647
2648 sp.ControllingClient.Close(); 2762 sp.ControllingClient.Close();
2649 } 2763
2650 else
2651 {
2652 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2653 }
2654 // BANG! SLASH! 2764 // BANG! SLASH!
2655 m_authenticateHandler.RemoveCircuit(agentID); 2765 m_authenticateHandler.RemoveCircuit(agentID);
2656 2766
@@ -2750,6 +2860,7 @@ namespace OpenSim.Region.Framework.Scenes
2750 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2860 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2751 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2861 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2752 client.OnCopyInventoryItem += CopyInventoryItem; 2862 client.OnCopyInventoryItem += CopyInventoryItem;
2863 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2753 client.OnMoveInventoryItem += MoveInventoryItem; 2864 client.OnMoveInventoryItem += MoveInventoryItem;
2754 client.OnRemoveInventoryItem += RemoveInventoryItem; 2865 client.OnRemoveInventoryItem += RemoveInventoryItem;
2755 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2866 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2927,15 +3038,16 @@ namespace OpenSim.Region.Framework.Scenes
2927 /// </summary> 3038 /// </summary>
2928 /// <param name="agentId">The avatar's Unique ID</param> 3039 /// <param name="agentId">The avatar's Unique ID</param>
2929 /// <param name="client">The IClientAPI for the client</param> 3040 /// <param name="client">The IClientAPI for the client</param>
2930 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3041 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2931 { 3042 {
2932 if (m_teleportModule != null) 3043 if (m_teleportModule != null)
2933 m_teleportModule.TeleportHome(agentId, client); 3044 return m_teleportModule.TeleportHome(agentId, client);
2934 else 3045 else
2935 { 3046 {
2936 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3047 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2937 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3048 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2938 } 3049 }
3050 return false;
2939 } 3051 }
2940 3052
2941 /// <summary> 3053 /// <summary>
@@ -3027,6 +3139,16 @@ namespace OpenSim.Region.Framework.Scenes
3027 /// <param name="flags"></param> 3139 /// <param name="flags"></param>
3028 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3140 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3029 { 3141 {
3142 //Add half the avatar's height so that the user doesn't fall through prims
3143 ScenePresence presence;
3144 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3145 {
3146 if (presence.Appearance != null)
3147 {
3148 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3149 }
3150 }
3151
3030 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3152 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3031 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3153 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3032 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3154 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3095,8 +3217,9 @@ namespace OpenSim.Region.Framework.Scenes
3095 regions.Remove(RegionInfo.RegionHandle); 3217 regions.Remove(RegionInfo.RegionHandle);
3096 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3218 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3097 } 3219 }
3098 3220 m_log.Debug("[Scene] Beginning ClientClosed");
3099 m_eventManager.TriggerClientClosed(agentID, this); 3221 m_eventManager.TriggerClientClosed(agentID, this);
3222 m_log.Debug("[Scene] Finished ClientClosed");
3100 } 3223 }
3101 catch (NullReferenceException) 3224 catch (NullReferenceException)
3102 { 3225 {
@@ -3104,7 +3227,12 @@ namespace OpenSim.Region.Framework.Scenes
3104 // Avatar is already disposed :/ 3227 // Avatar is already disposed :/
3105 } 3228 }
3106 3229
3230 m_log.Debug("[Scene] Beginning OnRemovePresence");
3107 m_eventManager.TriggerOnRemovePresence(agentID); 3231 m_eventManager.TriggerOnRemovePresence(agentID);
3232 m_log.Debug("[Scene] Finished OnRemovePresence");
3233
3234 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
3235 AttachmentsModule.SaveChangedAttachments(avatar);
3108 3236
3109 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) 3237 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
3110 AttachmentsModule.SaveChangedAttachments(avatar); 3238 AttachmentsModule.SaveChangedAttachments(avatar);
@@ -3124,8 +3252,11 @@ namespace OpenSim.Region.Framework.Scenes
3124 } 3252 }
3125 3253
3126 // Remove the avatar from the scene 3254 // Remove the avatar from the scene
3255 m_log.Debug("[Scene] Begin RemoveScenePresence");
3127 m_sceneGraph.RemoveScenePresence(agentID); 3256 m_sceneGraph.RemoveScenePresence(agentID);
3257 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3128 m_clientManager.Remove(agentID); 3258 m_clientManager.Remove(agentID);
3259 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3129 3260
3130 try 3261 try
3131 { 3262 {
@@ -3139,9 +3270,10 @@ namespace OpenSim.Region.Framework.Scenes
3139 { 3270 {
3140 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3271 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3141 } 3272 }
3142 3273 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3143 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3274 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3144// CleanDroppedAttachments(); 3275// CleanDroppedAttachments();
3276 m_log.Debug("[Scene] The avatar has left the building");
3145 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3277 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3146 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3278 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3147 } 3279 }
@@ -3260,13 +3392,16 @@ namespace OpenSim.Region.Framework.Scenes
3260 sp = null; 3392 sp = null;
3261 } 3393 }
3262 3394
3263 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3264 3395
3265 //On login test land permisions 3396 //On login test land permisions
3266 if (vialogin) 3397 if (vialogin)
3267 { 3398 {
3268 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3399 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3400 if (cache != null)
3401 cache.Remove(agent.firstname + " " + agent.lastname);
3402 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3269 { 3403 {
3404 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3270 return false; 3405 return false;
3271 } 3406 }
3272 } 3407 }
@@ -3289,8 +3424,13 @@ namespace OpenSim.Region.Framework.Scenes
3289 3424
3290 try 3425 try
3291 { 3426 {
3292 if (!AuthorizeUser(agent, out reason)) 3427 // Always check estate if this is a login. Always
3293 return false; 3428 // check if banned regions are to be blacked out.
3429 if (vialogin || (!m_seeIntoBannedRegion))
3430 {
3431 if (!AuthorizeUser(agent, out reason))
3432 return false;
3433 }
3294 } 3434 }
3295 catch (Exception e) 3435 catch (Exception e)
3296 { 3436 {
@@ -3392,6 +3532,8 @@ namespace OpenSim.Region.Framework.Scenes
3392 } 3532 }
3393 } 3533 }
3394 // Honor parcel landing type and position. 3534 // Honor parcel landing type and position.
3535 /*
3536 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3395 if (land != null) 3537 if (land != null)
3396 { 3538 {
3397 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3539 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3399,26 +3541,34 @@ namespace OpenSim.Region.Framework.Scenes
3399 agent.startpos = land.LandData.UserLocation; 3541 agent.startpos = land.LandData.UserLocation;
3400 } 3542 }
3401 } 3543 }
3544 */// This is now handled properly in ScenePresence.MakeRootAgent
3402 } 3545 }
3403 3546
3404 return true; 3547 return true;
3405 } 3548 }
3406 3549
3407 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3550 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3408 { 3551 {
3409 3552 reason = String.Empty;
3410 bool banned = land.IsBannedFromLand(agent.AgentID); 3553 if (Permissions.IsGod(agentID))
3411 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3554 return true;
3555
3556 ILandObject land = LandChannel.GetLandObject(posX, posY);
3557 if (land == null)
3558 return false;
3559
3560 bool banned = land.IsBannedFromLand(agentID);
3561 bool restricted = land.IsRestrictedFromLand(agentID);
3412 3562
3413 if (banned || restricted) 3563 if (banned || restricted)
3414 { 3564 {
3415 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3565 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3416 if (nearestParcel != null) 3566 if (nearestParcel != null)
3417 { 3567 {
3418 //Move agent to nearest allowed 3568 //Move agent to nearest allowed
3419 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3569 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3420 agent.startpos.X = newPosition.X; 3570 posX = newPosition.X;
3421 agent.startpos.Y = newPosition.Y; 3571 posY = newPosition.Y;
3422 } 3572 }
3423 else 3573 else
3424 { 3574 {
@@ -3480,7 +3630,7 @@ namespace OpenSim.Region.Framework.Scenes
3480 3630
3481 if (!m_strictAccessControl) return true; 3631 if (!m_strictAccessControl) return true;
3482 if (Permissions.IsGod(agent.AgentID)) return true; 3632 if (Permissions.IsGod(agent.AgentID)) return true;
3483 3633
3484 if (AuthorizationService != null) 3634 if (AuthorizationService != null)
3485 { 3635 {
3486 if (!AuthorizationService.IsAuthorizedForRegion( 3636 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3488,14 +3638,14 @@ namespace OpenSim.Region.Framework.Scenes
3488 { 3638 {
3489 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3639 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3490 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3640 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3491 3641
3492 return false; 3642 return false;
3493 } 3643 }
3494 } 3644 }
3495 3645
3496 if (m_regInfo.EstateSettings != null) 3646 if (m_regInfo.EstateSettings != null)
3497 { 3647 {
3498 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3648 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3499 { 3649 {
3500 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3650 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3501 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3651 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3685,6 +3835,13 @@ namespace OpenSim.Region.Framework.Scenes
3685 3835
3686 // We have to wait until the viewer contacts this region after receiving EAC. 3836 // We have to wait until the viewer contacts this region after receiving EAC.
3687 // That calls AddNewClient, which finally creates the ScenePresence 3837 // That calls AddNewClient, which finally creates the ScenePresence
3838 int flags = GetUserFlags(cAgentData.AgentID);
3839 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3840 {
3841 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3842 return false;
3843 }
3844
3688 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3845 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3689 if (nearestParcel == null) 3846 if (nearestParcel == null)
3690 { 3847 {
@@ -3700,7 +3857,6 @@ namespace OpenSim.Region.Framework.Scenes
3700 return false; 3857 return false;
3701 } 3858 }
3702 3859
3703
3704 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3860 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3705 3861
3706 if (childAgentUpdate != null) 3862 if (childAgentUpdate != null)
@@ -3767,12 +3923,22 @@ namespace OpenSim.Region.Framework.Scenes
3767 return false; 3923 return false;
3768 } 3924 }
3769 3925
3926 public bool IncomingCloseAgent(UUID agentID)
3927 {
3928 return IncomingCloseAgent(agentID, false);
3929 }
3930
3931 public bool IncomingCloseChildAgent(UUID agentID)
3932 {
3933 return IncomingCloseAgent(agentID, true);
3934 }
3935
3770 /// <summary> 3936 /// <summary>
3771 /// Tell a single agent to disconnect from the region. 3937 /// Tell a single agent to disconnect from the region.
3772 /// </summary> 3938 /// </summary>
3773 /// <param name="regionHandle"></param>
3774 /// <param name="agentID"></param> 3939 /// <param name="agentID"></param>
3775 public bool IncomingCloseAgent(UUID agentID) 3940 /// <param name="childOnly"></param>
3941 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3776 { 3942 {
3777 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3943 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3778 3944
@@ -3784,7 +3950,7 @@ namespace OpenSim.Region.Framework.Scenes
3784 { 3950 {
3785 m_sceneGraph.removeUserCount(false); 3951 m_sceneGraph.removeUserCount(false);
3786 } 3952 }
3787 else 3953 else if (!childOnly)
3788 { 3954 {
3789 m_sceneGraph.removeUserCount(true); 3955 m_sceneGraph.removeUserCount(true);
3790 } 3956 }
@@ -3800,9 +3966,12 @@ namespace OpenSim.Region.Framework.Scenes
3800 } 3966 }
3801 else 3967 else
3802 presence.ControllingClient.SendShutdownConnectionNotice(); 3968 presence.ControllingClient.SendShutdownConnectionNotice();
3969 presence.ControllingClient.Close(false);
3970 }
3971 else if (!childOnly)
3972 {
3973 presence.ControllingClient.Close(true);
3803 } 3974 }
3804
3805 presence.ControllingClient.Close();
3806 return true; 3975 return true;
3807 } 3976 }
3808 3977
@@ -4397,34 +4566,66 @@ namespace OpenSim.Region.Framework.Scenes
4397 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4566 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4398 } 4567 }
4399 4568
4400 public int GetHealth() 4569 public int GetHealth(out int flags, out string message)
4401 { 4570 {
4402 // Returns: 4571 // Returns:
4403 // 1 = sim is up and accepting http requests. The heartbeat has 4572 // 1 = sim is up and accepting http requests. The heartbeat has
4404 // stopped and the sim is probably locked up, but a remote 4573 // stopped and the sim is probably locked up, but a remote
4405 // admin restart may succeed 4574 // admin restart may succeed
4406 // 4575 //
4407 // 2 = Sim is up and the heartbeat is running. The sim is likely 4576 // 2 = Sim is up and the heartbeat is running. The sim is likely
4408 // usable for people within and logins _may_ work 4577 // usable for people within
4578 //
4579 // 3 = Sim is up and one packet thread is running. Sim is
4580 // unstable and will not accept new logins
4581 //
4582 // 4 = Sim is up and both packet threads are running. Sim is
4583 // likely usable
4409 // 4584 //
4410 // 3 = We have seen a new user enter within the past 4 minutes 4585 // 5 = We have seen a new user enter within the past 4 minutes
4411 // which can be seen as positive confirmation of sim health 4586 // which can be seen as positive confirmation of sim health
4412 // 4587 //
4588
4589 flags = 0;
4590 message = String.Empty;
4591
4592 CheckHeartbeat();
4593
4594 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4595 {
4596 // We're still starting
4597 // 0 means "in startup", it can't happen another way, since
4598 // to get here, we must be able to accept http connections
4599 return 0;
4600 }
4601
4413 int health=1; // Start at 1, means we're up 4602 int health=1; // Start at 1, means we're up
4414 4603
4415 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4604 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4605 {
4416 health+=1; 4606 health+=1;
4417 else 4607 flags |= 1;
4608 }
4609
4610 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4611 {
4612 health+=1;
4613 flags |= 2;
4614 }
4615
4616 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4617 {
4618 health+=1;
4619 flags |= 4;
4620 }
4621
4622 if (flags != 7)
4418 return health; 4623 return health;
4419 4624
4420 // A login in the last 4 mins? We can't be doing too badly 4625 // A login in the last 4 mins? We can't be doing too badly
4421 // 4626 //
4422 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4627 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4423 health++; 4628 health++;
4424 else
4425 return health;
4426
4427 CheckHeartbeat();
4428 4629
4429 return health; 4630 return health;
4430 } 4631 }
@@ -4617,7 +4818,7 @@ namespace OpenSim.Region.Framework.Scenes
4617 if (m_firstHeartbeat) 4818 if (m_firstHeartbeat)
4618 return; 4819 return;
4619 4820
4620 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4821 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4621 StartTimer(); 4822 StartTimer();
4622 } 4823 }
4623 4824
@@ -5029,6 +5230,54 @@ namespace OpenSim.Region.Framework.Scenes
5029 mapModule.GenerateMaptile(); 5230 mapModule.GenerateMaptile();
5030 } 5231 }
5031 5232
5233// public void CleanDroppedAttachments()
5234// {
5235// List<SceneObjectGroup> objectsToDelete =
5236// new List<SceneObjectGroup>();
5237//
5238// lock (m_cleaningAttachments)
5239// {
5240// ForEachSOG(delegate (SceneObjectGroup grp)
5241// {
5242// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5243// {
5244// UUID agentID = grp.OwnerID;
5245// if (agentID == UUID.Zero)
5246// {
5247// objectsToDelete.Add(grp);
5248// return;
5249// }
5250//
5251// ScenePresence sp = GetScenePresence(agentID);
5252// if (sp == null)
5253// {
5254// objectsToDelete.Add(grp);
5255// return;
5256// }
5257// }
5258// });
5259// }
5260//
5261// foreach (SceneObjectGroup grp in objectsToDelete)
5262// {
5263// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5264// DeleteSceneObject(grp, true);
5265// }
5266// }
5267
5268 public void ThreadAlive(int threadCode)
5269 {
5270 switch(threadCode)
5271 {
5272 case 1: // Incoming
5273 m_lastIncoming = Util.EnvironmentTickCount();
5274 break;
5275 case 2: // Incoming
5276 m_lastOutgoing = Util.EnvironmentTickCount();
5277 break;
5278 }
5279 }
5280
5032 // This method is called across the simulation connector to 5281 // This method is called across the simulation connector to
5033 // determine if a given agent is allowed in this region 5282 // determine if a given agent is allowed in this region
5034 // AS A ROOT AGENT. Returning false here will prevent them 5283 // AS A ROOT AGENT. Returning false here will prevent them
@@ -5037,6 +5286,14 @@ namespace OpenSim.Region.Framework.Scenes
5037 // child agent creation, thereby emulating the SL behavior. 5286 // child agent creation, thereby emulating the SL behavior.
5038 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5287 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5039 { 5288 {
5289 reason = "You are banned from the region";
5290
5291 if (Permissions.IsGod(agentID))
5292 {
5293 reason = String.Empty;
5294 return true;
5295 }
5296
5040 int num = m_sceneGraph.GetNumberOfScenePresences(); 5297 int num = m_sceneGraph.GetNumberOfScenePresences();
5041 5298
5042 if (num >= RegionInfo.RegionSettings.AgentLimit) 5299 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5048,11 +5305,82 @@ namespace OpenSim.Region.Framework.Scenes
5048 } 5305 }
5049 } 5306 }
5050 5307
5308 ScenePresence presence = GetScenePresence(agentID);
5309 IClientAPI client = null;
5310 AgentCircuitData aCircuit = null;
5311
5312 if (presence != null)
5313 {
5314 client = presence.ControllingClient;
5315 if (client != null)
5316 aCircuit = client.RequestClientInfo();
5317 }
5318
5319 // We may be called before there is a presence or a client.
5320 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5321 if (client == null)
5322 {
5323 aCircuit = new AgentCircuitData();
5324 aCircuit.AgentID = agentID;
5325 aCircuit.firstname = String.Empty;
5326 aCircuit.lastname = String.Empty;
5327 }
5328
5329 try
5330 {
5331 if (!AuthorizeUser(aCircuit, out reason))
5332 {
5333 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5334 return false;
5335 }
5336 }
5337 catch (Exception e)
5338 {
5339 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5340 return false;
5341 }
5342
5343 if (position == Vector3.Zero) // Teleport
5344 {
5345 float posX = 128.0f;
5346 float posY = 128.0f;
5347
5348 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5349 {
5350 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5351 return false;
5352 }
5353 }
5354 else // Walking
5355 {
5356 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5357 if (land == null)
5358 return false;
5359
5360 bool banned = land.IsBannedFromLand(agentID);
5361 bool restricted = land.IsRestrictedFromLand(agentID);
5362
5363 if (banned || restricted)
5364 return false;
5365 }
5366
5051 reason = String.Empty; 5367 reason = String.Empty;
5052 return true; 5368 return true;
5053 } 5369 }
5054 5370
5055 /// <summary> 5371 public void StartTimerWatchdog()
5372 {
5373 m_timerWatchdog.Interval = 1000;
5374 m_timerWatchdog.Elapsed += TimerWatchdog;
5375 m_timerWatchdog.AutoReset = true;
5376 m_timerWatchdog.Start();
5377 }
5378
5379 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5380 {
5381 CheckHeartbeat();
5382 }
5383
5056 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5384 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5057 /// autopilot that moves an avatar to a sit target!. 5385 /// autopilot that moves an avatar to a sit target!.
5058 /// </summary> 5386 /// </summary>