diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 84 |
1 files changed, 47 insertions, 37 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 56ac2c2..7ce95a7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1029,29 +1029,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
1029 | if (ScriptEngine) | 1029 | if (ScriptEngine) |
1030 | { | 1030 | { |
1031 | m_log.Info("Stopping all Scripts in Scene"); | 1031 | m_log.Info("Stopping all Scripts in Scene"); |
1032 | foreach (EntityBase ent in Entities) | 1032 | |
1033 | EntityBase[] entities = Entities.GetEntities(); | ||
1034 | foreach (EntityBase ent in entities) | ||
1033 | { | 1035 | { |
1034 | if (ent is SceneObjectGroup) | 1036 | if (ent is SceneObjectGroup) |
1035 | { | 1037 | ((SceneObjectGroup)ent).RemoveScriptInstances(false); |
1036 | ((SceneObjectGroup) ent).RemoveScriptInstances(false); | ||
1037 | } | ||
1038 | } | 1038 | } |
1039 | } | 1039 | } |
1040 | else | 1040 | else |
1041 | { | 1041 | { |
1042 | m_log.Info("Starting all Scripts in Scene"); | 1042 | m_log.Info("Starting all Scripts in Scene"); |
1043 | lock (Entities) | 1043 | |
1044 | EntityBase[] entities = Entities.GetEntities(); | ||
1045 | foreach (EntityBase ent in entities) | ||
1044 | { | 1046 | { |
1045 | foreach (EntityBase ent in Entities) | 1047 | if (ent is SceneObjectGroup) |
1046 | { | 1048 | { |
1047 | if (ent is SceneObjectGroup) | 1049 | SceneObjectGroup sog = (SceneObjectGroup)ent; |
1048 | { | 1050 | sog.CreateScriptInstances(0, false, DefaultScriptEngine, 0); |
1049 | ((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0); | 1051 | sog.ResumeScripts(); |
1050 | ((SceneObjectGroup)ent).ResumeScripts(); | ||
1051 | } | ||
1052 | } | 1052 | } |
1053 | } | 1053 | } |
1054 | } | 1054 | } |
1055 | |||
1055 | m_scripts_enabled = !ScriptEngine; | 1056 | m_scripts_enabled = !ScriptEngine; |
1056 | m_log.Info("[TOTEDD]: Here is the method to trigger disabling of the scripting engine"); | 1057 | m_log.Info("[TOTEDD]: Here is the method to trigger disabling of the scripting engine"); |
1057 | } | 1058 | } |
@@ -1098,7 +1099,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1098 | shuttingdown = true; | 1099 | shuttingdown = true; |
1099 | 1100 | ||
1100 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1101 | m_log.Debug("[SCENE]: Persisting changed objects"); |
1101 | List<EntityBase> entities = GetEntities(); | 1102 | EntityBase[] entities = GetEntities(); |
1102 | foreach (EntityBase entity in entities) | 1103 | foreach (EntityBase entity in entities) |
1103 | { | 1104 | { |
1104 | if (!entity.IsDeleted && entity is SceneObjectGroup && ((SceneObjectGroup)entity).HasGroupChanged) | 1105 | if (!entity.IsDeleted && entity is SceneObjectGroup && ((SceneObjectGroup)entity).HasGroupChanged) |
@@ -1528,18 +1529,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1528 | /// </summary> | 1529 | /// </summary> |
1529 | private void BackupWaitCallback(object o) | 1530 | private void BackupWaitCallback(object o) |
1530 | { | 1531 | { |
1531 | Backup(); | 1532 | Backup(false); |
1532 | } | 1533 | } |
1533 | 1534 | ||
1534 | /// <summary> | 1535 | /// <summary> |
1535 | /// Backup the scene. This acts as the main method of the backup thread. | 1536 | /// Backup the scene. This acts as the main method of the backup thread. |
1536 | /// </summary> | 1537 | /// </summary> |
1538 | /// <param name="forced"> | ||
1539 | /// If true, then any changes that have not yet been persisted are persisted. If false, | ||
1540 | /// then the persistence decision is left to the backup code (in some situations, such as object persistence, | ||
1541 | /// it's much more efficient to backup multiple changes at once rather than every single one). | ||
1537 | /// <returns></returns> | 1542 | /// <returns></returns> |
1538 | public void Backup() | 1543 | public void Backup(bool forced) |
1539 | { | 1544 | { |
1540 | lock (m_returns) | 1545 | lock (m_returns) |
1541 | { | 1546 | { |
1542 | EventManager.TriggerOnBackup(m_storageManager.DataStore); | 1547 | EventManager.TriggerOnBackup(m_storageManager.DataStore, forced); |
1543 | m_backingup = false; | 1548 | m_backingup = false; |
1544 | 1549 | ||
1545 | foreach (KeyValuePair<UUID, ReturnInfo> ret in m_returns) | 1550 | foreach (KeyValuePair<UUID, ReturnInfo> ret in m_returns) |
@@ -2033,8 +2038,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2033 | { | 2038 | { |
2034 | lock (Entities) | 2039 | lock (Entities) |
2035 | { | 2040 | { |
2036 | ICollection<EntityBase> entities = new List<EntityBase>(Entities); | 2041 | EntityBase[] entities = Entities.GetEntities(); |
2037 | |||
2038 | foreach (EntityBase e in entities) | 2042 | foreach (EntityBase e in entities) |
2039 | { | 2043 | { |
2040 | if (e is SceneObjectGroup) | 2044 | if (e is SceneObjectGroup) |
@@ -2088,7 +2092,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2088 | // rootPart.PhysActor = null; | 2092 | // rootPart.PhysActor = null; |
2089 | // } | 2093 | // } |
2090 | 2094 | ||
2091 | if (UnlinkSceneObject(group.UUID, false)) | 2095 | if (UnlinkSceneObject(group, false)) |
2092 | { | 2096 | { |
2093 | EventManager.TriggerObjectBeingRemovedFromScene(group); | 2097 | EventManager.TriggerObjectBeingRemovedFromScene(group); |
2094 | EventManager.TriggerParcelPrimCountTainted(); | 2098 | EventManager.TriggerParcelPrimCountTainted(); |
@@ -2103,18 +2107,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2103 | /// Unlink the given object from the scene. Unlike delete, this just removes the record of the object - the | 2107 | /// Unlink the given object from the scene. Unlike delete, this just removes the record of the object - the |
2104 | /// object itself is not destroyed. | 2108 | /// object itself is not destroyed. |
2105 | /// </summary> | 2109 | /// </summary> |
2106 | /// <param name="uuid">Id of object.</param> | 2110 | /// <param name="so">The scene object.</param> |
2111 | /// <param name="softDelete">If true, only deletes from scene, but keeps the object in the database.</param> | ||
2107 | /// <returns>true if the object was in the scene, false if it was not</returns> | 2112 | /// <returns>true if the object was in the scene, false if it was not</returns> |
2108 | /// <param name="softDelete">If true, only deletes from scene, but keeps object in database.</param> | 2113 | public bool UnlinkSceneObject(SceneObjectGroup so, bool softDelete) |
2109 | public bool UnlinkSceneObject(UUID uuid, bool softDelete) | ||
2110 | { | 2114 | { |
2111 | if (m_sceneGraph.DeleteSceneObject(uuid, softDelete)) | 2115 | if (m_sceneGraph.DeleteSceneObject(so.UUID, softDelete)) |
2112 | { | 2116 | { |
2113 | if (!softDelete) | 2117 | if (!softDelete) |
2114 | { | 2118 | { |
2115 | m_storageManager.DataStore.RemoveObject(uuid, | 2119 | // Force a database update so that the scene object group ID is accurate. It's possible that the |
2116 | m_regInfo.RegionID); | 2120 | // group has recently been delinked from another group but that this change has not been persisted |
2121 | // to the DB. | ||
2122 | ForceSceneObjectBackup(so); | ||
2123 | so.DetachFromBackup(); | ||
2124 | m_storageManager.DataStore.RemoveObject(so.UUID, m_regInfo.RegionID); | ||
2117 | } | 2125 | } |
2126 | |||
2127 | // We need to keep track of this state in case this group is still queued for further backup. | ||
2128 | so.IsDeleted = true; | ||
2118 | 2129 | ||
2119 | return true; | 2130 | return true; |
2120 | } | 2131 | } |
@@ -2145,7 +2156,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2145 | } | 2156 | } |
2146 | catch (Exception) | 2157 | catch (Exception) |
2147 | { | 2158 | { |
2148 | m_log.Warn("[DATABASE]: exception when trying to remove the prim that crossed the border."); | 2159 | m_log.Warn("[SCENE]: exception when trying to remove the prim that crossed the border."); |
2149 | } | 2160 | } |
2150 | return; | 2161 | return; |
2151 | } | 2162 | } |
@@ -2162,7 +2173,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2162 | } | 2173 | } |
2163 | catch (Exception) | 2174 | catch (Exception) |
2164 | { | 2175 | { |
2165 | m_log.Warn("[DATABASE]: exception when trying to return the prim that crossed the border."); | 2176 | m_log.Warn("[SCENE]: exception when trying to return the prim that crossed the border."); |
2166 | } | 2177 | } |
2167 | return; | 2178 | return; |
2168 | } | 2179 | } |
@@ -2643,6 +2654,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2643 | try | 2654 | try |
2644 | { | 2655 | { |
2645 | ScenePresence sp = GetScenePresence(agentID); | 2656 | ScenePresence sp = GetScenePresence(agentID); |
2657 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2658 | |||
2646 | if (sp != null) | 2659 | if (sp != null) |
2647 | sp.ControllingClient.Close(); | 2660 | sp.ControllingClient.Close(); |
2648 | 2661 | ||
@@ -3964,9 +3977,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3964 | /// </summary> | 3977 | /// </summary> |
3965 | public void ForceClientUpdate() | 3978 | public void ForceClientUpdate() |
3966 | { | 3979 | { |
3967 | List<EntityBase> EntityList = GetEntities(); | 3980 | EntityBase[] entityList = GetEntities(); |
3968 | 3981 | foreach (EntityBase ent in entityList) | |
3969 | foreach (EntityBase ent in EntityList) | ||
3970 | { | 3982 | { |
3971 | if (ent is SceneObjectGroup) | 3983 | if (ent is SceneObjectGroup) |
3972 | { | 3984 | { |
@@ -3984,9 +3996,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3984 | { | 3996 | { |
3985 | m_log.Debug("Searching for Primitive: '" + cmdparams[2] + "'"); | 3997 | m_log.Debug("Searching for Primitive: '" + cmdparams[2] + "'"); |
3986 | 3998 | ||
3987 | List<EntityBase> EntityList = GetEntities(); | 3999 | EntityBase[] entityList = GetEntities(); |
3988 | 4000 | foreach (EntityBase ent in entityList) | |
3989 | foreach (EntityBase ent in EntityList) | ||
3990 | { | 4001 | { |
3991 | if (ent is SceneObjectGroup) | 4002 | if (ent is SceneObjectGroup) |
3992 | { | 4003 | { |
@@ -4355,7 +4366,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4355 | /// will not affect the original list of objects in the scene. | 4366 | /// will not affect the original list of objects in the scene. |
4356 | /// </summary> | 4367 | /// </summary> |
4357 | /// <returns></returns> | 4368 | /// <returns></returns> |
4358 | public List<EntityBase> GetEntities() | 4369 | public EntityBase[] GetEntities() |
4359 | { | 4370 | { |
4360 | return m_sceneGraph.GetEntities(); | 4371 | return m_sceneGraph.GetEntities(); |
4361 | } | 4372 | } |
@@ -4389,9 +4400,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4389 | 4400 | ||
4390 | public void CleanTempObjects() | 4401 | public void CleanTempObjects() |
4391 | { | 4402 | { |
4392 | List<EntityBase> objs = GetEntities(); | 4403 | EntityBase[] entities = GetEntities(); |
4393 | 4404 | foreach (EntityBase obj in entities) | |
4394 | foreach (EntityBase obj in objs) | ||
4395 | { | 4405 | { |
4396 | if (obj is SceneObjectGroup) | 4406 | if (obj is SceneObjectGroup) |
4397 | { | 4407 | { |