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 d2a8ad0..552a75f 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 }
@@ -3297,13 +3433,16 @@ namespace OpenSim.Region.Framework.Scenes
3297 sp = null; 3433 sp = null;
3298 } 3434 }
3299 3435
3300 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3301 3436
3302 //On login test land permisions 3437 //On login test land permisions
3303 if (vialogin) 3438 if (vialogin)
3304 { 3439 {
3305 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3440 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3441 if (cache != null)
3442 cache.Remove(agent.firstname + " " + agent.lastname);
3443 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3306 { 3444 {
3445 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3307 return false; 3446 return false;
3308 } 3447 }
3309 } 3448 }
@@ -3327,8 +3466,13 @@ namespace OpenSim.Region.Framework.Scenes
3327 3466
3328 try 3467 try
3329 { 3468 {
3330 if (!AuthorizeUser(agent, out reason)) 3469 // Always check estate if this is a login. Always
3331 return false; 3470 // check if banned regions are to be blacked out.
3471 if (vialogin || (!m_seeIntoBannedRegion))
3472 {
3473 if (!AuthorizeUser(agent, out reason))
3474 return false;
3475 }
3332 } 3476 }
3333 catch (Exception e) 3477 catch (Exception e)
3334 { 3478 {
@@ -3454,6 +3598,8 @@ namespace OpenSim.Region.Framework.Scenes
3454 } 3598 }
3455 3599
3456 // Honor parcel landing type and position. 3600 // Honor parcel landing type and position.
3601 /*
3602 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3457 if (land != null) 3603 if (land != null)
3458 { 3604 {
3459 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3605 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3461,26 +3607,34 @@ namespace OpenSim.Region.Framework.Scenes
3461 agent.startpos = land.LandData.UserLocation; 3607 agent.startpos = land.LandData.UserLocation;
3462 } 3608 }
3463 } 3609 }
3610 */// This is now handled properly in ScenePresence.MakeRootAgent
3464 } 3611 }
3465 3612
3466 return true; 3613 return true;
3467 } 3614 }
3468 3615
3469 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3616 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3470 { 3617 {
3471 3618 reason = String.Empty;
3472 bool banned = land.IsBannedFromLand(agent.AgentID); 3619 if (Permissions.IsGod(agentID))
3473 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3620 return true;
3621
3622 ILandObject land = LandChannel.GetLandObject(posX, posY);
3623 if (land == null)
3624 return false;
3625
3626 bool banned = land.IsBannedFromLand(agentID);
3627 bool restricted = land.IsRestrictedFromLand(agentID);
3474 3628
3475 if (banned || restricted) 3629 if (banned || restricted)
3476 { 3630 {
3477 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3631 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3478 if (nearestParcel != null) 3632 if (nearestParcel != null)
3479 { 3633 {
3480 //Move agent to nearest allowed 3634 //Move agent to nearest allowed
3481 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3635 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3482 agent.startpos.X = newPosition.X; 3636 posX = newPosition.X;
3483 agent.startpos.Y = newPosition.Y; 3637 posY = newPosition.Y;
3484 } 3638 }
3485 else 3639 else
3486 { 3640 {
@@ -3542,7 +3696,7 @@ namespace OpenSim.Region.Framework.Scenes
3542 3696
3543 if (!m_strictAccessControl) return true; 3697 if (!m_strictAccessControl) return true;
3544 if (Permissions.IsGod(agent.AgentID)) return true; 3698 if (Permissions.IsGod(agent.AgentID)) return true;
3545 3699
3546 if (AuthorizationService != null) 3700 if (AuthorizationService != null)
3547 { 3701 {
3548 if (!AuthorizationService.IsAuthorizedForRegion( 3702 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3550,14 +3704,14 @@ namespace OpenSim.Region.Framework.Scenes
3550 { 3704 {
3551 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3705 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3552 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3706 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3553 3707
3554 return false; 3708 return false;
3555 } 3709 }
3556 } 3710 }
3557 3711
3558 if (m_regInfo.EstateSettings != null) 3712 if (m_regInfo.EstateSettings != null)
3559 { 3713 {
3560 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3714 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3561 { 3715 {
3562 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3716 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3563 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3717 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3749,6 +3903,13 @@ namespace OpenSim.Region.Framework.Scenes
3749 3903
3750 // We have to wait until the viewer contacts this region after receiving EAC. 3904 // We have to wait until the viewer contacts this region after receiving EAC.
3751 // That calls AddNewClient, which finally creates the ScenePresence 3905 // That calls AddNewClient, which finally creates the ScenePresence
3906 int flags = GetUserFlags(cAgentData.AgentID);
3907 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3908 {
3909 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3910 return false;
3911 }
3912
3752 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3913 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3753 if (nearestParcel == null) 3914 if (nearestParcel == null)
3754 { 3915 {
@@ -3830,12 +3991,22 @@ namespace OpenSim.Region.Framework.Scenes
3830 return false; 3991 return false;
3831 } 3992 }
3832 3993
3994 public bool IncomingCloseAgent(UUID agentID)
3995 {
3996 return IncomingCloseAgent(agentID, false);
3997 }
3998
3999 public bool IncomingCloseChildAgent(UUID agentID)
4000 {
4001 return IncomingCloseAgent(agentID, true);
4002 }
4003
3833 /// <summary> 4004 /// <summary>
3834 /// Tell a single agent to disconnect from the region. 4005 /// Tell a single agent to disconnect from the region.
3835 /// </summary> 4006 /// </summary>
3836 /// <param name="regionHandle"></param>
3837 /// <param name="agentID"></param> 4007 /// <param name="agentID"></param>
3838 public bool IncomingCloseAgent(UUID agentID) 4008 /// <param name="childOnly"></param>
4009 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3839 { 4010 {
3840 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 4011 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3841 4012
@@ -3847,7 +4018,7 @@ namespace OpenSim.Region.Framework.Scenes
3847 { 4018 {
3848 m_sceneGraph.removeUserCount(false); 4019 m_sceneGraph.removeUserCount(false);
3849 } 4020 }
3850 else 4021 else if (!childOnly)
3851 { 4022 {
3852 m_sceneGraph.removeUserCount(true); 4023 m_sceneGraph.removeUserCount(true);
3853 } 4024 }
@@ -3863,9 +4034,12 @@ namespace OpenSim.Region.Framework.Scenes
3863 } 4034 }
3864 else 4035 else
3865 presence.ControllingClient.SendShutdownConnectionNotice(); 4036 presence.ControllingClient.SendShutdownConnectionNotice();
4037 presence.ControllingClient.Close(false);
4038 }
4039 else if (!childOnly)
4040 {
4041 presence.ControllingClient.Close(true);
3866 } 4042 }
3867
3868 presence.ControllingClient.Close();
3869 return true; 4043 return true;
3870 } 4044 }
3871 4045
@@ -4458,34 +4632,78 @@ namespace OpenSim.Region.Framework.Scenes
4458 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4632 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4459 } 4633 }
4460 4634
4461 public int GetHealth() 4635 public int GetHealth(out int flags, out string message)
4462 { 4636 {
4463 // Returns: 4637 // Returns:
4464 // 1 = sim is up and accepting http requests. The heartbeat has 4638 // 1 = sim is up and accepting http requests. The heartbeat has
4465 // stopped and the sim is probably locked up, but a remote 4639 // stopped and the sim is probably locked up, but a remote
4466 // admin restart may succeed 4640 // admin restart may succeed
4467 // 4641 //
4468 // 2 = Sim is up and the heartbeat is running. The sim is likely 4642 // 2 = Sim is up and the heartbeat is running. The sim is likely
4469 // usable for people within and logins _may_ work 4643 // usable for people within
4644 //
4645 // 3 = Sim is up and one packet thread is running. Sim is
4646 // unstable and will not accept new logins
4647 //
4648 // 4 = Sim is up and both packet threads are running. Sim is
4649 // likely usable
4470 // 4650 //
4471 // 3 = We have seen a new user enter within the past 4 minutes 4651 // 5 = We have seen a new user enter within the past 4 minutes
4472 // which can be seen as positive confirmation of sim health 4652 // which can be seen as positive confirmation of sim health
4473 // 4653 //
4654
4655 flags = 0;
4656 message = String.Empty;
4657
4658 CheckHeartbeat();
4659
4660 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4661 {
4662 // We're still starting
4663 // 0 means "in startup", it can't happen another way, since
4664 // to get here, we must be able to accept http connections
4665 return 0;
4666 }
4667
4474 int health=1; // Start at 1, means we're up 4668 int health=1; // Start at 1, means we're up
4475 4669
4476 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4670 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4671 {
4672 health+=1;
4673 flags |= 1;
4674 }
4675
4676 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4677 {
4678 health+=1;
4679 flags |= 2;
4680 }
4681
4682 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4683 {
4477 health+=1; 4684 health+=1;
4685 flags |= 4;
4686 }
4478 else 4687 else
4688 {
4689int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
4690System.Diagnostics.Process proc = new System.Diagnostics.Process();
4691proc.EnableRaisingEvents=false;
4692proc.StartInfo.FileName = "/bin/kill";
4693proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
4694proc.Start();
4695proc.WaitForExit();
4696Thread.Sleep(1000);
4697Environment.Exit(1);
4698 }
4699
4700 if (flags != 7)
4479 return health; 4701 return health;
4480 4702
4481 // A login in the last 4 mins? We can't be doing too badly 4703 // A login in the last 4 mins? We can't be doing too badly
4482 // 4704 //
4483 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4705 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4484 health++; 4706 health++;
4485 else
4486 return health;
4487
4488 CheckHeartbeat();
4489 4707
4490 return health; 4708 return health;
4491 } 4709 }
@@ -4678,7 +4896,7 @@ namespace OpenSim.Region.Framework.Scenes
4678 if (m_firstHeartbeat) 4896 if (m_firstHeartbeat)
4679 return; 4897 return;
4680 4898
4681 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4899 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4682 StartTimer(); 4900 StartTimer();
4683 } 4901 }
4684 4902
@@ -4692,9 +4910,14 @@ namespace OpenSim.Region.Framework.Scenes
4692 get { return m_allowScriptCrossings; } 4910 get { return m_allowScriptCrossings; }
4693 } 4911 }
4694 4912
4695 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 4913 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
4914 {
4915 return GetNearestAllowedPosition(avatar, null);
4916 }
4917
4918 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
4696 { 4919 {
4697 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 4920 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
4698 4921
4699 if (nearestParcel != null) 4922 if (nearestParcel != null)
4700 { 4923 {
@@ -4753,13 +4976,18 @@ namespace OpenSim.Region.Framework.Scenes
4753 4976
4754 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 4977 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
4755 { 4978 {
4979 return GetNearestAllowedParcel(avatarId, x, y, null);
4980 }
4981
4982 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
4983 {
4756 List<ILandObject> all = AllParcels(); 4984 List<ILandObject> all = AllParcels();
4757 float minParcelDistance = float.MaxValue; 4985 float minParcelDistance = float.MaxValue;
4758 ILandObject nearestParcel = null; 4986 ILandObject nearestParcel = null;
4759 4987
4760 foreach (var parcel in all) 4988 foreach (var parcel in all)
4761 { 4989 {
4762 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 4990 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
4763 { 4991 {
4764 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 4992 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
4765 if (parcelDistance < minParcelDistance) 4993 if (parcelDistance < minParcelDistance)
@@ -5001,7 +5229,55 @@ namespace OpenSim.Region.Framework.Scenes
5001 mapModule.GenerateMaptile(); 5229 mapModule.GenerateMaptile();
5002 } 5230 }
5003 5231
5004 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5232// public void CleanDroppedAttachments()
5233// {
5234// List<SceneObjectGroup> objectsToDelete =
5235// new List<SceneObjectGroup>();
5236//
5237// lock (m_cleaningAttachments)
5238// {
5239// ForEachSOG(delegate (SceneObjectGroup grp)
5240// {
5241// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5242// {
5243// UUID agentID = grp.OwnerID;
5244// if (agentID == UUID.Zero)
5245// {
5246// objectsToDelete.Add(grp);
5247// return;
5248// }
5249//
5250// ScenePresence sp = GetScenePresence(agentID);
5251// if (sp == null)
5252// {
5253// objectsToDelete.Add(grp);
5254// return;
5255// }
5256// }
5257// });
5258// }
5259//
5260// foreach (SceneObjectGroup grp in objectsToDelete)
5261// {
5262// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5263// DeleteSceneObject(grp, true);
5264// }
5265// }
5266
5267 public void ThreadAlive(int threadCode)
5268 {
5269 switch(threadCode)
5270 {
5271 case 1: // Incoming
5272 m_lastIncoming = Util.EnvironmentTickCount();
5273 break;
5274 case 2: // Incoming
5275 m_lastOutgoing = Util.EnvironmentTickCount();
5276 break;
5277 }
5278 }
5279
5280 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
5005 { 5281 {
5006 RegenerateMaptile(); 5282 RegenerateMaptile();
5007 5283
@@ -5020,6 +5296,14 @@ namespace OpenSim.Region.Framework.Scenes
5020 // child agent creation, thereby emulating the SL behavior. 5296 // child agent creation, thereby emulating the SL behavior.
5021 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5297 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5022 { 5298 {
5299 reason = "You are banned from the region";
5300
5301 if (Permissions.IsGod(agentID))
5302 {
5303 reason = String.Empty;
5304 return true;
5305 }
5306
5023 int num = m_sceneGraph.GetNumberOfScenePresences(); 5307 int num = m_sceneGraph.GetNumberOfScenePresences();
5024 5308
5025 if (num >= RegionInfo.RegionSettings.AgentLimit) 5309 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5031,6 +5315,41 @@ namespace OpenSim.Region.Framework.Scenes
5031 } 5315 }
5032 } 5316 }
5033 5317
5318 ScenePresence presence = GetScenePresence(agentID);
5319 IClientAPI client = null;
5320 AgentCircuitData aCircuit = null;
5321
5322 if (presence != null)
5323 {
5324 client = presence.ControllingClient;
5325 if (client != null)
5326 aCircuit = client.RequestClientInfo();
5327 }
5328
5329 // We may be called before there is a presence or a client.
5330 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5331 if (client == null)
5332 {
5333 aCircuit = new AgentCircuitData();
5334 aCircuit.AgentID = agentID;
5335 aCircuit.firstname = String.Empty;
5336 aCircuit.lastname = String.Empty;
5337 }
5338
5339 try
5340 {
5341 if (!AuthorizeUser(aCircuit, out reason))
5342 {
5343 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5344 return false;
5345 }
5346 }
5347 catch (Exception e)
5348 {
5349 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5350 return false;
5351 }
5352
5034 if (position == Vector3.Zero) // Teleport 5353 if (position == Vector3.Zero) // Teleport
5035 { 5354 {
5036 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5355 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5059,13 +5378,46 @@ namespace OpenSim.Region.Framework.Scenes
5059 } 5378 }
5060 } 5379 }
5061 } 5380 }
5381
5382 float posX = 128.0f;
5383 float posY = 128.0f;
5384
5385 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5386 {
5387 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5388 return false;
5389 }
5390 }
5391 else // Walking
5392 {
5393 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5394 if (land == null)
5395 return false;
5396
5397 bool banned = land.IsBannedFromLand(agentID);
5398 bool restricted = land.IsRestrictedFromLand(agentID);
5399
5400 if (banned || restricted)
5401 return false;
5062 } 5402 }
5063 5403
5064 reason = String.Empty; 5404 reason = String.Empty;
5065 return true; 5405 return true;
5066 } 5406 }
5067 5407
5068 /// <summary> 5408 public void StartTimerWatchdog()
5409 {
5410 m_timerWatchdog.Interval = 1000;
5411 m_timerWatchdog.Elapsed += TimerWatchdog;
5412 m_timerWatchdog.AutoReset = true;
5413 m_timerWatchdog.Start();
5414 }
5415
5416 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5417 {
5418 CheckHeartbeat();
5419 }
5420
5069 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5421 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5070 /// autopilot that moves an avatar to a sit target!. 5422 /// autopilot that moves an avatar to a sit target!.
5071 /// </summary> 5423 /// </summary>