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 b4972d6..b828f39 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -103,6 +103,7 @@ namespace OpenSim.Region.Framework.Scenes
103 // TODO: need to figure out how allow client agents but deny 103 // TODO: need to figure out how allow client agents but deny
104 // root agents when ACL denies access to root agent 104 // root agents when ACL denies access to root agent
105 public bool m_strictAccessControl = true; 105 public bool m_strictAccessControl = true;
106 public bool m_seeIntoBannedRegion = false;
106 public int MaxUndoCount = 5; 107 public int MaxUndoCount = 5;
107 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 108 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
108 public bool LoginLock = false; 109 public bool LoginLock = false;
@@ -118,12 +119,14 @@ namespace OpenSim.Region.Framework.Scenes
118 119
119 protected int m_splitRegionID; 120 protected int m_splitRegionID;
120 protected Timer m_restartWaitTimer = new Timer(); 121 protected Timer m_restartWaitTimer = new Timer();
122 protected Timer m_timerWatchdog = new Timer();
121 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 123 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
122 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 124 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
123 protected string m_simulatorVersion = "OpenSimulator Server"; 125 protected string m_simulatorVersion = "OpenSimulator Server";
124 protected ModuleLoader m_moduleLoader; 126 protected ModuleLoader m_moduleLoader;
125 protected AgentCircuitManager m_authenticateHandler; 127 protected AgentCircuitManager m_authenticateHandler;
126 protected SceneCommunicationService m_sceneGridService; 128 protected SceneCommunicationService m_sceneGridService;
129 protected ISnmpModule m_snmpService = null;
127 130
128 protected ISimulationDataService m_SimulationDataService; 131 protected ISimulationDataService m_SimulationDataService;
129 protected IEstateDataService m_EstateDataService; 132 protected IEstateDataService m_EstateDataService;
@@ -176,7 +179,7 @@ namespace OpenSim.Region.Framework.Scenes
176 private int m_update_events = 1; 179 private int m_update_events = 1;
177 private int m_update_backup = 200; 180 private int m_update_backup = 200;
178 private int m_update_terrain = 50; 181 private int m_update_terrain = 50;
179// private int m_update_land = 1; 182 private int m_update_land = 10;
180 private int m_update_coarse_locations = 50; 183 private int m_update_coarse_locations = 50;
181 184
182 private int agentMS; 185 private int agentMS;
@@ -191,6 +194,7 @@ namespace OpenSim.Region.Framework.Scenes
191 private int landMS; 194 private int landMS;
192 private int lastCompletedFrame; 195 private int lastCompletedFrame;
193 196
197 public bool CombineRegions = false;
194 /// <summary> 198 /// <summary>
195 /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched 199 /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched
196 /// asynchronously from the update loop. 200 /// asynchronously from the update loop.
@@ -213,11 +217,14 @@ namespace OpenSim.Region.Framework.Scenes
213 private bool m_scripts_enabled = true; 217 private bool m_scripts_enabled = true;
214 private string m_defaultScriptEngine; 218 private string m_defaultScriptEngine;
215 private int m_LastLogin; 219 private int m_LastLogin;
216 private Thread HeartbeatThread; 220 private Thread HeartbeatThread = null;
217 private volatile bool shuttingdown; 221 private volatile bool shuttingdown;
218 222
219 private int m_lastUpdate; 223 private int m_lastUpdate;
224 private int m_lastIncoming;
225 private int m_lastOutgoing;
220 private bool m_firstHeartbeat = true; 226 private bool m_firstHeartbeat = true;
227 private int m_hbRestarts = 0;
221 228
222 private object m_deleting_scene_object = new object(); 229 private object m_deleting_scene_object = new object();
223 230
@@ -264,6 +271,19 @@ namespace OpenSim.Region.Framework.Scenes
264 get { return m_sceneGridService; } 271 get { return m_sceneGridService; }
265 } 272 }
266 273
274 public ISnmpModule SnmpService
275 {
276 get
277 {
278 if (m_snmpService == null)
279 {
280 m_snmpService = RequestModuleInterface<ISnmpModule>();
281 }
282
283 return m_snmpService;
284 }
285 }
286
267 public ISimulationDataService SimulationDataService 287 public ISimulationDataService SimulationDataService
268 { 288 {
269 get 289 get
@@ -545,6 +565,9 @@ namespace OpenSim.Region.Framework.Scenes
545 m_EstateDataService = estateDataService; 565 m_EstateDataService = estateDataService;
546 m_regionHandle = m_regInfo.RegionHandle; 566 m_regionHandle = m_regInfo.RegionHandle;
547 m_regionName = m_regInfo.RegionName; 567 m_regionName = m_regInfo.RegionName;
568 m_lastUpdate = Util.EnvironmentTickCount();
569 m_lastIncoming = 0;
570 m_lastOutgoing = 0;
548 571
549 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); 572 m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this);
550 m_asyncSceneObjectDeleter.Enabled = true; 573 m_asyncSceneObjectDeleter.Enabled = true;
@@ -662,6 +685,7 @@ namespace OpenSim.Region.Framework.Scenes
662 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); 685 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
663 686
664 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 687 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
688
665 if (RegionInfo.NonphysPrimMax > 0) 689 if (RegionInfo.NonphysPrimMax > 0)
666 { 690 {
667 m_maxNonphys = RegionInfo.NonphysPrimMax; 691 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -693,6 +717,7 @@ namespace OpenSim.Region.Framework.Scenes
693 m_persistAfter *= 10000000; 717 m_persistAfter *= 10000000;
694 718
695 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 719 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
720 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
696 721
697 IConfig packetConfig = m_config.Configs["PacketPool"]; 722 IConfig packetConfig = m_config.Configs["PacketPool"];
698 if (packetConfig != null) 723 if (packetConfig != null)
@@ -702,6 +727,8 @@ namespace OpenSim.Region.Framework.Scenes
702 } 727 }
703 728
704 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 729 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
730 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
731 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
705 732
706 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 733 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
707 if (m_generateMaptiles) 734 if (m_generateMaptiles)
@@ -737,9 +764,9 @@ namespace OpenSim.Region.Framework.Scenes
737 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); 764 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
738 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); 765 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
739 } 766 }
740 catch 767 catch (Exception e)
741 { 768 {
742 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 769 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
743 } 770 }
744 771
745 #endregion Region Config 772 #endregion Region Config
@@ -1150,7 +1177,22 @@ namespace OpenSim.Region.Framework.Scenes
1150 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1177 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1151 if (HeartbeatThread != null) 1178 if (HeartbeatThread != null)
1152 { 1179 {
1180 m_hbRestarts++;
1181 if(m_hbRestarts > 10)
1182 Environment.Exit(1);
1183 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1184
1185//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1186//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1187//proc.EnableRaisingEvents=false;
1188//proc.StartInfo.FileName = "/bin/kill";
1189//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1190//proc.Start();
1191//proc.WaitForExit();
1192//Thread.Sleep(1000);
1193//Environment.Exit(1);
1153 HeartbeatThread.Abort(); 1194 HeartbeatThread.Abort();
1195 Watchdog.AbortThread(HeartbeatThread.ManagedThreadId);
1154 HeartbeatThread = null; 1196 HeartbeatThread = null;
1155 } 1197 }
1156 m_lastUpdate = Util.EnvironmentTickCount(); 1198 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1196,9 +1238,6 @@ namespace OpenSim.Region.Framework.Scenes
1196 { 1238 {
1197 while (!shuttingdown) 1239 while (!shuttingdown)
1198 Update(); 1240 Update();
1199
1200 m_lastUpdate = Util.EnvironmentTickCount();
1201 m_firstHeartbeat = false;
1202 } 1241 }
1203 catch (ThreadAbortException) 1242 catch (ThreadAbortException)
1204 { 1243 {
@@ -1296,6 +1335,13 @@ namespace OpenSim.Region.Framework.Scenes
1296 eventMS = Util.EnvironmentTickCountSubtract(evMS); ; 1335 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1297 } 1336 }
1298 1337
1338 // if (Frame % m_update_land == 0)
1339 // {
1340 // int ldMS = Util.EnvironmentTickCount();
1341 // UpdateLand();
1342 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1343 // }
1344
1299 if (Frame % m_update_backup == 0) 1345 if (Frame % m_update_backup == 0)
1300 { 1346 {
1301 int backMS = Util.EnvironmentTickCount(); 1347 int backMS = Util.EnvironmentTickCount();
@@ -1403,12 +1449,16 @@ namespace OpenSim.Region.Framework.Scenes
1403 maintc = Util.EnvironmentTickCountSubtract(maintc); 1449 maintc = Util.EnvironmentTickCountSubtract(maintc);
1404 maintc = (int)(MinFrameTime * 1000) - maintc; 1450 maintc = (int)(MinFrameTime * 1000) - maintc;
1405 1451
1452
1453 m_lastUpdate = Util.EnvironmentTickCount();
1454 m_firstHeartbeat = false;
1455
1406 if (maintc > 0) 1456 if (maintc > 0)
1407 Thread.Sleep(maintc); 1457 Thread.Sleep(maintc);
1408 1458
1409 // Tell the watchdog that this thread is still alive 1459 // Tell the watchdog that this thread is still alive
1410 Watchdog.UpdateThread(); 1460 Watchdog.UpdateThread();
1411 } 1461 }
1412 1462
1413 public void AddGroupTarget(SceneObjectGroup grp) 1463 public void AddGroupTarget(SceneObjectGroup grp)
1414 { 1464 {
@@ -1424,9 +1474,9 @@ namespace OpenSim.Region.Framework.Scenes
1424 1474
1425 private void CheckAtTargets() 1475 private void CheckAtTargets()
1426 { 1476 {
1427 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1477 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1428 lock (m_groupsWithTargets) 1478 lock (m_groupsWithTargets)
1429 objs = m_groupsWithTargets.Values; 1479 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1430 1480
1431 foreach (SceneObjectGroup entry in objs) 1481 foreach (SceneObjectGroup entry in objs)
1432 entry.checkAtTargets(); 1482 entry.checkAtTargets();
@@ -1508,7 +1558,7 @@ namespace OpenSim.Region.Framework.Scenes
1508 msg.fromAgentName = "Server"; 1558 msg.fromAgentName = "Server";
1509 msg.dialog = (byte)19; // Object msg 1559 msg.dialog = (byte)19; // Object msg
1510 msg.fromGroup = false; 1560 msg.fromGroup = false;
1511 msg.offline = (byte)0; 1561 msg.offline = (byte)1;
1512 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1562 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1513 msg.Position = Vector3.Zero; 1563 msg.Position = Vector3.Zero;
1514 msg.RegionID = RegionInfo.RegionID.Guid; 1564 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1743,14 +1793,24 @@ namespace OpenSim.Region.Framework.Scenes
1743 /// <returns></returns> 1793 /// <returns></returns>
1744 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1794 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1745 { 1795 {
1796
1797 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1798 Vector3 wpos = Vector3.Zero;
1799 // Check for water surface intersection from above
1800 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1801 {
1802 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1803 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1804 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1805 wpos.Z = wheight;
1806 }
1807
1746 Vector3 pos = Vector3.Zero; 1808 Vector3 pos = Vector3.Zero;
1747 if (RayEndIsIntersection == (byte)1) 1809 if (RayEndIsIntersection == (byte)1)
1748 { 1810 {
1749 pos = RayEnd; 1811 pos = RayEnd;
1750 return pos;
1751 } 1812 }
1752 1813 else if (RayTargetID != UUID.Zero)
1753 if (RayTargetID != UUID.Zero)
1754 { 1814 {
1755 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1815 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1756 1816
@@ -1772,7 +1832,7 @@ namespace OpenSim.Region.Framework.Scenes
1772 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1832 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1773 1833
1774 // Un-comment out the following line to Get Raytrace results printed to the console. 1834 // Un-comment out the following line to Get Raytrace results printed to the console.
1775 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1835 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1776 float ScaleOffset = 0.5f; 1836 float ScaleOffset = 0.5f;
1777 1837
1778 // If we hit something 1838 // If we hit something
@@ -1795,13 +1855,10 @@ namespace OpenSim.Region.Framework.Scenes
1795 //pos.Z -= 0.25F; 1855 //pos.Z -= 0.25F;
1796 1856
1797 } 1857 }
1798
1799 return pos;
1800 } 1858 }
1801 else 1859 else
1802 { 1860 {
1803 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1861 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1804
1805 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1862 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1806 1863
1807 // Un-comment the following line to print the raytrace results to the console. 1864 // Un-comment the following line to print the raytrace results to the console.
@@ -1810,13 +1867,12 @@ namespace OpenSim.Region.Framework.Scenes
1810 if (ei.HitTF) 1867 if (ei.HitTF)
1811 { 1868 {
1812 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1869 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1813 } else 1870 }
1871 else
1814 { 1872 {
1815 // fall back to our stupid functionality 1873 // fall back to our stupid functionality
1816 pos = RayEnd; 1874 pos = RayEnd;
1817 } 1875 }
1818
1819 return pos;
1820 } 1876 }
1821 } 1877 }
1822 else 1878 else
@@ -1827,8 +1883,12 @@ namespace OpenSim.Region.Framework.Scenes
1827 //increase height so its above the ground. 1883 //increase height so its above the ground.
1828 //should be getting the normal of the ground at the rez point and using that? 1884 //should be getting the normal of the ground at the rez point and using that?
1829 pos.Z += scale.Z / 2f; 1885 pos.Z += scale.Z / 2f;
1830 return pos; 1886// return pos;
1831 } 1887 }
1888
1889 // check against posible water intercept
1890 if (wpos.Z > pos.Z) pos = wpos;
1891 return pos;
1832 } 1892 }
1833 1893
1834 1894
@@ -1912,7 +1972,10 @@ namespace OpenSim.Region.Framework.Scenes
1912 public bool AddRestoredSceneObject( 1972 public bool AddRestoredSceneObject(
1913 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1973 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1914 { 1974 {
1915 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1975 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1976 if (result)
1977 sceneObject.IsDeleted = false;
1978 return result;
1916 } 1979 }
1917 1980
1918 /// <summary> 1981 /// <summary>
@@ -2002,6 +2065,15 @@ namespace OpenSim.Region.Framework.Scenes
2002 /// </summary> 2065 /// </summary>
2003 public void DeleteAllSceneObjects() 2066 public void DeleteAllSceneObjects()
2004 { 2067 {
2068 DeleteAllSceneObjects(false);
2069 }
2070
2071 /// <summary>
2072 /// Delete every object from the scene. This does not include attachments worn by avatars.
2073 /// </summary>
2074 public void DeleteAllSceneObjects(bool exceptNoCopy)
2075 {
2076 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2005 lock (Entities) 2077 lock (Entities)
2006 { 2078 {
2007 EntityBase[] entities = Entities.GetEntities(); 2079 EntityBase[] entities = Entities.GetEntities();
@@ -2010,11 +2082,24 @@ namespace OpenSim.Region.Framework.Scenes
2010 if (e is SceneObjectGroup) 2082 if (e is SceneObjectGroup)
2011 { 2083 {
2012 SceneObjectGroup sog = (SceneObjectGroup)e; 2084 SceneObjectGroup sog = (SceneObjectGroup)e;
2013 if (!sog.IsAttachment) 2085 if (sog != null && !sog.IsAttachment)
2014 DeleteSceneObject((SceneObjectGroup)e, false); 2086 {
2087 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2088 {
2089 DeleteSceneObject((SceneObjectGroup)e, false);
2090 }
2091 else
2092 {
2093 toReturn.Add((SceneObjectGroup)e);
2094 }
2095 }
2015 } 2096 }
2016 } 2097 }
2017 } 2098 }
2099 if (toReturn.Count > 0)
2100 {
2101 returnObjects(toReturn.ToArray(), UUID.Zero);
2102 }
2018 } 2103 }
2019 2104
2020 /// <summary> 2105 /// <summary>
@@ -2062,6 +2147,8 @@ namespace OpenSim.Region.Framework.Scenes
2062 } 2147 }
2063 2148
2064 group.DeleteGroupFromScene(silent); 2149 group.DeleteGroupFromScene(silent);
2150 if (!silent)
2151 SendKillObject(new List<uint>() { group.LocalId });
2065 2152
2066// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2153// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2067 } 2154 }
@@ -2416,10 +2503,17 @@ namespace OpenSim.Region.Framework.Scenes
2416 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2503 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2417 public bool AddSceneObject(SceneObjectGroup sceneObject) 2504 public bool AddSceneObject(SceneObjectGroup sceneObject)
2418 { 2505 {
2506 if (sceneObject.OwnerID == UUID.Zero)
2507 {
2508 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2509 return false;
2510 }
2511
2419 // If the user is banned, we won't let any of their objects 2512 // If the user is banned, we won't let any of their objects
2420 // enter. Period. 2513 // enter. Period.
2421 // 2514 //
2422 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2515 int flags = GetUserFlags(sceneObject.OwnerID);
2516 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2423 { 2517 {
2424 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); 2518 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2425 2519
@@ -2465,12 +2559,23 @@ namespace OpenSim.Region.Framework.Scenes
2465 } 2559 }
2466 else 2560 else
2467 { 2561 {
2562 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2468 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2563 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2469 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2564 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2470 } 2565 }
2566 if (sceneObject.OwnerID == UUID.Zero)
2567 {
2568 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2569 return false;
2570 }
2471 } 2571 }
2472 else 2572 else
2473 { 2573 {
2574 if (sceneObject.OwnerID == UUID.Zero)
2575 {
2576 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2577 return false;
2578 }
2474 AddRestoredSceneObject(sceneObject, true, false); 2579 AddRestoredSceneObject(sceneObject, true, false);
2475 2580
2476 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2581 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2499,6 +2604,24 @@ namespace OpenSim.Region.Framework.Scenes
2499 return 2; // StateSource.PrimCrossing 2604 return 2; // StateSource.PrimCrossing
2500 } 2605 }
2501 2606
2607 public int GetUserFlags(UUID user)
2608 {
2609 //Unfortunately the SP approach means that the value is cached until region is restarted
2610 /*
2611 ScenePresence sp;
2612 if (TryGetScenePresence(user, out sp))
2613 {
2614 return sp.UserFlags;
2615 }
2616 else
2617 {
2618 */
2619 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2620 if (uac == null)
2621 return 0;
2622 return uac.UserFlags;
2623 //}
2624 }
2502 #endregion 2625 #endregion
2503 2626
2504 #region Add/Remove Avatar Methods 2627 #region Add/Remove Avatar Methods
@@ -2513,6 +2636,7 @@ namespace OpenSim.Region.Framework.Scenes
2513 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2636 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2514 2637
2515 CheckHeartbeat(); 2638 CheckHeartbeat();
2639 ScenePresence presence;
2516 2640
2517 ScenePresence sp = GetScenePresence(client.AgentId); 2641 ScenePresence sp = GetScenePresence(client.AgentId);
2518 2642
@@ -2561,7 +2685,13 @@ namespace OpenSim.Region.Framework.Scenes
2561 2685
2562 EventManager.TriggerOnNewClient(client); 2686 EventManager.TriggerOnNewClient(client);
2563 if (vialogin) 2687 if (vialogin)
2688 {
2564 EventManager.TriggerOnClientLogin(client); 2689 EventManager.TriggerOnClientLogin(client);
2690 // Send initial parcel data
2691 Vector3 pos = sp.AbsolutePosition;
2692 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2693 land.SendLandUpdateToClient(client);
2694 }
2565 2695
2566 return sp; 2696 return sp;
2567 } 2697 }
@@ -2651,19 +2781,12 @@ namespace OpenSim.Region.Framework.Scenes
2651 // and the scene presence and the client, if they exist 2781 // and the scene presence and the client, if they exist
2652 try 2782 try
2653 { 2783 {
2654 // We need to wait for the client to make UDP contact first. 2784 ScenePresence sp = GetScenePresence(agentID);
2655 // It's the UDP contact that creates the scene presence 2785 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2656 ScenePresence sp = WaitGetScenePresence(agentID); 2786
2657 if (sp != null) 2787 if (sp != null)
2658 {
2659 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2660
2661 sp.ControllingClient.Close(); 2788 sp.ControllingClient.Close();
2662 } 2789
2663 else
2664 {
2665 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2666 }
2667 // BANG! SLASH! 2790 // BANG! SLASH!
2668 m_authenticateHandler.RemoveCircuit(agentID); 2791 m_authenticateHandler.RemoveCircuit(agentID);
2669 2792
@@ -2764,6 +2887,7 @@ namespace OpenSim.Region.Framework.Scenes
2764 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2887 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2765 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2888 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2766 client.OnCopyInventoryItem += CopyInventoryItem; 2889 client.OnCopyInventoryItem += CopyInventoryItem;
2890 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2767 client.OnMoveInventoryItem += MoveInventoryItem; 2891 client.OnMoveInventoryItem += MoveInventoryItem;
2768 client.OnRemoveInventoryItem += RemoveInventoryItem; 2892 client.OnRemoveInventoryItem += RemoveInventoryItem;
2769 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2893 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2939,15 +3063,16 @@ namespace OpenSim.Region.Framework.Scenes
2939 /// </summary> 3063 /// </summary>
2940 /// <param name="agentId">The avatar's Unique ID</param> 3064 /// <param name="agentId">The avatar's Unique ID</param>
2941 /// <param name="client">The IClientAPI for the client</param> 3065 /// <param name="client">The IClientAPI for the client</param>
2942 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3066 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2943 { 3067 {
2944 if (m_teleportModule != null) 3068 if (m_teleportModule != null)
2945 m_teleportModule.TeleportHome(agentId, client); 3069 return m_teleportModule.TeleportHome(agentId, client);
2946 else 3070 else
2947 { 3071 {
2948 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3072 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2949 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3073 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2950 } 3074 }
3075 return false;
2951 } 3076 }
2952 3077
2953 /// <summary> 3078 /// <summary>
@@ -3039,6 +3164,16 @@ namespace OpenSim.Region.Framework.Scenes
3039 /// <param name="flags"></param> 3164 /// <param name="flags"></param>
3040 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3165 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3041 { 3166 {
3167 //Add half the avatar's height so that the user doesn't fall through prims
3168 ScenePresence presence;
3169 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3170 {
3171 if (presence.Appearance != null)
3172 {
3173 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3174 }
3175 }
3176
3042 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3177 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3043 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3178 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3044 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3179 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3107,8 +3242,9 @@ namespace OpenSim.Region.Framework.Scenes
3107 regions.Remove(RegionInfo.RegionHandle); 3242 regions.Remove(RegionInfo.RegionHandle);
3108 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3243 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3109 } 3244 }
3110 3245 m_log.Debug("[Scene] Beginning ClientClosed");
3111 m_eventManager.TriggerClientClosed(agentID, this); 3246 m_eventManager.TriggerClientClosed(agentID, this);
3247 m_log.Debug("[Scene] Finished ClientClosed");
3112 } 3248 }
3113 catch (NullReferenceException) 3249 catch (NullReferenceException)
3114 { 3250 {
@@ -3160,9 +3296,10 @@ namespace OpenSim.Region.Framework.Scenes
3160 { 3296 {
3161 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); 3297 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace);
3162 } 3298 }
3163 3299 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3164 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3300 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3165// CleanDroppedAttachments(); 3301// CleanDroppedAttachments();
3302 m_log.Debug("[Scene] The avatar has left the building");
3166 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3303 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3167 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3304 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3168 } 3305 }
@@ -3281,13 +3418,16 @@ namespace OpenSim.Region.Framework.Scenes
3281 sp = null; 3418 sp = null;
3282 } 3419 }
3283 3420
3284 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3285 3421
3286 //On login test land permisions 3422 //On login test land permisions
3287 if (vialogin) 3423 if (vialogin)
3288 { 3424 {
3289 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3425 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3426 if (cache != null)
3427 cache.Remove(agent.firstname + " " + agent.lastname);
3428 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3290 { 3429 {
3430 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3291 return false; 3431 return false;
3292 } 3432 }
3293 } 3433 }
@@ -3311,8 +3451,13 @@ namespace OpenSim.Region.Framework.Scenes
3311 3451
3312 try 3452 try
3313 { 3453 {
3314 if (!AuthorizeUser(agent, out reason)) 3454 // Always check estate if this is a login. Always
3315 return false; 3455 // check if banned regions are to be blacked out.
3456 if (vialogin || (!m_seeIntoBannedRegion))
3457 {
3458 if (!AuthorizeUser(agent, out reason))
3459 return false;
3460 }
3316 } 3461 }
3317 catch (Exception e) 3462 catch (Exception e)
3318 { 3463 {
@@ -3415,6 +3560,8 @@ namespace OpenSim.Region.Framework.Scenes
3415 } 3560 }
3416 } 3561 }
3417 // Honor parcel landing type and position. 3562 // Honor parcel landing type and position.
3563 /*
3564 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3418 if (land != null) 3565 if (land != null)
3419 { 3566 {
3420 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3567 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3422,26 +3569,34 @@ namespace OpenSim.Region.Framework.Scenes
3422 agent.startpos = land.LandData.UserLocation; 3569 agent.startpos = land.LandData.UserLocation;
3423 } 3570 }
3424 } 3571 }
3572 */// This is now handled properly in ScenePresence.MakeRootAgent
3425 } 3573 }
3426 3574
3427 return true; 3575 return true;
3428 } 3576 }
3429 3577
3430 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3578 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3431 { 3579 {
3432 3580 reason = String.Empty;
3433 bool banned = land.IsBannedFromLand(agent.AgentID); 3581 if (Permissions.IsGod(agentID))
3434 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3582 return true;
3583
3584 ILandObject land = LandChannel.GetLandObject(posX, posY);
3585 if (land == null)
3586 return false;
3587
3588 bool banned = land.IsBannedFromLand(agentID);
3589 bool restricted = land.IsRestrictedFromLand(agentID);
3435 3590
3436 if (banned || restricted) 3591 if (banned || restricted)
3437 { 3592 {
3438 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3593 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3439 if (nearestParcel != null) 3594 if (nearestParcel != null)
3440 { 3595 {
3441 //Move agent to nearest allowed 3596 //Move agent to nearest allowed
3442 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3597 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3443 agent.startpos.X = newPosition.X; 3598 posX = newPosition.X;
3444 agent.startpos.Y = newPosition.Y; 3599 posY = newPosition.Y;
3445 } 3600 }
3446 else 3601 else
3447 { 3602 {
@@ -3503,7 +3658,7 @@ namespace OpenSim.Region.Framework.Scenes
3503 3658
3504 if (!m_strictAccessControl) return true; 3659 if (!m_strictAccessControl) return true;
3505 if (Permissions.IsGod(agent.AgentID)) return true; 3660 if (Permissions.IsGod(agent.AgentID)) return true;
3506 3661
3507 if (AuthorizationService != null) 3662 if (AuthorizationService != null)
3508 { 3663 {
3509 if (!AuthorizationService.IsAuthorizedForRegion( 3664 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3511,14 +3666,14 @@ namespace OpenSim.Region.Framework.Scenes
3511 { 3666 {
3512 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3667 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3513 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3668 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3514 3669
3515 return false; 3670 return false;
3516 } 3671 }
3517 } 3672 }
3518 3673
3519 if (m_regInfo.EstateSettings != null) 3674 if (m_regInfo.EstateSettings != null)
3520 { 3675 {
3521 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3676 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3522 { 3677 {
3523 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3678 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3524 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3679 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3710,6 +3865,13 @@ namespace OpenSim.Region.Framework.Scenes
3710 3865
3711 // We have to wait until the viewer contacts this region after receiving EAC. 3866 // We have to wait until the viewer contacts this region after receiving EAC.
3712 // That calls AddNewClient, which finally creates the ScenePresence 3867 // That calls AddNewClient, which finally creates the ScenePresence
3868 int flags = GetUserFlags(cAgentData.AgentID);
3869 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3870 {
3871 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3872 return false;
3873 }
3874
3713 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3875 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3714 if (nearestParcel == null) 3876 if (nearestParcel == null)
3715 { 3877 {
@@ -3791,12 +3953,22 @@ namespace OpenSim.Region.Framework.Scenes
3791 return false; 3953 return false;
3792 } 3954 }
3793 3955
3956 public bool IncomingCloseAgent(UUID agentID)
3957 {
3958 return IncomingCloseAgent(agentID, false);
3959 }
3960
3961 public bool IncomingCloseChildAgent(UUID agentID)
3962 {
3963 return IncomingCloseAgent(agentID, true);
3964 }
3965
3794 /// <summary> 3966 /// <summary>
3795 /// Tell a single agent to disconnect from the region. 3967 /// Tell a single agent to disconnect from the region.
3796 /// </summary> 3968 /// </summary>
3797 /// <param name="regionHandle"></param>
3798 /// <param name="agentID"></param> 3969 /// <param name="agentID"></param>
3799 public bool IncomingCloseAgent(UUID agentID) 3970 /// <param name="childOnly"></param>
3971 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3800 { 3972 {
3801 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3973 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3802 3974
@@ -3808,7 +3980,7 @@ namespace OpenSim.Region.Framework.Scenes
3808 { 3980 {
3809 m_sceneGraph.removeUserCount(false); 3981 m_sceneGraph.removeUserCount(false);
3810 } 3982 }
3811 else 3983 else if (!childOnly)
3812 { 3984 {
3813 m_sceneGraph.removeUserCount(true); 3985 m_sceneGraph.removeUserCount(true);
3814 } 3986 }
@@ -3824,9 +3996,12 @@ namespace OpenSim.Region.Framework.Scenes
3824 } 3996 }
3825 else 3997 else
3826 presence.ControllingClient.SendShutdownConnectionNotice(); 3998 presence.ControllingClient.SendShutdownConnectionNotice();
3999 presence.ControllingClient.Close(false);
4000 }
4001 else if (!childOnly)
4002 {
4003 presence.ControllingClient.Close(true);
3827 } 4004 }
3828
3829 presence.ControllingClient.Close();
3830 return true; 4005 return true;
3831 } 4006 }
3832 4007
@@ -4409,34 +4584,78 @@ namespace OpenSim.Region.Framework.Scenes
4409 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4584 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4410 } 4585 }
4411 4586
4412 public int GetHealth() 4587 public int GetHealth(out int flags, out string message)
4413 { 4588 {
4414 // Returns: 4589 // Returns:
4415 // 1 = sim is up and accepting http requests. The heartbeat has 4590 // 1 = sim is up and accepting http requests. The heartbeat has
4416 // stopped and the sim is probably locked up, but a remote 4591 // stopped and the sim is probably locked up, but a remote
4417 // admin restart may succeed 4592 // admin restart may succeed
4418 // 4593 //
4419 // 2 = Sim is up and the heartbeat is running. The sim is likely 4594 // 2 = Sim is up and the heartbeat is running. The sim is likely
4420 // usable for people within and logins _may_ work 4595 // usable for people within
4596 //
4597 // 3 = Sim is up and one packet thread is running. Sim is
4598 // unstable and will not accept new logins
4599 //
4600 // 4 = Sim is up and both packet threads are running. Sim is
4601 // likely usable
4421 // 4602 //
4422 // 3 = We have seen a new user enter within the past 4 minutes 4603 // 5 = We have seen a new user enter within the past 4 minutes
4423 // which can be seen as positive confirmation of sim health 4604 // which can be seen as positive confirmation of sim health
4424 // 4605 //
4606
4607 flags = 0;
4608 message = String.Empty;
4609
4610 CheckHeartbeat();
4611
4612 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4613 {
4614 // We're still starting
4615 // 0 means "in startup", it can't happen another way, since
4616 // to get here, we must be able to accept http connections
4617 return 0;
4618 }
4619
4425 int health=1; // Start at 1, means we're up 4620 int health=1; // Start at 1, means we're up
4426 4621
4427 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4622 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4623 {
4624 health+=1;
4625 flags |= 1;
4626 }
4627
4628 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4629 {
4630 health+=1;
4631 flags |= 2;
4632 }
4633
4634 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4635 {
4428 health+=1; 4636 health+=1;
4637 flags |= 4;
4638 }
4429 else 4639 else
4640 {
4641int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
4642System.Diagnostics.Process proc = new System.Diagnostics.Process();
4643proc.EnableRaisingEvents=false;
4644proc.StartInfo.FileName = "/bin/kill";
4645proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
4646proc.Start();
4647proc.WaitForExit();
4648Thread.Sleep(1000);
4649Environment.Exit(1);
4650 }
4651
4652 if (flags != 7)
4430 return health; 4653 return health;
4431 4654
4432 // A login in the last 4 mins? We can't be doing too badly 4655 // A login in the last 4 mins? We can't be doing too badly
4433 // 4656 //
4434 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4657 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4435 health++; 4658 health++;
4436 else
4437 return health;
4438
4439 CheckHeartbeat();
4440 4659
4441 return health; 4660 return health;
4442 } 4661 }
@@ -4629,7 +4848,7 @@ namespace OpenSim.Region.Framework.Scenes
4629 if (m_firstHeartbeat) 4848 if (m_firstHeartbeat)
4630 return; 4849 return;
4631 4850
4632 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4851 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4633 StartTimer(); 4852 StartTimer();
4634 } 4853 }
4635 4854
@@ -5039,6 +5258,54 @@ namespace OpenSim.Region.Framework.Scenes
5039 mapModule.GenerateMaptile(); 5258 mapModule.GenerateMaptile();
5040 } 5259 }
5041 5260
5261// public void CleanDroppedAttachments()
5262// {
5263// List<SceneObjectGroup> objectsToDelete =
5264// new List<SceneObjectGroup>();
5265//
5266// lock (m_cleaningAttachments)
5267// {
5268// ForEachSOG(delegate (SceneObjectGroup grp)
5269// {
5270// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5271// {
5272// UUID agentID = grp.OwnerID;
5273// if (agentID == UUID.Zero)
5274// {
5275// objectsToDelete.Add(grp);
5276// return;
5277// }
5278//
5279// ScenePresence sp = GetScenePresence(agentID);
5280// if (sp == null)
5281// {
5282// objectsToDelete.Add(grp);
5283// return;
5284// }
5285// }
5286// });
5287// }
5288//
5289// foreach (SceneObjectGroup grp in objectsToDelete)
5290// {
5291// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5292// DeleteSceneObject(grp, true);
5293// }
5294// }
5295
5296 public void ThreadAlive(int threadCode)
5297 {
5298 switch(threadCode)
5299 {
5300 case 1: // Incoming
5301 m_lastIncoming = Util.EnvironmentTickCount();
5302 break;
5303 case 2: // Incoming
5304 m_lastOutgoing = Util.EnvironmentTickCount();
5305 break;
5306 }
5307 }
5308
5042 // This method is called across the simulation connector to 5309 // This method is called across the simulation connector to
5043 // determine if a given agent is allowed in this region 5310 // determine if a given agent is allowed in this region
5044 // AS A ROOT AGENT. Returning false here will prevent them 5311 // AS A ROOT AGENT. Returning false here will prevent them
@@ -5047,6 +5314,14 @@ namespace OpenSim.Region.Framework.Scenes
5047 // child agent creation, thereby emulating the SL behavior. 5314 // child agent creation, thereby emulating the SL behavior.
5048 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5315 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5049 { 5316 {
5317 reason = "You are banned from the region";
5318
5319 if (Permissions.IsGod(agentID))
5320 {
5321 reason = String.Empty;
5322 return true;
5323 }
5324
5050 int num = m_sceneGraph.GetNumberOfScenePresences(); 5325 int num = m_sceneGraph.GetNumberOfScenePresences();
5051 5326
5052 if (num >= RegionInfo.RegionSettings.AgentLimit) 5327 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5058,11 +5333,82 @@ namespace OpenSim.Region.Framework.Scenes
5058 } 5333 }
5059 } 5334 }
5060 5335
5336 ScenePresence presence = GetScenePresence(agentID);
5337 IClientAPI client = null;
5338 AgentCircuitData aCircuit = null;
5339
5340 if (presence != null)
5341 {
5342 client = presence.ControllingClient;
5343 if (client != null)
5344 aCircuit = client.RequestClientInfo();
5345 }
5346
5347 // We may be called before there is a presence or a client.
5348 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5349 if (client == null)
5350 {
5351 aCircuit = new AgentCircuitData();
5352 aCircuit.AgentID = agentID;
5353 aCircuit.firstname = String.Empty;
5354 aCircuit.lastname = String.Empty;
5355 }
5356
5357 try
5358 {
5359 if (!AuthorizeUser(aCircuit, out reason))
5360 {
5361 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5362 return false;
5363 }
5364 }
5365 catch (Exception e)
5366 {
5367 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5368 return false;
5369 }
5370
5371 if (position == Vector3.Zero) // Teleport
5372 {
5373 float posX = 128.0f;
5374 float posY = 128.0f;
5375
5376 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5377 {
5378 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5379 return false;
5380 }
5381 }
5382 else // Walking
5383 {
5384 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5385 if (land == null)
5386 return false;
5387
5388 bool banned = land.IsBannedFromLand(agentID);
5389 bool restricted = land.IsRestrictedFromLand(agentID);
5390
5391 if (banned || restricted)
5392 return false;
5393 }
5394
5061 reason = String.Empty; 5395 reason = String.Empty;
5062 return true; 5396 return true;
5063 } 5397 }
5064 5398
5065 /// <summary> 5399 public void StartTimerWatchdog()
5400 {
5401 m_timerWatchdog.Interval = 1000;
5402 m_timerWatchdog.Elapsed += TimerWatchdog;
5403 m_timerWatchdog.AutoReset = true;
5404 m_timerWatchdog.Start();
5405 }
5406
5407 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5408 {
5409 CheckHeartbeat();
5410 }
5411
5066 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5412 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5067 /// autopilot that moves an avatar to a sit target!. 5413 /// autopilot that moves an avatar to a sit target!.
5068 /// </summary> 5414 /// </summary>