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 3b90c16..e668790 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();
@@ -1183,9 +1211,6 @@ namespace OpenSim.Region.Framework.Scenes
1183 { 1211 {
1184 while (!shuttingdown) 1212 while (!shuttingdown)
1185 Update(); 1213 Update();
1186
1187 m_lastUpdate = Util.EnvironmentTickCount();
1188 m_firstHeartbeat = false;
1189 } 1214 }
1190 catch (ThreadAbortException) 1215 catch (ThreadAbortException)
1191 { 1216 {
@@ -1283,6 +1308,13 @@ namespace OpenSim.Region.Framework.Scenes
1283 eventMS = Util.EnvironmentTickCountSubtract(evMS); ; 1308 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1284 } 1309 }
1285 1310
1311 // if (Frame % m_update_land == 0)
1312 // {
1313 // int ldMS = Util.EnvironmentTickCount();
1314 // UpdateLand();
1315 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1316 // }
1317
1286 if (Frame % m_update_backup == 0) 1318 if (Frame % m_update_backup == 0)
1287 { 1319 {
1288 int backMS = Util.EnvironmentTickCount(); 1320 int backMS = Util.EnvironmentTickCount();
@@ -1384,12 +1416,16 @@ namespace OpenSim.Region.Framework.Scenes
1384 maintc = Util.EnvironmentTickCountSubtract(maintc); 1416 maintc = Util.EnvironmentTickCountSubtract(maintc);
1385 maintc = (int)(MinFrameTime * 1000) - maintc; 1417 maintc = (int)(MinFrameTime * 1000) - maintc;
1386 1418
1419
1420 m_lastUpdate = Util.EnvironmentTickCount();
1421 m_firstHeartbeat = false;
1422
1387 if (maintc > 0) 1423 if (maintc > 0)
1388 Thread.Sleep(maintc); 1424 Thread.Sleep(maintc);
1389 1425
1390 // Tell the watchdog that this thread is still alive 1426 // Tell the watchdog that this thread is still alive
1391 Watchdog.UpdateThread(); 1427 Watchdog.UpdateThread();
1392 } 1428 }
1393 1429
1394 public void AddGroupTarget(SceneObjectGroup grp) 1430 public void AddGroupTarget(SceneObjectGroup grp)
1395 { 1431 {
@@ -1405,9 +1441,9 @@ namespace OpenSim.Region.Framework.Scenes
1405 1441
1406 private void CheckAtTargets() 1442 private void CheckAtTargets()
1407 { 1443 {
1408 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1444 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1409 lock (m_groupsWithTargets) 1445 lock (m_groupsWithTargets)
1410 objs = m_groupsWithTargets.Values; 1446 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1411 1447
1412 foreach (SceneObjectGroup entry in objs) 1448 foreach (SceneObjectGroup entry in objs)
1413 entry.checkAtTargets(); 1449 entry.checkAtTargets();
@@ -1489,7 +1525,7 @@ namespace OpenSim.Region.Framework.Scenes
1489 msg.fromAgentName = "Server"; 1525 msg.fromAgentName = "Server";
1490 msg.dialog = (byte)19; // Object msg 1526 msg.dialog = (byte)19; // Object msg
1491 msg.fromGroup = false; 1527 msg.fromGroup = false;
1492 msg.offline = (byte)0; 1528 msg.offline = (byte)1;
1493 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1529 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1494 msg.Position = Vector3.Zero; 1530 msg.Position = Vector3.Zero;
1495 msg.RegionID = RegionInfo.RegionID.Guid; 1531 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 2661
@@ -2627,19 +2744,12 @@ namespace OpenSim.Region.Framework.Scenes
2627 // and the scene presence and the client, if they exist 2744 // and the scene presence and the client, if they exist
2628 try 2745 try
2629 { 2746 {
2630 // We need to wait for the client to make UDP contact first. 2747 ScenePresence sp = GetScenePresence(agentID);
2631 // It's the UDP contact that creates the scene presence 2748 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2632 ScenePresence sp = WaitGetScenePresence(agentID); 2749
2633 if (sp != null) 2750 if (sp != null)
2634 {
2635 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2636
2637 sp.ControllingClient.Close(); 2751 sp.ControllingClient.Close();
2638 } 2752
2639 else
2640 {
2641 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2642 }
2643 // BANG! SLASH! 2753 // BANG! SLASH!
2644 m_authenticateHandler.RemoveCircuit(agentID); 2754 m_authenticateHandler.RemoveCircuit(agentID);
2645 2755
@@ -2739,6 +2849,7 @@ namespace OpenSim.Region.Framework.Scenes
2739 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2849 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2740 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2850 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2741 client.OnCopyInventoryItem += CopyInventoryItem; 2851 client.OnCopyInventoryItem += CopyInventoryItem;
2852 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2742 client.OnMoveInventoryItem += MoveInventoryItem; 2853 client.OnMoveInventoryItem += MoveInventoryItem;
2743 client.OnRemoveInventoryItem += RemoveInventoryItem; 2854 client.OnRemoveInventoryItem += RemoveInventoryItem;
2744 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2855 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2916,15 +3027,16 @@ namespace OpenSim.Region.Framework.Scenes
2916 /// </summary> 3027 /// </summary>
2917 /// <param name="agentId">The avatar's Unique ID</param> 3028 /// <param name="agentId">The avatar's Unique ID</param>
2918 /// <param name="client">The IClientAPI for the client</param> 3029 /// <param name="client">The IClientAPI for the client</param>
2919 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3030 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2920 { 3031 {
2921 if (m_teleportModule != null) 3032 if (m_teleportModule != null)
2922 m_teleportModule.TeleportHome(agentId, client); 3033 return m_teleportModule.TeleportHome(agentId, client);
2923 else 3034 else
2924 { 3035 {
2925 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3036 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2926 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3037 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2927 } 3038 }
3039 return false;
2928 } 3040 }
2929 3041
2930 /// <summary> 3042 /// <summary>
@@ -3016,6 +3128,16 @@ namespace OpenSim.Region.Framework.Scenes
3016 /// <param name="flags"></param> 3128 /// <param name="flags"></param>
3017 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3129 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3018 { 3130 {
3131 //Add half the avatar's height so that the user doesn't fall through prims
3132 ScenePresence presence;
3133 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3134 {
3135 if (presence.Appearance != null)
3136 {
3137 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3138 }
3139 }
3140
3019 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3141 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3020 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3142 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3021 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3143 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3084,8 +3206,9 @@ namespace OpenSim.Region.Framework.Scenes
3084 regions.Remove(RegionInfo.RegionHandle); 3206 regions.Remove(RegionInfo.RegionHandle);
3085 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3207 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3086 } 3208 }
3087 3209 m_log.Debug("[Scene] Beginning ClientClosed");
3088 m_eventManager.TriggerClientClosed(agentID, this); 3210 m_eventManager.TriggerClientClosed(agentID, this);
3211 m_log.Debug("[Scene] Finished ClientClosed");
3089 } 3212 }
3090 catch (NullReferenceException) 3213 catch (NullReferenceException)
3091 { 3214 {
@@ -3093,7 +3216,12 @@ namespace OpenSim.Region.Framework.Scenes
3093 // Avatar is already disposed :/ 3216 // Avatar is already disposed :/
3094 } 3217 }
3095 3218
3219 m_log.Debug("[Scene] Beginning OnRemovePresence");
3096 m_eventManager.TriggerOnRemovePresence(agentID); 3220 m_eventManager.TriggerOnRemovePresence(agentID);
3221 m_log.Debug("[Scene] Finished OnRemovePresence");
3222
3223 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
3224 AttachmentsModule.SaveChangedAttachments(avatar);
3097 3225
3098 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) 3226 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
3099 AttachmentsModule.SaveChangedAttachments(avatar); 3227 AttachmentsModule.SaveChangedAttachments(avatar);
@@ -3113,8 +3241,11 @@ namespace OpenSim.Region.Framework.Scenes
3113 } 3241 }
3114 3242
3115 // Remove the avatar from the scene 3243 // Remove the avatar from the scene
3244 m_log.Debug("[Scene] Begin RemoveScenePresence");
3116 m_sceneGraph.RemoveScenePresence(agentID); 3245 m_sceneGraph.RemoveScenePresence(agentID);
3246 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3117 m_clientManager.Remove(agentID); 3247 m_clientManager.Remove(agentID);
3248 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3118 3249
3119 try 3250 try
3120 { 3251 {
@@ -3128,9 +3259,10 @@ namespace OpenSim.Region.Framework.Scenes
3128 { 3259 {
3129 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3260 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3130 } 3261 }
3131 3262 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3132 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3263 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3133// CleanDroppedAttachments(); 3264// CleanDroppedAttachments();
3265 m_log.Debug("[Scene] The avatar has left the building");
3134 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3266 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3135 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3267 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3136 } 3268 }
@@ -3283,13 +3415,16 @@ namespace OpenSim.Region.Framework.Scenes
3283 sp = null; 3415 sp = null;
3284 } 3416 }
3285 3417
3286 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3287 3418
3288 //On login test land permisions 3419 //On login test land permisions
3289 if (vialogin) 3420 if (vialogin)
3290 { 3421 {
3291 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3422 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3423 if (cache != null)
3424 cache.Remove(agent.firstname + " " + agent.lastname);
3425 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3292 { 3426 {
3427 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3293 return false; 3428 return false;
3294 } 3429 }
3295 } 3430 }
@@ -3312,8 +3447,13 @@ namespace OpenSim.Region.Framework.Scenes
3312 3447
3313 try 3448 try
3314 { 3449 {
3315 if (!AuthorizeUser(agent, out reason)) 3450 // Always check estate if this is a login. Always
3316 return false; 3451 // check if banned regions are to be blacked out.
3452 if (vialogin || (!m_seeIntoBannedRegion))
3453 {
3454 if (!AuthorizeUser(agent, out reason))
3455 return false;
3456 }
3317 } 3457 }
3318 catch (Exception e) 3458 catch (Exception e)
3319 { 3459 {
@@ -3415,6 +3555,8 @@ namespace OpenSim.Region.Framework.Scenes
3415 } 3555 }
3416 } 3556 }
3417 // Honor parcel landing type and position. 3557 // Honor parcel landing type and position.
3558 /*
3559 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3418 if (land != null) 3560 if (land != null)
3419 { 3561 {
3420 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3562 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3422,26 +3564,34 @@ namespace OpenSim.Region.Framework.Scenes
3422 agent.startpos = land.LandData.UserLocation; 3564 agent.startpos = land.LandData.UserLocation;
3423 } 3565 }
3424 } 3566 }
3567 */// This is now handled properly in ScenePresence.MakeRootAgent
3425 } 3568 }
3426 3569
3427 return true; 3570 return true;
3428 } 3571 }
3429 3572
3430 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3573 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3431 { 3574 {
3432 3575 reason = String.Empty;
3433 bool banned = land.IsBannedFromLand(agent.AgentID); 3576 if (Permissions.IsGod(agentID))
3434 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3577 return true;
3578
3579 ILandObject land = LandChannel.GetLandObject(posX, posY);
3580 if (land == null)
3581 return false;
3582
3583 bool banned = land.IsBannedFromLand(agentID);
3584 bool restricted = land.IsRestrictedFromLand(agentID);
3435 3585
3436 if (banned || restricted) 3586 if (banned || restricted)
3437 { 3587 {
3438 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3588 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3439 if (nearestParcel != null) 3589 if (nearestParcel != null)
3440 { 3590 {
3441 //Move agent to nearest allowed 3591 //Move agent to nearest allowed
3442 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3592 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3443 agent.startpos.X = newPosition.X; 3593 posX = newPosition.X;
3444 agent.startpos.Y = newPosition.Y; 3594 posY = newPosition.Y;
3445 } 3595 }
3446 else 3596 else
3447 { 3597 {
@@ -3503,7 +3653,7 @@ namespace OpenSim.Region.Framework.Scenes
3503 3653
3504 if (!m_strictAccessControl) return true; 3654 if (!m_strictAccessControl) return true;
3505 if (Permissions.IsGod(agent.AgentID)) return true; 3655 if (Permissions.IsGod(agent.AgentID)) return true;
3506 3656
3507 if (AuthorizationService != null) 3657 if (AuthorizationService != null)
3508 { 3658 {
3509 if (!AuthorizationService.IsAuthorizedForRegion( 3659 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3511,14 +3661,14 @@ namespace OpenSim.Region.Framework.Scenes
3511 { 3661 {
3512 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3662 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3513 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3663 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3514 3664
3515 return false; 3665 return false;
3516 } 3666 }
3517 } 3667 }
3518 3668
3519 if (m_regInfo.EstateSettings != null) 3669 if (m_regInfo.EstateSettings != null)
3520 { 3670 {
3521 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3671 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3522 { 3672 {
3523 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3673 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3524 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3674 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3708,6 +3858,13 @@ namespace OpenSim.Region.Framework.Scenes
3708 3858
3709 // We have to wait until the viewer contacts this region after receiving EAC. 3859 // We have to wait until the viewer contacts this region after receiving EAC.
3710 // That calls AddNewClient, which finally creates the ScenePresence 3860 // That calls AddNewClient, which finally creates the ScenePresence
3861 int flags = GetUserFlags(cAgentData.AgentID);
3862 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3863 {
3864 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3865 return false;
3866 }
3867
3711 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3868 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3712 if (nearestParcel == null) 3869 if (nearestParcel == null)
3713 { 3870 {
@@ -3723,7 +3880,6 @@ namespace OpenSim.Region.Framework.Scenes
3723 return false; 3880 return false;
3724 } 3881 }
3725 3882
3726
3727 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3883 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3728 3884
3729 if (childAgentUpdate != null) 3885 if (childAgentUpdate != null)
@@ -3790,12 +3946,22 @@ namespace OpenSim.Region.Framework.Scenes
3790 return false; 3946 return false;
3791 } 3947 }
3792 3948
3949 public bool IncomingCloseAgent(UUID agentID)
3950 {
3951 return IncomingCloseAgent(agentID, false);
3952 }
3953
3954 public bool IncomingCloseChildAgent(UUID agentID)
3955 {
3956 return IncomingCloseAgent(agentID, true);
3957 }
3958
3793 /// <summary> 3959 /// <summary>
3794 /// Tell a single agent to disconnect from the region. 3960 /// Tell a single agent to disconnect from the region.
3795 /// </summary> 3961 /// </summary>
3796 /// <param name="regionHandle"></param>
3797 /// <param name="agentID"></param> 3962 /// <param name="agentID"></param>
3798 public bool IncomingCloseAgent(UUID agentID) 3963 /// <param name="childOnly"></param>
3964 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3799 { 3965 {
3800 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3966 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3801 3967
@@ -3807,7 +3973,7 @@ namespace OpenSim.Region.Framework.Scenes
3807 { 3973 {
3808 m_sceneGraph.removeUserCount(false); 3974 m_sceneGraph.removeUserCount(false);
3809 } 3975 }
3810 else 3976 else if (!childOnly)
3811 { 3977 {
3812 m_sceneGraph.removeUserCount(true); 3978 m_sceneGraph.removeUserCount(true);
3813 } 3979 }
@@ -3823,9 +3989,12 @@ namespace OpenSim.Region.Framework.Scenes
3823 } 3989 }
3824 else 3990 else
3825 presence.ControllingClient.SendShutdownConnectionNotice(); 3991 presence.ControllingClient.SendShutdownConnectionNotice();
3992 presence.ControllingClient.Close(false);
3993 }
3994 else if (!childOnly)
3995 {
3996 presence.ControllingClient.Close(true);
3826 } 3997 }
3827
3828 presence.ControllingClient.Close();
3829 return true; 3998 return true;
3830 } 3999 }
3831 4000
@@ -4420,34 +4589,66 @@ namespace OpenSim.Region.Framework.Scenes
4420 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4589 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4421 } 4590 }
4422 4591
4423 public int GetHealth() 4592 public int GetHealth(out int flags, out string message)
4424 { 4593 {
4425 // Returns: 4594 // Returns:
4426 // 1 = sim is up and accepting http requests. The heartbeat has 4595 // 1 = sim is up and accepting http requests. The heartbeat has
4427 // stopped and the sim is probably locked up, but a remote 4596 // stopped and the sim is probably locked up, but a remote
4428 // admin restart may succeed 4597 // admin restart may succeed
4429 // 4598 //
4430 // 2 = Sim is up and the heartbeat is running. The sim is likely 4599 // 2 = Sim is up and the heartbeat is running. The sim is likely
4431 // usable for people within and logins _may_ work 4600 // usable for people within
4601 //
4602 // 3 = Sim is up and one packet thread is running. Sim is
4603 // unstable and will not accept new logins
4604 //
4605 // 4 = Sim is up and both packet threads are running. Sim is
4606 // likely usable
4432 // 4607 //
4433 // 3 = We have seen a new user enter within the past 4 minutes 4608 // 5 = We have seen a new user enter within the past 4 minutes
4434 // which can be seen as positive confirmation of sim health 4609 // which can be seen as positive confirmation of sim health
4435 // 4610 //
4611
4612 flags = 0;
4613 message = String.Empty;
4614
4615 CheckHeartbeat();
4616
4617 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4618 {
4619 // We're still starting
4620 // 0 means "in startup", it can't happen another way, since
4621 // to get here, we must be able to accept http connections
4622 return 0;
4623 }
4624
4436 int health=1; // Start at 1, means we're up 4625 int health=1; // Start at 1, means we're up
4437 4626
4438 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4627 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4628 {
4439 health+=1; 4629 health+=1;
4440 else 4630 flags |= 1;
4631 }
4632
4633 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4634 {
4635 health+=1;
4636 flags |= 2;
4637 }
4638
4639 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4640 {
4641 health+=1;
4642 flags |= 4;
4643 }
4644
4645 if (flags != 7)
4441 return health; 4646 return health;
4442 4647
4443 // A login in the last 4 mins? We can't be doing too badly 4648 // A login in the last 4 mins? We can't be doing too badly
4444 // 4649 //
4445 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4650 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4446 health++; 4651 health++;
4447 else
4448 return health;
4449
4450 CheckHeartbeat();
4451 4652
4452 return health; 4653 return health;
4453 } 4654 }
@@ -4640,7 +4841,7 @@ namespace OpenSim.Region.Framework.Scenes
4640 if (m_firstHeartbeat) 4841 if (m_firstHeartbeat)
4641 return; 4842 return;
4642 4843
4643 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4844 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4644 StartTimer(); 4845 StartTimer();
4645 } 4846 }
4646 4847
@@ -5054,6 +5255,54 @@ namespace OpenSim.Region.Framework.Scenes
5054 } 5255 }
5055 } 5256 }
5056 5257
5258// public void CleanDroppedAttachments()
5259// {
5260// List<SceneObjectGroup> objectsToDelete =
5261// new List<SceneObjectGroup>();
5262//
5263// lock (m_cleaningAttachments)
5264// {
5265// ForEachSOG(delegate (SceneObjectGroup grp)
5266// {
5267// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5268// {
5269// UUID agentID = grp.OwnerID;
5270// if (agentID == UUID.Zero)
5271// {
5272// objectsToDelete.Add(grp);
5273// return;
5274// }
5275//
5276// ScenePresence sp = GetScenePresence(agentID);
5277// if (sp == null)
5278// {
5279// objectsToDelete.Add(grp);
5280// return;
5281// }
5282// }
5283// });
5284// }
5285//
5286// foreach (SceneObjectGroup grp in objectsToDelete)
5287// {
5288// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5289// DeleteSceneObject(grp, true);
5290// }
5291// }
5292
5293 public void ThreadAlive(int threadCode)
5294 {
5295 switch(threadCode)
5296 {
5297 case 1: // Incoming
5298 m_lastIncoming = Util.EnvironmentTickCount();
5299 break;
5300 case 2: // Incoming
5301 m_lastOutgoing = Util.EnvironmentTickCount();
5302 break;
5303 }
5304 }
5305
5057 // This method is called across the simulation connector to 5306 // This method is called across the simulation connector to
5058 // determine if a given agent is allowed in this region 5307 // determine if a given agent is allowed in this region
5059 // AS A ROOT AGENT. Returning false here will prevent them 5308 // AS A ROOT AGENT. Returning false here will prevent them
@@ -5062,6 +5311,14 @@ namespace OpenSim.Region.Framework.Scenes
5062 // child agent creation, thereby emulating the SL behavior. 5311 // child agent creation, thereby emulating the SL behavior.
5063 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5312 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5064 { 5313 {
5314 reason = "You are banned from the region";
5315
5316 if (Permissions.IsGod(agentID))
5317 {
5318 reason = String.Empty;
5319 return true;
5320 }
5321
5065 int num = m_sceneGraph.GetNumberOfScenePresences(); 5322 int num = m_sceneGraph.GetNumberOfScenePresences();
5066 5323
5067 if (num >= RegionInfo.RegionSettings.AgentLimit) 5324 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5073,11 +5330,82 @@ namespace OpenSim.Region.Framework.Scenes
5073 } 5330 }
5074 } 5331 }
5075 5332
5333 ScenePresence presence = GetScenePresence(agentID);
5334 IClientAPI client = null;
5335 AgentCircuitData aCircuit = null;
5336
5337 if (presence != null)
5338 {
5339 client = presence.ControllingClient;
5340 if (client != null)
5341 aCircuit = client.RequestClientInfo();
5342 }
5343
5344 // We may be called before there is a presence or a client.
5345 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5346 if (client == null)
5347 {
5348 aCircuit = new AgentCircuitData();
5349 aCircuit.AgentID = agentID;
5350 aCircuit.firstname = String.Empty;
5351 aCircuit.lastname = String.Empty;
5352 }
5353
5354 try
5355 {
5356 if (!AuthorizeUser(aCircuit, out reason))
5357 {
5358 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5359 return false;
5360 }
5361 }
5362 catch (Exception e)
5363 {
5364 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5365 return false;
5366 }
5367
5368 if (position == Vector3.Zero) // Teleport
5369 {
5370 float posX = 128.0f;
5371 float posY = 128.0f;
5372
5373 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5374 {
5375 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5376 return false;
5377 }
5378 }
5379 else // Walking
5380 {
5381 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5382 if (land == null)
5383 return false;
5384
5385 bool banned = land.IsBannedFromLand(agentID);
5386 bool restricted = land.IsRestrictedFromLand(agentID);
5387
5388 if (banned || restricted)
5389 return false;
5390 }
5391
5076 reason = String.Empty; 5392 reason = String.Empty;
5077 return true; 5393 return true;
5078 } 5394 }
5079 5395
5080 /// <summary> 5396 public void StartTimerWatchdog()
5397 {
5398 m_timerWatchdog.Interval = 1000;
5399 m_timerWatchdog.Elapsed += TimerWatchdog;
5400 m_timerWatchdog.AutoReset = true;
5401 m_timerWatchdog.Start();
5402 }
5403
5404 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5405 {
5406 CheckHeartbeat();
5407 }
5408
5081 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5409 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5082 /// autopilot that moves an avatar to a sit target!. 5410 /// autopilot that moves an avatar to a sit target!.
5083 /// </summary> 5411 /// </summary>