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 ce386be..32c7262 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) |
@@ -1469,7 +1519,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1469 | 1519 | ||
1470 | // frameMS currently records work frame times, not total frame times (work + any required sleep to | 1520 | // frameMS currently records work frame times, not total frame times (work + any required sleep to |
1471 | // reach min frame time. | 1521 | // reach min frame time. |
1472 | StatsReporter.addFrameMS(frameMS); | 1522 | // StatsReporter.addFrameMS(frameMS); |
1473 | 1523 | ||
1474 | StatsReporter.addAgentMS(agentMS); | 1524 | StatsReporter.addAgentMS(agentMS); |
1475 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | 1525 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); |
@@ -1526,12 +1576,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1526 | 1576 | ||
1527 | previousFrameTick = m_lastFrameTick; | 1577 | previousFrameTick = m_lastFrameTick; |
1528 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1578 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1529 | maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1579 | maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); |
1530 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1580 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1531 | 1581 | ||
1582 | m_firstHeartbeat = false; | ||
1583 | |||
1584 | |||
1585 | sleepMS = Util.EnvironmentTickCount(); | ||
1586 | |||
1532 | if (maintc > 0) | 1587 | if (maintc > 0) |
1533 | Thread.Sleep(maintc); | 1588 | Thread.Sleep(maintc); |
1534 | 1589 | ||
1590 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); | ||
1591 | frameMS = Util.EnvironmentTickCountSubtract(framestart); | ||
1592 | StatsReporter.addSleepMS(sleepMS); | ||
1593 | StatsReporter.addFrameMS(frameMS); | ||
1594 | |||
1535 | // Optionally warn if a frame takes double the amount of time that it should. | 1595 | // Optionally warn if a frame takes double the amount of time that it should. |
1536 | if (DebugUpdates | 1596 | if (DebugUpdates |
1537 | && Util.EnvironmentTickCountSubtract( | 1597 | && Util.EnvironmentTickCountSubtract( |
@@ -1558,9 +1618,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1558 | 1618 | ||
1559 | private void CheckAtTargets() | 1619 | private void CheckAtTargets() |
1560 | { | 1620 | { |
1561 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1621 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1562 | lock (m_groupsWithTargets) | 1622 | lock (m_groupsWithTargets) |
1563 | objs = m_groupsWithTargets.Values; | 1623 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1564 | 1624 | ||
1565 | foreach (SceneObjectGroup entry in objs) | 1625 | foreach (SceneObjectGroup entry in objs) |
1566 | entry.checkAtTargets(); | 1626 | entry.checkAtTargets(); |
@@ -1641,7 +1701,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1641 | msg.fromAgentName = "Server"; | 1701 | msg.fromAgentName = "Server"; |
1642 | msg.dialog = (byte)19; // Object msg | 1702 | msg.dialog = (byte)19; // Object msg |
1643 | msg.fromGroup = false; | 1703 | msg.fromGroup = false; |
1644 | msg.offline = (byte)0; | 1704 | msg.offline = (byte)1; |
1645 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1705 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1646 | msg.Position = Vector3.Zero; | 1706 | msg.Position = Vector3.Zero; |
1647 | msg.RegionID = RegionInfo.RegionID.Guid; | 1707 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1863,6 +1923,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1863 | EventManager.TriggerPrimsLoaded(this); | 1923 | EventManager.TriggerPrimsLoaded(this); |
1864 | } | 1924 | } |
1865 | 1925 | ||
1926 | public bool SuportsRayCastFiltered() | ||
1927 | { | ||
1928 | if (PhysicsScene == null) | ||
1929 | return false; | ||
1930 | return PhysicsScene.SuportsRaycastWorldFiltered(); | ||
1931 | } | ||
1932 | |||
1933 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | ||
1934 | { | ||
1935 | if (PhysicsScene == null) | ||
1936 | return null; | ||
1937 | return PhysicsScene.RaycastWorld(position, direction, length, Count,filter); | ||
1938 | } | ||
1866 | 1939 | ||
1867 | /// <summary> | 1940 | /// <summary> |
1868 | /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. | 1941 | /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. |
@@ -1879,14 +1952,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1879 | /// <returns></returns> | 1952 | /// <returns></returns> |
1880 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1953 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1881 | { | 1954 | { |
1955 | |||
1956 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1957 | Vector3 wpos = Vector3.Zero; | ||
1958 | // Check for water surface intersection from above | ||
1959 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1960 | { | ||
1961 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1962 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1963 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1964 | wpos.Z = wheight; | ||
1965 | } | ||
1966 | |||
1882 | Vector3 pos = Vector3.Zero; | 1967 | Vector3 pos = Vector3.Zero; |
1883 | if (RayEndIsIntersection == (byte)1) | 1968 | if (RayEndIsIntersection == (byte)1) |
1884 | { | 1969 | { |
1885 | pos = RayEnd; | 1970 | pos = RayEnd; |
1886 | return pos; | ||
1887 | } | 1971 | } |
1888 | 1972 | else if (RayTargetID != UUID.Zero) | |
1889 | if (RayTargetID != UUID.Zero) | ||
1890 | { | 1973 | { |
1891 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1974 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1892 | 1975 | ||
@@ -1908,7 +1991,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1908 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1991 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1909 | 1992 | ||
1910 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1993 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1911 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1994 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1912 | float ScaleOffset = 0.5f; | 1995 | float ScaleOffset = 0.5f; |
1913 | 1996 | ||
1914 | // If we hit something | 1997 | // If we hit something |
@@ -1931,13 +2014,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1931 | //pos.Z -= 0.25F; | 2014 | //pos.Z -= 0.25F; |
1932 | 2015 | ||
1933 | } | 2016 | } |
1934 | |||
1935 | return pos; | ||
1936 | } | 2017 | } |
1937 | else | 2018 | else |
1938 | { | 2019 | { |
1939 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2020 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1940 | |||
1941 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2021 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1942 | 2022 | ||
1943 | // Un-comment the following line to print the raytrace results to the console. | 2023 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1946,13 +2026,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1946 | if (ei.HitTF) | 2026 | if (ei.HitTF) |
1947 | { | 2027 | { |
1948 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2028 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1949 | } else | 2029 | } |
2030 | else | ||
1950 | { | 2031 | { |
1951 | // fall back to our stupid functionality | 2032 | // fall back to our stupid functionality |
1952 | pos = RayEnd; | 2033 | pos = RayEnd; |
1953 | } | 2034 | } |
1954 | |||
1955 | return pos; | ||
1956 | } | 2035 | } |
1957 | } | 2036 | } |
1958 | else | 2037 | else |
@@ -1963,8 +2042,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1963 | //increase height so its above the ground. | 2042 | //increase height so its above the ground. |
1964 | //should be getting the normal of the ground at the rez point and using that? | 2043 | //should be getting the normal of the ground at the rez point and using that? |
1965 | pos.Z += scale.Z / 2f; | 2044 | pos.Z += scale.Z / 2f; |
1966 | return pos; | 2045 | // return pos; |
1967 | } | 2046 | } |
2047 | |||
2048 | // check against posible water intercept | ||
2049 | if (wpos.Z > pos.Z) pos = wpos; | ||
2050 | return pos; | ||
1968 | } | 2051 | } |
1969 | 2052 | ||
1970 | 2053 | ||
@@ -2054,7 +2137,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2054 | public bool AddRestoredSceneObject( | 2137 | public bool AddRestoredSceneObject( |
2055 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 2138 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
2056 | { | 2139 | { |
2057 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 2140 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
2141 | if (result) | ||
2142 | sceneObject.IsDeleted = false; | ||
2143 | return result; | ||
2058 | } | 2144 | } |
2059 | 2145 | ||
2060 | /// <summary> | 2146 | /// <summary> |
@@ -2146,6 +2232,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2146 | /// </summary> | 2232 | /// </summary> |
2147 | public void DeleteAllSceneObjects() | 2233 | public void DeleteAllSceneObjects() |
2148 | { | 2234 | { |
2235 | DeleteAllSceneObjects(false); | ||
2236 | } | ||
2237 | |||
2238 | /// <summary> | ||
2239 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2240 | /// </summary> | ||
2241 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2242 | { | ||
2243 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2149 | lock (Entities) | 2244 | lock (Entities) |
2150 | { | 2245 | { |
2151 | EntityBase[] entities = Entities.GetEntities(); | 2246 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2154,11 +2249,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2154 | if (e is SceneObjectGroup) | 2249 | if (e is SceneObjectGroup) |
2155 | { | 2250 | { |
2156 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2251 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2157 | if (!sog.IsAttachment) | 2252 | if (sog != null && !sog.IsAttachment) |
2158 | DeleteSceneObject((SceneObjectGroup)e, false); | 2253 | { |
2254 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2255 | { | ||
2256 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2257 | } | ||
2258 | else | ||
2259 | { | ||
2260 | toReturn.Add((SceneObjectGroup)e); | ||
2261 | } | ||
2262 | } | ||
2159 | } | 2263 | } |
2160 | } | 2264 | } |
2161 | } | 2265 | } |
2266 | if (toReturn.Count > 0) | ||
2267 | { | ||
2268 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2269 | } | ||
2162 | } | 2270 | } |
2163 | 2271 | ||
2164 | /// <summary> | 2272 | /// <summary> |
@@ -2193,6 +2301,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2193 | } | 2301 | } |
2194 | 2302 | ||
2195 | group.DeleteGroupFromScene(silent); | 2303 | group.DeleteGroupFromScene(silent); |
2304 | if (!silent) | ||
2305 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2196 | 2306 | ||
2197 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2307 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2198 | } | 2308 | } |
@@ -2482,6 +2592,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2482 | 2592 | ||
2483 | if (newPosition != Vector3.Zero) | 2593 | if (newPosition != Vector3.Zero) |
2484 | newObject.RootPart.GroupPosition = newPosition; | 2594 | newObject.RootPart.GroupPosition = newPosition; |
2595 | if (newObject.RootPart.KeyframeMotion != null) | ||
2596 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2485 | 2597 | ||
2486 | if (!AddSceneObject(newObject)) | 2598 | if (!AddSceneObject(newObject)) |
2487 | { | 2599 | { |
@@ -2550,10 +2662,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2550 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2662 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2551 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2663 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2552 | { | 2664 | { |
2665 | if (sceneObject.OwnerID == UUID.Zero) | ||
2666 | { | ||
2667 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2668 | return false; | ||
2669 | } | ||
2670 | |||
2553 | // If the user is banned, we won't let any of their objects | 2671 | // If the user is banned, we won't let any of their objects |
2554 | // enter. Period. | 2672 | // enter. Period. |
2555 | // | 2673 | // |
2556 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2674 | int flags = GetUserFlags(sceneObject.OwnerID); |
2675 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2557 | { | 2676 | { |
2558 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2677 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2559 | 2678 | ||
@@ -2599,12 +2718,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2599 | } | 2718 | } |
2600 | else | 2719 | else |
2601 | { | 2720 | { |
2721 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2602 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2722 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2603 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2723 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2604 | } | 2724 | } |
2725 | if (sceneObject.OwnerID == UUID.Zero) | ||
2726 | { | ||
2727 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2728 | return false; | ||
2729 | } | ||
2605 | } | 2730 | } |
2606 | else | 2731 | else |
2607 | { | 2732 | { |
2733 | if (sceneObject.OwnerID == UUID.Zero) | ||
2734 | { | ||
2735 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2736 | return false; | ||
2737 | } | ||
2608 | AddRestoredSceneObject(sceneObject, true, false); | 2738 | AddRestoredSceneObject(sceneObject, true, false); |
2609 | 2739 | ||
2610 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2740 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2633,6 +2763,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2633 | return 2; // StateSource.PrimCrossing | 2763 | return 2; // StateSource.PrimCrossing |
2634 | } | 2764 | } |
2635 | 2765 | ||
2766 | public int GetUserFlags(UUID user) | ||
2767 | { | ||
2768 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2769 | /* | ||
2770 | ScenePresence sp; | ||
2771 | if (TryGetScenePresence(user, out sp)) | ||
2772 | { | ||
2773 | return sp.UserFlags; | ||
2774 | } | ||
2775 | else | ||
2776 | { | ||
2777 | */ | ||
2778 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2779 | if (uac == null) | ||
2780 | return 0; | ||
2781 | return uac.UserFlags; | ||
2782 | //} | ||
2783 | } | ||
2636 | #endregion | 2784 | #endregion |
2637 | 2785 | ||
2638 | #region Add/Remove Avatar Methods | 2786 | #region Add/Remove Avatar Methods |
@@ -2646,7 +2794,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2646 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2794 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2647 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2795 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2648 | 2796 | ||
2649 | // CheckHeartbeat(); | 2797 | CheckHeartbeat(); |
2650 | 2798 | ||
2651 | ScenePresence sp = GetScenePresence(client.AgentId); | 2799 | ScenePresence sp = GetScenePresence(client.AgentId); |
2652 | 2800 | ||
@@ -2700,7 +2848,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2700 | 2848 | ||
2701 | EventManager.TriggerOnNewClient(client); | 2849 | EventManager.TriggerOnNewClient(client); |
2702 | if (vialogin) | 2850 | if (vialogin) |
2851 | { | ||
2703 | EventManager.TriggerOnClientLogin(client); | 2852 | EventManager.TriggerOnClientLogin(client); |
2853 | // Send initial parcel data | ||
2854 | Vector3 pos = sp.AbsolutePosition; | ||
2855 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2856 | land.SendLandUpdateToClient(client); | ||
2857 | } | ||
2704 | 2858 | ||
2705 | return sp; | 2859 | return sp; |
2706 | } | 2860 | } |
@@ -2790,19 +2944,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2790 | // and the scene presence and the client, if they exist | 2944 | // and the scene presence and the client, if they exist |
2791 | try | 2945 | try |
2792 | { | 2946 | { |
2793 | // We need to wait for the client to make UDP contact first. | 2947 | ScenePresence sp = GetScenePresence(agentID); |
2794 | // It's the UDP contact that creates the scene presence | 2948 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2795 | ScenePresence sp = WaitGetScenePresence(agentID); | 2949 | |
2796 | if (sp != null) | 2950 | if (sp != null) |
2797 | { | ||
2798 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2799 | |||
2800 | sp.ControllingClient.Close(); | 2951 | sp.ControllingClient.Close(); |
2801 | } | 2952 | |
2802 | else | ||
2803 | { | ||
2804 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2805 | } | ||
2806 | // BANG! SLASH! | 2953 | // BANG! SLASH! |
2807 | m_authenticateHandler.RemoveCircuit(agentID); | 2954 | m_authenticateHandler.RemoveCircuit(agentID); |
2808 | 2955 | ||
@@ -2847,6 +2994,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2847 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 2994 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2848 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 2995 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2849 | 2996 | ||
2997 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
2998 | |||
2850 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 2999 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2851 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3000 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2852 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3001 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -2903,6 +3052,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2903 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3052 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2904 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3053 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2905 | client.OnCopyInventoryItem += CopyInventoryItem; | 3054 | client.OnCopyInventoryItem += CopyInventoryItem; |
3055 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2906 | client.OnMoveInventoryItem += MoveInventoryItem; | 3056 | client.OnMoveInventoryItem += MoveInventoryItem; |
2907 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3057 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2908 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3058 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2974,6 +3124,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2974 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3124 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
2975 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3125 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
2976 | 3126 | ||
3127 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3128 | |||
2977 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3129 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2978 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3130 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
2979 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3131 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3076,7 +3228,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3076 | /// </summary> | 3228 | /// </summary> |
3077 | /// <param name="agentId">The avatar's Unique ID</param> | 3229 | /// <param name="agentId">The avatar's Unique ID</param> |
3078 | /// <param name="client">The IClientAPI for the client</param> | 3230 | /// <param name="client">The IClientAPI for the client</param> |
3079 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3231 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3080 | { | 3232 | { |
3081 | if (EntityTransferModule != null) | 3233 | if (EntityTransferModule != null) |
3082 | { | 3234 | { |
@@ -3087,6 +3239,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3087 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3239 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3088 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3240 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3089 | } | 3241 | } |
3242 | return false; | ||
3090 | } | 3243 | } |
3091 | 3244 | ||
3092 | /// <summary> | 3245 | /// <summary> |
@@ -3196,6 +3349,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3196 | /// <param name="flags"></param> | 3349 | /// <param name="flags"></param> |
3197 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3350 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3198 | { | 3351 | { |
3352 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3353 | ScenePresence presence; | ||
3354 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3355 | { | ||
3356 | if (presence.Appearance != null) | ||
3357 | { | ||
3358 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3359 | } | ||
3360 | } | ||
3361 | |||
3199 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3362 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3200 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3363 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3201 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3364 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3264,8 +3427,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3264 | regions.Remove(RegionInfo.RegionHandle); | 3427 | regions.Remove(RegionInfo.RegionHandle); |
3265 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3428 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3266 | } | 3429 | } |
3267 | 3430 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3268 | m_eventManager.TriggerClientClosed(agentID, this); | 3431 | m_eventManager.TriggerClientClosed(agentID, this); |
3432 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3269 | } | 3433 | } |
3270 | catch (NullReferenceException) | 3434 | catch (NullReferenceException) |
3271 | { | 3435 | { |
@@ -3327,9 +3491,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3327 | { | 3491 | { |
3328 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); | 3492 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); |
3329 | } | 3493 | } |
3330 | 3494 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3331 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3495 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3332 | // CleanDroppedAttachments(); | 3496 | // CleanDroppedAttachments(); |
3497 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3333 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3498 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3334 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3499 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3335 | } | 3500 | } |
@@ -3464,13 +3629,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3464 | sp = null; | 3629 | sp = null; |
3465 | } | 3630 | } |
3466 | 3631 | ||
3467 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3468 | 3632 | ||
3469 | //On login test land permisions | 3633 | //On login test land permisions |
3470 | if (vialogin) | 3634 | if (vialogin) |
3471 | { | 3635 | { |
3472 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3636 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3637 | if (cache != null) | ||
3638 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3639 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3473 | { | 3640 | { |
3641 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3474 | return false; | 3642 | return false; |
3475 | } | 3643 | } |
3476 | } | 3644 | } |
@@ -3493,9 +3661,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3493 | 3661 | ||
3494 | try | 3662 | try |
3495 | { | 3663 | { |
3496 | if (!AuthorizeUser(agent, out reason)) | 3664 | // Always check estate if this is a login. Always |
3497 | return false; | 3665 | // check if banned regions are to be blacked out. |
3498 | } catch (Exception e) | 3666 | if (vialogin || (!m_seeIntoBannedRegion)) |
3667 | { | ||
3668 | if (!AuthorizeUser(agent, out reason)) | ||
3669 | return false; | ||
3670 | } | ||
3671 | } | ||
3672 | catch (Exception e) | ||
3499 | { | 3673 | { |
3500 | m_log.ErrorFormat( | 3674 | m_log.ErrorFormat( |
3501 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); | 3675 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); |
@@ -3626,6 +3800,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3626 | } | 3800 | } |
3627 | 3801 | ||
3628 | // Honor parcel landing type and position. | 3802 | // Honor parcel landing type and position. |
3803 | /* | ||
3804 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3629 | if (land != null) | 3805 | if (land != null) |
3630 | { | 3806 | { |
3631 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3807 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3633,25 +3809,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3633 | agent.startpos = land.LandData.UserLocation; | 3809 | agent.startpos = land.LandData.UserLocation; |
3634 | } | 3810 | } |
3635 | } | 3811 | } |
3812 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3636 | } | 3813 | } |
3637 | 3814 | ||
3638 | return true; | 3815 | return true; |
3639 | } | 3816 | } |
3640 | 3817 | ||
3641 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3818 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3642 | { | 3819 | { |
3643 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3820 | reason = String.Empty; |
3644 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3821 | if (Permissions.IsGod(agentID)) |
3822 | return true; | ||
3823 | |||
3824 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3825 | if (land == null) | ||
3826 | return false; | ||
3827 | |||
3828 | bool banned = land.IsBannedFromLand(agentID); | ||
3829 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3645 | 3830 | ||
3646 | if (banned || restricted) | 3831 | if (banned || restricted) |
3647 | { | 3832 | { |
3648 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3833 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3649 | if (nearestParcel != null) | 3834 | if (nearestParcel != null) |
3650 | { | 3835 | { |
3651 | //Move agent to nearest allowed | 3836 | //Move agent to nearest allowed |
3652 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3837 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3653 | agent.startpos.X = newPosition.X; | 3838 | posX = newPosition.X; |
3654 | agent.startpos.Y = newPosition.Y; | 3839 | posY = newPosition.Y; |
3655 | } | 3840 | } |
3656 | else | 3841 | else |
3657 | { | 3842 | { |
@@ -3713,7 +3898,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3713 | 3898 | ||
3714 | if (!m_strictAccessControl) return true; | 3899 | if (!m_strictAccessControl) return true; |
3715 | if (Permissions.IsGod(agent.AgentID)) return true; | 3900 | if (Permissions.IsGod(agent.AgentID)) return true; |
3716 | 3901 | ||
3717 | if (AuthorizationService != null) | 3902 | if (AuthorizationService != null) |
3718 | { | 3903 | { |
3719 | if (!AuthorizationService.IsAuthorizedForRegion( | 3904 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3728,7 +3913,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3728 | 3913 | ||
3729 | if (m_regInfo.EstateSettings != null) | 3914 | if (m_regInfo.EstateSettings != null) |
3730 | { | 3915 | { |
3731 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3916 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3732 | { | 3917 | { |
3733 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3918 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3734 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3919 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3918,6 +4103,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3918 | 4103 | ||
3919 | // XPTO: if this agent is not allowed here as root, always return false | 4104 | // XPTO: if this agent is not allowed here as root, always return false |
3920 | 4105 | ||
4106 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4107 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4108 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4109 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4110 | { | ||
4111 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4112 | return false; | ||
4113 | } | ||
4114 | |||
3921 | // TODO: This check should probably be in QueryAccess(). | 4115 | // TODO: This check should probably be in QueryAccess(). |
3922 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4116 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3923 | if (nearestParcel == null) | 4117 | if (nearestParcel == null) |
@@ -4011,12 +4205,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
4011 | return false; | 4205 | return false; |
4012 | } | 4206 | } |
4013 | 4207 | ||
4208 | public bool IncomingCloseAgent(UUID agentID) | ||
4209 | { | ||
4210 | return IncomingCloseAgent(agentID, false); | ||
4211 | } | ||
4212 | |||
4213 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4214 | { | ||
4215 | return IncomingCloseAgent(agentID, true); | ||
4216 | } | ||
4217 | |||
4014 | /// <summary> | 4218 | /// <summary> |
4015 | /// Tell a single agent to disconnect from the region. | 4219 | /// Tell a single agent to disconnect from the region. |
4016 | /// </summary> | 4220 | /// </summary> |
4017 | /// <param name="regionHandle"></param> | ||
4018 | /// <param name="agentID"></param> | 4221 | /// <param name="agentID"></param> |
4019 | public bool IncomingCloseAgent(UUID agentID) | 4222 | /// <param name="childOnly"></param> |
4223 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
4020 | { | 4224 | { |
4021 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4225 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
4022 | 4226 | ||
@@ -4028,7 +4232,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4028 | { | 4232 | { |
4029 | m_sceneGraph.removeUserCount(false); | 4233 | m_sceneGraph.removeUserCount(false); |
4030 | } | 4234 | } |
4031 | else | 4235 | else if (!childOnly) |
4032 | { | 4236 | { |
4033 | m_sceneGraph.removeUserCount(true); | 4237 | m_sceneGraph.removeUserCount(true); |
4034 | } | 4238 | } |
@@ -4044,9 +4248,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4044 | } | 4248 | } |
4045 | else | 4249 | else |
4046 | presence.ControllingClient.SendShutdownConnectionNotice(); | 4250 | presence.ControllingClient.SendShutdownConnectionNotice(); |
4251 | presence.ControllingClient.Close(false); | ||
4252 | } | ||
4253 | else if (!childOnly) | ||
4254 | { | ||
4255 | presence.ControllingClient.Close(true); | ||
4047 | } | 4256 | } |
4048 | |||
4049 | presence.ControllingClient.Close(); | ||
4050 | return true; | 4257 | return true; |
4051 | } | 4258 | } |
4052 | 4259 | ||
@@ -4632,35 +4839,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4632 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4839 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4633 | } | 4840 | } |
4634 | 4841 | ||
4635 | public int GetHealth() | 4842 | public int GetHealth(out int flags, out string message) |
4636 | { | 4843 | { |
4637 | // Returns: | 4844 | // Returns: |
4638 | // 1 = sim is up and accepting http requests. The heartbeat has | 4845 | // 1 = sim is up and accepting http requests. The heartbeat has |
4639 | // stopped and the sim is probably locked up, but a remote | 4846 | // stopped and the sim is probably locked up, but a remote |
4640 | // admin restart may succeed | 4847 | // admin restart may succeed |
4641 | // | 4848 | // |
4642 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4849 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4643 | // usable for people within and logins _may_ work | 4850 | // usable for people within |
4644 | // | 4851 | // |
4645 | // 3 = We have seen a new user enter within the past 4 minutes | 4852 | // 3 = Sim is up and one packet thread is running. Sim is |
4853 | // unstable and will not accept new logins | ||
4854 | // | ||
4855 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4856 | // likely usable | ||
4857 | // | ||
4858 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4646 | // which can be seen as positive confirmation of sim health | 4859 | // which can be seen as positive confirmation of sim health |
4647 | // | 4860 | // |
4861 | |||
4862 | flags = 0; | ||
4863 | message = String.Empty; | ||
4864 | |||
4865 | CheckHeartbeat(); | ||
4866 | |||
4867 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4868 | { | ||
4869 | // We're still starting | ||
4870 | // 0 means "in startup", it can't happen another way, since | ||
4871 | // to get here, we must be able to accept http connections | ||
4872 | return 0; | ||
4873 | } | ||
4874 | |||
4648 | int health=1; // Start at 1, means we're up | 4875 | int health=1; // Start at 1, means we're up |
4649 | 4876 | ||
4650 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 4877 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4651 | health += 1; | 4878 | { |
4879 | health+=1; | ||
4880 | flags |= 1; | ||
4881 | } | ||
4882 | |||
4883 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4884 | { | ||
4885 | health+=1; | ||
4886 | flags |= 2; | ||
4887 | } | ||
4888 | |||
4889 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4890 | { | ||
4891 | health+=1; | ||
4892 | flags |= 4; | ||
4893 | } | ||
4652 | else | 4894 | else |
4895 | { | ||
4896 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4897 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4898 | proc.EnableRaisingEvents=false; | ||
4899 | proc.StartInfo.FileName = "/bin/kill"; | ||
4900 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4901 | proc.Start(); | ||
4902 | proc.WaitForExit(); | ||
4903 | Thread.Sleep(1000); | ||
4904 | Environment.Exit(1); | ||
4905 | } | ||
4906 | |||
4907 | if (flags != 7) | ||
4653 | return health; | 4908 | return health; |
4654 | 4909 | ||
4655 | // A login in the last 4 mins? We can't be doing too badly | 4910 | // A login in the last 4 mins? We can't be doing too badly |
4656 | // | 4911 | // |
4657 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4912 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4658 | health++; | 4913 | health++; |
4659 | else | 4914 | else |
4660 | return health; | 4915 | return health; |
4661 | 4916 | ||
4662 | // CheckHeartbeat(); | ||
4663 | |||
4664 | return health; | 4917 | return health; |
4665 | } | 4918 | } |
4666 | 4919 | ||
@@ -4748,7 +5001,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4748 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5001 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4749 | if (wasUsingPhysics) | 5002 | if (wasUsingPhysics) |
4750 | { | 5003 | { |
4751 | 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 | 5004 | 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 |
4752 | } | 5005 | } |
4753 | } | 5006 | } |
4754 | 5007 | ||
@@ -4847,14 +5100,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4847 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5100 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
4848 | } | 5101 | } |
4849 | 5102 | ||
4850 | // private void CheckHeartbeat() | 5103 | private void CheckHeartbeat() |
4851 | // { | 5104 | { |
4852 | // if (m_firstHeartbeat) | 5105 | if (m_firstHeartbeat) |
4853 | // return; | 5106 | return; |
4854 | // | 5107 | |
4855 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5108 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
4856 | // StartTimer(); | 5109 | Start(); |
4857 | // } | 5110 | } |
4858 | 5111 | ||
4859 | public override ISceneObject DeserializeObject(string representation) | 5112 | public override ISceneObject DeserializeObject(string representation) |
4860 | { | 5113 | { |
@@ -4866,9 +5119,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4866 | get { return m_allowScriptCrossings; } | 5119 | get { return m_allowScriptCrossings; } |
4867 | } | 5120 | } |
4868 | 5121 | ||
4869 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5122 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
5123 | { | ||
5124 | return GetNearestAllowedPosition(avatar, null); | ||
5125 | } | ||
5126 | |||
5127 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
4870 | { | 5128 | { |
4871 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5129 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); |
4872 | 5130 | ||
4873 | if (nearestParcel != null) | 5131 | if (nearestParcel != null) |
4874 | { | 5132 | { |
@@ -4877,10 +5135,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4877 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5135 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4878 | if (nearestPoint != null) | 5136 | if (nearestPoint != null) |
4879 | { | 5137 | { |
4880 | // m_log.DebugFormat( | 5138 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
4881 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
4882 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
4883 | |||
4884 | return nearestPoint.Value; | 5139 | return nearestPoint.Value; |
4885 | } | 5140 | } |
4886 | 5141 | ||
@@ -4890,17 +5145,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4890 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5145 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4891 | if (nearestPoint != null) | 5146 | if (nearestPoint != null) |
4892 | { | 5147 | { |
4893 | // m_log.DebugFormat( | 5148 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
4894 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
4895 | |||
4896 | return nearestPoint.Value; | 5149 | return nearestPoint.Value; |
4897 | } | 5150 | } |
4898 | 5151 | ||
4899 | //Ultimate backup if we have no idea where they are | 5152 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
4900 | // m_log.DebugFormat( | 5153 | if (dest != excludeParcel) |
4901 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5154 | { |
5155 | // Ultimate backup if we have no idea where they are and | ||
5156 | // the last allowed position was in another parcel | ||
5157 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5158 | return avatar.lastKnownAllowedPosition; | ||
5159 | } | ||
4902 | 5160 | ||
4903 | return avatar.lastKnownAllowedPosition; | 5161 | // else fall through to region edge |
4904 | } | 5162 | } |
4905 | 5163 | ||
4906 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5164 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -4934,13 +5192,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4934 | 5192 | ||
4935 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5193 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
4936 | { | 5194 | { |
5195 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5196 | } | ||
5197 | |||
5198 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5199 | { | ||
4937 | List<ILandObject> all = AllParcels(); | 5200 | List<ILandObject> all = AllParcels(); |
4938 | float minParcelDistance = float.MaxValue; | 5201 | float minParcelDistance = float.MaxValue; |
4939 | ILandObject nearestParcel = null; | 5202 | ILandObject nearestParcel = null; |
4940 | 5203 | ||
4941 | foreach (var parcel in all) | 5204 | foreach (var parcel in all) |
4942 | { | 5205 | { |
4943 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5206 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
4944 | { | 5207 | { |
4945 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5208 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
4946 | if (parcelDistance < minParcelDistance) | 5209 | if (parcelDistance < minParcelDistance) |
@@ -5182,7 +5445,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5182 | mapModule.GenerateMaptile(); | 5445 | mapModule.GenerateMaptile(); |
5183 | } | 5446 | } |
5184 | 5447 | ||
5185 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5448 | // public void CleanDroppedAttachments() |
5449 | // { | ||
5450 | // List<SceneObjectGroup> objectsToDelete = | ||
5451 | // new List<SceneObjectGroup>(); | ||
5452 | // | ||
5453 | // lock (m_cleaningAttachments) | ||
5454 | // { | ||
5455 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5456 | // { | ||
5457 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5458 | // { | ||
5459 | // UUID agentID = grp.OwnerID; | ||
5460 | // if (agentID == UUID.Zero) | ||
5461 | // { | ||
5462 | // objectsToDelete.Add(grp); | ||
5463 | // return; | ||
5464 | // } | ||
5465 | // | ||
5466 | // ScenePresence sp = GetScenePresence(agentID); | ||
5467 | // if (sp == null) | ||
5468 | // { | ||
5469 | // objectsToDelete.Add(grp); | ||
5470 | // return; | ||
5471 | // } | ||
5472 | // } | ||
5473 | // }); | ||
5474 | // } | ||
5475 | // | ||
5476 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5477 | // { | ||
5478 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5479 | // DeleteSceneObject(grp, true); | ||
5480 | // } | ||
5481 | // } | ||
5482 | |||
5483 | public void ThreadAlive(int threadCode) | ||
5484 | { | ||
5485 | switch(threadCode) | ||
5486 | { | ||
5487 | case 1: // Incoming | ||
5488 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5489 | break; | ||
5490 | case 2: // Incoming | ||
5491 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5492 | break; | ||
5493 | } | ||
5494 | } | ||
5495 | |||
5496 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5186 | { | 5497 | { |
5187 | RegenerateMaptile(); | 5498 | RegenerateMaptile(); |
5188 | 5499 | ||
@@ -5210,6 +5521,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5210 | /// <returns></returns> | 5521 | /// <returns></returns> |
5211 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5522 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5212 | { | 5523 | { |
5524 | reason = "You are banned from the region"; | ||
5525 | |||
5213 | if (EntityTransferModule.IsInTransit(agentID)) | 5526 | if (EntityTransferModule.IsInTransit(agentID)) |
5214 | { | 5527 | { |
5215 | reason = "Agent is still in transit from this region"; | 5528 | reason = "Agent is still in transit from this region"; |
@@ -5221,6 +5534,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5221 | return false; | 5534 | return false; |
5222 | } | 5535 | } |
5223 | 5536 | ||
5537 | if (Permissions.IsGod(agentID)) | ||
5538 | { | ||
5539 | reason = String.Empty; | ||
5540 | return true; | ||
5541 | } | ||
5542 | |||
5224 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 5543 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5225 | // However, the long term fix is to make sure root agent count is always accurate. | 5544 | // However, the long term fix is to make sure root agent count is always accurate. |
5226 | m_sceneGraph.RecalculateStats(); | 5545 | m_sceneGraph.RecalculateStats(); |
@@ -5241,6 +5560,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5241 | } | 5560 | } |
5242 | } | 5561 | } |
5243 | 5562 | ||
5563 | ScenePresence presence = GetScenePresence(agentID); | ||
5564 | IClientAPI client = null; | ||
5565 | AgentCircuitData aCircuit = null; | ||
5566 | |||
5567 | if (presence != null) | ||
5568 | { | ||
5569 | client = presence.ControllingClient; | ||
5570 | if (client != null) | ||
5571 | aCircuit = client.RequestClientInfo(); | ||
5572 | } | ||
5573 | |||
5574 | // We may be called before there is a presence or a client. | ||
5575 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5576 | if (client == null) | ||
5577 | { | ||
5578 | aCircuit = new AgentCircuitData(); | ||
5579 | aCircuit.AgentID = agentID; | ||
5580 | aCircuit.firstname = String.Empty; | ||
5581 | aCircuit.lastname = String.Empty; | ||
5582 | } | ||
5583 | |||
5584 | try | ||
5585 | { | ||
5586 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5587 | { | ||
5588 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5589 | return false; | ||
5590 | } | ||
5591 | } | ||
5592 | catch (Exception e) | ||
5593 | { | ||
5594 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5595 | return false; | ||
5596 | } | ||
5597 | |||
5244 | if (position == Vector3.Zero) // Teleport | 5598 | if (position == Vector3.Zero) // Teleport |
5245 | { | 5599 | { |
5246 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5600 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5269,13 +5623,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5269 | } | 5623 | } |
5270 | } | 5624 | } |
5271 | } | 5625 | } |
5626 | |||
5627 | float posX = 128.0f; | ||
5628 | float posY = 128.0f; | ||
5629 | |||
5630 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5631 | { | ||
5632 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5633 | return false; | ||
5634 | } | ||
5635 | } | ||
5636 | else // Walking | ||
5637 | { | ||
5638 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5639 | if (land == null) | ||
5640 | return false; | ||
5641 | |||
5642 | bool banned = land.IsBannedFromLand(agentID); | ||
5643 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5644 | |||
5645 | if (banned || restricted) | ||
5646 | return false; | ||
5272 | } | 5647 | } |
5273 | 5648 | ||
5274 | reason = String.Empty; | 5649 | reason = String.Empty; |
5275 | return true; | 5650 | return true; |
5276 | } | 5651 | } |
5277 | 5652 | ||
5278 | /// <summary> | 5653 | public void StartTimerWatchdog() |
5654 | { | ||
5655 | m_timerWatchdog.Interval = 1000; | ||
5656 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5657 | m_timerWatchdog.AutoReset = true; | ||
5658 | m_timerWatchdog.Start(); | ||
5659 | } | ||
5660 | |||
5661 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5662 | { | ||
5663 | CheckHeartbeat(); | ||
5664 | } | ||
5665 | |||
5279 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5666 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5280 | /// autopilot that moves an avatar to a sit target!. | 5667 | /// autopilot that moves an avatar to a sit target!. |
5281 | /// </summary> | 5668 | /// </summary> |