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