diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 014b007..84c3719 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -104,8 +104,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
104 | /// since the group's last persistent backup | 104 | /// since the group's last persistent backup |
105 | /// </summary> | 105 | /// </summary> |
106 | private bool m_hasGroupChanged = false; | 106 | private bool m_hasGroupChanged = false; |
107 | private long timeFirstChanged; | 107 | private long timeFirstChanged = 0; |
108 | private long timeLastChanged; | 108 | private long timeLastChanged = 0; |
109 | private long m_maxPersistTime = 0; | ||
110 | private long m_minPersistTime = 0; | ||
111 | private Random m_rand; | ||
112 | |||
109 | private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); | 113 | private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); |
110 | 114 | ||
111 | public void lockPartsForRead(bool locked) | 115 | public void lockPartsForRead(bool locked) |
@@ -182,6 +186,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
182 | timeLastChanged = DateTime.Now.Ticks; | 186 | timeLastChanged = DateTime.Now.Ticks; |
183 | if (!m_hasGroupChanged) | 187 | if (!m_hasGroupChanged) |
184 | timeFirstChanged = DateTime.Now.Ticks; | 188 | timeFirstChanged = DateTime.Now.Ticks; |
189 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) | ||
190 | { | ||
191 | if (m_rand == null) | ||
192 | { | ||
193 | byte[] val = new byte[16]; | ||
194 | m_rootPart.UUID.ToBytes(val, 0); | ||
195 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | ||
196 | } | ||
197 | |||
198 | if (m_scene.GetRootAgentCount() == 0) | ||
199 | { | ||
200 | //If the region is empty, this change has been made by an automated process | ||
201 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | ||
202 | |||
203 | float factor = 1.5f + (float)(m_rand.NextDouble()); | ||
204 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); | ||
205 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | //If the region is not empty, we want to obey the minimum and maximum persist times | ||
210 | //but add a random factor so we stagger the object persistance a little | ||
211 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | ||
212 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | ||
213 | } | ||
214 | } | ||
185 | } | 215 | } |
186 | m_hasGroupChanged = value; | 216 | m_hasGroupChanged = value; |
187 | } | 217 | } |
@@ -197,8 +227,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
197 | return false; | 227 | return false; |
198 | if (m_scene.ShuttingDown) | 228 | if (m_scene.ShuttingDown) |
199 | return true; | 229 | return true; |
230 | |||
231 | if (m_minPersistTime == 0 || m_maxPersistTime == 0) | ||
232 | { | ||
233 | m_maxPersistTime = m_scene.m_persistAfter; | ||
234 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
235 | } | ||
236 | |||
200 | long currentTime = DateTime.Now.Ticks; | 237 | long currentTime = DateTime.Now.Ticks; |
201 | if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) | 238 | |
239 | if (timeLastChanged == 0) timeLastChanged = currentTime; | ||
240 | if (timeFirstChanged == 0) timeFirstChanged = currentTime; | ||
241 | |||
242 | if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) | ||
202 | return true; | 243 | return true; |
203 | return false; | 244 | return false; |
204 | } | 245 | } |
@@ -530,6 +571,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
530 | /// </summary> | 571 | /// </summary> |
531 | public SceneObjectGroup() | 572 | public SceneObjectGroup() |
532 | { | 573 | { |
574 | |||
533 | } | 575 | } |
534 | 576 | ||
535 | /// <summary> | 577 | /// <summary> |
@@ -546,7 +588,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
546 | /// Constructor. This object is added to the scene later via AttachToScene() | 588 | /// Constructor. This object is added to the scene later via AttachToScene() |
547 | /// </summary> | 589 | /// </summary> |
548 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 590 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
549 | { | 591 | { |
550 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); | 592 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
551 | } | 593 | } |
552 | 594 | ||