aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs1412
-rwxr-xr-x[-rw-r--r--]OpenSim/Region/Framework/Scenes/SceneGraph.cs59
-rwxr-xr-xOpenSim/Region/Framework/Scenes/SimStatsReporter.cs221
-rwxr-xr-x[-rw-r--r--]OpenSim/Region/ScriptEngine/XEngine/XEngine.cs36
4 files changed, 969 insertions, 759 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 906c862..9fd1055 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1,29 +1,29 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4*
5 * Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12* * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15 * 15*
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26*/
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
@@ -48,7 +48,7 @@ using OpenSim.Region.Framework.Interfaces;
48using OpenSim.Region.Framework.Scenes.Scripting; 48using OpenSim.Region.Framework.Scenes.Scripting;
49using OpenSim.Region.Framework.Scenes.Serialization; 49using OpenSim.Region.Framework.Scenes.Serialization;
50using OpenSim.Region.Physics.Manager; 50using OpenSim.Region.Physics.Manager;
51using Timer=System.Timers.Timer; 51using Timer = System.Timers.Timer;
52using TPFlags = OpenSim.Framework.Constants.TeleportFlags; 52using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
53using GridRegion = OpenSim.Services.Interfaces.GridRegion; 53using GridRegion = OpenSim.Services.Interfaces.GridRegion;
54using PermissionMask = OpenSim.Framework.PermissionMask; 54using PermissionMask = OpenSim.Framework.PermissionMask;
@@ -62,6 +62,8 @@ namespace OpenSim.Region.Framework.Scenes
62 private const long DEFAULT_MIN_TIME_FOR_PERSISTENCE = 60L; 62 private const long DEFAULT_MIN_TIME_FOR_PERSISTENCE = 60L;
63 private const long DEFAULT_MAX_TIME_FOR_PERSISTENCE = 600L; 63 private const long DEFAULT_MAX_TIME_FOR_PERSISTENCE = 600L;
64 64
65 public const int m_defaultNumberFramesStored = 10;
66
65 public delegate void SynchronizeSceneHandler(Scene scene); 67 public delegate void SynchronizeSceneHandler(Scene scene);
66 68
67 #region Fields 69 #region Fields
@@ -103,9 +105,9 @@ namespace OpenSim.Region.Framework.Scenes
103 /// <summary> 105 /// <summary>
104 /// If false then physical objects are disabled, though collisions will continue as normal. 106 /// If false then physical objects are disabled, though collisions will continue as normal.
105 /// </summary> 107 /// </summary>
106 public bool PhysicsEnabled 108 public bool PhysicsEnabled
107 { 109 {
108 get 110 get
109 { 111 {
110 return m_physicsEnabled; 112 return m_physicsEnabled;
111 } 113 }
@@ -119,8 +121,8 @@ namespace OpenSim.Region.Framework.Scenes
119 IPhysicsParameters physScene = PhysicsScene as IPhysicsParameters; 121 IPhysicsParameters physScene = PhysicsScene as IPhysicsParameters;
120 122
121 if (physScene != null) 123 if (physScene != null)
122 physScene.SetPhysicsParameter( 124 physScene.SetPhysicsParameter(
123 "Active", m_physicsEnabled.ToString(), PhysParameterEntry.APPLY_TO_NONE); 125 "Active", m_physicsEnabled.ToString(), PhysParameterEntry.APPLY_TO_NONE);
124 } 126 }
125 } 127 }
126 } 128 }
@@ -130,10 +132,10 @@ namespace OpenSim.Region.Framework.Scenes
130 /// <summary> 132 /// <summary>
131 /// If false then scripts are not enabled on the smiulator 133 /// If false then scripts are not enabled on the smiulator
132 /// </summary> 134 /// </summary>
133 public bool ScriptsEnabled 135 public bool ScriptsEnabled
134 { 136 {
135 get { return m_scripts_enabled; } 137 get { return m_scripts_enabled; }
136 set 138 set
137 { 139 {
138 if (m_scripts_enabled != value) 140 if (m_scripts_enabled != value)
139 { 141 {
@@ -145,13 +147,13 @@ namespace OpenSim.Region.Framework.Scenes
145 foreach (EntityBase ent in entities) 147 foreach (EntityBase ent in entities)
146 { 148 {
147 if (ent is SceneObjectGroup) 149 if (ent is SceneObjectGroup)
148 ((SceneObjectGroup)ent).RemoveScriptInstances(false); 150 ((SceneObjectGroup)ent).RemoveScriptInstances(false);
149 } 151 }
150 } 152 }
151 else 153 else
152 { 154 {
153 m_log.Info("Starting all Scripts in Scene"); 155 m_log.Info("Starting all Scripts in Scene");
154 156
155 EntityBase[] entities = Entities.GetEntities(); 157 EntityBase[] entities = Entities.GetEntities();
156 foreach (EntityBase ent in entities) 158 foreach (EntityBase ent in entities)
157 { 159 {
@@ -236,8 +238,8 @@ namespace OpenSim.Region.Framework.Scenes
236 /// <summary> 238 /// <summary>
237 /// Temporarily setting to trigger appearance resends at 60 second intervals. 239 /// Temporarily setting to trigger appearance resends at 60 second intervals.
238 /// </summary> 240 /// </summary>
239 public bool SendPeriodicAppearanceUpdates { get; set; } 241 public bool SendPeriodicAppearanceUpdates { get; set; }
240 242
241 /// <summary> 243 /// <summary>
242 /// How much a root agent has to change position before updates are sent to viewers. 244 /// How much a root agent has to change position before updates are sent to viewers.
243 /// </summary> 245 /// </summary>
@@ -264,10 +266,11 @@ namespace OpenSim.Region.Framework.Scenes
264 public int ChildTerseUpdatePeriod { get; set; } 266 public int ChildTerseUpdatePeriod { get; set; }
265 267
266 protected float m_defaultDrawDistance = 255.0f; 268 protected float m_defaultDrawDistance = 255.0f;
267 public float DefaultDrawDistance 269 public float DefaultDrawDistance
268 { 270 {
269 // get { return m_defaultDrawDistance; } 271 // get { return m_defaultDrawDistance; }
270 get { 272 get
273 {
271 if (RegionInfo != null) 274 if (RegionInfo != null)
272 { 275 {
273 float largestDimension = Math.Max(RegionInfo.RegionSizeX, RegionInfo.RegionSizeY); 276 float largestDimension = Math.Max(RegionInfo.RegionSizeX, RegionInfo.RegionSizeY);
@@ -280,7 +283,7 @@ namespace OpenSim.Region.Framework.Scenes
280 283
281 private List<string> m_AllowedViewers = new List<string>(); 284 private List<string> m_AllowedViewers = new List<string>();
282 private List<string> m_BannedViewers = new List<string>(); 285 private List<string> m_BannedViewers = new List<string>();
283 286
284 // TODO: need to figure out how allow client agents but deny 287 // TODO: need to figure out how allow client agents but deny
285 // root agents when ACL denies access to root agent 288 // root agents when ACL denies access to root agent
286 public bool m_strictAccessControl = true; 289 public bool m_strictAccessControl = true;
@@ -367,15 +370,15 @@ namespace OpenSim.Region.Framework.Scenes
367 /// One can tweak this number to experiment. One current effect of reducing it is to make avatar animations 370 /// One can tweak this number to experiment. One current effect of reducing it is to make avatar animations
368 /// occur too quickly (viewer 1) or with even more slide (viewer 2). 371 /// occur too quickly (viewer 1) or with even more slide (viewer 2).
369 /// </remarks> 372 /// </remarks>
370 public int MinFrameTicks 373 public int MinFrameTicks
371 { 374 {
372 get { return m_minFrameTicks; } 375 get { return m_minFrameTicks; }
373 private set 376 private set
374 { 377 {
375 m_minFrameTicks = value; 378 m_minFrameTicks = value;
376 MinFrameSeconds = (float)m_minFrameTicks / 1000; 379 MinFrameSeconds = (float)m_minFrameTicks / 1000;
377 } 380 }
378 } 381 }
379 private int m_minFrameTicks; 382 private int m_minFrameTicks;
380 383
381 /// <summary> 384 /// <summary>
@@ -403,7 +406,7 @@ namespace OpenSim.Region.Framework.Scenes
403 private int m_update_events = 1; 406 private int m_update_events = 1;
404 private int m_update_backup = 200; 407 private int m_update_backup = 200;
405 private int m_update_terrain = 50; 408 private int m_update_terrain = 50;
406// private int m_update_land = 1; 409 // private int m_update_land = 1;
407 private int m_update_coarse_locations = 50; 410 private int m_update_coarse_locations = 50;
408 private int m_update_temp_cleaning = 180; 411 private int m_update_temp_cleaning = 180;
409 412
@@ -434,7 +437,7 @@ namespace OpenSim.Region.Framework.Scenes
434 /// asynchronously from the update loop. 437 /// asynchronously from the update loop.
435 /// </summary> 438 /// </summary>
436 private bool m_cleaningTemps = false; 439 private bool m_cleaningTemps = false;
437 440
438 /// <summary> 441 /// <summary>
439 /// Used to control main scene thread looping time when not updating via timer. 442 /// Used to control main scene thread looping time when not updating via timer.
440 /// </summary> 443 /// </summary>
@@ -489,7 +492,7 @@ namespace OpenSim.Region.Framework.Scenes
489 if (value) 492 if (value)
490 { 493 {
491 if (!m_active) 494 if (!m_active)
492 Start(false); 495 Start(false);
493 } 496 }
494 else 497 else
495 { 498 {
@@ -526,6 +529,13 @@ namespace OpenSim.Region.Framework.Scenes
526 get { return m_sceneGraph.PhysicsScene.TimeDilation; } 529 get { return m_sceneGraph.PhysicsScene.TimeDilation; }
527 } 530 }
528 531
532 public void setThreadCount(int inUseThreads)
533 {
534 // Just pass the thread count information on its way as the Scene
535 // does not require the value for anything at this time
536 StatsReporter.SetThreadCount(inUseThreads);
537 }
538
529 public SceneCommunicationService SceneGridService 539 public SceneCommunicationService SceneGridService
530 { 540 {
531 get { return m_sceneGridService; } 541 get { return m_sceneGridService; }
@@ -584,7 +594,7 @@ namespace OpenSim.Region.Framework.Scenes
584 return m_AssetService; 594 return m_AssetService;
585 } 595 }
586 } 596 }
587 597
588 public IAuthorizationService AuthorizationService 598 public IAuthorizationService AuthorizationService
589 { 599 {
590 get 600 get
@@ -645,7 +655,7 @@ namespace OpenSim.Region.Framework.Scenes
645 get 655 get
646 { 656 {
647 if (m_LibraryService == null) 657 if (m_LibraryService == null)
648 m_LibraryService = RequestModuleInterface<ILibraryService>(); 658 m_LibraryService = RequestModuleInterface<ILibraryService>();
649 659
650 return m_LibraryService; 660 return m_LibraryService;
651 } 661 }
@@ -656,7 +666,7 @@ namespace OpenSim.Region.Framework.Scenes
656 get 666 get
657 { 667 {
658 if (m_simulationService == null) 668 if (m_simulationService == null)
659 m_simulationService = RequestModuleInterface<ISimulationService>(); 669 m_simulationService = RequestModuleInterface<ISimulationService>();
660 670
661 return m_simulationService; 671 return m_simulationService;
662 } 672 }
@@ -667,7 +677,7 @@ namespace OpenSim.Region.Framework.Scenes
667 get 677 get
668 { 678 {
669 if (m_AuthenticationService == null) 679 if (m_AuthenticationService == null)
670 m_AuthenticationService = RequestModuleInterface<IAuthenticationService>(); 680 m_AuthenticationService = RequestModuleInterface<IAuthenticationService>();
671 return m_AuthenticationService; 681 return m_AuthenticationService;
672 } 682 }
673 } 683 }
@@ -677,7 +687,7 @@ namespace OpenSim.Region.Framework.Scenes
677 get 687 get
678 { 688 {
679 if (m_PresenceService == null) 689 if (m_PresenceService == null)
680 m_PresenceService = RequestModuleInterface<IPresenceService>(); 690 m_PresenceService = RequestModuleInterface<IPresenceService>();
681 return m_PresenceService; 691 return m_PresenceService;
682 } 692 }
683 } 693 }
@@ -687,7 +697,7 @@ namespace OpenSim.Region.Framework.Scenes
687 get 697 get
688 { 698 {
689 if (m_UserAccountService == null) 699 if (m_UserAccountService == null)
690 m_UserAccountService = RequestModuleInterface<IUserAccountService>(); 700 m_UserAccountService = RequestModuleInterface<IUserAccountService>();
691 return m_UserAccountService; 701 return m_UserAccountService;
692 } 702 }
693 } 703 }
@@ -697,7 +707,7 @@ namespace OpenSim.Region.Framework.Scenes
697 get 707 get
698 { 708 {
699 if (m_AvatarService == null) 709 if (m_AvatarService == null)
700 m_AvatarService = RequestModuleInterface<IAvatarService>(); 710 m_AvatarService = RequestModuleInterface<IAvatarService>();
701 return m_AvatarService; 711 return m_AvatarService;
702 } 712 }
703 } 713 }
@@ -707,7 +717,7 @@ namespace OpenSim.Region.Framework.Scenes
707 get 717 get
708 { 718 {
709 if (m_GridUserService == null) 719 if (m_GridUserService == null)
710 m_GridUserService = RequestModuleInterface<IGridUserService>(); 720 m_GridUserService = RequestModuleInterface<IGridUserService>();
711 return m_GridUserService; 721 return m_GridUserService;
712 } 722 }
713 } 723 }
@@ -721,7 +731,7 @@ namespace OpenSim.Region.Framework.Scenes
721 { 731 {
722 get { return m_AvatarFactory; } 732 get { return m_AvatarFactory; }
723 } 733 }
724 734
725 public ICapabilitiesModule CapsModule 735 public ICapabilitiesModule CapsModule
726 { 736 {
727 get { return m_capsModule; } 737 get { return m_capsModule; }
@@ -787,18 +797,20 @@ namespace OpenSim.Region.Framework.Scenes
787 get { return m_sceneGraph.Entities; } 797 get { return m_sceneGraph.Entities; }
788 } 798 }
789 799
790 800
791 // used in sequence see: SpawnPoint() 801 // used in sequence see: SpawnPoint()
792 private int m_SpawnPoint; 802 private int m_SpawnPoint;
793 // can be closest/random/sequence 803 // can be closest/random/sequence
794 public string SpawnPointRouting 804 public string SpawnPointRouting
795 { 805 {
796 get; private set; 806 get;
807 private set;
797 } 808 }
798 // allow landmarks to pass 809 // allow landmarks to pass
799 public bool TelehubAllowLandmarks 810 public bool TelehubAllowLandmarks
800 { 811 {
801 get; private set; 812 get;
813 private set;
802 } 814 }
803 815
804 #endregion Properties 816 #endregion Properties
@@ -806,10 +818,10 @@ namespace OpenSim.Region.Framework.Scenes
806 #region Constructors 818 #region Constructors
807 819
808 public Scene(RegionInfo regInfo, AgentCircuitManager authen, PhysicsScene physicsScene, 820 public Scene(RegionInfo regInfo, AgentCircuitManager authen, PhysicsScene physicsScene,
809 SceneCommunicationService sceneGridService, 821 SceneCommunicationService sceneGridService,
810 ISimulationDataService simDataService, IEstateDataService estateDataService, 822 ISimulationDataService simDataService, IEstateDataService estateDataService,
811 IConfigSource config, string simulatorVersion) 823 IConfigSource config, string simulatorVersion)
812 : this(regInfo, physicsScene) 824 : this(regInfo, physicsScene)
813 { 825 {
814 m_config = config; 826 m_config = config;
815 MinFrameTicks = 89; 827 MinFrameTicks = 89;
@@ -866,20 +878,20 @@ namespace OpenSim.Region.Framework.Scenes
866 } 878 }
867 879
868 if (updatedTerrainTextures) 880 if (updatedTerrainTextures)
869 rs.Save(); 881 rs.Save();
870 882
871 RegionInfo.RegionSettings = rs; 883 RegionInfo.RegionSettings = rs;
872 884
873 if (estateDataService != null) 885 if (estateDataService != null)
874 RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false); 886 RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false);
875 887
876 #endregion Region Settings 888 #endregion Region Settings
877 889
878 //Bind Storage Manager functions to some land manager functions for this scene 890 //Bind Storage Manager functions to some land manager functions for this scene
879 EventManager.OnLandObjectAdded += 891 EventManager.OnLandObjectAdded +=
880 new EventManager.LandObjectAdded(simDataService.StoreLandObject); 892 new EventManager.LandObjectAdded(simDataService.StoreLandObject);
881 EventManager.OnLandObjectRemoved += 893 EventManager.OnLandObjectRemoved +=
882 new EventManager.LandObjectRemoved(simDataService.RemoveLandObject); 894 new EventManager.LandObjectRemoved(simDataService.RemoveLandObject);
883 895
884 RegisterDefaultSceneEvents(); 896 RegisterDefaultSceneEvents();
885 897
@@ -904,8 +916,8 @@ namespace OpenSim.Region.Framework.Scenes
904 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); 916 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance);
905 UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); 917 UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup);
906 if (!UseBackup) 918 if (!UseBackup)
907 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); 919 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
908 920
909 //Animation states 921 //Animation states
910 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 922 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
911 923
@@ -959,10 +971,10 @@ namespace OpenSim.Region.Framework.Scenes
959 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 971 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
960 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 972 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
961 m_dontPersistBefore = 973 m_dontPersistBefore =
962 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); 974 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
963 m_dontPersistBefore *= 10000000; 975 m_dontPersistBefore *= 10000000;
964 m_persistAfter = 976 m_persistAfter =
965 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); 977 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
966 m_persistAfter *= 10000000; 978 m_persistAfter *= 10000000;
967 979
968 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 980 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
@@ -974,8 +986,8 @@ namespace OpenSim.Region.Framework.Scenes
974 986
975 string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; 987 string[] possibleMapConfigSections = new string[] { "Map", "Startup" };
976 988
977 m_generateMaptiles 989 m_generateMaptiles
978 = Util.GetConfigVarFromSections<bool>(config, "GenerateMaptiles", possibleMapConfigSections, true); 990 = Util.GetConfigVarFromSections<bool>(config, "GenerateMaptiles", possibleMapConfigSections, true);
979 991
980 if (m_generateMaptiles) 992 if (m_generateMaptiles)
981 { 993 {
@@ -991,9 +1003,9 @@ namespace OpenSim.Region.Framework.Scenes
991 } 1003 }
992 else 1004 else
993 { 1005 {
994 string tile 1006 string tile
995 = Util.GetConfigVarFromSections<string>( 1007 = Util.GetConfigVarFromSections<string>(
996 config, "MaptileStaticUUID", possibleMapConfigSections, UUID.Zero.ToString()); 1008 config, "MaptileStaticUUID", possibleMapConfigSections, UUID.Zero.ToString());
997 1009
998 UUID tileID; 1010 UUID tileID;
999 1011
@@ -1010,9 +1022,9 @@ namespace OpenSim.Region.Framework.Scenes
1010 1022
1011 string[] possibleAccessControlConfigSections = new string[] { "AccessControl", "Startup" }; 1023 string[] possibleAccessControlConfigSections = new string[] { "AccessControl", "Startup" };
1012 1024
1013 string grant 1025 string grant
1014 = Util.GetConfigVarFromSections<string>( 1026 = Util.GetConfigVarFromSections<string>(
1015 config, "AllowedClients", possibleAccessControlConfigSections, ""); 1027 config, "AllowedClients", possibleAccessControlConfigSections, "");
1016 1028
1017 if (grant.Length > 0) 1029 if (grant.Length > 0)
1018 { 1030 {
@@ -1022,9 +1034,9 @@ namespace OpenSim.Region.Framework.Scenes
1022 } 1034 }
1023 } 1035 }
1024 1036
1025 grant 1037 grant
1026 = Util.GetConfigVarFromSections<string>( 1038 = Util.GetConfigVarFromSections<string>(
1027 config, "BannedClients", possibleAccessControlConfigSections, ""); 1039 config, "BannedClients", possibleAccessControlConfigSections, "");
1028 1040
1029 if (grant.Length > 0) 1041 if (grant.Length > 0)
1030 { 1042 {
@@ -1035,27 +1047,27 @@ namespace OpenSim.Region.Framework.Scenes
1035 } 1047 }
1036 1048
1037 if (startupConfig.Contains("MinFrameTime")) 1049 if (startupConfig.Contains("MinFrameTime"))
1038 MinFrameTicks = (int)(startupConfig.GetFloat("MinFrameTime") * 1000); 1050 MinFrameTicks = (int)(startupConfig.GetFloat("MinFrameTime") * 1000);
1039 1051
1040 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); 1052 m_update_backup = startupConfig.GetInt("UpdateStorageEveryNFrames", m_update_backup);
1041 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 1053 m_update_coarse_locations = startupConfig.GetInt("UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
1042 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); 1054 m_update_entitymovement = startupConfig.GetInt("UpdateEntityMovementEveryNFrames", m_update_entitymovement);
1043 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); 1055 m_update_events = startupConfig.GetInt("UpdateEventsEveryNFrames", m_update_events);
1044 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); 1056 m_update_objects = startupConfig.GetInt("UpdateObjectsEveryNFrames", m_update_objects);
1045 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); 1057 m_update_physics = startupConfig.GetInt("UpdatePhysicsEveryNFrames", m_update_physics);
1046 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); 1058 m_update_presences = startupConfig.GetInt("UpdateAgentsEveryNFrames", m_update_presences);
1047 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); 1059 m_update_terrain = startupConfig.GetInt("UpdateTerrainEveryNFrames", m_update_terrain);
1048 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNSeconds", m_update_temp_cleaning); 1060 m_update_temp_cleaning = startupConfig.GetInt("UpdateTempCleaningEveryNSeconds", m_update_temp_cleaning);
1049 } 1061 }
1050 1062
1051 // FIXME: Ultimately this should be in a module. 1063 // FIXME: Ultimately this should be in a module.
1052 SendPeriodicAppearanceUpdates = false; 1064 SendPeriodicAppearanceUpdates = false;
1053 1065
1054 IConfig appearanceConfig = m_config.Configs["Appearance"]; 1066 IConfig appearanceConfig = m_config.Configs["Appearance"];
1055 if (appearanceConfig != null) 1067 if (appearanceConfig != null)
1056 { 1068 {
1057 SendPeriodicAppearanceUpdates 1069 SendPeriodicAppearanceUpdates
1058 = appearanceConfig.GetBoolean("ResendAppearanceUpdates", SendPeriodicAppearanceUpdates); 1070 = appearanceConfig.GetBoolean("ResendAppearanceUpdates", SendPeriodicAppearanceUpdates);
1059 } 1071 }
1060 1072
1061 #endregion Region Config 1073 #endregion Region Config
@@ -1083,58 +1095,68 @@ namespace OpenSim.Region.Framework.Scenes
1083 UpdatePrioritizationScheme = UpdatePrioritizationSchemes.Time; 1095 UpdatePrioritizationScheme = UpdatePrioritizationSchemes.Time;
1084 } 1096 }
1085 1097
1086 IsReprioritizationEnabled 1098 IsReprioritizationEnabled
1087 = interestConfig.GetBoolean("ReprioritizationEnabled", IsReprioritizationEnabled); 1099 = interestConfig.GetBoolean("ReprioritizationEnabled", IsReprioritizationEnabled);
1088 ReprioritizationInterval 1100 ReprioritizationInterval
1089 = interestConfig.GetDouble("ReprioritizationInterval", ReprioritizationInterval); 1101 = interestConfig.GetDouble("ReprioritizationInterval", ReprioritizationInterval);
1090 RootReprioritizationDistance 1102 RootReprioritizationDistance
1091 = interestConfig.GetDouble("RootReprioritizationDistance", RootReprioritizationDistance); 1103 = interestConfig.GetDouble("RootReprioritizationDistance", RootReprioritizationDistance);
1092 ChildReprioritizationDistance 1104 ChildReprioritizationDistance
1093 = interestConfig.GetDouble("ChildReprioritizationDistance", ChildReprioritizationDistance); 1105 = interestConfig.GetDouble("ChildReprioritizationDistance", ChildReprioritizationDistance);
1094 1106
1095 RootTerseUpdatePeriod = interestConfig.GetInt("RootTerseUpdatePeriod", RootTerseUpdatePeriod); 1107 RootTerseUpdatePeriod = interestConfig.GetInt("RootTerseUpdatePeriod", RootTerseUpdatePeriod);
1096 ChildTerseUpdatePeriod = interestConfig.GetInt("ChildTerseUpdatePeriod", ChildTerseUpdatePeriod); 1108 ChildTerseUpdatePeriod = interestConfig.GetInt("ChildTerseUpdatePeriod", ChildTerseUpdatePeriod);
1097 1109
1098 RootPositionUpdateTolerance 1110 RootPositionUpdateTolerance
1099 = interestConfig.GetFloat("RootPositionUpdateTolerance", RootPositionUpdateTolerance); 1111 = interestConfig.GetFloat("RootPositionUpdateTolerance", RootPositionUpdateTolerance);
1100 RootRotationUpdateTolerance 1112 RootRotationUpdateTolerance
1101 = interestConfig.GetFloat("RootRotationUpdateTolerance", RootRotationUpdateTolerance); 1113 = interestConfig.GetFloat("RootRotationUpdateTolerance", RootRotationUpdateTolerance);
1102 RootVelocityUpdateTolerance 1114 RootVelocityUpdateTolerance
1103 = interestConfig.GetFloat("RootVelocityUpdateTolerance", RootVelocityUpdateTolerance); 1115 = interestConfig.GetFloat("RootVelocityUpdateTolerance", RootVelocityUpdateTolerance);
1104 } 1116 }
1105 1117
1106 m_log.DebugFormat("[SCENE]: Using the {0} prioritization scheme", UpdatePrioritizationScheme); 1118 m_log.DebugFormat("[SCENE]: Using the {0} prioritization scheme", UpdatePrioritizationScheme);
1107 1119
1108 #endregion Interest Management 1120 #endregion Interest Management
1109 1121
1122 // The timer used by the Stopwatch class depends on the system hardware and operating system; inform
1123 // if the timer is based on a high-resolution performance counter or based on the system timer;
1124 // the performance counter will provide a more precise time than the system timer
1125 if (Stopwatch.IsHighResolution)
1126 m_log.InfoFormat("[SCENE]: Using high-resolution performance counter for statistics.");
1127 else
1128 m_log.InfoFormat("[SCENE]: Using system timer for statistics.");
1129
1110 // Acquire the statistics section of the OpenSim.ini file located 1130 // Acquire the statistics section of the OpenSim.ini file located
1111 // in the bin directory 1131 // in the bin directory
1112 IConfig statisticsConfig = m_config.Configs["Statistics"]; 1132 IConfig statisticsConfig = m_config.Configs["Statistics"];
1113 1133
1114 // Confirm that the statistics section existed in the configuration 1134 // Confirm that the statistics section existed in the configuration
1115 // file 1135 // file
1116 if (statisticsConfig != null) 1136 if (statisticsConfig != null)
1117 { 1137 {
1118 // Create the StatsReporter using the number of frames to store 1138 // Create the StatsReporter using the number of frames to store
1119 // for the frame time statistics, or 10 frames if the config 1139 // for the frame time statistics, or 10 frames if the config
1120 // file doesn't contain a value 1140 // file doesn't contain a value
1121 StatsReporter = new SimStatsReporter(this, 1141 StatsReporter = new SimStatsReporter(this,
1122 statisticsConfig.GetInt("NumberOfFrames", 10)); 1142 statisticsConfig.GetInt("NumberOfFrames",
1143 m_defaultNumberFramesStored));
1123 } 1144 }
1124 else 1145 else
1125 { 1146 {
1126 // Create a StatsReporter with the current scene and a default 1147 // Create a StatsReporter with the current scene and a default
1127 // 10 frames stored for the frame time statistics 1148 // 10 frames stored for the frame time statistics
1128 StatsReporter = new SimStatsReporter(this); 1149 StatsReporter = new SimStatsReporter(this);
1129 } 1150 }
1130 1151
1131 StatsReporter.OnSendStatsResult += SendSimStatsPackets; 1152 StatsReporter.OnSendStatsResult += SendSimStatsPackets;
1132 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 1153 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
1133 1154
1134 } 1155 }
1135 1156
1136 public Scene(RegionInfo regInfo, PhysicsScene physicsScene) : base(regInfo) 1157 public Scene(RegionInfo regInfo, PhysicsScene physicsScene)
1137 { 1158 : base(regInfo)
1159 {
1138 m_sceneGraph = new SceneGraph(this); 1160 m_sceneGraph = new SceneGraph(this);
1139 m_sceneGraph.PhysicsScene = physicsScene; 1161 m_sceneGraph.PhysicsScene = physicsScene;
1140 1162
@@ -1144,11 +1166,11 @@ namespace OpenSim.Region.Framework.Scenes
1144 // 1166 //
1145 // Out of memory 1167 // Out of memory
1146 // Operating system has killed the plugin 1168 // Operating system has killed the plugin
1147 m_sceneGraph.UnRecoverableError 1169 m_sceneGraph.UnRecoverableError
1148 += () => 1170 += () =>
1149 { 1171 {
1150 m_log.ErrorFormat("[SCENE]: Restarting region {0} due to unrecoverable physics crash", Name); 1172 m_log.ErrorFormat("[SCENE]: Restarting region {0} due to unrecoverable physics crash", Name);
1151 RestartNow(); 1173 RestartNow();
1152 }; 1174 };
1153 1175
1154 PhysicalPrims = true; 1176 PhysicalPrims = true;
@@ -1193,7 +1215,7 @@ namespace OpenSim.Region.Framework.Scenes
1193 IDialogModule dm = RequestModuleInterface<IDialogModule>(); 1215 IDialogModule dm = RequestModuleInterface<IDialogModule>();
1194 1216
1195 if (dm != null) 1217 if (dm != null)
1196 m_eventManager.OnPermissionError += dm.SendAlertToUser; 1218 m_eventManager.OnPermissionError += dm.SendAlertToUser;
1197 1219
1198 m_eventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; 1220 m_eventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement;
1199 } 1221 }
@@ -1223,7 +1245,7 @@ namespace OpenSim.Region.Framework.Scenes
1223 //int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY); 1245 //int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY);
1224 //if (resultX <= 1 && resultY <= 1) 1246 //if (resultX <= 1 && resultY <= 1)
1225 float dist = (float)Math.Max(DefaultDrawDistance, 1247 float dist = (float)Math.Max(DefaultDrawDistance,
1226 (float)Math.Max(RegionInfo.RegionSizeX, RegionInfo.RegionSizeY)); 1248 (float)Math.Max(RegionInfo.RegionSizeX, RegionInfo.RegionSizeY));
1227 uint newRegionX, newRegionY, thisRegionX, thisRegionY; 1249 uint newRegionX, newRegionY, thisRegionX, thisRegionY;
1228 Util.RegionHandleToRegionLoc(otherRegion.RegionHandle, out newRegionX, out newRegionY); 1250 Util.RegionHandleToRegionLoc(otherRegion.RegionHandle, out newRegionX, out newRegionY);
1229 Util.RegionHandleToRegionLoc(RegionInfo.RegionHandle, out thisRegionX, out thisRegionY); 1251 Util.RegionHandleToRegionLoc(RegionInfo.RegionHandle, out thisRegionX, out thisRegionY);
@@ -1247,7 +1269,7 @@ namespace OpenSim.Region.Framework.Scenes
1247 old.Add(otherRegion.RegionHandle); 1269 old.Add(otherRegion.RegionHandle);
1248 agent.DropOldNeighbours(old); 1270 agent.DropOldNeighbours(old);
1249 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc) 1271 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
1250 EntityTransferModule.EnableChildAgent(agent, otherRegion); 1272 EntityTransferModule.EnableChildAgent(agent, otherRegion);
1251 }); 1273 });
1252 } 1274 }
1253 catch (NullReferenceException) 1275 catch (NullReferenceException)
@@ -1260,8 +1282,8 @@ namespace OpenSim.Region.Framework.Scenes
1260 else 1282 else
1261 { 1283 {
1262 m_log.InfoFormat( 1284 m_log.InfoFormat(
1263 "[SCENE]: Got notice about far away Region: {0} at ({1}, {2})", 1285 "[SCENE]: Got notice about far away Region: {0} at ({1}, {2})",
1264 otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); 1286 otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
1265 } 1287 }
1266 } 1288 }
1267 } 1289 }
@@ -1339,7 +1361,7 @@ namespace OpenSim.Region.Framework.Scenes
1339 ForEachRootScenePresence(delegate(ScenePresence agent) 1361 ForEachRootScenePresence(delegate(ScenePresence agent)
1340 { 1362 {
1341 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc) 1363 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
1342 EntityTransferModule.EnableChildAgent(agent, r); 1364 EntityTransferModule.EnableChildAgent(agent, r);
1343 }); 1365 });
1344 } 1366 }
1345 catch (NullReferenceException) 1367 catch (NullReferenceException)
@@ -1377,14 +1399,14 @@ namespace OpenSim.Region.Framework.Scenes
1377 1399
1378 // Kick all ROOT agents with the message, 'The simulator is going down' 1400 // Kick all ROOT agents with the message, 'The simulator is going down'
1379 ForEachScenePresence(delegate(ScenePresence avatar) 1401 ForEachScenePresence(delegate(ScenePresence avatar)
1380 { 1402 {
1381 avatar.RemoveNeighbourRegion(RegionInfo.RegionHandle); 1403 avatar.RemoveNeighbourRegion(RegionInfo.RegionHandle);
1382 1404
1383 if (!avatar.IsChildAgent) 1405 if (!avatar.IsChildAgent)
1384 avatar.ControllingClient.Kick("The simulator is going down."); 1406 avatar.ControllingClient.Kick("The simulator is going down.");
1385 1407
1386 avatar.ControllingClient.SendShutdownConnectionNotice(); 1408 avatar.ControllingClient.SendShutdownConnectionNotice();
1387 }); 1409 });
1388 1410
1389 // Stop updating the scene objects and agents. 1411 // Stop updating the scene objects and agents.
1390 m_shuttingDown = true; 1412 m_shuttingDown = true;
@@ -1403,7 +1425,7 @@ namespace OpenSim.Region.Framework.Scenes
1403 m_sceneGraph.Close(); 1425 m_sceneGraph.Close();
1404 1426
1405 if (!GridService.DeregisterRegion(RegionInfo.RegionID)) 1427 if (!GridService.DeregisterRegion(RegionInfo.RegionID))
1406 m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); 1428 m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name);
1407 1429
1408 base.Close(); 1430 base.Close();
1409 1431
@@ -1434,12 +1456,12 @@ namespace OpenSim.Region.Framework.Scenes
1434 public void Start(bool startScripts) 1456 public void Start(bool startScripts)
1435 { 1457 {
1436 if (IsRunning) 1458 if (IsRunning)
1437 return; 1459 return;
1438 1460
1439 m_isRunning = true; 1461 m_isRunning = true;
1440 m_active = true; 1462 m_active = true;
1441 1463
1442// m_log.DebugFormat("[SCENE]: Starting Heartbeat timer for {0}", RegionInfo.RegionName); 1464 // m_log.DebugFormat("[SCENE]: Starting Heartbeat timer for {0}", RegionInfo.RegionName);
1443 if (m_heartbeatThread != null) 1465 if (m_heartbeatThread != null)
1444 { 1466 {
1445 m_heartbeatThread.Abort(); 1467 m_heartbeatThread.Abort();
@@ -1447,8 +1469,8 @@ namespace OpenSim.Region.Framework.Scenes
1447 } 1469 }
1448 1470
1449 m_heartbeatThread 1471 m_heartbeatThread
1450 = WorkManager.StartThread( 1472 = WorkManager.StartThread(
1451 Heartbeat, string.Format("Heartbeat-({0})", RegionInfo.RegionName.Replace(" ", "_")), ThreadPriority.Normal, false, false); 1473 Heartbeat, string.Format("Heartbeat-({0})", RegionInfo.RegionName.Replace(" ", "_")), ThreadPriority.Normal, false, false);
1452 1474
1453 StartScripts(); 1475 StartScripts();
1454 } 1476 }
@@ -1489,7 +1511,7 @@ namespace OpenSim.Region.Framework.Scenes
1489 Update(1); 1511 Update(1);
1490 1512
1491 WorkManager.StartThread( 1513 WorkManager.StartThread(
1492 Maintenance, string.Format("Maintenance ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, true); 1514 Maintenance, string.Format("Maintenance ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, true);
1493 1515
1494 Watchdog.GetCurrentThreadInfo().AlarmIfTimeout = true; 1516 Watchdog.GetCurrentThreadInfo().AlarmIfTimeout = true;
1495 m_lastFrameTick = Util.EnvironmentTickCount(); 1517 m_lastFrameTick = Util.EnvironmentTickCount();
@@ -1513,15 +1535,15 @@ namespace OpenSim.Region.Framework.Scenes
1513 private volatile bool m_isTimerUpdateRunning; 1535 private volatile bool m_isTimerUpdateRunning;
1514 1536
1515 private void Update(object sender, ElapsedEventArgs e) 1537 private void Update(object sender, ElapsedEventArgs e)
1516 { 1538 {
1517 if (m_isTimerUpdateRunning) 1539 if (m_isTimerUpdateRunning)
1518 return; 1540 return;
1519 1541
1520 m_isTimerUpdateRunning = true; 1542 m_isTimerUpdateRunning = true;
1521 1543
1522 // If the last frame did not complete on time, then immediately start the next update on the same thread 1544 // If the last frame did not complete on time, then immediately start the next update on the same thread
1523 // and ignore further timed updates until we have a frame that had spare time. 1545 // and ignore further timed updates until we have a frame that had spare time.
1524 while (!Update(1) && Active) {} 1546 while (!Update(1) && Active) { }
1525 1547
1526 if (!Active || m_shuttingDown) 1548 if (!Active || m_shuttingDown)
1527 { 1549 {
@@ -1547,7 +1569,7 @@ namespace OpenSim.Region.Framework.Scenes
1547 int previousMaintenanceTick; 1569 int previousMaintenanceTick;
1548 1570
1549 if (runs >= 0) 1571 if (runs >= 0)
1550 endRun = MaintenanceRun + runs; 1572 endRun = MaintenanceRun + runs;
1551 1573
1552 List<Vector3> coarseLocations; 1574 List<Vector3> coarseLocations;
1553 List<UUID> avatarUUIDs; 1575 List<UUID> avatarUUIDs;
@@ -1557,7 +1579,7 @@ namespace OpenSim.Region.Framework.Scenes
1557 runtc = Util.EnvironmentTickCount(); 1579 runtc = Util.EnvironmentTickCount();
1558 ++MaintenanceRun; 1580 ++MaintenanceRun;
1559 1581
1560// m_log.DebugFormat("[SCENE]: Maintenance run {0} in {1}", MaintenanceRun, Name); 1582 // m_log.DebugFormat("[SCENE]: Maintenance run {0} in {1}", MaintenanceRun, Name);
1561 1583
1562 // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client) 1584 // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client)
1563 if (MaintenanceRun % (m_update_coarse_locations / 10) == 0) 1585 if (MaintenanceRun % (m_update_coarse_locations / 10) == 0)
@@ -1572,7 +1594,7 @@ namespace OpenSim.Region.Framework.Scenes
1572 1594
1573 if (SendPeriodicAppearanceUpdates && MaintenanceRun % 60 == 0) 1595 if (SendPeriodicAppearanceUpdates && MaintenanceRun % 60 == 0)
1574 { 1596 {
1575// m_log.DebugFormat("[SCENE]: Sending periodic appearance updates"); 1597 // m_log.DebugFormat("[SCENE]: Sending periodic appearance updates");
1576 1598
1577 if (AvatarFactory != null) 1599 if (AvatarFactory != null)
1578 { 1600 {
@@ -1583,14 +1605,14 @@ namespace OpenSim.Region.Framework.Scenes
1583 // Delete temp-on-rez stuff 1605 // Delete temp-on-rez stuff
1584 if (MaintenanceRun % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1606 if (MaintenanceRun % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1585 { 1607 {
1586// m_log.DebugFormat("[SCENE]: Running temp-on-rez cleaning in {0}", Name); 1608 // m_log.DebugFormat("[SCENE]: Running temp-on-rez cleaning in {0}", Name);
1587 tmpMS = Util.EnvironmentTickCount(); 1609 tmpMS = Util.EnvironmentTickCount();
1588 m_cleaningTemps = true; 1610 m_cleaningTemps = true;
1589 1611
1590 WorkManager.RunInThread( 1612 WorkManager.RunInThread(
1591 delegate { CleanTempObjects(); m_cleaningTemps = false; }, 1613 delegate { CleanTempObjects(); m_cleaningTemps = false; },
1592 null, 1614 null,
1593 string.Format("CleanTempObjects ({0})", Name)); 1615 string.Format("CleanTempObjects ({0})", Name));
1594 1616
1595 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS); 1617 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS);
1596 } 1618 }
@@ -1601,19 +1623,19 @@ namespace OpenSim.Region.Framework.Scenes
1601 m_lastMaintenanceTick = Util.EnvironmentTickCount(); 1623 m_lastMaintenanceTick = Util.EnvironmentTickCount();
1602 runtc = Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, runtc); 1624 runtc = Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, runtc);
1603 runtc = MinMaintenanceTicks - runtc; 1625 runtc = MinMaintenanceTicks - runtc;
1604 1626
1605 if (runtc > 0) 1627 if (runtc > 0)
1606 m_maintenanceWaitEvent.WaitOne(runtc); 1628 m_maintenanceWaitEvent.WaitOne(runtc);
1607 1629
1608 // Optionally warn if a frame takes double the amount of time that it should. 1630 // Optionally warn if a frame takes double the amount of time that it should.
1609 if (DebugUpdates 1631 if (DebugUpdates
1610 && Util.EnvironmentTickCountSubtract( 1632 && Util.EnvironmentTickCountSubtract(
1611 m_lastMaintenanceTick, previousMaintenanceTick) > MinMaintenanceTicks * 2) 1633 m_lastMaintenanceTick, previousMaintenanceTick) > MinMaintenanceTicks * 2)
1612 m_log.WarnFormat( 1634 m_log.WarnFormat(
1613 "[SCENE]: Maintenance took {0} ms (desired max {1} ms) in {2}", 1635 "[SCENE]: Maintenance took {0} ms (desired max {1} ms) in {2}",
1614 Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, previousMaintenanceTick), 1636 Util.EnvironmentTickCountSubtract(m_lastMaintenanceTick, previousMaintenanceTick),
1615 MinMaintenanceTicks, 1637 MinMaintenanceTicks,
1616 RegionInfo.RegionName); 1638 RegionInfo.RegionName);
1617 } 1639 }
1618 } 1640 }
1619 1641
@@ -1622,14 +1644,14 @@ namespace OpenSim.Region.Framework.Scenes
1622 long? endFrame = null; 1644 long? endFrame = null;
1623 1645
1624 if (frames >= 0) 1646 if (frames >= 0)
1625 endFrame = Frame + frames; 1647 endFrame = Frame + frames;
1626 1648
1627 float physicsFPS = 0f; 1649 float physicsFPS = 0f;
1628 int previousFrameTick, tmpMS; 1650 int previousFrameTick, tmpMS;
1629 1651
1630 // These variables will be used to save the precise frame time using the 1652 // These variables will be used to save the precise frame time using the
1631 // Stopwatch class of Microsoft SDK; the times are recorded at the start 1653 // Stopwatch class of Microsoft SDK; the times are recorded at the start
1632 // and end of a particular section of code, and then used to calculate 1654 // and end of a parcticular section of code, and then used to calculate
1633 // the frame times, which are the sums of the sections for each given name 1655 // the frame times, which are the sums of the sections for each given name
1634 double preciseTotalFrameTime = 0.0; 1656 double preciseTotalFrameTime = 0.0;
1635 double preciseSimFrameTime = 0.0; 1657 double preciseSimFrameTime = 0.0;
@@ -1641,12 +1663,12 @@ namespace OpenSim.Region.Framework.Scenes
1641 // Begin the stopwatch to keep track of the time that the frame 1663 // Begin the stopwatch to keep track of the time that the frame
1642 // started running to determine how long the frame took to complete 1664 // started running to determine how long the frame took to complete
1643 totalFrameStopwatch.Start(); 1665 totalFrameStopwatch.Start();
1644 1666
1645 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) 1667 while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame))
1646 { 1668 {
1647 ++Frame; 1669 ++Frame;
1648 1670
1649// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1671 // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1650 1672
1651 agentMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; 1673 agentMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0;
1652 1674
@@ -1667,48 +1689,56 @@ namespace OpenSim.Region.Framework.Scenes
1667 // at this point in time, the precise values all begin 1689 // at this point in time, the precise values all begin
1668 // with the keyword precise 1690 // with the keyword precise
1669 tmpMS = Util.EnvironmentTickCount(); 1691 tmpMS = Util.EnvironmentTickCount();
1670
1671 simFrameStopwatch.Start(); 1692 simFrameStopwatch.Start();
1672 UpdateTerrain(); 1693 UpdateTerrain();
1673 1694
1674 // Get the simulation frame time that the avatar force 1695 // Get the simulation frame time that the avatar force
1675 // input took 1696 // input took
1676 simFrameStopwatch.Stop(); 1697 simFrameStopwatch.Stop();
1677 preciseSimFrameTime = 1698 preciseSimFrameTime =
1678 simFrameStopwatch.Elapsed.TotalMilliseconds; 1699 simFrameStopwatch.Elapsed.TotalMilliseconds;
1679 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS); 1700 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS);
1680 } 1701 }
1681 1702
1703 // At several points inside the code there was a need to
1704 // create a more precise measurement of time elapsed. This
1705 // led to the addition of variables that have a similar
1706 // function and thus remain tightly connected to their
1707 // original counterparts. However, the original code is
1708 // not receiving comments from our group because we don't
1709 // feel right modifying the code to that degree at this
1710 // point in time, the precise values all begin with the
1711 // keyword precise
1712
1682 tmpMS = Util.EnvironmentTickCount(); 1713 tmpMS = Util.EnvironmentTickCount();
1683 1714
1684 // Begin the stopwatch to track the time to prepare physics 1715 // Begin the stopwatch to track the time to prepare physics
1685 physicsFrameStopwatch.Start(); 1716 physicsFrameStopwatch.Start();
1686 if (PhysicsEnabled && Frame % m_update_physics == 0) 1717 if (PhysicsEnabled && Frame % m_update_physics == 0)
1687 m_sceneGraph.UpdatePreparePhysics(); 1718 m_sceneGraph.UpdatePreparePhysics();
1688 1719
1689 // Get the time it took to prepare the physics, this 1720 // Get the time it took to prepare the physics, this
1690 // would report the most precise time that physics was 1721 // would report the most precise time that physics was
1691 // running on the machine and should the physics not be 1722 // running on the machine and should the physics not be
1692 // enabled will report the time it took to check if physics 1723 // enabled will report the time it took to check if physics
1693 // was enabled 1724 // was enabled
1694 physicsFrameStopwatch.Stop(); 1725 physicsFrameStopwatch.Stop();
1695 precisePhysicsFrameTime = 1726 precisePhysicsFrameTime = physicsFrameStopwatch.Elapsed.TotalMilliseconds;
1696 physicsFrameStopwatch.Elapsed.TotalMilliseconds;
1697 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS); 1727 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1698 1728
1699 // Apply any pending avatar force input to the avatar's velocity 1729 // Apply any pending avatar force input to the avatar's velocity
1700 tmpMS = Util.EnvironmentTickCount(); 1730 tmpMS = Util.EnvironmentTickCount();
1701 simFrameStopwatch.Restart(); 1731 simFrameStopwatch.Restart();
1702 if (Frame % m_update_entitymovement == 0) 1732 if (Frame % m_update_entitymovement == 0)
1703 m_sceneGraph.UpdateScenePresenceMovement(); 1733 m_sceneGraph.UpdateScenePresenceMovement();
1704 1734
1705 // Get the simulation frame time that the avatar force input 1735 // Get the simulation frame time that the avatar force input
1706 // took 1736 // took
1707 simFrameStopwatch.Stop(); 1737 simFrameStopwatch.Stop();
1708 preciseSimFrameTime += 1738 preciseSimFrameTime +=
1709 simFrameStopwatch.Elapsed.TotalMilliseconds; 1739 simFrameStopwatch.Elapsed.TotalMilliseconds;
1710 agentMS = Util.EnvironmentTickCountSubtract(tmpMS); 1740 agentMS = Util.EnvironmentTickCountSubtract(tmpMS);
1711 1741
1712 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1742 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1713 // velocity 1743 // velocity
1714 tmpMS = Util.EnvironmentTickCount(); 1744 tmpMS = Util.EnvironmentTickCount();
@@ -1716,63 +1746,61 @@ namespace OpenSim.Region.Framework.Scenes
1716 if (Frame % m_update_physics == 0) 1746 if (Frame % m_update_physics == 0)
1717 { 1747 {
1718 if (PhysicsEnabled) 1748 if (PhysicsEnabled)
1719 physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameSeconds); 1749 physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameSeconds);
1720 1750
1721 if (SynchronizeScene != null) 1751 if (SynchronizeScene != null)
1722 SynchronizeScene(this); 1752 SynchronizeScene(this);
1723 } 1753 }
1724 1754
1725 // Add the main physics update time to the prepare physics 1755 // Add the main physics update time to the prepare physics time
1726 // time
1727 physicsFrameStopwatch.Stop(); 1756 physicsFrameStopwatch.Stop();
1728 precisePhysicsFrameTime += 1757 precisePhysicsFrameTime += physicsFrameStopwatch.Elapsed.TotalMilliseconds;
1729 physicsFrameStopwatch.Elapsed.TotalMilliseconds;
1730 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS); 1758 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS);
1731 1759
1732 // Start the stopwatch for the remainder of the simulation 1760 // Start the stopwatch for the remainder of the simulation
1733 simFrameStopwatch.Restart(); 1761 simFrameStopwatch.Restart();
1734 tmpMS = Util.EnvironmentTickCount(); 1762 tmpMS = Util.EnvironmentTickCount();
1735 1763
1736 // Check if any objects have reached their targets 1764 // Check if any objects have reached their targets
1737 CheckAtTargets(); 1765 CheckAtTargets();
1738 1766
1739 // Update SceneObjectGroups that have scheduled themselves for updates 1767 // Update SceneObjectGroups that have scheduled themselves for updates
1740 // Objects queue their updates onto all scene presences 1768 // Objects queue their updates onto all scene presences
1741 if (Frame % m_update_objects == 0) 1769 if (Frame % m_update_objects == 0)
1742 m_sceneGraph.UpdateObjectGroups(); 1770 m_sceneGraph.UpdateObjectGroups();
1743 1771
1744 // Run through all ScenePresences looking for updates 1772 // Run through all ScenePresences looking for updates
1745 // Presence updates and queued object updates for each presence are sent to clients 1773 // Presence updates and queued object updates for each presence are sent to clients
1746 if (Frame % m_update_presences == 0) 1774 if (Frame % m_update_presences == 0)
1747 m_sceneGraph.UpdatePresences(); 1775 m_sceneGraph.UpdatePresences();
1748 1776
1749 agentMS += Util.EnvironmentTickCountSubtract(tmpMS); 1777 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1750 1778
1751 if (Frame % m_update_events == 0) 1779 if (Frame % m_update_events == 0)
1752 { 1780 {
1753 tmpMS = Util.EnvironmentTickCount(); 1781 tmpMS = Util.EnvironmentTickCount();
1754 UpdateEvents(); 1782 UpdateEvents();
1755 eventMS = Util.EnvironmentTickCountSubtract(tmpMS); 1783 eventMS = Util.EnvironmentTickCountSubtract(tmpMS);
1756 } 1784 }
1757 1785
1758 if (PeriodicBackup && Frame % m_update_backup == 0) 1786 if (PeriodicBackup && Frame % m_update_backup == 0)
1759 { 1787 {
1760 tmpMS = Util.EnvironmentTickCount(); 1788 tmpMS = Util.EnvironmentTickCount();
1761 UpdateStorageBackup(); 1789 UpdateStorageBackup();
1762 backupMS = Util.EnvironmentTickCountSubtract(tmpMS); 1790 backupMS = Util.EnvironmentTickCountSubtract(tmpMS);
1763 } 1791 }
1764 1792
1765 //if (Frame % m_update_land == 0) 1793 //if (Frame % m_update_land == 0)
1766 //{ 1794 //{
1767 // int ldMS = Util.EnvironmentTickCount(); 1795 // int ldMS = Util.EnvironmentTickCount();
1768 // UpdateLand(); 1796 // UpdateLand();
1769 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1797 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1770 //} 1798 //}
1771 1799
1772 if (!LoginsEnabled && Frame == 20) 1800 if (!LoginsEnabled && Frame == 20)
1773 { 1801 {
1774 // m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock); 1802 // m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock);
1775 1803
1776 // In 99.9% of cases it is a bad idea to manually force garbage collection. However, 1804 // In 99.9% of cases it is a bad idea to manually force garbage collection. However,
1777 // this is a rare case where we know we have just went through a long cycle of heap 1805 // this is a rare case where we know we have just went through a long cycle of heap
1778 // allocations, and there is no more work to be done until someone logs in 1806 // allocations, and there is no more work to be done until someone logs in
@@ -1787,7 +1815,7 @@ namespace OpenSim.Region.Framework.Scenes
1787 } 1815 }
1788 1816
1789 m_sceneGridService.InformNeighborsThatRegionisUp( 1817 m_sceneGridService.InformNeighborsThatRegionisUp(
1790 RequestModuleInterface<INeighbourService>(), RegionInfo); 1818 RequestModuleInterface<INeighbourService>(), RegionInfo);
1791 1819
1792 // Region ready should always be set 1820 // Region ready should always be set
1793 Ready = true; 1821 Ready = true;
@@ -1798,7 +1826,7 @@ namespace OpenSim.Region.Framework.Scenes
1798 if (m_sceneGraph.GetActiveScriptsCount() == 0) 1826 if (m_sceneGraph.GetActiveScriptsCount() == 0)
1799 { 1827 {
1800 // In this case, we leave it to the IRegionReadyModule to enable logins 1828 // In this case, we leave it to the IRegionReadyModule to enable logins
1801 1829
1802 // LoginLock can currently only be set by a region module implementation. 1830 // LoginLock can currently only be set by a region module implementation.
1803 // If somehow this hasn't been done then the quickest way to bugfix is to see the 1831 // If somehow this hasn't been done then the quickest way to bugfix is to see the
1804 // NullReferenceException 1832 // NullReferenceException
@@ -1811,18 +1839,18 @@ namespace OpenSim.Region.Framework.Scenes
1811 catch (Exception e) 1839 catch (Exception e)
1812 { 1840 {
1813 m_log.ErrorFormat( 1841 m_log.ErrorFormat(
1814 "[SCENE]: Failed on region {0} with exception {1}{2}", 1842 "[SCENE]: Failed on region {0} with exception {1}{2}",
1815 RegionInfo.RegionName, e.Message, e.StackTrace); 1843 RegionInfo.RegionName, e.Message, e.StackTrace);
1816 } 1844 }
1817 1845
1818 EventManager.TriggerRegionHeartbeatEnd(this); 1846 EventManager.TriggerRegionHeartbeatEnd(this);
1819 otherMS = eventMS + backupMS + terrainMS + landMS; 1847 otherMS = eventMS + backupMS + terrainMS + landMS;
1820 1848
1821 // Get the elapsed time for the simulation frame 1849 // Get the elapsed time for the simulation frame
1822 simFrameStopwatch.Stop(); 1850 simFrameStopwatch.Stop();
1823 preciseSimFrameTime += 1851 preciseSimFrameTime +=
1824 simFrameStopwatch.Elapsed.TotalMilliseconds; 1852 simFrameStopwatch.Elapsed.TotalMilliseconds;
1825 1853
1826 if (!UpdateOnTimer) 1854 if (!UpdateOnTimer)
1827 { 1855 {
1828 Watchdog.UpdateThread(); 1856 Watchdog.UpdateThread();
@@ -1830,9 +1858,9 @@ namespace OpenSim.Region.Framework.Scenes
1830 spareMS = MinFrameTicks - Util.EnvironmentTickCountSubtract(m_lastFrameTick); 1858 spareMS = MinFrameTicks - Util.EnvironmentTickCountSubtract(m_lastFrameTick);
1831 1859
1832 if (spareMS > 0) 1860 if (spareMS > 0)
1833 m_updateWaitEvent.WaitOne(spareMS); 1861 m_updateWaitEvent.WaitOne(spareMS);
1834 else 1862 else
1835 spareMS = 0; 1863 spareMS = 0;
1836 } 1864 }
1837 else 1865 else
1838 { 1866 {
@@ -1841,15 +1869,15 @@ namespace OpenSim.Region.Framework.Scenes
1841 1869
1842 // Get the total frame time 1870 // Get the total frame time
1843 totalFrameStopwatch.Stop(); 1871 totalFrameStopwatch.Stop();
1844 preciseTotalFrameTime = 1872 preciseTotalFrameTime =
1845 totalFrameStopwatch.Elapsed.TotalMilliseconds; 1873 totalFrameStopwatch.Elapsed.TotalMilliseconds;
1846 1874
1847 // Restart the stopwatch for the total time of the next frame 1875 // Restart the stopwatch for the total time of the next frame
1848 totalFrameStopwatch.Restart(); 1876 totalFrameStopwatch.Restart();
1849 1877
1850 previousFrameTick = m_lastFrameTick; 1878 previousFrameTick = m_lastFrameTick;
1851 frameMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick); 1879 frameMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick);
1852 m_lastFrameTick = Util.EnvironmentTickCount(); 1880 m_lastFrameTick = Util.EnvironmentTickCount();
1853 1881
1854 // if (Frame%m_update_avatars == 0) 1882 // if (Frame%m_update_avatars == 0)
1855 // UpdateInWorldTime(); 1883 // UpdateInWorldTime();
@@ -1866,37 +1894,40 @@ namespace OpenSim.Region.Framework.Scenes
1866 1894
1867 // Send the correct time values to the stats reporter for the 1895 // Send the correct time values to the stats reporter for the
1868 // frame times 1896 // frame times
1869 StatsReporter.addFrameTimeMilliseconds(preciseTotalFrameTime, 1897 StatsReporter.addFrameTimeMilliseconds(preciseTotalFrameTime,
1870 preciseSimFrameTime, precisePhysicsFrameTime, 0.0); 1898 preciseSimFrameTime, precisePhysicsFrameTime, 0.0);
1871 1899
1872 // Send the correct number of frames that the physics library 1900 // Send the correct number of frames that the physics library
1873 // has processed to the stats reporter 1901 // has processed to the stats reporter
1874 StatsReporter.addPhysicsFrame(1); 1902 StatsReporter.addPhysicsFrame(1);
1875 1903
1876 // Optionally warn if a frame takes double the amount of time that it should. 1904 // Optionally warn if a frame takes double the amount of time that it should.
1877 if (DebugUpdates 1905 if (DebugUpdates
1878 && Util.EnvironmentTickCountSubtract( 1906 && Util.EnvironmentTickCountSubtract(
1879 m_lastFrameTick, previousFrameTick) > MinFrameTicks * 2) 1907 m_lastFrameTick, previousFrameTick) > MinFrameTicks * 2)
1880 m_log.WarnFormat( 1908 m_log.WarnFormat(
1881 "[SCENE]: Frame took {0} ms (desired max {1} ms) in {2}", 1909 "[SCENE]: Frame took {0} ms (desired max {1} ms) in {2}",
1882 Util.EnvironmentTickCountSubtract(m_lastFrameTick, previousFrameTick), 1910 Util.EnvironmentTickCountSubtract(m_lastFrameTick, previousFrameTick),
1883 MinFrameTicks, 1911 MinFrameTicks,
1884 RegionInfo.RegionName); 1912 RegionInfo.RegionName);
1885 } 1913 }
1886 1914
1915 // Finished updating scene frame, so stop the total frame's Stopwatch
1916 totalFrameStopwatch.Stop();
1917
1887 return spareMS >= 0; 1918 return spareMS >= 0;
1888 } 1919 }
1889 1920
1890 public void AddGroupTarget(SceneObjectGroup grp) 1921 public void AddGroupTarget(SceneObjectGroup grp)
1891 { 1922 {
1892 lock (m_groupsWithTargets) 1923 lock (m_groupsWithTargets)
1893 m_groupsWithTargets[grp.UUID] = grp; 1924 m_groupsWithTargets[grp.UUID] = grp;
1894 } 1925 }
1895 1926
1896 public void RemoveGroupTarget(SceneObjectGroup grp) 1927 public void RemoveGroupTarget(SceneObjectGroup grp)
1897 { 1928 {
1898 lock (m_groupsWithTargets) 1929 lock (m_groupsWithTargets)
1899 m_groupsWithTargets.Remove(grp.UUID); 1930 m_groupsWithTargets.Remove(grp.UUID);
1900 } 1931 }
1901 1932
1902 private void CheckAtTargets() 1933 private void CheckAtTargets()
@@ -1906,13 +1937,13 @@ namespace OpenSim.Region.Framework.Scenes
1906 lock (m_groupsWithTargets) 1937 lock (m_groupsWithTargets)
1907 { 1938 {
1908 if (m_groupsWithTargets.Count != 0) 1939 if (m_groupsWithTargets.Count != 0)
1909 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); 1940 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1910 } 1941 }
1911 1942
1912 if (objs != null) 1943 if (objs != null)
1913 { 1944 {
1914 foreach (SceneObjectGroup entry in objs) 1945 foreach (SceneObjectGroup entry in objs)
1915 entry.checkAtTargets(); 1946 entry.checkAtTargets();
1916 } 1947 }
1917 } 1948 }
1918 1949
@@ -1955,7 +1986,7 @@ namespace OpenSim.Region.Framework.Scenes
1955 { 1986 {
1956 m_eventManager.TriggerOnFrame(); 1987 m_eventManager.TriggerOnFrame();
1957 } 1988 }
1958 1989
1959 /// <summary> 1990 /// <summary>
1960 /// Backup the scene. 1991 /// Backup the scene.
1961 /// </summary> 1992 /// </summary>
@@ -1995,13 +2026,13 @@ namespace OpenSim.Region.Framework.Scenes
1995 // We must fill in a null-terminated 'empty' string here since bytes[0] will crash viewer 3. 2026 // We must fill in a null-terminated 'empty' string here since bytes[0] will crash viewer 3.
1996 msg.binaryBucket = Util.StringToBytes256("\0"); 2027 msg.binaryBucket = Util.StringToBytes256("\0");
1997 if (ret.Value.count > 1) 2028 if (ret.Value.count > 1)
1998 msg.message = string.Format("Your {0} objects were returned from {1} in region {2} due to {3}", ret.Value.count, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason); 2029 msg.message = string.Format("Your {0} objects were returned from {1} in region {2} due to {3}", ret.Value.count, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason);
1999 else 2030 else
2000 msg.message = string.Format("Your object {0} was returned from {1} in region {2} due to {3}", ret.Value.objectName, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason); 2031 msg.message = string.Format("Your object {0} was returned from {1} in region {2} due to {3}", ret.Value.objectName, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason);
2001 2032
2002 IMessageTransferModule tr = RequestModuleInterface<IMessageTransferModule>(); 2033 IMessageTransferModule tr = RequestModuleInterface<IMessageTransferModule>();
2003 if (tr != null) 2034 if (tr != null)
2004 tr.SendInstantMessage(msg, delegate(bool success) {}); 2035 tr.SendInstantMessage(msg, delegate(bool success) { });
2005 } 2036 }
2006 m_returns.Clear(); 2037 m_returns.Clear();
2007 } 2038 }
@@ -2092,7 +2123,7 @@ namespace OpenSim.Region.Framework.Scenes
2092 IConfig terrainConfig = m_config.Configs["Terrain"]; 2123 IConfig terrainConfig = m_config.Configs["Terrain"];
2093 String m_InitialTerrain = "pinhead-island"; 2124 String m_InitialTerrain = "pinhead-island";
2094 if (terrainConfig != null) 2125 if (terrainConfig != null)
2095 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); 2126 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
2096 2127
2097 m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain); 2128 m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain);
2098 Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ); 2129 Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
@@ -2107,11 +2138,11 @@ namespace OpenSim.Region.Framework.Scenes
2107 catch (IOException e) 2138 catch (IOException e)
2108 { 2139 {
2109 m_log.WarnFormat( 2140 m_log.WarnFormat(
2110 "[TERRAIN]: Scene.cs: LoadWorldMap() - Regenerating as failed with exception {0}{1}", 2141 "[TERRAIN]: Scene.cs: LoadWorldMap() - Regenerating as failed with exception {0}{1}",
2111 e.Message, e.StackTrace); 2142 e.Message, e.StackTrace);
2112 2143
2113 // Non standard region size. If there's an old terrain in the database, it might read past the buffer 2144 // Non standard region size. If there's an old terrain in the database, it might read past the buffer
2114 #pragma warning disable 0162 2145#pragma warning disable 0162
2115 if ((int)Constants.RegionSize != 256) 2146 if ((int)Constants.RegionSize != 256)
2116 { 2147 {
2117 Heightmap = new TerrainChannel(); 2148 Heightmap = new TerrainChannel();
@@ -2122,7 +2153,7 @@ namespace OpenSim.Region.Framework.Scenes
2122 catch (Exception e) 2153 catch (Exception e)
2123 { 2154 {
2124 m_log.WarnFormat( 2155 m_log.WarnFormat(
2125 "[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception {0}{1}", e.Message, e.StackTrace); 2156 "[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception {0}{1}", e.Message, e.StackTrace);
2126 } 2157 }
2127 } 2158 }
2128 2159
@@ -2139,18 +2170,18 @@ namespace OpenSim.Region.Framework.Scenes
2139 //// stored in the GridService, because that's what the world map module uses 2170 //// stored in the GridService, because that's what the world map module uses
2140 //// to send the map image UUIDs (of other regions) to the viewer... 2171 //// to send the map image UUIDs (of other regions) to the viewer...
2141 if (m_generateMaptiles) 2172 if (m_generateMaptiles)
2142 RegenerateMaptile(); 2173 RegenerateMaptile();
2143 2174
2144 GridRegion region = new GridRegion(RegionInfo); 2175 GridRegion region = new GridRegion(RegionInfo);
2145 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); 2176 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region);
2146// m_log.DebugFormat("[SCENE]: RegisterRegionWithGrid. name={0},id={1},loc=<{2},{3}>,size=<{4},{5}>", 2177 // m_log.DebugFormat("[SCENE]: RegisterRegionWithGrid. name={0},id={1},loc=<{2},{3}>,size=<{4},{5}>",
2147// m_regionName, 2178 // m_regionName,
2148// RegionInfo.RegionID, 2179 // RegionInfo.RegionID,
2149// RegionInfo.RegionLocX, RegionInfo.RegionLocY, 2180 // RegionInfo.RegionLocX, RegionInfo.RegionLocY,
2150// RegionInfo.RegionSizeX, RegionInfo.RegionSizeY); 2181 // RegionInfo.RegionSizeX, RegionInfo.RegionSizeY);
2151 2182
2152 if (error != String.Empty) 2183 if (error != String.Empty)
2153 throw new Exception(error); 2184 throw new Exception(error);
2154 } 2185 }
2155 2186
2156 #endregion 2187 #endregion
@@ -2209,7 +2240,7 @@ namespace OpenSim.Region.Framework.Scenes
2209 rootPart.TrimPermissions(); 2240 rootPart.TrimPermissions();
2210 2241
2211 // Don't do this here - it will get done later on when sculpt data is loaded. 2242 // Don't do this here - it will get done later on when sculpt data is loaded.
2212// group.CheckSculptAndLoad(); 2243 // group.CheckSculptAndLoad();
2213 } 2244 }
2214 2245
2215 LoadingPrims = false; 2246 LoadingPrims = false;
@@ -2219,15 +2250,15 @@ namespace OpenSim.Region.Framework.Scenes
2219 public bool SupportsRayCastFiltered() 2250 public bool SupportsRayCastFiltered()
2220 { 2251 {
2221 if (PhysicsScene == null) 2252 if (PhysicsScene == null)
2222 return false; 2253 return false;
2223 return PhysicsScene.SupportsRaycastWorldFiltered(); 2254 return PhysicsScene.SupportsRaycastWorldFiltered();
2224 } 2255 }
2225 2256
2226 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) 2257 public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
2227 { 2258 {
2228 if (PhysicsScene == null) 2259 if (PhysicsScene == null)
2229 return null; 2260 return null;
2230 return PhysicsScene.RaycastWorld(position, direction, length, Count,filter); 2261 return PhysicsScene.RaycastWorld(position, direction, length, Count, filter);
2231 } 2262 }
2232 2263
2233 /// <summary> 2264 /// <summary>
@@ -2295,7 +2326,7 @@ namespace OpenSim.Region.Framework.Scenes
2295 //And in cases when we weren't rezzing from inventory we were re-adding the 0.25 straight after calling this method 2326 //And in cases when we weren't rezzing from inventory we were re-adding the 0.25 straight after calling this method
2296 // Un-offset the prim (it gets offset later by the consumer method) 2327 // Un-offset the prim (it gets offset later by the consumer method)
2297 //pos.Z -= 0.25F; 2328 //pos.Z -= 0.25F;
2298 2329
2299 } 2330 }
2300 2331
2301 return pos; 2332 return pos;
@@ -2312,7 +2343,7 @@ namespace OpenSim.Region.Framework.Scenes
2312 if (ei.HitTF) 2343 if (ei.HitTF)
2313 { 2344 {
2314 pos = ei.ipoint; 2345 pos = ei.ipoint;
2315 } 2346 }
2316 else 2347 else
2317 { 2348 {
2318 // fall back to our stupid functionality 2349 // fall back to our stupid functionality
@@ -2348,8 +2379,8 @@ namespace OpenSim.Region.Framework.Scenes
2348 /// <param name="RayTargetID"></param> 2379 /// <param name="RayTargetID"></param>
2349 /// <param name="RayEndIsIntersection"></param> 2380 /// <param name="RayEndIsIntersection"></param>
2350 public virtual void AddNewPrim(UUID ownerID, UUID groupID, Vector3 RayEnd, Quaternion rot, PrimitiveBaseShape shape, 2381 public virtual void AddNewPrim(UUID ownerID, UUID groupID, Vector3 RayEnd, Quaternion rot, PrimitiveBaseShape shape,
2351 byte bypassRaycast, Vector3 RayStart, UUID RayTargetID, 2382 byte bypassRaycast, Vector3 RayStart, UUID RayTargetID,
2352 byte RayEndIsIntersection) 2383 byte RayEndIsIntersection)
2353 { 2384 {
2354 Vector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new Vector3(0.5f, 0.5f, 0.5f), false); 2385 Vector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new Vector3(0.5f, 0.5f, 0.5f), false);
2355 2386
@@ -2364,18 +2395,18 @@ namespace OpenSim.Region.Framework.Scenes
2364 { 2395 {
2365 IClientAPI client = null; 2396 IClientAPI client = null;
2366 if (TryGetClient(ownerID, out client)) 2397 if (TryGetClient(ownerID, out client))
2367 client.SendAlertMessage("You cannot create objects here."); 2398 client.SendAlertMessage("You cannot create objects here.");
2368 } 2399 }
2369 } 2400 }
2370 2401
2371 public virtual SceneObjectGroup AddNewPrim( 2402 public virtual SceneObjectGroup AddNewPrim(
2372 UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) 2403 UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
2373 { 2404 {
2374 //m_log.DebugFormat( 2405 //m_log.DebugFormat(
2375 // "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName); 2406 // "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName);
2376 2407
2377 SceneObjectGroup sceneObject = null; 2408 SceneObjectGroup sceneObject = null;
2378 2409
2379 // If an entity creator has been registered for this prim type then use that 2410 // If an entity creator has been registered for this prim type then use that
2380 if (m_entityCreators.ContainsKey((PCode)shape.PCode)) 2411 if (m_entityCreators.ContainsKey((PCode)shape.PCode))
2381 { 2412 {
@@ -2390,13 +2421,13 @@ namespace OpenSim.Region.Framework.Scenes
2390 } 2421 }
2391 2422
2392 if (UserManagementModule != null) 2423 if (UserManagementModule != null)
2393 sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID); 2424 sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID);
2394 2425
2395 sceneObject.ScheduleGroupForFullUpdate(); 2426 sceneObject.ScheduleGroupForFullUpdate();
2396 2427
2397 return sceneObject; 2428 return sceneObject;
2398 } 2429 }
2399 2430
2400 /// <summary> 2431 /// <summary>
2401 /// Add an object into the scene that has come from storage 2432 /// Add an object into the scene that has come from storage
2402 /// </summary> 2433 /// </summary>
@@ -2418,7 +2449,7 @@ namespace OpenSim.Region.Framework.Scenes
2418 /// true if the object was added, false if an object with the same uuid was already in the scene 2449 /// true if the object was added, false if an object with the same uuid was already in the scene
2419 /// </returns> 2450 /// </returns>
2420 public bool AddRestoredSceneObject( 2451 public bool AddRestoredSceneObject(
2421 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 2452 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
2422 { 2453 {
2423 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) 2454 if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates))
2424 { 2455 {
@@ -2429,7 +2460,7 @@ namespace OpenSim.Region.Framework.Scenes
2429 return false; 2460 return false;
2430 2461
2431 } 2462 }
2432 2463
2433 /// <summary> 2464 /// <summary>
2434 /// Add an object into the scene that has come from storage 2465 /// Add an object into the scene that has come from storage
2435 /// </summary> 2466 /// </summary>
@@ -2447,7 +2478,7 @@ namespace OpenSim.Region.Framework.Scenes
2447 /// true if the object was added, false if an object with the same uuid was already in the scene 2478 /// true if the object was added, false if an object with the same uuid was already in the scene
2448 /// </returns> 2479 /// </returns>
2449 public bool AddRestoredSceneObject( 2480 public bool AddRestoredSceneObject(
2450 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) 2481 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted)
2451 { 2482 {
2452 return AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, true); 2483 return AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, true);
2453 } 2484 }
@@ -2465,7 +2496,7 @@ namespace OpenSim.Region.Framework.Scenes
2465 { 2496 {
2466 return AddNewSceneObject(sceneObject, attachToBackup, true); 2497 return AddNewSceneObject(sceneObject, attachToBackup, true);
2467 } 2498 }
2468 2499
2469 /// <summary> 2500 /// <summary>
2470 /// Add a newly created object to the scene 2501 /// Add a newly created object to the scene
2471 /// </summary> 2502 /// </summary>
@@ -2480,16 +2511,16 @@ namespace OpenSim.Region.Framework.Scenes
2480 /// </param> 2511 /// </param>
2481 /// <returns>true if the object was added. false if not</returns> 2512 /// <returns>true if the object was added. false if not</returns>
2482 public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) 2513 public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
2483 { 2514 {
2484 if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates)) 2515 if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates))
2485 { 2516 {
2486 EventManager.TriggerObjectAddedToScene(sceneObject); 2517 EventManager.TriggerObjectAddedToScene(sceneObject);
2487 return true; 2518 return true;
2488 } 2519 }
2489 2520
2490 return false; 2521 return false;
2491 } 2522 }
2492 2523
2493 /// <summary> 2524 /// <summary>
2494 /// Add a newly created object to the scene. 2525 /// Add a newly created object to the scene.
2495 /// </summary> 2526 /// </summary>
@@ -2503,10 +2534,10 @@ namespace OpenSim.Region.Framework.Scenes
2503 /// <param name="vel">Velocity of the object. This parameter only has an effect if the object is physical</param> 2534 /// <param name="vel">Velocity of the object. This parameter only has an effect if the object is physical</param>
2504 /// <returns></returns> 2535 /// <returns></returns>
2505 public bool AddNewSceneObject( 2536 public bool AddNewSceneObject(
2506 SceneObjectGroup sceneObject, bool attachToBackup, Vector3? pos, Quaternion? rot, Vector3 vel) 2537 SceneObjectGroup sceneObject, bool attachToBackup, Vector3? pos, Quaternion? rot, Vector3 vel)
2507 { 2538 {
2508 if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel)) 2539 if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel))
2509 { 2540 {
2510 EventManager.TriggerObjectAddedToScene(sceneObject); 2541 EventManager.TriggerObjectAddedToScene(sceneObject);
2511 return true; 2542 return true;
2512 } 2543 }
@@ -2528,7 +2559,7 @@ namespace OpenSim.Region.Framework.Scenes
2528 { 2559 {
2529 SceneObjectGroup sog = (SceneObjectGroup)e; 2560 SceneObjectGroup sog = (SceneObjectGroup)e;
2530 if (!sog.IsAttachment) 2561 if (!sog.IsAttachment)
2531 DeleteSceneObject((SceneObjectGroup)e, false); 2562 DeleteSceneObject((SceneObjectGroup)e, false);
2532 } 2563 }
2533 } 2564 }
2534 } 2565 }
@@ -2554,13 +2585,13 @@ namespace OpenSim.Region.Framework.Scenes
2554 /// <param name="silent">Suppress broadcasting changes to other clients.</param> 2585 /// <param name="silent">Suppress broadcasting changes to other clients.</param>
2555 /// <param name="removeScripts">If true, then scripts are removed. If false, then they are only stopped.</para> 2586 /// <param name="removeScripts">If true, then scripts are removed. If false, then they are only stopped.</para>
2556 public void DeleteSceneObject(SceneObjectGroup group, bool silent, bool removeScripts) 2587 public void DeleteSceneObject(SceneObjectGroup group, bool silent, bool removeScripts)
2557 { 2588 {
2558// m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID); 2589 // m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID);
2559 2590
2560 if (removeScripts) 2591 if (removeScripts)
2561 group.RemoveScriptInstances(true); 2592 group.RemoveScriptInstances(true);
2562 else 2593 else
2563 group.StopScriptInstances(); 2594 group.StopScriptInstances();
2564 2595
2565 SceneObjectPart[] partList = group.Parts; 2596 SceneObjectPart[] partList = group.Parts;
2566 2597
@@ -2590,7 +2621,7 @@ namespace OpenSim.Region.Framework.Scenes
2590 2621
2591 group.DeleteGroupFromScene(silent); 2622 group.DeleteGroupFromScene(silent);
2592 2623
2593// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2624 // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2594 } 2625 }
2595 2626
2596 /// <summary> 2627 /// <summary>
@@ -2610,12 +2641,12 @@ namespace OpenSim.Region.Framework.Scenes
2610 // database update, because RemoveObject() works by searching on the SceneGroupID. 2641 // database update, because RemoveObject() works by searching on the SceneGroupID.
2611 // This is an expensive thing to do so only do it if absolutely necessary. 2642 // This is an expensive thing to do so only do it if absolutely necessary.
2612 if (so.GroupContainsForeignPrims) 2643 if (so.GroupContainsForeignPrims)
2613 ForceSceneObjectBackup(so); 2644 ForceSceneObjectBackup(so);
2614 2645
2615 so.DetachFromBackup(); 2646 so.DetachFromBackup();
2616 SimulationDataService.RemoveObject(so.UUID, RegionInfo.RegionID); 2647 SimulationDataService.RemoveObject(so.UUID, RegionInfo.RegionID);
2617 } 2648 }
2618 2649
2619 // We need to keep track of this state in case this group is still queued for further backup. 2650 // We need to keep track of this state in case this group is still queued for further backup.
2620 so.IsDeleted = true; 2651 so.IsDeleted = true;
2621 2652
@@ -2635,9 +2666,9 @@ namespace OpenSim.Region.Framework.Scenes
2635 public void CrossPrimGroupIntoNewRegion(Vector3 attemptedPosition, SceneObjectGroup grp, bool silent) 2666 public void CrossPrimGroupIntoNewRegion(Vector3 attemptedPosition, SceneObjectGroup grp, bool silent)
2636 { 2667 {
2637 if (grp == null) 2668 if (grp == null)
2638 return; 2669 return;
2639 if (grp.IsDeleted) 2670 if (grp.IsDeleted)
2640 return; 2671 return;
2641 2672
2642 if (grp.RootPart.DIE_AT_EDGE) 2673 if (grp.RootPart.DIE_AT_EDGE)
2643 { 2674 {
@@ -2671,7 +2702,7 @@ namespace OpenSim.Region.Framework.Scenes
2671 } 2702 }
2672 2703
2673 if (EntityTransferModule != null) 2704 if (EntityTransferModule != null)
2674 EntityTransferModule.Cross(grp, attemptedPosition, silent); 2705 EntityTransferModule.Cross(grp, attemptedPosition, silent);
2675 } 2706 }
2676 2707
2677 // Simple test to see if a position is in the current region. 2708 // Simple test to see if a position is in the current region.
@@ -2684,14 +2715,14 @@ namespace OpenSim.Region.Framework.Scenes
2684 int xx = (int)Math.Floor(pos.X); 2715 int xx = (int)Math.Floor(pos.X);
2685 int yy = (int)Math.Floor(pos.Y); 2716 int yy = (int)Math.Floor(pos.Y);
2686 if (xx < 0 || yy < 0) 2717 if (xx < 0 || yy < 0)
2687 return false; 2718 return false;
2688 2719
2689 IRegionCombinerModule regionCombinerModule = RequestModuleInterface<IRegionCombinerModule>(); 2720 IRegionCombinerModule regionCombinerModule = RequestModuleInterface<IRegionCombinerModule>();
2690 if (regionCombinerModule == null) 2721 if (regionCombinerModule == null)
2691 { 2722 {
2692 // Regular region. Just check for region size 2723 // Regular region. Just check for region size
2693 if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY ) 2724 if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY)
2694 ret = true; 2725 ret = true;
2695 } 2726 }
2696 else 2727 else
2697 { 2728 {
@@ -2725,7 +2756,7 @@ namespace OpenSim.Region.Framework.Scenes
2725 } 2756 }
2726 2757
2727 if (!EntityTransferModule.HandleIncomingSceneObject(newObject, newPosition)) 2758 if (!EntityTransferModule.HandleIncomingSceneObject(newObject, newPosition))
2728 return false; 2759 return false;
2729 2760
2730 // Do this as late as possible so that listeners have full access to the incoming object 2761 // Do this as late as possible so that listeners have full access to the incoming object
2731 EventManager.TriggerOnIncomingSceneObject(newObject); 2762 EventManager.TriggerOnIncomingSceneObject(newObject);
@@ -2746,13 +2777,13 @@ namespace OpenSim.Region.Framework.Scenes
2746 // 2777 //
2747 SceneObjectPart[] parts = sceneObject.Parts; 2778 SceneObjectPart[] parts = sceneObject.Parts;
2748 for (int i = 0; i < parts.Length; i++) 2779 for (int i = 0; i < parts.Length; i++)
2749 parts[i].LocalId = 0; 2780 parts[i].LocalId = 0;
2750 2781
2751 if (sceneObject.IsAttachmentCheckFull()) // Attachment 2782 if (sceneObject.IsAttachmentCheckFull()) // Attachment
2752 { 2783 {
2753 sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez); 2784 sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
2754 sceneObject.RootPart.AddFlag(PrimFlags.Phantom); 2785 sceneObject.RootPart.AddFlag(PrimFlags.Phantom);
2755 2786
2756 // Don't sent a full update here because this will cause full updates to be sent twice for 2787 // Don't sent a full update here because this will cause full updates to be sent twice for
2757 // attachments on region crossings, resulting in viewer glitches. 2788 // attachments on region crossings, resulting in viewer glitches.
2758 AddRestoredSceneObject(sceneObject, false, false, false); 2789 AddRestoredSceneObject(sceneObject, false, false, false);
@@ -2767,10 +2798,10 @@ namespace OpenSim.Region.Framework.Scenes
2767 { 2798 {
2768 SceneObjectGroup grp = sceneObject; 2799 SceneObjectGroup grp = sceneObject;
2769 2800
2770// m_log.DebugFormat( 2801 // m_log.DebugFormat(
2771// "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID); 2802 // "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID);
2772// m_log.DebugFormat( 2803 // m_log.DebugFormat(
2773// "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2804 // "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2774 2805
2775 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2806 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2776 2807
@@ -2778,7 +2809,7 @@ namespace OpenSim.Region.Framework.Scenes
2778 // information that this is due to a teleport/border cross rather than an ordinary attachment. 2809 // information that this is due to a teleport/border cross rather than an ordinary attachment.
2779 // We currently do this in Scene.MakeRootAgent() instead. 2810 // We currently do this in Scene.MakeRootAgent() instead.
2780 if (AttachmentsModule != null) 2811 if (AttachmentsModule != null)
2781 AttachmentsModule.AttachObject(sp, grp, 0, false, false, true); 2812 AttachmentsModule.AttachObject(sp, grp, 0, false, false, true);
2782 } 2813 }
2783 else 2814 else
2784 { 2815 {
@@ -2804,6 +2835,9 @@ namespace OpenSim.Region.Framework.Scenes
2804 bool vialogin; 2835 bool vialogin;
2805 bool reallyNew = true; 2836 bool reallyNew = true;
2806 2837
2838 // Update the number of users attempting to login
2839 StatsReporter.UpdateUsersLoggingIn(true);
2840
2807 // Validation occurs in LLUDPServer 2841 // Validation occurs in LLUDPServer
2808 // 2842 //
2809 // XXX: A race condition exists here where two simultaneous calls to AddNewAgent can interfere with 2843 // XXX: A race condition exists here where two simultaneous calls to AddNewAgent can interfere with
@@ -2824,11 +2858,11 @@ namespace OpenSim.Region.Framework.Scenes
2824 lock (aCircuit) 2858 lock (aCircuit)
2825 { 2859 {
2826 vialogin 2860 vialogin
2827 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 2861 = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0
2828 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2862 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2829 2863
2830 // CheckHeartbeat(); 2864 // CheckHeartbeat();
2831 2865
2832 sp = GetScenePresence(client.AgentId); 2866 sp = GetScenePresence(client.AgentId);
2833 2867
2834 // XXX: Not sure how good it is to add a new client if a scene presence already exists. Possibly this 2868 // XXX: Not sure how good it is to add a new client if a scene presence already exists. Possibly this
@@ -2838,9 +2872,9 @@ namespace OpenSim.Region.Framework.Scenes
2838 if (sp == null) 2872 if (sp == null)
2839 { 2873 {
2840 m_log.DebugFormat( 2874 m_log.DebugFormat(
2841 "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}", 2875 "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}",
2842 client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos); 2876 client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos);
2843 2877
2844 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); 2878 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
2845 2879
2846 // We must set this here so that TriggerOnNewClient and TriggerOnClientLogin can determine whether the 2880 // We must set this here so that TriggerOnNewClient and TriggerOnClientLogin can determine whether the
@@ -2857,7 +2891,7 @@ namespace OpenSim.Region.Framework.Scenes
2857 m_clientManager.Add(client); 2891 m_clientManager.Add(client);
2858 SubscribeToClientEvents(client); 2892 SubscribeToClientEvents(client);
2859 m_eventManager.TriggerOnNewPresence(sp); 2893 m_eventManager.TriggerOnNewPresence(sp);
2860 2894
2861 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; 2895 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
2862 } 2896 }
2863 else 2897 else
@@ -2870,24 +2904,28 @@ namespace OpenSim.Region.Framework.Scenes
2870 client.SceneAgent = sp; 2904 client.SceneAgent = sp;
2871 2905
2872 m_log.WarnFormat( 2906 m_log.WarnFormat(
2873 "[SCENE]: Already found {0} scene presence for {1} in {2} when asked to add new scene presence", 2907 "[SCENE]: Already found {0} scene presence for {1} in {2} when asked to add new scene presence",
2874 sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName); 2908 sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName);
2875 2909
2876 reallyNew = false; 2910 reallyNew = false;
2877 } 2911 }
2878 2912
2879 // This is currently also being done earlier in NewUserConnection for real users to see if this 2913 // This is currently also being done earlier in NewUserConnection for real users to see if this
2880 // resolves problems where HG agents are occasionally seen by others as "Unknown user" in chat and other 2914 // resolves problems where HG agents are occasionally seen by others as "Unknown user" in chat and other
2881 // places. However, we still need to do it here for NPCs. 2915 // places. However, we still need to do it here for NPCs.
2882 CacheUserName(sp, aCircuit); 2916 CacheUserName(sp, aCircuit);
2883 2917
2884 if (reallyNew) 2918 if (reallyNew)
2885 EventManager.TriggerOnNewClient(client); 2919 EventManager.TriggerOnNewClient(client);
2886 2920
2887 if (vialogin) 2921 if (vialogin)
2888 EventManager.TriggerOnClientLogin(client); 2922 EventManager.TriggerOnClientLogin(client);
2889 } 2923 }
2890 2924
2925 // User has logged into the scene so update the list of users logging
2926 // in
2927 StatsReporter.UpdateUsersLoggingIn(false);
2928
2891 m_LastLogin = Util.EnvironmentTickCount(); 2929 m_LastLogin = Util.EnvironmentTickCount();
2892 2930
2893 return sp; 2931 return sp;
@@ -2900,9 +2938,9 @@ namespace OpenSim.Region.Framework.Scenes
2900 { 2938 {
2901 AgentCircuitData circuit = AuthenticateHandler.GetAgentCircuitData(agentID); 2939 AgentCircuitData circuit = AuthenticateHandler.GetAgentCircuitData(agentID);
2902 if (circuit != null && circuit.ServiceURLs != null && circuit.ServiceURLs.ContainsKey("HomeURI")) 2940 if (circuit != null && circuit.ServiceURLs != null && circuit.ServiceURLs.ContainsKey("HomeURI"))
2903 return circuit.ServiceURLs["HomeURI"].ToString(); 2941 return circuit.ServiceURLs["HomeURI"].ToString();
2904 else 2942 else
2905 return null; 2943 return null;
2906 } 2944 }
2907 2945
2908 /// <summary> 2946 /// <summary>
@@ -2925,7 +2963,7 @@ namespace OpenSim.Region.Framework.Scenes
2925 string homeURL = string.Empty; 2963 string homeURL = string.Empty;
2926 2964
2927 if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) 2965 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
2928 homeURL = aCircuit.ServiceURLs["HomeURI"].ToString(); 2966 homeURL = aCircuit.ServiceURLs["HomeURI"].ToString();
2929 2967
2930 if (aCircuit.lastname.StartsWith("@")) 2968 if (aCircuit.lastname.StartsWith("@"))
2931 { 2969 {
@@ -2945,7 +2983,7 @@ namespace OpenSim.Region.Framework.Scenes
2945 private bool VerifyClient(AgentCircuitData aCircuit, System.Net.IPEndPoint ep, out bool vialogin) 2983 private bool VerifyClient(AgentCircuitData aCircuit, System.Net.IPEndPoint ep, out bool vialogin)
2946 { 2984 {
2947 vialogin = false; 2985 vialogin = false;
2948 2986
2949 // Do the verification here 2987 // Do the verification here
2950 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) 2988 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
2951 { 2989 {
@@ -2961,7 +2999,7 @@ namespace OpenSim.Region.Framework.Scenes
2961 return false; 2999 return false;
2962 } 3000 }
2963 else 3001 else
2964 m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned true", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); 3002 m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned true", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2965 3003
2966 } 3004 }
2967 } 3005 }
@@ -2969,7 +3007,7 @@ namespace OpenSim.Region.Framework.Scenes
2969 else if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) 3007 else if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
2970 { 3008 {
2971 m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via regular login. Client IP verification not performed.", 3009 m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via regular login. Client IP verification not performed.",
2972 aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); 3010 aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2973 vialogin = true; 3011 vialogin = true;
2974 } 3012 }
2975 3013
@@ -3013,7 +3051,7 @@ namespace OpenSim.Region.Framework.Scenes
3013 } 3051 }
3014 } 3052 }
3015 else 3053 else
3016 return true; 3054 return true;
3017 } 3055 }
3018 3056
3019 return false; 3057 return false;
@@ -3040,7 +3078,7 @@ namespace OpenSim.Region.Framework.Scenes
3040 { 3078 {
3041 client.OnRegionHandShakeReply += SendLayerData; 3079 client.OnRegionHandShakeReply += SendLayerData;
3042 } 3080 }
3043 3081
3044 public virtual void SubscribeToClientPrimEvents(IClientAPI client) 3082 public virtual void SubscribeToClientPrimEvents(IClientAPI client)
3045 { 3083 {
3046 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; 3084 client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition;
@@ -3050,7 +3088,7 @@ namespace OpenSim.Region.Framework.Scenes
3050 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; 3088 client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation;
3051 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; 3089 client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation;
3052 client.OnUpdatePrimSingleRotationPosition += m_sceneGraph.UpdatePrimSingleRotationPosition; 3090 client.OnUpdatePrimSingleRotationPosition += m_sceneGraph.UpdatePrimSingleRotationPosition;
3053 3091
3054 client.OnUpdatePrimScale += m_sceneGraph.UpdatePrimScale; 3092 client.OnUpdatePrimScale += m_sceneGraph.UpdatePrimScale;
3055 client.OnUpdatePrimGroupScale += m_sceneGraph.UpdatePrimGroupScale; 3093 client.OnUpdatePrimGroupScale += m_sceneGraph.UpdatePrimGroupScale;
3056 client.OnUpdateExtraParams += m_sceneGraph.UpdateExtraParam; 3094 client.OnUpdateExtraParams += m_sceneGraph.UpdateExtraParam;
@@ -3063,7 +3101,7 @@ namespace OpenSim.Region.Framework.Scenes
3063 client.OnSpinStart += m_sceneGraph.SpinStart; 3101 client.OnSpinStart += m_sceneGraph.SpinStart;
3064 client.OnSpinUpdate += m_sceneGraph.SpinObject; 3102 client.OnSpinUpdate += m_sceneGraph.SpinObject;
3065 client.OnDeRezObject += DeRezObjects; 3103 client.OnDeRezObject += DeRezObjects;
3066 3104
3067 client.OnObjectName += m_sceneGraph.PrimName; 3105 client.OnObjectName += m_sceneGraph.PrimName;
3068 client.OnObjectClickAction += m_sceneGraph.PrimClickAction; 3106 client.OnObjectClickAction += m_sceneGraph.PrimClickAction;
3069 client.OnObjectMaterial += m_sceneGraph.PrimMaterial; 3107 client.OnObjectMaterial += m_sceneGraph.PrimMaterial;
@@ -3075,7 +3113,7 @@ namespace OpenSim.Region.Framework.Scenes
3075 client.OnRequestObjectPropertiesFamily += m_sceneGraph.RequestObjectPropertiesFamily; 3113 client.OnRequestObjectPropertiesFamily += m_sceneGraph.RequestObjectPropertiesFamily;
3076 client.OnObjectPermissions += HandleObjectPermissionsUpdate; 3114 client.OnObjectPermissions += HandleObjectPermissionsUpdate;
3077 client.OnGrabObject += ProcessObjectGrab; 3115 client.OnGrabObject += ProcessObjectGrab;
3078 client.OnGrabUpdate += ProcessObjectGrabUpdate; 3116 client.OnGrabUpdate += ProcessObjectGrabUpdate;
3079 client.OnDeGrabObject += ProcessObjectDeGrab; 3117 client.OnDeGrabObject += ProcessObjectDeGrab;
3080 client.OnUndo += m_sceneGraph.HandleUndo; 3118 client.OnUndo += m_sceneGraph.HandleUndo;
3081 client.OnRedo += m_sceneGraph.HandleRedo; 3119 client.OnRedo += m_sceneGraph.HandleRedo;
@@ -3136,7 +3174,7 @@ namespace OpenSim.Region.Framework.Scenes
3136 //client.OnNameFromUUIDRequest += HandleUUIDNameRequest; 3174 //client.OnNameFromUUIDRequest += HandleUUIDNameRequest;
3137 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; 3175 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
3138 } 3176 }
3139 3177
3140 public virtual void SubscribeToClientNetworkEvents(IClientAPI client) 3178 public virtual void SubscribeToClientNetworkEvents(IClientAPI client)
3141 { 3179 {
3142 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats; 3180 client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats;
@@ -3297,7 +3335,7 @@ namespace OpenSim.Region.Framework.Scenes
3297 { 3335 {
3298 SceneObjectGroup copy = SceneGraph.DuplicateObject(originalPrim, offset, flags, AgentID, GroupID, Quaternion.Identity); 3336 SceneObjectGroup copy = SceneGraph.DuplicateObject(originalPrim, offset, flags, AgentID, GroupID, Quaternion.Identity);
3299 if (copy != null) 3337 if (copy != null)
3300 EventManager.TriggerObjectAddedToScene(copy); 3338 EventManager.TriggerObjectAddedToScene(copy);
3301 } 3339 }
3302 3340
3303 /// <summary> 3341 /// <summary>
@@ -3316,8 +3354,8 @@ namespace OpenSim.Region.Framework.Scenes
3316 /// <param name="CopyCenters">Position the object at the center of the face that it's colliding with</param> 3354 /// <param name="CopyCenters">Position the object at the center of the face that it's colliding with</param>
3317 /// <param name="CopyRotates">Rotate the object the same as the localID object</param> 3355 /// <param name="CopyRotates">Rotate the object the same as the localID object</param>
3318 public void doObjectDuplicateOnRay(uint localID, uint dupeFlags, UUID AgentID, UUID GroupID, 3356 public void doObjectDuplicateOnRay(uint localID, uint dupeFlags, UUID AgentID, UUID GroupID,
3319 UUID RayTargetObj, Vector3 RayEnd, Vector3 RayStart, 3357 UUID RayTargetObj, Vector3 RayEnd, Vector3 RayStart,
3320 bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates) 3358 bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates)
3321 { 3359 {
3322 Vector3 pos; 3360 Vector3 pos;
3323 const bool frontFacesOnly = true; 3361 const bool frontFacesOnly = true;
@@ -3378,7 +3416,7 @@ namespace OpenSim.Region.Framework.Scenes
3378 } 3416 }
3379 3417
3380 if (copy != null) 3418 if (copy != null)
3381 EventManager.TriggerObjectAddedToScene(copy); 3419 EventManager.TriggerObjectAddedToScene(copy);
3382 } 3420 }
3383 } 3421 }
3384 } 3422 }
@@ -3429,25 +3467,25 @@ namespace OpenSim.Region.Framework.Scenes
3429 if (acd == null) 3467 if (acd == null)
3430 { 3468 {
3431 m_log.ErrorFormat( 3469 m_log.ErrorFormat(
3432 "[SCENE]: No agent circuit found for {0} in {1}, aborting Scene.RemoveClient", agentID, Name); 3470 "[SCENE]: No agent circuit found for {0} in {1}, aborting Scene.RemoveClient", agentID, Name);
3433 3471
3434 return; 3472 return;
3435 } 3473 }
3436 3474
3437 // TODO: Can we now remove this lock? 3475 // TODO: Can we now remove this lock?
3438 lock (acd) 3476 lock (acd)
3439 { 3477 {
3440 bool isChildAgent = false; 3478 bool isChildAgent = false;
3441 3479
3442 ScenePresence avatar = GetScenePresence(agentID); 3480 ScenePresence avatar = GetScenePresence(agentID);
3443 3481
3444 // Shouldn't be necessary since RemoveClient() is currently only called by IClientAPI.Close() which 3482 // Shouldn't be necessary since RemoveClient() is currently only called by IClientAPI.Close() which
3445 // in turn is only called by Scene.IncomingCloseAgent() which checks whether the presence exists or not 3483 // in turn is only called by Scene.IncomingCloseAgent() which checks whether the presence exists or not
3446 // However, will keep for now just in case. 3484 // However, will keep for now just in case.
3447 if (avatar == null) 3485 if (avatar == null)
3448 { 3486 {
3449 m_log.ErrorFormat( 3487 m_log.ErrorFormat(
3450 "[SCENE]: Called RemoveClient() with agent ID {0} but no such presence is in the scene.", agentID); 3488 "[SCENE]: Called RemoveClient() with agent ID {0} but no such presence is in the scene.", agentID);
3451 m_authenticateHandler.RemoveCircuit(agentID); 3489 m_authenticateHandler.RemoveCircuit(agentID);
3452 3490
3453 return; 3491 return;
@@ -3458,9 +3496,9 @@ namespace OpenSim.Region.Framework.Scenes
3458 isChildAgent = avatar.IsChildAgent; 3496 isChildAgent = avatar.IsChildAgent;
3459 3497
3460 m_log.DebugFormat( 3498 m_log.DebugFormat(
3461 "[SCENE]: Removing {0} agent {1} {2} from {3}", 3499 "[SCENE]: Removing {0} agent {1} {2} from {3}",
3462 isChildAgent ? "child" : "root", avatar.Name, agentID, Name); 3500 isChildAgent ? "child" : "root", avatar.Name, agentID, Name);
3463 3501
3464 // Don't do this to root agents, it's not nice for the viewer 3502 // Don't do this to root agents, it's not nice for the viewer
3465 if (closeChildAgents && isChildAgent) 3503 if (closeChildAgents && isChildAgent)
3466 { 3504 {
@@ -3468,20 +3506,20 @@ namespace OpenSim.Region.Framework.Scenes
3468 // Let's do this via UDP 3506 // Let's do this via UDP
3469 avatar.ControllingClient.SendShutdownConnectionNotice(); 3507 avatar.ControllingClient.SendShutdownConnectionNotice();
3470 } 3508 }
3471 3509
3472 // Only applies to root agents. 3510 // Only applies to root agents.
3473 if (avatar.ParentID != 0) 3511 if (avatar.ParentID != 0)
3474 { 3512 {
3475 avatar.StandUp(); 3513 avatar.StandUp();
3476 } 3514 }
3477 3515
3478 m_sceneGraph.removeUserCount(!isChildAgent); 3516 m_sceneGraph.removeUserCount(!isChildAgent);
3479 3517
3480 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop 3518 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
3481 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI 3519 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
3482 if (closeChildAgents && CapsModule != null) 3520 if (closeChildAgents && CapsModule != null)
3483 CapsModule.RemoveCaps(agentID); 3521 CapsModule.RemoveCaps(agentID);
3484 3522
3485 if (closeChildAgents && !isChildAgent) 3523 if (closeChildAgents && !isChildAgent)
3486 { 3524 {
3487 List<ulong> regions = avatar.KnownRegionHandles; 3525 List<ulong> regions = avatar.KnownRegionHandles;
@@ -3490,10 +3528,10 @@ namespace OpenSim.Region.Framework.Scenes
3490 // This ends up being done asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours. 3528 // This ends up being done asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours.
3491 m_sceneGridService.SendCloseChildAgentConnections(agentID, acd.SessionID.ToString(), regions); 3529 m_sceneGridService.SendCloseChildAgentConnections(agentID, acd.SessionID.ToString(), regions);
3492 } 3530 }
3493 3531
3494 m_eventManager.TriggerClientClosed(agentID, this); 3532 m_eventManager.TriggerClientClosed(agentID, this);
3495 m_eventManager.TriggerOnRemovePresence(agentID); 3533 m_eventManager.TriggerOnRemovePresence(agentID);
3496 3534
3497 if (!isChildAgent) 3535 if (!isChildAgent)
3498 { 3536 {
3499 if (AttachmentsModule != null) 3537 if (AttachmentsModule != null)
@@ -3502,22 +3540,22 @@ namespace OpenSim.Region.Framework.Scenes
3502 } 3540 }
3503 3541
3504 ForEachClient( 3542 ForEachClient(
3505 delegate(IClientAPI client) 3543 delegate(IClientAPI client)
3506 { 3544 {
3507 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3545 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3508 try { client.SendKillObject(new List<uint> { avatar.LocalId }); } 3546 try { client.SendKillObject(new List<uint> { avatar.LocalId }); }
3509 catch (NullReferenceException) { } 3547 catch (NullReferenceException) { }
3510 }); 3548 });
3511 } 3549 }
3512 3550
3513 // It's possible for child agents to have transactions if changes are being made cross-border. 3551 // It's possible for child agents to have transactions if changes are being made cross-border.
3514 if (AgentTransactionsModule != null) 3552 if (AgentTransactionsModule != null)
3515 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); 3553 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3516 } 3554 }
3517 catch (Exception e) 3555 catch (Exception e)
3518 { 3556 {
3519 m_log.Error( 3557 m_log.Error(
3520 string.Format("[SCENE]: Exception removing {0} from {1}. Cleaning up. Exception ", avatar.Name, Name), e); 3558 string.Format("[SCENE]: Exception removing {0} from {1}. Cleaning up. Exception ", avatar.Name, Name), e);
3521 } 3559 }
3522 finally 3560 finally
3523 { 3561 {
@@ -3529,13 +3567,13 @@ namespace OpenSim.Region.Framework.Scenes
3529 m_authenticateHandler.RemoveCircuit(agentID); 3567 m_authenticateHandler.RemoveCircuit(agentID);
3530 m_sceneGraph.RemoveScenePresence(agentID); 3568 m_sceneGraph.RemoveScenePresence(agentID);
3531 m_clientManager.Remove(agentID); 3569 m_clientManager.Remove(agentID);
3532 3570
3533 avatar.Close(); 3571 avatar.Close();
3534 } 3572 }
3535 catch (Exception e) 3573 catch (Exception e)
3536 { 3574 {
3537 m_log.Error( 3575 m_log.Error(
3538 string.Format("[SCENE]: Exception in final clean up of {0} in {1}. Exception ", avatar.Name, Name), e); 3576 string.Format("[SCENE]: Exception in final clean up of {0} in {1}. Exception ", avatar.Name, Name), e);
3539 } 3577 }
3540 } 3578 }
3541 } 3579 }
@@ -3581,7 +3619,7 @@ namespace OpenSim.Region.Framework.Scenes
3581 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3619 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3582 { 3620 {
3583 if (part.ParentGroup.RootPart != part) // Child part 3621 if (part.ParentGroup.RootPart != part) // Child part
3584 continue; 3622 continue;
3585 } 3623 }
3586 } 3624 }
3587 deleteIDs.Add(localID); 3625 deleteIDs.Add(localID);
@@ -3634,7 +3672,7 @@ namespace OpenSim.Region.Framework.Scenes
3634 public bool NewUserConnection(AgentCircuitData acd, uint teleportFlags, GridRegion source, out string reason, bool requirePresenceLookup) 3672 public bool NewUserConnection(AgentCircuitData acd, uint teleportFlags, GridRegion source, out string reason, bool requirePresenceLookup)
3635 { 3673 {
3636 bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 || 3674 bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 ||
3637 (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0); 3675 (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0);
3638 bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0); 3676 bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0);
3639 bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0); 3677 bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0);
3640 3678
@@ -3650,18 +3688,18 @@ namespace OpenSim.Region.Framework.Scenes
3650 // Don't disable this log message - it's too helpful 3688 // Don't disable this log message - it's too helpful
3651 string curViewer = Util.GetViewerName(acd); 3689 string curViewer = Util.GetViewerName(acd);
3652 m_log.DebugFormat( 3690 m_log.DebugFormat(
3653 "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9}. {10}", 3691 "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9}. {10}",
3654 RegionInfo.RegionName, 3692 RegionInfo.RegionName,
3655 (acd.child ? "child" : "root"), 3693 (acd.child ? "child" : "root"),
3656 acd.firstname, 3694 acd.firstname,
3657 acd.lastname, 3695 acd.lastname,
3658 acd.AgentID, 3696 acd.AgentID,
3659 acd.circuitcode, 3697 acd.circuitcode,
3660 acd.IPAddress, 3698 acd.IPAddress,
3661 curViewer, 3699 curViewer,
3662 ((TPFlags)teleportFlags).ToString(), 3700 ((TPFlags)teleportFlags).ToString(),
3663 acd.startpos, 3701 acd.startpos,
3664 (source == null) ? "" : string.Format("From region {0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI == null) ? "" : " @ " + source.ServerURI) 3702 (source == null) ? "" : string.Format("From region {0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI == null) ? "" : " @ " + source.ServerURI)
3665 ); 3703 );
3666 3704
3667 if (!LoginsEnabled) 3705 if (!LoginsEnabled)
@@ -3707,8 +3745,8 @@ namespace OpenSim.Region.Framework.Scenes
3707 if (ViewerDenied) 3745 if (ViewerDenied)
3708 { 3746 {
3709 m_log.DebugFormat( 3747 m_log.DebugFormat(
3710 "[SCENE]: Access denied for {0} {1} using {2}", 3748 "[SCENE]: Access denied for {0} {1} using {2}",
3711 acd.firstname, acd.lastname, curViewer); 3749 acd.firstname, acd.lastname, curViewer);
3712 reason = "Access denied, your viewer is banned by the region owner"; 3750 reason = "Access denied, your viewer is banned by the region owner";
3713 return false; 3751 return false;
3714 } 3752 }
@@ -3722,13 +3760,13 @@ namespace OpenSim.Region.Framework.Scenes
3722 3760
3723 // We need to ensure that we are not already removing the scene presence before we ask it not to be 3761 // We need to ensure that we are not already removing the scene presence before we ask it not to be
3724 // closed. 3762 // closed.
3725 if (sp != null && sp.IsChildAgent 3763 if (sp != null && sp.IsChildAgent
3726 && (sp.LifecycleState == ScenePresenceState.Running 3764 && (sp.LifecycleState == ScenePresenceState.Running
3727 || sp.LifecycleState == ScenePresenceState.PreRemove)) 3765 || sp.LifecycleState == ScenePresenceState.PreRemove))
3728 { 3766 {
3729 m_log.DebugFormat( 3767 m_log.DebugFormat(
3730 "[SCENE]: Reusing existing child scene presence for {0}, state {1} in {2}", 3768 "[SCENE]: Reusing existing child scene presence for {0}, state {1} in {2}",
3731 sp.Name, sp.LifecycleState, Name); 3769 sp.Name, sp.LifecycleState, Name);
3732 3770
3733 // In the case where, for example, an A B C D region layout, an avatar may 3771 // In the case where, for example, an A B C D region layout, an avatar may
3734 // teleport from A -> D, but then -> C before A has asked B to close its old child agent. When C 3772 // teleport from A -> D, but then -> C before A has asked B to close its old child agent. When C
@@ -3740,15 +3778,15 @@ namespace OpenSim.Region.Framework.Scenes
3740 // vulnerable to an issue when a viewer quits a region without sending a proper logout but then 3778 // vulnerable to an issue when a viewer quits a region without sending a proper logout but then
3741 // re-establishes the connection on a relogin. This could wrongly set the DoNotCloseAfterTeleport 3779 // re-establishes the connection on a relogin. This could wrongly set the DoNotCloseAfterTeleport
3742 // flag when no teleport had taken place (and hence no close was going to come). 3780 // flag when no teleport had taken place (and hence no close was going to come).
3743// if (!acd.ChildrenCapSeeds.ContainsKey(RegionInfo.RegionHandle)) 3781 // if (!acd.ChildrenCapSeeds.ContainsKey(RegionInfo.RegionHandle))
3744// { 3782 // {
3745// m_log.DebugFormat( 3783 // m_log.DebugFormat(
3746// "[SCENE]: Setting DoNotCloseAfterTeleport for child scene presence {0} in {1} because source will attempt close.", 3784 // "[SCENE]: Setting DoNotCloseAfterTeleport for child scene presence {0} in {1} because source will attempt close.",
3747// sp.Name, Name); 3785 // sp.Name, Name);
3748// 3786 //
3749// sp.DoNotCloseAfterTeleport = true; 3787 // sp.DoNotCloseAfterTeleport = true;
3750// } 3788 // }
3751// else if (EntityTransferModule.IsInTransit(sp.UUID)) 3789 // else if (EntityTransferModule.IsInTransit(sp.UUID))
3752 3790
3753 sp.LifecycleState = ScenePresenceState.Running; 3791 sp.LifecycleState = ScenePresenceState.Running;
3754 3792
@@ -3757,8 +3795,8 @@ namespace OpenSim.Region.Framework.Scenes
3757 sp.DoNotCloseAfterTeleport = true; 3795 sp.DoNotCloseAfterTeleport = true;
3758 3796
3759 m_log.DebugFormat( 3797 m_log.DebugFormat(
3760 "[SCENE]: Set DoNotCloseAfterTeleport for child scene presence {0} in {1} because this region will attempt end-of-teleport close from a previous close.", 3798 "[SCENE]: Set DoNotCloseAfterTeleport for child scene presence {0} in {1} because this region will attempt end-of-teleport close from a previous close.",
3761 sp.Name, Name); 3799 sp.Name, Name);
3762 } 3800 }
3763 } 3801 }
3764 } 3802 }
@@ -3772,21 +3810,21 @@ namespace OpenSim.Region.Framework.Scenes
3772 int pollsLeft = polls; 3810 int pollsLeft = polls;
3773 3811
3774 while (sp.LifecycleState == ScenePresenceState.Removing && pollsLeft-- > 0) 3812 while (sp.LifecycleState == ScenePresenceState.Removing && pollsLeft-- > 0)
3775 Thread.Sleep(pollInterval); 3813 Thread.Sleep(pollInterval);
3776 3814
3777 if (sp.LifecycleState == ScenePresenceState.Removing) 3815 if (sp.LifecycleState == ScenePresenceState.Removing)
3778 { 3816 {
3779 m_log.WarnFormat( 3817 m_log.WarnFormat(
3780 "[SCENE]: Agent {0} in {1} was still being removed after {2}s. Aborting NewUserConnection.", 3818 "[SCENE]: Agent {0} in {1} was still being removed after {2}s. Aborting NewUserConnection.",
3781 sp.Name, Name, polls * pollInterval / 1000); 3819 sp.Name, Name, polls * pollInterval / 1000);
3782 3820
3783 return false; 3821 return false;
3784 } 3822 }
3785 else if (polls != pollsLeft) 3823 else if (polls != pollsLeft)
3786 { 3824 {
3787 m_log.DebugFormat( 3825 m_log.DebugFormat(
3788 "[SCENE]: NewUserConnection for agent {0} in {1} had to wait {2}s for in-progress removal to complete on an old presence.", 3826 "[SCENE]: NewUserConnection for agent {0} in {1} had to wait {2}s for in-progress removal to complete on an old presence.",
3789 sp.Name, Name, polls * pollInterval / 1000); 3827 sp.Name, Name, polls * pollInterval / 1000);
3790 } 3828 }
3791 } 3829 }
3792 3830
@@ -3802,11 +3840,11 @@ namespace OpenSim.Region.Framework.Scenes
3802 // Or the same user is trying to be root twice here, won't work. 3840 // Or the same user is trying to be root twice here, won't work.
3803 // Kill it. 3841 // Kill it.
3804 m_log.WarnFormat( 3842 m_log.WarnFormat(
3805 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", 3843 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3806 sp.Name, sp.UUID, RegionInfo.RegionName); 3844 sp.Name, sp.UUID, RegionInfo.RegionName);
3807 3845
3808 if (sp.ControllingClient != null) 3846 if (sp.ControllingClient != null)
3809 CloseAgent(sp.UUID, true); 3847 CloseAgent(sp.UUID, true);
3810 3848
3811 sp = null; 3849 sp = null;
3812 } 3850 }
@@ -3821,7 +3859,7 @@ namespace OpenSim.Region.Framework.Scenes
3821 m_authenticateHandler.AddNewCircuit(acd.circuitcode, acd); 3859 m_authenticateHandler.AddNewCircuit(acd.circuitcode, acd);
3822 3860
3823 land = LandChannel.GetLandObject(acd.startpos.X, acd.startpos.Y); 3861 land = LandChannel.GetLandObject(acd.startpos.X, acd.startpos.Y);
3824 3862
3825 // On login test land permisions 3863 // On login test land permisions
3826 if (vialogin) 3864 if (vialogin)
3827 { 3865 {
@@ -3831,7 +3869,7 @@ namespace OpenSim.Region.Framework.Scenes
3831 return false; 3869 return false;
3832 } 3870 }
3833 } 3871 }
3834 3872
3835 if (sp == null) // We don't have an [child] agent here already 3873 if (sp == null) // We don't have an [child] agent here already
3836 { 3874 {
3837 if (requirePresenceLookup) 3875 if (requirePresenceLookup)
@@ -3847,13 +3885,13 @@ namespace OpenSim.Region.Framework.Scenes
3847 catch (Exception e) 3885 catch (Exception e)
3848 { 3886 {
3849 m_log.ErrorFormat( 3887 m_log.ErrorFormat(
3850 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); 3888 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace);
3851 3889
3852 m_authenticateHandler.RemoveCircuit(acd.circuitcode); 3890 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
3853 return false; 3891 return false;
3854 } 3892 }
3855 } 3893 }
3856 3894
3857 try 3895 try
3858 { 3896 {
3859 if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason)) 3897 if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason))
@@ -3865,17 +3903,17 @@ namespace OpenSim.Region.Framework.Scenes
3865 catch (Exception e) 3903 catch (Exception e)
3866 { 3904 {
3867 m_log.ErrorFormat( 3905 m_log.ErrorFormat(
3868 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); 3906 "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
3869 3907
3870 m_authenticateHandler.RemoveCircuit(acd.circuitcode); 3908 m_authenticateHandler.RemoveCircuit(acd.circuitcode);
3871 return false; 3909 return false;
3872 } 3910 }
3873 3911
3874 m_log.InfoFormat( 3912 m_log.InfoFormat(
3875 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", 3913 "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})",
3876 Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname, 3914 Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname,
3877 acd.AgentID, acd.circuitcode); 3915 acd.AgentID, acd.circuitcode);
3878 3916
3879 if (CapsModule != null) 3917 if (CapsModule != null)
3880 { 3918 {
3881 CapsModule.SetAgentCapsSeeds(acd); 3919 CapsModule.SetAgentCapsSeeds(acd);
@@ -3887,13 +3925,13 @@ namespace OpenSim.Region.Framework.Scenes
3887 // Let the SP know how we got here. This has a lot of interesting 3925 // Let the SP know how we got here. This has a lot of interesting
3888 // uses down the line. 3926 // uses down the line.
3889 sp.TeleportFlags = (TPFlags)teleportFlags; 3927 sp.TeleportFlags = (TPFlags)teleportFlags;
3890 3928
3891 if (sp.IsChildAgent) 3929 if (sp.IsChildAgent)
3892 { 3930 {
3893 m_log.DebugFormat( 3931 m_log.DebugFormat(
3894 "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", 3932 "[SCENE]: Adjusting known seeds for existing agent {0} in {1}",
3895 acd.AgentID, RegionInfo.RegionName); 3933 acd.AgentID, RegionInfo.RegionName);
3896 3934
3897 sp.AdjustKnownSeeds(); 3935 sp.AdjustKnownSeeds();
3898 3936
3899 if (CapsModule != null) 3937 if (CapsModule != null)
@@ -3912,7 +3950,7 @@ namespace OpenSim.Region.Framework.Scenes
3912 3950
3913 if (vialogin) 3951 if (vialogin)
3914 { 3952 {
3915// CleanDroppedAttachments(); 3953 // CleanDroppedAttachments();
3916 3954
3917 // Make sure avatar position is in the region (why it wouldn't be is a mystery but do sanity checking) 3955 // Make sure avatar position is in the region (why it wouldn't be is a mystery but do sanity checking)
3918 if (acd.startpos.X < 0) acd.startpos.X = 1f; 3956 if (acd.startpos.X < 0) acd.startpos.X = 1f;
@@ -3920,14 +3958,14 @@ namespace OpenSim.Region.Framework.Scenes
3920 if (acd.startpos.Y < 0) acd.startpos.Y = 1f; 3958 if (acd.startpos.Y < 0) acd.startpos.Y = 1f;
3921 if (acd.startpos.Y >= RegionInfo.RegionSizeY) acd.startpos.Y = RegionInfo.RegionSizeY - 1f; 3959 if (acd.startpos.Y >= RegionInfo.RegionSizeY) acd.startpos.Y = RegionInfo.RegionSizeY - 1f;
3922 3960
3923// m_log.DebugFormat( 3961 // m_log.DebugFormat(
3924// "[SCENE]: Found telehub object {0} for new user connection {1} to {2}", 3962 // "[SCENE]: Found telehub object {0} for new user connection {1} to {2}",
3925// RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); 3963 // RegionInfo.RegionSettings.TelehubObject, acd.Name, Name);
3926 3964
3927 // Honor Estate teleport routing via Telehubs excluding ViaHome and GodLike TeleportFlags 3965 // Honor Estate teleport routing via Telehubs excluding ViaHome and GodLike TeleportFlags
3928 if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero && 3966 if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero &&
3929 RegionInfo.EstateSettings.AllowDirectTeleport == false && 3967 RegionInfo.EstateSettings.AllowDirectTeleport == false &&
3930 !viahome && !godlike) 3968 !viahome && !godlike)
3931 { 3969 {
3932 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); 3970 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject);
3933 3971
@@ -3939,15 +3977,15 @@ namespace OpenSim.Region.Framework.Scenes
3939 { 3977 {
3940 // We have multiple SpawnPoints, Route the agent to a random or sequential one 3978 // We have multiple SpawnPoints, Route the agent to a random or sequential one
3941 if (SpawnPointRouting == "random") 3979 if (SpawnPointRouting == "random")
3942 acd.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation( 3980 acd.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation(
3943 telehub.AbsolutePosition, 3981 telehub.AbsolutePosition,
3944 telehub.GroupRotation 3982 telehub.GroupRotation
3945 ); 3983 );
3946 else 3984 else
3947 acd.startpos = spawnpoints[SpawnPoint()].GetLocation( 3985 acd.startpos = spawnpoints[SpawnPoint()].GetLocation(
3948 telehub.AbsolutePosition, 3986 telehub.AbsolutePosition,
3949 telehub.GroupRotation 3987 telehub.GroupRotation
3950 ); 3988 );
3951 } 3989 }
3952 else if (spawnpoints.Count == 1) 3990 else if (spawnpoints.Count == 1)
3953 { 3991 {
@@ -3957,15 +3995,15 @@ namespace OpenSim.Region.Framework.Scenes
3957 else 3995 else
3958 { 3996 {
3959 m_log.DebugFormat( 3997 m_log.DebugFormat(
3960 "[SCENE]: No spawnpoints defined for telehub {0} for {1} in {2}. Continuing.", 3998 "[SCENE]: No spawnpoints defined for telehub {0} for {1} in {2}. Continuing.",
3961 RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); 3999 RegionInfo.RegionSettings.TelehubObject, acd.Name, Name);
3962 } 4000 }
3963 } 4001 }
3964 else 4002 else
3965 { 4003 {
3966 m_log.DebugFormat( 4004 m_log.DebugFormat(
3967 "[SCENE]: No telehub {0} found to direct {1} in {2}. Continuing.", 4005 "[SCENE]: No telehub {0} found to direct {1} in {2}. Continuing.",
3968 RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); 4006 RegionInfo.RegionSettings.TelehubObject, acd.Name, Name);
3969 } 4007 }
3970 4008
3971 // Final permissions check; this time we don't allow changing the position 4009 // Final permissions check; this time we don't allow changing the position
@@ -4002,7 +4040,7 @@ namespace OpenSim.Region.Framework.Scenes
4002 { 4040 {
4003 ILandObject land = LandChannel.GetLandObject(pos); 4041 ILandObject land = LandChannel.GetLandObject(pos);
4004 if (land == null) 4042 if (land == null)
4005 return true; 4043 return true;
4006 4044
4007 if (land.IsBannedFromLand(agentID) || land.IsRestrictedFromLand(agentID)) 4045 if (land.IsBannedFromLand(agentID) || land.IsRestrictedFromLand(agentID))
4008 { 4046 {
@@ -4016,21 +4054,21 @@ namespace OpenSim.Region.Framework.Scenes
4016 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) 4054 public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
4017 { 4055 {
4018 if (posX < 0) 4056 if (posX < 0)
4019 posX = 0; 4057 posX = 0;
4020 else if (posX >= (float)RegionInfo.RegionSizeX) 4058 else if (posX >= (float)RegionInfo.RegionSizeX)
4021 posX = (float)RegionInfo.RegionSizeX - 0.001f; 4059 posX = (float)RegionInfo.RegionSizeX - 0.001f;
4022 if (posY < 0) 4060 if (posY < 0)
4023 posY = 0; 4061 posY = 0;
4024 else if (posY >= (float)RegionInfo.RegionSizeY) 4062 else if (posY >= (float)RegionInfo.RegionSizeY)
4025 posY = (float)RegionInfo.RegionSizeY - 0.001f; 4063 posY = (float)RegionInfo.RegionSizeY - 0.001f;
4026 4064
4027 reason = String.Empty; 4065 reason = String.Empty;
4028 if (Permissions.IsGod(agentID)) 4066 if (Permissions.IsGod(agentID))
4029 return true; 4067 return true;
4030 4068
4031 ILandObject land = LandChannel.GetLandObject(posX, posY); 4069 ILandObject land = LandChannel.GetLandObject(posX, posY);
4032 if (land == null) 4070 if (land == null)
4033 return false; 4071 return false;
4034 4072
4035 bool banned = land.IsBannedFromLand(agentID); 4073 bool banned = land.IsBannedFromLand(agentID);
4036 bool restricted = land.IsRestrictedFromLand(agentID); 4074 bool restricted = land.IsRestrictedFromLand(agentID);
@@ -4054,7 +4092,7 @@ namespace OpenSim.Region.Framework.Scenes
4054 else 4092 else
4055 { 4093 {
4056 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", 4094 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
4057 RegionInfo.RegionName); 4095 RegionInfo.RegionName);
4058 } 4096 }
4059 return false; 4097 return false;
4060 } 4098 }
@@ -4105,15 +4143,15 @@ namespace OpenSim.Region.Framework.Scenes
4105 4143
4106 if (!m_strictAccessControl) return true; 4144 if (!m_strictAccessControl) return true;
4107 if (Permissions.IsGod(agent.AgentID)) return true; 4145 if (Permissions.IsGod(agent.AgentID)) return true;
4108 4146
4109 if (AuthorizationService != null) 4147 if (AuthorizationService != null)
4110 { 4148 {
4111 if (!AuthorizationService.IsAuthorizedForRegion( 4149 if (!AuthorizationService.IsAuthorizedForRegion(
4112 agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason)) 4150 agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason))
4113 { 4151 {
4114 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because: {4}", 4152 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because: {4}",
4115 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName, reason); 4153 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName, reason);
4116 4154
4117 return false; 4155 return false;
4118 } 4156 }
4119 } 4157 }
@@ -4129,9 +4167,9 @@ namespace OpenSim.Region.Framework.Scenes
4129 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) 4167 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID))
4130 { 4168 {
4131 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 4169 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
4132 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 4170 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
4133 reason = String.Format("Denied access to region {0}: You have been banned from that region.", 4171 reason = String.Format("Denied access to region {0}: You have been banned from that region.",
4134 RegionInfo.RegionName); 4172 RegionInfo.RegionName);
4135 return false; 4173 return false;
4136 } 4174 }
4137 } 4175 }
@@ -4149,7 +4187,7 @@ namespace OpenSim.Region.Framework.Scenes
4149 if (GroupMembership != null) 4187 if (GroupMembership != null)
4150 { 4188 {
4151 for (int i = 0; i < GroupMembership.Length; i++) 4189 for (int i = 0; i < GroupMembership.Length; i++)
4152 agentGroups.Add(GroupMembership[i].GroupID); 4190 agentGroups.Add(GroupMembership[i].GroupID);
4153 } 4191 }
4154 else 4192 else
4155 { 4193 {
@@ -4177,13 +4215,13 @@ namespace OpenSim.Region.Framework.Scenes
4177 } 4215 }
4178 4216
4179 if (!RegionInfo.EstateSettings.PublicAccess && 4217 if (!RegionInfo.EstateSettings.PublicAccess &&
4180 !RegionInfo.EstateSettings.HasAccess(agent.AgentID) && 4218 !RegionInfo.EstateSettings.HasAccess(agent.AgentID) &&
4181 !groupAccess) 4219 !groupAccess)
4182 { 4220 {
4183 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", 4221 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate",
4184 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 4222 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
4185 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", 4223 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
4186 RegionInfo.RegionName); 4224 RegionInfo.RegionName);
4187 return false; 4225 return false;
4188 } 4226 }
4189 } 4227 }
@@ -4239,69 +4277,69 @@ namespace OpenSim.Region.Framework.Scenes
4239 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); 4277 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc);
4240 } 4278 }
4241 4279
4242// /// <summary> 4280 // /// <summary>
4243// /// The Grid has requested that we log-off a user. Log them off. 4281 // /// The Grid has requested that we log-off a user. Log them off.
4244// /// </summary> 4282 // /// </summary>
4245// /// <param name="AvatarID">Unique ID of the avatar to log-off</param> 4283 // /// <param name="AvatarID">Unique ID of the avatar to log-off</param>
4246// /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param> 4284 // /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param>
4247// /// <param name="message">message to display to the user. Reason for being logged off</param> 4285 // /// <param name="message">message to display to the user. Reason for being logged off</param>
4248// public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) 4286 // public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
4249// { 4287 // {
4250// ScenePresence loggingOffUser = GetScenePresence(AvatarID); 4288 // ScenePresence loggingOffUser = GetScenePresence(AvatarID);
4251// if (loggingOffUser != null) 4289 // if (loggingOffUser != null)
4252// { 4290 // {
4253// UUID localRegionSecret = UUID.Zero; 4291 // UUID localRegionSecret = UUID.Zero;
4254// bool parsedsecret = UUID.TryParse(RegionInfo.regionSecret, out localRegionSecret); 4292 // bool parsedsecret = UUID.TryParse(RegionInfo.regionSecret, out localRegionSecret);
4255// 4293 //
4256// // Region Secret is used here in case a new sessionid overwrites an old one on the user server. 4294 // // Region Secret is used here in case a new sessionid overwrites an old one on the user server.
4257// // Will update the user server in a few revisions to use it. 4295 // // Will update the user server in a few revisions to use it.
4258// 4296 //
4259// if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) 4297 // if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret))
4260// { 4298 // {
4261// m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); 4299 // m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles);
4262// loggingOffUser.ControllingClient.Kick(message); 4300 // loggingOffUser.ControllingClient.Kick(message);
4263// // Give them a second to receive the message! 4301 // // Give them a second to receive the message!
4264// Thread.Sleep(1000); 4302 // Thread.Sleep(1000);
4265// loggingOffUser.ControllingClient.Close(); 4303 // loggingOffUser.ControllingClient.Close();
4266// } 4304 // }
4267// else 4305 // else
4268// { 4306 // {
4269// m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); 4307 // m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate");
4270// } 4308 // }
4271// } 4309 // }
4272// else 4310 // else
4273// { 4311 // {
4274// m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString()); 4312 // m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString());
4275// } 4313 // }
4276// } 4314 // }
4277 4315
4278// /// <summary> 4316 // /// <summary>
4279// /// Triggered when an agent crosses into this sim. Also happens on initial login. 4317 // /// Triggered when an agent crosses into this sim. Also happens on initial login.
4280// /// </summary> 4318 // /// </summary>
4281// /// <param name="agentID"></param> 4319 // /// <param name="agentID"></param>
4282// /// <param name="position"></param> 4320 // /// <param name="position"></param>
4283// /// <param name="isFlying"></param> 4321 // /// <param name="isFlying"></param>
4284// public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) 4322 // public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
4285// { 4323 // {
4286// ScenePresence presence = GetScenePresence(agentID); 4324 // ScenePresence presence = GetScenePresence(agentID);
4287// if (presence != null) 4325 // if (presence != null)
4288// { 4326 // {
4289// try 4327 // try
4290// { 4328 // {
4291// presence.MakeRootAgent(position, isFlying); 4329 // presence.MakeRootAgent(position, isFlying);
4292// } 4330 // }
4293// catch (Exception e) 4331 // catch (Exception e)
4294// { 4332 // {
4295// m_log.ErrorFormat("[SCENE]: Unable to do agent crossing, exception {0}{1}", e.Message, e.StackTrace); 4333 // m_log.ErrorFormat("[SCENE]: Unable to do agent crossing, exception {0}{1}", e.Message, e.StackTrace);
4296// } 4334 // }
4297// } 4335 // }
4298// else 4336 // else
4299// { 4337 // {
4300// m_log.ErrorFormat( 4338 // m_log.ErrorFormat(
4301// "[SCENE]: Could not find presence for agent {0} crossing into scene {1}", 4339 // "[SCENE]: Could not find presence for agent {0} crossing into scene {1}",
4302// agentID, RegionInfo.RegionName); 4340 // agentID, RegionInfo.RegionName);
4303// } 4341 // }
4304// } 4342 // }
4305 4343
4306 /// <summary> 4344 /// <summary>
4307 /// We've got an update about an agent that sees into this region, 4345 /// We've got an update about an agent that sees into this region,
@@ -4313,15 +4351,15 @@ namespace OpenSim.Region.Framework.Scenes
4313 public virtual bool IncomingUpdateChildAgent(AgentData cAgentData) 4351 public virtual bool IncomingUpdateChildAgent(AgentData cAgentData)
4314 { 4352 {
4315 m_log.DebugFormat( 4353 m_log.DebugFormat(
4316 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); 4354 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
4317 4355
4318 // TODO: This check should probably be in QueryAccess(). 4356 // TODO: This check should probably be in QueryAccess().
4319 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, RegionInfo.RegionSizeX / 2, RegionInfo.RegionSizeY / 2); 4357 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, RegionInfo.RegionSizeX / 2, RegionInfo.RegionSizeY / 2);
4320 if (nearestParcel == null) 4358 if (nearestParcel == null)
4321 { 4359 {
4322 m_log.InfoFormat( 4360 m_log.InfoFormat(
4323 "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel", 4361 "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel",
4324 cAgentData.AgentID, RegionInfo.RegionName); 4362 cAgentData.AgentID, RegionInfo.RegionName);
4325 4363
4326 return false; 4364 return false;
4327 } 4365 }
@@ -4337,11 +4375,11 @@ namespace OpenSim.Region.Framework.Scenes
4337 if (cAgentData.SessionID != sp.ControllingClient.SessionId) 4375 if (cAgentData.SessionID != sp.ControllingClient.SessionId)
4338 { 4376 {
4339 m_log.WarnFormat( 4377 m_log.WarnFormat(
4340 "[SCENE]: Attempt to update agent {0} with invalid session id {1} (possibly from simulator in older version; tell them to update).", 4378 "[SCENE]: Attempt to update agent {0} with invalid session id {1} (possibly from simulator in older version; tell them to update).",
4341 sp.UUID, cAgentData.SessionID); 4379 sp.UUID, cAgentData.SessionID);
4342 4380
4343 Console.WriteLine(String.Format("[SCENE]: Attempt to update agent {0} ({1}) with invalid session id {2}", 4381 Console.WriteLine(String.Format("[SCENE]: Attempt to update agent {0} ({1}) with invalid session id {2}",
4344 sp.UUID, sp.ControllingClient.SessionId, cAgentData.SessionID)); 4382 sp.UUID, sp.ControllingClient.SessionId, cAgentData.SessionID));
4345 } 4383 }
4346 4384
4347 sp.UpdateChildAgent(cAgentData); 4385 sp.UpdateChildAgent(cAgentData);
@@ -4350,19 +4388,19 @@ namespace OpenSim.Region.Framework.Scenes
4350 if (cAgentData.SenderWantsToWaitForRoot) 4388 if (cAgentData.SenderWantsToWaitForRoot)
4351 { 4389 {
4352 while (sp.IsChildAgent && ntimes-- > 0) 4390 while (sp.IsChildAgent && ntimes-- > 0)
4353 Thread.Sleep(1000); 4391 Thread.Sleep(1000);
4354 4392
4355 if (sp.IsChildAgent) 4393 if (sp.IsChildAgent)
4356 m_log.WarnFormat( 4394 m_log.WarnFormat(
4357 "[SCENE]: Found presence {0} {1} unexpectedly still child in {2}", 4395 "[SCENE]: Found presence {0} {1} unexpectedly still child in {2}",
4358 sp.Name, sp.UUID, Name); 4396 sp.Name, sp.UUID, Name);
4359 else 4397 else
4360 m_log.InfoFormat( 4398 m_log.InfoFormat(
4361 "[SCENE]: Found presence {0} {1} as root in {2} after {3} waits", 4399 "[SCENE]: Found presence {0} {1} as root in {2} after {3} waits",
4362 sp.Name, sp.UUID, Name, 20 - ntimes); 4400 sp.Name, sp.UUID, Name, 20 - ntimes);
4363 4401
4364 if (sp.IsChildAgent) 4402 if (sp.IsChildAgent)
4365 return false; 4403 return false;
4366 } 4404 }
4367 4405
4368 return true; 4406 return true;
@@ -4379,17 +4417,17 @@ namespace OpenSim.Region.Framework.Scenes
4379 /// <returns>true if we handled it.</returns> 4417 /// <returns>true if we handled it.</returns>
4380 public virtual bool IncomingUpdateChildAgent(AgentPosition cAgentData) 4418 public virtual bool IncomingUpdateChildAgent(AgentPosition cAgentData)
4381 { 4419 {
4382// m_log.DebugFormat( 4420 // m_log.DebugFormat(
4383// "[SCENE PRESENCE]: IncomingChildAgentDataUpdate POSITION for {0} in {1}, position {2}", 4421 // "[SCENE PRESENCE]: IncomingChildAgentDataUpdate POSITION for {0} in {1}, position {2}",
4384// cAgentData.AgentID, Name, cAgentData.Position); 4422 // cAgentData.AgentID, Name, cAgentData.Position);
4385 4423
4386 ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID); 4424 ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID);
4387 if (childAgentUpdate != null) 4425 if (childAgentUpdate != null)
4388 { 4426 {
4389// if (childAgentUpdate.ControllingClient.SessionId != cAgentData.SessionID) 4427 // if (childAgentUpdate.ControllingClient.SessionId != cAgentData.SessionID)
4390// // Only warn for now 4428 // // Only warn for now
4391// m_log.WarnFormat("[SCENE]: Attempt at updating position of agent {0} with invalid session id {1}. Neighbor running older version?", 4429 // m_log.WarnFormat("[SCENE]: Attempt at updating position of agent {0} with invalid session id {1}. Neighbor running older version?",
4392// childAgentUpdate.UUID, cAgentData.SessionID); 4430 // childAgentUpdate.UUID, cAgentData.SessionID);
4393 4431
4394 // I can't imagine *yet* why we would get an update if the agent is a root agent.. 4432 // I can't imagine *yet* why we would get an update if the agent is a root agent..
4395 // however to avoid a race condition crossing borders.. 4433 // however to avoid a race condition crossing borders..
@@ -4421,12 +4459,12 @@ namespace OpenSim.Region.Framework.Scenes
4421 int ntimes = 20; 4459 int ntimes = 20;
4422 ScenePresence sp = null; 4460 ScenePresence sp = null;
4423 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4461 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4424 Thread.Sleep(1000); 4462 Thread.Sleep(1000);
4425 4463
4426 if (sp == null) 4464 if (sp == null)
4427 m_log.WarnFormat( 4465 m_log.WarnFormat(
4428 "[SCENE PRESENCE]: Did not find presence with id {0} in {1} before timeout", 4466 "[SCENE PRESENCE]: Did not find presence with id {0} in {1} before timeout",
4429 agentID, RegionInfo.RegionName); 4467 agentID, RegionInfo.RegionName);
4430 4468
4431 return sp; 4469 return sp;
4432 } 4470 }
@@ -4448,8 +4486,8 @@ namespace OpenSim.Region.Framework.Scenes
4448 if (acd == null) 4486 if (acd == null)
4449 { 4487 {
4450 m_log.DebugFormat( 4488 m_log.DebugFormat(
4451 "[SCENE]: Request to close agent {0} but no such agent in scene {1}. May have been closed previously.", 4489 "[SCENE]: Request to close agent {0} but no such agent in scene {1}. May have been closed previously.",
4452 agentID, Name); 4490 agentID, Name);
4453 4491
4454 return false; 4492 return false;
4455 } 4493 }
@@ -4461,8 +4499,8 @@ namespace OpenSim.Region.Framework.Scenes
4461 else 4499 else
4462 { 4500 {
4463 m_log.WarnFormat( 4501 m_log.WarnFormat(
4464 "[SCENE]: Request to close agent {0} with invalid authorization token {1} in {2}", 4502 "[SCENE]: Request to close agent {0} with invalid authorization token {1} in {2}",
4465 agentID, auth_token, Name); 4503 agentID, auth_token, Name);
4466 } 4504 }
4467 4505
4468 return false; 4506 return false;
@@ -4488,8 +4526,8 @@ namespace OpenSim.Region.Framework.Scenes
4488 if (sp.DoNotCloseAfterTeleport) 4526 if (sp.DoNotCloseAfterTeleport)
4489 { 4527 {
4490 m_log.DebugFormat( 4528 m_log.DebugFormat(
4491 "[SCENE]: Not pre-closing {0} agent {1} in {2} since another simulator has re-established the child connection", 4529 "[SCENE]: Not pre-closing {0} agent {1} in {2} since another simulator has re-established the child connection",
4492 sp.IsChildAgent ? "child" : "root", sp.Name, Name); 4530 sp.IsChildAgent ? "child" : "root", sp.Name, Name);
4493 4531
4494 // Need to reset the flag so that a subsequent close after another teleport can succeed. 4532 // Need to reset the flag so that a subsequent close after another teleport can succeed.
4495 sp.DoNotCloseAfterTeleport = false; 4533 sp.DoNotCloseAfterTeleport = false;
@@ -4500,8 +4538,8 @@ namespace OpenSim.Region.Framework.Scenes
4500 if (sp.LifecycleState != ScenePresenceState.Running) 4538 if (sp.LifecycleState != ScenePresenceState.Running)
4501 { 4539 {
4502 m_log.DebugFormat( 4540 m_log.DebugFormat(
4503 "[SCENE]: Called IncomingPreCloseAgent() for {0} in {1} but presence is already in state {2}", 4541 "[SCENE]: Called IncomingPreCloseAgent() for {0} in {1} but presence is already in state {2}",
4504 sp.Name, Name, sp.LifecycleState); 4542 sp.Name, Name, sp.LifecycleState);
4505 4543
4506 return false; 4544 return false;
4507 } 4545 }
@@ -4527,21 +4565,21 @@ namespace OpenSim.Region.Framework.Scenes
4527 lock (m_removeClientLock) 4565 lock (m_removeClientLock)
4528 { 4566 {
4529 sp = GetScenePresence(agentID); 4567 sp = GetScenePresence(agentID);
4530 4568
4531 if (sp == null) 4569 if (sp == null)
4532 { 4570 {
4533 m_log.DebugFormat( 4571 m_log.DebugFormat(
4534 "[SCENE]: Called CloseClient() with agent ID {0} but no such presence is in {1}", 4572 "[SCENE]: Called CloseClient() with agent ID {0} but no such presence is in {1}",
4535 agentID, Name); 4573 agentID, Name);
4536 4574
4537 return false; 4575 return false;
4538 } 4576 }
4539 4577
4540 if (sp.LifecycleState != ScenePresenceState.Running && sp.LifecycleState != ScenePresenceState.PreRemove) 4578 if (sp.LifecycleState != ScenePresenceState.Running && sp.LifecycleState != ScenePresenceState.PreRemove)
4541 { 4579 {
4542 m_log.DebugFormat( 4580 m_log.DebugFormat(
4543 "[SCENE]: Called CloseClient() for {0} in {1} but presence is already in state {2}", 4581 "[SCENE]: Called CloseClient() for {0} in {1} but presence is already in state {2}",
4544 sp.Name, Name, sp.LifecycleState); 4582 sp.Name, Name, sp.LifecycleState);
4545 4583
4546 return false; 4584 return false;
4547 } 4585 }
@@ -4552,8 +4590,8 @@ namespace OpenSim.Region.Framework.Scenes
4552 if (sp.DoNotCloseAfterTeleport) 4590 if (sp.DoNotCloseAfterTeleport)
4553 { 4591 {
4554 m_log.DebugFormat( 4592 m_log.DebugFormat(
4555 "[SCENE]: Not closing {0} agent {1} in {2} since another simulator has re-established the child connection", 4593 "[SCENE]: Not closing {0} agent {1} in {2} since another simulator has re-established the child connection",
4556 sp.IsChildAgent ? "child" : "root", sp.Name, Name); 4594 sp.IsChildAgent ? "child" : "root", sp.Name, Name);
4557 4595
4558 // Need to reset the flag so that a subsequent close after another teleport can succeed. 4596 // Need to reset the flag so that a subsequent close after another teleport can succeed.
4559 sp.DoNotCloseAfterTeleport = false; 4597 sp.DoNotCloseAfterTeleport = false;
@@ -4581,7 +4619,7 @@ namespace OpenSim.Region.Framework.Scenes
4581 /// <param name="lookAt"></param> 4619 /// <param name="lookAt"></param>
4582 /// <param name="teleportFlags"></param> 4620 /// <param name="teleportFlags"></param>
4583 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, 4621 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
4584 Vector3 lookat, uint teleportFlags) 4622 Vector3 lookat, uint teleportFlags)
4585 { 4623 {
4586 GridRegion region = GridService.GetRegionByName(RegionInfo.ScopeID, regionName); 4624 GridRegion region = GridService.GetRegionByName(RegionInfo.ScopeID, regionName);
4587 4625
@@ -4604,7 +4642,7 @@ namespace OpenSim.Region.Framework.Scenes
4604 /// <param name="lookAt"></param> 4642 /// <param name="lookAt"></param>
4605 /// <param name="teleportFlags"></param> 4643 /// <param name="teleportFlags"></param>
4606 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, 4644 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position,
4607 Vector3 lookAt, uint teleportFlags) 4645 Vector3 lookAt, uint teleportFlags)
4608 { 4646 {
4609 ScenePresence sp = GetScenePresence(remoteClient.AgentId); 4647 ScenePresence sp = GetScenePresence(remoteClient.AgentId);
4610 if (sp != null) 4648 if (sp != null)
@@ -4703,8 +4741,8 @@ namespace OpenSim.Region.Framework.Scenes
4703 if (part.Name == cmdparams[2]) 4741 if (part.Name == cmdparams[2])
4704 { 4742 {
4705 part.Resize( 4743 part.Resize(
4706 new Vector3(Convert.ToSingle(cmdparams[3]), Convert.ToSingle(cmdparams[4]), 4744 new Vector3(Convert.ToSingle(cmdparams[3]), Convert.ToSingle(cmdparams[4]),
4707 Convert.ToSingle(cmdparams[5]))); 4745 Convert.ToSingle(cmdparams[5])));
4708 4746
4709 m_log.DebugFormat("Edited scale of Primitive: {0}", part.Name); 4747 m_log.DebugFormat("Edited scale of Primitive: {0}", part.Name);
4710 } 4748 }
@@ -4749,7 +4787,7 @@ namespace OpenSim.Region.Framework.Scenes
4749 4787
4750 #region Script Engine 4788 #region Script Engine
4751 4789
4752 private bool ScriptDanger(SceneObjectPart part,Vector3 pos) 4790 private bool ScriptDanger(SceneObjectPart part, Vector3 pos)
4753 { 4791 {
4754 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); 4792 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
4755 if (part != null) 4793 if (part != null)
@@ -4765,7 +4803,7 @@ namespace OpenSim.Region.Framework.Scenes
4765 return true; 4803 return true;
4766 } 4804 }
4767 else if (((parcel.LandData.Flags & (uint)ParcelFlags.AllowGroupScripts) != 0) 4805 else if (((parcel.LandData.Flags & (uint)ParcelFlags.AllowGroupScripts) != 0)
4768 && (parcel.LandData.GroupID != UUID.Zero) && (parcel.LandData.GroupID == part.GroupID)) 4806 && (parcel.LandData.GroupID != UUID.Zero) && (parcel.LandData.GroupID == part.GroupID))
4769 { 4807 {
4770 return true; 4808 return true;
4771 } 4809 }
@@ -5107,15 +5145,15 @@ namespace OpenSim.Region.Framework.Scenes
5107 #endregion 5145 #endregion
5108 5146
5109 5147
5110// Commented pending deletion since this method no longer appears to do anything at all 5148 // Commented pending deletion since this method no longer appears to do anything at all
5111// public bool NeedSceneCacheClear(UUID agentID) 5149 // public bool NeedSceneCacheClear(UUID agentID)
5112// { 5150 // {
5113// IInventoryTransferModule inv = RequestModuleInterface<IInventoryTransferModule>(); 5151 // IInventoryTransferModule inv = RequestModuleInterface<IInventoryTransferModule>();
5114// if (inv == null) 5152 // if (inv == null)
5115// return true; 5153 // return true;
5116// 5154 //
5117// return inv.NeedSceneCacheClear(agentID, this); 5155 // return inv.NeedSceneCacheClear(agentID, this);
5118// } 5156 // }
5119 5157
5120 public void CleanTempObjects() 5158 public void CleanTempObjects()
5121 { 5159 {
@@ -5131,7 +5169,7 @@ namespace OpenSim.Region.Framework.Scenes
5131 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) 5169 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
5132 { 5170 {
5133 if (grp.RootPart.Expires <= DateTime.Now) 5171 if (grp.RootPart.Expires <= DateTime.Now)
5134 DeleteSceneObject(grp, false); 5172 DeleteSceneObject(grp, false);
5135 } 5173 }
5136 } 5174 }
5137 } 5175 }
@@ -5157,21 +5195,21 @@ namespace OpenSim.Region.Framework.Scenes
5157 // 3 = We have seen a new user enter within the past 4 minutes 5195 // 3 = We have seen a new user enter within the past 4 minutes
5158 // which can be seen as positive confirmation of sim health 5196 // which can be seen as positive confirmation of sim health
5159 // 5197 //
5160 int health=1; // Start at 1, means we're up 5198 int health = 1; // Start at 1, means we're up
5161 5199
5162 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) 5200 if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000)
5163 health += 1; 5201 health += 1;
5164 else 5202 else
5165 return health; 5203 return health;
5166 5204
5167 // A login in the last 4 mins? We can't be doing too badly 5205 // A login in the last 4 mins? We can't be doing too badly
5168 // 5206 //
5169 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 5207 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000)
5170 health++; 5208 health++;
5171 else 5209 else
5172 return health; 5210 return health;
5173 5211
5174// CheckHeartbeat(); 5212 // CheckHeartbeat();
5175 5213
5176 return health; 5214 return health;
5177 } 5215 }
@@ -5201,41 +5239,41 @@ namespace OpenSim.Region.Framework.Scenes
5201 jointProxyObject.AngularVelocity = trackedBody.AngularVelocity; 5239 jointProxyObject.AngularVelocity = trackedBody.AngularVelocity;
5202 switch (joint.Type) 5240 switch (joint.Type)
5203 { 5241 {
5204 case PhysicsJointType.Ball: 5242 case PhysicsJointType.Ball:
5205 { 5243 {
5206 Vector3 jointAnchor = PhysicsScene.GetJointAnchor(joint); 5244 Vector3 jointAnchor = PhysicsScene.GetJointAnchor(joint);
5207 Vector3 proxyPos = jointAnchor; 5245 Vector3 proxyPos = jointAnchor;
5208 jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos); // schedules the entire group for a terse update 5246 jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos); // schedules the entire group for a terse update
5209 } 5247 }
5210 break; 5248 break;
5211 5249
5212 case PhysicsJointType.Hinge: 5250 case PhysicsJointType.Hinge:
5213 { 5251 {
5214 Vector3 jointAnchor = PhysicsScene.GetJointAnchor(joint); 5252 Vector3 jointAnchor = PhysicsScene.GetJointAnchor(joint);
5215 5253
5216 // Normally, we would just ask the physics scene to return the axis for the joint. 5254 // Normally, we would just ask the physics scene to return the axis for the joint.
5217 // Unfortunately, ODE sometimes returns <0,0,0> for the joint axis, which should 5255 // Unfortunately, ODE sometimes returns <0,0,0> for the joint axis, which should
5218 // never occur. Therefore we cannot rely on ODE to always return a correct joint axis. 5256 // never occur. Therefore we cannot rely on ODE to always return a correct joint axis.
5219 // Therefore the following call does not always work: 5257 // Therefore the following call does not always work:
5220 //PhysicsVector phyJointAxis = _PhyScene.GetJointAxis(joint); 5258 //PhysicsVector phyJointAxis = _PhyScene.GetJointAxis(joint);
5221 5259
5222 // instead we compute the joint orientation by saving the original joint orientation 5260 // instead we compute the joint orientation by saving the original joint orientation
5223 // relative to one of the jointed bodies, and applying this transformation 5261 // relative to one of the jointed bodies, and applying this transformation
5224 // to the current position of the jointed bodies (the tracked body) to compute the 5262 // to the current position of the jointed bodies (the tracked body) to compute the
5225 // current joint orientation. 5263 // current joint orientation.
5226 5264
5227 if (joint.TrackedBodyName == null) 5265 if (joint.TrackedBodyName == null)
5228 { 5266 {
5229 jointErrorMessage(joint, "joint.TrackedBodyName is null, joint " + joint.ObjectNameInScene); 5267 jointErrorMessage(joint, "joint.TrackedBodyName is null, joint " + joint.ObjectNameInScene);
5230 } 5268 }
5231 5269
5232 Vector3 proxyPos = jointAnchor; 5270 Vector3 proxyPos = jointAnchor;
5233 Quaternion q = trackedBody.RotationOffset * joint.LocalRotation; 5271 Quaternion q = trackedBody.RotationOffset * joint.LocalRotation;
5234 5272
5235 jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos); // schedules the entire group for a terse update 5273 jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos); // schedules the entire group for a terse update
5236 jointProxyObject.ParentGroup.UpdateGroupRotationR(q); // schedules the entire group for a terse update 5274 jointProxyObject.ParentGroup.UpdateGroupRotationR(q); // schedules the entire group for a terse update
5237 } 5275 }
5238 break; 5276 break;
5239 } 5277 }
5240 } 5278 }
5241 5279
@@ -5276,30 +5314,30 @@ namespace OpenSim.Region.Framework.Scenes
5276 if (joint != null) 5314 if (joint != null)
5277 { 5315 {
5278 if (joint.ErrorMessageCount > PhysicsJoint.maxErrorMessages) 5316 if (joint.ErrorMessageCount > PhysicsJoint.maxErrorMessages)
5279 return; 5317 return;
5280 5318
5281 SceneObjectPart jointProxyObject = GetSceneObjectPart(joint.ObjectNameInScene); 5319 SceneObjectPart jointProxyObject = GetSceneObjectPart(joint.ObjectNameInScene);
5282 if (jointProxyObject != null) 5320 if (jointProxyObject != null)
5283 { 5321 {
5284 SimChat(Utils.StringToBytes("[NINJA]: " + message), 5322 SimChat(Utils.StringToBytes("[NINJA]: " + message),
5285 ChatTypeEnum.DebugChannel, 5323 ChatTypeEnum.DebugChannel,
5286 2147483647, 5324 2147483647,
5287 jointProxyObject.AbsolutePosition, 5325 jointProxyObject.AbsolutePosition,
5288 jointProxyObject.Name, 5326 jointProxyObject.Name,
5289 jointProxyObject.UUID, 5327 jointProxyObject.UUID,
5290 false); 5328 false);
5291 5329
5292 joint.ErrorMessageCount++; 5330 joint.ErrorMessageCount++;
5293 5331
5294 if (joint.ErrorMessageCount > PhysicsJoint.maxErrorMessages) 5332 if (joint.ErrorMessageCount > PhysicsJoint.maxErrorMessages)
5295 { 5333 {
5296 SimChat(Utils.StringToBytes("[NINJA]: Too many messages for this joint, suppressing further messages."), 5334 SimChat(Utils.StringToBytes("[NINJA]: Too many messages for this joint, suppressing further messages."),
5297 ChatTypeEnum.DebugChannel, 5335 ChatTypeEnum.DebugChannel,
5298 2147483647, 5336 2147483647,
5299 jointProxyObject.AbsolutePosition, 5337 jointProxyObject.AbsolutePosition,
5300 jointProxyObject.Name, 5338 jointProxyObject.Name,
5301 jointProxyObject.UUID, 5339 jointProxyObject.UUID,
5302 false); 5340 false);
5303 } 5341 }
5304 } 5342 }
5305 else 5343 else
@@ -5312,9 +5350,9 @@ namespace OpenSim.Region.Framework.Scenes
5312 public Scene ConsoleScene() 5350 public Scene ConsoleScene()
5313 { 5351 {
5314 if (MainConsole.Instance == null) 5352 if (MainConsole.Instance == null)
5315 return null; 5353 return null;
5316 if (MainConsole.Instance.ConsoleScene is Scene) 5354 if (MainConsole.Instance.ConsoleScene is Scene)
5317 return (Scene)MainConsole.Instance.ConsoleScene; 5355 return (Scene)MainConsole.Instance.ConsoleScene;
5318 return null; 5356 return null;
5319 } 5357 }
5320 5358
@@ -5325,13 +5363,13 @@ namespace OpenSim.Region.Framework.Scenes
5325 public float GetGroundHeight(float x, float y) 5363 public float GetGroundHeight(float x, float y)
5326 { 5364 {
5327 if (x < 0) 5365 if (x < 0)
5328 x = 0; 5366 x = 0;
5329 if (x >= Heightmap.Width) 5367 if (x >= Heightmap.Width)
5330 x = Heightmap.Width - 1; 5368 x = Heightmap.Width - 1;
5331 if (y < 0) 5369 if (y < 0)
5332 y = 0; 5370 y = 0;
5333 if (y >= Heightmap.Height) 5371 if (y >= Heightmap.Height)
5334 y = Heightmap.Height - 1; 5372 y = Heightmap.Height - 1;
5335 5373
5336 Vector3 p0 = new Vector3(x, y, (float)Heightmap[(int)x, (int)y]); 5374 Vector3 p0 = new Vector3(x, y, (float)Heightmap[(int)x, (int)y]);
5337 Vector3 p1 = p0; 5375 Vector3 p1 = p0;
@@ -5339,11 +5377,11 @@ namespace OpenSim.Region.Framework.Scenes
5339 5377
5340 p1.X += 1.0f; 5378 p1.X += 1.0f;
5341 if (p1.X < Heightmap.Width) 5379 if (p1.X < Heightmap.Width)
5342 p1.Z = (float)Heightmap[(int)p1.X, (int)p1.Y]; 5380 p1.Z = (float)Heightmap[(int)p1.X, (int)p1.Y];
5343 5381
5344 p2.Y += 1.0f; 5382 p2.Y += 1.0f;
5345 if (p2.Y < Heightmap.Height) 5383 if (p2.Y < Heightmap.Height)
5346 p2.Z = (float)Heightmap[(int)p2.X, (int)p2.Y]; 5384 p2.Z = (float)Heightmap[(int)p2.X, (int)p2.Y];
5347 5385
5348 Vector3 v0 = new Vector3(p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z); 5386 Vector3 v0 = new Vector3(p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z);
5349 Vector3 v1 = new Vector3(p2.X - p0.X, p2.Y - p0.Y, p2.Z - p0.Z); 5387 Vector3 v1 = new Vector3(p2.X - p0.X, p2.Y - p0.Y, p2.Z - p0.Z);
@@ -5363,14 +5401,14 @@ namespace OpenSim.Region.Framework.Scenes
5363 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; 5401 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
5364 } 5402 }
5365 5403
5366// private void CheckHeartbeat() 5404 // private void CheckHeartbeat()
5367// { 5405 // {
5368// if (m_firstHeartbeat) 5406 // if (m_firstHeartbeat)
5369// return; 5407 // return;
5370// 5408 //
5371// if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) 5409 // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000)
5372// StartTimer(); 5410 // StartTimer();
5373// } 5411 // }
5374 5412
5375 public override ISceneObject DeserializeObject(string representation) 5413 public override ISceneObject DeserializeObject(string representation)
5376 { 5414 {
@@ -5413,7 +5451,7 @@ namespace OpenSim.Region.Framework.Scenes
5413 } 5451 }
5414 5452
5415 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); 5453 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
5416 if (dest != excludeParcel) 5454 if (dest != excludeParcel)
5417 { 5455 {
5418 // Ultimate backup if we have no idea where they are and 5456 // Ultimate backup if we have no idea where they are and
5419 // the last allowed position was in another parcel 5457 // the last allowed position was in another parcel
@@ -5523,9 +5561,9 @@ namespace OpenSim.Region.Framework.Scenes
5523 private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar) 5561 private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar)
5524 { 5562 {
5525 float xdistance = avatar.AbsolutePosition.X < RegionInfo.RegionSizeX / 2 5563 float xdistance = avatar.AbsolutePosition.X < RegionInfo.RegionSizeX / 2
5526 ? avatar.AbsolutePosition.X : RegionInfo.RegionSizeX - avatar.AbsolutePosition.X; 5564 ? avatar.AbsolutePosition.X : RegionInfo.RegionSizeX - avatar.AbsolutePosition.X;
5527 float ydistance = avatar.AbsolutePosition.Y < RegionInfo.RegionSizeY / 2 5565 float ydistance = avatar.AbsolutePosition.Y < RegionInfo.RegionSizeY / 2
5528 ? avatar.AbsolutePosition.Y : RegionInfo.RegionSizeY - avatar.AbsolutePosition.Y; 5566 ? avatar.AbsolutePosition.Y : RegionInfo.RegionSizeY - avatar.AbsolutePosition.Y;
5529 5567
5530 //find out what vertical edge to go to 5568 //find out what vertical edge to go to
5531 if (xdistance < ydistance) 5569 if (xdistance < ydistance)
@@ -5572,7 +5610,7 @@ namespace OpenSim.Region.Framework.Scenes
5572 { 5610 {
5573 IEstateDataService estateDataService = EstateDataService; 5611 IEstateDataService estateDataService = EstateDataService;
5574 if (estateDataService == null) 5612 if (estateDataService == null)
5575 return new List<UUID>(0); 5613 return new List<UUID>(0);
5576 5614
5577 return estateDataService.GetRegions(estateID); 5615 return estateDataService.GetRegions(estateID);
5578 } 5616 }
@@ -5595,8 +5633,8 @@ namespace OpenSim.Region.Framework.Scenes
5595 private void HandleReloadEstate(string module, string[] cmd) 5633 private void HandleReloadEstate(string module, string[] cmd)
5596 { 5634 {
5597 if (MainConsole.Instance.ConsoleScene == null || 5635 if (MainConsole.Instance.ConsoleScene == null ||
5598 (MainConsole.Instance.ConsoleScene is Scene && 5636 (MainConsole.Instance.ConsoleScene is Scene &&
5599 (Scene)MainConsole.Instance.ConsoleScene == this)) 5637 (Scene)MainConsole.Instance.ConsoleScene == this))
5600 { 5638 {
5601 ReloadEstateData(); 5639 ReloadEstateData();
5602 } 5640 }
@@ -5614,8 +5652,8 @@ namespace OpenSim.Region.Framework.Scenes
5614 /// <param name="maxZ"></param> 5652 /// <param name="maxZ"></param>
5615 /// <returns></returns> 5653 /// <returns></returns>
5616 public static Vector3[] GetCombinedBoundingBox( 5654 public static Vector3[] GetCombinedBoundingBox(
5617 List<SceneObjectGroup> objects, 5655 List<SceneObjectGroup> objects,
5618 out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) 5656 out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ)
5619 { 5657 {
5620 minX = float.MaxValue; 5658 minX = float.MaxValue;
5621 maxX = float.MinValue; 5659 maxX = float.MinValue;
@@ -5633,10 +5671,10 @@ namespace OpenSim.Region.Framework.Scenes
5633 Vector3 vec = g.AbsolutePosition; 5671 Vector3 vec = g.AbsolutePosition;
5634 5672
5635 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); 5673 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
5636 5674
5637// m_log.DebugFormat( 5675 // m_log.DebugFormat(
5638// "[SCENE]: For {0} found AxisAlignedBoundingBoxRaw {1}, {2}", 5676 // "[SCENE]: For {0} found AxisAlignedBoundingBoxRaw {1}, {2}",
5639// g.Name, new Vector3(ominX, ominY, ominZ), new Vector3(omaxX, omaxY, omaxZ)); 5677 // g.Name, new Vector3(ominX, ominY, ominZ), new Vector3(omaxX, omaxY, omaxZ));
5640 5678
5641 ominX += vec.X; 5679 ominX += vec.X;
5642 omaxX += vec.X; 5680 omaxX += vec.X;
@@ -5646,17 +5684,17 @@ namespace OpenSim.Region.Framework.Scenes
5646 omaxZ += vec.Z; 5684 omaxZ += vec.Z;
5647 5685
5648 if (minX > ominX) 5686 if (minX > ominX)
5649 minX = ominX; 5687 minX = ominX;
5650 if (minY > ominY) 5688 if (minY > ominY)
5651 minY = ominY; 5689 minY = ominY;
5652 if (minZ > ominZ) 5690 if (minZ > ominZ)
5653 minZ = ominZ; 5691 minZ = ominZ;
5654 if (maxX < omaxX) 5692 if (maxX < omaxX)
5655 maxX = omaxX; 5693 maxX = omaxX;
5656 if (maxY < omaxY) 5694 if (maxY < omaxY)
5657 maxY = omaxY; 5695 maxY = omaxY;
5658 if (maxZ < omaxZ) 5696 if (maxZ < omaxZ)
5659 maxZ = omaxZ; 5697 maxZ = omaxZ;
5660 } 5698 }
5661 5699
5662 foreach (SceneObjectGroup g in objects) 5700 foreach (SceneObjectGroup g in objects)
@@ -5681,7 +5719,7 @@ namespace OpenSim.Region.Framework.Scenes
5681 { 5719 {
5682 IWorldMapModule mapModule = RequestModuleInterface<IWorldMapModule>(); 5720 IWorldMapModule mapModule = RequestModuleInterface<IWorldMapModule>();
5683 if (mapModule != null) 5721 if (mapModule != null)
5684 mapModule.GenerateMaptile(); 5722 mapModule.GenerateMaptile();
5685 } 5723 }
5686 5724
5687 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) 5725 private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e)
@@ -5692,7 +5730,7 @@ namespace OpenSim.Region.Framework.Scenes
5692 // so that all simulators can retrieve it 5730 // so that all simulators can retrieve it
5693 string error = GridService.RegisterRegion(RegionInfo.ScopeID, new GridRegion(RegionInfo)); 5731 string error = GridService.RegisterRegion(RegionInfo.ScopeID, new GridRegion(RegionInfo));
5694 if (error != string.Empty) 5732 if (error != string.Empty)
5695 throw new Exception(error); 5733 throw new Exception(error);
5696 } 5734 }
5697 5735
5698 /// <summary> 5736 /// <summary>
@@ -5722,7 +5760,7 @@ namespace OpenSim.Region.Framework.Scenes
5722 } 5760 }
5723 5761
5724 if (!AllowAvatarCrossing && !viaTeleport) 5762 if (!AllowAvatarCrossing && !viaTeleport)
5725 return false; 5763 return false;
5726 5764
5727 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. 5765 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5728 // However, the long term fix is to make sure root agent count is always accurate. 5766 // However, the long term fix is to make sure root agent count is always accurate.
@@ -5737,8 +5775,8 @@ namespace OpenSim.Region.Framework.Scenes
5737 reason = "The region is full"; 5775 reason = "The region is full";
5738 5776
5739 m_log.DebugFormat( 5777 m_log.DebugFormat(
5740 "[SCENE]: Denying presence with id {0} entry into {1} since region is at agent limit of {2}", 5778 "[SCENE]: Denying presence with id {0} entry into {1} since region is at agent limit of {2}",
5741 agentID, RegionInfo.RegionName, RegionInfo.RegionSettings.AgentLimit); 5779 agentID, RegionInfo.RegionName, RegionInfo.RegionSettings.AgentLimit);
5742 5780
5743 return false; 5781 return false;
5744 } 5782 }
@@ -5752,7 +5790,7 @@ namespace OpenSim.Region.Framework.Scenes
5752 { 5790 {
5753 client = presence.ControllingClient; 5791 client = presence.ControllingClient;
5754 if (client != null) 5792 if (client != null)
5755 aCircuit = client.RequestClientInfo(); 5793 aCircuit = client.RequestClientInfo();
5756 } 5794 }
5757 5795
5758 // We may be called before there is a presence or a client. 5796 // We may be called before there is a presence or a client.
@@ -5775,7 +5813,7 @@ namespace OpenSim.Region.Framework.Scenes
5775 } 5813 }
5776 catch (Exception e) 5814 catch (Exception e)
5777 { 5815 {
5778 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); 5816 m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} " + e.StackTrace, e.Message);
5779 reason = "Error authorizing agent: " + e.Message; 5817 reason = "Error authorizing agent: " + e.Message;
5780 return false; 5818 return false;
5781 } 5819 }
@@ -5794,16 +5832,16 @@ namespace OpenSim.Region.Framework.Scenes
5794 Vector3 spawnPoint = sp.GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); 5832 Vector3 spawnPoint = sp.GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
5795 ILandObject land = LandChannel.GetLandObject(spawnPoint.X, spawnPoint.Y); 5833 ILandObject land = LandChannel.GetLandObject(spawnPoint.X, spawnPoint.Y);
5796 if (land == null) 5834 if (land == null)
5797 continue; 5835 continue;
5798 if (land.IsEitherBannedOrRestricted(agentID)) 5836 if (land.IsEitherBannedOrRestricted(agentID))
5799 continue; 5837 continue;
5800 banned = false; 5838 banned = false;
5801 break; 5839 break;
5802 } 5840 }
5803 5841
5804 if (banned) 5842 if (banned)
5805 { 5843 {
5806 if(Permissions.IsAdministrator(agentID) == false || Permissions.IsGridGod(agentID) == false) 5844 if (Permissions.IsAdministrator(agentID) == false || Permissions.IsGridGod(agentID) == false)
5807 { 5845 {
5808 reason = "No suitable landing point found"; 5846 reason = "No suitable landing point found";
5809 return false; 5847 return false;
@@ -5839,9 +5877,9 @@ namespace OpenSim.Region.Framework.Scenes
5839 if (banned || restricted) 5877 if (banned || restricted)
5840 { 5878 {
5841 if (banned) 5879 if (banned)
5842 reason = "You are banned from the parcel"; 5880 reason = "You are banned from the parcel";
5843 else 5881 else
5844 reason = "The parcel is restricted"; 5882 reason = "The parcel is restricted";
5845 return false; 5883 return false;
5846 } 5884 }
5847 } 5885 }
@@ -5863,15 +5901,15 @@ namespace OpenSim.Region.Framework.Scenes
5863 if (presence.MovingToTarget) 5901 if (presence.MovingToTarget)
5864 { 5902 {
5865 double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget); 5903 double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget);
5866// m_log.DebugFormat( 5904 // m_log.DebugFormat(
5867// "[SCENE]: Abs pos of {0} is {1}, target {2}, distance {3}", 5905 // "[SCENE]: Abs pos of {0} is {1}, target {2}, distance {3}",
5868// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget); 5906 // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget);
5869 5907
5870 // Check the error term of the current position in relation to the target position 5908 // Check the error term of the current position in relation to the target position
5871 if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT) 5909 if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT)
5872 { 5910 {
5873 // We are close enough to the target 5911 // We are close enough to the target
5874// m_log.DebugFormat("[SCENEE]: Stopping autopilot of {0}", presence.Name); 5912 // m_log.DebugFormat("[SCENEE]: Stopping autopilot of {0}", presence.Name);
5875 5913
5876 presence.Velocity = Vector3.Zero; 5914 presence.Velocity = Vector3.Zero;
5877 presence.AbsolutePosition = presence.MoveToPositionTarget; 5915 presence.AbsolutePosition = presence.MoveToPositionTarget;
@@ -5885,28 +5923,28 @@ namespace OpenSim.Region.Framework.Scenes
5885 // least be able to set collision status once, rather than 5 times to give it enough 5923 // least be able to set collision status once, rather than 5 times to give it enough
5886 // weighting so that that PhysicsActor thinks it really is colliding. 5924 // weighting so that that PhysicsActor thinks it really is colliding.
5887 for (int i = 0; i < 5; i++) 5925 for (int i = 0; i < 5; i++)
5888 presence.IsColliding = true; 5926 presence.IsColliding = true;
5889 5927
5890 if (presence.LandAtTarget) 5928 if (presence.LandAtTarget)
5891 presence.Flying = false; 5929 presence.Flying = false;
5892 5930
5893// Vector3 targetPos = presence.MoveToPositionTarget; 5931 // Vector3 targetPos = presence.MoveToPositionTarget;
5894// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; 5932 // float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
5895// if (targetPos.Z - terrainHeight < 0.2) 5933 // if (targetPos.Z - terrainHeight < 0.2)
5896// { 5934 // {
5897// presence.Flying = false; 5935 // presence.Flying = false;
5898// } 5936 // }
5899 } 5937 }
5900 5938
5901// m_log.DebugFormat( 5939 // m_log.DebugFormat(
5902// "[SCENE]: AgentControlFlags {0}, MovementFlag {1} for {2}", 5940 // "[SCENE]: AgentControlFlags {0}, MovementFlag {1} for {2}",
5903// presence.AgentControlFlags, presence.MovementFlag, presence.Name); 5941 // presence.AgentControlFlags, presence.MovementFlag, presence.Name);
5904 } 5942 }
5905 else 5943 else
5906 { 5944 {
5907// m_log.DebugFormat( 5945 // m_log.DebugFormat(
5908// "[SCENE]: Updating npc {0} at {1} for next movement to {2}", 5946 // "[SCENE]: Updating npc {0} at {1} for next movement to {2}",
5909// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); 5947 // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget);
5910 5948
5911 Vector3 agent_control_v3 = new Vector3(); 5949 Vector3 agent_control_v3 = new Vector3();
5912 presence.HandleMoveToTargetUpdate(1, ref agent_control_v3); 5950 presence.HandleMoveToTargetUpdate(1, ref agent_control_v3);
@@ -5921,11 +5959,11 @@ namespace OpenSim.Region.Framework.Scenes
5921 int spawnpoints = RegionInfo.RegionSettings.SpawnPoints().Count; 5959 int spawnpoints = RegionInfo.RegionSettings.SpawnPoints().Count;
5922 5960
5923 if (spawnpoints == 0) 5961 if (spawnpoints == 0)
5924 return 0; 5962 return 0;
5925 5963
5926 m_SpawnPoint++; 5964 m_SpawnPoint++;
5927 if (m_SpawnPoint > spawnpoints) 5965 if (m_SpawnPoint > spawnpoints)
5928 m_SpawnPoint = 1; 5966 m_SpawnPoint = 1;
5929 return m_SpawnPoint - 1; 5967 return m_SpawnPoint - 1;
5930 } 5968 }
5931 5969
@@ -5955,12 +5993,12 @@ namespace OpenSim.Region.Framework.Scenes
5955 public string GetExtraSetting(string name) 5993 public string GetExtraSetting(string name)
5956 { 5994 {
5957 if (m_extraSettings == null) 5995 if (m_extraSettings == null)
5958 return String.Empty; 5996 return String.Empty;
5959 5997
5960 string val; 5998 string val;
5961 5999
5962 if (!m_extraSettings.TryGetValue(name, out val)) 6000 if (!m_extraSettings.TryGetValue(name, out val))
5963 return String.Empty; 6001 return String.Empty;
5964 6002
5965 return val; 6003 return val;
5966 } 6004 }
@@ -5968,14 +6006,14 @@ namespace OpenSim.Region.Framework.Scenes
5968 public void StoreExtraSetting(string name, string val) 6006 public void StoreExtraSetting(string name, string val)
5969 { 6007 {
5970 if (m_extraSettings == null) 6008 if (m_extraSettings == null)
5971 return; 6009 return;
5972 6010
5973 string oldVal; 6011 string oldVal;
5974 6012
5975 if (m_extraSettings.TryGetValue(name, out oldVal)) 6013 if (m_extraSettings.TryGetValue(name, out oldVal))
5976 { 6014 {
5977 if (oldVal == val) 6015 if (oldVal == val)
5978 return; 6016 return;
5979 } 6017 }
5980 6018
5981 m_extraSettings[name] = val; 6019 m_extraSettings[name] = val;
@@ -5988,10 +6026,10 @@ namespace OpenSim.Region.Framework.Scenes
5988 public void RemoveExtraSetting(string name) 6026 public void RemoveExtraSetting(string name)
5989 { 6027 {
5990 if (m_extraSettings == null) 6028 if (m_extraSettings == null)
5991 return; 6029 return;
5992 6030
5993 if (!m_extraSettings.ContainsKey(name)) 6031 if (!m_extraSettings.ContainsKey(name))
5994 return; 6032 return;
5995 6033
5996 m_extraSettings.Remove(name); 6034 m_extraSettings.Remove(name);
5997 6035
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 51f50d9..c2e9b61 100644..100755
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -67,7 +67,9 @@ namespace OpenSim.Region.Framework.Scenes
67 protected Scene m_parentScene; 67 protected Scene m_parentScene;
68 protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>(); 68 protected Dictionary<UUID, SceneObjectGroup> m_updateList = new Dictionary<UUID, SceneObjectGroup>();
69 protected int m_numRootAgents = 0; 69 protected int m_numRootAgents = 0;
70 protected int m_numTotalPrim = 0;
70 protected int m_numPrim = 0; 71 protected int m_numPrim = 0;
72 protected int m_numMesh = 0;
71 protected int m_numChildAgents = 0; 73 protected int m_numChildAgents = 0;
72 protected int m_physicalPrim = 0; 74 protected int m_physicalPrim = 0;
73 75
@@ -368,7 +370,8 @@ namespace OpenSim.Region.Framework.Scenes
368 370
369 SceneObjectPart[] parts = sceneObject.Parts; 371 SceneObjectPart[] parts = sceneObject.Parts;
370 372
371 // Clamp child prim sizes and add child prims to the m_numPrim count 373 // Clamp the sizes (scales) of the child prims and add the child prims to the count of all primitives
374 // (meshes and geometric primitives) in the scene; add child prims to m_numTotalPrim count
372 if (m_parentScene.m_clampPrimSize) 375 if (m_parentScene.m_clampPrimSize)
373 { 376 {
374 foreach (SceneObjectPart part in parts) 377 foreach (SceneObjectPart part in parts)
@@ -382,7 +385,19 @@ namespace OpenSim.Region.Framework.Scenes
382 part.Shape.Scale = scale; 385 part.Shape.Scale = scale;
383 } 386 }
384 } 387 }
385 m_numPrim += parts.Length; 388 m_numTotalPrim += parts.Length;
389
390 // Go through all parts (geometric primitives and meshes) of this Scene Object
391 foreach (SceneObjectPart part in parts)
392 {
393 // Keep track of the total number of meshes or geometric primitives now in the scene;
394 // determine which object this is based on its primitive type: sculpted (sculpt) prim refers to
395 // a mesh and all other prims (i.e. box, sphere, etc) are geometric primitives
396 if (part.GetPrimType() == PrimType.SCULPT)
397 m_numMesh++;
398 else
399 m_numPrim++;
400 }
386 401
387 sceneObject.AttachToScene(m_parentScene); 402 sceneObject.AttachToScene(m_parentScene);
388 403
@@ -437,7 +452,21 @@ namespace OpenSim.Region.Framework.Scenes
437 452
438 if (!resultOfObjectLinked) 453 if (!resultOfObjectLinked)
439 { 454 {
440 m_numPrim -= grp.PrimCount; 455 // Decrement the total number of primitives (meshes and geometric primitives)
456 // that are part of the Scene Object being removed
457 m_numTotalPrim -= grp.PrimCount;
458
459 // Go through all parts (primitives and meshes) of this Scene Object
460 foreach (SceneObjectPart part in grp.Parts)
461 {
462 // Keep track of the total number of meshes or geometric primitives left in the scene;
463 // determine which object this is based on its primitive type: sculpted (sculpt) prim refers to
464 // a mesh and all other prims (i.e. box, sphere, etc) are geometric primitives
465 if (part.GetPrimType() == PrimType.SCULPT)
466 m_numMesh--;
467 else
468 m_numPrim--;
469 }
441 470
442 if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics) 471 if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics)
443 RemovePhysicalPrim(grp.PrimCount); 472 RemovePhysicalPrim(grp.PrimCount);
@@ -687,9 +716,19 @@ namespace OpenSim.Region.Framework.Scenes
687 716
688 public int GetTotalObjectsCount() 717 public int GetTotalObjectsCount()
689 { 718 {
719 return m_numTotalPrim;
720 }
721
722 public int GetTotalPrimObjectsCount()
723 {
690 return m_numPrim; 724 return m_numPrim;
691 } 725 }
692 726
727 public int GetTotalMeshObjectsCount()
728 {
729 return m_numMesh;
730 }
731
693 public int GetActiveObjectsCount() 732 public int GetActiveObjectsCount()
694 { 733 {
695 return m_physicalPrim; 734 return m_physicalPrim;
@@ -1970,7 +2009,19 @@ namespace OpenSim.Region.Framework.Scenes
1970 // think it's selected, so it will never send a deselect... 2009 // think it's selected, so it will never send a deselect...
1971 copy.IsSelected = false; 2010 copy.IsSelected = false;
1972 2011
1973 m_numPrim += copy.Parts.Length; 2012 m_numTotalPrim += copy.Parts.Length;
2013
2014 // Go through all parts (primitives and meshes) of this Scene Object
2015 foreach (SceneObjectPart part in copy.Parts)
2016 {
2017 // Keep track of the total number of meshes or geometric primitives now in the scene;
2018 // determine which object this is based on its primitive type: sculpted (sculpt) prim refers to
2019 // a mesh and all other prims (i.e. box, sphere, etc) are geometric primitives
2020 if (part.GetPrimType() == PrimType.SCULPT)
2021 m_numMesh++;
2022 else
2023 m_numPrim++;
2024 }
1974 2025
1975 if (rot != Quaternion.Identity) 2026 if (rot != Quaternion.Identity)
1976 { 2027 {
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 6182bcd..8918c3b 100755
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -61,6 +61,10 @@ namespace OpenSim.Region.Framework.Scenes
61 61
62 private YourStatsAreWrong handlerStatsIncorrect; 62 private YourStatsAreWrong handlerStatsIncorrect;
63 63
64 // Determines the size of the array that is used to collect StatBlocks
65 // for sending to the SimStats and SimExtraStatsCollector
66 private const int m_statisticArraySize = 27;
67
64 /// <summary> 68 /// <summary>
65 /// These are the IDs of stats sent in the StatsPacket to the viewer. 69 /// These are the IDs of stats sent in the StatsPacket to the viewer.
66 /// </summary> 70 /// </summary>
@@ -104,7 +108,12 @@ namespace OpenSim.Region.Framework.Scenes
104 ScriptEps = 31, 108 ScriptEps = 31,
105 SimSpareMs = 32, 109 SimSpareMs = 32,
106 SimSleepMs = 33, 110 SimSleepMs = 33,
107 SimIoPumpTime = 34 111 SimIoPumpTime = 34,
112 FrameDilation = 35,
113 UsersLoggingIn = 36,
114 TotalGeoPrim = 37,
115 TotalMesh = 38,
116 ThreadCount = 39
108 } 117 }
109 118
110 /// <summary> 119 /// <summary>
@@ -175,7 +184,7 @@ namespace OpenSim.Region.Framework.Scenes
175 184
176 // saved last reported value so there is something available for llGetRegionFPS 185 // saved last reported value so there is something available for llGetRegionFPS
177 private float lastReportedSimFPS; 186 private float lastReportedSimFPS;
178 private float[] lastReportedSimStats = new float[22]; 187 private float[] lastReportedSimStats = new float[m_statisticArraySize];
179 private float m_pfps; 188 private float m_pfps;
180 189
181 /// <summary> 190 /// <summary>
@@ -202,6 +211,8 @@ namespace OpenSim.Region.Framework.Scenes
202 private int m_rootAgents; 211 private int m_rootAgents;
203 private int m_childAgents; 212 private int m_childAgents;
204 private int m_numPrim; 213 private int m_numPrim;
214 private int m_numGeoPrim;
215 private int m_numMesh;
205 private int m_inPacketsPerSecond; 216 private int m_inPacketsPerSecond;
206 private int m_outPacketsPerSecond; 217 private int m_outPacketsPerSecond;
207 private int m_activePrim; 218 private int m_activePrim;
@@ -214,26 +225,33 @@ namespace OpenSim.Region.Framework.Scenes
214 private int m_objectCapacity = 45000; 225 private int m_objectCapacity = 45000;
215 226
216 // This is the number of frames that will be stored and then averaged for 227 // This is the number of frames that will be stored and then averaged for
217 // the Total, Simulation, Physics, and Network Frame Time; It is set to 228 // the Total, Simulation, Physics, and Network Frame Time; It is set to
218 // 10 by default but can be changed by the OpenSim.ini configuration file 229 // 10 by default but can be changed by the OpenSim.ini configuration file
219 // NumberOfFrames parameter 230 // NumberOfFrames parameter
220 private int m_numberFramesStored = 10; 231 private int m_numberFramesStored = Scene.m_defaultNumberFramesStored;
221 232
222 // The arrays that will hold the time it took to run the past N frames, 233 // The arrays that will hold the time it took to run the past N frames,
223 // where N is the num_frames_to_average given by the configuration file 234 // where N is the num_frames_to_average given by the configuration file
224 private double[] m_totalFrameTimeMilliseconds; 235 private double[] m_totalFrameTimeMilliseconds;
225 private double[] m_simulationFrameTimeMilliseconds; 236 private double[] m_simulationFrameTimeMilliseconds;
226 private double[] m_physicsFrameTimeMilliseconds; 237 private double[] m_physicsFrameTimeMilliseconds;
227 private double[] m_networkFrameTimeMilliseconds; 238 private double[] m_networkFrameTimeMilliseconds;
228 239
229 // The location of the next time in milliseconds that will be 240 // The location of the next time in milliseconds that will be
230 // (over)written when the next frame completes 241 // (over)written when the next frame completes
231 private int m_nextLocation = 0; 242 private int m_nextLocation = 0;
232 243
233 // The correct number of frames that have completed since the last stats 244 // The correct number of frames that have completed since the last stats
234 // update for physics 245 // update for physics
235 private int m_numberPhysicsFrames; 246 private int m_numberPhysicsFrames;
236 247
248 // The current number of users attempting to login to the region
249 private int m_usersLoggingIn;
250
251 // The last reported value of threads from the SmartThreadPool inside of
252 // XEngine
253 private int m_inUseThreads;
254
237 private Scene m_scene; 255 private Scene m_scene;
238 256
239 private RegionInfo ReportingRegion; 257 private RegionInfo ReportingRegion;
@@ -246,11 +264,13 @@ namespace OpenSim.Region.Framework.Scenes
246 { 264 {
247 // Initialize the different frame time arrays to the correct sizes 265 // Initialize the different frame time arrays to the correct sizes
248 m_totalFrameTimeMilliseconds = new double[m_numberFramesStored]; 266 m_totalFrameTimeMilliseconds = new double[m_numberFramesStored];
249 m_simulationFrameTimeMilliseconds = new 267 m_simulationFrameTimeMilliseconds = new double[m_numberFramesStored];
250 double[m_numberFramesStored];
251 m_physicsFrameTimeMilliseconds = new double[m_numberFramesStored]; 268 m_physicsFrameTimeMilliseconds = new double[m_numberFramesStored];
252 m_networkFrameTimeMilliseconds = new double[m_numberFramesStored]; 269 m_networkFrameTimeMilliseconds = new double[m_numberFramesStored];
253 270
271 // Initialize the current number of users logging into the region
272 m_usersLoggingIn = 0;
273
254 m_scene = scene; 274 m_scene = scene;
255 m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps; 275 m_reportedFpsCorrectionFactor = scene.MinFrameSeconds * m_nominalReportedFps;
256 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000); 276 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
@@ -284,13 +304,14 @@ namespace OpenSim.Region.Framework.Scenes
284 StatsManager.RegisterStat(SlowFramesStat); 304 StatsManager.RegisterStat(SlowFramesStat);
285 } 305 }
286 306
307
287 public SimStatsReporter(Scene scene, int numberOfFrames) : this (scene) 308 public SimStatsReporter(Scene scene, int numberOfFrames) : this (scene)
288 { 309 {
289 // Store the number of frames from the OpenSim.ini configuration 310 // Store the number of frames from the OpenSim.ini configuration file
290 // file 311 m_numberFramesStored = numberOfFrames;
291 m_numberFramesStored = numberOfFrames;
292 } 312 }
293 313
314
294 public void Close() 315 public void Close()
295 { 316 {
296 m_report.Elapsed -= TriggerStatsHeartbeat; 317 m_report.Elapsed -= TriggerStatsHeartbeat;
@@ -328,11 +349,17 @@ namespace OpenSim.Region.Framework.Scenes
328 double simulationSumFrameTime; 349 double simulationSumFrameTime;
329 double physicsSumFrameTime; 350 double physicsSumFrameTime;
330 double networkSumFrameTime; 351 double networkSumFrameTime;
331 352 float frameDilation;
353 int currentFrame;
354
332 if (!m_scene.Active) 355 if (!m_scene.Active)
333 return; 356 return;
334 357
335 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; 358 // Create arrays to hold the statistics for this current scene,
359 // these will be passed to the SimExtraStatsCollector, they are also
360 // sent to the SimStats class
361 SimStatsPacket.StatBlock[] sb = new
362 SimStatsPacket.StatBlock[m_statisticArraySize];
336 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); 363 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
337 364
338 // Know what's not thread safe in Mono... modifying timers. 365 // Know what's not thread safe in Mono... modifying timers.
@@ -354,21 +381,21 @@ namespace OpenSim.Region.Framework.Scenes
354 381
355#region various statistic googly moogly 382#region various statistic googly moogly
356 383
357 // ORIGINAL code commented out until we have time to add our own 384 // ORIGINAL code commented out until we have time to add our own
358 // statistics to the statistics window, this will be done as a 385 // statistics to the statistics window, this will be done as a
359 // new section given the title of our current project 386 // new section given the title of our current project
360 // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently 387 // We're going to lie about the FPS because we've been lying since 2008. The actual FPS is currently
361 // locked at a maximum of 11. Maybe at some point this can change so that we're not lying. 388 // locked at a maximum of 11. Maybe at some point this can change so that we're not lying.
362 //int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); 389 //int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor);
363 int reportedFPS = m_fps; 390 int reportedFPS = m_fps;
364 391
365 // save the reported value so there is something available for llGetRegionFPS 392 // save the reported value so there is something available for llGetRegionFPS
366 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor; 393 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;
367 394
368 // ORIGINAL code commented out until we have time to add our own 395 // ORIGINAL code commented out until we have time to add our own
369 // statistics to the statistics window 396 // statistics to the statistics window
370 //float physfps = ((m_pfps / 1000)); 397 //float physfps = ((m_pfps / 1000));
371 float physfps = m_numberPhysicsFrames; 398 float physfps = m_numberPhysicsFrames;
372 399
373 //if (physfps > 600) 400 //if (physfps > 600)
374 //physfps = physfps - (physfps - 600); 401 //physfps = physfps - (physfps - 600);
@@ -381,6 +408,8 @@ namespace OpenSim.Region.Framework.Scenes
381 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); 408 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
382 m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); 409 m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
383 m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount(); 410 m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount();
411 m_numGeoPrim = m_scene.SceneGraph.GetTotalPrimObjectsCount();
412 m_numMesh = m_scene.SceneGraph.GetTotalMeshObjectsCount();
384 m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount(); 413 m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount();
385 m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount(); 414 m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();
386 415
@@ -406,11 +435,11 @@ namespace OpenSim.Region.Framework.Scenes
406 if (framesUpdated == 0) 435 if (framesUpdated == 0)
407 framesUpdated = 1; 436 framesUpdated = 1;
408 437
409 for (int i = 0; i < 22; i++) 438 for (int i = 0; i < m_statisticArraySize; i++)
410 { 439 {
411 sb[i] = new SimStatsPacket.StatBlock(); 440 sb[i] = new SimStatsPacket.StatBlock();
412 } 441 }
413 442
414 // Resetting the sums of the frame times to prevent any errors 443 // Resetting the sums of the frame times to prevent any errors
415 // in calculating the moving average for frame time 444 // in calculating the moving average for frame time
416 totalSumFrameTime = 0; 445 totalSumFrameTime = 0;
@@ -425,12 +454,25 @@ namespace OpenSim.Region.Framework.Scenes
425 // Sum up each frame time in order to calculate the moving 454 // Sum up each frame time in order to calculate the moving
426 // average of frame time 455 // average of frame time
427 totalSumFrameTime += m_totalFrameTimeMilliseconds[i]; 456 totalSumFrameTime += m_totalFrameTimeMilliseconds[i];
428 simulationSumFrameTime += 457 simulationSumFrameTime +=
429 m_simulationFrameTimeMilliseconds[i]; 458 m_simulationFrameTimeMilliseconds[i];
430 physicsSumFrameTime += m_physicsFrameTimeMilliseconds[i]; 459 physicsSumFrameTime += m_physicsFrameTimeMilliseconds[i];
431 networkSumFrameTime += m_networkFrameTimeMilliseconds[i]; 460 networkSumFrameTime += m_networkFrameTimeMilliseconds[i];
432 } 461 }
433 462
463 // Get the index that represents the current frame based on the next one known; go back
464 // to the last index if next one is stated to restart at 0
465 if (m_nextLocation == 0)
466 currentFrame = m_numberFramesStored - 1;
467 else
468 currentFrame = m_nextLocation - 1;
469
470 // Calculate the frame dilation; which is currently based on the ratio between the sum of the
471 // physics and simulation rate, and the set minimum time to run a scene's frame
472 frameDilation = (float)(m_simulationFrameTimeMilliseconds[currentFrame] +
473 m_physicsFrameTimeMilliseconds[currentFrame]) / m_scene.MinFrameTicks;
474
475 // ORIGINAL code commented out until we have time to add our own
434 sb[0].StatID = (uint) Stats.TimeDilation; 476 sb[0].StatID = (uint) Stats.TimeDilation;
435 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 477 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
436 478
@@ -455,31 +497,28 @@ namespace OpenSim.Region.Framework.Scenes
455 sb[7].StatID = (uint) Stats.ActivePrim; 497 sb[7].StatID = (uint) Stats.ActivePrim;
456 sb[7].StatValue = m_activePrim; 498 sb[7].StatValue = m_activePrim;
457 499
458 // ORIGINAL code commented out until we have time to add our own 500 // ORIGINAL code commented out until we have time to add our own
459 // statistics to the statistics window 501 // statistics to the statistics window
460 sb[8].StatID = (uint)Stats.FrameMS; 502 sb[8].StatID = (uint)Stats.FrameMS;
461 //sb[8].StatValue = m_frameMS / framesUpdated; 503 //sb[8].StatValue = m_frameMS / framesUpdated;
462 sb[8].StatValue = (float) totalSumFrameTime / 504 sb[8].StatValue = (float) totalSumFrameTime / m_numberFramesStored;
463 m_numberFramesStored;
464 505
465 sb[9].StatID = (uint)Stats.NetMS; 506 sb[9].StatID = (uint)Stats.NetMS;
466 //sb[9].StatValue = m_netMS / framesUpdated; 507 //sb[9].StatValue = m_netMS / framesUpdated;
467 sb[9].StatValue = (float) networkSumFrameTime / 508 sb[9].StatValue = (float) networkSumFrameTime / m_numberFramesStored;
468 m_numberFramesStored;
469 509
470 sb[10].StatID = (uint)Stats.PhysicsMS; 510 sb[10].StatID = (uint)Stats.PhysicsMS;
471 //sb[10].StatValue = m_physicsMS / framesUpdated; 511 //sb[10].StatValue = m_physicsMS / framesUpdated;
472 sb[10].StatValue = (float) physicsSumFrameTime / 512 sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored;
473 m_numberFramesStored;
474 513
475 sb[11].StatID = (uint)Stats.ImageMS ; 514 sb[11].StatID = (uint)Stats.ImageMS ;
476 sb[11].StatValue = m_imageMS / framesUpdated; 515 sb[11].StatValue = m_imageMS / framesUpdated;
477 516
478 sb[12].StatID = (uint)Stats.OtherMS; 517 sb[12].StatID = (uint)Stats.OtherMS;
479 //sb[12].StatValue = m_otherMS / framesUpdated; 518 //sb[12].StatValue = m_otherMS / framesUpdated;
480 sb[12].StatValue = (float) simulationSumFrameTime / 519 sb[12].StatValue = (float) simulationSumFrameTime /
481 m_numberFramesStored; 520 m_numberFramesStored;
482 521
483 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 522 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
484 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); 523 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
485 524
@@ -507,7 +546,28 @@ namespace OpenSim.Region.Framework.Scenes
507 sb[21].StatID = (uint)Stats.SimSpareMs; 546 sb[21].StatID = (uint)Stats.SimSpareMs;
508 sb[21].StatValue = m_spareMS / framesUpdated; 547 sb[21].StatValue = m_spareMS / framesUpdated;
509 548
510 for (int i = 0; i < 22; i++) 549 // Current ratio between the sum of physics and sim rate, and the
550 // minimum time to run a scene's frame
551 sb[22].StatID = (uint)Stats.FrameDilation;
552 sb[22].StatValue = frameDilation;
553
554 // Current number of users currently attemptint to login to region
555 sb[23].StatID = (uint)Stats.UsersLoggingIn;
556 sb[23].StatValue = m_usersLoggingIn;
557
558 // Total number of geometric primitives in the scene
559 sb[24].StatID = (uint)Stats.TotalGeoPrim;
560 sb[24].StatValue = m_numGeoPrim;
561
562 // Total number of mesh objects in the scene
563 sb[25].StatID = (uint)Stats.TotalMesh;
564 sb[25].StatValue = m_numMesh;
565
566 // Current number of threads that XEngine is using
567 sb[26].StatID = (uint)Stats.ThreadCount;
568 sb[26].StatValue = m_inUseThreads;
569
570 for (int i = 0; i < m_statisticArraySize; i++)
511 { 571 {
512 lastReportedSimStats[i] = sb[i].StatValue; 572 lastReportedSimStats[i] = sb[i].StatValue;
513 } 573 }
@@ -554,8 +614,8 @@ namespace OpenSim.Region.Framework.Scenes
554 { 614 {
555 // Reset the number of frames that the physics library has 615 // Reset the number of frames that the physics library has
556 // processed since the last stats report 616 // processed since the last stats report
557 m_numberPhysicsFrames = 0; 617 m_numberPhysicsFrames = 0;
558 618
559 m_timeDilation = 0; 619 m_timeDilation = 0;
560 m_fps = 0; 620 m_fps = 0;
561 m_pfps = 0; 621 m_pfps = 0;
@@ -686,32 +746,32 @@ namespace OpenSim.Region.Framework.Scenes
686 m_otherMS += ms; 746 m_otherMS += ms;
687 } 747 }
688 748
689 public void addPhysicsFrame(int frames) 749 public void addPhysicsFrame(int frames)
690 { 750 {
691 // Add the number of physics frames to the correct total physics 751 // Add the number of physics frames to the correct total physics
692 // frames 752 // frames
693 m_numberPhysicsFrames += frames; 753 m_numberPhysicsFrames += frames;
694 } 754 }
695 755
696 public void addFrameTimeMilliseconds(double total, double simulation, 756 public void addFrameTimeMilliseconds(double total, double simulation,
697 double physics, double network) 757 double physics, double network)
698 { 758 {
699 // Save the frame times from the current frame into the appropriate 759 // Save the frame times from the current frame into the appropriate
700 // arrays 760 // arrays
701 m_totalFrameTimeMilliseconds[m_nextLocation] = total; 761 m_totalFrameTimeMilliseconds[m_nextLocation] = total;
702 m_simulationFrameTimeMilliseconds[m_nextLocation] = simulation; 762 m_simulationFrameTimeMilliseconds[m_nextLocation] = simulation;
703 m_physicsFrameTimeMilliseconds[m_nextLocation] = physics; 763 m_physicsFrameTimeMilliseconds[m_nextLocation] = physics;
704 m_networkFrameTimeMilliseconds[m_nextLocation] = network; 764 m_networkFrameTimeMilliseconds[m_nextLocation] = network;
705 765
706 // Update to the next location in the list 766 // Update to the next location in the list
707 m_nextLocation++; 767 m_nextLocation++;
768
769 // Since the list will begin to overwrite the oldest frame values
770 // first, the next location needs to loop back to the beginning of the
771 // list whenever it reaches the end
772 m_nextLocation = m_nextLocation % m_numberFramesStored;
773 }
708 774
709 // Since the list will begin to overwrite the oldest frame values
710 // first, the next location needs to loop back to the beginning of the
711 // list whenever it reaches the end
712 m_nextLocation = m_nextLocation % m_numberFramesStored;
713 }
714
715 public void AddPendingDownloads(int count) 775 public void AddPendingDownloads(int count)
716 { 776 {
717 m_pendingDownloads += count; 777 m_pendingDownloads += count;
@@ -734,6 +794,31 @@ namespace OpenSim.Region.Framework.Scenes
734 AddunAckedBytes(unAckedBytes); 794 AddunAckedBytes(unAckedBytes);
735 } 795 }
736 796
797 public void UpdateUsersLoggingIn(bool isLoggingIn)
798 {
799 // Determine whether the user has started logging in or has completed
800 // logging into the region
801 if (isLoggingIn)
802 {
803 // The user is starting to login to the region so increment the
804 // number of users attempting to login to the region
805 m_usersLoggingIn++;
806 }
807 else
808 {
809 // The user has finished logging into the region so decrement the
810 // number of users logging into the region
811 m_usersLoggingIn--;
812 }
813 }
814
815 public void SetThreadCount(int inUseThreads)
816 {
817 // Save the new number of threads to our member variable to send to
818 // the extra stats collector
819 m_inUseThreads = inUseThreads;
820 }
821
737 #endregion 822 #endregion
738 823
739 public Dictionary<string, float> GetExtraSimStats() 824 public Dictionary<string, float> GetExtraSimStats()
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 54620d1..4e383f8 100644..100755
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1872,6 +1872,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1872 IScriptInstance instance = GetInstance(itemID); 1872 IScriptInstance instance = GetInstance(itemID);
1873 if (instance != null) 1873 if (instance != null)
1874 instance.ApiResetScript(); 1874 instance.ApiResetScript();
1875
1876 // Send the new number of threads that are in use by the thread
1877 // pool, I believe that by adding them to the locations where the
1878 // script is changing states that I will catch all changes to the
1879 // thread pool
1880 m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
1875 } 1881 }
1876 1882
1877 public void ResetScript(UUID itemID) 1883 public void ResetScript(UUID itemID)
@@ -1879,6 +1885,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1879 IScriptInstance instance = GetInstance(itemID); 1885 IScriptInstance instance = GetInstance(itemID);
1880 if (instance != null) 1886 if (instance != null)
1881 instance.ResetScript(m_WaitForEventCompletionOnScriptStop); 1887 instance.ResetScript(m_WaitForEventCompletionOnScriptStop);
1888
1889 // Send the new number of threads that are in use by the thread
1890 // pool, I believe that by adding them to the locations where the
1891 // script is changing states that I will catch all changes to the
1892 // thread pool
1893 m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
1882 } 1894 }
1883 1895
1884 public void StartScript(UUID itemID) 1896 public void StartScript(UUID itemID)
@@ -1888,6 +1900,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1888 instance.Start(); 1900 instance.Start();
1889 else 1901 else
1890 m_runFlags.AddOrUpdate(itemID, true, 240); 1902 m_runFlags.AddOrUpdate(itemID, true, 240);
1903
1904 // Send the new number of threads that are in use by the thread
1905 // pool, I believe that by adding them to the locations where the
1906 // script is changing states that I will catch all changes to the
1907 // thread pool
1908 m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
1891 } 1909 }
1892 1910
1893 public void StopScript(UUID itemID) 1911 public void StopScript(UUID itemID)
@@ -1903,6 +1921,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1903// m_log.DebugFormat("[XENGINE]: Could not find script with ID {0} to stop in {1}", itemID, World.Name); 1921// m_log.DebugFormat("[XENGINE]: Could not find script with ID {0} to stop in {1}", itemID, World.Name);
1904 m_runFlags.AddOrUpdate(itemID, false, 240); 1922 m_runFlags.AddOrUpdate(itemID, false, 240);
1905 } 1923 }
1924
1925 // Send the new number of threads that are in use by the thread
1926 // pool, I believe that by adding them to the locations where the
1927 // script is changing states that I will catch all changes to the
1928 // thread pool
1929 m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
1906 } 1930 }
1907 1931
1908 public DetectParams GetDetectParams(UUID itemID, int idx) 1932 public DetectParams GetDetectParams(UUID itemID, int idx)
@@ -2393,6 +2417,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2393 instance.Suspend(); 2417 instance.Suspend();
2394// else 2418// else
2395// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID); 2419// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID);
2420
2421 // Send the new number of threads that are in use by the thread
2422 // pool, I believe that by adding them to the locations where the
2423 // script is changing states that I will catch all changes to the
2424 // thread pool
2425 m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
2396 } 2426 }
2397 2427
2398 public void ResumeScript(UUID itemID) 2428 public void ResumeScript(UUID itemID)
@@ -2404,6 +2434,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2404 instance.Resume(); 2434 instance.Resume();
2405// else 2435// else
2406// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID); 2436// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID);
2437
2438 // Send the new number of threads that are in use by the thread
2439 // pool, I believe that by adding them to the locations where the
2440 // script is changing states that I will catch all changes to the
2441 // thread pool
2442 m_Scene.setThreadCount(m_ThreadPool.InUseThreads);
2407 } 2443 }
2408 2444
2409 public bool HasScript(UUID itemID, out bool running) 2445 public bool HasScript(UUID itemID, out bool running)