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.cs490
1 files changed, 418 insertions, 72 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 6666328..c2ba893 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;
@@ -168,7 +171,7 @@ namespace OpenSim.Region.Framework.Scenes
168 private int m_update_events = 1; 171 private int m_update_events = 1;
169 private int m_update_backup = 200; 172 private int m_update_backup = 200;
170 private int m_update_terrain = 50; 173 private int m_update_terrain = 50;
171// private int m_update_land = 1; 174 private int m_update_land = 10;
172 private int m_update_coarse_locations = 50; 175 private int m_update_coarse_locations = 50;
173 176
174 private int agentMS; 177 private int agentMS;
@@ -183,6 +186,7 @@ namespace OpenSim.Region.Framework.Scenes
183 private int landMS; 186 private int landMS;
184 private int lastCompletedFrame; 187 private int lastCompletedFrame;
185 188
189 public bool CombineRegions = false;
186 /// <summary> 190 /// <summary>
187 /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched 191 /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched
188 /// asynchronously from the update loop. 192 /// asynchronously from the update loop.
@@ -205,11 +209,14 @@ namespace OpenSim.Region.Framework.Scenes
205 private bool m_scripts_enabled = true; 209 private bool m_scripts_enabled = true;
206 private string m_defaultScriptEngine; 210 private string m_defaultScriptEngine;
207 private int m_LastLogin; 211 private int m_LastLogin;
208 private Thread HeartbeatThread; 212 private Thread HeartbeatThread = null;
209 private volatile bool shuttingdown; 213 private volatile bool shuttingdown;
210 214
211 private int m_lastUpdate; 215 private int m_lastUpdate;
216 private int m_lastIncoming;
217 private int m_lastOutgoing;
212 private bool m_firstHeartbeat = true; 218 private bool m_firstHeartbeat = true;
219 private int m_hbRestarts = 0;
213 220
214 private object m_deleting_scene_object = new object(); 221 private object m_deleting_scene_object = new object();
215 222
@@ -256,6 +263,19 @@ namespace OpenSim.Region.Framework.Scenes
256 get { return m_sceneGridService; } 263 get { return m_sceneGridService; }
257 } 264 }
258 265
266 public ISnmpModule SnmpService
267 {
268 get
269 {
270 if (m_snmpService == null)
271 {
272 m_snmpService = RequestModuleInterface<ISnmpModule>();
273 }
274
275 return m_snmpService;
276 }
277 }
278
259 public ISimulationDataService SimulationDataService 279 public ISimulationDataService SimulationDataService
260 { 280 {
261 get 281 get
@@ -537,6 +557,9 @@ namespace OpenSim.Region.Framework.Scenes
537 m_EstateDataService = estateDataService; 557 m_EstateDataService = estateDataService;
538 m_regionHandle = m_regInfo.RegionHandle; 558 m_regionHandle = m_regInfo.RegionHandle;
539 m_regionName = m_regInfo.RegionName; 559 m_regionName = m_regInfo.RegionName;
560 m_lastUpdate = Util.EnvironmentTickCount();
561 m_lastIncoming = 0;
562 m_lastOutgoing = 0;
540 563
541 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 564 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
542 m_asyncSceneObjectDeleter.Enabled = true; 565 m_asyncSceneObjectDeleter.Enabled = true;
@@ -653,6 +676,7 @@ namespace OpenSim.Region.Framework.Scenes
653 m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); 676 m_physicalPrim = startupConfig.GetBoolean("physical_prim", true);
654 677
655 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 678 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
679
656 if (RegionInfo.NonphysPrimMax > 0) 680 if (RegionInfo.NonphysPrimMax > 0)
657 { 681 {
658 m_maxNonphys = RegionInfo.NonphysPrimMax; 682 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -684,6 +708,7 @@ namespace OpenSim.Region.Framework.Scenes
684 m_persistAfter *= 10000000; 708 m_persistAfter *= 10000000;
685 709
686 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 710 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
711 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
687 712
688 IConfig packetConfig = m_config.Configs["PacketPool"]; 713 IConfig packetConfig = m_config.Configs["PacketPool"];
689 if (packetConfig != null) 714 if (packetConfig != null)
@@ -693,6 +718,8 @@ namespace OpenSim.Region.Framework.Scenes
693 } 718 }
694 719
695 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 720 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
721 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
722 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
696 723
697 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 724 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
698 if (m_generateMaptiles) 725 if (m_generateMaptiles)
@@ -728,9 +755,9 @@ namespace OpenSim.Region.Framework.Scenes
728 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); 755 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
729 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); 756 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
730 } 757 }
731 catch 758 catch (Exception e)
732 { 759 {
733 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 760 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
734 } 761 }
735 762
736 #endregion Region Config 763 #endregion Region Config
@@ -1141,7 +1168,22 @@ namespace OpenSim.Region.Framework.Scenes
1141 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1168 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1142 if (HeartbeatThread != null) 1169 if (HeartbeatThread != null)
1143 { 1170 {
1171 m_hbRestarts++;
1172 if(m_hbRestarts > 10)
1173 Environment.Exit(1);
1174 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1175
1176//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1177//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1178//proc.EnableRaisingEvents=false;
1179//proc.StartInfo.FileName = "/bin/kill";
1180//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1181//proc.Start();
1182//proc.WaitForExit();
1183//Thread.Sleep(1000);
1184//Environment.Exit(1);
1144 HeartbeatThread.Abort(); 1185 HeartbeatThread.Abort();
1186 Watchdog.AbortThread(HeartbeatThread.ManagedThreadId);
1145 HeartbeatThread = null; 1187 HeartbeatThread = null;
1146 } 1188 }
1147 m_lastUpdate = Util.EnvironmentTickCount(); 1189 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1187,9 +1229,6 @@ namespace OpenSim.Region.Framework.Scenes
1187 { 1229 {
1188 while (!shuttingdown) 1230 while (!shuttingdown)
1189 Update(); 1231 Update();
1190
1191 m_lastUpdate = Util.EnvironmentTickCount();
1192 m_firstHeartbeat = false;
1193 } 1232 }
1194 catch (ThreadAbortException) 1233 catch (ThreadAbortException)
1195 { 1234 {
@@ -1287,6 +1326,13 @@ namespace OpenSim.Region.Framework.Scenes
1287 eventMS = Util.EnvironmentTickCountSubtract(evMS); ; 1326 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1288 } 1327 }
1289 1328
1329 // if (Frame % m_update_land == 0)
1330 // {
1331 // int ldMS = Util.EnvironmentTickCount();
1332 // UpdateLand();
1333 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1334 // }
1335
1290 if (Frame % m_update_backup == 0) 1336 if (Frame % m_update_backup == 0)
1291 { 1337 {
1292 int backMS = Util.EnvironmentTickCount(); 1338 int backMS = Util.EnvironmentTickCount();
@@ -1394,12 +1440,16 @@ namespace OpenSim.Region.Framework.Scenes
1394 maintc = Util.EnvironmentTickCountSubtract(maintc); 1440 maintc = Util.EnvironmentTickCountSubtract(maintc);
1395 maintc = (int)(MinFrameTime * 1000) - maintc; 1441 maintc = (int)(MinFrameTime * 1000) - maintc;
1396 1442
1443
1444 m_lastUpdate = Util.EnvironmentTickCount();
1445 m_firstHeartbeat = false;
1446
1397 if (maintc > 0) 1447 if (maintc > 0)
1398 Thread.Sleep(maintc); 1448 Thread.Sleep(maintc);
1399 1449
1400 // Tell the watchdog that this thread is still alive 1450 // Tell the watchdog that this thread is still alive
1401 Watchdog.UpdateThread(); 1451 Watchdog.UpdateThread();
1402 } 1452 }
1403 1453
1404 public void AddGroupTarget(SceneObjectGroup grp) 1454 public void AddGroupTarget(SceneObjectGroup grp)
1405 { 1455 {
@@ -1415,9 +1465,9 @@ namespace OpenSim.Region.Framework.Scenes
1415 1465
1416 private void CheckAtTargets() 1466 private void CheckAtTargets()
1417 { 1467 {
1418 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1468 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1419 lock (m_groupsWithTargets) 1469 lock (m_groupsWithTargets)
1420 objs = m_groupsWithTargets.Values; 1470 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1421 1471
1422 foreach (SceneObjectGroup entry in objs) 1472 foreach (SceneObjectGroup entry in objs)
1423 entry.checkAtTargets(); 1473 entry.checkAtTargets();
@@ -1499,7 +1549,7 @@ namespace OpenSim.Region.Framework.Scenes
1499 msg.fromAgentName = "Server"; 1549 msg.fromAgentName = "Server";
1500 msg.dialog = (byte)19; // Object msg 1550 msg.dialog = (byte)19; // Object msg
1501 msg.fromGroup = false; 1551 msg.fromGroup = false;
1502 msg.offline = (byte)0; 1552 msg.offline = (byte)1;
1503 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1553 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1504 msg.Position = Vector3.Zero; 1554 msg.Position = Vector3.Zero;
1505 msg.RegionID = RegionInfo.RegionID.Guid; 1555 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1734,14 +1784,24 @@ namespace OpenSim.Region.Framework.Scenes
1734 /// <returns></returns> 1784 /// <returns></returns>
1735 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1785 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1736 { 1786 {
1787
1788 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1789 Vector3 wpos = Vector3.Zero;
1790 // Check for water surface intersection from above
1791 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1792 {
1793 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1794 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1795 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1796 wpos.Z = wheight;
1797 }
1798
1737 Vector3 pos = Vector3.Zero; 1799 Vector3 pos = Vector3.Zero;
1738 if (RayEndIsIntersection == (byte)1) 1800 if (RayEndIsIntersection == (byte)1)
1739 { 1801 {
1740 pos = RayEnd; 1802 pos = RayEnd;
1741 return pos;
1742 } 1803 }
1743 1804 else if (RayTargetID != UUID.Zero)
1744 if (RayTargetID != UUID.Zero)
1745 { 1805 {
1746 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1806 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1747 1807
@@ -1763,7 +1823,7 @@ namespace OpenSim.Region.Framework.Scenes
1763 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1823 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1764 1824
1765 // Un-comment out the following line to Get Raytrace results printed to the console. 1825 // Un-comment out the following line to Get Raytrace results printed to the console.
1766 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1826 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1767 float ScaleOffset = 0.5f; 1827 float ScaleOffset = 0.5f;
1768 1828
1769 // If we hit something 1829 // If we hit something
@@ -1786,13 +1846,10 @@ namespace OpenSim.Region.Framework.Scenes
1786 //pos.Z -= 0.25F; 1846 //pos.Z -= 0.25F;
1787 1847
1788 } 1848 }
1789
1790 return pos;
1791 } 1849 }
1792 else 1850 else
1793 { 1851 {
1794 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1852 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1795
1796 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1853 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1797 1854
1798 // Un-comment the following line to print the raytrace results to the console. 1855 // Un-comment the following line to print the raytrace results to the console.
@@ -1801,13 +1858,12 @@ namespace OpenSim.Region.Framework.Scenes
1801 if (ei.HitTF) 1858 if (ei.HitTF)
1802 { 1859 {
1803 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1860 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1804 } else 1861 }
1862 else
1805 { 1863 {
1806 // fall back to our stupid functionality 1864 // fall back to our stupid functionality
1807 pos = RayEnd; 1865 pos = RayEnd;
1808 } 1866 }
1809
1810 return pos;
1811 } 1867 }
1812 } 1868 }
1813 else 1869 else
@@ -1818,8 +1874,12 @@ namespace OpenSim.Region.Framework.Scenes
1818 //increase height so its above the ground. 1874 //increase height so its above the ground.
1819 //should be getting the normal of the ground at the rez point and using that? 1875 //should be getting the normal of the ground at the rez point and using that?
1820 pos.Z += scale.Z / 2f; 1876 pos.Z += scale.Z / 2f;
1821 return pos; 1877// return pos;
1822 } 1878 }
1879
1880 // check against posible water intercept
1881 if (wpos.Z > pos.Z) pos = wpos;
1882 return pos;
1823 } 1883 }
1824 1884
1825 1885
@@ -1903,7 +1963,10 @@ namespace OpenSim.Region.Framework.Scenes
1903 public bool AddRestoredSceneObject( 1963 public bool AddRestoredSceneObject(
1904 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1964 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1905 { 1965 {
1906 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1966 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1967 if (result)
1968 sceneObject.IsDeleted = false;
1969 return result;
1907 } 1970 }
1908 1971
1909 /// <summary> 1972 /// <summary>
@@ -1993,6 +2056,15 @@ namespace OpenSim.Region.Framework.Scenes
1993 /// </summary> 2056 /// </summary>
1994 public void DeleteAllSceneObjects() 2057 public void DeleteAllSceneObjects()
1995 { 2058 {
2059 DeleteAllSceneObjects(false);
2060 }
2061
2062 /// <summary>
2063 /// Delete every object from the scene. This does not include attachments worn by avatars.
2064 /// </summary>
2065 public void DeleteAllSceneObjects(bool exceptNoCopy)
2066 {
2067 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1996 lock (Entities) 2068 lock (Entities)
1997 { 2069 {
1998 EntityBase[] entities = Entities.GetEntities(); 2070 EntityBase[] entities = Entities.GetEntities();
@@ -2001,11 +2073,24 @@ namespace OpenSim.Region.Framework.Scenes
2001 if (e is SceneObjectGroup) 2073 if (e is SceneObjectGroup)
2002 { 2074 {
2003 SceneObjectGroup sog = (SceneObjectGroup)e; 2075 SceneObjectGroup sog = (SceneObjectGroup)e;
2004 if (!sog.IsAttachment) 2076 if (sog != null && !sog.IsAttachment)
2005 DeleteSceneObject((SceneObjectGroup)e, false); 2077 {
2078 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2079 {
2080 DeleteSceneObject((SceneObjectGroup)e, false);
2081 }
2082 else
2083 {
2084 toReturn.Add((SceneObjectGroup)e);
2085 }
2086 }
2006 } 2087 }
2007 } 2088 }
2008 } 2089 }
2090 if (toReturn.Count > 0)
2091 {
2092 returnObjects(toReturn.ToArray(), UUID.Zero);
2093 }
2009 } 2094 }
2010 2095
2011 /// <summary> 2096 /// <summary>
@@ -2053,6 +2138,8 @@ namespace OpenSim.Region.Framework.Scenes
2053 } 2138 }
2054 2139
2055 group.DeleteGroupFromScene(silent); 2140 group.DeleteGroupFromScene(silent);
2141 if (!silent)
2142 SendKillObject(new List<uint>() { group.LocalId });
2056 2143
2057// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2144// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2058 } 2145 }
@@ -2407,10 +2494,17 @@ namespace OpenSim.Region.Framework.Scenes
2407 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2494 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2408 public bool AddSceneObject(SceneObjectGroup sceneObject) 2495 public bool AddSceneObject(SceneObjectGroup sceneObject)
2409 { 2496 {
2497 if (sceneObject.OwnerID == UUID.Zero)
2498 {
2499 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2500 return false;
2501 }
2502
2410 // If the user is banned, we won't let any of their objects 2503 // If the user is banned, we won't let any of their objects
2411 // enter. Period. 2504 // enter. Period.
2412 // 2505 //
2413 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2506 int flags = GetUserFlags(sceneObject.OwnerID);
2507 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2414 { 2508 {
2415 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); 2509 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2416 2510
@@ -2456,12 +2550,23 @@ namespace OpenSim.Region.Framework.Scenes
2456 } 2550 }
2457 else 2551 else
2458 { 2552 {
2553 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2459 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2554 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2460 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2555 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2461 } 2556 }
2557 if (sceneObject.OwnerID == UUID.Zero)
2558 {
2559 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2560 return false;
2561 }
2462 } 2562 }
2463 else 2563 else
2464 { 2564 {
2565 if (sceneObject.OwnerID == UUID.Zero)
2566 {
2567 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2568 return false;
2569 }
2465 AddRestoredSceneObject(sceneObject, true, false); 2570 AddRestoredSceneObject(sceneObject, true, false);
2466 2571
2467 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2572 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2490,6 +2595,24 @@ namespace OpenSim.Region.Framework.Scenes
2490 return 2; // StateSource.PrimCrossing 2595 return 2; // StateSource.PrimCrossing
2491 } 2596 }
2492 2597
2598 public int GetUserFlags(UUID user)
2599 {
2600 //Unfortunately the SP approach means that the value is cached until region is restarted
2601 /*
2602 ScenePresence sp;
2603 if (TryGetScenePresence(user, out sp))
2604 {
2605 return sp.UserFlags;
2606 }
2607 else
2608 {
2609 */
2610 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2611 if (uac == null)
2612 return 0;
2613 return uac.UserFlags;
2614 //}
2615 }
2493 #endregion 2616 #endregion
2494 2617
2495 #region Add/Remove Avatar Methods 2618 #region Add/Remove Avatar Methods
@@ -2504,6 +2627,7 @@ namespace OpenSim.Region.Framework.Scenes
2504 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2627 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2505 2628
2506 CheckHeartbeat(); 2629 CheckHeartbeat();
2630 ScenePresence presence;
2507 2631
2508 ScenePresence sp = GetScenePresence(client.AgentId); 2632 ScenePresence sp = GetScenePresence(client.AgentId);
2509 2633
@@ -2552,7 +2676,13 @@ namespace OpenSim.Region.Framework.Scenes
2552 2676
2553 EventManager.TriggerOnNewClient(client); 2677 EventManager.TriggerOnNewClient(client);
2554 if (vialogin) 2678 if (vialogin)
2679 {
2555 EventManager.TriggerOnClientLogin(client); 2680 EventManager.TriggerOnClientLogin(client);
2681 // Send initial parcel data
2682 Vector3 pos = sp.AbsolutePosition;
2683 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2684 land.SendLandUpdateToClient(client);
2685 }
2556 2686
2557 return sp; 2687 return sp;
2558 } 2688 }
@@ -2642,19 +2772,12 @@ namespace OpenSim.Region.Framework.Scenes
2642 // and the scene presence and the client, if they exist 2772 // and the scene presence and the client, if they exist
2643 try 2773 try
2644 { 2774 {
2645 // We need to wait for the client to make UDP contact first. 2775 ScenePresence sp = GetScenePresence(agentID);
2646 // It's the UDP contact that creates the scene presence 2776 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2647 ScenePresence sp = WaitGetScenePresence(agentID); 2777
2648 if (sp != null) 2778 if (sp != null)
2649 {
2650 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2651
2652 sp.ControllingClient.Close(); 2779 sp.ControllingClient.Close();
2653 } 2780
2654 else
2655 {
2656 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2657 }
2658 // BANG! SLASH! 2781 // BANG! SLASH!
2659 m_authenticateHandler.RemoveCircuit(agentID); 2782 m_authenticateHandler.RemoveCircuit(agentID);
2660 2783
@@ -2755,6 +2878,7 @@ namespace OpenSim.Region.Framework.Scenes
2755 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2878 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2756 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2879 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2757 client.OnCopyInventoryItem += CopyInventoryItem; 2880 client.OnCopyInventoryItem += CopyInventoryItem;
2881 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2758 client.OnMoveInventoryItem += MoveInventoryItem; 2882 client.OnMoveInventoryItem += MoveInventoryItem;
2759 client.OnRemoveInventoryItem += RemoveInventoryItem; 2883 client.OnRemoveInventoryItem += RemoveInventoryItem;
2760 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2884 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2930,15 +3054,16 @@ namespace OpenSim.Region.Framework.Scenes
2930 /// </summary> 3054 /// </summary>
2931 /// <param name="agentId">The avatar's Unique ID</param> 3055 /// <param name="agentId">The avatar's Unique ID</param>
2932 /// <param name="client">The IClientAPI for the client</param> 3056 /// <param name="client">The IClientAPI for the client</param>
2933 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3057 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2934 { 3058 {
2935 if (m_teleportModule != null) 3059 if (m_teleportModule != null)
2936 m_teleportModule.TeleportHome(agentId, client); 3060 return m_teleportModule.TeleportHome(agentId, client);
2937 else 3061 else
2938 { 3062 {
2939 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3063 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2940 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3064 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2941 } 3065 }
3066 return false;
2942 } 3067 }
2943 3068
2944 /// <summary> 3069 /// <summary>
@@ -3030,6 +3155,16 @@ namespace OpenSim.Region.Framework.Scenes
3030 /// <param name="flags"></param> 3155 /// <param name="flags"></param>
3031 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3156 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3032 { 3157 {
3158 //Add half the avatar's height so that the user doesn't fall through prims
3159 ScenePresence presence;
3160 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3161 {
3162 if (presence.Appearance != null)
3163 {
3164 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3165 }
3166 }
3167
3033 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3168 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3034 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3169 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3035 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3170 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3098,8 +3233,9 @@ namespace OpenSim.Region.Framework.Scenes
3098 regions.Remove(RegionInfo.RegionHandle); 3233 regions.Remove(RegionInfo.RegionHandle);
3099 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3234 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3100 } 3235 }
3101 3236 m_log.Debug("[Scene] Beginning ClientClosed");
3102 m_eventManager.TriggerClientClosed(agentID, this); 3237 m_eventManager.TriggerClientClosed(agentID, this);
3238 m_log.Debug("[Scene] Finished ClientClosed");
3103 } 3239 }
3104 catch (NullReferenceException) 3240 catch (NullReferenceException)
3105 { 3241 {
@@ -3151,9 +3287,10 @@ namespace OpenSim.Region.Framework.Scenes
3151 { 3287 {
3152 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); 3288 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace);
3153 } 3289 }
3154 3290 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3155 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3291 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3156// CleanDroppedAttachments(); 3292// CleanDroppedAttachments();
3293 m_log.Debug("[Scene] The avatar has left the building");
3157 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3294 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3158 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3295 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3159 } 3296 }
@@ -3272,13 +3409,16 @@ namespace OpenSim.Region.Framework.Scenes
3272 sp = null; 3409 sp = null;
3273 } 3410 }
3274 3411
3275 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3276 3412
3277 //On login test land permisions 3413 //On login test land permisions
3278 if (vialogin) 3414 if (vialogin)
3279 { 3415 {
3280 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3416 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3417 if (cache != null)
3418 cache.Remove(agent.firstname + " " + agent.lastname);
3419 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3281 { 3420 {
3421 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3282 return false; 3422 return false;
3283 } 3423 }
3284 } 3424 }
@@ -3302,8 +3442,13 @@ namespace OpenSim.Region.Framework.Scenes
3302 3442
3303 try 3443 try
3304 { 3444 {
3305 if (!AuthorizeUser(agent, out reason)) 3445 // Always check estate if this is a login. Always
3306 return false; 3446 // check if banned regions are to be blacked out.
3447 if (vialogin || (!m_seeIntoBannedRegion))
3448 {
3449 if (!AuthorizeUser(agent, out reason))
3450 return false;
3451 }
3307 } 3452 }
3308 catch (Exception e) 3453 catch (Exception e)
3309 { 3454 {
@@ -3406,6 +3551,8 @@ namespace OpenSim.Region.Framework.Scenes
3406 } 3551 }
3407 } 3552 }
3408 // Honor parcel landing type and position. 3553 // Honor parcel landing type and position.
3554 /*
3555 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3409 if (land != null) 3556 if (land != null)
3410 { 3557 {
3411 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3558 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3413,26 +3560,34 @@ namespace OpenSim.Region.Framework.Scenes
3413 agent.startpos = land.LandData.UserLocation; 3560 agent.startpos = land.LandData.UserLocation;
3414 } 3561 }
3415 } 3562 }
3563 */// This is now handled properly in ScenePresence.MakeRootAgent
3416 } 3564 }
3417 3565
3418 return true; 3566 return true;
3419 } 3567 }
3420 3568
3421 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3569 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3422 { 3570 {
3423 3571 reason = String.Empty;
3424 bool banned = land.IsBannedFromLand(agent.AgentID); 3572 if (Permissions.IsGod(agentID))
3425 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3573 return true;
3574
3575 ILandObject land = LandChannel.GetLandObject(posX, posY);
3576 if (land == null)
3577 return false;
3578
3579 bool banned = land.IsBannedFromLand(agentID);
3580 bool restricted = land.IsRestrictedFromLand(agentID);
3426 3581
3427 if (banned || restricted) 3582 if (banned || restricted)
3428 { 3583 {
3429 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3584 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3430 if (nearestParcel != null) 3585 if (nearestParcel != null)
3431 { 3586 {
3432 //Move agent to nearest allowed 3587 //Move agent to nearest allowed
3433 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3588 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3434 agent.startpos.X = newPosition.X; 3589 posX = newPosition.X;
3435 agent.startpos.Y = newPosition.Y; 3590 posY = newPosition.Y;
3436 } 3591 }
3437 else 3592 else
3438 { 3593 {
@@ -3494,7 +3649,7 @@ namespace OpenSim.Region.Framework.Scenes
3494 3649
3495 if (!m_strictAccessControl) return true; 3650 if (!m_strictAccessControl) return true;
3496 if (Permissions.IsGod(agent.AgentID)) return true; 3651 if (Permissions.IsGod(agent.AgentID)) return true;
3497 3652
3498 if (AuthorizationService != null) 3653 if (AuthorizationService != null)
3499 { 3654 {
3500 if (!AuthorizationService.IsAuthorizedForRegion( 3655 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3502,14 +3657,14 @@ namespace OpenSim.Region.Framework.Scenes
3502 { 3657 {
3503 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3658 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3504 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3659 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3505 3660
3506 return false; 3661 return false;
3507 } 3662 }
3508 } 3663 }
3509 3664
3510 if (m_regInfo.EstateSettings != null) 3665 if (m_regInfo.EstateSettings != null)
3511 { 3666 {
3512 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3667 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3513 { 3668 {
3514 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3669 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3515 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3670 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3701,6 +3856,13 @@ namespace OpenSim.Region.Framework.Scenes
3701 3856
3702 // We have to wait until the viewer contacts this region after receiving EAC. 3857 // We have to wait until the viewer contacts this region after receiving EAC.
3703 // That calls AddNewClient, which finally creates the ScenePresence 3858 // That calls AddNewClient, which finally creates the ScenePresence
3859 int flags = GetUserFlags(cAgentData.AgentID);
3860 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3861 {
3862 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3863 return false;
3864 }
3865
3704 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3866 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3705 if (nearestParcel == null) 3867 if (nearestParcel == null)
3706 { 3868 {
@@ -3782,12 +3944,22 @@ namespace OpenSim.Region.Framework.Scenes
3782 return false; 3944 return false;
3783 } 3945 }
3784 3946
3947 public bool IncomingCloseAgent(UUID agentID)
3948 {
3949 return IncomingCloseAgent(agentID, false);
3950 }
3951
3952 public bool IncomingCloseChildAgent(UUID agentID)
3953 {
3954 return IncomingCloseAgent(agentID, true);
3955 }
3956
3785 /// <summary> 3957 /// <summary>
3786 /// Tell a single agent to disconnect from the region. 3958 /// Tell a single agent to disconnect from the region.
3787 /// </summary> 3959 /// </summary>
3788 /// <param name="regionHandle"></param>
3789 /// <param name="agentID"></param> 3960 /// <param name="agentID"></param>
3790 public bool IncomingCloseAgent(UUID agentID) 3961 /// <param name="childOnly"></param>
3962 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3791 { 3963 {
3792 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3964 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3793 3965
@@ -3799,7 +3971,7 @@ namespace OpenSim.Region.Framework.Scenes
3799 { 3971 {
3800 m_sceneGraph.removeUserCount(false); 3972 m_sceneGraph.removeUserCount(false);
3801 } 3973 }
3802 else 3974 else if (!childOnly)
3803 { 3975 {
3804 m_sceneGraph.removeUserCount(true); 3976 m_sceneGraph.removeUserCount(true);
3805 } 3977 }
@@ -3815,9 +3987,12 @@ namespace OpenSim.Region.Framework.Scenes
3815 } 3987 }
3816 else 3988 else
3817 presence.ControllingClient.SendShutdownConnectionNotice(); 3989 presence.ControllingClient.SendShutdownConnectionNotice();
3990 presence.ControllingClient.Close(false);
3991 }
3992 else if (!childOnly)
3993 {
3994 presence.ControllingClient.Close(true);
3818 } 3995 }
3819
3820 presence.ControllingClient.Close();
3821 return true; 3996 return true;
3822 } 3997 }
3823 3998
@@ -4400,34 +4575,78 @@ namespace OpenSim.Region.Framework.Scenes
4400 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4575 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4401 } 4576 }
4402 4577
4403 public int GetHealth() 4578 public int GetHealth(out int flags, out string message)
4404 { 4579 {
4405 // Returns: 4580 // Returns:
4406 // 1 = sim is up and accepting http requests. The heartbeat has 4581 // 1 = sim is up and accepting http requests. The heartbeat has
4407 // stopped and the sim is probably locked up, but a remote 4582 // stopped and the sim is probably locked up, but a remote
4408 // admin restart may succeed 4583 // admin restart may succeed
4409 // 4584 //
4410 // 2 = Sim is up and the heartbeat is running. The sim is likely 4585 // 2 = Sim is up and the heartbeat is running. The sim is likely
4411 // usable for people within and logins _may_ work 4586 // usable for people within
4587 //
4588 // 3 = Sim is up and one packet thread is running. Sim is
4589 // unstable and will not accept new logins
4590 //
4591 // 4 = Sim is up and both packet threads are running. Sim is
4592 // likely usable
4412 // 4593 //
4413 // 3 = We have seen a new user enter within the past 4 minutes 4594 // 5 = We have seen a new user enter within the past 4 minutes
4414 // which can be seen as positive confirmation of sim health 4595 // which can be seen as positive confirmation of sim health
4415 // 4596 //
4597
4598 flags = 0;
4599 message = String.Empty;
4600
4601 CheckHeartbeat();
4602
4603 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4604 {
4605 // We're still starting
4606 // 0 means "in startup", it can't happen another way, since
4607 // to get here, we must be able to accept http connections
4608 return 0;
4609 }
4610
4416 int health=1; // Start at 1, means we're up 4611 int health=1; // Start at 1, means we're up
4417 4612
4418 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4613 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4614 {
4615 health+=1;
4616 flags |= 1;
4617 }
4618
4619 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4620 {
4621 health+=1;
4622 flags |= 2;
4623 }
4624
4625 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4626 {
4419 health+=1; 4627 health+=1;
4628 flags |= 4;
4629 }
4420 else 4630 else
4631 {
4632int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
4633System.Diagnostics.Process proc = new System.Diagnostics.Process();
4634proc.EnableRaisingEvents=false;
4635proc.StartInfo.FileName = "/bin/kill";
4636proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
4637proc.Start();
4638proc.WaitForExit();
4639Thread.Sleep(1000);
4640Environment.Exit(1);
4641 }
4642
4643 if (flags != 7)
4421 return health; 4644 return health;
4422 4645
4423 // A login in the last 4 mins? We can't be doing too badly 4646 // A login in the last 4 mins? We can't be doing too badly
4424 // 4647 //
4425 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4648 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4426 health++; 4649 health++;
4427 else
4428 return health;
4429
4430 CheckHeartbeat();
4431 4650
4432 return health; 4651 return health;
4433 } 4652 }
@@ -4620,7 +4839,7 @@ namespace OpenSim.Region.Framework.Scenes
4620 if (m_firstHeartbeat) 4839 if (m_firstHeartbeat)
4621 return; 4840 return;
4622 4841
4623 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4842 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4624 StartTimer(); 4843 StartTimer();
4625 } 4844 }
4626 4845
@@ -5030,6 +5249,54 @@ namespace OpenSim.Region.Framework.Scenes
5030 mapModule.GenerateMaptile(); 5249 mapModule.GenerateMaptile();
5031 } 5250 }
5032 5251
5252// public void CleanDroppedAttachments()
5253// {
5254// List<SceneObjectGroup> objectsToDelete =
5255// new List<SceneObjectGroup>();
5256//
5257// lock (m_cleaningAttachments)
5258// {
5259// ForEachSOG(delegate (SceneObjectGroup grp)
5260// {
5261// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5262// {
5263// UUID agentID = grp.OwnerID;
5264// if (agentID == UUID.Zero)
5265// {
5266// objectsToDelete.Add(grp);
5267// return;
5268// }
5269//
5270// ScenePresence sp = GetScenePresence(agentID);
5271// if (sp == null)
5272// {
5273// objectsToDelete.Add(grp);
5274// return;
5275// }
5276// }
5277// });
5278// }
5279//
5280// foreach (SceneObjectGroup grp in objectsToDelete)
5281// {
5282// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5283// DeleteSceneObject(grp, true);
5284// }
5285// }
5286
5287 public void ThreadAlive(int threadCode)
5288 {
5289 switch(threadCode)
5290 {
5291 case 1: // Incoming
5292 m_lastIncoming = Util.EnvironmentTickCount();
5293 break;
5294 case 2: // Incoming
5295 m_lastOutgoing = Util.EnvironmentTickCount();
5296 break;
5297 }
5298 }
5299
5033 // This method is called across the simulation connector to 5300 // This method is called across the simulation connector to
5034 // determine if a given agent is allowed in this region 5301 // determine if a given agent is allowed in this region
5035 // AS A ROOT AGENT. Returning false here will prevent them 5302 // AS A ROOT AGENT. Returning false here will prevent them
@@ -5038,6 +5305,14 @@ namespace OpenSim.Region.Framework.Scenes
5038 // child agent creation, thereby emulating the SL behavior. 5305 // child agent creation, thereby emulating the SL behavior.
5039 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5306 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5040 { 5307 {
5308 reason = "You are banned from the region";
5309
5310 if (Permissions.IsGod(agentID))
5311 {
5312 reason = String.Empty;
5313 return true;
5314 }
5315
5041 int num = m_sceneGraph.GetNumberOfScenePresences(); 5316 int num = m_sceneGraph.GetNumberOfScenePresences();
5042 5317
5043 if (num >= RegionInfo.RegionSettings.AgentLimit) 5318 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5049,11 +5324,82 @@ namespace OpenSim.Region.Framework.Scenes
5049 } 5324 }
5050 } 5325 }
5051 5326
5327 ScenePresence presence = GetScenePresence(agentID);
5328 IClientAPI client = null;
5329 AgentCircuitData aCircuit = null;
5330
5331 if (presence != null)
5332 {
5333 client = presence.ControllingClient;
5334 if (client != null)
5335 aCircuit = client.RequestClientInfo();
5336 }
5337
5338 // We may be called before there is a presence or a client.
5339 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5340 if (client == null)
5341 {
5342 aCircuit = new AgentCircuitData();
5343 aCircuit.AgentID = agentID;
5344 aCircuit.firstname = String.Empty;
5345 aCircuit.lastname = String.Empty;
5346 }
5347
5348 try
5349 {
5350 if (!AuthorizeUser(aCircuit, out reason))
5351 {
5352 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5353 return false;
5354 }
5355 }
5356 catch (Exception e)
5357 {
5358 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5359 return false;
5360 }
5361
5362 if (position == Vector3.Zero) // Teleport
5363 {
5364 float posX = 128.0f;
5365 float posY = 128.0f;
5366
5367 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5368 {
5369 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5370 return false;
5371 }
5372 }
5373 else // Walking
5374 {
5375 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5376 if (land == null)
5377 return false;
5378
5379 bool banned = land.IsBannedFromLand(agentID);
5380 bool restricted = land.IsRestrictedFromLand(agentID);
5381
5382 if (banned || restricted)
5383 return false;
5384 }
5385
5052 reason = String.Empty; 5386 reason = String.Empty;
5053 return true; 5387 return true;
5054 } 5388 }
5055 5389
5056 /// <summary> 5390 public void StartTimerWatchdog()
5391 {
5392 m_timerWatchdog.Interval = 1000;
5393 m_timerWatchdog.Elapsed += TimerWatchdog;
5394 m_timerWatchdog.AutoReset = true;
5395 m_timerWatchdog.Start();
5396 }
5397
5398 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5399 {
5400 CheckHeartbeat();
5401 }
5402
5057 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5403 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5058 /// autopilot that moves an avatar to a sit target!. 5404 /// autopilot that moves an avatar to a sit target!.
5059 /// </summary> 5405 /// </summary>