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 11505cc..684745f 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();
@@ -1386,12 +1432,16 @@ namespace OpenSim.Region.Framework.Scenes
1386 maintc = Util.EnvironmentTickCountSubtract(maintc); 1432 maintc = Util.EnvironmentTickCountSubtract(maintc);
1387 maintc = (int)(MinFrameTime * 1000) - maintc; 1433 maintc = (int)(MinFrameTime * 1000) - maintc;
1388 1434
1435
1436 m_lastUpdate = Util.EnvironmentTickCount();
1437 m_firstHeartbeat = false;
1438
1389 if (maintc > 0) 1439 if (maintc > 0)
1390 Thread.Sleep(maintc); 1440 Thread.Sleep(maintc);
1391 1441
1392 // Tell the watchdog that this thread is still alive 1442 // Tell the watchdog that this thread is still alive
1393 Watchdog.UpdateThread(); 1443 Watchdog.UpdateThread();
1394 } 1444 }
1395 1445
1396 public void AddGroupTarget(SceneObjectGroup grp) 1446 public void AddGroupTarget(SceneObjectGroup grp)
1397 { 1447 {
@@ -1407,9 +1457,9 @@ namespace OpenSim.Region.Framework.Scenes
1407 1457
1408 private void CheckAtTargets() 1458 private void CheckAtTargets()
1409 { 1459 {
1410 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1460 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1411 lock (m_groupsWithTargets) 1461 lock (m_groupsWithTargets)
1412 objs = m_groupsWithTargets.Values; 1462 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1413 1463
1414 foreach (SceneObjectGroup entry in objs) 1464 foreach (SceneObjectGroup entry in objs)
1415 entry.checkAtTargets(); 1465 entry.checkAtTargets();
@@ -1491,7 +1541,7 @@ namespace OpenSim.Region.Framework.Scenes
1491 msg.fromAgentName = "Server"; 1541 msg.fromAgentName = "Server";
1492 msg.dialog = (byte)19; // Object msg 1542 msg.dialog = (byte)19; // Object msg
1493 msg.fromGroup = false; 1543 msg.fromGroup = false;
1494 msg.offline = (byte)0; 1544 msg.offline = (byte)1;
1495 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1545 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1496 msg.Position = Vector3.Zero; 1546 msg.Position = Vector3.Zero;
1497 msg.RegionID = RegionInfo.RegionID.Guid; 1547 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1724,14 +1774,24 @@ namespace OpenSim.Region.Framework.Scenes
1724 /// <returns></returns> 1774 /// <returns></returns>
1725 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1775 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1726 { 1776 {
1777
1778 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1779 Vector3 wpos = Vector3.Zero;
1780 // Check for water surface intersection from above
1781 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1782 {
1783 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1784 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1785 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1786 wpos.Z = wheight;
1787 }
1788
1727 Vector3 pos = Vector3.Zero; 1789 Vector3 pos = Vector3.Zero;
1728 if (RayEndIsIntersection == (byte)1) 1790 if (RayEndIsIntersection == (byte)1)
1729 { 1791 {
1730 pos = RayEnd; 1792 pos = RayEnd;
1731 return pos;
1732 } 1793 }
1733 1794 else if (RayTargetID != UUID.Zero)
1734 if (RayTargetID != UUID.Zero)
1735 { 1795 {
1736 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1796 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1737 1797
@@ -1753,7 +1813,7 @@ namespace OpenSim.Region.Framework.Scenes
1753 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1813 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1754 1814
1755 // Un-comment out the following line to Get Raytrace results printed to the console. 1815 // Un-comment out the following line to Get Raytrace results printed to the console.
1756 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1816 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1757 float ScaleOffset = 0.5f; 1817 float ScaleOffset = 0.5f;
1758 1818
1759 // If we hit something 1819 // If we hit something
@@ -1776,13 +1836,10 @@ namespace OpenSim.Region.Framework.Scenes
1776 //pos.Z -= 0.25F; 1836 //pos.Z -= 0.25F;
1777 1837
1778 } 1838 }
1779
1780 return pos;
1781 } 1839 }
1782 else 1840 else
1783 { 1841 {
1784 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1842 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1785
1786 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1843 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1787 1844
1788 // Un-comment the following line to print the raytrace results to the console. 1845 // Un-comment the following line to print the raytrace results to the console.
@@ -1791,13 +1848,12 @@ namespace OpenSim.Region.Framework.Scenes
1791 if (ei.HitTF) 1848 if (ei.HitTF)
1792 { 1849 {
1793 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1850 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1794 } else 1851 }
1852 else
1795 { 1853 {
1796 // fall back to our stupid functionality 1854 // fall back to our stupid functionality
1797 pos = RayEnd; 1855 pos = RayEnd;
1798 } 1856 }
1799
1800 return pos;
1801 } 1857 }
1802 } 1858 }
1803 else 1859 else
@@ -1808,8 +1864,12 @@ namespace OpenSim.Region.Framework.Scenes
1808 //increase height so its above the ground. 1864 //increase height so its above the ground.
1809 //should be getting the normal of the ground at the rez point and using that? 1865 //should be getting the normal of the ground at the rez point and using that?
1810 pos.Z += scale.Z / 2f; 1866 pos.Z += scale.Z / 2f;
1811 return pos; 1867// return pos;
1812 } 1868 }
1869
1870 // check against posible water intercept
1871 if (wpos.Z > pos.Z) pos = wpos;
1872 return pos;
1813 } 1873 }
1814 1874
1815 1875
@@ -1893,7 +1953,10 @@ namespace OpenSim.Region.Framework.Scenes
1893 public bool AddRestoredSceneObject( 1953 public bool AddRestoredSceneObject(
1894 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1954 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1895 { 1955 {
1896 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1956 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1957 if (result)
1958 sceneObject.IsDeleted = false;
1959 return result;
1897 } 1960 }
1898 1961
1899 /// <summary> 1962 /// <summary>
@@ -1983,6 +2046,15 @@ namespace OpenSim.Region.Framework.Scenes
1983 /// </summary> 2046 /// </summary>
1984 public void DeleteAllSceneObjects() 2047 public void DeleteAllSceneObjects()
1985 { 2048 {
2049 DeleteAllSceneObjects(false);
2050 }
2051
2052 /// <summary>
2053 /// Delete every object from the scene. This does not include attachments worn by avatars.
2054 /// </summary>
2055 public void DeleteAllSceneObjects(bool exceptNoCopy)
2056 {
2057 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1986 lock (Entities) 2058 lock (Entities)
1987 { 2059 {
1988 EntityBase[] entities = Entities.GetEntities(); 2060 EntityBase[] entities = Entities.GetEntities();
@@ -1991,11 +2063,24 @@ namespace OpenSim.Region.Framework.Scenes
1991 if (e is SceneObjectGroup) 2063 if (e is SceneObjectGroup)
1992 { 2064 {
1993 SceneObjectGroup sog = (SceneObjectGroup)e; 2065 SceneObjectGroup sog = (SceneObjectGroup)e;
1994 if (!sog.IsAttachment) 2066 if (sog != null && !sog.IsAttachment)
1995 DeleteSceneObject((SceneObjectGroup)e, false); 2067 {
2068 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2069 {
2070 DeleteSceneObject((SceneObjectGroup)e, false);
2071 }
2072 else
2073 {
2074 toReturn.Add((SceneObjectGroup)e);
2075 }
2076 }
1996 } 2077 }
1997 } 2078 }
1998 } 2079 }
2080 if (toReturn.Count > 0)
2081 {
2082 returnObjects(toReturn.ToArray(), UUID.Zero);
2083 }
1999 } 2084 }
2000 2085
2001 /// <summary> 2086 /// <summary>
@@ -2043,6 +2128,8 @@ namespace OpenSim.Region.Framework.Scenes
2043 } 2128 }
2044 2129
2045 group.DeleteGroupFromScene(silent); 2130 group.DeleteGroupFromScene(silent);
2131 if (!silent)
2132 SendKillObject(new List<uint>() { group.LocalId });
2046 2133
2047// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2134// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2048 } 2135 }
@@ -2397,10 +2484,17 @@ namespace OpenSim.Region.Framework.Scenes
2397 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2484 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2398 public bool AddSceneObject(SceneObjectGroup sceneObject) 2485 public bool AddSceneObject(SceneObjectGroup sceneObject)
2399 { 2486 {
2487 if (sceneObject.OwnerID == UUID.Zero)
2488 {
2489 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2490 return false;
2491 }
2492
2400 // If the user is banned, we won't let any of their objects 2493 // If the user is banned, we won't let any of their objects
2401 // enter. Period. 2494 // enter. Period.
2402 // 2495 //
2403 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2496 int flags = GetUserFlags(sceneObject.OwnerID);
2497 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2404 { 2498 {
2405 m_log.Info("[INTERREGION]: Denied prim crossing for " + 2499 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2406 "banned avatar"); 2500 "banned avatar");
@@ -2447,12 +2541,23 @@ namespace OpenSim.Region.Framework.Scenes
2447 } 2541 }
2448 else 2542 else
2449 { 2543 {
2544 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2450 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2545 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2451 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2546 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2452 } 2547 }
2548 if (sceneObject.OwnerID == UUID.Zero)
2549 {
2550 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2551 return false;
2552 }
2453 } 2553 }
2454 else 2554 else
2455 { 2555 {
2556 if (sceneObject.OwnerID == UUID.Zero)
2557 {
2558 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2559 return false;
2560 }
2456 AddRestoredSceneObject(sceneObject, true, false); 2561 AddRestoredSceneObject(sceneObject, true, false);
2457 2562
2458 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2563 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2482,6 +2587,24 @@ namespace OpenSim.Region.Framework.Scenes
2482 return 2; // StateSource.PrimCrossing 2587 return 2; // StateSource.PrimCrossing
2483 } 2588 }
2484 2589
2590 public int GetUserFlags(UUID user)
2591 {
2592 //Unfortunately the SP approach means that the value is cached until region is restarted
2593 /*
2594 ScenePresence sp;
2595 if (TryGetScenePresence(user, out sp))
2596 {
2597 return sp.UserFlags;
2598 }
2599 else
2600 {
2601 */
2602 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2603 if (uac == null)
2604 return 0;
2605 return uac.UserFlags;
2606 //}
2607 }
2485 #endregion 2608 #endregion
2486 2609
2487 #region Add/Remove Avatar Methods 2610 #region Add/Remove Avatar Methods
@@ -2496,6 +2619,7 @@ namespace OpenSim.Region.Framework.Scenes
2496 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2619 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2497 2620
2498 CheckHeartbeat(); 2621 CheckHeartbeat();
2622 ScenePresence presence;
2499 2623
2500 ScenePresence sp = GetScenePresence(client.AgentId); 2624 ScenePresence sp = GetScenePresence(client.AgentId);
2501 2625
@@ -2543,7 +2667,13 @@ namespace OpenSim.Region.Framework.Scenes
2543 2667
2544 EventManager.TriggerOnNewClient(client); 2668 EventManager.TriggerOnNewClient(client);
2545 if (vialogin) 2669 if (vialogin)
2670 {
2546 EventManager.TriggerOnClientLogin(client); 2671 EventManager.TriggerOnClientLogin(client);
2672 // Send initial parcel data
2673 Vector3 pos = sp.AbsolutePosition;
2674 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2675 land.SendLandUpdateToClient(client);
2676 }
2547 2677
2548 return sp; 2678 return sp;
2549 } 2679 }
@@ -2633,19 +2763,12 @@ namespace OpenSim.Region.Framework.Scenes
2633 // and the scene presence and the client, if they exist 2763 // and the scene presence and the client, if they exist
2634 try 2764 try
2635 { 2765 {
2636 // We need to wait for the client to make UDP contact first. 2766 ScenePresence sp = GetScenePresence(agentID);
2637 // It's the UDP contact that creates the scene presence 2767 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2638 ScenePresence sp = WaitGetScenePresence(agentID); 2768
2639 if (sp != null) 2769 if (sp != null)
2640 {
2641 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2642
2643 sp.ControllingClient.Close(); 2770 sp.ControllingClient.Close();
2644 } 2771
2645 else
2646 {
2647 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2648 }
2649 // BANG! SLASH! 2772 // BANG! SLASH!
2650 m_authenticateHandler.RemoveCircuit(agentID); 2773 m_authenticateHandler.RemoveCircuit(agentID);
2651 2774
@@ -2745,6 +2868,7 @@ namespace OpenSim.Region.Framework.Scenes
2745 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2868 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2746 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2869 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2747 client.OnCopyInventoryItem += CopyInventoryItem; 2870 client.OnCopyInventoryItem += CopyInventoryItem;
2871 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2748 client.OnMoveInventoryItem += MoveInventoryItem; 2872 client.OnMoveInventoryItem += MoveInventoryItem;
2749 client.OnRemoveInventoryItem += RemoveInventoryItem; 2873 client.OnRemoveInventoryItem += RemoveInventoryItem;
2750 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2874 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2922,15 +3046,16 @@ namespace OpenSim.Region.Framework.Scenes
2922 /// </summary> 3046 /// </summary>
2923 /// <param name="agentId">The avatar's Unique ID</param> 3047 /// <param name="agentId">The avatar's Unique ID</param>
2924 /// <param name="client">The IClientAPI for the client</param> 3048 /// <param name="client">The IClientAPI for the client</param>
2925 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3049 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2926 { 3050 {
2927 if (m_teleportModule != null) 3051 if (m_teleportModule != null)
2928 m_teleportModule.TeleportHome(agentId, client); 3052 return m_teleportModule.TeleportHome(agentId, client);
2929 else 3053 else
2930 { 3054 {
2931 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3055 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2932 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3056 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2933 } 3057 }
3058 return false;
2934 } 3059 }
2935 3060
2936 /// <summary> 3061 /// <summary>
@@ -3022,6 +3147,16 @@ namespace OpenSim.Region.Framework.Scenes
3022 /// <param name="flags"></param> 3147 /// <param name="flags"></param>
3023 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3148 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3024 { 3149 {
3150 //Add half the avatar's height so that the user doesn't fall through prims
3151 ScenePresence presence;
3152 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3153 {
3154 if (presence.Appearance != null)
3155 {
3156 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3157 }
3158 }
3159
3025 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3160 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3026 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3161 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3027 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3162 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3090,8 +3225,9 @@ namespace OpenSim.Region.Framework.Scenes
3090 regions.Remove(RegionInfo.RegionHandle); 3225 regions.Remove(RegionInfo.RegionHandle);
3091 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3226 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3092 } 3227 }
3093 3228 m_log.Debug("[Scene] Beginning ClientClosed");
3094 m_eventManager.TriggerClientClosed(agentID, this); 3229 m_eventManager.TriggerClientClosed(agentID, this);
3230 m_log.Debug("[Scene] Finished ClientClosed");
3095 } 3231 }
3096 catch (NullReferenceException) 3232 catch (NullReferenceException)
3097 { 3233 {
@@ -3143,9 +3279,10 @@ namespace OpenSim.Region.Framework.Scenes
3143 { 3279 {
3144 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3280 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3145 } 3281 }
3146 3282 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3147 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3283 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3148// CleanDroppedAttachments(); 3284// CleanDroppedAttachments();
3285 m_log.Debug("[Scene] The avatar has left the building");
3149 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3286 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3150 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3287 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3151 } 3288 }
@@ -3264,13 +3401,16 @@ namespace OpenSim.Region.Framework.Scenes
3264 sp = null; 3401 sp = null;
3265 } 3402 }
3266 3403
3267 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3268 3404
3269 //On login test land permisions 3405 //On login test land permisions
3270 if (vialogin) 3406 if (vialogin)
3271 { 3407 {
3272 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3408 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3409 if (cache != null)
3410 cache.Remove(agent.firstname + " " + agent.lastname);
3411 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3273 { 3412 {
3413 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3274 return false; 3414 return false;
3275 } 3415 }
3276 } 3416 }
@@ -3293,8 +3433,13 @@ namespace OpenSim.Region.Framework.Scenes
3293 3433
3294 try 3434 try
3295 { 3435 {
3296 if (!AuthorizeUser(agent, out reason)) 3436 // Always check estate if this is a login. Always
3297 return false; 3437 // check if banned regions are to be blacked out.
3438 if (vialogin || (!m_seeIntoBannedRegion))
3439 {
3440 if (!AuthorizeUser(agent, out reason))
3441 return false;
3442 }
3298 } 3443 }
3299 catch (Exception e) 3444 catch (Exception e)
3300 { 3445 {
@@ -3396,6 +3541,8 @@ namespace OpenSim.Region.Framework.Scenes
3396 } 3541 }
3397 } 3542 }
3398 // Honor parcel landing type and position. 3543 // Honor parcel landing type and position.
3544 /*
3545 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3399 if (land != null) 3546 if (land != null)
3400 { 3547 {
3401 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3548 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3403,26 +3550,34 @@ namespace OpenSim.Region.Framework.Scenes
3403 agent.startpos = land.LandData.UserLocation; 3550 agent.startpos = land.LandData.UserLocation;
3404 } 3551 }
3405 } 3552 }
3553 */// This is now handled properly in ScenePresence.MakeRootAgent
3406 } 3554 }
3407 3555
3408 return true; 3556 return true;
3409 } 3557 }
3410 3558
3411 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3559 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3412 { 3560 {
3413 3561 reason = String.Empty;
3414 bool banned = land.IsBannedFromLand(agent.AgentID); 3562 if (Permissions.IsGod(agentID))
3415 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3563 return true;
3564
3565 ILandObject land = LandChannel.GetLandObject(posX, posY);
3566 if (land == null)
3567 return false;
3568
3569 bool banned = land.IsBannedFromLand(agentID);
3570 bool restricted = land.IsRestrictedFromLand(agentID);
3416 3571
3417 if (banned || restricted) 3572 if (banned || restricted)
3418 { 3573 {
3419 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3574 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3420 if (nearestParcel != null) 3575 if (nearestParcel != null)
3421 { 3576 {
3422 //Move agent to nearest allowed 3577 //Move agent to nearest allowed
3423 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3578 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3424 agent.startpos.X = newPosition.X; 3579 posX = newPosition.X;
3425 agent.startpos.Y = newPosition.Y; 3580 posY = newPosition.Y;
3426 } 3581 }
3427 else 3582 else
3428 { 3583 {
@@ -3484,7 +3639,7 @@ namespace OpenSim.Region.Framework.Scenes
3484 3639
3485 if (!m_strictAccessControl) return true; 3640 if (!m_strictAccessControl) return true;
3486 if (Permissions.IsGod(agent.AgentID)) return true; 3641 if (Permissions.IsGod(agent.AgentID)) return true;
3487 3642
3488 if (AuthorizationService != null) 3643 if (AuthorizationService != null)
3489 { 3644 {
3490 if (!AuthorizationService.IsAuthorizedForRegion( 3645 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3492,14 +3647,14 @@ namespace OpenSim.Region.Framework.Scenes
3492 { 3647 {
3493 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3648 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3494 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3649 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3495 3650
3496 return false; 3651 return false;
3497 } 3652 }
3498 } 3653 }
3499 3654
3500 if (m_regInfo.EstateSettings != null) 3655 if (m_regInfo.EstateSettings != null)
3501 { 3656 {
3502 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3657 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3503 { 3658 {
3504 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3659 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3505 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3660 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3689,6 +3844,13 @@ namespace OpenSim.Region.Framework.Scenes
3689 3844
3690 // We have to wait until the viewer contacts this region after receiving EAC. 3845 // We have to wait until the viewer contacts this region after receiving EAC.
3691 // That calls AddNewClient, which finally creates the ScenePresence 3846 // That calls AddNewClient, which finally creates the ScenePresence
3847 int flags = GetUserFlags(cAgentData.AgentID);
3848 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3849 {
3850 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3851 return false;
3852 }
3853
3692 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3854 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3693 if (nearestParcel == null) 3855 if (nearestParcel == null)
3694 { 3856 {
@@ -3770,12 +3932,22 @@ namespace OpenSim.Region.Framework.Scenes
3770 return false; 3932 return false;
3771 } 3933 }
3772 3934
3935 public bool IncomingCloseAgent(UUID agentID)
3936 {
3937 return IncomingCloseAgent(agentID, false);
3938 }
3939
3940 public bool IncomingCloseChildAgent(UUID agentID)
3941 {
3942 return IncomingCloseAgent(agentID, true);
3943 }
3944
3773 /// <summary> 3945 /// <summary>
3774 /// Tell a single agent to disconnect from the region. 3946 /// Tell a single agent to disconnect from the region.
3775 /// </summary> 3947 /// </summary>
3776 /// <param name="regionHandle"></param>
3777 /// <param name="agentID"></param> 3948 /// <param name="agentID"></param>
3778 public bool IncomingCloseAgent(UUID agentID) 3949 /// <param name="childOnly"></param>
3950 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3779 { 3951 {
3780 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3952 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3781 3953
@@ -3787,7 +3959,7 @@ namespace OpenSim.Region.Framework.Scenes
3787 { 3959 {
3788 m_sceneGraph.removeUserCount(false); 3960 m_sceneGraph.removeUserCount(false);
3789 } 3961 }
3790 else 3962 else if (!childOnly)
3791 { 3963 {
3792 m_sceneGraph.removeUserCount(true); 3964 m_sceneGraph.removeUserCount(true);
3793 } 3965 }
@@ -3803,9 +3975,12 @@ namespace OpenSim.Region.Framework.Scenes
3803 } 3975 }
3804 else 3976 else
3805 presence.ControllingClient.SendShutdownConnectionNotice(); 3977 presence.ControllingClient.SendShutdownConnectionNotice();
3978 presence.ControllingClient.Close(false);
3979 }
3980 else if (!childOnly)
3981 {
3982 presence.ControllingClient.Close(true);
3806 } 3983 }
3807
3808 presence.ControllingClient.Close();
3809 return true; 3984 return true;
3810 } 3985 }
3811 3986
@@ -4400,34 +4575,66 @@ namespace OpenSim.Region.Framework.Scenes
4400 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4575 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4401 } 4576 }
4402 4577
4403 public int GetHealth() 4578 public int GetHealth(out int flags, out string message)
4404 { 4579 {
4405 // Returns: 4580 // Returns:
4406 // 1 = sim is up and accepting http requests. The heartbeat has 4581 // 1 = sim is up and accepting http requests. The heartbeat has
4407 // stopped and the sim is probably locked up, but a remote 4582 // stopped and the sim is probably locked up, but a remote
4408 // admin restart may succeed 4583 // admin restart may succeed
4409 // 4584 //
4410 // 2 = Sim is up and the heartbeat is running. The sim is likely 4585 // 2 = Sim is up and the heartbeat is running. The sim is likely
4411 // usable for people within and logins _may_ work 4586 // usable for people within
4412 // 4587 //
4413 // 3 = We have seen a new user enter within the past 4 minutes 4588 // 3 = Sim is up and one packet thread is running. Sim is
4589 // unstable and will not accept new logins
4590 //
4591 // 4 = Sim is up and both packet threads are running. Sim is
4592 // likely usable
4593 //
4594 // 5 = We have seen a new user enter within the past 4 minutes
4414 // which can be seen as positive confirmation of sim health 4595 // which can be seen as positive confirmation of sim health
4415 // 4596 //
4597
4598 flags = 0;
4599 message = String.Empty;
4600
4601 CheckHeartbeat();
4602
4603 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4604 {
4605 // We're still starting
4606 // 0 means "in startup", it can't happen another way, since
4607 // to get here, we must be able to accept http connections
4608 return 0;
4609 }
4610
4416 int health=1; // Start at 1, means we're up 4611 int health=1; // Start at 1, means we're up
4417 4612
4418 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4613 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4614 {
4419 health+=1; 4615 health+=1;
4420 else 4616 flags |= 1;
4617 }
4618
4619 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4620 {
4621 health+=1;
4622 flags |= 2;
4623 }
4624
4625 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4626 {
4627 health+=1;
4628 flags |= 4;
4629 }
4630
4631 if (flags != 7)
4421 return health; 4632 return health;
4422 4633
4423 // A login in the last 4 mins? We can't be doing too badly 4634 // A login in the last 4 mins? We can't be doing too badly
4424 // 4635 //
4425 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4636 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4426 health++; 4637 health++;
4427 else
4428 return health;
4429
4430 CheckHeartbeat();
4431 4638
4432 return health; 4639 return health;
4433 } 4640 }
@@ -4620,7 +4827,7 @@ namespace OpenSim.Region.Framework.Scenes
4620 if (m_firstHeartbeat) 4827 if (m_firstHeartbeat)
4621 return; 4828 return;
4622 4829
4623 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4830 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4624 StartTimer(); 4831 StartTimer();
4625 } 4832 }
4626 4833
@@ -5030,6 +5237,54 @@ namespace OpenSim.Region.Framework.Scenes
5030 mapModule.GenerateMaptile(); 5237 mapModule.GenerateMaptile();
5031 } 5238 }
5032 5239
5240// public void CleanDroppedAttachments()
5241// {
5242// List<SceneObjectGroup> objectsToDelete =
5243// new List<SceneObjectGroup>();
5244//
5245// lock (m_cleaningAttachments)
5246// {
5247// ForEachSOG(delegate (SceneObjectGroup grp)
5248// {
5249// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5250// {
5251// UUID agentID = grp.OwnerID;
5252// if (agentID == UUID.Zero)
5253// {
5254// objectsToDelete.Add(grp);
5255// return;
5256// }
5257//
5258// ScenePresence sp = GetScenePresence(agentID);
5259// if (sp == null)
5260// {
5261// objectsToDelete.Add(grp);
5262// return;
5263// }
5264// }
5265// });
5266// }
5267//
5268// foreach (SceneObjectGroup grp in objectsToDelete)
5269// {
5270// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5271// DeleteSceneObject(grp, true);
5272// }
5273// }
5274
5275 public void ThreadAlive(int threadCode)
5276 {
5277 switch(threadCode)
5278 {
5279 case 1: // Incoming
5280 m_lastIncoming = Util.EnvironmentTickCount();
5281 break;
5282 case 2: // Incoming
5283 m_lastOutgoing = Util.EnvironmentTickCount();
5284 break;
5285 }
5286 }
5287
5033 // This method is called across the simulation connector to 5288 // This method is called across the simulation connector to
5034 // determine if a given agent is allowed in this region 5289 // determine if a given agent is allowed in this region
5035 // AS A ROOT AGENT. Returning false here will prevent them 5290 // AS A ROOT AGENT. Returning false here will prevent them
@@ -5038,6 +5293,14 @@ namespace OpenSim.Region.Framework.Scenes
5038 // child agent creation, thereby emulating the SL behavior. 5293 // child agent creation, thereby emulating the SL behavior.
5039 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5294 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5040 { 5295 {
5296 reason = "You are banned from the region";
5297
5298 if (Permissions.IsGod(agentID))
5299 {
5300 reason = String.Empty;
5301 return true;
5302 }
5303
5041 int num = m_sceneGraph.GetNumberOfScenePresences(); 5304 int num = m_sceneGraph.GetNumberOfScenePresences();
5042 5305
5043 if (num >= RegionInfo.RegionSettings.AgentLimit) 5306 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5049,11 +5312,82 @@ namespace OpenSim.Region.Framework.Scenes
5049 } 5312 }
5050 } 5313 }
5051 5314
5315 ScenePresence presence = GetScenePresence(agentID);
5316 IClientAPI client = null;
5317 AgentCircuitData aCircuit = null;
5318
5319 if (presence != null)
5320 {
5321 client = presence.ControllingClient;
5322 if (client != null)
5323 aCircuit = client.RequestClientInfo();
5324 }
5325
5326 // We may be called before there is a presence or a client.
5327 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5328 if (client == null)
5329 {
5330 aCircuit = new AgentCircuitData();
5331 aCircuit.AgentID = agentID;
5332 aCircuit.firstname = String.Empty;
5333 aCircuit.lastname = String.Empty;
5334 }
5335
5336 try
5337 {
5338 if (!AuthorizeUser(aCircuit, out reason))
5339 {
5340 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5341 return false;
5342 }
5343 }
5344 catch (Exception e)
5345 {
5346 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5347 return false;
5348 }
5349
5350 if (position == Vector3.Zero) // Teleport
5351 {
5352 float posX = 128.0f;
5353 float posY = 128.0f;
5354
5355 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5356 {
5357 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5358 return false;
5359 }
5360 }
5361 else // Walking
5362 {
5363 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5364 if (land == null)
5365 return false;
5366
5367 bool banned = land.IsBannedFromLand(agentID);
5368 bool restricted = land.IsRestrictedFromLand(agentID);
5369
5370 if (banned || restricted)
5371 return false;
5372 }
5373
5052 reason = String.Empty; 5374 reason = String.Empty;
5053 return true; 5375 return true;
5054 } 5376 }
5055 5377
5056 /// <summary> 5378 public void StartTimerWatchdog()
5379 {
5380 m_timerWatchdog.Interval = 1000;
5381 m_timerWatchdog.Elapsed += TimerWatchdog;
5382 m_timerWatchdog.AutoReset = true;
5383 m_timerWatchdog.Start();
5384 }
5385
5386 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5387 {
5388 CheckHeartbeat();
5389 }
5390
5057 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5391 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5058 /// autopilot that moves an avatar to a sit target!. 5392 /// autopilot that moves an avatar to a sit target!.
5059 /// </summary> 5393 /// </summary>