diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 725 |
1 files changed, 556 insertions, 169 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 702e322..b79892d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -124,6 +124,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
124 | // TODO: need to figure out how allow client agents but deny | 124 | // TODO: need to figure out how allow client agents but deny |
125 | // root agents when ACL denies access to root agent | 125 | // root agents when ACL denies access to root agent |
126 | public bool m_strictAccessControl = true; | 126 | public bool m_strictAccessControl = true; |
127 | public bool m_seeIntoBannedRegion = false; | ||
127 | public int MaxUndoCount = 5; | 128 | public int MaxUndoCount = 5; |
128 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 129 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
129 | public bool LoginLock = false; | 130 | public bool LoginLock = false; |
@@ -139,12 +140,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
139 | 140 | ||
140 | protected int m_splitRegionID; | 141 | protected int m_splitRegionID; |
141 | protected Timer m_restartWaitTimer = new Timer(); | 142 | protected Timer m_restartWaitTimer = new Timer(); |
143 | protected Timer m_timerWatchdog = new Timer(); | ||
142 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 144 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
143 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 145 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
144 | protected string m_simulatorVersion = "OpenSimulator Server"; | 146 | protected string m_simulatorVersion = "OpenSimulator Server"; |
145 | protected ModuleLoader m_moduleLoader; | 147 | protected ModuleLoader m_moduleLoader; |
146 | protected AgentCircuitManager m_authenticateHandler; | 148 | protected AgentCircuitManager m_authenticateHandler; |
147 | protected SceneCommunicationService m_sceneGridService; | 149 | protected SceneCommunicationService m_sceneGridService; |
150 | protected ISnmpModule m_snmpService = null; | ||
148 | 151 | ||
149 | protected ISimulationDataService m_SimulationDataService; | 152 | protected ISimulationDataService m_SimulationDataService; |
150 | protected IEstateDataService m_EstateDataService; | 153 | protected IEstateDataService m_EstateDataService; |
@@ -206,7 +209,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
206 | private int m_update_events = 1; | 209 | private int m_update_events = 1; |
207 | private int m_update_backup = 200; | 210 | private int m_update_backup = 200; |
208 | private int m_update_terrain = 50; | 211 | private int m_update_terrain = 50; |
209 | // private int m_update_land = 1; | 212 | private int m_update_land = 10; |
210 | private int m_update_coarse_locations = 50; | 213 | private int m_update_coarse_locations = 50; |
211 | 214 | ||
212 | private int agentMS; | 215 | private int agentMS; |
@@ -225,6 +228,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
225 | /// </summary> | 228 | /// </summary> |
226 | private int m_lastFrameTick; | 229 | private int m_lastFrameTick; |
227 | 230 | ||
231 | public bool CombineRegions = false; | ||
228 | /// <summary> | 232 | /// <summary> |
229 | /// Tick at which the last maintenance run occurred. | 233 | /// Tick at which the last maintenance run occurred. |
230 | /// </summary> | 234 | /// </summary> |
@@ -255,6 +259,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
255 | /// </summary> | 259 | /// </summary> |
256 | private int m_LastLogin; | 260 | private int m_LastLogin; |
257 | 261 | ||
262 | private int m_lastIncoming; | ||
263 | private int m_lastOutgoing; | ||
264 | private int m_hbRestarts = 0; | ||
265 | |||
266 | |||
258 | /// <summary> | 267 | /// <summary> |
259 | /// Thread that runs the scene loop. | 268 | /// Thread that runs the scene loop. |
260 | /// </summary> | 269 | /// </summary> |
@@ -270,7 +279,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
270 | private volatile bool m_shuttingDown; | 279 | private volatile bool m_shuttingDown; |
271 | 280 | ||
272 | // private int m_lastUpdate; | 281 | // private int m_lastUpdate; |
273 | // private bool m_firstHeartbeat = true; | 282 | private bool m_firstHeartbeat = true; |
274 | 283 | ||
275 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 284 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
276 | private bool m_reprioritizationEnabled = true; | 285 | private bool m_reprioritizationEnabled = true; |
@@ -315,6 +324,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
315 | get { return m_sceneGridService; } | 324 | get { return m_sceneGridService; } |
316 | } | 325 | } |
317 | 326 | ||
327 | public ISnmpModule SnmpService | ||
328 | { | ||
329 | get | ||
330 | { | ||
331 | if (m_snmpService == null) | ||
332 | { | ||
333 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
334 | } | ||
335 | |||
336 | return m_snmpService; | ||
337 | } | ||
338 | } | ||
339 | |||
318 | public ISimulationDataService SimulationDataService | 340 | public ISimulationDataService SimulationDataService |
319 | { | 341 | { |
320 | get | 342 | get |
@@ -613,6 +635,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
613 | m_EstateDataService = estateDataService; | 635 | m_EstateDataService = estateDataService; |
614 | m_regionHandle = m_regInfo.RegionHandle; | 636 | m_regionHandle = m_regInfo.RegionHandle; |
615 | m_regionName = m_regInfo.RegionName; | 637 | m_regionName = m_regInfo.RegionName; |
638 | m_lastIncoming = 0; | ||
639 | m_lastOutgoing = 0; | ||
616 | 640 | ||
617 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 641 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
618 | m_asyncSceneObjectDeleter.Enabled = true; | 642 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -693,102 +717,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
693 | 717 | ||
694 | // Region config overrides global config | 718 | // Region config overrides global config |
695 | // | 719 | // |
696 | if (m_config.Configs["Startup"] != null) | 720 | try |
697 | { | 721 | { |
698 | IConfig startupConfig = m_config.Configs["Startup"]; | 722 | if (m_config.Configs["Startup"] != null) |
699 | |||
700 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | ||
701 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); | ||
702 | if (!m_useBackup) | ||
703 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | ||
704 | |||
705 | //Animation states | ||
706 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | ||
707 | |||
708 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | ||
709 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | ||
710 | |||
711 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); | ||
712 | if (RegionInfo.NonphysPrimMax > 0) | ||
713 | { | 723 | { |
714 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 724 | IConfig startupConfig = m_config.Configs["Startup"]; |
715 | } | ||
716 | |||
717 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | ||
718 | 725 | ||
719 | if (RegionInfo.PhysPrimMax > 0) | 726 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
720 | { | 727 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); |
721 | m_maxPhys = RegionInfo.PhysPrimMax; | 728 | if (!m_useBackup) |
722 | } | 729 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
730 | |||
731 | //Animation states | ||
732 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | ||
723 | 733 | ||
724 | // Here, if clamping is requested in either global or | 734 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
725 | // local config, it will be used | 735 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
726 | // | ||
727 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); | ||
728 | if (RegionInfo.ClampPrimSize) | ||
729 | { | ||
730 | m_clampPrimSize = true; | ||
731 | } | ||
732 | 736 | ||
733 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | 737 | m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); |
734 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 738 | if (RegionInfo.NonphysPrimMax > 0) |
735 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 739 | { |
736 | m_dontPersistBefore = | 740 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
737 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | 741 | } |
738 | m_dontPersistBefore *= 10000000; | ||
739 | m_persistAfter = | ||
740 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | ||
741 | m_persistAfter *= 10000000; | ||
742 | 742 | ||
743 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 743 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
744 | 744 | ||
745 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | 745 | if (RegionInfo.PhysPrimMax > 0) |
746 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | 746 | { |
747 | m_maxPhys = RegionInfo.PhysPrimMax; | ||
748 | } | ||
747 | 749 | ||
748 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 750 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); |
749 | if (packetConfig != null) | 751 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); |
750 | { | ||
751 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); | ||
752 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); | ||
753 | } | ||
754 | 752 | ||
755 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 753 | // Here, if clamping is requested in either global or |
754 | // local config, it will be used | ||
755 | // | ||
756 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); | ||
757 | if (RegionInfo.ClampPrimSize) | ||
758 | { | ||
759 | m_clampPrimSize = true; | ||
760 | } | ||
756 | 761 | ||
757 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 762 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
758 | if (m_generateMaptiles) | 763 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
759 | { | 764 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
760 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); | 765 | m_dontPersistBefore = |
761 | if (maptileRefresh != 0) | 766 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); |
767 | m_dontPersistBefore *= 10000000; | ||
768 | m_persistAfter = | ||
769 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | ||
770 | m_persistAfter *= 10000000; | ||
771 | |||
772 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | ||
773 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
774 | |||
775 | IConfig packetConfig = m_config.Configs["PacketPool"]; | ||
776 | if (packetConfig != null) | ||
762 | { | 777 | { |
763 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | 778 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); |
764 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | 779 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); |
765 | m_mapGenerationTimer.AutoReset = true; | ||
766 | m_mapGenerationTimer.Start(); | ||
767 | } | 780 | } |
768 | } | ||
769 | else | ||
770 | { | ||
771 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
772 | UUID tileID; | ||
773 | 781 | ||
774 | if (UUID.TryParse(tile, out tileID)) | 782 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
783 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
784 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
785 | |||
786 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | ||
787 | if (m_generateMaptiles) | ||
775 | { | 788 | { |
776 | RegionInfo.RegionSettings.TerrainImageID = tileID; | 789 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); |
790 | if (maptileRefresh != 0) | ||
791 | { | ||
792 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | ||
793 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | ||
794 | m_mapGenerationTimer.AutoReset = true; | ||
795 | m_mapGenerationTimer.Start(); | ||
796 | } | ||
777 | } | 797 | } |
778 | } | 798 | else |
799 | { | ||
800 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
801 | UUID tileID; | ||
779 | 802 | ||
780 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); | 803 | if (UUID.TryParse(tile, out tileID)) |
781 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | 804 | { |
782 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | 805 | RegionInfo.RegionSettings.TerrainImageID = tileID; |
783 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | 806 | } |
784 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | 807 | } |
785 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | ||
786 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | ||
787 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | ||
788 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | ||
789 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | ||
790 | 808 | ||
791 | SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); | 809 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); |
810 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | ||
811 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | ||
812 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | ||
813 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | ||
814 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | ||
815 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | ||
816 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | ||
817 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | ||
818 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | ||
819 | SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); | ||
820 | } | ||
821 | } | ||
822 | catch (Exception e) | ||
823 | { | ||
824 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); | ||
792 | } | 825 | } |
793 | 826 | ||
794 | #endregion Region Config | 827 | #endregion Region Config |
@@ -1215,7 +1248,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1215 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1248 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1216 | if (m_heartbeatThread != null) | 1249 | if (m_heartbeatThread != null) |
1217 | { | 1250 | { |
1251 | m_hbRestarts++; | ||
1252 | if(m_hbRestarts > 10) | ||
1253 | Environment.Exit(1); | ||
1254 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1255 | |||
1256 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1257 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1258 | //proc.EnableRaisingEvents=false; | ||
1259 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1260 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1261 | //proc.Start(); | ||
1262 | //proc.WaitForExit(); | ||
1263 | //Thread.Sleep(1000); | ||
1264 | //Environment.Exit(1); | ||
1218 | m_heartbeatThread.Abort(); | 1265 | m_heartbeatThread.Abort(); |
1266 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1219 | m_heartbeatThread = null; | 1267 | m_heartbeatThread = null; |
1220 | } | 1268 | } |
1221 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1269 | // m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1363,10 +1411,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1363 | int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; | 1411 | int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; |
1364 | int previousFrameTick; | 1412 | int previousFrameTick; |
1365 | int maintc; | 1413 | int maintc; |
1414 | int sleepMS; | ||
1415 | int framestart; | ||
1366 | 1416 | ||
1367 | while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) | 1417 | while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) |
1368 | { | 1418 | { |
1369 | maintc = Util.EnvironmentTickCount(); | 1419 | framestart = Util.EnvironmentTickCount(); |
1370 | ++Frame; | 1420 | ++Frame; |
1371 | 1421 | ||
1372 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1422 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
@@ -1454,7 +1504,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1454 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1504 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1455 | //} | 1505 | //} |
1456 | 1506 | ||
1457 | frameMS = Util.EnvironmentTickCountSubtract(maintc); | 1507 | // frameMS = Util.EnvironmentTickCountSubtract(maintc); |
1458 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1508 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
1459 | 1509 | ||
1460 | // if (Frame%m_update_avatars == 0) | 1510 | // if (Frame%m_update_avatars == 0) |
@@ -1465,7 +1515,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1465 | 1515 | ||
1466 | // frameMS currently records work frame times, not total frame times (work + any required sleep to | 1516 | // frameMS currently records work frame times, not total frame times (work + any required sleep to |
1467 | // reach min frame time. | 1517 | // reach min frame time. |
1468 | StatsReporter.addFrameMS(frameMS); | 1518 | // StatsReporter.addFrameMS(frameMS); |
1469 | 1519 | ||
1470 | StatsReporter.addAgentMS(agentMS); | 1520 | StatsReporter.addAgentMS(agentMS); |
1471 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | 1521 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); |
@@ -1521,12 +1571,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1521 | 1571 | ||
1522 | previousFrameTick = m_lastFrameTick; | 1572 | previousFrameTick = m_lastFrameTick; |
1523 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1573 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1524 | maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1574 | maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); |
1525 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1575 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1526 | 1576 | ||
1577 | m_firstHeartbeat = false; | ||
1578 | |||
1579 | |||
1580 | sleepMS = Util.EnvironmentTickCount(); | ||
1581 | |||
1527 | if (maintc > 0) | 1582 | if (maintc > 0) |
1528 | Thread.Sleep(maintc); | 1583 | Thread.Sleep(maintc); |
1529 | 1584 | ||
1585 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); | ||
1586 | frameMS = Util.EnvironmentTickCountSubtract(framestart); | ||
1587 | StatsReporter.addSleepMS(sleepMS); | ||
1588 | StatsReporter.addFrameMS(frameMS); | ||
1589 | |||
1530 | // Optionally warn if a frame takes double the amount of time that it should. | 1590 | // Optionally warn if a frame takes double the amount of time that it should. |
1531 | if (DebugUpdates | 1591 | if (DebugUpdates |
1532 | && Util.EnvironmentTickCountSubtract( | 1592 | && Util.EnvironmentTickCountSubtract( |
@@ -1553,9 +1613,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1553 | 1613 | ||
1554 | private void CheckAtTargets() | 1614 | private void CheckAtTargets() |
1555 | { | 1615 | { |
1556 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1616 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1557 | lock (m_groupsWithTargets) | 1617 | lock (m_groupsWithTargets) |
1558 | objs = m_groupsWithTargets.Values; | 1618 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1559 | 1619 | ||
1560 | foreach (SceneObjectGroup entry in objs) | 1620 | foreach (SceneObjectGroup entry in objs) |
1561 | entry.checkAtTargets(); | 1621 | entry.checkAtTargets(); |
@@ -1636,7 +1696,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1636 | msg.fromAgentName = "Server"; | 1696 | msg.fromAgentName = "Server"; |
1637 | msg.dialog = (byte)19; // Object msg | 1697 | msg.dialog = (byte)19; // Object msg |
1638 | msg.fromGroup = false; | 1698 | msg.fromGroup = false; |
1639 | msg.offline = (byte)0; | 1699 | msg.offline = (byte)1; |
1640 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1700 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1641 | msg.Position = Vector3.Zero; | 1701 | msg.Position = Vector3.Zero; |
1642 | msg.RegionID = RegionInfo.RegionID.Guid; | 1702 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1858,6 +1918,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1858 | EventManager.TriggerPrimsLoaded(this); | 1918 | EventManager.TriggerPrimsLoaded(this); |
1859 | } | 1919 | } |
1860 | 1920 | ||
1921 | public bool SuportsRayCastFiltered() | ||
1922 | { | ||
1923 | if (PhysicsScene == null) | ||
1924 | return false; | ||
1925 | return PhysicsScene.SuportsRaycastWorldFiltered(); | ||
1926 | } | ||
1927 | |||
1928 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | ||
1929 | { | ||
1930 | if (PhysicsScene == null) | ||
1931 | return null; | ||
1932 | return PhysicsScene.RaycastWorld(position, direction, length, Count,filter); | ||
1933 | } | ||
1861 | 1934 | ||
1862 | /// <summary> | 1935 | /// <summary> |
1863 | /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. | 1936 | /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. |
@@ -1874,14 +1947,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1874 | /// <returns></returns> | 1947 | /// <returns></returns> |
1875 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1948 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1876 | { | 1949 | { |
1950 | |||
1951 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1952 | Vector3 wpos = Vector3.Zero; | ||
1953 | // Check for water surface intersection from above | ||
1954 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1955 | { | ||
1956 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1957 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1958 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1959 | wpos.Z = wheight; | ||
1960 | } | ||
1961 | |||
1877 | Vector3 pos = Vector3.Zero; | 1962 | Vector3 pos = Vector3.Zero; |
1878 | if (RayEndIsIntersection == (byte)1) | 1963 | if (RayEndIsIntersection == (byte)1) |
1879 | { | 1964 | { |
1880 | pos = RayEnd; | 1965 | pos = RayEnd; |
1881 | return pos; | ||
1882 | } | 1966 | } |
1883 | 1967 | else if (RayTargetID != UUID.Zero) | |
1884 | if (RayTargetID != UUID.Zero) | ||
1885 | { | 1968 | { |
1886 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1969 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1887 | 1970 | ||
@@ -1903,7 +1986,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1903 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1986 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1904 | 1987 | ||
1905 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1988 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1906 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1989 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1907 | float ScaleOffset = 0.5f; | 1990 | float ScaleOffset = 0.5f; |
1908 | 1991 | ||
1909 | // If we hit something | 1992 | // If we hit something |
@@ -1926,13 +2009,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1926 | //pos.Z -= 0.25F; | 2009 | //pos.Z -= 0.25F; |
1927 | 2010 | ||
1928 | } | 2011 | } |
1929 | |||
1930 | return pos; | ||
1931 | } | 2012 | } |
1932 | else | 2013 | else |
1933 | { | 2014 | { |
1934 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2015 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1935 | |||
1936 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2016 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1937 | 2017 | ||
1938 | // Un-comment the following line to print the raytrace results to the console. | 2018 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1941,13 +2021,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1941 | if (ei.HitTF) | 2021 | if (ei.HitTF) |
1942 | { | 2022 | { |
1943 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2023 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1944 | } else | 2024 | } |
2025 | else | ||
1945 | { | 2026 | { |
1946 | // fall back to our stupid functionality | 2027 | // fall back to our stupid functionality |
1947 | pos = RayEnd; | 2028 | pos = RayEnd; |
1948 | } | 2029 | } |
1949 | |||
1950 | return pos; | ||
1951 | } | 2030 | } |
1952 | } | 2031 | } |
1953 | else | 2032 | else |
@@ -1958,8 +2037,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1958 | //increase height so its above the ground. | 2037 | //increase height so its above the ground. |
1959 | //should be getting the normal of the ground at the rez point and using that? | 2038 | //should be getting the normal of the ground at the rez point and using that? |
1960 | pos.Z += scale.Z / 2f; | 2039 | pos.Z += scale.Z / 2f; |
1961 | return pos; | 2040 | // return pos; |
1962 | } | 2041 | } |
2042 | |||
2043 | // check against posible water intercept | ||
2044 | if (wpos.Z > pos.Z) pos = wpos; | ||
2045 | return pos; | ||
1963 | } | 2046 | } |
1964 | 2047 | ||
1965 | 2048 | ||
@@ -2049,7 +2132,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2049 | public bool AddRestoredSceneObject( | 2132 | public bool AddRestoredSceneObject( |
2050 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 2133 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
2051 | { | 2134 | { |
2052 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 2135 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
2136 | if (result) | ||
2137 | sceneObject.IsDeleted = false; | ||
2138 | return result; | ||
2053 | } | 2139 | } |
2054 | 2140 | ||
2055 | /// <summary> | 2141 | /// <summary> |
@@ -2141,6 +2227,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2141 | /// </summary> | 2227 | /// </summary> |
2142 | public void DeleteAllSceneObjects() | 2228 | public void DeleteAllSceneObjects() |
2143 | { | 2229 | { |
2230 | DeleteAllSceneObjects(false); | ||
2231 | } | ||
2232 | |||
2233 | /// <summary> | ||
2234 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2235 | /// </summary> | ||
2236 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2237 | { | ||
2238 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2144 | lock (Entities) | 2239 | lock (Entities) |
2145 | { | 2240 | { |
2146 | EntityBase[] entities = Entities.GetEntities(); | 2241 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2149,11 +2244,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2149 | if (e is SceneObjectGroup) | 2244 | if (e is SceneObjectGroup) |
2150 | { | 2245 | { |
2151 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2246 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2152 | if (!sog.IsAttachment) | 2247 | if (sog != null && !sog.IsAttachment) |
2153 | DeleteSceneObject((SceneObjectGroup)e, false); | 2248 | { |
2249 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2250 | { | ||
2251 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2252 | } | ||
2253 | else | ||
2254 | { | ||
2255 | toReturn.Add((SceneObjectGroup)e); | ||
2256 | } | ||
2257 | } | ||
2154 | } | 2258 | } |
2155 | } | 2259 | } |
2156 | } | 2260 | } |
2261 | if (toReturn.Count > 0) | ||
2262 | { | ||
2263 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2264 | } | ||
2157 | } | 2265 | } |
2158 | 2266 | ||
2159 | /// <summary> | 2267 | /// <summary> |
@@ -2188,6 +2296,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2188 | } | 2296 | } |
2189 | 2297 | ||
2190 | group.DeleteGroupFromScene(silent); | 2298 | group.DeleteGroupFromScene(silent); |
2299 | if (!silent) | ||
2300 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2191 | 2301 | ||
2192 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2302 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2193 | } | 2303 | } |
@@ -2477,6 +2587,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2477 | 2587 | ||
2478 | if (newPosition != Vector3.Zero) | 2588 | if (newPosition != Vector3.Zero) |
2479 | newObject.RootPart.GroupPosition = newPosition; | 2589 | newObject.RootPart.GroupPosition = newPosition; |
2590 | if (newObject.RootPart.KeyframeMotion != null) | ||
2591 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2480 | 2592 | ||
2481 | if (!AddSceneObject(newObject)) | 2593 | if (!AddSceneObject(newObject)) |
2482 | { | 2594 | { |
@@ -2545,10 +2657,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2545 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2657 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2546 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2658 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2547 | { | 2659 | { |
2660 | if (sceneObject.OwnerID == UUID.Zero) | ||
2661 | { | ||
2662 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2663 | return false; | ||
2664 | } | ||
2665 | |||
2548 | // If the user is banned, we won't let any of their objects | 2666 | // If the user is banned, we won't let any of their objects |
2549 | // enter. Period. | 2667 | // enter. Period. |
2550 | // | 2668 | // |
2551 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2669 | int flags = GetUserFlags(sceneObject.OwnerID); |
2670 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2552 | { | 2671 | { |
2553 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2672 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2554 | 2673 | ||
@@ -2594,12 +2713,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2594 | } | 2713 | } |
2595 | else | 2714 | else |
2596 | { | 2715 | { |
2716 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2597 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2717 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2598 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2718 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2599 | } | 2719 | } |
2720 | if (sceneObject.OwnerID == UUID.Zero) | ||
2721 | { | ||
2722 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2723 | return false; | ||
2724 | } | ||
2600 | } | 2725 | } |
2601 | else | 2726 | else |
2602 | { | 2727 | { |
2728 | if (sceneObject.OwnerID == UUID.Zero) | ||
2729 | { | ||
2730 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2731 | return false; | ||
2732 | } | ||
2603 | AddRestoredSceneObject(sceneObject, true, false); | 2733 | AddRestoredSceneObject(sceneObject, true, false); |
2604 | 2734 | ||
2605 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2735 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2628,6 +2758,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2628 | return 2; // StateSource.PrimCrossing | 2758 | return 2; // StateSource.PrimCrossing |
2629 | } | 2759 | } |
2630 | 2760 | ||
2761 | public int GetUserFlags(UUID user) | ||
2762 | { | ||
2763 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2764 | /* | ||
2765 | ScenePresence sp; | ||
2766 | if (TryGetScenePresence(user, out sp)) | ||
2767 | { | ||
2768 | return sp.UserFlags; | ||
2769 | } | ||
2770 | else | ||
2771 | { | ||
2772 | */ | ||
2773 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2774 | if (uac == null) | ||
2775 | return 0; | ||
2776 | return uac.UserFlags; | ||
2777 | //} | ||
2778 | } | ||
2631 | #endregion | 2779 | #endregion |
2632 | 2780 | ||
2633 | #region Add/Remove Avatar Methods | 2781 | #region Add/Remove Avatar Methods |
@@ -2641,7 +2789,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2641 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2789 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2642 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2790 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2643 | 2791 | ||
2644 | // CheckHeartbeat(); | 2792 | CheckHeartbeat(); |
2645 | 2793 | ||
2646 | ScenePresence sp = GetScenePresence(client.AgentId); | 2794 | ScenePresence sp = GetScenePresence(client.AgentId); |
2647 | 2795 | ||
@@ -2695,7 +2843,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2695 | 2843 | ||
2696 | EventManager.TriggerOnNewClient(client); | 2844 | EventManager.TriggerOnNewClient(client); |
2697 | if (vialogin) | 2845 | if (vialogin) |
2846 | { | ||
2698 | EventManager.TriggerOnClientLogin(client); | 2847 | EventManager.TriggerOnClientLogin(client); |
2848 | // Send initial parcel data | ||
2849 | Vector3 pos = sp.AbsolutePosition; | ||
2850 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2851 | land.SendLandUpdateToClient(client); | ||
2852 | } | ||
2699 | 2853 | ||
2700 | return sp; | 2854 | return sp; |
2701 | } | 2855 | } |
@@ -2785,19 +2939,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2785 | // and the scene presence and the client, if they exist | 2939 | // and the scene presence and the client, if they exist |
2786 | try | 2940 | try |
2787 | { | 2941 | { |
2788 | // We need to wait for the client to make UDP contact first. | 2942 | ScenePresence sp = GetScenePresence(agentID); |
2789 | // It's the UDP contact that creates the scene presence | 2943 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2790 | ScenePresence sp = WaitGetScenePresence(agentID); | 2944 | |
2791 | if (sp != null) | 2945 | if (sp != null) |
2792 | { | ||
2793 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2794 | |||
2795 | sp.ControllingClient.Close(); | 2946 | sp.ControllingClient.Close(); |
2796 | } | 2947 | |
2797 | else | ||
2798 | { | ||
2799 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2800 | } | ||
2801 | // BANG! SLASH! | 2948 | // BANG! SLASH! |
2802 | m_authenticateHandler.RemoveCircuit(agentID); | 2949 | m_authenticateHandler.RemoveCircuit(agentID); |
2803 | 2950 | ||
@@ -2842,6 +2989,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2842 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 2989 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2843 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 2990 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2844 | 2991 | ||
2992 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
2993 | |||
2845 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2994 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2846 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2995 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2847 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 2996 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2898,6 +3047,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2898 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3047 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2899 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3048 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2900 | client.OnCopyInventoryItem += CopyInventoryItem; | 3049 | client.OnCopyInventoryItem += CopyInventoryItem; |
3050 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2901 | client.OnMoveInventoryItem += MoveInventoryItem; | 3051 | client.OnMoveInventoryItem += MoveInventoryItem; |
2902 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3052 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2903 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3053 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2969,6 +3119,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2969 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3119 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
2970 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3120 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
2971 | 3121 | ||
3122 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3123 | |||
2972 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3124 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2973 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3125 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2974 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3126 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3071,7 +3223,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3071 | /// </summary> | 3223 | /// </summary> |
3072 | /// <param name="agentId">The avatar's Unique ID</param> | 3224 | /// <param name="agentId">The avatar's Unique ID</param> |
3073 | /// <param name="client">The IClientAPI for the client</param> | 3225 | /// <param name="client">The IClientAPI for the client</param> |
3074 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3226 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3075 | { | 3227 | { |
3076 | if (EntityTransferModule != null) | 3228 | if (EntityTransferModule != null) |
3077 | { | 3229 | { |
@@ -3082,6 +3234,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3082 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3234 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3083 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3235 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3084 | } | 3236 | } |
3237 | return false; | ||
3085 | } | 3238 | } |
3086 | 3239 | ||
3087 | /// <summary> | 3240 | /// <summary> |
@@ -3191,6 +3344,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3191 | /// <param name="flags"></param> | 3344 | /// <param name="flags"></param> |
3192 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3345 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3193 | { | 3346 | { |
3347 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3348 | ScenePresence presence; | ||
3349 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3350 | { | ||
3351 | if (presence.Appearance != null) | ||
3352 | { | ||
3353 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3354 | } | ||
3355 | } | ||
3356 | |||
3194 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3357 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3195 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3358 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3196 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3359 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3259,8 +3422,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3259 | regions.Remove(RegionInfo.RegionHandle); | 3422 | regions.Remove(RegionInfo.RegionHandle); |
3260 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3423 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3261 | } | 3424 | } |
3262 | 3425 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3263 | m_eventManager.TriggerClientClosed(agentID, this); | 3426 | m_eventManager.TriggerClientClosed(agentID, this); |
3427 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3264 | } | 3428 | } |
3265 | catch (NullReferenceException) | 3429 | catch (NullReferenceException) |
3266 | { | 3430 | { |
@@ -3322,9 +3486,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3322 | { | 3486 | { |
3323 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); | 3487 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); |
3324 | } | 3488 | } |
3325 | 3489 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3326 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3490 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3327 | // CleanDroppedAttachments(); | 3491 | // CleanDroppedAttachments(); |
3492 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3328 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3493 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3329 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3494 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3330 | } | 3495 | } |
@@ -3459,13 +3624,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3459 | sp = null; | 3624 | sp = null; |
3460 | } | 3625 | } |
3461 | 3626 | ||
3462 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3463 | 3627 | ||
3464 | //On login test land permisions | 3628 | //On login test land permisions |
3465 | if (vialogin) | 3629 | if (vialogin) |
3466 | { | 3630 | { |
3467 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3631 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3632 | if (cache != null) | ||
3633 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3634 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3468 | { | 3635 | { |
3636 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3469 | return false; | 3637 | return false; |
3470 | } | 3638 | } |
3471 | } | 3639 | } |
@@ -3488,9 +3656,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3488 | 3656 | ||
3489 | try | 3657 | try |
3490 | { | 3658 | { |
3491 | if (!AuthorizeUser(agent, out reason)) | 3659 | // Always check estate if this is a login. Always |
3492 | return false; | 3660 | // check if banned regions are to be blacked out. |
3493 | } catch (Exception e) | 3661 | if (vialogin || (!m_seeIntoBannedRegion)) |
3662 | { | ||
3663 | if (!AuthorizeUser(agent, out reason)) | ||
3664 | return false; | ||
3665 | } | ||
3666 | } | ||
3667 | catch (Exception e) | ||
3494 | { | 3668 | { |
3495 | m_log.ErrorFormat( | 3669 | m_log.ErrorFormat( |
3496 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); | 3670 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); |
@@ -3621,6 +3795,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3621 | } | 3795 | } |
3622 | 3796 | ||
3623 | // Honor parcel landing type and position. | 3797 | // Honor parcel landing type and position. |
3798 | /* | ||
3799 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3624 | if (land != null) | 3800 | if (land != null) |
3625 | { | 3801 | { |
3626 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3802 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3628,25 +3804,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3628 | agent.startpos = land.LandData.UserLocation; | 3804 | agent.startpos = land.LandData.UserLocation; |
3629 | } | 3805 | } |
3630 | } | 3806 | } |
3807 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3631 | } | 3808 | } |
3632 | 3809 | ||
3633 | return true; | 3810 | return true; |
3634 | } | 3811 | } |
3635 | 3812 | ||
3636 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3813 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3637 | { | 3814 | { |
3638 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3815 | reason = String.Empty; |
3639 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3816 | if (Permissions.IsGod(agentID)) |
3817 | return true; | ||
3818 | |||
3819 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3820 | if (land == null) | ||
3821 | return false; | ||
3822 | |||
3823 | bool banned = land.IsBannedFromLand(agentID); | ||
3824 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3640 | 3825 | ||
3641 | if (banned || restricted) | 3826 | if (banned || restricted) |
3642 | { | 3827 | { |
3643 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3828 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3644 | if (nearestParcel != null) | 3829 | if (nearestParcel != null) |
3645 | { | 3830 | { |
3646 | //Move agent to nearest allowed | 3831 | //Move agent to nearest allowed |
3647 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3832 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3648 | agent.startpos.X = newPosition.X; | 3833 | posX = newPosition.X; |
3649 | agent.startpos.Y = newPosition.Y; | 3834 | posY = newPosition.Y; |
3650 | } | 3835 | } |
3651 | else | 3836 | else |
3652 | { | 3837 | { |
@@ -3708,7 +3893,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3708 | 3893 | ||
3709 | if (!m_strictAccessControl) return true; | 3894 | if (!m_strictAccessControl) return true; |
3710 | if (Permissions.IsGod(agent.AgentID)) return true; | 3895 | if (Permissions.IsGod(agent.AgentID)) return true; |
3711 | 3896 | ||
3712 | if (AuthorizationService != null) | 3897 | if (AuthorizationService != null) |
3713 | { | 3898 | { |
3714 | if (!AuthorizationService.IsAuthorizedForRegion( | 3899 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3723,7 +3908,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3723 | 3908 | ||
3724 | if (m_regInfo.EstateSettings != null) | 3909 | if (m_regInfo.EstateSettings != null) |
3725 | { | 3910 | { |
3726 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3911 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3727 | { | 3912 | { |
3728 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3913 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3729 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3914 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3913,6 +4098,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3913 | 4098 | ||
3914 | // XPTO: if this agent is not allowed here as root, always return false | 4099 | // XPTO: if this agent is not allowed here as root, always return false |
3915 | 4100 | ||
4101 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4102 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4103 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4104 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4105 | { | ||
4106 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4107 | return false; | ||
4108 | } | ||
4109 | |||
3916 | // TODO: This check should probably be in QueryAccess(). | 4110 | // TODO: This check should probably be in QueryAccess(). |
3917 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4111 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3918 | if (nearestParcel == null) | 4112 | if (nearestParcel == null) |
@@ -4006,12 +4200,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
4006 | return false; | 4200 | return false; |
4007 | } | 4201 | } |
4008 | 4202 | ||
4203 | public bool IncomingCloseAgent(UUID agentID) | ||
4204 | { | ||
4205 | return IncomingCloseAgent(agentID, false); | ||
4206 | } | ||
4207 | |||
4208 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4209 | { | ||
4210 | return IncomingCloseAgent(agentID, true); | ||
4211 | } | ||
4212 | |||
4009 | /// <summary> | 4213 | /// <summary> |
4010 | /// Tell a single agent to disconnect from the region. | 4214 | /// Tell a single agent to disconnect from the region. |
4011 | /// </summary> | 4215 | /// </summary> |
4012 | /// <param name="regionHandle"></param> | ||
4013 | /// <param name="agentID"></param> | 4216 | /// <param name="agentID"></param> |
4014 | public bool IncomingCloseAgent(UUID agentID) | 4217 | /// <param name="childOnly"></param> |
4218 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
4015 | { | 4219 | { |
4016 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4220 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
4017 | 4221 | ||
@@ -4023,7 +4227,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4023 | { | 4227 | { |
4024 | m_sceneGraph.removeUserCount(false); | 4228 | m_sceneGraph.removeUserCount(false); |
4025 | } | 4229 | } |
4026 | else | 4230 | else if (!childOnly) |
4027 | { | 4231 | { |
4028 | m_sceneGraph.removeUserCount(true); | 4232 | m_sceneGraph.removeUserCount(true); |
4029 | } | 4233 | } |
@@ -4039,9 +4243,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4039 | } | 4243 | } |
4040 | else | 4244 | else |
4041 | presence.ControllingClient.SendShutdownConnectionNotice(); | 4245 | presence.ControllingClient.SendShutdownConnectionNotice(); |
4246 | presence.ControllingClient.Close(false); | ||
4247 | } | ||
4248 | else if (!childOnly) | ||
4249 | { | ||
4250 | presence.ControllingClient.Close(true); | ||
4042 | } | 4251 | } |
4043 | |||
4044 | presence.ControllingClient.Close(); | ||
4045 | return true; | 4252 | return true; |
4046 | } | 4253 | } |
4047 | 4254 | ||
@@ -4627,35 +4834,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4627 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4834 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4628 | } | 4835 | } |
4629 | 4836 | ||
4630 | public int GetHealth() | 4837 | public int GetHealth(out int flags, out string message) |
4631 | { | 4838 | { |
4632 | // Returns: | 4839 | // Returns: |
4633 | // 1 = sim is up and accepting http requests. The heartbeat has | 4840 | // 1 = sim is up and accepting http requests. The heartbeat has |
4634 | // stopped and the sim is probably locked up, but a remote | 4841 | // stopped and the sim is probably locked up, but a remote |
4635 | // admin restart may succeed | 4842 | // admin restart may succeed |
4636 | // | 4843 | // |
4637 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4844 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4638 | // usable for people within and logins _may_ work | 4845 | // usable for people within |
4639 | // | 4846 | // |
4640 | // 3 = We have seen a new user enter within the past 4 minutes | 4847 | // 3 = Sim is up and one packet thread is running. Sim is |
4848 | // unstable and will not accept new logins | ||
4849 | // | ||
4850 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4851 | // likely usable | ||
4852 | // | ||
4853 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4641 | // which can be seen as positive confirmation of sim health | 4854 | // which can be seen as positive confirmation of sim health |
4642 | // | 4855 | // |
4856 | |||
4857 | flags = 0; | ||
4858 | message = String.Empty; | ||
4859 | |||
4860 | CheckHeartbeat(); | ||
4861 | |||
4862 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4863 | { | ||
4864 | // We're still starting | ||
4865 | // 0 means "in startup", it can't happen another way, since | ||
4866 | // to get here, we must be able to accept http connections | ||
4867 | return 0; | ||
4868 | } | ||
4869 | |||
4643 | int health=1; // Start at 1, means we're up | 4870 | int health=1; // Start at 1, means we're up |
4644 | 4871 | ||
4645 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 4872 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4646 | health += 1; | 4873 | { |
4874 | health+=1; | ||
4875 | flags |= 1; | ||
4876 | } | ||
4877 | |||
4878 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4879 | { | ||
4880 | health+=1; | ||
4881 | flags |= 2; | ||
4882 | } | ||
4883 | |||
4884 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4885 | { | ||
4886 | health+=1; | ||
4887 | flags |= 4; | ||
4888 | } | ||
4647 | else | 4889 | else |
4890 | { | ||
4891 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4892 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4893 | proc.EnableRaisingEvents=false; | ||
4894 | proc.StartInfo.FileName = "/bin/kill"; | ||
4895 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4896 | proc.Start(); | ||
4897 | proc.WaitForExit(); | ||
4898 | Thread.Sleep(1000); | ||
4899 | Environment.Exit(1); | ||
4900 | } | ||
4901 | |||
4902 | if (flags != 7) | ||
4648 | return health; | 4903 | return health; |
4649 | 4904 | ||
4650 | // A login in the last 4 mins? We can't be doing too badly | 4905 | // A login in the last 4 mins? We can't be doing too badly |
4651 | // | 4906 | // |
4652 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4907 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4653 | health++; | 4908 | health++; |
4654 | else | 4909 | else |
4655 | return health; | 4910 | return health; |
4656 | 4911 | ||
4657 | // CheckHeartbeat(); | ||
4658 | |||
4659 | return health; | 4912 | return health; |
4660 | } | 4913 | } |
4661 | 4914 | ||
@@ -4743,7 +4996,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4743 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 4996 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4744 | if (wasUsingPhysics) | 4997 | if (wasUsingPhysics) |
4745 | { | 4998 | { |
4746 | 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 | 4999 | 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 |
4747 | } | 5000 | } |
4748 | } | 5001 | } |
4749 | 5002 | ||
@@ -4842,14 +5095,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4842 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5095 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
4843 | } | 5096 | } |
4844 | 5097 | ||
4845 | // private void CheckHeartbeat() | 5098 | private void CheckHeartbeat() |
4846 | // { | 5099 | { |
4847 | // if (m_firstHeartbeat) | 5100 | if (m_firstHeartbeat) |
4848 | // return; | 5101 | return; |
4849 | // | 5102 | |
4850 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5103 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
4851 | // StartTimer(); | 5104 | Start(); |
4852 | // } | 5105 | } |
4853 | 5106 | ||
4854 | public override ISceneObject DeserializeObject(string representation) | 5107 | public override ISceneObject DeserializeObject(string representation) |
4855 | { | 5108 | { |
@@ -4861,9 +5114,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4861 | get { return m_allowScriptCrossings; } | 5114 | get { return m_allowScriptCrossings; } |
4862 | } | 5115 | } |
4863 | 5116 | ||
4864 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5117 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
5118 | { | ||
5119 | return GetNearestAllowedPosition(avatar, null); | ||
5120 | } | ||
5121 | |||
5122 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
4865 | { | 5123 | { |
4866 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5124 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); |
4867 | 5125 | ||
4868 | if (nearestParcel != null) | 5126 | if (nearestParcel != null) |
4869 | { | 5127 | { |
@@ -4872,10 +5130,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4872 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5130 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4873 | if (nearestPoint != null) | 5131 | if (nearestPoint != null) |
4874 | { | 5132 | { |
4875 | // m_log.DebugFormat( | 5133 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
4876 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
4877 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
4878 | |||
4879 | return nearestPoint.Value; | 5134 | return nearestPoint.Value; |
4880 | } | 5135 | } |
4881 | 5136 | ||
@@ -4885,17 +5140,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4885 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5140 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4886 | if (nearestPoint != null) | 5141 | if (nearestPoint != null) |
4887 | { | 5142 | { |
4888 | // m_log.DebugFormat( | 5143 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
4889 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
4890 | |||
4891 | return nearestPoint.Value; | 5144 | return nearestPoint.Value; |
4892 | } | 5145 | } |
4893 | 5146 | ||
4894 | //Ultimate backup if we have no idea where they are | 5147 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
4895 | // m_log.DebugFormat( | 5148 | if (dest != excludeParcel) |
4896 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5149 | { |
5150 | // Ultimate backup if we have no idea where they are and | ||
5151 | // the last allowed position was in another parcel | ||
5152 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5153 | return avatar.lastKnownAllowedPosition; | ||
5154 | } | ||
4897 | 5155 | ||
4898 | return avatar.lastKnownAllowedPosition; | 5156 | // else fall through to region edge |
4899 | } | 5157 | } |
4900 | 5158 | ||
4901 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5159 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -4929,13 +5187,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4929 | 5187 | ||
4930 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5188 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
4931 | { | 5189 | { |
5190 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5191 | } | ||
5192 | |||
5193 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5194 | { | ||
4932 | List<ILandObject> all = AllParcels(); | 5195 | List<ILandObject> all = AllParcels(); |
4933 | float minParcelDistance = float.MaxValue; | 5196 | float minParcelDistance = float.MaxValue; |
4934 | ILandObject nearestParcel = null; | 5197 | ILandObject nearestParcel = null; |
4935 | 5198 | ||
4936 | foreach (var parcel in all) | 5199 | foreach (var parcel in all) |
4937 | { | 5200 | { |
4938 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5201 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
4939 | { | 5202 | { |
4940 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5203 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
4941 | if (parcelDistance < minParcelDistance) | 5204 | if (parcelDistance < minParcelDistance) |
@@ -5177,7 +5440,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5177 | mapModule.GenerateMaptile(); | 5440 | mapModule.GenerateMaptile(); |
5178 | } | 5441 | } |
5179 | 5442 | ||
5180 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5443 | // public void CleanDroppedAttachments() |
5444 | // { | ||
5445 | // List<SceneObjectGroup> objectsToDelete = | ||
5446 | // new List<SceneObjectGroup>(); | ||
5447 | // | ||
5448 | // lock (m_cleaningAttachments) | ||
5449 | // { | ||
5450 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5451 | // { | ||
5452 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5453 | // { | ||
5454 | // UUID agentID = grp.OwnerID; | ||
5455 | // if (agentID == UUID.Zero) | ||
5456 | // { | ||
5457 | // objectsToDelete.Add(grp); | ||
5458 | // return; | ||
5459 | // } | ||
5460 | // | ||
5461 | // ScenePresence sp = GetScenePresence(agentID); | ||
5462 | // if (sp == null) | ||
5463 | // { | ||
5464 | // objectsToDelete.Add(grp); | ||
5465 | // return; | ||
5466 | // } | ||
5467 | // } | ||
5468 | // }); | ||
5469 | // } | ||
5470 | // | ||
5471 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5472 | // { | ||
5473 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5474 | // DeleteSceneObject(grp, true); | ||
5475 | // } | ||
5476 | // } | ||
5477 | |||
5478 | public void ThreadAlive(int threadCode) | ||
5479 | { | ||
5480 | switch(threadCode) | ||
5481 | { | ||
5482 | case 1: // Incoming | ||
5483 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5484 | break; | ||
5485 | case 2: // Incoming | ||
5486 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5487 | break; | ||
5488 | } | ||
5489 | } | ||
5490 | |||
5491 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5181 | { | 5492 | { |
5182 | RegenerateMaptile(); | 5493 | RegenerateMaptile(); |
5183 | 5494 | ||
@@ -5205,6 +5516,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5205 | /// <returns></returns> | 5516 | /// <returns></returns> |
5206 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5517 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5207 | { | 5518 | { |
5519 | reason = "You are banned from the region"; | ||
5520 | |||
5208 | if (EntityTransferModule.IsInTransit(agentID)) | 5521 | if (EntityTransferModule.IsInTransit(agentID)) |
5209 | { | 5522 | { |
5210 | reason = "Agent is still in transit from this region"; | 5523 | reason = "Agent is still in transit from this region"; |
@@ -5216,6 +5529,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5216 | return false; | 5529 | return false; |
5217 | } | 5530 | } |
5218 | 5531 | ||
5532 | if (Permissions.IsGod(agentID)) | ||
5533 | { | ||
5534 | reason = String.Empty; | ||
5535 | return true; | ||
5536 | } | ||
5537 | |||
5219 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 5538 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5220 | // However, the long term fix is to make sure root agent count is always accurate. | 5539 | // However, the long term fix is to make sure root agent count is always accurate. |
5221 | m_sceneGraph.RecalculateStats(); | 5540 | m_sceneGraph.RecalculateStats(); |
@@ -5236,6 +5555,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5236 | } | 5555 | } |
5237 | } | 5556 | } |
5238 | 5557 | ||
5558 | ScenePresence presence = GetScenePresence(agentID); | ||
5559 | IClientAPI client = null; | ||
5560 | AgentCircuitData aCircuit = null; | ||
5561 | |||
5562 | if (presence != null) | ||
5563 | { | ||
5564 | client = presence.ControllingClient; | ||
5565 | if (client != null) | ||
5566 | aCircuit = client.RequestClientInfo(); | ||
5567 | } | ||
5568 | |||
5569 | // We may be called before there is a presence or a client. | ||
5570 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5571 | if (client == null) | ||
5572 | { | ||
5573 | aCircuit = new AgentCircuitData(); | ||
5574 | aCircuit.AgentID = agentID; | ||
5575 | aCircuit.firstname = String.Empty; | ||
5576 | aCircuit.lastname = String.Empty; | ||
5577 | } | ||
5578 | |||
5579 | try | ||
5580 | { | ||
5581 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5582 | { | ||
5583 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5584 | return false; | ||
5585 | } | ||
5586 | } | ||
5587 | catch (Exception e) | ||
5588 | { | ||
5589 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5590 | return false; | ||
5591 | } | ||
5592 | |||
5239 | if (position == Vector3.Zero) // Teleport | 5593 | if (position == Vector3.Zero) // Teleport |
5240 | { | 5594 | { |
5241 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5595 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5264,13 +5618,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5264 | } | 5618 | } |
5265 | } | 5619 | } |
5266 | } | 5620 | } |
5621 | |||
5622 | float posX = 128.0f; | ||
5623 | float posY = 128.0f; | ||
5624 | |||
5625 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5626 | { | ||
5627 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5628 | return false; | ||
5629 | } | ||
5630 | } | ||
5631 | else // Walking | ||
5632 | { | ||
5633 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5634 | if (land == null) | ||
5635 | return false; | ||
5636 | |||
5637 | bool banned = land.IsBannedFromLand(agentID); | ||
5638 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5639 | |||
5640 | if (banned || restricted) | ||
5641 | return false; | ||
5267 | } | 5642 | } |
5268 | 5643 | ||
5269 | reason = String.Empty; | 5644 | reason = String.Empty; |
5270 | return true; | 5645 | return true; |
5271 | } | 5646 | } |
5272 | 5647 | ||
5273 | /// <summary> | 5648 | public void StartTimerWatchdog() |
5649 | { | ||
5650 | m_timerWatchdog.Interval = 1000; | ||
5651 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5652 | m_timerWatchdog.AutoReset = true; | ||
5653 | m_timerWatchdog.Start(); | ||
5654 | } | ||
5655 | |||
5656 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5657 | { | ||
5658 | CheckHeartbeat(); | ||
5659 | } | ||
5660 | |||
5274 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5661 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5275 | /// autopilot that moves an avatar to a sit target!. | 5662 | /// autopilot that moves an avatar to a sit target!. |
5276 | /// </summary> | 5663 | /// </summary> |