OSDN Git Service

RAD-7 RAD-172: Complete inventory search, recent and worn filters
[radegast/radegast.git] / Radegast / Core / RadegastInstance.cs
index 2fb5ce2..70cbd78 100644 (file)
@@ -1,6 +1,6 @@
 // 
 // Radegast Metaverse Client
-// Copyright (c) 2009, Radegast Development Team
+// Copyright (c) 2009-2010, Radegast Development Team
 // All rights reserved.
 // 
 // Redistribution and use in source and binary forms, with or without
@@ -53,6 +53,7 @@ namespace Radegast
             if (RadegastFormCreated != null) RadegastFormCreated(radForm);
         }
         #endregion
+
         private GridClient client;
         private RadegastNetcom netcom;
 
@@ -74,6 +75,16 @@ namespace Radegast
             }
         }
 
+        /// <summary>
+        /// When was Radegast started (UTC)
+        /// </summary>
+        public readonly DateTime StartupTimeUTC;
+
+        /// <summary>
+        /// Time zone of the current world (currently hard coded to US Pacific time)
+        /// </summary>
+        public TimeZoneInfo WordTimeZone;
+
         private string userDir;
         /// <summary>
         /// System (not grid!) user's dir
@@ -249,6 +260,10 @@ namespace Radegast
 
             client = client0;
 
+            // Initialize current time zone, and mark when we started
+            GetWorldTimeZone();
+            StartupTimeUTC = DateTime.UtcNow;
+
             // Are we running mono?
             monoRuntime = Type.GetType("Mono.Runtime") != null;
 
@@ -292,7 +307,7 @@ namespace Radegast
             client.Assets.Cache.AutoPruneEnabled = false;
 
             client.Throttle.Total = 5000000f;
-            client.Settings.THROTTLE_OUTGOING_PACKETS = true;
+            client.Settings.THROTTLE_OUTGOING_PACKETS = false;
             client.Settings.LOGIN_TIMEOUT = 120 * 1000;
             client.Settings.SIMULATOR_TIMEOUT = 120 * 1000;
             client.Settings.MAX_CONCURRENT_TEXTURE_DOWNLOADS = 20;
@@ -322,6 +337,42 @@ namespace Radegast
                 netcom.ClientConnected -= new EventHandler<EventArgs>(netcom_ClientConnected);
         }
 
+        private void GetWorldTimeZone()
+        {
+            try
+            {
+                foreach (TimeZoneInfo tz in TimeZoneInfo.GetSystemTimeZones())
+                {
+                    if (tz.Id == "Pacific Standard Time" || tz.Id == "America/Los_Angeles")
+                    {
+                        WordTimeZone = tz;
+                        break;
+                    }
+                }
+            }
+            catch (Exception) { }
+        }
+
+        public DateTime GetWorldTime()
+        {
+            DateTime now;
+            
+            try
+            {
+                if (WordTimeZone != null)
+                    now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, WordTimeZone);
+                else
+                    now = DateTime.UtcNow.AddHours(-7);
+            }
+            catch (Exception)
+            {
+                now = DateTime.UtcNow.AddHours(-7);
+            }
+
+            return now;
+        }
+
+
         public void Reconnect()
         {
             TabConsole.DisplayNotificationInChat("Attempting to reconnect...", ChatBufferTextStyle.StatusDarkBlue);
@@ -461,7 +512,7 @@ namespace Radegast
 
                 if (name == INCOMPLETE_NAME)
                 {
-                    gotName.WaitOne(10 * 1000);
+                    gotName.WaitOne(10 * 1000, false);
                 }
 
                 client.Avatars.UUIDNameReply -= handler;