diff options
author | Master ScienceSim | 2010-10-28 09:09:42 -0700 |
---|---|---|
committer | Master ScienceSim | 2010-10-28 09:09:42 -0700 |
commit | f2c1d0e34feba801ff85c35ee049ed6d3067bb0d (patch) | |
tree | ff692ecc0db2b9cdf4cacd5a42234a5bb58ddd34 /OpenSim/Region/CoreModules | |
parent | Added background thread to handle delayed send and save of appearance (diff) | |
parent | Formatting cleanup. (diff) | |
download | opensim-SC_OLD-f2c1d0e34feba801ff85c35ee049ed6d3067bb0d.zip opensim-SC_OLD-f2c1d0e34feba801ff85c35ee049ed6d3067bb0d.tar.gz opensim-SC_OLD-f2c1d0e34feba801ff85c35ee049ed6d3067bb0d.tar.bz2 opensim-SC_OLD-f2c1d0e34feba801ff85c35ee049ed6d3067bb0d.tar.xz |
Merge branch 'opensim-master' into dev-appearance
Diffstat (limited to 'OpenSim/Region/CoreModules')
7 files changed, 111 insertions, 71 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index ef5efdd..4359c01 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -167,7 +167,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
167 | // sanity check: | 167 | // sanity check: |
168 | if (c.Sender == null) | 168 | if (c.Sender == null) |
169 | { | 169 | { |
170 | m_log.ErrorFormat("[CHAT] OnChatFromClient from {0} has empty Sender field!", sender); | 170 | m_log.ErrorFormat("[CHAT]: OnChatFromClient from {0} has empty Sender field!", sender); |
171 | return; | 171 | return; |
172 | } | 172 | } |
173 | 173 | ||
@@ -220,17 +220,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
220 | if (message.Length >= 1000) // libomv limit | 220 | if (message.Length >= 1000) // libomv limit |
221 | message = message.Substring(0, 1000); | 221 | message = message.Substring(0, 1000); |
222 | 222 | ||
223 | // m_log.DebugFormat("[CHAT]: DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType); | 223 | // m_log.DebugFormat( |
224 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", | ||
225 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); | ||
224 | 226 | ||
227 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | ||
228 | |||
225 | foreach (Scene s in m_scenes) | 229 | foreach (Scene s in m_scenes) |
226 | { | 230 | { |
227 | s.ForEachScenePresence( | 231 | s.ForEachScenePresence( |
228 | delegate(ScenePresence presence) | 232 | delegate(ScenePresence presence) |
229 | { | 233 | { |
230 | TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType); | 234 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType)) |
235 | receiverIDs.Add(presence.UUID); | ||
231 | } | 236 | } |
232 | ); | 237 | ); |
233 | } | 238 | } |
239 | |||
240 | (scene as Scene).EventManager.TriggerOnChatToClients( | ||
241 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); | ||
234 | } | 242 | } |
235 | 243 | ||
236 | static private Vector3 CenterOfRegion = new Vector3(128, 128, 30); | 244 | static private Vector3 CenterOfRegion = new Vector3(128, 128, 30); |
@@ -269,6 +277,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
269 | 277 | ||
270 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); | 278 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); |
271 | 279 | ||
280 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | ||
281 | |||
272 | ((Scene)c.Scene).ForEachScenePresence( | 282 | ((Scene)c.Scene).ForEachScenePresence( |
273 | delegate(ScenePresence presence) | 283 | delegate(ScenePresence presence) |
274 | { | 284 | { |
@@ -286,16 +296,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
286 | 296 | ||
287 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, | 297 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, |
288 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 298 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); |
299 | receiverIDs.Add(presence.UUID); | ||
289 | }); | 300 | }); |
301 | |||
302 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( | ||
303 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | ||
290 | } | 304 | } |
291 | 305 | ||
292 | 306 | /// <summary> | |
293 | protected virtual void TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, | 307 | /// Try to send a message to the given presence |
308 | /// </summary> | ||
309 | /// <param name="presence">The receiver</param> | ||
310 | /// <param name="fromPos"></param> | ||
311 | /// <param name="regionPos">/param> | ||
312 | /// <param name="fromAgentID"></param> | ||
313 | /// <param name="fromName"></param> | ||
314 | /// <param name="type"></param> | ||
315 | /// <param name="message"></param> | ||
316 | /// <param name="src"></param> | ||
317 | /// <returns>true if the message was sent to the receiver, false if it was not sent due to failing a | ||
318 | /// precondition</returns> | ||
319 | protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, | ||
294 | UUID fromAgentID, string fromName, ChatTypeEnum type, | 320 | UUID fromAgentID, string fromName, ChatTypeEnum type, |
295 | string message, ChatSourceType src) | 321 | string message, ChatSourceType src) |
296 | { | 322 | { |
297 | // don't send stuff to child agents | 323 | // don't send stuff to child agents |
298 | if (presence.IsChildAgent) return; | 324 | if (presence.IsChildAgent) return false; |
299 | 325 | ||
300 | Vector3 fromRegionPos = fromPos + regionPos; | 326 | Vector3 fromRegionPos = fromPos + regionPos; |
301 | Vector3 toRegionPos = presence.AbsolutePosition + | 327 | Vector3 toRegionPos = presence.AbsolutePosition + |
@@ -308,12 +334,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
308 | type == ChatTypeEnum.Say && dis > m_saydistance || | 334 | type == ChatTypeEnum.Say && dis > m_saydistance || |
309 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | 335 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) |
310 | { | 336 | { |
311 | return; | 337 | return false; |
312 | } | 338 | } |
313 | 339 | ||
314 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView | 340 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView |
315 | presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, | 341 | presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, |
316 | fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully); | 342 | fromAgentID, (byte)src, (byte)ChatAudibleLevel.Fully); |
343 | |||
344 | return true; | ||
317 | } | 345 | } |
318 | } | 346 | } |
319 | } | 347 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index c1df827..046b05f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -33,6 +33,7 @@ using System.Reflection; | |||
33 | using System.Threading; | 33 | using System.Threading; |
34 | using System.Text; | 34 | using System.Text; |
35 | using System.Xml; | 35 | using System.Xml; |
36 | using System.Xml.Linq; | ||
36 | using log4net; | 37 | using log4net; |
37 | using OpenMetaverse; | 38 | using OpenMetaverse; |
38 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
@@ -50,6 +51,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
50 | { | 51 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 53 | ||
54 | /// <summary> | ||
55 | /// The maximum major version of archive that we can read. Minor versions shouldn't need a max number since version | ||
56 | /// bumps here should be compatible. | ||
57 | /// </summary> | ||
58 | public static int MAX_MAJOR_VERSION = 0; | ||
59 | |||
53 | protected TarArchiveReader archive; | 60 | protected TarArchiveReader archive; |
54 | 61 | ||
55 | private UserAccount m_userInfo; | 62 | private UserAccount m_userInfo; |
@@ -133,7 +140,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
133 | 140 | ||
134 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) | 141 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) |
135 | { | 142 | { |
136 | if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) | 143 | if (filePath == ArchiveConstants.CONTROL_FILE_PATH) |
144 | { | ||
145 | LoadControlFile(filePath, data); | ||
146 | } | ||
147 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) | ||
137 | { | 148 | { |
138 | if (LoadAsset(filePath, data)) | 149 | if (LoadAsset(filePath, data)) |
139 | successfulAssetRestores++; | 150 | successfulAssetRestores++; |
@@ -461,5 +472,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
461 | return false; | 472 | return false; |
462 | } | 473 | } |
463 | } | 474 | } |
475 | |||
476 | /// <summary> | ||
477 | /// Load control file | ||
478 | /// </summary> | ||
479 | /// <param name="path"></param> | ||
480 | /// <param name="data"></param> | ||
481 | protected void LoadControlFile(string path, byte[] data) | ||
482 | { | ||
483 | XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data)); | ||
484 | XElement archiveElement = doc.Element("archive"); | ||
485 | int majorVersion = int.Parse(archiveElement.Attribute("major_version").Value); | ||
486 | int minorVersion = int.Parse(archiveElement.Attribute("minor_version").Value); | ||
487 | string version = string.Format("{0}.{1}", majorVersion, minorVersion); | ||
488 | |||
489 | if (majorVersion > MAX_MAJOR_VERSION) | ||
490 | { | ||
491 | throw new Exception( | ||
492 | string.Format( | ||
493 | "The IAR you are trying to load has major version number of {0} but this version of OpenSim can only load IARs with major version number {1} and below", | ||
494 | majorVersion, MAX_MAJOR_VERSION)); | ||
495 | } | ||
496 | |||
497 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); | ||
498 | } | ||
464 | } | 499 | } |
465 | } \ No newline at end of file | 500 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index bae5a7a..9080e1c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -123,9 +123,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
123 | 123 | ||
124 | try | 124 | try |
125 | { | 125 | { |
126 | // We're almost done. Just need to write out the control file now | ||
127 | m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile()); | ||
128 | m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); | ||
129 | m_archiveWriter.Close(); | 126 | m_archiveWriter.Close(); |
130 | } | 127 | } |
131 | catch (Exception e) | 128 | catch (Exception e) |
@@ -277,6 +274,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
277 | 274 | ||
278 | m_archiveWriter = new TarArchiveWriter(m_saveStream); | 275 | m_archiveWriter = new TarArchiveWriter(m_saveStream); |
279 | 276 | ||
277 | // Write out control file. This has to be done first so that subsequent loaders will see this file first | ||
278 | // XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this | ||
279 | m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile()); | ||
280 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Added control file to archive."); | ||
281 | |||
280 | if (inventoryFolder != null) | 282 | if (inventoryFolder != null) |
281 | { | 283 | { |
282 | m_log.DebugFormat( | 284 | m_log.DebugFormat( |
@@ -399,13 +401,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
399 | /// <returns></returns> | 401 | /// <returns></returns> |
400 | public static string Create0p1ControlFile() | 402 | public static string Create0p1ControlFile() |
401 | { | 403 | { |
404 | int majorVersion = 0, minorVersion = 1; | ||
405 | |||
406 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); | ||
407 | |||
402 | StringWriter sw = new StringWriter(); | 408 | StringWriter sw = new StringWriter(); |
403 | XmlTextWriter xtw = new XmlTextWriter(sw); | 409 | XmlTextWriter xtw = new XmlTextWriter(sw); |
404 | xtw.Formatting = Formatting.Indented; | 410 | xtw.Formatting = Formatting.Indented; |
405 | xtw.WriteStartDocument(); | 411 | xtw.WriteStartDocument(); |
406 | xtw.WriteStartElement("archive"); | 412 | xtw.WriteStartElement("archive"); |
407 | xtw.WriteAttributeString("major_version", "0"); | 413 | xtw.WriteAttributeString("major_version", majorVersion.ToString()); |
408 | xtw.WriteAttributeString("minor_version", "1"); | 414 | xtw.WriteAttributeString("minor_version", minorVersion.ToString()); |
409 | xtw.WriteEndElement(); | 415 | xtw.WriteEndElement(); |
410 | 416 | ||
411 | xtw.Flush(); | 417 | xtw.Flush(); |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index f1f5258..117b2fd 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
54 | 54 | ||
55 | /// <summary> | 55 | /// <summary> |
56 | /// The maximum major version of OAR that we can read. Minor versions shouldn't need a number since version | 56 | /// The maximum major version of OAR that we can read. Minor versions shouldn't need a max number since version |
57 | /// bumps here should be compatible. | 57 | /// bumps here should be compatible. |
58 | /// </summary> | 58 | /// </summary> |
59 | public static int MAX_MAJOR_VERSION = 0; | 59 | public static int MAX_MAJOR_VERSION = 0; |
@@ -481,17 +481,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
481 | /// </summary> | 481 | /// </summary> |
482 | /// <param name="path"></param> | 482 | /// <param name="path"></param> |
483 | /// <param name="data"></param> | 483 | /// <param name="data"></param> |
484 | private void LoadControlFile(string path, byte[] data) | 484 | protected void LoadControlFile(string path, byte[] data) |
485 | { | 485 | { |
486 | //Create the XmlNamespaceManager. | 486 | XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); |
487 | NameTable nt = new NameTable(); | ||
488 | XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); | ||
489 | |||
490 | // Create the XmlParserContext. | ||
491 | XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); | 487 | XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); |
492 | 488 | XmlTextReader xtr = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context); | |
493 | XmlTextReader xtr | ||
494 | = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context); | ||
495 | 489 | ||
496 | RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings; | 490 | RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings; |
497 | 491 | ||
@@ -530,10 +524,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
530 | currentRegionSettings.LoadedCreationID = xtr.ReadElementContentAsString(); | 524 | currentRegionSettings.LoadedCreationID = xtr.ReadElementContentAsString(); |
531 | } | 525 | } |
532 | } | 526 | } |
533 | |||
534 | } | 527 | } |
535 | 528 | ||
536 | currentRegionSettings.Save(); | 529 | currentRegionSettings.Save(); |
537 | } | 530 | } |
538 | } | 531 | } |
539 | } | 532 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 43789af..3182079 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs | |||
@@ -171,7 +171,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
171 | 171 | ||
172 | m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time."); | 172 | m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time."); |
173 | 173 | ||
174 | // Write out control file | 174 | // Write out control file. This has to be done first so that subsequent loaders will see this file first |
175 | // XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this | ||
175 | archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile(options)); | 176 | archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile(options)); |
176 | m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); | 177 | m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); |
177 | 178 | ||
@@ -198,13 +199,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
198 | { | 199 | { |
199 | majorVersion = 1; | 200 | majorVersion = 1; |
200 | minorVersion = 0; | 201 | minorVersion = 0; |
201 | } | 202 | } |
202 | */ | 203 | */ |
203 | 204 | ||
204 | m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion); | 205 | m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion); |
205 | // if (majorVersion == 1) | 206 | // if (majorVersion == 1) |
206 | // { | 207 | // { |
207 | // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); | 208 | // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); |
208 | // } | 209 | // } |
209 | 210 | ||
210 | 211 | ||
@@ -231,6 +232,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
231 | sw.Close(); | 232 | sw.Close(); |
232 | 233 | ||
233 | return s; | 234 | return s; |
234 | } | 235 | } |
235 | } | 236 | } |
236 | } | 237 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index a1451ce..d4a09b4 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | |||
@@ -188,7 +188,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
188 | m_log.ErrorFormat( | 188 | m_log.ErrorFormat( |
189 | "[ARCHIVER]: (... {0} more not shown)", uuids.Count - MAX_UUID_DISPLAY_ON_TIMEOUT); | 189 | "[ARCHIVER]: (... {0} more not shown)", uuids.Count - MAX_UUID_DISPLAY_ON_TIMEOUT); |
190 | 190 | ||
191 | m_log.Error("[ARCHIVER]: OAR save aborted."); | 191 | m_log.Error("[ARCHIVER]: OAR save aborted. PLEASE DO NOT USE THIS OAR, IT WILL BE INCOMPLETE."); |
192 | } | 192 | } |
193 | catch (Exception e) | 193 | catch (Exception e) |
194 | { | 194 | { |
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index a6dc2ec..cea7c78 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs | |||
@@ -44,10 +44,8 @@ namespace OpenSim.Region.CoreModules | |||
44 | /// it is not based on ~06:00 == Sun Rise. Rather it is based on 00:00 being sun-rise. | 44 | /// it is not based on ~06:00 == Sun Rise. Rather it is based on 00:00 being sun-rise. |
45 | /// </summary> | 45 | /// </summary> |
46 | 46 | ||
47 | |||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 48 | ||
50 | |||
51 | // | 49 | // |
52 | // Global Constants used to determine where in the sky the sun is | 50 | // Global Constants used to determine where in the sky the sun is |
53 | // | 51 | // |
@@ -108,26 +106,25 @@ namespace OpenSim.Region.CoreModules | |||
108 | private Scene m_scene = null; | 106 | private Scene m_scene = null; |
109 | 107 | ||
110 | // Calculated Once in the lifetime of a region | 108 | // Calculated Once in the lifetime of a region |
111 | private long TicksToEpoch; // Elapsed time for 1/1/1970 | 109 | private long TicksToEpoch; // Elapsed time for 1/1/1970 |
112 | private uint SecondsPerSunCycle; // Length of a virtual day in RW seconds | 110 | private uint SecondsPerSunCycle; // Length of a virtual day in RW seconds |
113 | private uint SecondsPerYear; // Length of a virtual year in RW seconds | 111 | private uint SecondsPerYear; // Length of a virtual year in RW seconds |
114 | private double SunSpeed; // Rate of passage in radians/second | 112 | private double SunSpeed; // Rate of passage in radians/second |
115 | private double SeasonSpeed; // Rate of change for seasonal effects | 113 | private double SeasonSpeed; // Rate of change for seasonal effects |
116 | // private double HoursToRadians; // Rate of change for seasonal effects | 114 | // private double HoursToRadians; // Rate of change for seasonal effects |
117 | private long TicksUTCOffset = 0; // seconds offset from UTC | 115 | private long TicksUTCOffset = 0; // seconds offset from UTC |
118 | // Calculated every update | 116 | // Calculated every update |
119 | private float OrbitalPosition; // Orbital placement at a point in time | 117 | private float OrbitalPosition; // Orbital placement at a point in time |
120 | private double HorizonShift; // Axis offset to skew day and night | 118 | private double HorizonShift; // Axis offset to skew day and night |
121 | private double TotalDistanceTravelled; // Distance since beginning of time (in radians) | 119 | private double TotalDistanceTravelled; // Distance since beginning of time (in radians) |
122 | private double SeasonalOffset; // Seaonal variation of tilt | 120 | private double SeasonalOffset; // Seaonal variation of tilt |
123 | private float Magnitude; // Normal tilt | 121 | private float Magnitude; // Normal tilt |
124 | // private double VWTimeRatio; // VW time as a ratio of real time | 122 | // private double VWTimeRatio; // VW time as a ratio of real time |
125 | 123 | ||
126 | // Working values | 124 | // Working values |
127 | private Vector3 Position = Vector3.Zero; | 125 | private Vector3 Position = Vector3.Zero; |
128 | private Vector3 Velocity = Vector3.Zero; | 126 | private Vector3 Velocity = Vector3.Zero; |
129 | private Quaternion Tilt = new Quaternion(1.0f, 0.0f, 0.0f, 0.0f); | 127 | private Quaternion Tilt = new Quaternion(1.0f, 0.0f, 0.0f, 0.0f); |
130 | |||
131 | 128 | ||
132 | // Used to fix the sun in the sky so it doesn't move based on current time | 129 | // Used to fix the sun in the sky so it doesn't move based on current time |
133 | private bool m_SunFixed = false; | 130 | private bool m_SunFixed = false; |
@@ -135,8 +132,6 @@ namespace OpenSim.Region.CoreModules | |||
135 | 132 | ||
136 | private const int TICKS_PER_SECOND = 10000000; | 133 | private const int TICKS_PER_SECOND = 10000000; |
137 | 134 | ||
138 | |||
139 | |||
140 | // Current time in elapsed seconds since Jan 1st 1970 | 135 | // Current time in elapsed seconds since Jan 1st 1970 |
141 | private ulong CurrentTime | 136 | private ulong CurrentTime |
142 | { | 137 | { |
@@ -149,8 +144,6 @@ namespace OpenSim.Region.CoreModules | |||
149 | // Time in seconds since UTC to use to calculate sun position. | 144 | // Time in seconds since UTC to use to calculate sun position. |
150 | ulong PosTime = 0; | 145 | ulong PosTime = 0; |
151 | 146 | ||
152 | |||
153 | |||
154 | /// <summary> | 147 | /// <summary> |
155 | /// Calculate the sun's orbital position and its velocity. | 148 | /// Calculate the sun's orbital position and its velocity. |
156 | /// </summary> | 149 | /// </summary> |
@@ -202,7 +195,6 @@ namespace OpenSim.Region.CoreModules | |||
202 | PosTime += (ulong)(((CurDayPercentage - 0.5) / .5) * NightSeconds); | 195 | PosTime += (ulong)(((CurDayPercentage - 0.5) / .5) * NightSeconds); |
203 | } | 196 | } |
204 | } | 197 | } |
205 | |||
206 | } | 198 | } |
207 | 199 | ||
208 | TotalDistanceTravelled = SunSpeed * PosTime; // distance measured in radians | 200 | TotalDistanceTravelled = SunSpeed * PosTime; // distance measured in radians |
@@ -251,7 +243,6 @@ namespace OpenSim.Region.CoreModules | |||
251 | Velocity.X = 0; | 243 | Velocity.X = 0; |
252 | Velocity.Y = 0; | 244 | Velocity.Y = 0; |
253 | Velocity.Z = 0; | 245 | Velocity.Z = 0; |
254 | |||
255 | } | 246 | } |
256 | else | 247 | else |
257 | { | 248 | { |
@@ -271,9 +262,7 @@ namespace OpenSim.Region.CoreModules | |||
271 | private float GetCurrentTimeAsLindenSunHour() | 262 | private float GetCurrentTimeAsLindenSunHour() |
272 | { | 263 | { |
273 | if (m_SunFixed) | 264 | if (m_SunFixed) |
274 | { | ||
275 | return m_SunFixedHour + 6; | 265 | return m_SunFixedHour + 6; |
276 | } | ||
277 | 266 | ||
278 | return GetCurrentSunHour() + 6.0f; | 267 | return GetCurrentSunHour() + 6.0f; |
279 | } | 268 | } |
@@ -297,8 +286,6 @@ namespace OpenSim.Region.CoreModules | |||
297 | m_scene.AddCommand(this, String.Format("sun {0}", kvp.Key), String.Format("{0} - {1}", kvp.Key, kvp.Value), "", HandleSunConsoleCommand); | 286 | m_scene.AddCommand(this, String.Format("sun {0}", kvp.Key), String.Format("{0} - {1}", kvp.Key, kvp.Value), "", HandleSunConsoleCommand); |
298 | } | 287 | } |
299 | 288 | ||
300 | |||
301 | |||
302 | TimeZone local = TimeZone.CurrentTimeZone; | 289 | TimeZone local = TimeZone.CurrentTimeZone; |
303 | TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; | 290 | TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; |
304 | m_log.Debug("[SUN]: localtime offset is " + TicksUTCOffset); | 291 | m_log.Debug("[SUN]: localtime offset is " + TicksUTCOffset); |
@@ -325,13 +312,11 @@ namespace OpenSim.Region.CoreModules | |||
325 | // must hard code to ~.5 to match sun position in LL based viewers | 312 | // must hard code to ~.5 to match sun position in LL based viewers |
326 | m_HorizonShift = config.Configs["Sun"].GetDouble("day_night_offset", d_day_night); | 313 | m_HorizonShift = config.Configs["Sun"].GetDouble("day_night_offset", d_day_night); |
327 | 314 | ||
328 | |||
329 | // Scales the sun hours 0...12 vs 12...24, essentially makes daylight hours longer/shorter vs nighttime hours | 315 | // Scales the sun hours 0...12 vs 12...24, essentially makes daylight hours longer/shorter vs nighttime hours |
330 | m_DayTimeSunHourScale = config.Configs["Sun"].GetDouble("day_time_sun_hour_scale", d_DayTimeSunHourScale); | 316 | m_DayTimeSunHourScale = config.Configs["Sun"].GetDouble("day_time_sun_hour_scale", d_DayTimeSunHourScale); |
331 | 317 | ||
332 | // Update frequency in frames | 318 | // Update frequency in frames |
333 | m_UpdateInterval = config.Configs["Sun"].GetInt("update_interval", d_frame_mod); | 319 | m_UpdateInterval = config.Configs["Sun"].GetInt("update_interval", d_frame_mod); |
334 | |||
335 | } | 320 | } |
336 | catch (Exception e) | 321 | catch (Exception e) |
337 | { | 322 | { |
@@ -391,10 +376,8 @@ namespace OpenSim.Region.CoreModules | |||
391 | } | 376 | } |
392 | 377 | ||
393 | scene.RegisterModuleInterface<ISunModule>(this); | 378 | scene.RegisterModuleInterface<ISunModule>(this); |
394 | |||
395 | } | 379 | } |
396 | 380 | ||
397 | |||
398 | public void PostInitialise() | 381 | public void PostInitialise() |
399 | { | 382 | { |
400 | } | 383 | } |
@@ -402,7 +385,7 @@ namespace OpenSim.Region.CoreModules | |||
402 | public void Close() | 385 | public void Close() |
403 | { | 386 | { |
404 | ready = false; | 387 | ready = false; |
405 | 388 | ||
406 | // Remove our hooks | 389 | // Remove our hooks |
407 | m_scene.EventManager.OnFrame -= SunUpdate; | 390 | m_scene.EventManager.OnFrame -= SunUpdate; |
408 | m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel; | 391 | m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel; |
@@ -419,6 +402,7 @@ namespace OpenSim.Region.CoreModules | |||
419 | { | 402 | { |
420 | get { return false; } | 403 | get { return false; } |
421 | } | 404 | } |
405 | |||
422 | #endregion | 406 | #endregion |
423 | 407 | ||
424 | #region EventManager Events | 408 | #region EventManager Events |
@@ -446,9 +430,7 @@ namespace OpenSim.Region.CoreModules | |||
446 | public void SunUpdate() | 430 | public void SunUpdate() |
447 | { | 431 | { |
448 | if (((m_frame++ % m_UpdateInterval) != 0) || !ready || m_SunFixed || !receivedEstateToolsSunUpdate) | 432 | if (((m_frame++ % m_UpdateInterval) != 0) || !ready || m_SunFixed || !receivedEstateToolsSunUpdate) |
449 | { | ||
450 | return; | 433 | return; |
451 | } | ||
452 | 434 | ||
453 | GenSunPos(); // Generate shared values once | 435 | GenSunPos(); // Generate shared values once |
454 | 436 | ||
@@ -467,7 +449,7 @@ namespace OpenSim.Region.CoreModules | |||
467 | } | 449 | } |
468 | 450 | ||
469 | /// <summary> | 451 | /// <summary> |
470 | /// | 452 | /// |
471 | /// </summary> | 453 | /// </summary> |
472 | /// <param name="regionHandle"></param> | 454 | /// <param name="regionHandle"></param> |
473 | /// <param name="FixedTime">Is the sun's position fixed?</param> | 455 | /// <param name="FixedTime">Is the sun's position fixed?</param> |
@@ -484,7 +466,6 @@ namespace OpenSim.Region.CoreModules | |||
484 | while (FixedSunHour < 0) | 466 | while (FixedSunHour < 0) |
485 | FixedSunHour += 24; | 467 | FixedSunHour += 24; |
486 | 468 | ||
487 | |||
488 | m_SunFixedHour = FixedSunHour; | 469 | m_SunFixedHour = FixedSunHour; |
489 | m_SunFixed = FixedSun; | 470 | m_SunFixed = FixedSun; |
490 | 471 | ||
@@ -499,14 +480,12 @@ namespace OpenSim.Region.CoreModules | |||
499 | // When sun settings are updated, we should update all clients with new settings. | 480 | // When sun settings are updated, we should update all clients with new settings. |
500 | SunUpdateToAllClients(); | 481 | SunUpdateToAllClients(); |
501 | 482 | ||
502 | |||
503 | m_log.DebugFormat("[SUN]: PosTime : {0}", PosTime.ToString()); | 483 | m_log.DebugFormat("[SUN]: PosTime : {0}", PosTime.ToString()); |
504 | } | 484 | } |
505 | } | 485 | } |
506 | 486 | ||
507 | #endregion | 487 | #endregion |
508 | 488 | ||
509 | |||
510 | private void SunUpdateToAllClients() | 489 | private void SunUpdateToAllClients() |
511 | { | 490 | { |
512 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) | 491 | m_scene.ForEachScenePresence(delegate(ScenePresence sp) |
@@ -553,7 +532,6 @@ namespace OpenSim.Region.CoreModules | |||
553 | { | 532 | { |
554 | float ticksleftover = CurrentTime % SecondsPerSunCycle; | 533 | float ticksleftover = CurrentTime % SecondsPerSunCycle; |
555 | 534 | ||
556 | |||
557 | return (24.0f * (ticksleftover / SecondsPerSunCycle)); | 535 | return (24.0f * (ticksleftover / SecondsPerSunCycle)); |
558 | } | 536 | } |
559 | 537 | ||
@@ -666,7 +644,6 @@ namespace OpenSim.Region.CoreModules | |||
666 | 644 | ||
667 | // When sun settings are updated, we should update all clients with new settings. | 645 | // When sun settings are updated, we should update all clients with new settings. |
668 | SunUpdateToAllClients(); | 646 | SunUpdateToAllClients(); |
669 | |||
670 | } | 647 | } |
671 | 648 | ||
672 | return Output; | 649 | return Output; |