diff options
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0277ed8..13d1d4e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -106,9 +106,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
106 | private bool m_hasGroupChanged = false; | 106 | private bool m_hasGroupChanged = false; |
107 | private long timeFirstChanged = 0; | 107 | private long timeFirstChanged = 0; |
108 | private long timeLastChanged = 0; | 108 | private long timeLastChanged = 0; |
109 | long m_maxPersistTime = 0; | 109 | private long m_maxPersistTime = 0; |
110 | long m_minPersistTime = 0; | 110 | private long m_minPersistTime = 0; |
111 | Random m_rand; | 111 | private Random m_rand; |
112 | 112 | ||
113 | private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); | 113 | private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); |
114 | 114 | ||
@@ -186,27 +186,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
186 | timeLastChanged = DateTime.Now.Ticks; | 186 | timeLastChanged = DateTime.Now.Ticks; |
187 | if (!m_hasGroupChanged) | 187 | if (!m_hasGroupChanged) |
188 | timeFirstChanged = DateTime.Now.Ticks; | 188 | timeFirstChanged = DateTime.Now.Ticks; |
189 | if (m_rand == null) | 189 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) |
190 | { | 190 | { |
191 | byte[] val = new byte[16]; | 191 | if (m_rand == null) |
192 | m_rootPart.UUID.ToBytes(val, 0); | 192 | { |
193 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | 193 | byte[] val = new byte[16]; |
194 | } | 194 | m_rootPart.UUID.ToBytes(val, 0); |
195 | if (Scene.GetRootAgentCount() == 0) | 195 | m_rand = new Random(BitConverter.ToInt32(val, 0)); |
196 | { | 196 | } |
197 | //If the region is empty, this change has been made by an automated process | 197 | |
198 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | 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. | ||
199 | 202 | ||
200 | float factor = 1.5f + (float)(m_rand.NextDouble()); | 203 | float factor = 1.5f + (float)(m_rand.NextDouble()); |
201 | m_maxPersistTime = (long)((float)Scene.m_persistAfter * factor); | 204 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); |
202 | m_minPersistTime = (long)((float)Scene.m_dontPersistBefore * factor); | 205 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); |
203 | } | 206 | } |
204 | else | 207 | else |
205 | { | 208 | { |
206 | //If the region is not empty, we want to obey the minimum and maximum persist times | 209 | //If the region is not empty, we want to obey the minimum and maximum persist times |
207 | //but add a random factor so we stagger the object persistance a little | 210 | //but add a random factor so we stagger the object persistance a little |
208 | m_maxPersistTime = (long)((float)Scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | 211 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 |
209 | m_minPersistTime = (long)((float)Scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | 212 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 |
213 | } | ||
210 | } | 214 | } |
211 | } | 215 | } |
212 | m_hasGroupChanged = value; | 216 | m_hasGroupChanged = value; |