aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs628
1 files changed, 306 insertions, 322 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e3bc8c7..28fce53 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -51,6 +51,7 @@ using 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;
54 55
55namespace OpenSim.Region.Framework.Scenes 56namespace OpenSim.Region.Framework.Scenes
56{ 57{
@@ -68,14 +69,84 @@ namespace OpenSim.Region.Framework.Scenes
68 public bool EmergencyMonitoring = false; 69 public bool EmergencyMonitoring = false;
69 70
70 /// <summary> 71 /// <summary>
72 /// Show debug information about animations.
73 /// </summary>
74 public bool DebugAnimations { get; set; }
75
76 /// <summary>
71 /// Show debug information about teleports. 77 /// Show debug information about teleports.
72 /// </summary> 78 /// </summary>
73 public bool DebugTeleporting { get; private set; } 79 public bool DebugTeleporting { get; set; }
74 80
75 /// <summary> 81 /// <summary>
76 /// Show debug information about the scene loop. 82 /// Show debug information about the scene loop.
77 /// </summary> 83 /// </summary>
78 public bool DebugUpdates { get; private set; } 84 public bool DebugUpdates { get; set; }
85
86 /// <summary>
87 /// If true then the scene is saved to persistent storage periodically, every m_update_backup frames and
88 /// if objects meet required conditions (m_dontPersistBefore and m_dontPersistAfter).
89 /// </summary>
90 /// <remarks>
91 /// Even if false, the scene will still be saved on clean shutdown.
92 /// FIXME: Currently, setting this to false will mean that objects are not periodically returned from parcels.
93 /// This needs to be fixed.
94 /// </remarks>
95 public bool PeriodicBackup { get; set; }
96
97 /// <summary>
98 /// If false then the scene is never saved to persistence storage even if PeriodicBackup == true and even
99 /// if the scene is being shut down for the final time.
100 /// </summary>
101 public bool UseBackup { get; set; }
102
103 /// <summary>
104 /// If false then physical objects are disabled, though collisions will continue as normal.
105 /// </summary>
106 public bool PhysicsEnabled { get; set; }
107
108 /// <summary>
109 /// If false then scripts are not enabled on the smiulator
110 /// </summary>
111 public bool ScriptsEnabled
112 {
113 get { return m_scripts_enabled; }
114 set
115 {
116 if (m_scripts_enabled != value)
117 {
118 if (!value)
119 {
120 m_log.Info("Stopping all Scripts in Scene");
121
122 EntityBase[] entities = Entities.GetEntities();
123 foreach (EntityBase ent in entities)
124 {
125 if (ent is SceneObjectGroup)
126 ((SceneObjectGroup)ent).RemoveScriptInstances(false);
127 }
128 }
129 else
130 {
131 m_log.Info("Starting all Scripts in Scene");
132
133 EntityBase[] entities = Entities.GetEntities();
134 foreach (EntityBase ent in entities)
135 {
136 if (ent is SceneObjectGroup)
137 {
138 SceneObjectGroup sog = (SceneObjectGroup)ent;
139 sog.CreateScriptInstances(0, false, DefaultScriptEngine, 0);
140 sog.ResumeScripts();
141 }
142 }
143 }
144
145 m_scripts_enabled = value;
146 }
147 }
148 }
149 private bool m_scripts_enabled;
79 150
80 public SynchronizeSceneHandler SynchronizeScene; 151 public SynchronizeSceneHandler SynchronizeScene;
81 152
@@ -284,8 +355,6 @@ namespace OpenSim.Region.Framework.Scenes
284 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 355 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
285 private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>(); 356 private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>();
286 357
287 private bool m_physics_enabled = true;
288 private bool m_scripts_enabled = true;
289 private string m_defaultScriptEngine; 358 private string m_defaultScriptEngine;
290 359
291 /// <summary> 360 /// <summary>
@@ -348,7 +417,6 @@ namespace OpenSim.Region.Framework.Scenes
348 417
349 private Timer m_mapGenerationTimer = new Timer(); 418 private Timer m_mapGenerationTimer = new Timer();
350 private bool m_generateMaptiles; 419 private bool m_generateMaptiles;
351 private bool m_useBackup = true;
352 420
353 #endregion Fields 421 #endregion Fields
354 422
@@ -614,11 +682,6 @@ namespace OpenSim.Region.Framework.Scenes
614 get { return m_authenticateHandler; } 682 get { return m_authenticateHandler; }
615 } 683 }
616 684
617 public bool UseBackup
618 {
619 get { return m_useBackup; }
620 }
621
622 // an instance to the physics plugin's Scene object. 685 // an instance to the physics plugin's Scene object.
623 public PhysicsScene PhysicsScene 686 public PhysicsScene PhysicsScene
624 { 687 {
@@ -678,7 +741,6 @@ namespace OpenSim.Region.Framework.Scenes
678 public Scene(RegionInfo regInfo, AgentCircuitManager authen, 741 public Scene(RegionInfo regInfo, AgentCircuitManager authen,
679 SceneCommunicationService sceneGridService, 742 SceneCommunicationService sceneGridService,
680 ISimulationDataService simDataService, IEstateDataService estateDataService, 743 ISimulationDataService simDataService, IEstateDataService estateDataService,
681 bool dumpAssetsToFile,
682 IConfigSource config, string simulatorVersion) 744 IConfigSource config, string simulatorVersion)
683 : this(regInfo) 745 : this(regInfo)
684 { 746 {
@@ -762,15 +824,20 @@ namespace OpenSim.Region.Framework.Scenes
762 // 824 //
763 // Out of memory 825 // Out of memory
764 // Operating system has killed the plugin 826 // Operating system has killed the plugin
765 m_sceneGraph.UnRecoverableError += RestartNow; 827 m_sceneGraph.UnRecoverableError
828 += () =>
829 {
830 m_log.ErrorFormat("[SCENE]: Restarting region {0} due to unrecoverable physics crash", Name);
831 RestartNow();
832 };
766 833
767 RegisterDefaultSceneEvents(); 834 RegisterDefaultSceneEvents();
768 835
769 DumpAssetsToFile = dumpAssetsToFile; 836 // XXX: Don't set the public property since we don't want to activate here. This needs to be handled
770 837 // better in the future.
771 m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; 838 m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;
772 839
773 m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics; 840 PhysicsEnabled = !RegionInfo.RegionSettings.DisablePhysics;
774 841
775 m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")"; 842 m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")";
776 843
@@ -778,141 +845,154 @@ namespace OpenSim.Region.Framework.Scenes
778 845
779 // Region config overrides global config 846 // Region config overrides global config
780 // 847 //
781 try 848 if (m_config.Configs["Startup"] != null)
782 { 849 {
783 if (m_config.Configs["Startup"] != null) 850 IConfig startupConfig = m_config.Configs["Startup"];
851
852 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
853
854 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
855 UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup);
856 if (!UseBackup)
857 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
858
859 //Animation states
860 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
861
862 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
863 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
864
865 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys);
866 if (RegionInfo.NonphysPrimMin > 0)
784 { 867 {
785 IConfig startupConfig = m_config.Configs["Startup"]; 868 m_minNonphys = RegionInfo.NonphysPrimMin;
869 }
786 870
787 StartDisabled = startupConfig.GetBoolean("StartDisabled", false); 871 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
872 if (RegionInfo.NonphysPrimMax > 0)
873 {
874 m_maxNonphys = RegionInfo.NonphysPrimMax;
875 }
788 876
789 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); 877 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys);
790 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); 878 if (RegionInfo.PhysPrimMin > 0)
791 if (!m_useBackup) 879 {
792 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); 880 m_minPhys = RegionInfo.PhysPrimMin;
793 881 }
794 //Animation states
795 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
796 882
797 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); 883 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
798 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
799 884
800 m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); 885 if (RegionInfo.PhysPrimMax > 0)
801 if (RegionInfo.NonphysPrimMin > 0) 886 {
802 { 887 m_maxPhys = RegionInfo.PhysPrimMax;
803 m_minNonphys = RegionInfo.NonphysPrimMin; 888 }
804 }
805 889
806 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 890 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity);
807 if (RegionInfo.NonphysPrimMax > 0) 891 if (RegionInfo.LinksetCapacity > 0)
808 { 892 {
809 m_maxNonphys = RegionInfo.NonphysPrimMax; 893 m_linksetCapacity = RegionInfo.LinksetCapacity;
810 } 894 }
811 895
812 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys); 896 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
813 if (RegionInfo.PhysPrimMin > 0) 897 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
814 {
815 m_minPhys = RegionInfo.PhysPrimMin;
816 }
817 898
818 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 899 // Here, if clamping is requested in either global or
900 // local config, it will be used
901 //
902 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize);
903 if (RegionInfo.ClampPrimSize)
904 {
905 m_clampPrimSize = true;
906 }
819 907
820 if (RegionInfo.PhysPrimMax > 0) 908 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
821 { 909 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
822 m_maxPhys = RegionInfo.PhysPrimMax; 910 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
823 } 911 m_dontPersistBefore =
912 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
913 m_dontPersistBefore *= 10000000;
914 m_persistAfter =
915 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
916 m_persistAfter *= 10000000;
824 917
825 m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); 918 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
826 if (RegionInfo.LinksetCapacity > 0) 919 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
827 {
828 m_linksetCapacity = RegionInfo.LinksetCapacity;
829 }
830 920
831 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); 921 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
832 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); 922 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
923 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
833 924
834 // Here, if clamping is requested in either global or 925 string[] possibleMapConfigSections = new string[] { "Map", "Startup" };
835 // local config, it will be used 926
836 // 927 m_generateMaptiles
837 m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); 928 = Util.GetConfigVarFromSections<bool>(config, "GenerateMaptiles", possibleMapConfigSections, true);
838 if (RegionInfo.ClampPrimSize) 929
930 if (m_generateMaptiles)
931 {
932 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0);
933 if (maptileRefresh != 0)
839 { 934 {
840 m_clampPrimSize = true; 935 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
936 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
937 m_mapGenerationTimer.AutoReset = true;
938 m_mapGenerationTimer.Start();
841 } 939 }
940 }
941 else
942 {
943 string tile
944 = Util.GetConfigVarFromSections<string>(
945 config, "MaptileStaticUUID", possibleMapConfigSections, UUID.Zero.ToString());
842 946
843 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); 947 UUID tileID;
844 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 948
845 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 949 if (tile != UUID.Zero.ToString() && UUID.TryParse(tile, out tileID))
846 m_dontPersistBefore =
847 startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE);
848 m_dontPersistBefore *= 10000000;
849 m_persistAfter =
850 startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
851 m_persistAfter *= 10000000;
852
853 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
854 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
855
856 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
857 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
858 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
859
860 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
861 if (m_generateMaptiles)
862 { 950 {
863 int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); 951 RegionInfo.RegionSettings.TerrainImageID = tileID;
864 if (maptileRefresh != 0)
865 {
866 m_mapGenerationTimer.Interval = maptileRefresh * 1000;
867 m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister;
868 m_mapGenerationTimer.AutoReset = true;
869 m_mapGenerationTimer.Start();
870 }
871 } 952 }
872 else 953 else
873 { 954 {
874 string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); 955 RegionInfo.RegionSettings.TerrainImageID = RegionInfo.MaptileStaticUUID;
875 UUID tileID; 956 m_log.InfoFormat("[SCENE]: Region {0}, maptile set to {1}", RegionInfo.RegionName, RegionInfo.MaptileStaticUUID.ToString());
876
877 if (UUID.TryParse(tile, out tileID))
878 {
879 RegionInfo.RegionSettings.TerrainImageID = tileID;
880 }
881 } 957 }
958 }
959
960 string[] possibleAccessControlConfigSections = new string[] { "AccessControl", "Startup" };
882 961
883 string grant = startupConfig.GetString("AllowedClients", String.Empty); 962 string grant
884 if (grant.Length > 0) 963 = Util.GetConfigVarFromSections<string>(
964 config, "AllowedClients", possibleAccessControlConfigSections, "");
965
966 if (grant.Length > 0)
967 {
968 foreach (string viewer in grant.Split(','))
885 { 969 {
886 foreach (string viewer in grant.Split(',')) 970 m_AllowedViewers.Add(viewer.Trim().ToLower());
887 {
888 m_AllowedViewers.Add(viewer.Trim().ToLower());
889 }
890 } 971 }
972 }
973
974 grant
975 = Util.GetConfigVarFromSections<string>(
976 config, "BannedClients", possibleAccessControlConfigSections, "");
891 977
892 grant = startupConfig.GetString("BannedClients", String.Empty); 978 if (grant.Length > 0)
893 if (grant.Length > 0) 979 {
980 foreach (string viewer in grant.Split(','))
894 { 981 {
895 foreach (string viewer in grant.Split(',')) 982 m_BannedViewers.Add(viewer.Trim().ToLower());
896 {
897 m_BannedViewers.Add(viewer.Trim().ToLower());
898 }
899 } 983 }
900
901 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
902 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
903 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
904 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
905 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
906 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
907 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
908 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
909 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
910 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
911 } 984 }
912 } 985
913 catch (Exception e) 986 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
914 { 987 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
915 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); 988 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
989 m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement);
990 m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events);
991 m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects);
992 m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics);
993 m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences);
994 m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain);
995 m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning);
916 } 996 }
917 997
918 // FIXME: Ultimately this should be in a module. 998 // FIXME: Ultimately this should be in a module.
@@ -965,6 +1045,10 @@ namespace OpenSim.Region.Framework.Scenes
965 { 1045 {
966 PhysicalPrims = true; 1046 PhysicalPrims = true;
967 CollidablePrims = true; 1047 CollidablePrims = true;
1048 PhysicsEnabled = true;
1049
1050 PeriodicBackup = true;
1051 UseBackup = true;
968 1052
969 BordersLocked = true; 1053 BordersLocked = true;
970 Border northBorder = new Border(); 1054 Border northBorder = new Border();
@@ -1207,83 +1291,6 @@ namespace OpenSim.Region.Framework.Scenes
1207 } 1291 }
1208 } 1292 }
1209 1293
1210 public void SetSceneCoreDebug(Dictionary<string, string> options)
1211 {
1212 if (options.ContainsKey("active"))
1213 {
1214 bool active;
1215
1216 if (bool.TryParse(options["active"], out active))
1217 Active = active;
1218 }
1219
1220 if (options.ContainsKey("scripting"))
1221 {
1222 bool enableScripts = true;
1223 if (bool.TryParse(options["scripting"], out enableScripts) && m_scripts_enabled != enableScripts)
1224 {
1225 if (!enableScripts)
1226 {
1227 m_log.Info("Stopping all Scripts in Scene");
1228
1229 EntityBase[] entities = Entities.GetEntities();
1230 foreach (EntityBase ent in entities)
1231 {
1232 if (ent is SceneObjectGroup)
1233 ((SceneObjectGroup)ent).RemoveScriptInstances(false);
1234 }
1235 }
1236 else
1237 {
1238 m_log.Info("Starting all Scripts in Scene");
1239
1240 EntityBase[] entities = Entities.GetEntities();
1241 foreach (EntityBase ent in entities)
1242 {
1243 if (ent is SceneObjectGroup)
1244 {
1245 SceneObjectGroup sog = (SceneObjectGroup)ent;
1246 sog.CreateScriptInstances(0, false, DefaultScriptEngine, 0);
1247 sog.ResumeScripts();
1248 }
1249 }
1250 }
1251
1252 m_scripts_enabled = enableScripts;
1253 }
1254 }
1255
1256 if (options.ContainsKey("physics"))
1257 {
1258 bool enablePhysics;
1259 if (bool.TryParse(options["physics"], out enablePhysics))
1260 m_physics_enabled = enablePhysics;
1261 }
1262
1263// if (options.ContainsKey("collisions"))
1264// {
1265// // TODO: Implement. If false, should stop objects colliding, though possibly should still allow
1266// // the avatar themselves to collide with the ground.
1267// }
1268
1269 if (options.ContainsKey("teleport"))
1270 {
1271 bool enableTeleportDebugging;
1272 if (bool.TryParse(options["teleport"], out enableTeleportDebugging))
1273 DebugTeleporting = enableTeleportDebugging;
1274 }
1275
1276 if (options.ContainsKey("updates"))
1277 {
1278 bool enableUpdateDebugging;
1279 if (bool.TryParse(options["updates"], out enableUpdateDebugging))
1280 {
1281 DebugUpdates = enableUpdateDebugging;
1282 GcNotify.Enabled = DebugUpdates;
1283 }
1284 }
1285 }
1286
1287 public int GetInaccurateNeighborCount() 1294 public int GetInaccurateNeighborCount()
1288 { 1295 {
1289 return m_neighbours.Count; 1296 return m_neighbours.Count;
@@ -1332,16 +1339,7 @@ namespace OpenSim.Region.Framework.Scenes
1332 1339
1333 m_log.Debug("[SCENE]: Persisting changed objects"); 1340 m_log.Debug("[SCENE]: Persisting changed objects");
1334 1341
1335 EntityBase[] entities = GetEntities(); 1342 Backup(false);
1336 foreach (EntityBase entity in entities)
1337 {
1338 if (!entity.IsDeleted && entity is SceneObjectGroup && ((SceneObjectGroup)entity).HasGroupChanged)
1339 {
1340 ((SceneObjectGroup)entity).ProcessBackup(SimulationDataService, false);
1341 }
1342 }
1343
1344 m_log.Debug("[SCENE]: Graph close");
1345 m_sceneGraph.Close(); 1343 m_sceneGraph.Close();
1346 1344
1347 if (!GridService.DeregisterRegion(RegionInfo.RegionID)) 1345 if (!GridService.DeregisterRegion(RegionInfo.RegionID))
@@ -1568,7 +1566,7 @@ namespace OpenSim.Region.Framework.Scenes
1568 } 1566 }
1569 1567
1570 tmpMS = Util.EnvironmentTickCount(); 1568 tmpMS = Util.EnvironmentTickCount();
1571 if ((Frame % m_update_physics == 0) && m_physics_enabled) 1569 if (PhysicsEnabled && Frame % m_update_physics == 0)
1572 m_sceneGraph.UpdatePreparePhysics(); 1570 m_sceneGraph.UpdatePreparePhysics();
1573 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS); 1571 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1574 1572
@@ -1583,7 +1581,7 @@ namespace OpenSim.Region.Framework.Scenes
1583 tmpMS = Util.EnvironmentTickCount(); 1581 tmpMS = Util.EnvironmentTickCount();
1584 if (Frame % m_update_physics == 0) 1582 if (Frame % m_update_physics == 0)
1585 { 1583 {
1586 if (m_physics_enabled) 1584 if (PhysicsEnabled)
1587 physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameTime); 1585 physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameTime);
1588 1586
1589 if (SynchronizeScene != null) 1587 if (SynchronizeScene != null)
@@ -1625,7 +1623,7 @@ namespace OpenSim.Region.Framework.Scenes
1625 eventMS = Util.EnvironmentTickCountSubtract(tmpMS); 1623 eventMS = Util.EnvironmentTickCountSubtract(tmpMS);
1626 } 1624 }
1627 1625
1628 if (Frame % m_update_backup == 0) 1626 if (PeriodicBackup && Frame % m_update_backup == 0)
1629 { 1627 {
1630 tmpMS = Util.EnvironmentTickCount(); 1628 tmpMS = Util.EnvironmentTickCount();
1631 UpdateStorageBackup(); 1629 UpdateStorageBackup();
@@ -2646,7 +2644,6 @@ namespace OpenSim.Region.Framework.Scenes
2646 2644
2647 } 2645 }
2648 } 2646 }
2649
2650 2647
2651 return null; 2648 return null;
2652 } 2649 }
@@ -2769,8 +2766,6 @@ namespace OpenSim.Region.Framework.Scenes
2769 2766
2770 if (newPosition != Vector3.Zero) 2767 if (newPosition != Vector3.Zero)
2771 newObject.RootPart.GroupPosition = newPosition; 2768 newObject.RootPart.GroupPosition = newPosition;
2772 if (newObject.RootPart.KeyframeMotion != null)
2773 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2774 2769
2775 if (!AddSceneObject(newObject)) 2770 if (!AddSceneObject(newObject))
2776 { 2771 {
@@ -2798,6 +2793,9 @@ namespace OpenSim.Region.Framework.Scenes
2798 // before we restart the scripts, or else some functions won't work. 2793 // before we restart the scripts, or else some functions won't work.
2799 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); 2794 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
2800 newObject.ResumeScripts(); 2795 newObject.ResumeScripts();
2796
2797 if (newObject.RootPart.KeyframeMotion != null)
2798 newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject);
2801 } 2799 }
2802 2800
2803 // Do this as late as possible so that listeners have full access to the incoming object 2801 // Do this as late as possible so that listeners have full access to the incoming object
@@ -2863,9 +2861,12 @@ namespace OpenSim.Region.Framework.Scenes
2863// "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2861// "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2864 2862
2865 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2863 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2866 2864
2865 // We must currently not resume scripts at this stage since AttachmentsModule does not have the
2866 // information that this is due to a teleport/border cross rather than an ordinary attachment.
2867 // We currently do this in Scene.MakeRootAgent() instead.
2867 if (AttachmentsModule != null) 2868 if (AttachmentsModule != null)
2868 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false); 2869 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true);
2869 } 2870 }
2870 else 2871 else
2871 { 2872 {
@@ -2970,24 +2971,16 @@ namespace OpenSim.Region.Framework.Scenes
2970 SubscribeToClientEvents(client); 2971 SubscribeToClientEvents(client);
2971 2972
2972 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); 2973 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
2974 InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46);
2975 if (cof == null)
2976 sp.COF = UUID.Zero;
2977 else
2978 sp.COF = cof.ID;
2979
2980 m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF);
2973 m_eventManager.TriggerOnNewPresence(sp); 2981 m_eventManager.TriggerOnNewPresence(sp);
2974 2982
2975 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; 2983 sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags;
2976
2977 // The first agent upon login is a root agent by design.
2978 // For this agent we will have to rez the attachments.
2979 // All other AddNewClient calls find aCircuit.child to be true.
2980 if (aCircuit.child == false)
2981 {
2982 // We have to set SP to be a root agent here so that SP.MakeRootAgent() will later not try to
2983 // start the scripts again (since this is done in RezAttachments()).
2984 // XXX: This is convoluted.
2985 sp.IsChildAgent = false;
2986 sp.IsLoggingIn = true;
2987
2988 if (AttachmentsModule != null)
2989 Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); });
2990 }
2991 } 2984 }
2992 else 2985 else
2993 { 2986 {
@@ -3615,7 +3608,7 @@ namespace OpenSim.Region.Framework.Scenes
3615 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop 3608 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
3616 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI 3609 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
3617 if (closeChildAgents && CapsModule != null) 3610 if (closeChildAgents && CapsModule != null)
3618 CapsModule.RemoveCaps(agentID); 3611 CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode);
3619 3612
3620// // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever 3613// // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3621// // this method is doing is HORRIBLE!!! 3614// // this method is doing is HORRIBLE!!!
@@ -3846,20 +3839,36 @@ namespace OpenSim.Region.Framework.Scenes
3846 return false; 3839 return false;
3847 } 3840 }
3848 3841
3849
3850 ScenePresence sp = GetScenePresence(agent.AgentID); 3842 ScenePresence sp = GetScenePresence(agent.AgentID);
3851 3843
3852 if (sp != null && !sp.IsChildAgent) 3844 // If we have noo presence here or if that presence is a zombie root
3845 // presence that will be kicled, we need a new CAPS object.
3846 if (sp == null || (sp != null && !sp.IsChildAgent))
3853 { 3847 {
3854 // We have a zombie from a crashed session. 3848 if (CapsModule != null)
3855 // Or the same user is trying to be root twice here, won't work. 3849 {
3856 // Kill it. 3850 lock (agent)
3857 m_log.WarnFormat( 3851 {
3858 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", 3852 CapsModule.SetAgentCapsSeeds(agent);
3859 sp.Name, sp.UUID, RegionInfo.RegionName); 3853 CapsModule.CreateCaps(agent.AgentID, agent.circuitcode);
3854 }
3855 }
3856 }
3860 3857
3861 sp.ControllingClient.Close(true, true); 3858 if (sp != null)
3862 sp = null; 3859 {
3860 if (!sp.IsChildAgent)
3861 {
3862 // We have a zombie from a crashed session.
3863 // Or the same user is trying to be root twice here, won't work.
3864 // Kill it.
3865 m_log.WarnFormat(
3866 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3867 sp.Name, sp.UUID, RegionInfo.RegionName);
3868
3869 sp.ControllingClient.Close(true, true);
3870 sp = null;
3871 }
3863 } 3872 }
3864 3873
3865 lock (agent) 3874 lock (agent)
@@ -3900,7 +3909,9 @@ namespace OpenSim.Region.Framework.Scenes
3900 if (vialogin || (!m_seeIntoBannedRegion)) 3909 if (vialogin || (!m_seeIntoBannedRegion))
3901 { 3910 {
3902 if (!AuthorizeUser(agent, out reason)) 3911 if (!AuthorizeUser(agent, out reason))
3912 {
3903 return false; 3913 return false;
3914 }
3904 } 3915 }
3905 } 3916 }
3906 catch (Exception e) 3917 catch (Exception e)
@@ -3915,11 +3926,6 @@ namespace OpenSim.Region.Framework.Scenes
3915 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, 3926 RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
3916 agent.AgentID, agent.circuitcode); 3927 agent.AgentID, agent.circuitcode);
3917 3928
3918 if (CapsModule != null)
3919 {
3920 CapsModule.SetAgentCapsSeeds(agent);
3921 CapsModule.CreateCaps(agent.AgentID);
3922 }
3923 } 3929 }
3924 else 3930 else
3925 { 3931 {
@@ -3945,6 +3951,11 @@ namespace OpenSim.Region.Framework.Scenes
3945 agent.teleportFlags = teleportFlags; 3951 agent.teleportFlags = teleportFlags;
3946 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3952 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3947 3953
3954 if (CapsModule != null)
3955 {
3956 CapsModule.ActivateCaps(agent.circuitcode);
3957 }
3958
3948 if (vialogin) 3959 if (vialogin)
3949 { 3960 {
3950// CleanDroppedAttachments(); 3961// CleanDroppedAttachments();
@@ -4306,33 +4317,33 @@ namespace OpenSim.Region.Framework.Scenes
4306// } 4317// }
4307// } 4318// }
4308 4319
4309 /// <summary> 4320// /// <summary>
4310 /// Triggered when an agent crosses into this sim. Also happens on initial login. 4321// /// Triggered when an agent crosses into this sim. Also happens on initial login.
4311 /// </summary> 4322// /// </summary>
4312 /// <param name="agentID"></param> 4323// /// <param name="agentID"></param>
4313 /// <param name="position"></param> 4324// /// <param name="position"></param>
4314 /// <param name="isFlying"></param> 4325// /// <param name="isFlying"></param>
4315 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) 4326// public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
4316 { 4327// {
4317 ScenePresence presence = GetScenePresence(agentID); 4328// ScenePresence presence = GetScenePresence(agentID);
4318 if (presence != null) 4329// if (presence != null)
4319 { 4330// {
4320 try 4331// try
4321 { 4332// {
4322 presence.MakeRootAgent(position, isFlying); 4333// presence.MakeRootAgent(position, isFlying);
4323 } 4334// }
4324 catch (Exception e) 4335// catch (Exception e)
4325 { 4336// {
4326 m_log.ErrorFormat("[SCENE]: Unable to do agent crossing, exception {0}{1}", e.Message, e.StackTrace); 4337// m_log.ErrorFormat("[SCENE]: Unable to do agent crossing, exception {0}{1}", e.Message, e.StackTrace);
4327 } 4338// }
4328 } 4339// }
4329 else 4340// else
4330 { 4341// {
4331 m_log.ErrorFormat( 4342// m_log.ErrorFormat(
4332 "[SCENE]: Could not find presence for agent {0} crossing into scene {1}", 4343// "[SCENE]: Could not find presence for agent {0} crossing into scene {1}",
4333 agentID, RegionInfo.RegionName); 4344// agentID, RegionInfo.RegionName);
4334 } 4345// }
4335 } 4346// }
4336 4347
4337 /// <summary> 4348 /// <summary>
4338 /// We've got an update about an agent that sees into this region, 4349 /// We've got an update about an agent that sees into this region,
@@ -4702,19 +4713,6 @@ namespace OpenSim.Region.Framework.Scenes
4702 4713
4703 #region Script Engine 4714 #region Script Engine
4704 4715
4705 private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>();
4706 public bool DumpAssetsToFile;
4707
4708 /// <summary>
4709 ///
4710 /// </summary>
4711 /// <param name="scriptEngine"></param>
4712 public void AddScriptEngine(ScriptEngineInterface scriptEngine)
4713 {
4714 ScriptEngines.Add(scriptEngine);
4715 scriptEngine.InitializeEngine(this);
4716 }
4717
4718 private bool ScriptDanger(SceneObjectPart part,Vector3 pos) 4716 private bool ScriptDanger(SceneObjectPart part,Vector3 pos)
4719 { 4717 {
4720 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); 4718 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
@@ -5122,7 +5120,7 @@ namespace OpenSim.Region.Framework.Scenes
5122 { 5120 {
5123 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) 5121 if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)
5124 { 5122 {
5125 if (grp.RootPart.Expires <= DateTime.Now) 5123 if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now)
5126 DeleteSceneObject(grp, false); 5124 DeleteSceneObject(grp, false);
5127 } 5125 }
5128 } 5126 }
@@ -5621,33 +5619,7 @@ Environment.Exit(1);
5621 5619
5622 public void TriggerEstateSunUpdate() 5620 public void TriggerEstateSunUpdate()
5623 { 5621 {
5624 float sun; 5622 EventManager.TriggerEstateToolsSunUpdate(RegionInfo.RegionHandle);
5625 if (RegionInfo.RegionSettings.UseEstateSun)
5626 {
5627 sun = (float)RegionInfo.EstateSettings.SunPosition;
5628 if (RegionInfo.EstateSettings.UseGlobalTime)
5629 {
5630 sun = EventManager.GetCurrentTimeAsSunLindenHour() - 6.0f;
5631 }
5632
5633 //
5634 EventManager.TriggerEstateToolsSunUpdate(
5635 RegionInfo.RegionHandle,
5636 RegionInfo.EstateSettings.FixedSun,
5637 RegionInfo.RegionSettings.UseEstateSun,
5638 sun);
5639 }
5640 else
5641 {
5642 // Use the Sun Position from the Region Settings
5643 sun = (float)RegionInfo.RegionSettings.SunPosition - 6.0f;
5644
5645 EventManager.TriggerEstateToolsSunUpdate(
5646 RegionInfo.RegionHandle,
5647 RegionInfo.RegionSettings.FixedSun,
5648 RegionInfo.RegionSettings.UseEstateSun,
5649 sun);
5650 }
5651 } 5623 }
5652 5624
5653 private void HandleReloadEstate(string module, string[] cmd) 5625 private void HandleReloadEstate(string module, string[] cmd)
@@ -5915,8 +5887,13 @@ Environment.Exit(1);
5915 5887
5916 if (banned) 5888 if (banned)
5917 { 5889 {
5918 reason = "No suitable landing point found"; 5890 if(Permissions.IsAdministrator(agentID) == false || Permissions.IsGridGod(agentID) == false)
5919 return false; 5891 {
5892 reason = "No suitable landing point found";
5893 return false;
5894 }
5895 reason = "Administrative access only";
5896 return true;
5920 } 5897 }
5921 } 5898 }
5922 } 5899 }
@@ -6043,10 +6020,17 @@ Environment.Exit(1);
6043 GC.Collect(); 6020 GC.Collect();
6044 } 6021 }
6045 6022
6046 // Wrappers to get physics modules retrieve assets. Has to be done this way 6023 /// <summary>
6047 // because we can't assign the asset service to physics directly - at the 6024 /// Wrappers to get physics modules retrieve assets.
6048 // time physics are instantiated it's not registered but it will be by 6025 /// </summary>
6049 // the time the first prim exists. 6026 /// <remarks>
6027 /// Has to be done this way
6028 /// because we can't assign the asset service to physics directly - at the
6029 /// time physics are instantiated it's not registered but it will be by
6030 /// the time the first prim exists.
6031 /// </remarks>
6032 /// <param name="assetID"></param>
6033 /// <param name="callback"></param>
6050 public void PhysicsRequestAsset(UUID assetID, AssetReceivedDelegate callback) 6034 public void PhysicsRequestAsset(UUID assetID, AssetReceivedDelegate callback)
6051 { 6035 {
6052 AssetService.Get(assetID.ToString(), callback, PhysicsAssetReceived); 6036 AssetService.Get(assetID.ToString(), callback, PhysicsAssetReceived);