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.cs489
1 files changed, 416 insertions, 73 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index df6c88f..273d8bd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -104,6 +104,7 @@ namespace OpenSim.Region.Framework.Scenes
104 // TODO: need to figure out how allow client agents but deny 104 // TODO: need to figure out how allow client agents but deny
105 // root agents when ACL denies access to root agent 105 // root agents when ACL denies access to root agent
106 public bool m_strictAccessControl = true; 106 public bool m_strictAccessControl = true;
107 public bool m_seeIntoBannedRegion = false;
107 public int MaxUndoCount = 5; 108 public int MaxUndoCount = 5;
108 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 109 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
109 public bool LoginLock = false; 110 public bool LoginLock = false;
@@ -119,12 +120,14 @@ namespace OpenSim.Region.Framework.Scenes
119 120
120 protected int m_splitRegionID; 121 protected int m_splitRegionID;
121 protected Timer m_restartWaitTimer = new Timer(); 122 protected Timer m_restartWaitTimer = new Timer();
123 protected Timer m_timerWatchdog = new Timer();
122 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 124 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
123 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 125 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
124 protected string m_simulatorVersion = "OpenSimulator Server"; 126 protected string m_simulatorVersion = "OpenSimulator Server";
125 protected ModuleLoader m_moduleLoader; 127 protected ModuleLoader m_moduleLoader;
126 protected AgentCircuitManager m_authenticateHandler; 128 protected AgentCircuitManager m_authenticateHandler;
127 protected SceneCommunicationService m_sceneGridService; 129 protected SceneCommunicationService m_sceneGridService;
130 protected ISnmpModule m_snmpService = null;
128 131
129 protected ISimulationDataService m_SimulationDataService; 132 protected ISimulationDataService m_SimulationDataService;
130 protected IEstateDataService m_EstateDataService; 133 protected IEstateDataService m_EstateDataService;
@@ -177,7 +180,7 @@ namespace OpenSim.Region.Framework.Scenes
177 private int m_update_events = 1; 180 private int m_update_events = 1;
178 private int m_update_backup = 200; 181 private int m_update_backup = 200;
179 private int m_update_terrain = 50; 182 private int m_update_terrain = 50;
180// private int m_update_land = 1; 183 private int m_update_land = 10;
181 private int m_update_coarse_locations = 50; 184 private int m_update_coarse_locations = 50;
182 185
183 private int agentMS; 186 private int agentMS;
@@ -192,6 +195,7 @@ namespace OpenSim.Region.Framework.Scenes
192 private int landMS; 195 private int landMS;
193 private int lastCompletedFrame; 196 private int lastCompletedFrame;
194 197
198 public bool CombineRegions = false;
195 /// <summary> 199 /// <summary>
196 /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched 200 /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched
197 /// asynchronously from the update loop. 201 /// asynchronously from the update loop.
@@ -214,11 +218,14 @@ namespace OpenSim.Region.Framework.Scenes
214 private bool m_scripts_enabled = true; 218 private bool m_scripts_enabled = true;
215 private string m_defaultScriptEngine; 219 private string m_defaultScriptEngine;
216 private int m_LastLogin; 220 private int m_LastLogin;
217 private Thread HeartbeatThread; 221 private Thread HeartbeatThread = null;
218 private volatile bool shuttingdown; 222 private volatile bool shuttingdown;
219 223
220 private int m_lastUpdate; 224 private int m_lastUpdate;
225 private int m_lastIncoming;
226 private int m_lastOutgoing;
221 private bool m_firstHeartbeat = true; 227 private bool m_firstHeartbeat = true;
228 private int m_hbRestarts = 0;
222 229
223 private object m_deleting_scene_object = new object(); 230 private object m_deleting_scene_object = new object();
224 231
@@ -265,6 +272,19 @@ namespace OpenSim.Region.Framework.Scenes
265 get { return m_sceneGridService; } 272 get { return m_sceneGridService; }
266 } 273 }
267 274
275 public ISnmpModule SnmpService
276 {
277 get
278 {
279 if (m_snmpService == null)
280 {
281 m_snmpService = RequestModuleInterface<ISnmpModule>();
282 }
283
284 return m_snmpService;
285 }
286 }
287
268 public ISimulationDataService SimulationDataService 288 public ISimulationDataService SimulationDataService
269 { 289 {
270 get 290 get
@@ -546,6 +566,9 @@ namespace OpenSim.Region.Framework.Scenes
546 m_EstateDataService = estateDataService; 566 m_EstateDataService = estateDataService;
547 m_regionHandle = m_regInfo.RegionHandle; 567 m_regionHandle = m_regInfo.RegionHandle;
548 m_regionName = m_regInfo.RegionName; 568 m_regionName = m_regInfo.RegionName;
569 m_lastUpdate = Util.EnvironmentTickCount();
570 m_lastIncoming = 0;
571 m_lastOutgoing = 0;
549 572
550 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 573 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
551 m_asyncSceneObjectDeleter.Enabled = true; 574 m_asyncSceneObjectDeleter.Enabled = true;
@@ -646,6 +669,7 @@ namespace OpenSim.Region.Framework.Scenes
646 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); 669 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
647 670
648 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 671 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
672
649 if (RegionInfo.NonphysPrimMax > 0) 673 if (RegionInfo.NonphysPrimMax > 0)
650 { 674 {
651 m_maxNonphys = RegionInfo.NonphysPrimMax; 675 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -677,6 +701,7 @@ namespace OpenSim.Region.Framework.Scenes
677 m_persistAfter *= 10000000; 701 m_persistAfter *= 10000000;
678 702
679 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 703 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
704 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
680 705
681 IConfig packetConfig = m_config.Configs["PacketPool"]; 706 IConfig packetConfig = m_config.Configs["PacketPool"];
682 if (packetConfig != null) 707 if (packetConfig != null)
@@ -686,6 +711,8 @@ namespace OpenSim.Region.Framework.Scenes
686 } 711 }
687 712
688 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 713 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
714 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
715 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
689 716
690 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 717 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
691 if (m_generateMaptiles) 718 if (m_generateMaptiles)
@@ -721,9 +748,9 @@ namespace OpenSim.Region.Framework.Scenes
721 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); 748 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
722 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); 749 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
723 } 750 }
724 catch 751 catch (Exception e)
725 { 752 {
726 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 753 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
727 } 754 }
728 755
729 #endregion Region Config 756 #endregion Region Config
@@ -1134,7 +1161,22 @@ namespace OpenSim.Region.Framework.Scenes
1134 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1161 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1135 if (HeartbeatThread != null) 1162 if (HeartbeatThread != null)
1136 { 1163 {
1164 m_hbRestarts++;
1165 if(m_hbRestarts > 10)
1166 Environment.Exit(1);
1167 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1168
1169//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1170//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1171//proc.EnableRaisingEvents=false;
1172//proc.StartInfo.FileName = "/bin/kill";
1173//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1174//proc.Start();
1175//proc.WaitForExit();
1176//Thread.Sleep(1000);
1177//Environment.Exit(1);
1137 HeartbeatThread.Abort(); 1178 HeartbeatThread.Abort();
1179 Watchdog.AbortThread(HeartbeatThread.ManagedThreadId);
1138 HeartbeatThread = null; 1180 HeartbeatThread = null;
1139 } 1181 }
1140 m_lastUpdate = Util.EnvironmentTickCount(); 1182 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1181,9 +1223,6 @@ namespace OpenSim.Region.Framework.Scenes
1181 m_eventManager.TriggerOnRegionStarted(this); 1223 m_eventManager.TriggerOnRegionStarted(this);
1182 while (!shuttingdown) 1224 while (!shuttingdown)
1183 Update(); 1225 Update();
1184
1185 m_lastUpdate = Util.EnvironmentTickCount();
1186 m_firstHeartbeat = false;
1187 } 1226 }
1188 catch (ThreadAbortException) 1227 catch (ThreadAbortException)
1189 { 1228 {
@@ -1281,6 +1320,13 @@ namespace OpenSim.Region.Framework.Scenes
1281 eventMS = Util.EnvironmentTickCountSubtract(evMS); ; 1320 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1282 } 1321 }
1283 1322
1323 // if (Frame % m_update_land == 0)
1324 // {
1325 // int ldMS = Util.EnvironmentTickCount();
1326 // UpdateLand();
1327 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1328 // }
1329
1284 if (Frame % m_update_backup == 0) 1330 if (Frame % m_update_backup == 0)
1285 { 1331 {
1286 int backMS = Util.EnvironmentTickCount(); 1332 int backMS = Util.EnvironmentTickCount();
@@ -1388,12 +1434,16 @@ namespace OpenSim.Region.Framework.Scenes
1388 maintc = Util.EnvironmentTickCountSubtract(maintc); 1434 maintc = Util.EnvironmentTickCountSubtract(maintc);
1389 maintc = (int)(MinFrameTime * 1000) - maintc; 1435 maintc = (int)(MinFrameTime * 1000) - maintc;
1390 1436
1437
1438 m_lastUpdate = Util.EnvironmentTickCount();
1439 m_firstHeartbeat = false;
1440
1391 if (maintc > 0) 1441 if (maintc > 0)
1392 Thread.Sleep(maintc); 1442 Thread.Sleep(maintc);
1393 1443
1394 // Tell the watchdog that this thread is still alive 1444 // Tell the watchdog that this thread is still alive
1395 Watchdog.UpdateThread(); 1445 Watchdog.UpdateThread();
1396 } 1446 }
1397 1447
1398 public void AddGroupTarget(SceneObjectGroup grp) 1448 public void AddGroupTarget(SceneObjectGroup grp)
1399 { 1449 {
@@ -1409,9 +1459,9 @@ namespace OpenSim.Region.Framework.Scenes
1409 1459
1410 private void CheckAtTargets() 1460 private void CheckAtTargets()
1411 { 1461 {
1412 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1462 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1413 lock (m_groupsWithTargets) 1463 lock (m_groupsWithTargets)
1414 objs = m_groupsWithTargets.Values; 1464 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1415 1465
1416 foreach (SceneObjectGroup entry in objs) 1466 foreach (SceneObjectGroup entry in objs)
1417 entry.checkAtTargets(); 1467 entry.checkAtTargets();
@@ -1493,7 +1543,7 @@ namespace OpenSim.Region.Framework.Scenes
1493 msg.fromAgentName = "Server"; 1543 msg.fromAgentName = "Server";
1494 msg.dialog = (byte)19; // Object msg 1544 msg.dialog = (byte)19; // Object msg
1495 msg.fromGroup = false; 1545 msg.fromGroup = false;
1496 msg.offline = (byte)0; 1546 msg.offline = (byte)1;
1497 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1547 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1498 msg.Position = Vector3.Zero; 1548 msg.Position = Vector3.Zero;
1499 msg.RegionID = RegionInfo.RegionID.Guid; 1549 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1724,14 +1774,24 @@ namespace OpenSim.Region.Framework.Scenes
1724 /// <returns></returns> 1774 /// <returns></returns>
1725 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1775 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1726 { 1776 {
1777
1778 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1779 Vector3 wpos = Vector3.Zero;
1780 // Check for water surface intersection from above
1781 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1782 {
1783 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1784 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1785 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1786 wpos.Z = wheight;
1787 }
1788
1727 Vector3 pos = Vector3.Zero; 1789 Vector3 pos = Vector3.Zero;
1728 if (RayEndIsIntersection == (byte)1) 1790 if (RayEndIsIntersection == (byte)1)
1729 { 1791 {
1730 pos = RayEnd; 1792 pos = RayEnd;
1731 return pos;
1732 } 1793 }
1733 1794 else if (RayTargetID != UUID.Zero)
1734 if (RayTargetID != UUID.Zero)
1735 { 1795 {
1736 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1796 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1737 1797
@@ -1753,7 +1813,7 @@ namespace OpenSim.Region.Framework.Scenes
1753 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1813 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1754 1814
1755 // Un-comment out the following line to Get Raytrace results printed to the console. 1815 // 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()); 1816 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1757 float ScaleOffset = 0.5f; 1817 float ScaleOffset = 0.5f;
1758 1818
1759 // If we hit something 1819 // If we hit something
@@ -1776,13 +1836,10 @@ namespace OpenSim.Region.Framework.Scenes
1776 //pos.Z -= 0.25F; 1836 //pos.Z -= 0.25F;
1777 1837
1778 } 1838 }
1779
1780 return pos;
1781 } 1839 }
1782 else 1840 else
1783 { 1841 {
1784 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1842 // 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); 1843 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1787 1844
1788 // Un-comment the following line to print the raytrace results to the console. 1845 // Un-comment the following line to print the raytrace results to the console.
@@ -1791,13 +1848,12 @@ namespace OpenSim.Region.Framework.Scenes
1791 if (ei.HitTF) 1848 if (ei.HitTF)
1792 { 1849 {
1793 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1850 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1794 } else 1851 }
1852 else
1795 { 1853 {
1796 // fall back to our stupid functionality 1854 // fall back to our stupid functionality
1797 pos = RayEnd; 1855 pos = RayEnd;
1798 } 1856 }
1799
1800 return pos;
1801 } 1857 }
1802 } 1858 }
1803 else 1859 else
@@ -1808,8 +1864,12 @@ namespace OpenSim.Region.Framework.Scenes
1808 //increase height so its above the ground. 1864 //increase height so its above the ground.
1809 //should be getting the normal of the ground at the rez point and using that? 1865 //should be getting the normal of the ground at the rez point and using that?
1810 pos.Z += scale.Z / 2f; 1866 pos.Z += scale.Z / 2f;
1811 return pos; 1867// return pos;
1812 } 1868 }
1869
1870 // check against posible water intercept
1871 if (wpos.Z > pos.Z) pos = wpos;
1872 return pos;
1813 } 1873 }
1814 1874
1815 1875
@@ -1893,7 +1953,10 @@ namespace OpenSim.Region.Framework.Scenes
1893 public bool AddRestoredSceneObject( 1953 public bool AddRestoredSceneObject(
1894 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1954 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1895 { 1955 {
1896 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1956 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1957 if (result)
1958 sceneObject.IsDeleted = false;
1959 return result;
1897 } 1960 }
1898 1961
1899 /// <summary> 1962 /// <summary>
@@ -1985,6 +2048,15 @@ namespace OpenSim.Region.Framework.Scenes
1985 /// </summary> 2048 /// </summary>
1986 public void DeleteAllSceneObjects() 2049 public void DeleteAllSceneObjects()
1987 { 2050 {
2051 DeleteAllSceneObjects(false);
2052 }
2053
2054 /// <summary>
2055 /// Delete every object from the scene. This does not include attachments worn by avatars.
2056 /// </summary>
2057 public void DeleteAllSceneObjects(bool exceptNoCopy)
2058 {
2059 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1988 lock (Entities) 2060 lock (Entities)
1989 { 2061 {
1990 EntityBase[] entities = Entities.GetEntities(); 2062 EntityBase[] entities = Entities.GetEntities();
@@ -1993,11 +2065,24 @@ namespace OpenSim.Region.Framework.Scenes
1993 if (e is SceneObjectGroup) 2065 if (e is SceneObjectGroup)
1994 { 2066 {
1995 SceneObjectGroup sog = (SceneObjectGroup)e; 2067 SceneObjectGroup sog = (SceneObjectGroup)e;
1996 if (!sog.IsAttachment) 2068 if (sog != null && !sog.IsAttachment)
1997 DeleteSceneObject((SceneObjectGroup)e, false); 2069 {
2070 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2071 {
2072 DeleteSceneObject((SceneObjectGroup)e, false);
2073 }
2074 else
2075 {
2076 toReturn.Add((SceneObjectGroup)e);
2077 }
2078 }
1998 } 2079 }
1999 } 2080 }
2000 } 2081 }
2082 if (toReturn.Count > 0)
2083 {
2084 returnObjects(toReturn.ToArray(), UUID.Zero);
2085 }
2001 } 2086 }
2002 2087
2003 /// <summary> 2088 /// <summary>
@@ -2045,6 +2130,8 @@ namespace OpenSim.Region.Framework.Scenes
2045 } 2130 }
2046 2131
2047 group.DeleteGroupFromScene(silent); 2132 group.DeleteGroupFromScene(silent);
2133 if (!silent)
2134 SendKillObject(new List<uint>() { group.LocalId });
2048 2135
2049// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2136// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2050 } 2137 }
@@ -2399,10 +2486,17 @@ namespace OpenSim.Region.Framework.Scenes
2399 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2486 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2400 public bool AddSceneObject(SceneObjectGroup sceneObject) 2487 public bool AddSceneObject(SceneObjectGroup sceneObject)
2401 { 2488 {
2489 if (sceneObject.OwnerID == UUID.Zero)
2490 {
2491 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2492 return false;
2493 }
2494
2402 // If the user is banned, we won't let any of their objects 2495 // If the user is banned, we won't let any of their objects
2403 // enter. Period. 2496 // enter. Period.
2404 // 2497 //
2405 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2498 int flags = GetUserFlags(sceneObject.OwnerID);
2499 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2406 { 2500 {
2407 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); 2501 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2408 2502
@@ -2448,12 +2542,23 @@ namespace OpenSim.Region.Framework.Scenes
2448 } 2542 }
2449 else 2543 else
2450 { 2544 {
2545 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2451 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2546 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2452 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2547 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2453 } 2548 }
2549 if (sceneObject.OwnerID == UUID.Zero)
2550 {
2551 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2552 return false;
2553 }
2454 } 2554 }
2455 else 2555 else
2456 { 2556 {
2557 if (sceneObject.OwnerID == UUID.Zero)
2558 {
2559 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2560 return false;
2561 }
2457 AddRestoredSceneObject(sceneObject, true, false); 2562 AddRestoredSceneObject(sceneObject, true, false);
2458 2563
2459 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2564 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2482,6 +2587,24 @@ namespace OpenSim.Region.Framework.Scenes
2482 return 2; // StateSource.PrimCrossing 2587 return 2; // StateSource.PrimCrossing
2483 } 2588 }
2484 2589
2590 public int GetUserFlags(UUID user)
2591 {
2592 //Unfortunately the SP approach means that the value is cached until region is restarted
2593 /*
2594 ScenePresence sp;
2595 if (TryGetScenePresence(user, out sp))
2596 {
2597 return sp.UserFlags;
2598 }
2599 else
2600 {
2601 */
2602 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2603 if (uac == null)
2604 return 0;
2605 return uac.UserFlags;
2606 //}
2607 }
2485 #endregion 2608 #endregion
2486 2609
2487 #region Add/Remove Avatar Methods 2610 #region Add/Remove Avatar Methods
@@ -2496,6 +2619,7 @@ namespace OpenSim.Region.Framework.Scenes
2496 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2619 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2497 2620
2498 CheckHeartbeat(); 2621 CheckHeartbeat();
2622 ScenePresence presence;
2499 2623
2500 ScenePresence sp = GetScenePresence(client.AgentId); 2624 ScenePresence sp = GetScenePresence(client.AgentId);
2501 2625
@@ -2544,7 +2668,13 @@ namespace OpenSim.Region.Framework.Scenes
2544 2668
2545 EventManager.TriggerOnNewClient(client); 2669 EventManager.TriggerOnNewClient(client);
2546 if (vialogin) 2670 if (vialogin)
2671 {
2547 EventManager.TriggerOnClientLogin(client); 2672 EventManager.TriggerOnClientLogin(client);
2673 // Send initial parcel data
2674 Vector3 pos = sp.AbsolutePosition;
2675 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2676 land.SendLandUpdateToClient(client);
2677 }
2548 2678
2549 return sp; 2679 return sp;
2550 } 2680 }
@@ -2634,19 +2764,12 @@ namespace OpenSim.Region.Framework.Scenes
2634 // and the scene presence and the client, if they exist 2764 // and the scene presence and the client, if they exist
2635 try 2765 try
2636 { 2766 {
2637 // We need to wait for the client to make UDP contact first. 2767 ScenePresence sp = GetScenePresence(agentID);
2638 // It's the UDP contact that creates the scene presence 2768 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2639 ScenePresence sp = WaitGetScenePresence(agentID); 2769
2640 if (sp != null) 2770 if (sp != null)
2641 {
2642 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2643
2644 sp.ControllingClient.Close(); 2771 sp.ControllingClient.Close();
2645 } 2772
2646 else
2647 {
2648 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2649 }
2650 // BANG! SLASH! 2773 // BANG! SLASH!
2651 m_authenticateHandler.RemoveCircuit(agentID); 2774 m_authenticateHandler.RemoveCircuit(agentID);
2652 2775
@@ -2747,6 +2870,7 @@ namespace OpenSim.Region.Framework.Scenes
2747 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2870 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2748 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2871 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2749 client.OnCopyInventoryItem += CopyInventoryItem; 2872 client.OnCopyInventoryItem += CopyInventoryItem;
2873 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2750 client.OnMoveInventoryItem += MoveInventoryItem; 2874 client.OnMoveInventoryItem += MoveInventoryItem;
2751 client.OnRemoveInventoryItem += RemoveInventoryItem; 2875 client.OnRemoveInventoryItem += RemoveInventoryItem;
2752 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2876 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2922,15 +3046,16 @@ namespace OpenSim.Region.Framework.Scenes
2922 /// </summary> 3046 /// </summary>
2923 /// <param name="agentId">The avatar's Unique ID</param> 3047 /// <param name="agentId">The avatar's Unique ID</param>
2924 /// <param name="client">The IClientAPI for the client</param> 3048 /// <param name="client">The IClientAPI for the client</param>
2925 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3049 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2926 { 3050 {
2927 if (m_teleportModule != null) 3051 if (m_teleportModule != null)
2928 m_teleportModule.TeleportHome(agentId, client); 3052 return m_teleportModule.TeleportHome(agentId, client);
2929 else 3053 else
2930 { 3054 {
2931 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3055 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2932 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3056 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2933 } 3057 }
3058 return false;
2934 } 3059 }
2935 3060
2936 /// <summary> 3061 /// <summary>
@@ -3022,6 +3147,16 @@ namespace OpenSim.Region.Framework.Scenes
3022 /// <param name="flags"></param> 3147 /// <param name="flags"></param>
3023 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3148 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3024 { 3149 {
3150 //Add half the avatar's height so that the user doesn't fall through prims
3151 ScenePresence presence;
3152 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3153 {
3154 if (presence.Appearance != null)
3155 {
3156 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3157 }
3158 }
3159
3025 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3160 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3026 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3161 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3027 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3162 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3090,8 +3225,9 @@ namespace OpenSim.Region.Framework.Scenes
3090 regions.Remove(RegionInfo.RegionHandle); 3225 regions.Remove(RegionInfo.RegionHandle);
3091 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3226 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3092 } 3227 }
3093 3228 m_log.Debug("[Scene] Beginning ClientClosed");
3094 m_eventManager.TriggerClientClosed(agentID, this); 3229 m_eventManager.TriggerClientClosed(agentID, this);
3230 m_log.Debug("[Scene] Finished ClientClosed");
3095 } 3231 }
3096 catch (NullReferenceException) 3232 catch (NullReferenceException)
3097 { 3233 {
@@ -3143,9 +3279,10 @@ namespace OpenSim.Region.Framework.Scenes
3143 { 3279 {
3144 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); 3280 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace);
3145 } 3281 }
3146 3282 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3147 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3283 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3148// CleanDroppedAttachments(); 3284// CleanDroppedAttachments();
3285 m_log.Debug("[Scene] The avatar has left the building");
3149 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3286 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3150 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3287 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3151 } 3288 }
@@ -3264,13 +3401,16 @@ namespace OpenSim.Region.Framework.Scenes
3264 sp = null; 3401 sp = null;
3265 } 3402 }
3266 3403
3267 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3268 3404
3269 //On login test land permisions 3405 //On login test land permisions
3270 if (vialogin) 3406 if (vialogin)
3271 { 3407 {
3272 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3408 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3409 if (cache != null)
3410 cache.Remove(agent.firstname + " " + agent.lastname);
3411 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3273 { 3412 {
3413 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3274 return false; 3414 return false;
3275 } 3415 }
3276 } 3416 }
@@ -3294,8 +3434,13 @@ namespace OpenSim.Region.Framework.Scenes
3294 3434
3295 try 3435 try
3296 { 3436 {
3297 if (!AuthorizeUser(agent, out reason)) 3437 // Always check estate if this is a login. Always
3298 return false; 3438 // check if banned regions are to be blacked out.
3439 if (vialogin || (!m_seeIntoBannedRegion))
3440 {
3441 if (!AuthorizeUser(agent, out reason))
3442 return false;
3443 }
3299 } 3444 }
3300 catch (Exception e) 3445 catch (Exception e)
3301 { 3446 {
@@ -3398,6 +3543,8 @@ namespace OpenSim.Region.Framework.Scenes
3398 } 3543 }
3399 } 3544 }
3400 // Honor parcel landing type and position. 3545 // Honor parcel landing type and position.
3546 /*
3547 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3401 if (land != null) 3548 if (land != null)
3402 { 3549 {
3403 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3550 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3405,26 +3552,34 @@ namespace OpenSim.Region.Framework.Scenes
3405 agent.startpos = land.LandData.UserLocation; 3552 agent.startpos = land.LandData.UserLocation;
3406 } 3553 }
3407 } 3554 }
3555 */// This is now handled properly in ScenePresence.MakeRootAgent
3408 } 3556 }
3409 3557
3410 return true; 3558 return true;
3411 } 3559 }
3412 3560
3413 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3561 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3414 { 3562 {
3415 3563 reason = String.Empty;
3416 bool banned = land.IsBannedFromLand(agent.AgentID); 3564 if (Permissions.IsGod(agentID))
3417 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3565 return true;
3566
3567 ILandObject land = LandChannel.GetLandObject(posX, posY);
3568 if (land == null)
3569 return false;
3570
3571 bool banned = land.IsBannedFromLand(agentID);
3572 bool restricted = land.IsRestrictedFromLand(agentID);
3418 3573
3419 if (banned || restricted) 3574 if (banned || restricted)
3420 { 3575 {
3421 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3576 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3422 if (nearestParcel != null) 3577 if (nearestParcel != null)
3423 { 3578 {
3424 //Move agent to nearest allowed 3579 //Move agent to nearest allowed
3425 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3580 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3426 agent.startpos.X = newPosition.X; 3581 posX = newPosition.X;
3427 agent.startpos.Y = newPosition.Y; 3582 posY = newPosition.Y;
3428 } 3583 }
3429 else 3584 else
3430 { 3585 {
@@ -3486,7 +3641,7 @@ namespace OpenSim.Region.Framework.Scenes
3486 3641
3487 if (!m_strictAccessControl) return true; 3642 if (!m_strictAccessControl) return true;
3488 if (Permissions.IsGod(agent.AgentID)) return true; 3643 if (Permissions.IsGod(agent.AgentID)) return true;
3489 3644
3490 if (AuthorizationService != null) 3645 if (AuthorizationService != null)
3491 { 3646 {
3492 if (!AuthorizationService.IsAuthorizedForRegion( 3647 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3494,14 +3649,14 @@ namespace OpenSim.Region.Framework.Scenes
3494 { 3649 {
3495 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3650 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3496 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3651 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3497 3652
3498 return false; 3653 return false;
3499 } 3654 }
3500 } 3655 }
3501 3656
3502 if (m_regInfo.EstateSettings != null) 3657 if (m_regInfo.EstateSettings != null)
3503 { 3658 {
3504 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3659 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3505 { 3660 {
3506 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3661 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3507 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3662 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3693,6 +3848,13 @@ namespace OpenSim.Region.Framework.Scenes
3693 3848
3694 // We have to wait until the viewer contacts this region after receiving EAC. 3849 // We have to wait until the viewer contacts this region after receiving EAC.
3695 // That calls AddNewClient, which finally creates the ScenePresence 3850 // That calls AddNewClient, which finally creates the ScenePresence
3851 int flags = GetUserFlags(cAgentData.AgentID);
3852 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3853 {
3854 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3855 return false;
3856 }
3857
3696 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3858 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3697 if (nearestParcel == null) 3859 if (nearestParcel == null)
3698 { 3860 {
@@ -3774,12 +3936,22 @@ namespace OpenSim.Region.Framework.Scenes
3774 return false; 3936 return false;
3775 } 3937 }
3776 3938
3939 public bool IncomingCloseAgent(UUID agentID)
3940 {
3941 return IncomingCloseAgent(agentID, false);
3942 }
3943
3944 public bool IncomingCloseChildAgent(UUID agentID)
3945 {
3946 return IncomingCloseAgent(agentID, true);
3947 }
3948
3777 /// <summary> 3949 /// <summary>
3778 /// Tell a single agent to disconnect from the region. 3950 /// Tell a single agent to disconnect from the region.
3779 /// </summary> 3951 /// </summary>
3780 /// <param name="regionHandle"></param>
3781 /// <param name="agentID"></param> 3952 /// <param name="agentID"></param>
3782 public bool IncomingCloseAgent(UUID agentID) 3953 /// <param name="childOnly"></param>
3954 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3783 { 3955 {
3784 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3956 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3785 3957
@@ -3791,7 +3963,7 @@ namespace OpenSim.Region.Framework.Scenes
3791 { 3963 {
3792 m_sceneGraph.removeUserCount(false); 3964 m_sceneGraph.removeUserCount(false);
3793 } 3965 }
3794 else 3966 else if (!childOnly)
3795 { 3967 {
3796 m_sceneGraph.removeUserCount(true); 3968 m_sceneGraph.removeUserCount(true);
3797 } 3969 }
@@ -3807,9 +3979,12 @@ namespace OpenSim.Region.Framework.Scenes
3807 } 3979 }
3808 else 3980 else
3809 presence.ControllingClient.SendShutdownConnectionNotice(); 3981 presence.ControllingClient.SendShutdownConnectionNotice();
3982 presence.ControllingClient.Close(false);
3983 }
3984 else if (!childOnly)
3985 {
3986 presence.ControllingClient.Close(true);
3810 } 3987 }
3811
3812 presence.ControllingClient.Close();
3813 return true; 3988 return true;
3814 } 3989 }
3815 3990
@@ -4392,34 +4567,78 @@ namespace OpenSim.Region.Framework.Scenes
4392 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4567 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4393 } 4568 }
4394 4569
4395 public int GetHealth() 4570 public int GetHealth(out int flags, out string message)
4396 { 4571 {
4397 // Returns: 4572 // Returns:
4398 // 1 = sim is up and accepting http requests. The heartbeat has 4573 // 1 = sim is up and accepting http requests. The heartbeat has
4399 // stopped and the sim is probably locked up, but a remote 4574 // stopped and the sim is probably locked up, but a remote
4400 // admin restart may succeed 4575 // admin restart may succeed
4401 // 4576 //
4402 // 2 = Sim is up and the heartbeat is running. The sim is likely 4577 // 2 = Sim is up and the heartbeat is running. The sim is likely
4403 // usable for people within and logins _may_ work 4578 // usable for people within
4579 //
4580 // 3 = Sim is up and one packet thread is running. Sim is
4581 // unstable and will not accept new logins
4404 // 4582 //
4405 // 3 = We have seen a new user enter within the past 4 minutes 4583 // 4 = Sim is up and both packet threads are running. Sim is
4584 // likely usable
4585 //
4586 // 5 = We have seen a new user enter within the past 4 minutes
4406 // which can be seen as positive confirmation of sim health 4587 // which can be seen as positive confirmation of sim health
4407 // 4588 //
4589
4590 flags = 0;
4591 message = String.Empty;
4592
4593 CheckHeartbeat();
4594
4595 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4596 {
4597 // We're still starting
4598 // 0 means "in startup", it can't happen another way, since
4599 // to get here, we must be able to accept http connections
4600 return 0;
4601 }
4602
4408 int health=1; // Start at 1, means we're up 4603 int health=1; // Start at 1, means we're up
4409 4604
4410 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4605 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4606 {
4411 health+=1; 4607 health+=1;
4608 flags |= 1;
4609 }
4610
4611 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4612 {
4613 health+=1;
4614 flags |= 2;
4615 }
4616
4617 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4618 {
4619 health+=1;
4620 flags |= 4;
4621 }
4412 else 4622 else
4623 {
4624int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
4625System.Diagnostics.Process proc = new System.Diagnostics.Process();
4626proc.EnableRaisingEvents=false;
4627proc.StartInfo.FileName = "/bin/kill";
4628proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
4629proc.Start();
4630proc.WaitForExit();
4631Thread.Sleep(1000);
4632Environment.Exit(1);
4633 }
4634
4635 if (flags != 7)
4413 return health; 4636 return health;
4414 4637
4415 // A login in the last 4 mins? We can't be doing too badly 4638 // A login in the last 4 mins? We can't be doing too badly
4416 // 4639 //
4417 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4640 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4418 health++; 4641 health++;
4419 else
4420 return health;
4421
4422 CheckHeartbeat();
4423 4642
4424 return health; 4643 return health;
4425 } 4644 }
@@ -4612,7 +4831,7 @@ namespace OpenSim.Region.Framework.Scenes
4612 if (m_firstHeartbeat) 4831 if (m_firstHeartbeat)
4613 return; 4832 return;
4614 4833
4615 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4834 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4616 StartTimer(); 4835 StartTimer();
4617 } 4836 }
4618 4837
@@ -4935,7 +5154,55 @@ namespace OpenSim.Region.Framework.Scenes
4935 mapModule.GenerateMaptile(); 5154 mapModule.GenerateMaptile();
4936 } 5155 }
4937 5156
4938 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5157// public void CleanDroppedAttachments()
5158// {
5159// List<SceneObjectGroup> objectsToDelete =
5160// new List<SceneObjectGroup>();
5161//
5162// lock (m_cleaningAttachments)
5163// {
5164// ForEachSOG(delegate (SceneObjectGroup grp)
5165// {
5166// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5167// {
5168// UUID agentID = grp.OwnerID;
5169// if (agentID == UUID.Zero)
5170// {
5171// objectsToDelete.Add(grp);
5172// return;
5173// }
5174//
5175// ScenePresence sp = GetScenePresence(agentID);
5176// if (sp == null)
5177// {
5178// objectsToDelete.Add(grp);
5179// return;
5180// }
5181// }
5182// });
5183// }
5184//
5185// foreach (SceneObjectGroup grp in objectsToDelete)
5186// {
5187// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5188// DeleteSceneObject(grp, true);
5189// }
5190// }
5191
5192 public void ThreadAlive(int threadCode)
5193 {
5194 switch(threadCode)
5195 {
5196 case 1: // Incoming
5197 m_lastIncoming = Util.EnvironmentTickCount();
5198 break;
5199 case 2: // Incoming
5200 m_lastOutgoing = Util.EnvironmentTickCount();
5201 break;
5202 }
5203 }
5204
5205 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
4939 { 5206 {
4940 RegenerateMaptile(); 5207 RegenerateMaptile();
4941 5208
@@ -4954,6 +5221,14 @@ namespace OpenSim.Region.Framework.Scenes
4954 // child agent creation, thereby emulating the SL behavior. 5221 // child agent creation, thereby emulating the SL behavior.
4955 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5222 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
4956 { 5223 {
5224 reason = "You are banned from the region";
5225
5226 if (Permissions.IsGod(agentID))
5227 {
5228 reason = String.Empty;
5229 return true;
5230 }
5231
4957 int num = m_sceneGraph.GetNumberOfScenePresences(); 5232 int num = m_sceneGraph.GetNumberOfScenePresences();
4958 5233
4959 if (num >= RegionInfo.RegionSettings.AgentLimit) 5234 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -4965,6 +5240,41 @@ namespace OpenSim.Region.Framework.Scenes
4965 } 5240 }
4966 } 5241 }
4967 5242
5243 ScenePresence presence = GetScenePresence(agentID);
5244 IClientAPI client = null;
5245 AgentCircuitData aCircuit = null;
5246
5247 if (presence != null)
5248 {
5249 client = presence.ControllingClient;
5250 if (client != null)
5251 aCircuit = client.RequestClientInfo();
5252 }
5253
5254 // We may be called before there is a presence or a client.
5255 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5256 if (client == null)
5257 {
5258 aCircuit = new AgentCircuitData();
5259 aCircuit.AgentID = agentID;
5260 aCircuit.firstname = String.Empty;
5261 aCircuit.lastname = String.Empty;
5262 }
5263
5264 try
5265 {
5266 if (!AuthorizeUser(aCircuit, out reason))
5267 {
5268 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5269 return false;
5270 }
5271 }
5272 catch (Exception e)
5273 {
5274 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5275 return false;
5276 }
5277
4968 if (position == Vector3.Zero) // Teleport 5278 if (position == Vector3.Zero) // Teleport
4969 { 5279 {
4970 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5280 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -4993,13 +5303,46 @@ namespace OpenSim.Region.Framework.Scenes
4993 } 5303 }
4994 } 5304 }
4995 } 5305 }
5306
5307 float posX = 128.0f;
5308 float posY = 128.0f;
5309
5310 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5311 {
5312 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5313 return false;
5314 }
5315 }
5316 else // Walking
5317 {
5318 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5319 if (land == null)
5320 return false;
5321
5322 bool banned = land.IsBannedFromLand(agentID);
5323 bool restricted = land.IsRestrictedFromLand(agentID);
5324
5325 if (banned || restricted)
5326 return false;
4996 } 5327 }
4997 5328
4998 reason = String.Empty; 5329 reason = String.Empty;
4999 return true; 5330 return true;
5000 } 5331 }
5001 5332
5002 /// <summary> 5333 public void StartTimerWatchdog()
5334 {
5335 m_timerWatchdog.Interval = 1000;
5336 m_timerWatchdog.Elapsed += TimerWatchdog;
5337 m_timerWatchdog.AutoReset = true;
5338 m_timerWatchdog.Start();
5339 }
5340
5341 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5342 {
5343 CheckHeartbeat();
5344 }
5345
5003 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5346 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5004 /// autopilot that moves an avatar to a sit target!. 5347 /// autopilot that moves an avatar to a sit target!.
5005 /// </summary> 5348 /// </summary>