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.cs504
1 files changed, 428 insertions, 76 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 3347822..ec5cf32 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;
@@ -677,6 +700,7 @@ namespace OpenSim.Region.Framework.Scenes
677 m_persistAfter *= 10000000; 700 m_persistAfter *= 10000000;
678 701
679 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 702 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
703 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
680 704
681 IConfig packetConfig = m_config.Configs["PacketPool"]; 705 IConfig packetConfig = m_config.Configs["PacketPool"];
682 if (packetConfig != null) 706 if (packetConfig != null)
@@ -686,6 +710,8 @@ namespace OpenSim.Region.Framework.Scenes
686 } 710 }
687 711
688 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 712 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
713 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
714 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
689 715
690 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 716 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
691 if (m_generateMaptiles) 717 if (m_generateMaptiles)
@@ -721,9 +747,9 @@ namespace OpenSim.Region.Framework.Scenes
721 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); 747 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
722 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); 748 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
723 } 749 }
724 catch 750 catch (Exception e)
725 { 751 {
726 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 752 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
727 } 753 }
728 754
729 #endregion Region Config 755 #endregion Region Config
@@ -1134,7 +1160,22 @@ namespace OpenSim.Region.Framework.Scenes
1134 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1160 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1135 if (HeartbeatThread != null) 1161 if (HeartbeatThread != null)
1136 { 1162 {
1163 m_hbRestarts++;
1164 if(m_hbRestarts > 10)
1165 Environment.Exit(1);
1166 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1167
1168//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1169//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1170//proc.EnableRaisingEvents=false;
1171//proc.StartInfo.FileName = "/bin/kill";
1172//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1173//proc.Start();
1174//proc.WaitForExit();
1175//Thread.Sleep(1000);
1176//Environment.Exit(1);
1137 HeartbeatThread.Abort(); 1177 HeartbeatThread.Abort();
1178 Watchdog.AbortThread(HeartbeatThread.ManagedThreadId);
1138 HeartbeatThread = null; 1179 HeartbeatThread = null;
1139 } 1180 }
1140 m_lastUpdate = Util.EnvironmentTickCount(); 1181 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1181,9 +1222,6 @@ namespace OpenSim.Region.Framework.Scenes
1181 m_eventManager.TriggerOnRegionStarted(this); 1222 m_eventManager.TriggerOnRegionStarted(this);
1182 while (!shuttingdown) 1223 while (!shuttingdown)
1183 Update(); 1224 Update();
1184
1185 m_lastUpdate = Util.EnvironmentTickCount();
1186 m_firstHeartbeat = false;
1187 } 1225 }
1188 catch (ThreadAbortException) 1226 catch (ThreadAbortException)
1189 { 1227 {
@@ -1281,6 +1319,13 @@ namespace OpenSim.Region.Framework.Scenes
1281 eventMS = Util.EnvironmentTickCountSubtract(evMS); ; 1319 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1282 } 1320 }
1283 1321
1322 // if (Frame % m_update_land == 0)
1323 // {
1324 // int ldMS = Util.EnvironmentTickCount();
1325 // UpdateLand();
1326 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1327 // }
1328
1284 if (Frame % m_update_backup == 0) 1329 if (Frame % m_update_backup == 0)
1285 { 1330 {
1286 int backMS = Util.EnvironmentTickCount(); 1331 int backMS = Util.EnvironmentTickCount();
@@ -1390,12 +1435,16 @@ namespace OpenSim.Region.Framework.Scenes
1390 maintc = Util.EnvironmentTickCountSubtract(maintc); 1435 maintc = Util.EnvironmentTickCountSubtract(maintc);
1391 maintc = (int)(MinFrameTime * 1000) - maintc; 1436 maintc = (int)(MinFrameTime * 1000) - maintc;
1392 1437
1438
1439 m_lastUpdate = Util.EnvironmentTickCount();
1440 m_firstHeartbeat = false;
1441
1393 if (maintc > 0) 1442 if (maintc > 0)
1394 Thread.Sleep(maintc); 1443 Thread.Sleep(maintc);
1395 1444
1396 // Tell the watchdog that this thread is still alive 1445 // Tell the watchdog that this thread is still alive
1397 Watchdog.UpdateThread(); 1446 Watchdog.UpdateThread();
1398 } 1447 }
1399 1448
1400 public void AddGroupTarget(SceneObjectGroup grp) 1449 public void AddGroupTarget(SceneObjectGroup grp)
1401 { 1450 {
@@ -1411,9 +1460,9 @@ namespace OpenSim.Region.Framework.Scenes
1411 1460
1412 private void CheckAtTargets() 1461 private void CheckAtTargets()
1413 { 1462 {
1414 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1463 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1415 lock (m_groupsWithTargets) 1464 lock (m_groupsWithTargets)
1416 objs = m_groupsWithTargets.Values; 1465 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1417 1466
1418 foreach (SceneObjectGroup entry in objs) 1467 foreach (SceneObjectGroup entry in objs)
1419 entry.checkAtTargets(); 1468 entry.checkAtTargets();
@@ -1495,7 +1544,7 @@ namespace OpenSim.Region.Framework.Scenes
1495 msg.fromAgentName = "Server"; 1544 msg.fromAgentName = "Server";
1496 msg.dialog = (byte)19; // Object msg 1545 msg.dialog = (byte)19; // Object msg
1497 msg.fromGroup = false; 1546 msg.fromGroup = false;
1498 msg.offline = (byte)0; 1547 msg.offline = (byte)1;
1499 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1548 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1500 msg.Position = Vector3.Zero; 1549 msg.Position = Vector3.Zero;
1501 msg.RegionID = RegionInfo.RegionID.Guid; 1550 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1726,14 +1775,24 @@ namespace OpenSim.Region.Framework.Scenes
1726 /// <returns></returns> 1775 /// <returns></returns>
1727 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1776 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1728 { 1777 {
1778
1779 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1780 Vector3 wpos = Vector3.Zero;
1781 // Check for water surface intersection from above
1782 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1783 {
1784 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1785 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1786 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1787 wpos.Z = wheight;
1788 }
1789
1729 Vector3 pos = Vector3.Zero; 1790 Vector3 pos = Vector3.Zero;
1730 if (RayEndIsIntersection == (byte)1) 1791 if (RayEndIsIntersection == (byte)1)
1731 { 1792 {
1732 pos = RayEnd; 1793 pos = RayEnd;
1733 return pos;
1734 } 1794 }
1735 1795 else if (RayTargetID != UUID.Zero)
1736 if (RayTargetID != UUID.Zero)
1737 { 1796 {
1738 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1797 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1739 1798
@@ -1755,7 +1814,7 @@ namespace OpenSim.Region.Framework.Scenes
1755 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1814 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1756 1815
1757 // Un-comment out the following line to Get Raytrace results printed to the console. 1816 // Un-comment out the following line to Get Raytrace results printed to the console.
1758 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1817 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1759 float ScaleOffset = 0.5f; 1818 float ScaleOffset = 0.5f;
1760 1819
1761 // If we hit something 1820 // If we hit something
@@ -1778,13 +1837,10 @@ namespace OpenSim.Region.Framework.Scenes
1778 //pos.Z -= 0.25F; 1837 //pos.Z -= 0.25F;
1779 1838
1780 } 1839 }
1781
1782 return pos;
1783 } 1840 }
1784 else 1841 else
1785 { 1842 {
1786 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1843 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1787
1788 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1844 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1789 1845
1790 // Un-comment the following line to print the raytrace results to the console. 1846 // Un-comment the following line to print the raytrace results to the console.
@@ -1793,13 +1849,12 @@ namespace OpenSim.Region.Framework.Scenes
1793 if (ei.HitTF) 1849 if (ei.HitTF)
1794 { 1850 {
1795 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1851 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1796 } else 1852 }
1853 else
1797 { 1854 {
1798 // fall back to our stupid functionality 1855 // fall back to our stupid functionality
1799 pos = RayEnd; 1856 pos = RayEnd;
1800 } 1857 }
1801
1802 return pos;
1803 } 1858 }
1804 } 1859 }
1805 else 1860 else
@@ -1810,8 +1865,12 @@ namespace OpenSim.Region.Framework.Scenes
1810 //increase height so its above the ground. 1865 //increase height so its above the ground.
1811 //should be getting the normal of the ground at the rez point and using that? 1866 //should be getting the normal of the ground at the rez point and using that?
1812 pos.Z += scale.Z / 2f; 1867 pos.Z += scale.Z / 2f;
1813 return pos; 1868// return pos;
1814 } 1869 }
1870
1871 // check against posible water intercept
1872 if (wpos.Z > pos.Z) pos = wpos;
1873 return pos;
1815 } 1874 }
1816 1875
1817 1876
@@ -1895,7 +1954,10 @@ namespace OpenSim.Region.Framework.Scenes
1895 public bool AddRestoredSceneObject( 1954 public bool AddRestoredSceneObject(
1896 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1955 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1897 { 1956 {
1898 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1957 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1958 if (result)
1959 sceneObject.IsDeleted = false;
1960 return result;
1899 } 1961 }
1900 1962
1901 /// <summary> 1963 /// <summary>
@@ -1987,6 +2049,15 @@ namespace OpenSim.Region.Framework.Scenes
1987 /// </summary> 2049 /// </summary>
1988 public void DeleteAllSceneObjects() 2050 public void DeleteAllSceneObjects()
1989 { 2051 {
2052 DeleteAllSceneObjects(false);
2053 }
2054
2055 /// <summary>
2056 /// Delete every object from the scene. This does not include attachments worn by avatars.
2057 /// </summary>
2058 public void DeleteAllSceneObjects(bool exceptNoCopy)
2059 {
2060 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1990 lock (Entities) 2061 lock (Entities)
1991 { 2062 {
1992 EntityBase[] entities = Entities.GetEntities(); 2063 EntityBase[] entities = Entities.GetEntities();
@@ -1995,11 +2066,24 @@ namespace OpenSim.Region.Framework.Scenes
1995 if (e is SceneObjectGroup) 2066 if (e is SceneObjectGroup)
1996 { 2067 {
1997 SceneObjectGroup sog = (SceneObjectGroup)e; 2068 SceneObjectGroup sog = (SceneObjectGroup)e;
1998 if (!sog.IsAttachment) 2069 if (sog != null && !sog.IsAttachment)
1999 DeleteSceneObject((SceneObjectGroup)e, false); 2070 {
2071 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2072 {
2073 DeleteSceneObject((SceneObjectGroup)e, false);
2074 }
2075 else
2076 {
2077 toReturn.Add((SceneObjectGroup)e);
2078 }
2079 }
2000 } 2080 }
2001 } 2081 }
2002 } 2082 }
2083 if (toReturn.Count > 0)
2084 {
2085 returnObjects(toReturn.ToArray(), UUID.Zero);
2086 }
2003 } 2087 }
2004 2088
2005 /// <summary> 2089 /// <summary>
@@ -2047,6 +2131,8 @@ namespace OpenSim.Region.Framework.Scenes
2047 } 2131 }
2048 2132
2049 group.DeleteGroupFromScene(silent); 2133 group.DeleteGroupFromScene(silent);
2134 if (!silent)
2135 SendKillObject(new List<uint>() { group.LocalId });
2050 2136
2051// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2137// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2052 } 2138 }
@@ -2401,10 +2487,17 @@ namespace OpenSim.Region.Framework.Scenes
2401 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2487 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2402 public bool AddSceneObject(SceneObjectGroup sceneObject) 2488 public bool AddSceneObject(SceneObjectGroup sceneObject)
2403 { 2489 {
2490 if (sceneObject.OwnerID == UUID.Zero)
2491 {
2492 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2493 return false;
2494 }
2495
2404 // If the user is banned, we won't let any of their objects 2496 // If the user is banned, we won't let any of their objects
2405 // enter. Period. 2497 // enter. Period.
2406 // 2498 //
2407 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2499 int flags = GetUserFlags(sceneObject.OwnerID);
2500 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2408 { 2501 {
2409 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); 2502 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2410 2503
@@ -2450,12 +2543,23 @@ namespace OpenSim.Region.Framework.Scenes
2450 } 2543 }
2451 else 2544 else
2452 { 2545 {
2546 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2453 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2547 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2454 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2548 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2455 } 2549 }
2550 if (sceneObject.OwnerID == UUID.Zero)
2551 {
2552 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2553 return false;
2554 }
2456 } 2555 }
2457 else 2556 else
2458 { 2557 {
2558 if (sceneObject.OwnerID == UUID.Zero)
2559 {
2560 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2561 return false;
2562 }
2459 AddRestoredSceneObject(sceneObject, true, false); 2563 AddRestoredSceneObject(sceneObject, true, false);
2460 2564
2461 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2565 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2484,6 +2588,24 @@ namespace OpenSim.Region.Framework.Scenes
2484 return 2; // StateSource.PrimCrossing 2588 return 2; // StateSource.PrimCrossing
2485 } 2589 }
2486 2590
2591 public int GetUserFlags(UUID user)
2592 {
2593 //Unfortunately the SP approach means that the value is cached until region is restarted
2594 /*
2595 ScenePresence sp;
2596 if (TryGetScenePresence(user, out sp))
2597 {
2598 return sp.UserFlags;
2599 }
2600 else
2601 {
2602 */
2603 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2604 if (uac == null)
2605 return 0;
2606 return uac.UserFlags;
2607 //}
2608 }
2487 #endregion 2609 #endregion
2488 2610
2489 #region Add/Remove Avatar Methods 2611 #region Add/Remove Avatar Methods
@@ -2498,6 +2620,7 @@ namespace OpenSim.Region.Framework.Scenes
2498 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2620 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2499 2621
2500 CheckHeartbeat(); 2622 CheckHeartbeat();
2623 ScenePresence presence;
2501 2624
2502 ScenePresence sp = GetScenePresence(client.AgentId); 2625 ScenePresence sp = GetScenePresence(client.AgentId);
2503 2626
@@ -2546,7 +2669,13 @@ namespace OpenSim.Region.Framework.Scenes
2546 2669
2547 EventManager.TriggerOnNewClient(client); 2670 EventManager.TriggerOnNewClient(client);
2548 if (vialogin) 2671 if (vialogin)
2672 {
2549 EventManager.TriggerOnClientLogin(client); 2673 EventManager.TriggerOnClientLogin(client);
2674 // Send initial parcel data
2675 Vector3 pos = sp.AbsolutePosition;
2676 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2677 land.SendLandUpdateToClient(client);
2678 }
2550 2679
2551 return sp; 2680 return sp;
2552 } 2681 }
@@ -2636,19 +2765,12 @@ namespace OpenSim.Region.Framework.Scenes
2636 // and the scene presence and the client, if they exist 2765 // and the scene presence and the client, if they exist
2637 try 2766 try
2638 { 2767 {
2639 // We need to wait for the client to make UDP contact first. 2768 ScenePresence sp = GetScenePresence(agentID);
2640 // It's the UDP contact that creates the scene presence 2769 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2641 ScenePresence sp = WaitGetScenePresence(agentID); 2770
2642 if (sp != null) 2771 if (sp != null)
2643 {
2644 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2645
2646 sp.ControllingClient.Close(); 2772 sp.ControllingClient.Close();
2647 } 2773
2648 else
2649 {
2650 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2651 }
2652 // BANG! SLASH! 2774 // BANG! SLASH!
2653 m_authenticateHandler.RemoveCircuit(agentID); 2775 m_authenticateHandler.RemoveCircuit(agentID);
2654 2776
@@ -2749,6 +2871,7 @@ namespace OpenSim.Region.Framework.Scenes
2749 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2871 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2750 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2872 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2751 client.OnCopyInventoryItem += CopyInventoryItem; 2873 client.OnCopyInventoryItem += CopyInventoryItem;
2874 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2752 client.OnMoveInventoryItem += MoveInventoryItem; 2875 client.OnMoveInventoryItem += MoveInventoryItem;
2753 client.OnRemoveInventoryItem += RemoveInventoryItem; 2876 client.OnRemoveInventoryItem += RemoveInventoryItem;
2754 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2877 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2924,15 +3047,16 @@ namespace OpenSim.Region.Framework.Scenes
2924 /// </summary> 3047 /// </summary>
2925 /// <param name="agentId">The avatar's Unique ID</param> 3048 /// <param name="agentId">The avatar's Unique ID</param>
2926 /// <param name="client">The IClientAPI for the client</param> 3049 /// <param name="client">The IClientAPI for the client</param>
2927 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3050 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2928 { 3051 {
2929 if (m_teleportModule != null) 3052 if (m_teleportModule != null)
2930 m_teleportModule.TeleportHome(agentId, client); 3053 return m_teleportModule.TeleportHome(agentId, client);
2931 else 3054 else
2932 { 3055 {
2933 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3056 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2934 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3057 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2935 } 3058 }
3059 return false;
2936 } 3060 }
2937 3061
2938 /// <summary> 3062 /// <summary>
@@ -3042,6 +3166,16 @@ namespace OpenSim.Region.Framework.Scenes
3042 /// <param name="flags"></param> 3166 /// <param name="flags"></param>
3043 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3167 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3044 { 3168 {
3169 //Add half the avatar's height so that the user doesn't fall through prims
3170 ScenePresence presence;
3171 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3172 {
3173 if (presence.Appearance != null)
3174 {
3175 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3176 }
3177 }
3178
3045 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3179 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3046 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3180 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3047 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3181 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3110,8 +3244,9 @@ namespace OpenSim.Region.Framework.Scenes
3110 regions.Remove(RegionInfo.RegionHandle); 3244 regions.Remove(RegionInfo.RegionHandle);
3111 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3245 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3112 } 3246 }
3113 3247 m_log.Debug("[Scene] Beginning ClientClosed");
3114 m_eventManager.TriggerClientClosed(agentID, this); 3248 m_eventManager.TriggerClientClosed(agentID, this);
3249 m_log.Debug("[Scene] Finished ClientClosed");
3115 } 3250 }
3116 catch (NullReferenceException) 3251 catch (NullReferenceException)
3117 { 3252 {
@@ -3173,9 +3308,10 @@ namespace OpenSim.Region.Framework.Scenes
3173 { 3308 {
3174 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); 3309 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace);
3175 } 3310 }
3176 3311 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3177 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3312 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3178// CleanDroppedAttachments(); 3313// CleanDroppedAttachments();
3314 m_log.Debug("[Scene] The avatar has left the building");
3179 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3315 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3180 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3316 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3181 } 3317 }
@@ -3294,13 +3430,16 @@ namespace OpenSim.Region.Framework.Scenes
3294 sp = null; 3430 sp = null;
3295 } 3431 }
3296 3432
3297 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3298 3433
3299 //On login test land permisions 3434 //On login test land permisions
3300 if (vialogin) 3435 if (vialogin)
3301 { 3436 {
3302 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3437 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3438 if (cache != null)
3439 cache.Remove(agent.firstname + " " + agent.lastname);
3440 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3303 { 3441 {
3442 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3304 return false; 3443 return false;
3305 } 3444 }
3306 } 3445 }
@@ -3324,8 +3463,13 @@ namespace OpenSim.Region.Framework.Scenes
3324 3463
3325 try 3464 try
3326 { 3465 {
3327 if (!AuthorizeUser(agent, out reason)) 3466 // Always check estate if this is a login. Always
3328 return false; 3467 // check if banned regions are to be blacked out.
3468 if (vialogin || (!m_seeIntoBannedRegion))
3469 {
3470 if (!AuthorizeUser(agent, out reason))
3471 return false;
3472 }
3329 } 3473 }
3330 catch (Exception e) 3474 catch (Exception e)
3331 { 3475 {
@@ -3428,6 +3572,8 @@ namespace OpenSim.Region.Framework.Scenes
3428 } 3572 }
3429 } 3573 }
3430 // Honor parcel landing type and position. 3574 // Honor parcel landing type and position.
3575 /*
3576 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3431 if (land != null) 3577 if (land != null)
3432 { 3578 {
3433 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3579 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3435,26 +3581,34 @@ namespace OpenSim.Region.Framework.Scenes
3435 agent.startpos = land.LandData.UserLocation; 3581 agent.startpos = land.LandData.UserLocation;
3436 } 3582 }
3437 } 3583 }
3584 */// This is now handled properly in ScenePresence.MakeRootAgent
3438 } 3585 }
3439 3586
3440 return true; 3587 return true;
3441 } 3588 }
3442 3589
3443 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3590 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3444 { 3591 {
3445 3592 reason = String.Empty;
3446 bool banned = land.IsBannedFromLand(agent.AgentID); 3593 if (Permissions.IsGod(agentID))
3447 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3594 return true;
3595
3596 ILandObject land = LandChannel.GetLandObject(posX, posY);
3597 if (land == null)
3598 return false;
3599
3600 bool banned = land.IsBannedFromLand(agentID);
3601 bool restricted = land.IsRestrictedFromLand(agentID);
3448 3602
3449 if (banned || restricted) 3603 if (banned || restricted)
3450 { 3604 {
3451 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3605 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3452 if (nearestParcel != null) 3606 if (nearestParcel != null)
3453 { 3607 {
3454 //Move agent to nearest allowed 3608 //Move agent to nearest allowed
3455 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3609 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3456 agent.startpos.X = newPosition.X; 3610 posX = newPosition.X;
3457 agent.startpos.Y = newPosition.Y; 3611 posY = newPosition.Y;
3458 } 3612 }
3459 else 3613 else
3460 { 3614 {
@@ -3516,7 +3670,7 @@ namespace OpenSim.Region.Framework.Scenes
3516 3670
3517 if (!m_strictAccessControl) return true; 3671 if (!m_strictAccessControl) return true;
3518 if (Permissions.IsGod(agent.AgentID)) return true; 3672 if (Permissions.IsGod(agent.AgentID)) return true;
3519 3673
3520 if (AuthorizationService != null) 3674 if (AuthorizationService != null)
3521 { 3675 {
3522 if (!AuthorizationService.IsAuthorizedForRegion( 3676 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3524,14 +3678,14 @@ namespace OpenSim.Region.Framework.Scenes
3524 { 3678 {
3525 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3679 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3526 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3680 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3527 3681
3528 return false; 3682 return false;
3529 } 3683 }
3530 } 3684 }
3531 3685
3532 if (m_regInfo.EstateSettings != null) 3686 if (m_regInfo.EstateSettings != null)
3533 { 3687 {
3534 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3688 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3535 { 3689 {
3536 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3690 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3537 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3691 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3723,6 +3877,13 @@ namespace OpenSim.Region.Framework.Scenes
3723 3877
3724 // We have to wait until the viewer contacts this region after receiving EAC. 3878 // We have to wait until the viewer contacts this region after receiving EAC.
3725 // That calls AddNewClient, which finally creates the ScenePresence 3879 // That calls AddNewClient, which finally creates the ScenePresence
3880 int flags = GetUserFlags(cAgentData.AgentID);
3881 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3882 {
3883 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3884 return false;
3885 }
3886
3726 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3887 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3727 if (nearestParcel == null) 3888 if (nearestParcel == null)
3728 { 3889 {
@@ -3804,12 +3965,22 @@ namespace OpenSim.Region.Framework.Scenes
3804 return false; 3965 return false;
3805 } 3966 }
3806 3967
3968 public bool IncomingCloseAgent(UUID agentID)
3969 {
3970 return IncomingCloseAgent(agentID, false);
3971 }
3972
3973 public bool IncomingCloseChildAgent(UUID agentID)
3974 {
3975 return IncomingCloseAgent(agentID, true);
3976 }
3977
3807 /// <summary> 3978 /// <summary>
3808 /// Tell a single agent to disconnect from the region. 3979 /// Tell a single agent to disconnect from the region.
3809 /// </summary> 3980 /// </summary>
3810 /// <param name="regionHandle"></param>
3811 /// <param name="agentID"></param> 3981 /// <param name="agentID"></param>
3812 public bool IncomingCloseAgent(UUID agentID) 3982 /// <param name="childOnly"></param>
3983 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3813 { 3984 {
3814 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3985 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3815 3986
@@ -3821,7 +3992,7 @@ namespace OpenSim.Region.Framework.Scenes
3821 { 3992 {
3822 m_sceneGraph.removeUserCount(false); 3993 m_sceneGraph.removeUserCount(false);
3823 } 3994 }
3824 else 3995 else if (!childOnly)
3825 { 3996 {
3826 m_sceneGraph.removeUserCount(true); 3997 m_sceneGraph.removeUserCount(true);
3827 } 3998 }
@@ -3837,9 +4008,12 @@ namespace OpenSim.Region.Framework.Scenes
3837 } 4008 }
3838 else 4009 else
3839 presence.ControllingClient.SendShutdownConnectionNotice(); 4010 presence.ControllingClient.SendShutdownConnectionNotice();
4011 presence.ControllingClient.Close(false);
4012 }
4013 else if (!childOnly)
4014 {
4015 presence.ControllingClient.Close(true);
3840 } 4016 }
3841
3842 presence.ControllingClient.Close();
3843 return true; 4017 return true;
3844 } 4018 }
3845 4019
@@ -4432,34 +4606,78 @@ namespace OpenSim.Region.Framework.Scenes
4432 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4606 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4433 } 4607 }
4434 4608
4435 public int GetHealth() 4609 public int GetHealth(out int flags, out string message)
4436 { 4610 {
4437 // Returns: 4611 // Returns:
4438 // 1 = sim is up and accepting http requests. The heartbeat has 4612 // 1 = sim is up and accepting http requests. The heartbeat has
4439 // stopped and the sim is probably locked up, but a remote 4613 // stopped and the sim is probably locked up, but a remote
4440 // admin restart may succeed 4614 // admin restart may succeed
4441 // 4615 //
4442 // 2 = Sim is up and the heartbeat is running. The sim is likely 4616 // 2 = Sim is up and the heartbeat is running. The sim is likely
4443 // usable for people within and logins _may_ work 4617 // usable for people within
4618 //
4619 // 3 = Sim is up and one packet thread is running. Sim is
4620 // unstable and will not accept new logins
4621 //
4622 // 4 = Sim is up and both packet threads are running. Sim is
4623 // likely usable
4444 // 4624 //
4445 // 3 = We have seen a new user enter within the past 4 minutes 4625 // 5 = We have seen a new user enter within the past 4 minutes
4446 // which can be seen as positive confirmation of sim health 4626 // which can be seen as positive confirmation of sim health
4447 // 4627 //
4628
4629 flags = 0;
4630 message = String.Empty;
4631
4632 CheckHeartbeat();
4633
4634 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4635 {
4636 // We're still starting
4637 // 0 means "in startup", it can't happen another way, since
4638 // to get here, we must be able to accept http connections
4639 return 0;
4640 }
4641
4448 int health=1; // Start at 1, means we're up 4642 int health=1; // Start at 1, means we're up
4449 4643
4450 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4644 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4645 {
4646 health+=1;
4647 flags |= 1;
4648 }
4649
4650 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4651 {
4652 health+=1;
4653 flags |= 2;
4654 }
4655
4656 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4657 {
4451 health+=1; 4658 health+=1;
4659 flags |= 4;
4660 }
4452 else 4661 else
4662 {
4663int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
4664System.Diagnostics.Process proc = new System.Diagnostics.Process();
4665proc.EnableRaisingEvents=false;
4666proc.StartInfo.FileName = "/bin/kill";
4667proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
4668proc.Start();
4669proc.WaitForExit();
4670Thread.Sleep(1000);
4671Environment.Exit(1);
4672 }
4673
4674 if (flags != 7)
4453 return health; 4675 return health;
4454 4676
4455 // A login in the last 4 mins? We can't be doing too badly 4677 // A login in the last 4 mins? We can't be doing too badly
4456 // 4678 //
4457 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4679 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4458 health++; 4680 health++;
4459 else
4460 return health;
4461
4462 CheckHeartbeat();
4463 4681
4464 return health; 4682 return health;
4465 } 4683 }
@@ -4652,7 +4870,7 @@ namespace OpenSim.Region.Framework.Scenes
4652 if (m_firstHeartbeat) 4870 if (m_firstHeartbeat)
4653 return; 4871 return;
4654 4872
4655 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4873 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4656 StartTimer(); 4874 StartTimer();
4657 } 4875 }
4658 4876
@@ -4666,9 +4884,14 @@ namespace OpenSim.Region.Framework.Scenes
4666 get { return m_allowScriptCrossings; } 4884 get { return m_allowScriptCrossings; }
4667 } 4885 }
4668 4886
4669 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 4887 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
4888 {
4889 return GetNearestAllowedPosition(avatar, null);
4890 }
4891
4892 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
4670 { 4893 {
4671 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 4894 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
4672 4895
4673 if (nearestParcel != null) 4896 if (nearestParcel != null)
4674 { 4897 {
@@ -4727,13 +4950,18 @@ namespace OpenSim.Region.Framework.Scenes
4727 4950
4728 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 4951 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
4729 { 4952 {
4953 return GetNearestAllowedParcel(avatarId, x, y, null);
4954 }
4955
4956 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
4957 {
4730 List<ILandObject> all = AllParcels(); 4958 List<ILandObject> all = AllParcels();
4731 float minParcelDistance = float.MaxValue; 4959 float minParcelDistance = float.MaxValue;
4732 ILandObject nearestParcel = null; 4960 ILandObject nearestParcel = null;
4733 4961
4734 foreach (var parcel in all) 4962 foreach (var parcel in all)
4735 { 4963 {
4736 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 4964 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
4737 { 4965 {
4738 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 4966 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
4739 if (parcelDistance < minParcelDistance) 4967 if (parcelDistance < minParcelDistance)
@@ -4975,7 +5203,55 @@ namespace OpenSim.Region.Framework.Scenes
4975 mapModule.GenerateMaptile(); 5203 mapModule.GenerateMaptile();
4976 } 5204 }
4977 5205
4978 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5206// public void CleanDroppedAttachments()
5207// {
5208// List<SceneObjectGroup> objectsToDelete =
5209// new List<SceneObjectGroup>();
5210//
5211// lock (m_cleaningAttachments)
5212// {
5213// ForEachSOG(delegate (SceneObjectGroup grp)
5214// {
5215// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5216// {
5217// UUID agentID = grp.OwnerID;
5218// if (agentID == UUID.Zero)
5219// {
5220// objectsToDelete.Add(grp);
5221// return;
5222// }
5223//
5224// ScenePresence sp = GetScenePresence(agentID);
5225// if (sp == null)
5226// {
5227// objectsToDelete.Add(grp);
5228// return;
5229// }
5230// }
5231// });
5232// }
5233//
5234// foreach (SceneObjectGroup grp in objectsToDelete)
5235// {
5236// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5237// DeleteSceneObject(grp, true);
5238// }
5239// }
5240
5241 public void ThreadAlive(int threadCode)
5242 {
5243 switch(threadCode)
5244 {
5245 case 1: // Incoming
5246 m_lastIncoming = Util.EnvironmentTickCount();
5247 break;
5248 case 2: // Incoming
5249 m_lastOutgoing = Util.EnvironmentTickCount();
5250 break;
5251 }
5252 }
5253
5254 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
4979 { 5255 {
4980 RegenerateMaptile(); 5256 RegenerateMaptile();
4981 5257
@@ -4994,6 +5270,14 @@ namespace OpenSim.Region.Framework.Scenes
4994 // child agent creation, thereby emulating the SL behavior. 5270 // child agent creation, thereby emulating the SL behavior.
4995 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5271 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
4996 { 5272 {
5273 reason = "You are banned from the region";
5274
5275 if (Permissions.IsGod(agentID))
5276 {
5277 reason = String.Empty;
5278 return true;
5279 }
5280
4997 int num = m_sceneGraph.GetNumberOfScenePresences(); 5281 int num = m_sceneGraph.GetNumberOfScenePresences();
4998 5282
4999 if (num >= RegionInfo.RegionSettings.AgentLimit) 5283 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5005,6 +5289,41 @@ namespace OpenSim.Region.Framework.Scenes
5005 } 5289 }
5006 } 5290 }
5007 5291
5292 ScenePresence presence = GetScenePresence(agentID);
5293 IClientAPI client = null;
5294 AgentCircuitData aCircuit = null;
5295
5296 if (presence != null)
5297 {
5298 client = presence.ControllingClient;
5299 if (client != null)
5300 aCircuit = client.RequestClientInfo();
5301 }
5302
5303 // We may be called before there is a presence or a client.
5304 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5305 if (client == null)
5306 {
5307 aCircuit = new AgentCircuitData();
5308 aCircuit.AgentID = agentID;
5309 aCircuit.firstname = String.Empty;
5310 aCircuit.lastname = String.Empty;
5311 }
5312
5313 try
5314 {
5315 if (!AuthorizeUser(aCircuit, out reason))
5316 {
5317 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5318 return false;
5319 }
5320 }
5321 catch (Exception e)
5322 {
5323 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5324 return false;
5325 }
5326
5008 if (position == Vector3.Zero) // Teleport 5327 if (position == Vector3.Zero) // Teleport
5009 { 5328 {
5010 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5329 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5033,13 +5352,46 @@ namespace OpenSim.Region.Framework.Scenes
5033 } 5352 }
5034 } 5353 }
5035 } 5354 }
5355
5356 float posX = 128.0f;
5357 float posY = 128.0f;
5358
5359 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5360 {
5361 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5362 return false;
5363 }
5364 }
5365 else // Walking
5366 {
5367 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5368 if (land == null)
5369 return false;
5370
5371 bool banned = land.IsBannedFromLand(agentID);
5372 bool restricted = land.IsRestrictedFromLand(agentID);
5373
5374 if (banned || restricted)
5375 return false;
5036 } 5376 }
5037 5377
5038 reason = String.Empty; 5378 reason = String.Empty;
5039 return true; 5379 return true;
5040 } 5380 }
5041 5381
5042 /// <summary> 5382 public void StartTimerWatchdog()
5383 {
5384 m_timerWatchdog.Interval = 1000;
5385 m_timerWatchdog.Elapsed += TimerWatchdog;
5386 m_timerWatchdog.AutoReset = true;
5387 m_timerWatchdog.Start();
5388 }
5389
5390 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5391 {
5392 CheckHeartbeat();
5393 }
5394
5043 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5395 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5044 /// autopilot that moves an avatar to a sit target!. 5396 /// autopilot that moves an avatar to a sit target!.
5045 /// </summary> 5397 /// </summary>