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