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.cs523
1 files changed, 435 insertions, 88 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index a01b851..e675c73 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
@@ -1133,7 +1159,22 @@ namespace OpenSim.Region.Framework.Scenes
1133 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1159 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1134 if (HeartbeatThread != null) 1160 if (HeartbeatThread != null)
1135 { 1161 {
1162 m_hbRestarts++;
1163 if(m_hbRestarts > 10)
1164 Environment.Exit(1);
1165 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1166
1167//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
1168//System.Diagnostics.Process proc = new System.Diagnostics.Process();
1169//proc.EnableRaisingEvents=false;
1170//proc.StartInfo.FileName = "/bin/kill";
1171//proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
1172//proc.Start();
1173//proc.WaitForExit();
1174//Thread.Sleep(1000);
1175//Environment.Exit(1);
1136 HeartbeatThread.Abort(); 1176 HeartbeatThread.Abort();
1177 Watchdog.AbortThread(HeartbeatThread.ManagedThreadId);
1137 HeartbeatThread = null; 1178 HeartbeatThread = null;
1138 } 1179 }
1139 m_lastUpdate = Util.EnvironmentTickCount(); 1180 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1187,9 +1228,6 @@ namespace OpenSim.Region.Framework.Scenes
1187 1228
1188 while (!shuttingdown) 1229 while (!shuttingdown)
1189 Update(); 1230 Update();
1190
1191 m_lastUpdate = Util.EnvironmentTickCount();
1192 m_firstHeartbeat = false;
1193 } 1231 }
1194 catch (ThreadAbortException) 1232 catch (ThreadAbortException)
1195 { 1233 {
@@ -1287,6 +1325,13 @@ namespace OpenSim.Region.Framework.Scenes
1287 eventMS = Util.EnvironmentTickCountSubtract(evMS); ; 1325 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1288 } 1326 }
1289 1327
1328 // if (Frame % m_update_land == 0)
1329 // {
1330 // int ldMS = Util.EnvironmentTickCount();
1331 // UpdateLand();
1332 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1333 // }
1334
1290 if (Frame % m_update_backup == 0) 1335 if (Frame % m_update_backup == 0)
1291 { 1336 {
1292 int backMS = Util.EnvironmentTickCount(); 1337 int backMS = Util.EnvironmentTickCount();
@@ -1380,12 +1425,16 @@ namespace OpenSim.Region.Framework.Scenes
1380 maintc = Util.EnvironmentTickCountSubtract(maintc); 1425 maintc = Util.EnvironmentTickCountSubtract(maintc);
1381 maintc = (int)(MinFrameTime * 1000) - maintc; 1426 maintc = (int)(MinFrameTime * 1000) - maintc;
1382 1427
1428
1429 m_lastUpdate = Util.EnvironmentTickCount();
1430 m_firstHeartbeat = false;
1431
1383 if (maintc > 0) 1432 if (maintc > 0)
1384 Thread.Sleep(maintc); 1433 Thread.Sleep(maintc);
1385 1434
1386 // Tell the watchdog that this thread is still alive 1435 // Tell the watchdog that this thread is still alive
1387 Watchdog.UpdateThread(); 1436 Watchdog.UpdateThread();
1388 } 1437 }
1389 1438
1390 public void AddGroupTarget(SceneObjectGroup grp) 1439 public void AddGroupTarget(SceneObjectGroup grp)
1391 { 1440 {
@@ -1401,9 +1450,9 @@ namespace OpenSim.Region.Framework.Scenes
1401 1450
1402 private void CheckAtTargets() 1451 private void CheckAtTargets()
1403 { 1452 {
1404 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1453 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1405 lock (m_groupsWithTargets) 1454 lock (m_groupsWithTargets)
1406 objs = m_groupsWithTargets.Values; 1455 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1407 1456
1408 foreach (SceneObjectGroup entry in objs) 1457 foreach (SceneObjectGroup entry in objs)
1409 entry.checkAtTargets(); 1458 entry.checkAtTargets();
@@ -1484,7 +1533,7 @@ namespace OpenSim.Region.Framework.Scenes
1484 msg.fromAgentName = "Server"; 1533 msg.fromAgentName = "Server";
1485 msg.dialog = (byte)19; // Object msg 1534 msg.dialog = (byte)19; // Object msg
1486 msg.fromGroup = false; 1535 msg.fromGroup = false;
1487 msg.offline = (byte)0; 1536 msg.offline = (byte)1;
1488 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; 1537 msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID;
1489 msg.Position = Vector3.Zero; 1538 msg.Position = Vector3.Zero;
1490 msg.RegionID = RegionInfo.RegionID.Guid; 1539 msg.RegionID = RegionInfo.RegionID.Guid;
@@ -1715,14 +1764,24 @@ namespace OpenSim.Region.Framework.Scenes
1715 /// <returns></returns> 1764 /// <returns></returns>
1716 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1765 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1717 { 1766 {
1767
1768 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1769 Vector3 wpos = Vector3.Zero;
1770 // Check for water surface intersection from above
1771 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1772 {
1773 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1774 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1775 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1776 wpos.Z = wheight;
1777 }
1778
1718 Vector3 pos = Vector3.Zero; 1779 Vector3 pos = Vector3.Zero;
1719 if (RayEndIsIntersection == (byte)1) 1780 if (RayEndIsIntersection == (byte)1)
1720 { 1781 {
1721 pos = RayEnd; 1782 pos = RayEnd;
1722 return pos;
1723 } 1783 }
1724 1784 else if (RayTargetID != UUID.Zero)
1725 if (RayTargetID != UUID.Zero)
1726 { 1785 {
1727 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1786 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1728 1787
@@ -1744,7 +1803,7 @@ namespace OpenSim.Region.Framework.Scenes
1744 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1803 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1745 1804
1746 // Un-comment out the following line to Get Raytrace results printed to the console. 1805 // Un-comment out the following line to Get Raytrace results printed to the console.
1747 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1806 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1748 float ScaleOffset = 0.5f; 1807 float ScaleOffset = 0.5f;
1749 1808
1750 // If we hit something 1809 // If we hit something
@@ -1767,13 +1826,10 @@ namespace OpenSim.Region.Framework.Scenes
1767 //pos.Z -= 0.25F; 1826 //pos.Z -= 0.25F;
1768 1827
1769 } 1828 }
1770
1771 return pos;
1772 } 1829 }
1773 else 1830 else
1774 { 1831 {
1775 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1832 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1776
1777 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1833 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1778 1834
1779 // Un-comment the following line to print the raytrace results to the console. 1835 // Un-comment the following line to print the raytrace results to the console.
@@ -1782,13 +1838,12 @@ namespace OpenSim.Region.Framework.Scenes
1782 if (ei.HitTF) 1838 if (ei.HitTF)
1783 { 1839 {
1784 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1840 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1785 } else 1841 }
1842 else
1786 { 1843 {
1787 // fall back to our stupid functionality 1844 // fall back to our stupid functionality
1788 pos = RayEnd; 1845 pos = RayEnd;
1789 } 1846 }
1790
1791 return pos;
1792 } 1847 }
1793 } 1848 }
1794 else 1849 else
@@ -1799,8 +1854,12 @@ namespace OpenSim.Region.Framework.Scenes
1799 //increase height so its above the ground. 1854 //increase height so its above the ground.
1800 //should be getting the normal of the ground at the rez point and using that? 1855 //should be getting the normal of the ground at the rez point and using that?
1801 pos.Z += scale.Z / 2f; 1856 pos.Z += scale.Z / 2f;
1802 return pos; 1857// return pos;
1803 } 1858 }
1859
1860 // check against posible water intercept
1861 if (wpos.Z > pos.Z) pos = wpos;
1862 return pos;
1804 } 1863 }
1805 1864
1806 1865
@@ -1884,7 +1943,10 @@ namespace OpenSim.Region.Framework.Scenes
1884 public bool AddRestoredSceneObject( 1943 public bool AddRestoredSceneObject(
1885 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1944 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1886 { 1945 {
1887 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1946 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1947 if (result)
1948 sceneObject.IsDeleted = false;
1949 return result;
1888 } 1950 }
1889 1951
1890 /// <summary> 1952 /// <summary>
@@ -1976,6 +2038,15 @@ namespace OpenSim.Region.Framework.Scenes
1976 /// </summary> 2038 /// </summary>
1977 public void DeleteAllSceneObjects() 2039 public void DeleteAllSceneObjects()
1978 { 2040 {
2041 DeleteAllSceneObjects(false);
2042 }
2043
2044 /// <summary>
2045 /// Delete every object from the scene. This does not include attachments worn by avatars.
2046 /// </summary>
2047 public void DeleteAllSceneObjects(bool exceptNoCopy)
2048 {
2049 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1979 lock (Entities) 2050 lock (Entities)
1980 { 2051 {
1981 EntityBase[] entities = Entities.GetEntities(); 2052 EntityBase[] entities = Entities.GetEntities();
@@ -1984,11 +2055,24 @@ namespace OpenSim.Region.Framework.Scenes
1984 if (e is SceneObjectGroup) 2055 if (e is SceneObjectGroup)
1985 { 2056 {
1986 SceneObjectGroup sog = (SceneObjectGroup)e; 2057 SceneObjectGroup sog = (SceneObjectGroup)e;
1987 if (!sog.IsAttachment) 2058 if (sog != null && !sog.IsAttachment)
1988 DeleteSceneObject((SceneObjectGroup)e, false); 2059 {
2060 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2061 {
2062 DeleteSceneObject((SceneObjectGroup)e, false);
2063 }
2064 else
2065 {
2066 toReturn.Add((SceneObjectGroup)e);
2067 }
2068 }
1989 } 2069 }
1990 } 2070 }
1991 } 2071 }
2072 if (toReturn.Count > 0)
2073 {
2074 returnObjects(toReturn.ToArray(), UUID.Zero);
2075 }
1992 } 2076 }
1993 2077
1994 /// <summary> 2078 /// <summary>
@@ -2036,6 +2120,8 @@ namespace OpenSim.Region.Framework.Scenes
2036 } 2120 }
2037 2121
2038 group.DeleteGroupFromScene(silent); 2122 group.DeleteGroupFromScene(silent);
2123 if (!silent)
2124 SendKillObject(new List<uint>() { group.LocalId });
2039 2125
2040// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2126// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2041 } 2127 }
@@ -2325,6 +2411,8 @@ namespace OpenSim.Region.Framework.Scenes
2325 2411
2326 if (newPosition != Vector3.Zero) 2412 if (newPosition != Vector3.Zero)
2327 newObject.RootPart.GroupPosition = newPosition; 2413 newObject.RootPart.GroupPosition = newPosition;
2414 if (newObject.RootPart.KeyframeMotion != null)
2415 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2328 2416
2329 if (!AddSceneObject(newObject)) 2417 if (!AddSceneObject(newObject))
2330 { 2418 {
@@ -2393,10 +2481,17 @@ namespace OpenSim.Region.Framework.Scenes
2393 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2481 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2394 public bool AddSceneObject(SceneObjectGroup sceneObject) 2482 public bool AddSceneObject(SceneObjectGroup sceneObject)
2395 { 2483 {
2484 if (sceneObject.OwnerID == UUID.Zero)
2485 {
2486 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2487 return false;
2488 }
2489
2396 // If the user is banned, we won't let any of their objects 2490 // If the user is banned, we won't let any of their objects
2397 // enter. Period. 2491 // enter. Period.
2398 // 2492 //
2399 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2493 int flags = GetUserFlags(sceneObject.OwnerID);
2494 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2400 { 2495 {
2401 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); 2496 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2402 2497
@@ -2442,12 +2537,23 @@ namespace OpenSim.Region.Framework.Scenes
2442 } 2537 }
2443 else 2538 else
2444 { 2539 {
2540 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2445 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2541 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2446 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2542 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2447 } 2543 }
2544 if (sceneObject.OwnerID == UUID.Zero)
2545 {
2546 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2547 return false;
2548 }
2448 } 2549 }
2449 else 2550 else
2450 { 2551 {
2552 if (sceneObject.OwnerID == UUID.Zero)
2553 {
2554 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2555 return false;
2556 }
2451 AddRestoredSceneObject(sceneObject, true, false); 2557 AddRestoredSceneObject(sceneObject, true, false);
2452 2558
2453 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2559 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2476,6 +2582,24 @@ namespace OpenSim.Region.Framework.Scenes
2476 return 2; // StateSource.PrimCrossing 2582 return 2; // StateSource.PrimCrossing
2477 } 2583 }
2478 2584
2585 public int GetUserFlags(UUID user)
2586 {
2587 //Unfortunately the SP approach means that the value is cached until region is restarted
2588 /*
2589 ScenePresence sp;
2590 if (TryGetScenePresence(user, out sp))
2591 {
2592 return sp.UserFlags;
2593 }
2594 else
2595 {
2596 */
2597 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2598 if (uac == null)
2599 return 0;
2600 return uac.UserFlags;
2601 //}
2602 }
2479 #endregion 2603 #endregion
2480 2604
2481 #region Add/Remove Avatar Methods 2605 #region Add/Remove Avatar Methods
@@ -2490,6 +2614,7 @@ namespace OpenSim.Region.Framework.Scenes
2490 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2614 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2491 2615
2492 CheckHeartbeat(); 2616 CheckHeartbeat();
2617 ScenePresence presence;
2493 2618
2494 ScenePresence sp = GetScenePresence(client.AgentId); 2619 ScenePresence sp = GetScenePresence(client.AgentId);
2495 2620
@@ -2538,7 +2663,13 @@ namespace OpenSim.Region.Framework.Scenes
2538 2663
2539 EventManager.TriggerOnNewClient(client); 2664 EventManager.TriggerOnNewClient(client);
2540 if (vialogin) 2665 if (vialogin)
2666 {
2541 EventManager.TriggerOnClientLogin(client); 2667 EventManager.TriggerOnClientLogin(client);
2668 // Send initial parcel data
2669 Vector3 pos = sp.AbsolutePosition;
2670 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2671 land.SendLandUpdateToClient(client);
2672 }
2542 2673
2543 return sp; 2674 return sp;
2544 } 2675 }
@@ -2628,19 +2759,12 @@ namespace OpenSim.Region.Framework.Scenes
2628 // and the scene presence and the client, if they exist 2759 // and the scene presence and the client, if they exist
2629 try 2760 try
2630 { 2761 {
2631 // We need to wait for the client to make UDP contact first. 2762 ScenePresence sp = GetScenePresence(agentID);
2632 // It's the UDP contact that creates the scene presence 2763 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2633 ScenePresence sp = WaitGetScenePresence(agentID); 2764
2634 if (sp != null) 2765 if (sp != null)
2635 {
2636 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2637
2638 sp.ControllingClient.Close(); 2766 sp.ControllingClient.Close();
2639 } 2767
2640 else
2641 {
2642 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2643 }
2644 // BANG! SLASH! 2768 // BANG! SLASH!
2645 m_authenticateHandler.RemoveCircuit(agentID); 2769 m_authenticateHandler.RemoveCircuit(agentID);
2646 2770
@@ -2741,6 +2865,7 @@ namespace OpenSim.Region.Framework.Scenes
2741 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2865 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2742 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2866 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2743 client.OnCopyInventoryItem += CopyInventoryItem; 2867 client.OnCopyInventoryItem += CopyInventoryItem;
2868 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2744 client.OnMoveInventoryItem += MoveInventoryItem; 2869 client.OnMoveInventoryItem += MoveInventoryItem;
2745 client.OnRemoveInventoryItem += RemoveInventoryItem; 2870 client.OnRemoveInventoryItem += RemoveInventoryItem;
2746 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2871 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2916,15 +3041,16 @@ namespace OpenSim.Region.Framework.Scenes
2916 /// </summary> 3041 /// </summary>
2917 /// <param name="agentId">The avatar's Unique ID</param> 3042 /// <param name="agentId">The avatar's Unique ID</param>
2918 /// <param name="client">The IClientAPI for the client</param> 3043 /// <param name="client">The IClientAPI for the client</param>
2919 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3044 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2920 { 3045 {
2921 if (m_teleportModule != null) 3046 if (m_teleportModule != null)
2922 m_teleportModule.TeleportHome(agentId, client); 3047 return m_teleportModule.TeleportHome(agentId, client);
2923 else 3048 else
2924 { 3049 {
2925 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3050 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2926 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3051 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2927 } 3052 }
3053 return false;
2928 } 3054 }
2929 3055
2930 /// <summary> 3056 /// <summary>
@@ -3034,6 +3160,16 @@ namespace OpenSim.Region.Framework.Scenes
3034 /// <param name="flags"></param> 3160 /// <param name="flags"></param>
3035 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3161 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3036 { 3162 {
3163 //Add half the avatar's height so that the user doesn't fall through prims
3164 ScenePresence presence;
3165 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3166 {
3167 if (presence.Appearance != null)
3168 {
3169 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3170 }
3171 }
3172
3037 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3173 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3038 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3174 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3039 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3175 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3102,8 +3238,9 @@ namespace OpenSim.Region.Framework.Scenes
3102 regions.Remove(RegionInfo.RegionHandle); 3238 regions.Remove(RegionInfo.RegionHandle);
3103 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3239 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3104 } 3240 }
3105 3241 m_log.Debug("[Scene] Beginning ClientClosed");
3106 m_eventManager.TriggerClientClosed(agentID, this); 3242 m_eventManager.TriggerClientClosed(agentID, this);
3243 m_log.Debug("[Scene] Finished ClientClosed");
3107 } 3244 }
3108 catch (NullReferenceException) 3245 catch (NullReferenceException)
3109 { 3246 {
@@ -3165,9 +3302,10 @@ namespace OpenSim.Region.Framework.Scenes
3165 { 3302 {
3166 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); 3303 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace);
3167 } 3304 }
3168 3305 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3169 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3306 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3170// CleanDroppedAttachments(); 3307// CleanDroppedAttachments();
3308 m_log.Debug("[Scene] The avatar has left the building");
3171 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3309 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3172 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3310 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3173 } 3311 }
@@ -3289,13 +3427,16 @@ namespace OpenSim.Region.Framework.Scenes
3289 sp = null; 3427 sp = null;
3290 } 3428 }
3291 3429
3292 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3293 3430
3294 //On login test land permisions 3431 //On login test land permisions
3295 if (vialogin) 3432 if (vialogin)
3296 { 3433 {
3297 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3434 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3435 if (cache != null)
3436 cache.Remove(agent.firstname + " " + agent.lastname);
3437 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3298 { 3438 {
3439 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3299 return false; 3440 return false;
3300 } 3441 }
3301 } 3442 }
@@ -3319,8 +3460,13 @@ namespace OpenSim.Region.Framework.Scenes
3319 3460
3320 try 3461 try
3321 { 3462 {
3322 if (!AuthorizeUser(agent, out reason)) 3463 // Always check estate if this is a login. Always
3323 return false; 3464 // check if banned regions are to be blacked out.
3465 if (vialogin || (!m_seeIntoBannedRegion))
3466 {
3467 if (!AuthorizeUser(agent, out reason))
3468 return false;
3469 }
3324 } 3470 }
3325 catch (Exception e) 3471 catch (Exception e)
3326 { 3472 {
@@ -3446,6 +3592,8 @@ namespace OpenSim.Region.Framework.Scenes
3446 } 3592 }
3447 3593
3448 // Honor parcel landing type and position. 3594 // Honor parcel landing type and position.
3595 /*
3596 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3449 if (land != null) 3597 if (land != null)
3450 { 3598 {
3451 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3599 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3453,26 +3601,34 @@ namespace OpenSim.Region.Framework.Scenes
3453 agent.startpos = land.LandData.UserLocation; 3601 agent.startpos = land.LandData.UserLocation;
3454 } 3602 }
3455 } 3603 }
3604 */// This is now handled properly in ScenePresence.MakeRootAgent
3456 } 3605 }
3457 3606
3458 return true; 3607 return true;
3459 } 3608 }
3460 3609
3461 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3610 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3462 { 3611 {
3463 3612 reason = String.Empty;
3464 bool banned = land.IsBannedFromLand(agent.AgentID); 3613 if (Permissions.IsGod(agentID))
3465 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3614 return true;
3615
3616 ILandObject land = LandChannel.GetLandObject(posX, posY);
3617 if (land == null)
3618 return false;
3619
3620 bool banned = land.IsBannedFromLand(agentID);
3621 bool restricted = land.IsRestrictedFromLand(agentID);
3466 3622
3467 if (banned || restricted) 3623 if (banned || restricted)
3468 { 3624 {
3469 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3625 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3470 if (nearestParcel != null) 3626 if (nearestParcel != null)
3471 { 3627 {
3472 //Move agent to nearest allowed 3628 //Move agent to nearest allowed
3473 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3629 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3474 agent.startpos.X = newPosition.X; 3630 posX = newPosition.X;
3475 agent.startpos.Y = newPosition.Y; 3631 posY = newPosition.Y;
3476 } 3632 }
3477 else 3633 else
3478 { 3634 {
@@ -3534,7 +3690,7 @@ namespace OpenSim.Region.Framework.Scenes
3534 3690
3535 if (!m_strictAccessControl) return true; 3691 if (!m_strictAccessControl) return true;
3536 if (Permissions.IsGod(agent.AgentID)) return true; 3692 if (Permissions.IsGod(agent.AgentID)) return true;
3537 3693
3538 if (AuthorizationService != null) 3694 if (AuthorizationService != null)
3539 { 3695 {
3540 if (!AuthorizationService.IsAuthorizedForRegion( 3696 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3542,14 +3698,14 @@ namespace OpenSim.Region.Framework.Scenes
3542 { 3698 {
3543 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3699 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3544 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3700 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3545 3701
3546 return false; 3702 return false;
3547 } 3703 }
3548 } 3704 }
3549 3705
3550 if (m_regInfo.EstateSettings != null) 3706 if (m_regInfo.EstateSettings != null)
3551 { 3707 {
3552 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3708 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3553 { 3709 {
3554 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3710 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3555 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3711 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3741,6 +3897,13 @@ namespace OpenSim.Region.Framework.Scenes
3741 3897
3742 // We have to wait until the viewer contacts this region after receiving EAC. 3898 // We have to wait until the viewer contacts this region after receiving EAC.
3743 // That calls AddNewClient, which finally creates the ScenePresence 3899 // That calls AddNewClient, which finally creates the ScenePresence
3900 int flags = GetUserFlags(cAgentData.AgentID);
3901 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3902 {
3903 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3904 return false;
3905 }
3906
3744 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3907 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3745 if (nearestParcel == null) 3908 if (nearestParcel == null)
3746 { 3909 {
@@ -3822,12 +3985,22 @@ namespace OpenSim.Region.Framework.Scenes
3822 return false; 3985 return false;
3823 } 3986 }
3824 3987
3988 public bool IncomingCloseAgent(UUID agentID)
3989 {
3990 return IncomingCloseAgent(agentID, false);
3991 }
3992
3993 public bool IncomingCloseChildAgent(UUID agentID)
3994 {
3995 return IncomingCloseAgent(agentID, true);
3996 }
3997
3825 /// <summary> 3998 /// <summary>
3826 /// Tell a single agent to disconnect from the region. 3999 /// Tell a single agent to disconnect from the region.
3827 /// </summary> 4000 /// </summary>
3828 /// <param name="regionHandle"></param>
3829 /// <param name="agentID"></param> 4001 /// <param name="agentID"></param>
3830 public bool IncomingCloseAgent(UUID agentID) 4002 /// <param name="childOnly"></param>
4003 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3831 { 4004 {
3832 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 4005 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3833 4006
@@ -3839,7 +4012,7 @@ namespace OpenSim.Region.Framework.Scenes
3839 { 4012 {
3840 m_sceneGraph.removeUserCount(false); 4013 m_sceneGraph.removeUserCount(false);
3841 } 4014 }
3842 else 4015 else if (!childOnly)
3843 { 4016 {
3844 m_sceneGraph.removeUserCount(true); 4017 m_sceneGraph.removeUserCount(true);
3845 } 4018 }
@@ -3855,9 +4028,12 @@ namespace OpenSim.Region.Framework.Scenes
3855 } 4028 }
3856 else 4029 else
3857 presence.ControllingClient.SendShutdownConnectionNotice(); 4030 presence.ControllingClient.SendShutdownConnectionNotice();
4031 presence.ControllingClient.Close(false);
4032 }
4033 else if (!childOnly)
4034 {
4035 presence.ControllingClient.Close(true);
3858 } 4036 }
3859
3860 presence.ControllingClient.Close();
3861 return true; 4037 return true;
3862 } 4038 }
3863 4039
@@ -4439,34 +4615,78 @@ namespace OpenSim.Region.Framework.Scenes
4439 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4615 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4440 } 4616 }
4441 4617
4442 public int GetHealth() 4618 public int GetHealth(out int flags, out string message)
4443 { 4619 {
4444 // Returns: 4620 // Returns:
4445 // 1 = sim is up and accepting http requests. The heartbeat has 4621 // 1 = sim is up and accepting http requests. The heartbeat has
4446 // stopped and the sim is probably locked up, but a remote 4622 // stopped and the sim is probably locked up, but a remote
4447 // admin restart may succeed 4623 // admin restart may succeed
4448 // 4624 //
4449 // 2 = Sim is up and the heartbeat is running. The sim is likely 4625 // 2 = Sim is up and the heartbeat is running. The sim is likely
4450 // usable for people within and logins _may_ work 4626 // usable for people within
4627 //
4628 // 3 = Sim is up and one packet thread is running. Sim is
4629 // unstable and will not accept new logins
4630 //
4631 // 4 = Sim is up and both packet threads are running. Sim is
4632 // likely usable
4451 // 4633 //
4452 // 3 = We have seen a new user enter within the past 4 minutes 4634 // 5 = We have seen a new user enter within the past 4 minutes
4453 // which can be seen as positive confirmation of sim health 4635 // which can be seen as positive confirmation of sim health
4454 // 4636 //
4637
4638 flags = 0;
4639 message = String.Empty;
4640
4641 CheckHeartbeat();
4642
4643 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4644 {
4645 // We're still starting
4646 // 0 means "in startup", it can't happen another way, since
4647 // to get here, we must be able to accept http connections
4648 return 0;
4649 }
4650
4455 int health=1; // Start at 1, means we're up 4651 int health=1; // Start at 1, means we're up
4456 4652
4457 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4653 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4654 {
4655 health+=1;
4656 flags |= 1;
4657 }
4658
4659 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4660 {
4661 health+=1;
4662 flags |= 2;
4663 }
4664
4665 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4666 {
4458 health+=1; 4667 health+=1;
4668 flags |= 4;
4669 }
4459 else 4670 else
4671 {
4672int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
4673System.Diagnostics.Process proc = new System.Diagnostics.Process();
4674proc.EnableRaisingEvents=false;
4675proc.StartInfo.FileName = "/bin/kill";
4676proc.StartInfo.Arguments = "-QUIT " + pid.ToString();
4677proc.Start();
4678proc.WaitForExit();
4679Thread.Sleep(1000);
4680Environment.Exit(1);
4681 }
4682
4683 if (flags != 7)
4460 return health; 4684 return health;
4461 4685
4462 // A login in the last 4 mins? We can't be doing too badly 4686 // A login in the last 4 mins? We can't be doing too badly
4463 // 4687 //
4464 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4688 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4465 health++; 4689 health++;
4466 else
4467 return health;
4468
4469 CheckHeartbeat();
4470 4690
4471 return health; 4691 return health;
4472 } 4692 }
@@ -4555,7 +4775,7 @@ namespace OpenSim.Region.Framework.Scenes
4555 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); 4775 bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
4556 if (wasUsingPhysics) 4776 if (wasUsingPhysics)
4557 { 4777 {
4558 jointProxyObject.UpdatePrimFlags(false, false, true, false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock 4778 jointProxyObject.UpdatePrimFlags(false, false, true, false,false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock
4559 } 4779 }
4560 } 4780 }
4561 4781
@@ -4659,7 +4879,7 @@ namespace OpenSim.Region.Framework.Scenes
4659 if (m_firstHeartbeat) 4879 if (m_firstHeartbeat)
4660 return; 4880 return;
4661 4881
4662 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4882 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4663 StartTimer(); 4883 StartTimer();
4664 } 4884 }
4665 4885
@@ -4673,9 +4893,14 @@ namespace OpenSim.Region.Framework.Scenes
4673 get { return m_allowScriptCrossings; } 4893 get { return m_allowScriptCrossings; }
4674 } 4894 }
4675 4895
4676 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 4896 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
4677 { 4897 {
4678 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 4898 return GetNearestAllowedPosition(avatar, null);
4899 }
4900
4901 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
4902 {
4903 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
4679 4904
4680 if (nearestParcel != null) 4905 if (nearestParcel != null)
4681 { 4906 {
@@ -4684,10 +4909,7 @@ namespace OpenSim.Region.Framework.Scenes
4684 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 4909 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4685 if (nearestPoint != null) 4910 if (nearestPoint != null)
4686 { 4911 {
4687// m_log.DebugFormat( 4912 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
4688// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
4689// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
4690
4691 return nearestPoint.Value; 4913 return nearestPoint.Value;
4692 } 4914 }
4693 4915
@@ -4697,16 +4919,12 @@ namespace OpenSim.Region.Framework.Scenes
4697 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 4919 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
4698 if (nearestPoint != null) 4920 if (nearestPoint != null)
4699 { 4921 {
4700// m_log.DebugFormat( 4922 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
4701// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
4702
4703 return nearestPoint.Value; 4923 return nearestPoint.Value;
4704 } 4924 }
4705 4925
4706 //Ultimate backup if we have no idea where they are 4926 //Ultimate backup if we have no idea where they are
4707// m_log.DebugFormat( 4927 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
4708// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition);
4709
4710 return avatar.lastKnownAllowedPosition; 4928 return avatar.lastKnownAllowedPosition;
4711 } 4929 }
4712 4930
@@ -4741,13 +4959,18 @@ namespace OpenSim.Region.Framework.Scenes
4741 4959
4742 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 4960 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
4743 { 4961 {
4962 return GetNearestAllowedParcel(avatarId, x, y, null);
4963 }
4964
4965 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
4966 {
4744 List<ILandObject> all = AllParcels(); 4967 List<ILandObject> all = AllParcels();
4745 float minParcelDistance = float.MaxValue; 4968 float minParcelDistance = float.MaxValue;
4746 ILandObject nearestParcel = null; 4969 ILandObject nearestParcel = null;
4747 4970
4748 foreach (var parcel in all) 4971 foreach (var parcel in all)
4749 { 4972 {
4750 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 4973 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
4751 { 4974 {
4752 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 4975 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
4753 if (parcelDistance < minParcelDistance) 4976 if (parcelDistance < minParcelDistance)
@@ -4989,7 +5212,55 @@ namespace OpenSim.Region.Framework.Scenes
4989 mapModule.GenerateMaptile(); 5212 mapModule.GenerateMaptile();
4990 } 5213 }
4991 5214
4992 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5215// public void CleanDroppedAttachments()
5216// {
5217// List<SceneObjectGroup> objectsToDelete =
5218// new List<SceneObjectGroup>();
5219//
5220// lock (m_cleaningAttachments)
5221// {
5222// ForEachSOG(delegate (SceneObjectGroup grp)
5223// {
5224// if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5225// {
5226// UUID agentID = grp.OwnerID;
5227// if (agentID == UUID.Zero)
5228// {
5229// objectsToDelete.Add(grp);
5230// return;
5231// }
5232//
5233// ScenePresence sp = GetScenePresence(agentID);
5234// if (sp == null)
5235// {
5236// objectsToDelete.Add(grp);
5237// return;
5238// }
5239// }
5240// });
5241// }
5242//
5243// foreach (SceneObjectGroup grp in objectsToDelete)
5244// {
5245// m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5246// DeleteSceneObject(grp, true);
5247// }
5248// }
5249
5250 public void ThreadAlive(int threadCode)
5251 {
5252 switch(threadCode)
5253 {
5254 case 1: // Incoming
5255 m_lastIncoming = Util.EnvironmentTickCount();
5256 break;
5257 case 2: // Incoming
5258 m_lastOutgoing = Util.EnvironmentTickCount();
5259 break;
5260 }
5261 }
5262
5263 public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
4993 { 5264 {
4994 RegenerateMaptile(); 5265 RegenerateMaptile();
4995 5266
@@ -5008,6 +5279,14 @@ namespace OpenSim.Region.Framework.Scenes
5008 // child agent creation, thereby emulating the SL behavior. 5279 // child agent creation, thereby emulating the SL behavior.
5009 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5280 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5010 { 5281 {
5282 reason = "You are banned from the region";
5283
5284 if (Permissions.IsGod(agentID))
5285 {
5286 reason = String.Empty;
5287 return true;
5288 }
5289
5011 int num = m_sceneGraph.GetNumberOfScenePresences(); 5290 int num = m_sceneGraph.GetNumberOfScenePresences();
5012 5291
5013 if (num >= RegionInfo.RegionSettings.AgentLimit) 5292 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5019,6 +5298,41 @@ namespace OpenSim.Region.Framework.Scenes
5019 } 5298 }
5020 } 5299 }
5021 5300
5301 ScenePresence presence = GetScenePresence(agentID);
5302 IClientAPI client = null;
5303 AgentCircuitData aCircuit = null;
5304
5305 if (presence != null)
5306 {
5307 client = presence.ControllingClient;
5308 if (client != null)
5309 aCircuit = client.RequestClientInfo();
5310 }
5311
5312 // We may be called before there is a presence or a client.
5313 // Fake AgentCircuitData to keep IAuthorizationModule smiling
5314 if (client == null)
5315 {
5316 aCircuit = new AgentCircuitData();
5317 aCircuit.AgentID = agentID;
5318 aCircuit.firstname = String.Empty;
5319 aCircuit.lastname = String.Empty;
5320 }
5321
5322 try
5323 {
5324 if (!AuthorizeUser(aCircuit, out reason))
5325 {
5326 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5327 return false;
5328 }
5329 }
5330 catch (Exception e)
5331 {
5332 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
5333 return false;
5334 }
5335
5022 if (position == Vector3.Zero) // Teleport 5336 if (position == Vector3.Zero) // Teleport
5023 { 5337 {
5024 if (!RegionInfo.EstateSettings.AllowDirectTeleport) 5338 if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5047,13 +5361,46 @@ namespace OpenSim.Region.Framework.Scenes
5047 } 5361 }
5048 } 5362 }
5049 } 5363 }
5364
5365 float posX = 128.0f;
5366 float posY = 128.0f;
5367
5368 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5369 {
5370 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5371 return false;
5372 }
5373 }
5374 else // Walking
5375 {
5376 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5377 if (land == null)
5378 return false;
5379
5380 bool banned = land.IsBannedFromLand(agentID);
5381 bool restricted = land.IsRestrictedFromLand(agentID);
5382
5383 if (banned || restricted)
5384 return false;
5050 } 5385 }
5051 5386
5052 reason = String.Empty; 5387 reason = String.Empty;
5053 return true; 5388 return true;
5054 } 5389 }
5055 5390
5056 /// <summary> 5391 public void StartTimerWatchdog()
5392 {
5393 m_timerWatchdog.Interval = 1000;
5394 m_timerWatchdog.Elapsed += TimerWatchdog;
5395 m_timerWatchdog.AutoReset = true;
5396 m_timerWatchdog.Start();
5397 }
5398
5399 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5400 {
5401 CheckHeartbeat();
5402 }
5403
5057 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5404 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5058 /// autopilot that moves an avatar to a sit target!. 5405 /// autopilot that moves an avatar to a sit target!.
5059 /// </summary> 5406 /// </summary>