diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 683 |
1 files changed, 524 insertions, 159 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 18a7ce8..b50ccc4 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,12 +218,15 @@ 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; |
222 | 228 | private int m_hbRestarts = 0; | |
229 | |||
223 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 230 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
224 | private bool m_reprioritizationEnabled = true; | 231 | private bool m_reprioritizationEnabled = true; |
225 | private double m_reprioritizationInterval = 5000.0; | 232 | private double m_reprioritizationInterval = 5000.0; |
@@ -263,6 +270,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
263 | get { return m_sceneGridService; } | 270 | get { return m_sceneGridService; } |
264 | } | 271 | } |
265 | 272 | ||
273 | public ISnmpModule SnmpService | ||
274 | { | ||
275 | get | ||
276 | { | ||
277 | if (m_snmpService == null) | ||
278 | { | ||
279 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
280 | } | ||
281 | |||
282 | return m_snmpService; | ||
283 | } | ||
284 | } | ||
285 | |||
266 | public ISimulationDataService SimulationDataService | 286 | public ISimulationDataService SimulationDataService |
267 | { | 287 | { |
268 | get | 288 | get |
@@ -544,6 +564,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
544 | m_EstateDataService = estateDataService; | 564 | m_EstateDataService = estateDataService; |
545 | m_regionHandle = m_regInfo.RegionHandle; | 565 | m_regionHandle = m_regInfo.RegionHandle; |
546 | m_regionName = m_regInfo.RegionName; | 566 | m_regionName = m_regInfo.RegionName; |
567 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
568 | m_lastIncoming = 0; | ||
569 | m_lastOutgoing = 0; | ||
547 | 570 | ||
548 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 571 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
549 | m_asyncSceneObjectDeleter.Enabled = true; | 572 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -628,96 +651,106 @@ namespace OpenSim.Region.Framework.Scenes | |||
628 | 651 | ||
629 | // Region config overrides global config | 652 | // Region config overrides global config |
630 | // | 653 | // |
631 | if (m_config.Configs["Startup"] != null) | 654 | try |
632 | { | 655 | { |
633 | IConfig startupConfig = m_config.Configs["Startup"]; | 656 | if (m_config.Configs["Startup"] != null) |
657 | { | ||
658 | IConfig startupConfig = m_config.Configs["Startup"]; | ||
634 | 659 | ||
635 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); | 660 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
636 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); | 661 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); |
637 | if (!m_useBackup) | 662 | if (!m_useBackup) |
638 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | 663 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
639 | 664 | ||
640 | //Animation states | 665 | //Animation states |
641 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 666 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
642 | 667 | ||
643 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); | 668 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
644 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); | 669 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
645 | 670 | ||
646 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); | 671 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); |
647 | if (RegionInfo.NonphysPrimMax > 0) | 672 | if (RegionInfo.NonphysPrimMax > 0) |
648 | { | 673 | { |
649 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 674 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
650 | } | 675 | } |
651 | 676 | ||
652 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 677 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
653 | 678 | ||
654 | if (RegionInfo.PhysPrimMax > 0) | 679 | if (RegionInfo.PhysPrimMax > 0) |
655 | { | 680 | { |
656 | m_maxPhys = RegionInfo.PhysPrimMax; | 681 | m_maxPhys = RegionInfo.PhysPrimMax; |
657 | } | 682 | } |
658 | 683 | ||
659 | // Here, if clamping is requested in either global or | 684 | // Here, if clamping is requested in either global or |
660 | // local config, it will be used | 685 | // local config, it will be used |
661 | // | 686 | // |
662 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); | 687 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); |
663 | if (RegionInfo.ClampPrimSize) | 688 | if (RegionInfo.ClampPrimSize) |
664 | { | 689 | { |
665 | m_clampPrimSize = true; | 690 | m_clampPrimSize = true; |
666 | } | 691 | } |
667 | 692 | ||
668 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 693 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
669 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 694 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
670 | m_dontPersistBefore = | 695 | m_dontPersistBefore = |
671 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | 696 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); |
672 | m_dontPersistBefore *= 10000000; | 697 | m_dontPersistBefore *= 10000000; |
673 | m_persistAfter = | 698 | m_persistAfter = |
674 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | 699 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); |
675 | m_persistAfter *= 10000000; | 700 | m_persistAfter *= 10000000; |
676 | 701 | ||
677 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 702 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
703 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
678 | 704 | ||
679 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 705 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
680 | if (packetConfig != null) | 706 | if (packetConfig != null) |
681 | { | 707 | { |
682 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); | 708 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); |
683 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); | 709 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); |
684 | } | 710 | } |
685 | 711 | ||
686 | 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); | ||
687 | 715 | ||
688 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 716 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
689 | if (m_generateMaptiles) | 717 | if (m_generateMaptiles) |
690 | { | ||
691 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); | ||
692 | if (maptileRefresh != 0) | ||
693 | { | 718 | { |
694 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | 719 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); |
695 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | 720 | if (maptileRefresh != 0) |
696 | m_mapGenerationTimer.AutoReset = true; | 721 | { |
697 | m_mapGenerationTimer.Start(); | 722 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; |
723 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | ||
724 | m_mapGenerationTimer.AutoReset = true; | ||
725 | m_mapGenerationTimer.Start(); | ||
726 | } | ||
698 | } | 727 | } |
699 | } | 728 | else |
700 | else | ||
701 | { | ||
702 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
703 | UUID tileID; | ||
704 | |||
705 | if (UUID.TryParse(tile, out tileID)) | ||
706 | { | 729 | { |
707 | RegionInfo.RegionSettings.TerrainImageID = tileID; | 730 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); |
731 | UUID tileID; | ||
732 | |||
733 | if (UUID.TryParse(tile, out tileID)) | ||
734 | { | ||
735 | RegionInfo.RegionSettings.TerrainImageID = tileID; | ||
736 | } | ||
708 | } | 737 | } |
709 | } | ||
710 | 738 | ||
711 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); | 739 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); |
712 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | 740 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); |
713 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | 741 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); |
714 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | 742 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); |
715 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | 743 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); |
716 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | 744 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); |
717 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | 745 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); |
718 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | 746 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); |
719 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | 747 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); |
720 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | 748 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); |
749 | } | ||
750 | } | ||
751 | catch (Exception e) | ||
752 | { | ||
753 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); | ||
721 | } | 754 | } |
722 | 755 | ||
723 | #endregion Region Config | 756 | #endregion Region Config |
@@ -1126,7 +1159,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1126 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1159 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1127 | if (HeartbeatThread != null) | 1160 | if (HeartbeatThread != null) |
1128 | { | 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); | ||
1129 | HeartbeatThread.Abort(); | 1176 | HeartbeatThread.Abort(); |
1177 | Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); | ||
1130 | HeartbeatThread = null; | 1178 | HeartbeatThread = null; |
1131 | } | 1179 | } |
1132 | m_lastUpdate = Util.EnvironmentTickCount(); | 1180 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1180,9 +1228,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1180 | 1228 | ||
1181 | while (!shuttingdown) | 1229 | while (!shuttingdown) |
1182 | Update(); | 1230 | Update(); |
1183 | |||
1184 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1185 | m_firstHeartbeat = false; | ||
1186 | } | 1231 | } |
1187 | finally | 1232 | finally |
1188 | { | 1233 | { |
@@ -1277,6 +1322,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1277 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1322 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1278 | } | 1323 | } |
1279 | 1324 | ||
1325 | // if (Frame % m_update_land == 0) | ||
1326 | // { | ||
1327 | // int ldMS = Util.EnvironmentTickCount(); | ||
1328 | // UpdateLand(); | ||
1329 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1330 | // } | ||
1331 | |||
1280 | if (Frame % m_update_backup == 0) | 1332 | if (Frame % m_update_backup == 0) |
1281 | { | 1333 | { |
1282 | int backMS = Util.EnvironmentTickCount(); | 1334 | int backMS = Util.EnvironmentTickCount(); |
@@ -1366,12 +1418,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1366 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1418 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1367 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1419 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1368 | 1420 | ||
1421 | |||
1422 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1423 | m_firstHeartbeat = false; | ||
1424 | |||
1369 | if (maintc > 0) | 1425 | if (maintc > 0) |
1370 | Thread.Sleep(maintc); | 1426 | Thread.Sleep(maintc); |
1371 | 1427 | ||
1372 | // Tell the watchdog that this thread is still alive | 1428 | // Tell the watchdog that this thread is still alive |
1373 | Watchdog.UpdateThread(); | 1429 | Watchdog.UpdateThread(); |
1374 | } | 1430 | } |
1375 | 1431 | ||
1376 | public void AddGroupTarget(SceneObjectGroup grp) | 1432 | public void AddGroupTarget(SceneObjectGroup grp) |
1377 | { | 1433 | { |
@@ -1387,9 +1443,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1387 | 1443 | ||
1388 | private void CheckAtTargets() | 1444 | private void CheckAtTargets() |
1389 | { | 1445 | { |
1390 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1446 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1391 | lock (m_groupsWithTargets) | 1447 | lock (m_groupsWithTargets) |
1392 | objs = m_groupsWithTargets.Values; | 1448 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1393 | 1449 | ||
1394 | foreach (SceneObjectGroup entry in objs) | 1450 | foreach (SceneObjectGroup entry in objs) |
1395 | entry.checkAtTargets(); | 1451 | entry.checkAtTargets(); |
@@ -1470,7 +1526,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1470 | msg.fromAgentName = "Server"; | 1526 | msg.fromAgentName = "Server"; |
1471 | msg.dialog = (byte)19; // Object msg | 1527 | msg.dialog = (byte)19; // Object msg |
1472 | msg.fromGroup = false; | 1528 | msg.fromGroup = false; |
1473 | msg.offline = (byte)0; | 1529 | msg.offline = (byte)1; |
1474 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1530 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1475 | msg.Position = Vector3.Zero; | 1531 | msg.Position = Vector3.Zero; |
1476 | msg.RegionID = RegionInfo.RegionID.Guid; | 1532 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1708,14 +1764,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1708 | /// <returns></returns> | 1764 | /// <returns></returns> |
1709 | 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) |
1710 | { | 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 | |||
1711 | Vector3 pos = Vector3.Zero; | 1779 | Vector3 pos = Vector3.Zero; |
1712 | if (RayEndIsIntersection == (byte)1) | 1780 | if (RayEndIsIntersection == (byte)1) |
1713 | { | 1781 | { |
1714 | pos = RayEnd; | 1782 | pos = RayEnd; |
1715 | return pos; | ||
1716 | } | 1783 | } |
1717 | 1784 | else if (RayTargetID != UUID.Zero) | |
1718 | if (RayTargetID != UUID.Zero) | ||
1719 | { | 1785 | { |
1720 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1786 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1721 | 1787 | ||
@@ -1737,7 +1803,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1737 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1803 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1738 | 1804 | ||
1739 | // 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. |
1740 | // 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()); |
1741 | float ScaleOffset = 0.5f; | 1807 | float ScaleOffset = 0.5f; |
1742 | 1808 | ||
1743 | // If we hit something | 1809 | // If we hit something |
@@ -1760,13 +1826,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1760 | //pos.Z -= 0.25F; | 1826 | //pos.Z -= 0.25F; |
1761 | 1827 | ||
1762 | } | 1828 | } |
1763 | |||
1764 | return pos; | ||
1765 | } | 1829 | } |
1766 | else | 1830 | else |
1767 | { | 1831 | { |
1768 | // 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. |
1769 | |||
1770 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1833 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1771 | 1834 | ||
1772 | // 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. |
@@ -1775,13 +1838,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1775 | if (ei.HitTF) | 1838 | if (ei.HitTF) |
1776 | { | 1839 | { |
1777 | 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); |
1778 | } else | 1841 | } |
1842 | else | ||
1779 | { | 1843 | { |
1780 | // fall back to our stupid functionality | 1844 | // fall back to our stupid functionality |
1781 | pos = RayEnd; | 1845 | pos = RayEnd; |
1782 | } | 1846 | } |
1783 | |||
1784 | return pos; | ||
1785 | } | 1847 | } |
1786 | } | 1848 | } |
1787 | else | 1849 | else |
@@ -1792,8 +1854,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1792 | //increase height so its above the ground. | 1854 | //increase height so its above the ground. |
1793 | //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? |
1794 | pos.Z += scale.Z / 2f; | 1856 | pos.Z += scale.Z / 2f; |
1795 | return pos; | 1857 | // return pos; |
1796 | } | 1858 | } |
1859 | |||
1860 | // check against posible water intercept | ||
1861 | if (wpos.Z > pos.Z) pos = wpos; | ||
1862 | return pos; | ||
1797 | } | 1863 | } |
1798 | 1864 | ||
1799 | 1865 | ||
@@ -1877,7 +1943,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1877 | public bool AddRestoredSceneObject( | 1943 | public bool AddRestoredSceneObject( |
1878 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1944 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1879 | { | 1945 | { |
1880 | 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; | ||
1881 | } | 1950 | } |
1882 | 1951 | ||
1883 | /// <summary> | 1952 | /// <summary> |
@@ -1969,6 +2038,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1969 | /// </summary> | 2038 | /// </summary> |
1970 | public void DeleteAllSceneObjects() | 2039 | public void DeleteAllSceneObjects() |
1971 | { | 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>(); | ||
1972 | lock (Entities) | 2050 | lock (Entities) |
1973 | { | 2051 | { |
1974 | EntityBase[] entities = Entities.GetEntities(); | 2052 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1977,11 +2055,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1977 | if (e is SceneObjectGroup) | 2055 | if (e is SceneObjectGroup) |
1978 | { | 2056 | { |
1979 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2057 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1980 | if (!sog.IsAttachment) | 2058 | if (sog != null && !sog.IsAttachment) |
1981 | 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 | } | ||
1982 | } | 2069 | } |
1983 | } | 2070 | } |
1984 | } | 2071 | } |
2072 | if (toReturn.Count > 0) | ||
2073 | { | ||
2074 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2075 | } | ||
1985 | } | 2076 | } |
1986 | 2077 | ||
1987 | /// <summary> | 2078 | /// <summary> |
@@ -2022,6 +2113,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2022 | } | 2113 | } |
2023 | 2114 | ||
2024 | group.DeleteGroupFromScene(silent); | 2115 | group.DeleteGroupFromScene(silent); |
2116 | if (!silent) | ||
2117 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2025 | 2118 | ||
2026 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2119 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2027 | } | 2120 | } |
@@ -2311,6 +2404,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2311 | 2404 | ||
2312 | if (newPosition != Vector3.Zero) | 2405 | if (newPosition != Vector3.Zero) |
2313 | newObject.RootPart.GroupPosition = newPosition; | 2406 | newObject.RootPart.GroupPosition = newPosition; |
2407 | if (newObject.RootPart.KeyframeMotion != null) | ||
2408 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2314 | 2409 | ||
2315 | if (!AddSceneObject(newObject)) | 2410 | if (!AddSceneObject(newObject)) |
2316 | { | 2411 | { |
@@ -2379,10 +2474,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2379 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2474 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2380 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2475 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2381 | { | 2476 | { |
2477 | if (sceneObject.OwnerID == UUID.Zero) | ||
2478 | { | ||
2479 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2480 | return false; | ||
2481 | } | ||
2482 | |||
2382 | // If the user is banned, we won't let any of their objects | 2483 | // If the user is banned, we won't let any of their objects |
2383 | // enter. Period. | 2484 | // enter. Period. |
2384 | // | 2485 | // |
2385 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2486 | int flags = GetUserFlags(sceneObject.OwnerID); |
2487 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2386 | { | 2488 | { |
2387 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2489 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2388 | 2490 | ||
@@ -2428,12 +2530,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2428 | } | 2530 | } |
2429 | else | 2531 | else |
2430 | { | 2532 | { |
2533 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2431 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2534 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2432 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2535 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2433 | } | 2536 | } |
2537 | if (sceneObject.OwnerID == UUID.Zero) | ||
2538 | { | ||
2539 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2540 | return false; | ||
2541 | } | ||
2434 | } | 2542 | } |
2435 | else | 2543 | else |
2436 | { | 2544 | { |
2545 | if (sceneObject.OwnerID == UUID.Zero) | ||
2546 | { | ||
2547 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2548 | return false; | ||
2549 | } | ||
2437 | AddRestoredSceneObject(sceneObject, true, false); | 2550 | AddRestoredSceneObject(sceneObject, true, false); |
2438 | 2551 | ||
2439 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2552 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2462,6 +2575,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2462 | return 2; // StateSource.PrimCrossing | 2575 | return 2; // StateSource.PrimCrossing |
2463 | } | 2576 | } |
2464 | 2577 | ||
2578 | public int GetUserFlags(UUID user) | ||
2579 | { | ||
2580 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2581 | /* | ||
2582 | ScenePresence sp; | ||
2583 | if (TryGetScenePresence(user, out sp)) | ||
2584 | { | ||
2585 | return sp.UserFlags; | ||
2586 | } | ||
2587 | else | ||
2588 | { | ||
2589 | */ | ||
2590 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2591 | if (uac == null) | ||
2592 | return 0; | ||
2593 | return uac.UserFlags; | ||
2594 | //} | ||
2595 | } | ||
2465 | #endregion | 2596 | #endregion |
2466 | 2597 | ||
2467 | #region Add/Remove Avatar Methods | 2598 | #region Add/Remove Avatar Methods |
@@ -2476,6 +2607,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2476 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2607 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2477 | 2608 | ||
2478 | CheckHeartbeat(); | 2609 | CheckHeartbeat(); |
2610 | ScenePresence presence; | ||
2479 | 2611 | ||
2480 | ScenePresence sp = GetScenePresence(client.AgentId); | 2612 | ScenePresence sp = GetScenePresence(client.AgentId); |
2481 | 2613 | ||
@@ -2524,7 +2656,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2524 | 2656 | ||
2525 | EventManager.TriggerOnNewClient(client); | 2657 | EventManager.TriggerOnNewClient(client); |
2526 | if (vialogin) | 2658 | if (vialogin) |
2659 | { | ||
2527 | EventManager.TriggerOnClientLogin(client); | 2660 | EventManager.TriggerOnClientLogin(client); |
2661 | // Send initial parcel data | ||
2662 | Vector3 pos = sp.AbsolutePosition; | ||
2663 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2664 | land.SendLandUpdateToClient(client); | ||
2665 | } | ||
2528 | 2666 | ||
2529 | return sp; | 2667 | return sp; |
2530 | } | 2668 | } |
@@ -2614,19 +2752,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2614 | // and the scene presence and the client, if they exist | 2752 | // and the scene presence and the client, if they exist |
2615 | try | 2753 | try |
2616 | { | 2754 | { |
2617 | // We need to wait for the client to make UDP contact first. | 2755 | ScenePresence sp = GetScenePresence(agentID); |
2618 | // It's the UDP contact that creates the scene presence | 2756 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2619 | ScenePresence sp = WaitGetScenePresence(agentID); | 2757 | |
2620 | if (sp != null) | 2758 | if (sp != null) |
2621 | { | ||
2622 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2623 | |||
2624 | sp.ControllingClient.Close(); | 2759 | sp.ControllingClient.Close(); |
2625 | } | 2760 | |
2626 | else | ||
2627 | { | ||
2628 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2629 | } | ||
2630 | // BANG! SLASH! | 2761 | // BANG! SLASH! |
2631 | m_authenticateHandler.RemoveCircuit(agentID); | 2762 | m_authenticateHandler.RemoveCircuit(agentID); |
2632 | 2763 | ||
@@ -2671,6 +2802,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2671 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 2802 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2672 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 2803 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2673 | 2804 | ||
2805 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
2806 | |||
2674 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2807 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2675 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2808 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2676 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 2809 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2727,6 +2860,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2727 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2860 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2728 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2861 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2729 | client.OnCopyInventoryItem += CopyInventoryItem; | 2862 | client.OnCopyInventoryItem += CopyInventoryItem; |
2863 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2730 | client.OnMoveInventoryItem += MoveInventoryItem; | 2864 | client.OnMoveInventoryItem += MoveInventoryItem; |
2731 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2865 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2732 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2866 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2798,6 +2932,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2798 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 2932 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
2799 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 2933 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
2800 | 2934 | ||
2935 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
2936 | |||
2801 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 2937 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2802 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 2938 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2803 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 2939 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2900,15 +3036,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2900 | /// </summary> | 3036 | /// </summary> |
2901 | /// <param name="agentId">The avatar's Unique ID</param> | 3037 | /// <param name="agentId">The avatar's Unique ID</param> |
2902 | /// <param name="client">The IClientAPI for the client</param> | 3038 | /// <param name="client">The IClientAPI for the client</param> |
2903 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3039 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2904 | { | 3040 | { |
2905 | if (m_teleportModule != null) | 3041 | if (m_teleportModule != null) |
2906 | m_teleportModule.TeleportHome(agentId, client); | 3042 | return m_teleportModule.TeleportHome(agentId, client); |
2907 | else | 3043 | else |
2908 | { | 3044 | { |
2909 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3045 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2910 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3046 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2911 | } | 3047 | } |
3048 | return false; | ||
2912 | } | 3049 | } |
2913 | 3050 | ||
2914 | /// <summary> | 3051 | /// <summary> |
@@ -3018,6 +3155,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3018 | /// <param name="flags"></param> | 3155 | /// <param name="flags"></param> |
3019 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3156 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3020 | { | 3157 | { |
3158 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3159 | ScenePresence presence; | ||
3160 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3161 | { | ||
3162 | if (presence.Appearance != null) | ||
3163 | { | ||
3164 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3165 | } | ||
3166 | } | ||
3167 | |||
3021 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3168 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3022 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3169 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3023 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3170 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3086,8 +3233,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3086 | regions.Remove(RegionInfo.RegionHandle); | 3233 | regions.Remove(RegionInfo.RegionHandle); |
3087 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3234 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3088 | } | 3235 | } |
3089 | 3236 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3090 | m_eventManager.TriggerClientClosed(agentID, this); | 3237 | m_eventManager.TriggerClientClosed(agentID, this); |
3238 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3091 | } | 3239 | } |
3092 | catch (NullReferenceException) | 3240 | catch (NullReferenceException) |
3093 | { | 3241 | { |
@@ -3149,9 +3297,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3149 | { | 3297 | { |
3150 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); | 3298 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); |
3151 | } | 3299 | } |
3152 | 3300 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3153 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3301 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3154 | // CleanDroppedAttachments(); | 3302 | // CleanDroppedAttachments(); |
3303 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3155 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3304 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3156 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3305 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3157 | } | 3306 | } |
@@ -3273,13 +3422,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3273 | sp = null; | 3422 | sp = null; |
3274 | } | 3423 | } |
3275 | 3424 | ||
3276 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3277 | 3425 | ||
3278 | //On login test land permisions | 3426 | //On login test land permisions |
3279 | if (vialogin) | 3427 | if (vialogin) |
3280 | { | 3428 | { |
3281 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3429 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3430 | if (cache != null) | ||
3431 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3432 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3282 | { | 3433 | { |
3434 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3283 | return false; | 3435 | return false; |
3284 | } | 3436 | } |
3285 | } | 3437 | } |
@@ -3303,8 +3455,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3303 | 3455 | ||
3304 | try | 3456 | try |
3305 | { | 3457 | { |
3306 | if (!AuthorizeUser(agent, out reason)) | 3458 | // Always check estate if this is a login. Always |
3307 | return false; | 3459 | // check if banned regions are to be blacked out. |
3460 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3461 | { | ||
3462 | if (!AuthorizeUser(agent, out reason)) | ||
3463 | return false; | ||
3464 | } | ||
3308 | } | 3465 | } |
3309 | catch (Exception e) | 3466 | catch (Exception e) |
3310 | { | 3467 | { |
@@ -3430,6 +3587,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3430 | } | 3587 | } |
3431 | 3588 | ||
3432 | // Honor parcel landing type and position. | 3589 | // Honor parcel landing type and position. |
3590 | /* | ||
3591 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3433 | if (land != null) | 3592 | if (land != null) |
3434 | { | 3593 | { |
3435 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3594 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3437,26 +3596,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3437 | agent.startpos = land.LandData.UserLocation; | 3596 | agent.startpos = land.LandData.UserLocation; |
3438 | } | 3597 | } |
3439 | } | 3598 | } |
3599 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3440 | } | 3600 | } |
3441 | 3601 | ||
3442 | return true; | 3602 | return true; |
3443 | } | 3603 | } |
3444 | 3604 | ||
3445 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3605 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3446 | { | 3606 | { |
3447 | 3607 | reason = String.Empty; | |
3448 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3608 | if (Permissions.IsGod(agentID)) |
3449 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3609 | return true; |
3610 | |||
3611 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3612 | if (land == null) | ||
3613 | return false; | ||
3614 | |||
3615 | bool banned = land.IsBannedFromLand(agentID); | ||
3616 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3450 | 3617 | ||
3451 | if (banned || restricted) | 3618 | if (banned || restricted) |
3452 | { | 3619 | { |
3453 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3620 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3454 | if (nearestParcel != null) | 3621 | if (nearestParcel != null) |
3455 | { | 3622 | { |
3456 | //Move agent to nearest allowed | 3623 | //Move agent to nearest allowed |
3457 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3624 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3458 | agent.startpos.X = newPosition.X; | 3625 | posX = newPosition.X; |
3459 | agent.startpos.Y = newPosition.Y; | 3626 | posY = newPosition.Y; |
3460 | } | 3627 | } |
3461 | else | 3628 | else |
3462 | { | 3629 | { |
@@ -3518,7 +3685,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3518 | 3685 | ||
3519 | if (!m_strictAccessControl) return true; | 3686 | if (!m_strictAccessControl) return true; |
3520 | if (Permissions.IsGod(agent.AgentID)) return true; | 3687 | if (Permissions.IsGod(agent.AgentID)) return true; |
3521 | 3688 | ||
3522 | if (AuthorizationService != null) | 3689 | if (AuthorizationService != null) |
3523 | { | 3690 | { |
3524 | if (!AuthorizationService.IsAuthorizedForRegion( | 3691 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3533,7 +3700,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3533 | 3700 | ||
3534 | if (m_regInfo.EstateSettings != null) | 3701 | if (m_regInfo.EstateSettings != null) |
3535 | { | 3702 | { |
3536 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3703 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3537 | { | 3704 | { |
3538 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3705 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3539 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3706 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3725,6 +3892,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3725 | 3892 | ||
3726 | // We have to wait until the viewer contacts this region after receiving EAC. | 3893 | // We have to wait until the viewer contacts this region after receiving EAC. |
3727 | // That calls AddNewClient, which finally creates the ScenePresence | 3894 | // That calls AddNewClient, which finally creates the ScenePresence |
3895 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3896 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3897 | { | ||
3898 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3899 | return false; | ||
3900 | } | ||
3901 | |||
3728 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3902 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3729 | if (nearestParcel == null) | 3903 | if (nearestParcel == null) |
3730 | { | 3904 | { |
@@ -3806,12 +3980,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3806 | return false; | 3980 | return false; |
3807 | } | 3981 | } |
3808 | 3982 | ||
3983 | public bool IncomingCloseAgent(UUID agentID) | ||
3984 | { | ||
3985 | return IncomingCloseAgent(agentID, false); | ||
3986 | } | ||
3987 | |||
3988 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3989 | { | ||
3990 | return IncomingCloseAgent(agentID, true); | ||
3991 | } | ||
3992 | |||
3809 | /// <summary> | 3993 | /// <summary> |
3810 | /// Tell a single agent to disconnect from the region. | 3994 | /// Tell a single agent to disconnect from the region. |
3811 | /// </summary> | 3995 | /// </summary> |
3812 | /// <param name="regionHandle"></param> | ||
3813 | /// <param name="agentID"></param> | 3996 | /// <param name="agentID"></param> |
3814 | public bool IncomingCloseAgent(UUID agentID) | 3997 | /// <param name="childOnly"></param> |
3998 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3815 | { | 3999 | { |
3816 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4000 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3817 | 4001 | ||
@@ -3823,7 +4007,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3823 | { | 4007 | { |
3824 | m_sceneGraph.removeUserCount(false); | 4008 | m_sceneGraph.removeUserCount(false); |
3825 | } | 4009 | } |
3826 | else | 4010 | else if (!childOnly) |
3827 | { | 4011 | { |
3828 | m_sceneGraph.removeUserCount(true); | 4012 | m_sceneGraph.removeUserCount(true); |
3829 | } | 4013 | } |
@@ -3839,9 +4023,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3839 | } | 4023 | } |
3840 | else | 4024 | else |
3841 | presence.ControllingClient.SendShutdownConnectionNotice(); | 4025 | presence.ControllingClient.SendShutdownConnectionNotice(); |
4026 | presence.ControllingClient.Close(false); | ||
4027 | } | ||
4028 | else if (!childOnly) | ||
4029 | { | ||
4030 | presence.ControllingClient.Close(true); | ||
3842 | } | 4031 | } |
3843 | |||
3844 | presence.ControllingClient.Close(); | ||
3845 | return true; | 4032 | return true; |
3846 | } | 4033 | } |
3847 | 4034 | ||
@@ -4423,34 +4610,78 @@ namespace OpenSim.Region.Framework.Scenes | |||
4423 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4610 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4424 | } | 4611 | } |
4425 | 4612 | ||
4426 | public int GetHealth() | 4613 | public int GetHealth(out int flags, out string message) |
4427 | { | 4614 | { |
4428 | // Returns: | 4615 | // Returns: |
4429 | // 1 = sim is up and accepting http requests. The heartbeat has | 4616 | // 1 = sim is up and accepting http requests. The heartbeat has |
4430 | // stopped and the sim is probably locked up, but a remote | 4617 | // stopped and the sim is probably locked up, but a remote |
4431 | // admin restart may succeed | 4618 | // admin restart may succeed |
4432 | // | 4619 | // |
4433 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4620 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4434 | // usable for people within and logins _may_ work | 4621 | // usable for people within |
4622 | // | ||
4623 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4624 | // unstable and will not accept new logins | ||
4435 | // | 4625 | // |
4436 | // 3 = We have seen a new user enter within the past 4 minutes | 4626 | // 4 = Sim is up and both packet threads are running. Sim is |
4627 | // likely usable | ||
4628 | // | ||
4629 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4437 | // which can be seen as positive confirmation of sim health | 4630 | // which can be seen as positive confirmation of sim health |
4438 | // | 4631 | // |
4632 | |||
4633 | flags = 0; | ||
4634 | message = String.Empty; | ||
4635 | |||
4636 | CheckHeartbeat(); | ||
4637 | |||
4638 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4639 | { | ||
4640 | // We're still starting | ||
4641 | // 0 means "in startup", it can't happen another way, since | ||
4642 | // to get here, we must be able to accept http connections | ||
4643 | return 0; | ||
4644 | } | ||
4645 | |||
4439 | int health=1; // Start at 1, means we're up | 4646 | int health=1; // Start at 1, means we're up |
4440 | 4647 | ||
4441 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4648 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4649 | { | ||
4650 | health+=1; | ||
4651 | flags |= 1; | ||
4652 | } | ||
4653 | |||
4654 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4655 | { | ||
4442 | health+=1; | 4656 | health+=1; |
4657 | flags |= 2; | ||
4658 | } | ||
4659 | |||
4660 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4661 | { | ||
4662 | health+=1; | ||
4663 | flags |= 4; | ||
4664 | } | ||
4443 | else | 4665 | else |
4666 | { | ||
4667 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4668 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4669 | proc.EnableRaisingEvents=false; | ||
4670 | proc.StartInfo.FileName = "/bin/kill"; | ||
4671 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4672 | proc.Start(); | ||
4673 | proc.WaitForExit(); | ||
4674 | Thread.Sleep(1000); | ||
4675 | Environment.Exit(1); | ||
4676 | } | ||
4677 | |||
4678 | if (flags != 7) | ||
4444 | return health; | 4679 | return health; |
4445 | 4680 | ||
4446 | // A login in the last 4 mins? We can't be doing too badly | 4681 | // A login in the last 4 mins? We can't be doing too badly |
4447 | // | 4682 | // |
4448 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4683 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4449 | health++; | 4684 | health++; |
4450 | else | ||
4451 | return health; | ||
4452 | |||
4453 | CheckHeartbeat(); | ||
4454 | 4685 | ||
4455 | return health; | 4686 | return health; |
4456 | } | 4687 | } |
@@ -4539,7 +4770,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4539 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 4770 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4540 | if (wasUsingPhysics) | 4771 | if (wasUsingPhysics) |
4541 | { | 4772 | { |
4542 | 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 | 4773 | 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 |
4543 | } | 4774 | } |
4544 | } | 4775 | } |
4545 | 4776 | ||
@@ -4643,7 +4874,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4643 | if (m_firstHeartbeat) | 4874 | if (m_firstHeartbeat) |
4644 | return; | 4875 | return; |
4645 | 4876 | ||
4646 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4877 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4647 | StartTimer(); | 4878 | StartTimer(); |
4648 | } | 4879 | } |
4649 | 4880 | ||
@@ -4657,9 +4888,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4657 | get { return m_allowScriptCrossings; } | 4888 | get { return m_allowScriptCrossings; } |
4658 | } | 4889 | } |
4659 | 4890 | ||
4660 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 4891 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
4892 | { | ||
4893 | return GetNearestAllowedPosition(avatar, null); | ||
4894 | } | ||
4895 | |||
4896 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
4661 | { | 4897 | { |
4662 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 4898 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); |
4663 | 4899 | ||
4664 | if (nearestParcel != null) | 4900 | if (nearestParcel != null) |
4665 | { | 4901 | { |
@@ -4668,10 +4904,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4668 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 4904 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4669 | if (nearestPoint != null) | 4905 | if (nearestPoint != null) |
4670 | { | 4906 | { |
4671 | // m_log.DebugFormat( | 4907 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
4672 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
4673 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
4674 | |||
4675 | return nearestPoint.Value; | 4908 | return nearestPoint.Value; |
4676 | } | 4909 | } |
4677 | 4910 | ||
@@ -4681,17 +4914,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4681 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 4914 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4682 | if (nearestPoint != null) | 4915 | if (nearestPoint != null) |
4683 | { | 4916 | { |
4684 | // m_log.DebugFormat( | 4917 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
4685 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
4686 | |||
4687 | return nearestPoint.Value; | 4918 | return nearestPoint.Value; |
4688 | } | 4919 | } |
4689 | 4920 | ||
4690 | //Ultimate backup if we have no idea where they are | 4921 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
4691 | // m_log.DebugFormat( | 4922 | if (dest != excludeParcel) |
4692 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 4923 | { |
4924 | // Ultimate backup if we have no idea where they are and | ||
4925 | // the last allowed position was in another parcel | ||
4926 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
4927 | return avatar.lastKnownAllowedPosition; | ||
4928 | } | ||
4693 | 4929 | ||
4694 | return avatar.lastKnownAllowedPosition; | 4930 | // else fall through to region edge |
4695 | } | 4931 | } |
4696 | 4932 | ||
4697 | //Go to the edge, this happens in teleporting to a region with no available parcels | 4933 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -4725,13 +4961,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4725 | 4961 | ||
4726 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 4962 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
4727 | { | 4963 | { |
4964 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
4965 | } | ||
4966 | |||
4967 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
4968 | { | ||
4728 | List<ILandObject> all = AllParcels(); | 4969 | List<ILandObject> all = AllParcels(); |
4729 | float minParcelDistance = float.MaxValue; | 4970 | float minParcelDistance = float.MaxValue; |
4730 | ILandObject nearestParcel = null; | 4971 | ILandObject nearestParcel = null; |
4731 | 4972 | ||
4732 | foreach (var parcel in all) | 4973 | foreach (var parcel in all) |
4733 | { | 4974 | { |
4734 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 4975 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
4735 | { | 4976 | { |
4736 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 4977 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
4737 | if (parcelDistance < minParcelDistance) | 4978 | if (parcelDistance < minParcelDistance) |
@@ -4973,7 +5214,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
4973 | mapModule.GenerateMaptile(); | 5214 | mapModule.GenerateMaptile(); |
4974 | } | 5215 | } |
4975 | 5216 | ||
4976 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5217 | // public void CleanDroppedAttachments() |
5218 | // { | ||
5219 | // List<SceneObjectGroup> objectsToDelete = | ||
5220 | // new List<SceneObjectGroup>(); | ||
5221 | // | ||
5222 | // lock (m_cleaningAttachments) | ||
5223 | // { | ||
5224 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5225 | // { | ||
5226 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5227 | // { | ||
5228 | // UUID agentID = grp.OwnerID; | ||
5229 | // if (agentID == UUID.Zero) | ||
5230 | // { | ||
5231 | // objectsToDelete.Add(grp); | ||
5232 | // return; | ||
5233 | // } | ||
5234 | // | ||
5235 | // ScenePresence sp = GetScenePresence(agentID); | ||
5236 | // if (sp == null) | ||
5237 | // { | ||
5238 | // objectsToDelete.Add(grp); | ||
5239 | // return; | ||
5240 | // } | ||
5241 | // } | ||
5242 | // }); | ||
5243 | // } | ||
5244 | // | ||
5245 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5246 | // { | ||
5247 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5248 | // DeleteSceneObject(grp, true); | ||
5249 | // } | ||
5250 | // } | ||
5251 | |||
5252 | public void ThreadAlive(int threadCode) | ||
5253 | { | ||
5254 | switch(threadCode) | ||
5255 | { | ||
5256 | case 1: // Incoming | ||
5257 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5258 | break; | ||
5259 | case 2: // Incoming | ||
5260 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5261 | break; | ||
5262 | } | ||
5263 | } | ||
5264 | |||
5265 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
4977 | { | 5266 | { |
4978 | RegenerateMaptile(); | 5267 | RegenerateMaptile(); |
4979 | 5268 | ||
@@ -4992,6 +5281,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4992 | // child agent creation, thereby emulating the SL behavior. | 5281 | // child agent creation, thereby emulating the SL behavior. |
4993 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5282 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
4994 | { | 5283 | { |
5284 | reason = "You are banned from the region"; | ||
5285 | |||
5286 | if (Permissions.IsGod(agentID)) | ||
5287 | { | ||
5288 | reason = String.Empty; | ||
5289 | return true; | ||
5290 | } | ||
5291 | |||
4995 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5292 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
4996 | 5293 | ||
4997 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5294 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5003,6 +5300,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5003 | } | 5300 | } |
5004 | } | 5301 | } |
5005 | 5302 | ||
5303 | ScenePresence presence = GetScenePresence(agentID); | ||
5304 | IClientAPI client = null; | ||
5305 | AgentCircuitData aCircuit = null; | ||
5306 | |||
5307 | if (presence != null) | ||
5308 | { | ||
5309 | client = presence.ControllingClient; | ||
5310 | if (client != null) | ||
5311 | aCircuit = client.RequestClientInfo(); | ||
5312 | } | ||
5313 | |||
5314 | // We may be called before there is a presence or a client. | ||
5315 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5316 | if (client == null) | ||
5317 | { | ||
5318 | aCircuit = new AgentCircuitData(); | ||
5319 | aCircuit.AgentID = agentID; | ||
5320 | aCircuit.firstname = String.Empty; | ||
5321 | aCircuit.lastname = String.Empty; | ||
5322 | } | ||
5323 | |||
5324 | try | ||
5325 | { | ||
5326 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5327 | { | ||
5328 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5329 | return false; | ||
5330 | } | ||
5331 | } | ||
5332 | catch (Exception e) | ||
5333 | { | ||
5334 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5335 | return false; | ||
5336 | } | ||
5337 | |||
5006 | if (position == Vector3.Zero) // Teleport | 5338 | if (position == Vector3.Zero) // Teleport |
5007 | { | 5339 | { |
5008 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5340 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5031,13 +5363,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5031 | } | 5363 | } |
5032 | } | 5364 | } |
5033 | } | 5365 | } |
5366 | |||
5367 | float posX = 128.0f; | ||
5368 | float posY = 128.0f; | ||
5369 | |||
5370 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5371 | { | ||
5372 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5373 | return false; | ||
5374 | } | ||
5375 | } | ||
5376 | else // Walking | ||
5377 | { | ||
5378 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5379 | if (land == null) | ||
5380 | return false; | ||
5381 | |||
5382 | bool banned = land.IsBannedFromLand(agentID); | ||
5383 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5384 | |||
5385 | if (banned || restricted) | ||
5386 | return false; | ||
5034 | } | 5387 | } |
5035 | 5388 | ||
5036 | reason = String.Empty; | 5389 | reason = String.Empty; |
5037 | return true; | 5390 | return true; |
5038 | } | 5391 | } |
5039 | 5392 | ||
5040 | /// <summary> | 5393 | public void StartTimerWatchdog() |
5394 | { | ||
5395 | m_timerWatchdog.Interval = 1000; | ||
5396 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5397 | m_timerWatchdog.AutoReset = true; | ||
5398 | m_timerWatchdog.Start(); | ||
5399 | } | ||
5400 | |||
5401 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5402 | { | ||
5403 | CheckHeartbeat(); | ||
5404 | } | ||
5405 | |||
5041 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5406 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5042 | /// autopilot that moves an avatar to a sit target!. | 5407 | /// autopilot that moves an avatar to a sit target!. |
5043 | /// </summary> | 5408 | /// </summary> |