Fixes for OLA/Relay

Fixes for OLA/Relay

git-svn-id: 47f56b7fec11f2b20b024c4b5577ab30eb1905fb@90517 2327b42d-5241-43d6-9e2a-de5ac946f064

--- WOCEmmaClient/OlaParser.cs
+++ WOCEmmaClient/OlaParser.cs
@@ -101,14 +101,14 @@
                     string splitbaseCommand = "select splittimes.modifyDate, splittimes.passedTime, Controls.ID, results.entryid, results.allocatedStartTime, persons.familyname as lastname, persons.firstname as firstname, clubs.name as clubname, eventclasses.shortName, splittimes.passedCount from splittimes, results, SplitTimeControls, Controls, eventClasses, raceClasses, Persons, Clubs, entries where splittimes.resultraceindividualnumber = results.resultid and SplitTimes.splitTimeControlID = SplitTimeControls.splitTimeControlID and SplitTimeControls.timingControl = Controls.controlid and Controls.eventRaceId = " + m_EventRaceId + " and raceclasses.eventClassID = eventClasses.eventClassID and results.raceClassID = raceclasses.raceclassid and raceClasses.eventRaceId = " + m_EventRaceId + " and eventclasses.eventid = " + m_EventID + " and results.entryid = entries.entryid and entries.competitorid = persons.personid and persons.clubid = clubs.clubid and splitTimes.modifyDate > " + paramOper;
                     if (isOla5)
                     {
-                        baseCommand = "select results.modifyDate, results.totalTime, results.position, persons.familyname as lastname, persons.firstname as firstname, organisations.name as clubname, eventclasses.shortName, results.runnerStatus, results.entryid, results.allocatedStartTime, results.starttime from results, entries, Persons, organisations, raceclasses,eventclasses where raceclasses.eventClassID = eventClasses.eventClassID and results.raceClassID = raceclasses.raceclassid and raceClasses.eventRaceId = " + m_EventRaceId + " and eventclasses.eventid = " + m_EventID + " and results.entryid = entries.entryid and entries.competitorid = persons.personid and persons.defaultorganisationid = organisations.organisationid and results.runnerStatus != 'notActivated' and results.modifyDate > " + paramOper;
+                        baseCommand = "select results.modifyDate, results.totalTime, results.position, persons.familyname as lastname, persons.firstname as firstname, organisations.name as clubname, eventclasses.shortName, results.runnerStatus, results.entryid, results.allocatedStartTime, results.starttime from results, entries, Persons, organisations, raceclasses,eventclasses where raceclasses.eventClassID = eventClasses.eventClassID and results.raceClassID = raceclasses.raceclassid and raceClasses.eventRaceId = " + m_EventRaceId + " and eventclasses.eventid = " + m_EventID + " and results.entryid = entries.entryid and entries.competitorid = persons.personid and persons.defaultorganisationid = organisations.organisationid and results.modifyDate > " + paramOper;
                         splitbaseCommand = "select splittimes.modifyDate, splittimes.passedTime, Controls.ID, results.entryid, results.allocatedStartTime, results.starttime, persons.familyname as lastname, persons.firstname as firstname, organisations.name as clubname, eventclasses.shortName, splittimes.passedCount from splittimes, results, SplitTimeControls, Controls, eventClasses, raceClasses, Persons, organisations, entries where splittimes.resultraceindividualnumber = results.resultid and SplitTimes.splitTimeControlID = SplitTimeControls.splitTimeControlID and SplitTimeControls.timingControl = Controls.controlid and Controls.eventRaceId = " + m_EventRaceId + " and raceclasses.eventClassID = eventClasses.eventClassID and results.raceClassID = raceclasses.raceclassid and raceClasses.eventRaceId = " + m_EventRaceId + " and eventclasses.eventid = " + m_EventID + " and results.entryid = entries.entryid and entries.competitorid = persons.personid and persons.defaultorganisationid = organisations.organisationid and splitTimes.modifyDate > " + paramOper;
                     }

                     if (isRelay)
                     {
-                        baseCommand = "select results.modifyDate,results.totalTime, results.position, persons.familyname as lastname, persons.firstname as firstname, entries.teamName as clubname, eventclasses.shortName, raceclasses.relayleg, results.runnerStatus, results.relayPersonId as entryId, results.finishTime, results.allocatedStartTime, (select firststarttime from raceclasses rc where rc.eventClassId = eventclasses.EventClassID and rc.relayleg=1 and rc.eventRaceId = " + m_EventRaceId + ") as firststarttime from results, entries, Persons, raceclasses,eventclasses where raceclasses.eventClassID = eventClasses.eventClassID and results.raceClassID = raceclasses.raceclassid and raceClasses.eventRaceId = " + m_EventRaceId + " and eventclasses.eventid = " + m_EventID + " and results.entryid = entries.entryid and results.relaypersonid = persons.personid and results.runnerStatus != 'notActivated' and results.modifyDate > " + paramOper;
-                        splitbaseCommand = "select splittimes.modifyDate, splittimes.passedTime, Controls.ID, results.relayPersonId as entryId, results.allocatedStartTime, persons.familyname as lastname, persons.firstname as firstname, entries.teamName as clubname, eventclasses.shortName,raceclasses.relayleg, splittimes.passedCount,results.allocatedStartTime  from splittimes, results, SplitTimeControls, Controls, eventClasses, raceClasses, Persons, entries where splittimes.resultraceindividualnumber = results.resultid and SplitTimes.splitTimeControlID = SplitTimeControls.splitTimeControlID and SplitTimeControls.timingControl = Controls.controlid and Controls.eventRaceId = " + m_EventRaceId + " and raceclasses.eventClassID = eventClasses.eventClassID and results.raceClassID = raceclasses.raceclassid and raceClasses.eventRaceId = " + m_EventRaceId + " and eventclasses.eventid = " + m_EventID + " and results.entryid = entries.entryid and results.relaypersonid = persons.personid and splitTimes.modifyDate > " + paramOper;
+                        baseCommand = "select results.modifyDate,results.totalTime, results.position, persons.familyname as lastname, persons.firstname as firstname, entries.teamName as clubname, eventclasses.shortName, raceclasses.relayleg, results.runnerStatus, results.resultId as entryId, results.finishTime, results.allocatedStartTime, results.starttime, (select firststarttime from raceclasses rc where rc.eventClassId = eventclasses.EventClassID and rc.relayleg=1 and rc.eventRaceId = " + m_EventRaceId + ") as firststarttime from results, entries, Persons, raceclasses,eventclasses where raceclasses.eventClassID = eventClasses.eventClassID and results.raceClassID = raceclasses.raceclassid and raceClasses.eventRaceId = " + m_EventRaceId + " and eventclasses.eventid = " + m_EventID + " and results.entryid = entries.entryid and results.relaypersonid = persons.personid and results.modifyDate > " + paramOper;
+                        splitbaseCommand = "select splittimes.modifyDate, splittimes.passedTime, Controls.ID, results.resultId as entryId, results.allocatedStartTime, persons.familyname as lastname, persons.firstname as firstname, entries.teamName as clubname, eventclasses.shortName,raceclasses.relayleg, splittimes.passedCount,results.allocatedStartTime, (select firststarttime from raceclasses rc where rc.eventClassId = eventclasses.EventClassID and rc.relayleg=1 and rc.eventRaceId = " + m_EventRaceId + ") as firststarttime  from splittimes, results, SplitTimeControls, Controls, eventClasses, raceClasses, Persons, entries where splittimes.resultraceindividualnumber = results.resultid and SplitTimes.splitTimeControlID = SplitTimeControls.splitTimeControlID and SplitTimeControls.timingControl = Controls.controlid and Controls.eventRaceId = " + m_EventRaceId + " and raceclasses.eventClassID = eventClasses.eventClassID and results.raceClassID = raceclasses.raceclassid and raceClasses.eventRaceId = " + m_EventRaceId + " and eventclasses.eventid = " + m_EventID + " and results.entryid = entries.entryid and results.relaypersonid = persons.personid and splitTimes.modifyDate > " + paramOper;
                     }

                     cmd.CommandText = baseCommand; //new OleDbCommand(baseCommand, m_Connection);
@@ -216,6 +216,7 @@
                                         string tTime = reader["starttime"].ToString();
                                         startTime = ParseDateTime(tTime);
                                     }
+

                                     iStartTime = 0;
                                     if (startTime > DateTime.MinValue)
@@ -293,7 +294,7 @@
                                         rstatus = 12;
                                         break;
                                 }
-                                if (rstatus != 9 && rstatus != 10)
+                                //if (rstatus != 9 && rstatus != 10)
                                     FireOnResult(runnerID, 0, fName + " " + famName, club, classN, iStartTime, time, rstatus, new List<ResultStruct>());

                             }
@@ -315,7 +316,12 @@
                                 int entryid = Convert.ToInt32(reader["entryid"].ToString());
                                 DateTime startTime;

-                                if (reader["allocatedStartTime"] != null && reader["allocatedStartTime"] != DBNull.Value)
+                                if (reader["firstStartTime"] != null && reader["firstStartTime"] != DBNull.Value)
+                                {
+                                    tTime = reader["firstStartTime"].ToString();
+                                    startTime = ParseDateTime(tTime);
+                                }
+                                else if (reader["allocatedStartTime"] != null && reader["allocatedStartTime"] != DBNull.Value)
                                 {
                                     tTime = reader["allocatedStartTime"].ToString();
                                     startTime = ParseDateTime(tTime);


Fix property name

Fix property name

--- WalletWasabi.Gui/Config.cs
+++ WalletWasabi.Gui/Config.cs
@@ -65,7 +65,7 @@
 		[JsonProperty(PropertyName = "StopLocalBitcoinCoreOnShutdown", DefaultValueHandling = DefaultValueHandling.Populate)]
 		public bool StopLocalBitcoinCoreOnShutdown { get; internal set; }

-		[JsonProperty(PropertyName = "BitcoinCoreDataDir")]
+		[JsonProperty(PropertyName = "LocalBitcoinCoreDataDir")]
 		public string LocalBitcoinCoreDataDir { get; internal set; } = EnvironmentHelpers.TryGetDefaultBitcoinCoreDataDir() ?? "";

 		[JsonProperty(PropertyName = "TorSocks5EndPoint")]


Wait for initialization

Wait for initialization

--- WalletWasabi.Gui/Global.cs
+++ WalletWasabi.Gui/Global.cs
@@ -118,6 +118,8 @@
 			}
 		}

+		private static bool Initialized { get; set; } = false;
+
 		public static async Task InitializeNoWalletAsync()
 		{
 			WalletService = null;
@@ -341,6 +343,8 @@
 			Logger.LogInfo("Start synchronizing filters...");

 			#endregion SynchronizerInitialization
+
+			Initialized = true;
 		}

 		private static async Task AddKnownBitcoinFullNodeAsHiddenServiceAsync(AddressManager addressManager)
@@ -377,6 +381,11 @@

 		public static async Task InitializeWalletServiceAsync(KeyManager keyManager)
 		{
+			while (!Initialized)
+			{
+				await Task.Delay(100);
+			}
+
 			if (Config.UseTor.Value)
 			{
 				ChaumianClient = new CcjClient(Synchronizer, Network, keyManager, () => Config.GetCurrentBackendUri(), Config.GetTorSocks5EndPoint());


[skip ci] Merge pull request #927 from lontivero/Fixed/OSX-Notification-Error

Wrap osasacript parameter around quote marks

--- WalletWasabi.Gui/Global.cs
+++ WalletWasabi.Gui/Global.cs
@@ -274,7 +274,7 @@
 						Process.Start(new ProcessStartInfo
 						{
 							FileName = "osascript",
-							Arguments = $"-e display notification \"Received {coin.Amount.ToString(false, true)} BTC\" with title \"Wasabi\"",
+							Arguments = $"-e \"display notification \\\"Received {coin.Amount.ToString(false, true)} BTC\\\" with title \\\"Wasabi\\\"\"",
 							CreateNoWindow = true
 						});
 					}


Catch exception and log

Catch exception and log

--- WalletWasabi.Gui/Global.cs
+++ WalletWasabi.Gui/Global.cs
@@ -76,14 +76,21 @@
 			Config = Guard.NotNull(nameof(config), config);
 		}

-		private static async Task DequeueAllCoinsAsync()
-		{
-			Logger.LogWarning("Process was signaled for killing.");
-			if (WalletService == null || ChaumianClient == null)
-				return;
-			Logger.LogWarning("Unregistering coins in CoinJoin process.");
-			IEnumerable<SmartCoin> enqueuedCoins = WalletService.Coins.Where(x => x.CoinJoinInProgress);
-			await ChaumianClient.DequeueCoinsFromMixAsync(enqueuedCoins.ToArray());
+		private static async Task TryDequeueAllCoinsAsync()
+		{
+			try
+			{
+				Logger.LogWarning("Process was signaled for killing.", nameof(Global));
+				if (WalletService == null || ChaumianClient == null)
+					return;
+				Logger.LogWarning("Unregistering coins in CoinJoin process.", nameof(Global));
+				IEnumerable<SmartCoin> enqueuedCoins = WalletService.Coins.Where(x => x.CoinJoinInProgress);
+				await ChaumianClient.DequeueCoinsFromMixAsync(enqueuedCoins.ToArray());
+			}
+			catch (Exception ex)
+			{
+				Logger.LogWarning(ex, nameof(Global));
+			}
 		}

 		public static void InitializeNoWallet()
@@ -91,11 +98,11 @@
 			WalletService = null;
 			ChaumianClient = null;

-			AppDomain.CurrentDomain.ProcessExit += async (s, e) => await DequeueAllCoinsAsync();
+			AppDomain.CurrentDomain.ProcessExit += async (s, e) => await TryDequeueAllCoinsAsync();
 			Console.CancelKeyPress += async (s, e) =>
 			{
 				e.Cancel = true;
-				await DequeueAllCoinsAsync();
+				await TryDequeueAllCoinsAsync();
 			};

 			var addressManagerFolderPath = Path.Combine(DataDir, "AddressManager");


fixed viewer not starting in an authenticated mode

--- WebApp/MarkupPanel.ascx.cs
+++ WebApp/MarkupPanel.ascx.cs
@@ -33,9 +33,9 @@
       {
         tboMarkupUser.Attributes["value"] = AppUser.GetDisplayName(connection);
         tboMarkupUser.Attributes["disabled"] = "disabled";
-				chkMarkupLock.Style["visibility"] = "visible";
+        chkMarkupLock.Style["visibility"] = "visible";
         labMarkupLock.Style["visibility"] = "visible";
-        cmdNewMarkup.Attributes["class"] = cmdNewMarkup.Attributes["class"].Replace("btnControlLock", "");
+        cmdNewMarkup.CssClass = cmdNewMarkup.CssClass.Replace("btnControlLock", "");
       }
     }
   }


CrossLines3D: use ColorExtensionMethods

CrossLines3D: use ColorExtensionMethods

--- WpfUtility/CrossLines3D.cs
+++ WpfUtility/CrossLines3D.cs
@@ -50,7 +50,7 @@
         }

         private void SetColor(Color color) {
-            var material = new DiffuseMaterial(new SolidColorBrush(color));
+            var material = color.ToMaterial();
             _model.Material = material;
             _model.BackMaterial = material;
         }


Fixed chomp indicator emitting logic

Fixed chomp indicator emitting logic

Unit test RoundtripExample17 was failing because the correct chomp indicator wasn't being emitted

--- YamlDotNet.Core/Emitter.cs
+++ YamlDotNet.Core/Emitter.cs
@@ -1842,17 +1842,12 @@
 			isOpenEnded = false;

 			string chomp_hint = null;
-			if(value.Length == 0) {
+			if(value.Length == 0 || !analyzer.IsBreak(value.Length - 1)) {
 				chomp_hint = "-";
 			}
-			else {
-				if(analyzer.IsBreak(value.Length - 1)) {
-					chomp_hint = "-";
-				}
-				else if(value.Length < 2 || analyzer.IsBreak(value.Length - 2)) {
-					chomp_hint = "+";
-					isOpenEnded = true;
-				}
+			else if(value.Length >= 2 && analyzer.IsBreak(value.Length - 2)) {
+				chomp_hint = "+";
+				isOpenEnded = true;
 			}

 			if(chomp_hint != null){
@@ -1860,4 +1855,4 @@
 			}
 		}
 	}
-}+}


Delete TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs


Fixed breaking change to list boxes

Fixed breaking change to list boxes

--- Engines/Forms/FlatRedBall.Forms/FlatRedBall.Forms.Shared/Controls/ItemsControl.cs
+++ Engines/Forms/FlatRedBall.Forms/FlatRedBall.Forms.Shared/Controls/ItemsControl.cs
@@ -15,7 +15,29 @@
         #region Fields/Properties

         protected Type ItemGumType { get; set; }
-        protected Type ItemFormsType { get; set; } = typeof(ListBoxItem);
+
+        Type itemFormsType = typeof(ListBoxItem);
+
+
+        // There can be a logical conflict when dealing with list items.
+        // When creating a Gum list item, the Gum object may specify a Forms
+        // type. But the list can also specify a forms type. So which do we use?
+        // We'll use the list item forms type unless the list box has its value set
+        // explicitly. then we'll go to the list box type. This eventually should get
+        // marked as obsolete and we should instead go to a VM solution.
+        bool isItemTypeSetExplicitly = false;
+        protected Type ItemFormsType
+        {
+            get => itemFormsType;
+            set
+            {
+                if(value !=  itemFormsType)
+                {
+                    isItemTypeSetExplicitly = true;
+                    itemFormsType = value;
+                }
+            }
+        }

         IList items;
         public IList Items
@@ -142,7 +164,7 @@
                 }

                 ListBoxItem item;
-                if (visual.FormsControlAsObject is ListBoxItem asListBoxItem)
+                if (visual.FormsControlAsObject is ListBoxItem asListBoxItem && ! isItemTypeSetExplicitly)
                 {
                     item = asListBoxItem;
                 }


Use UUID for logging in ServicePlatformDataProvider.Subscription.cs

--- PART/Source/CprBroker/ServicePlatform/ServicePlatformDataProvider.Subscription.cs
+++ PART/Source/CprBroker/ServicePlatform/ServicePlatformDataProvider.Subscription.cs
@@ -59,7 +59,7 @@
         public bool PutSubscription(PersonIdentifier personIdentifier)
         {
             var service = CreateService<CprSubscriptionService.CprSubscriptionWebServicePortType, CprSubscriptionService.CprSubscriptionWebServicePortTypeClient>(ServiceInfo.CPRSubscription);
-
+
             using (var callContext = this.BeginCall("AddPNRSubscription", personIdentifier.CprNumber))
             {
                 try
@@ -84,17 +84,17 @@
                                 //success
                                 break;
                             case ReturnCodePNR.NON_EXISTING_PNR:
-                                throw new Exception(String.Format("Error placing subscription for PNR <{0}>, service platform returns NON_EXISTING_PNR.", personIdentifier.CprNumber));
+                                throw new Exception(String.Format("Error placing subscription for UUID <{0}>, service platform returns NON_EXISTING_PNR.", personIdentifier.UUID));
                             default:
-                                throw new Exception(String.Format("Error placing subscription for PNR <{0}>, service platform returns unexpected code <{1}>.", personIdentifier.CprNumber, returnCode));
+                                throw new Exception(String.Format("Error placing subscription for UUID <{0}>, service platform returns unexpected code <{1}>.", personIdentifier.UUID, returnCode));
                         }
-                        //Admin.LogSuccess(String.Format("Placed service platform subscription on PNR [%s], returned value [%s] ",personIdentifier.CprNumber, returnCode)); //TODO: Remove this log line
+                        //Admin.LogSuccess(String.Format("Placed service platform subscription on UUID [%s], returned value [%s] ",personIdentifier.UUID, returnCode)); //TODO: Remove this log line
                         callContext.Succeed();
                         return true;
                     }
                     else
                     {
-                        throw new Exception(String.Format("Null value returned by service api call AddPNRSubscription, when trying to place subscription for PNR: <{0}>", personIdentifier.CprNumber));
+                        throw new Exception(String.Format("Null value returned by service api call AddPNRSubscription, when trying to place subscription for UUID: <{0}>", personIdentifier.UUID));
                     }

                 }


Added try-catch to handle the Blacklist table not existing

--- PART/Source/CprBroker/ServicePlatform/ServicePlatformDataProvider.Subscription.cs
+++ PART/Source/CprBroker/ServicePlatform/ServicePlatformDataProvider.Subscription.cs
@@ -66,21 +66,29 @@
             // This is a Blacklist feature, where we check if the person is "blacklisted" and should not be subscriped to, when called through CPR Broker
             using (var conn = new SqlConnection(ConfigManager.Current.Settings.CprBrokerConnectionString))
             {
-                // Count the number of Cpr numbers that match the cpr number being processed
-                // - we just need to know if it is in the db, but this is the easiest way
-                var cmd = new SqlCommand("SELECT COUNT(1) FROM [Blacklist] WHERE CprNr = @cpr", conn);
-
-                // Should be safer and more effecient than inserting it in the string above
-                cmd.Parameters.AddWithValue("@cpr", personIdentifier.CprNumber);
-                conn.Open();
-
-                bool exists = 0 < (int)cmd.ExecuteScalar();
-
-                if (exists)
-                {
-                    Admin.LogSuccess("Subscription of person<"+personIdentifier.UUID+"> blocked, because person was Black-Listed ");
-                    return false;
-                }
+                // This Try-Catch block is here since the [Blacklist] table will not always be at a server. When it is not,
+                // the subscription process should just continue.
+                try
+                {
+                    // Count the number of Cpr numbers that match the cpr number being processed
+                    // - we just need to know if it is in the db, but this is the easiest way
+                    var cmd = new SqlCommand("SELECT COUNT(1) FROM [Blacklist] WHERE CprNr = @cpr", conn);
+
+                    // Should be safer and more effecient than inserting it in the string above
+                    cmd.Parameters.AddWithValue("@cpr", personIdentifier.CprNumber);
+                    conn.Open();
+
+                    bool exists = 0 < (int)cmd.ExecuteScalar();
+
+                    if (exists)
+                    {
+                        Admin.LogSuccess("Subscription of person<" + personIdentifier.UUID + "> blocked, because person was Black-Listed ");
+                        return false;
+                    }
+
+                }
+                // If the [blacklist] table does not exist, the person is not blacklisted, so just make the subscription.
+                catch (SqlException) { }
             }

             var service = CreateService<CprSubscriptionService.CprSubscriptionWebServicePortType, CprSubscriptionService.CprSubscriptionWebServicePortTypeClient>(ServiceInfo.CPRSubscription);


[Toolkit.Game] Refactor code in GameWindowPhoneBackgroundXaml for WP8

--- Source/Toolkit/SharpDX.Toolkit.Game/WindowsPhone/GameWindowPhoneBackgroundXaml.cs
+++ Source/Toolkit/SharpDX.Toolkit.Game/WindowsPhone/GameWindowPhoneBackgroundXaml.cs
@@ -1,4 +1,4 @@
-// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel
+// Copyright (c) 2010-2012 SharpDX - Alexandre Mutel
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -17,6 +17,7 @@
 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
+
 #if WP8

 using System;
@@ -24,44 +25,69 @@
 using System.Runtime.InteropServices;
 using System.Windows;
 using System.Windows.Controls;
+
 using SharpDX.Direct3D11;
 using SharpDX.Toolkit.Graphics;

 namespace SharpDX.Toolkit
 {
-    internal class GameWindowPhoneBackgroundXaml : GameWindow, IDrawingSurfaceBackgroundContentProviderNative,
-                                                          IInspectable, ICustomQueryInterface
+    internal class GameWindowPhoneBackgroundXaml : GameWindow,
+                                                   IDrawingSurfaceBackgroundContentProviderNative,
+                                                   IInspectable,
+                                                   ICustomQueryInterface
     {
+        #region Fields
+
+        private readonly RenderTargetLocal[] renderTargets = new RenderTargetLocal[3];
+
+        private readonly IntPtr thisComObjectPtr;
+
         private RenderTarget2D backBuffer;
+
+        private Device currentDevice;
+
+        private DeviceContext currentDeviceContext;
+
+        private RenderTargetView currentRenderTargetView;
+
+        private Exception drawException;
+
+        private DrawingSurfaceBackgroundGrid drawingSurfaceBackgroundGrid;
+
         private GraphicsDevice graphicsDevice;
-        private Device currentDevice;
-        private DeviceContext currentDeviceContext;
-        private RenderTargetView currentRenderTargetView;
+
+        private IGraphicsDeviceManager graphicsDeviceManager;
+
+        private RenderTargetGraphicsPresenter graphicsPresenter;
+
+        private DrawingSurfaceRuntimeHost host;

         private bool isInitialized;

-        private IGraphicsDeviceManager graphicsDeviceManager;
-        private readonly IntPtr thisComObjectPtr;
-
-        private DrawingSurfaceBackgroundGrid drawingSurfaceBackgroundGrid;
-        private DrawingSurfaceRuntimeHost host;
+        private int nextRenderTarget;
+
+        #endregion
+
+        #region Constructors and Destructors

         internal GameWindowPhoneBackgroundXaml()
         {
             thisComObjectPtr = CppObjectShadow.ToIntPtr<IDrawingSurfaceBackgroundContentProviderNative>(this);
         }

-        public override object NativeWindow
-        {
-            get { return drawingSurfaceBackgroundGrid; }
-        }
-
-        public override bool IsMouseVisible { get; set; }
+        #endregion
+
+        #region Public Properties

         public override bool AllowUserResizing
         {
-            get { return false; }
-            set { }
+            get
+            {
+                return false;
+            }
+            set
+            {
+            }
         }

         public override DrawingRectangle ClientBounds
@@ -78,12 +104,28 @@

         public override DisplayOrientation CurrentOrientation
         {
-            get { return DisplayOrientation.Default; }
+            get
+            {
+                return DisplayOrientation.Default;
+            }
         }

         public override bool IsMinimized
         {
-            get { return false; }
+            get
+            {
+                return false;
+            }
+        }
+
+        public override bool IsMouseVisible { get; set; }
+
+        public override object NativeWindow
+        {
+            get
+            {
+                return drawingSurfaceBackgroundGrid;
+            }
         }

         /// <summary>
@@ -94,22 +136,42 @@
         /// </value>
         public override bool Visible
         {
-            get { return true; }
-            set { }
-        }
-
-        #region Implementation of ICallbackable
+            get
+            {
+                return true;
+            }
+            set
+            {
+            }
+        }
+
+        #endregion
+
+        #region Explicit Interface Properties

         IDisposable ICallbackable.Shadow { get; set; }

         #endregion

-        #region Implementation of IDrawingSurfaceBackgroundContentProviderNative
-
-        private readonly RenderTargetLocal[] renderTargets = new RenderTargetLocal[3];
-        private Exception drawException;
-        private RenderTargetGraphicsPresenter graphicsPresenter;
-        private int nextRenderTarget;
+        #region Public Methods and Operators
+
+        public override void BeginScreenDeviceChange(bool willBeFullScreen)
+        {
+        }
+
+        public override void EndScreenDeviceChange(int clientWidth, int clientHeight)
+        {
+        }
+
+        #endregion
+
+        #region Explicit Interface Methods
+
+        CustomQueryInterfaceResult ICustomQueryInterface.GetInterface(ref Guid iid, out IntPtr ppv)
+        {
+            ppv = thisComObjectPtr;
+            return CustomQueryInterfaceResult.Handled;
+        }

         void IDrawingSurfaceBackgroundContentProviderNative.Connect(DrawingSurfaceRuntimeHost host, Device device)
         {
@@ -121,48 +183,17 @@
             // Don't perform any dispose here, as It seems that we are unable to get back to the application after (program access violation)
         }

-        private void DisposeAll()
-        {
-            // Dispose the graphics device
-            Utilities.Dispose(ref graphicsDevice);
-
-            for (int i = 0; i < renderTargets.Length; i++)
-            {
-                renderTargets[i].Dispose();
-            }
-            Utilities.Dispose(ref backBuffer);
-        }
-
-        void IDrawingSurfaceBackgroundContentProviderNative.PrepareResources(DateTime presentTargetTime,
-                                                                             ref DrawingSizeF desiredRenderTargetSize)
-        {
-        }
-
-        internal GraphicsDevice EnsureDevice()
-        {
-            if (graphicsDevice == null)
-            {
-                graphicsDevice = GraphicsDevice.New(currentDevice);
-
-                renderTargets[0].NativePointer = currentRenderTargetView.NativePointer;
-                renderTargets[0].RenderTarget = RenderTarget2D.New(graphicsDevice, currentRenderTargetView, true);
-                backBuffer = renderTargets[0].RenderTarget;
-                nextRenderTarget = (nextRenderTarget + 1) % renderTargets.Length;
-
-                graphicsPresenter = new RenderTargetGraphicsPresenter(graphicsDevice, backBuffer);
-                graphicsDevice.Presenter = graphicsPresenter;
-            }
-
-            return graphicsDevice;
-        }
-
-        void IDrawingSurfaceBackgroundContentProviderNative.Draw(Device device, DeviceContext context,
-                                                                 RenderTargetView renderTargetView)
+        void IDrawingSurfaceBackgroundContentProviderNative.Draw(
+            Device device,
+            DeviceContext context,
+            RenderTargetView renderTargetView)
         {
             try
             {
                 if (!Exiting)
                 {
+                    // Sets the current RenderTargetView
+                    currentRenderTargetView = renderTargetView;

                     // Create the GraphicsDevice here
                     if (!ComObject.EqualsComObject(device, currentDevice) ||
@@ -170,12 +201,13 @@
                     {
                         currentDevice = device;
                         currentDeviceContext = context;
-                        currentRenderTargetView = renderTargetView;
-
+
+                        // Dispose all previously allocated device/backbuffers
                         DisposeAll();

                         if (!isInitialized)
                         {
+                            // The InitCallback will call us back on EnsureDevice method
                             InitCallback();
                             isInitialized = true;
                         }
@@ -189,37 +221,9 @@
                         }
                     }

-                    // Find any previous render target that was already alocated.
-                    bool foundRenderTarget = false;
-                    foreach (RenderTargetLocal renderTargetLocal in renderTargets)
-                    {
-                        if (renderTargetLocal.NativePointer == renderTargetView.NativePointer)
-                        {
-                            backBuffer = renderTargetLocal.RenderTarget;
-                            graphicsPresenter.SetBackBuffer(backBuffer);
-                            foundRenderTarget = true;
-                            break;
-                        }
-                    }
-
-                    if (!foundRenderTarget)
-                    {
-                        // Dispose any previous render target.
-                        renderTargets[nextRenderTarget].Dispose();
-
-                        // Creates the new backBuffer and associated it to the GraphicsPresenter
-                        backBuffer = RenderTarget2D.New(graphicsDevice, renderTargetView, true);
-
-                        renderTargets[nextRenderTarget].NativePointer = renderTargetView.NativePointer;
-                        renderTargets[nextRenderTarget].RenderTarget = backBuffer;
-                        nextRenderTarget = (nextRenderTarget + 1)%renderTargets.Length;
-
-                        graphicsPresenter.SetBackBuffer(backBuffer);
-                    }
-
-                    // TODO: Check that new device/devicecontext/renderTargetView are the same
-                    // else we need to handle DeviceReset/Remove...etc.
-
+                    EnsurePresenter(false);
+
+                    // Call the main Game.Run loop
                     RunCallback();

                     // Aks the host for additional frame
@@ -235,47 +239,87 @@
             }
         }

-        private struct RenderTargetLocal
-        {
-            public IntPtr NativePointer;
-            public RenderTarget2D RenderTarget;
-
-            public void Dispose()
-            {
-                Utilities.Dispose(ref RenderTarget);
-                NativePointer = IntPtr.Zero;
-            }
-        }
-
-        #endregion
-
-        #region Implementation of ICustomQueryInterface
-
-        CustomQueryInterfaceResult ICustomQueryInterface.GetInterface(ref Guid iid, out IntPtr ppv)
-        {
-            ppv = thisComObjectPtr;
-            return CustomQueryInterfaceResult.Handled;
-        }
-
-        #endregion
-
-        public override void BeginScreenDeviceChange(bool willBeFullScreen)
-        {
-        }
-
-        public override void EndScreenDeviceChange(int clientWidth, int clientHeight)
-        {
-        }
+        private int frameCount = 0;
+
+        void IDrawingSurfaceBackgroundContentProviderNative.PrepareResources(
+            DateTime presentTargetTime,
+            ref DrawingSizeF desiredRenderTargetSize)
+        {
+        }
+
+        #endregion
+
+        #region Methods

         internal override bool CanHandle(GameContext gameContext)
         {
             return gameContext.ContextType == GameContextType.WindowsPhoneBackgroundXaml;
         }

+        /// <summary>
+        /// Creates a <see cref="GraphicsDevice"/> if not already created based from latest internal device.
+        /// </summary>
+        /// <returns>a instance of GraphicsDevice.</returns>
+        internal GraphicsDevice EnsureDevice()
+        {
+            if (graphicsDevice == null)
+            {
+                // Creates a GraphicsDevice from the current GraphicsDevice
+                graphicsDevice = GraphicsDevice.New(currentDevice);
+
+                // Reset the presenter
+                EnsurePresenter(true);
+            }
+
+            return graphicsDevice;
+        }
+
+        /// <summary>
+        /// Creates a <see cref="RenderTargetGraphicsPresenter" /> if not already created based from latest internal device.
+        /// </summary>
+        /// <param name="resetPresenter">if set to <c>true</c> [reset presenter].</param>
+        internal void EnsurePresenter(bool resetPresenter)
+        {
+            // Find any previous render target that was already alocated.
+            if (!resetPresenter)
+            {
+                foreach (RenderTargetLocal renderTargetLocal in renderTargets)
+                {
+                    if (renderTargetLocal.NativePointer == currentRenderTargetView.NativePointer)
+                    {
+                        backBuffer = renderTargetLocal.RenderTarget;
+                        graphicsPresenter.SetBackBuffer(backBuffer);
+                        return;
+                    }
+                }
+            }
+
+            // Creates the backbuffer
+            backBuffer = RenderTarget2D.New(graphicsDevice, currentRenderTargetView, true);
+
+            // Dispose any previous render target.
+            renderTargets[nextRenderTarget].Dispose();
+            renderTargets[nextRenderTarget].NativePointer = currentRenderTargetView.NativePointer;
+            renderTargets[nextRenderTarget].RenderTarget = backBuffer;
+            nextRenderTarget = (nextRenderTarget + 1) % renderTargets.Length;
+
+            if (resetPresenter)
+            {
+                graphicsPresenter = new RenderTargetGraphicsPresenter(graphicsDevice, backBuffer);
+                graphicsDevice.Presenter = graphicsPresenter;
+            }
+
+            graphicsPresenter.SetBackBuffer(backBuffer);
+        }
+
         internal override void Initialize(GameContext gameContext)
         {
-            drawingSurfaceBackgroundGrid = (DrawingSurfaceBackgroundGrid) gameContext.Control;
+            drawingSurfaceBackgroundGrid = (DrawingSurfaceBackgroundGrid)gameContext.Control;
             graphicsDeviceManager = (IGraphicsDeviceManager)Services.GetService(typeof(IGraphicsDeviceManager));
+        }
+
+        internal override void Resize(int width, int height)
+        {
         }

         internal override void Run()
@@ -286,23 +330,37 @@
             drawingSurfaceBackgroundGrid.Unloaded += drawingSurfaceBackgroundGrid_Unloaded;
         }

-        internal override void Resize(int width, int height)
-        {
-        }
-
         protected internal override void SetSupportedOrientations(DisplayOrientation orientations)
         {
         }

+        protected override void Dispose(bool disposeManagedResources)
+        {
+            drawingSurfaceBackgroundGrid.SetBackgroundContentProvider(null);
+
+            base.Dispose(disposeManagedResources);
+        }
+
         protected override void SetTitle(string title)
         {
         }

-        protected override void Dispose(bool disposeManagedResources)
-        {
-            drawingSurfaceBackgroundGrid.SetBackgroundContentProvider(null);
-
-            base.Dispose(disposeManagedResources);
+        private void DisposeAll()
+        {
+            // Dispose the graphics device
+            Utilities.Dispose(ref graphicsDevice);
+
+            // Dispose all allocated render targets
+            for (int i = 0; i < renderTargets.Length; i++)
+            {
+                renderTargets[i].Dispose();
+            }
+
+            // Dispose the backbuffer
+            Utilities.Dispose(ref backBuffer);
+
+            // Clears the presenter
+            graphicsPresenter = null;
         }

         private void DrawingSurfaceBackgroundGridOnLoaded(object sender, RoutedEventArgs routedEventArgs)
@@ -318,6 +376,29 @@
             // Set the background to run this instance
             drawingSurfaceBackgroundGrid.SetBackgroundContentProvider(null);
         }
+
+        #endregion
+
+        private struct RenderTargetLocal
+        {
+            #region Fields
+
+            public IntPtr NativePointer;
+
+            public RenderTarget2D RenderTarget;
+
+            #endregion
+
+            #region Public Methods and Operators
+
+            public void Dispose()
+            {
+                Utilities.Dispose(ref RenderTarget);
+                NativePointer = IntPtr.Zero;
+            }
+
+            #endregion
+        }
     }
 }


slight fix in some unit tests

slight fix in some unit tests

--- Test/StaticAnalysis.Tests.Unit/Advanced/StaticError/ReturnAliasAccessFailTests.cs
+++ Test/StaticAnalysis.Tests.Unit/Advanced/StaticError/ReturnAliasAccessFailTests.cs
@@ -68,7 +68,7 @@
  {
   var letter = new Letter(""test"", 0);
   this.Target = this.CreateMachine(typeof(M));
-  Letter otherLetter = null;
+  Letter otherLetter;
   this.Send(this.Target, new eUnit(letter));
   otherLetter = this.Foo(letter);
   otherLetter.Num = 1;
@@ -237,7 +237,7 @@
  {
   var letter = new Letter(""test"", 0);
   this.Target = this.CreateMachine(typeof(M));
-  Letter otherLetter = null;
+  Letter otherLetter;
   this.Send(this.Target, new eUnit(letter));
   otherLetter = this.Foo(letter);
   otherLetter.Num = 1;
@@ -329,7 +329,7 @@
  {
   var letter = new Letter(""test"", 0);
   this.Target = this.CreateMachine(typeof(M));
-  Letter otherLetter = null;
+  Letter otherLetter;
   this.Send(this.Target, new eUnit(letter));
   otherLetter = this.Bar(letter);
   otherLetter.Num = 1;
@@ -427,7 +427,7 @@
  {
   var letter = new Letter(""test"", 0);
   this.Target = this.CreateMachine(typeof(M));
-  Letter otherLetter = null;
+  Letter otherLetter;
   this.Send(this.Target, new eUnit(letter));
   otherLetter = this.Bar(letter);
   otherLetter.Num = 1;


tabify mesh hide inspector file

tabify mesh hide inspector file

--- UMAProject/Assets/UMA/Core/StandardAssets/UMA/Scripts/Editor/MeshHideInspector.cs
+++ UMAProject/Assets/UMA/Core/StandardAssets/UMA/Scripts/Editor/MeshHideInspector.cs
@@ -8,430 +8,430 @@

 namespace UMA.Editors
 {
-    //OnPreviewGUI
-    //http://timaksu.com/post/126337219047/spruce-up-your-custom-unity-inspectors-with-a
-    //
-    [CustomEditor(typeof(MeshHideAsset))]
-    public class MeshHideInspector : Editor
-    {
-        private Mesh _meshPreview;
-        private UMAMeshData _meshData;
-        private PreviewRenderUtility _previewRenderUtility;
-        private Vector2 _drag;
-        private Material _material;
+	//OnPreviewGUI
+	//http://timaksu.com/post/126337219047/spruce-up-your-custom-unity-inspectors-with-a
+	//
+	[CustomEditor(typeof(MeshHideAsset))]
+	public class MeshHideInspector : Editor
+	{
+		private Mesh _meshPreview;
+		private UMAMeshData _meshData;
+		private PreviewRenderUtility _previewRenderUtility;
+		private Vector2 _drag;
+		private Material _material;

 		private int selectedRaceIndex = 0;
 		private DynamicRaceLibrary thisDynamicRaceLibrary;
 		private List<RaceData> foundRaces = new List<RaceData>();
 		private List<string> foundRaceNames = new List<string>();

-        void OnEnable()
-        {
-            MeshHideAsset source = target as MeshHideAsset;
+		void OnEnable()
+		{
+			MeshHideAsset source = target as MeshHideAsset;

 			if (thisDynamicRaceLibrary == null)
 				thisDynamicRaceLibrary = UMAContext.FindInstance().raceLibrary as DynamicRaceLibrary;

 			SetRaceLists();

-            if (source.asset == null)
-                return;
-
-            if( _material == null )
-                _material = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Diffuse.mat");
-
-            if (_meshPreview == null)
-            {
-                UpdateMeshPreview();
-            }
-
-            if (_previewRenderUtility == null)
-            {
-                _previewRenderUtility = new PreviewRenderUtility();
-                ResetPreviewCamera();
-            }
-        }
-
-        public override void OnInspectorGUI()
-        {
-            serializedObject.Update();
-            MeshHideAsset source = target as MeshHideAsset;
-            bool beginSceneEditing = false;
-
-            //DrawDefaultInspector();
-            SlotDataAsset obj = EditorGUILayout.ObjectField("SlotDataAsset", source.asset, typeof(SlotDataAsset), false) as SlotDataAsset;
-            if (obj != null && obj != source.asset)
-            {
-                UpdateSourceAsset(obj);
-            }
-
-            //If we had a slotData added and we set it to none, then lets clear everything.
-            if(obj == null && source.asset != null)
-            {
-                source.asset = null;
-                source.Initialize();
-                AssetDatabase.SaveAssets();
-                EditorUtility.SetDirty(target);
-            }
-
-            if (source.asset == null)
-                EditorGUILayout.HelpBox("No SlotDataAsset set! Begin by adding a SlotDataAsset to the object field above.", MessageType.Error);
-
-
-            //Race Selector here
-            int newRaceIndex = 0;
-            GUILayout.Space(20);
-            newRaceIndex = EditorGUILayout.Popup("Select Base Slot by Race", selectedRaceIndex, foundRaceNames.ToArray() );
-            if(newRaceIndex != selectedRaceIndex)
-            {
-                selectedRaceIndex = newRaceIndex;
-            }
-            if(selectedRaceIndex > 0)
-            {
-                UMAData.UMARecipe baseRecipe = new UMAData.UMARecipe();
-                foundRaces[selectedRaceIndex].baseRaceRecipe.Load(baseRecipe, UMAContext.FindInstance());
-
-                foreach(SlotData sd in baseRecipe.slotDataList)
-                {
-                    if (sd != null && sd.asset != null)
-                    {
-                        if( GUILayout.Button(string.Format("{0} ({1})", sd.asset.name, sd.slotName)))
-                        {
-                            if( UpdateSourceAsset(sd.asset))
-                                selectedRaceIndex = 0;
-                        }
-                    }
-                }
-            }
-
-            GUILayout.Space(20);
-            if (source.TriangleCount > 0)
-            {
-                EditorGUILayout.LabelField("Triangle Indices Count: " + source.TriangleCount);
-                EditorGUILayout.LabelField("Submesh Count: " + source.SubmeshCount);
-                EditorGUILayout.LabelField("Hidden Triangle Count: " + source.HiddenCount);
-            }
-            else
-                EditorGUILayout.LabelField("No triangle array found");
-
-            GUILayout.Space(20);
-            if (!GeometrySelectorWindow.IsOpen)
-            {
-                EditorGUI.BeginDisabledGroup(source.asset == null);
-                if (GUILayout.Button("Begin Editing", GUILayout.MinHeight(50)))
-                {
-                    if (source.asset != null)
-                        beginSceneEditing = true;
-                }
-                EditorGUI.EndDisabledGroup();
-                GUILayout.Space(20);
-                GUILayout.Label("Editing will be done in an empty scene.");
-                GUILayout.Label("You will be prompted to save the scene");
-                GUILayout.Label("if there are any unsaved changes.");
-            }
-            serializedObject.ApplyModifiedProperties();
-
-            if (beginSceneEditing)
-            {
-                // This has to happen outside the inspector
-                EditorApplication.delayCall += CreateSceneEditObject;
-            }
-        }
-
-        private bool UpdateSourceAsset( SlotDataAsset newObj )
-        {
-            MeshHideAsset source = target as MeshHideAsset;
-            bool update = false;
-
-            if (source.asset != null)
-            {
-                if (EditorUtility.DisplayDialog("Warning", "Setting a new source slot will clear the existing data on this asset!", "OK", "Cancel"))
-                    update = true;
-            }
-            else
-            {
-                update = true;
-            }
-
-            if(update)
-            {
-                source.asset = newObj;
-                source.Initialize();
-                UpdateMeshPreview();
-                AssetDatabase.SaveAssets();
-                EditorUtility.SetDirty(target);
-                return true;
-            }
-            return false;
-        }
-
-        private void UpdateMeshPreview()
-        {
-            MeshHideAsset source = target as MeshHideAsset;
-            if (source.asset == null)
-            {
-                _meshPreview = null;
-                return;
-            }
-
-            if( _meshPreview == null )
-                _meshPreview = new Mesh();
-
-            UpdateMeshData( source.triangleFlags);
-
-            _meshPreview.Clear();
-            _meshPreview.vertices = _meshData.vertices;
-            _meshPreview.subMeshCount = _meshData.subMeshCount;
-
-            for(int i = 0; i < _meshData.subMeshCount; i++)
-                _meshPreview.SetTriangles(_meshData.submeshes[i].triangles, i);
-
-            ResetPreviewCamera();
-        }
-
-        public void UpdateMeshData( BitArray[] triangleFlags )
-        {
-            if (triangleFlags == null)
-            {
-                Debug.LogWarning("UpdateMeshData: triangleFlags are null!");
-                return;
-            }
-
-            if (_meshData == null )
-                _meshData = new UMAMeshData();
-
-            MeshHideAsset source = target as MeshHideAsset;
-
-            UMAMeshData sourceData = source.asset.meshData;
-
-            _meshData.submeshes = new SubMeshTriangles[sourceData.subMeshCount];
-            _meshData.subMeshCount = sourceData.subMeshCount;
-
-            bool has_normals = (sourceData.normals != null && sourceData.normals.Length != 0);
-
-            _meshData.vertices = new Vector3[sourceData.vertexCount];
-            sourceData.vertices.CopyTo(_meshData.vertices, 0);
-
-            if(has_normals)
-            {
-                _meshData.normals = new Vector3[sourceData.vertexCount];
-                sourceData.normals.CopyTo(_meshData.normals, 0);
-            }
-
-            for (int i = 0; i < sourceData.subMeshCount; i++)
-            {
-                List<int> newTriangles = new List<int>();
-                for (int j = 0; j < triangleFlags[i].Count; j++)
-                {
-                    if (!triangleFlags[i][j])
-                    {
-                        newTriangles.Add(sourceData.submeshes[i].triangles[(j*3) + 0]);
-                        newTriangles.Add(sourceData.submeshes[i].triangles[(j*3) + 1]);
-                        newTriangles.Add(sourceData.submeshes[i].triangles[(j*3) + 2]);
-                    }
-                }
-                _meshData.submeshes[i] = new SubMeshTriangles();
-                _meshData.submeshes[i].triangles = new int[newTriangles.Count];
-                newTriangles.CopyTo(_meshData.submeshes[i].triangles);
-            }
-        }
-
-        private void CreateSceneEditObject()
-        {
-            MeshHideAsset source = target as MeshHideAsset;
-            if (source.asset == null)
-                return;
-
-            if (GeometrySelectorWindow.IsOpen)
-            {
-                return;
-            }
-
-            if (GeometrySelectorExists())
-            {
-                GameObject.DestroyImmediate(GameObject.Find("GeometrySelector").gameObject);
-            }
-
-            int saveChoice = EditorUtility.DisplayDialogComplex("Open Mesh Hide Editor", "Opening the Mesh Hide Editor will close all scenes and create a new blank scene. Any current scene changes will be lost unless saved.", "Save and Continue", "Continue without saving", "Cancel");
-
-            switch(saveChoice)
-            {
-                case 0: // Save and continue
-                    {
-                        if (!EditorSceneManager.SaveOpenScenes())
-                            return;
-                        break;
-                    }
-                case 1: // don't save and continue
-                    break;
-                case 2: // cancel
-                    return;
-            }
-
-            SceneView sceneView = SceneView.lastActiveSceneView;
-
-            if (sceneView == null)
-            {
-                EditorUtility.DisplayDialog("Error", "A Scene View must be open and active", "OK");
-                return;
-            }
-
-            SceneView.lastActiveSceneView.Focus();
-
-            List<GeometrySelector.SceneInfo> currentscenes = new List<GeometrySelector.SceneInfo>();
-
-            for (int i = 0; i < EditorSceneManager.sceneCount; i++)
-            {
-                Scene sc = EditorSceneManager.GetSceneAt(i);
-                GeometrySelector.SceneInfo si = new GeometrySelector.SceneInfo();
-                si.path = sc.path;
-                si.name = sc.name;
-                if (i == 0)
-                {
-                    // first scene should clear the temp scene.
-                    si.mode = OpenSceneMode.Single;
-                }
-                else
-                {
-                    si.mode = sc.isLoaded ? OpenSceneMode.Additive : OpenSceneMode.AdditiveWithoutLoading;
-                }
-                currentscenes.Add(si);
-            }
-
-            Scene s = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
-            EditorSceneManager.SetActiveScene(s);
-            GameObject obj = EditorUtility.CreateGameObjectWithHideFlags("GeometrySelector", HideFlags.DontSaveInEditor);
-            GeometrySelector geometry = obj.AddComponent<GeometrySelector>();
-
-            if (geometry != null)
-            {
-                Selection.activeGameObject = obj;
-                SceneView.lastActiveSceneView.FrameSelected(true);
-
-                geometry.meshAsset = source;
-                geometry.restoreScenes = currentscenes;
-                geometry.InitializeFromMeshData(source.asset.meshData);
-
-                //temporary, only works on submesh 0
-                geometry.selectedTriangles = new BitArray(source.triangleFlags[0]);
-
-                geometry.UpdateSelectionMesh();
-                SceneView.FrameLastActiveSceneView();
-                SceneView.lastActiveSceneView.FrameSelected();
-            }
-        }
+			if (source.asset == null)
+				return;
+
+			if( _material == null )
+				_material = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Diffuse.mat");
+
+			if (_meshPreview == null)
+			{
+				UpdateMeshPreview();
+			}
+
+			if (_previewRenderUtility == null)
+			{
+				_previewRenderUtility = new PreviewRenderUtility();
+				ResetPreviewCamera();
+			}
+		}
+
+		public override void OnInspectorGUI()
+		{
+			serializedObject.Update();
+			MeshHideAsset source = target as MeshHideAsset;
+			bool beginSceneEditing = false;
+
+			//DrawDefaultInspector();
+			SlotDataAsset obj = EditorGUILayout.ObjectField("SlotDataAsset", source.asset, typeof(SlotDataAsset), false) as SlotDataAsset;
+			if (obj != null && obj != source.asset)
+			{
+				UpdateSourceAsset(obj);
+			}
+
+			//If we had a slotData added and we set it to none, then lets clear everything.
+			if(obj == null && source.asset != null)
+			{
+				source.asset = null;
+				source.Initialize();
+				AssetDatabase.SaveAssets();
+				EditorUtility.SetDirty(target);
+			}
+
+			if (source.asset == null)
+				EditorGUILayout.HelpBox("No SlotDataAsset set! Begin by adding a SlotDataAsset to the object field above.", MessageType.Error);
+
+
+			//Race Selector here
+			int newRaceIndex = 0;
+			GUILayout.Space(20);
+			newRaceIndex = EditorGUILayout.Popup("Select Base Slot by Race", selectedRaceIndex, foundRaceNames.ToArray() );
+			if(newRaceIndex != selectedRaceIndex)
+			{
+				selectedRaceIndex = newRaceIndex;
+			}
+			if(selectedRaceIndex > 0)
+			{
+				UMAData.UMARecipe baseRecipe = new UMAData.UMARecipe();
+				foundRaces[selectedRaceIndex].baseRaceRecipe.Load(baseRecipe, UMAContext.FindInstance());
+
+				foreach(SlotData sd in baseRecipe.slotDataList)
+				{
+					if (sd != null && sd.asset != null)
+					{
+						if( GUILayout.Button(string.Format("{0} ({1})", sd.asset.name, sd.slotName)))
+						{
+							if( UpdateSourceAsset(sd.asset))
+								selectedRaceIndex = 0;
+						}
+					}
+				}
+			}
+
+			GUILayout.Space(20);
+			if (source.TriangleCount > 0)
+			{
+				EditorGUILayout.LabelField("Triangle Indices Count: " + source.TriangleCount);
+				EditorGUILayout.LabelField("Submesh Count: " + source.SubmeshCount);
+				EditorGUILayout.LabelField("Hidden Triangle Count: " + source.HiddenCount);
+			}
+			else
+				EditorGUILayout.LabelField("No triangle array found");
+
+			GUILayout.Space(20);
+			if (!GeometrySelectorWindow.IsOpen)
+			{
+				EditorGUI.BeginDisabledGroup(source.asset == null);
+				if (GUILayout.Button("Begin Editing", GUILayout.MinHeight(50)))
+				{
+					if (source.asset != null)
+						beginSceneEditing = true;
+				}
+				EditorGUI.EndDisabledGroup();
+				GUILayout.Space(20);
+				GUILayout.Label("Editing will be done in an empty scene.");
+				GUILayout.Label("You will be prompted to save the scene");
+				GUILayout.Label("if there are any unsaved changes.");
+			}
+			serializedObject.ApplyModifiedProperties();
+
+			if (beginSceneEditing)
+			{
+				// This has to happen outside the inspector
+				EditorApplication.delayCall += CreateSceneEditObject;
+			}
+		}
+
+		private bool UpdateSourceAsset( SlotDataAsset newObj )
+		{
+			MeshHideAsset source = target as MeshHideAsset;
+			bool update = false;
+
+			if (source.asset != null)
+			{
+				if (EditorUtility.DisplayDialog("Warning", "Setting a new source slot will clear the existing data on this asset!", "OK", "Cancel"))
+					update = true;
+			}
+			else
+			{
+				update = true;
+			}
+
+			if(update)
+			{
+				source.asset = newObj;
+				source.Initialize();
+				UpdateMeshPreview();
+				AssetDatabase.SaveAssets();
+				EditorUtility.SetDirty(target);
+				return true;
+			}
+			return false;
+		}
+
+		private void UpdateMeshPreview()
+		{
+			MeshHideAsset source = target as MeshHideAsset;
+			if (source.asset == null)
+			{
+				_meshPreview = null;
+				return;
+			}
+
+			if( _meshPreview == null )
+				_meshPreview = new Mesh();
+
+			UpdateMeshData( source.triangleFlags);
+
+			_meshPreview.Clear();
+			_meshPreview.vertices = _meshData.vertices;
+			_meshPreview.subMeshCount = _meshData.subMeshCount;
+
+			for(int i = 0; i < _meshData.subMeshCount; i++)
+				_meshPreview.SetTriangles(_meshData.submeshes[i].triangles, i);
+
+			ResetPreviewCamera();
+		}
+
+		public void UpdateMeshData( BitArray[] triangleFlags )
+		{
+			if (triangleFlags == null)
+			{
+				Debug.LogWarning("UpdateMeshData: triangleFlags are null!");
+				return;
+			}
+
+			if (_meshData == null )
+				_meshData = new UMAMeshData();
+
+			MeshHideAsset source = target as MeshHideAsset;
+
+			UMAMeshData sourceData = source.asset.meshData;
+
+			_meshData.submeshes = new SubMeshTriangles[sourceData.subMeshCount];
+			_meshData.subMeshCount = sourceData.subMeshCount;
+
+			bool has_normals = (sourceData.normals != null && sourceData.normals.Length != 0);
+
+			_meshData.vertices = new Vector3[sourceData.vertexCount];
+			sourceData.vertices.CopyTo(_meshData.vertices, 0);
+
+			if(has_normals)
+			{
+				_meshData.normals = new Vector3[sourceData.vertexCount];
+				sourceData.normals.CopyTo(_meshData.normals, 0);
+			}
+
+			for (int i = 0; i < sourceData.subMeshCount; i++)
+			{
+				List<int> newTriangles = new List<int>();
+				for (int j = 0; j < triangleFlags[i].Count; j++)
+				{
+					if (!triangleFlags[i][j])
+					{
+						newTriangles.Add(sourceData.submeshes[i].triangles[(j*3) + 0]);
+						newTriangles.Add(sourceData.submeshes[i].triangles[(j*3) + 1]);
+						newTriangles.Add(sourceData.submeshes[i].triangles[(j*3) + 2]);
+					}
+				}
+				_meshData.submeshes[i] = new SubMeshTriangles();
+				_meshData.submeshes[i].triangles = new int[newTriangles.Count];
+				newTriangles.CopyTo(_meshData.submeshes[i].triangles);
+			}
+		}
+
+		private void CreateSceneEditObject()
+		{
+			MeshHideAsset source = target as MeshHideAsset;
+			if (source.asset == null)
+				return;
+
+			if (GeometrySelectorWindow.IsOpen)
+			{
+				return;
+			}
+
+			if (GeometrySelectorExists())
+			{
+				GameObject.DestroyImmediate(GameObject.Find("GeometrySelector").gameObject);
+			}
+
+			int saveChoice = EditorUtility.DisplayDialogComplex("Open Mesh Hide Editor", "Opening the Mesh Hide Editor will close all scenes and create a new blank scene. Any current scene changes will be lost unless saved.", "Save and Continue", "Continue without saving", "Cancel");
+
+			switch(saveChoice)
+			{
+				case 0: // Save and continue
+					{
+						if (!EditorSceneManager.SaveOpenScenes())
+							return;
+						break;
+					}
+				case 1: // don't save and continue
+					break;
+				case 2: // cancel
+					return;
+			}
+
+			SceneView sceneView = SceneView.lastActiveSceneView;
+
+			if (sceneView == null)
+			{
+				EditorUtility.DisplayDialog("Error", "A Scene View must be open and active", "OK");
+				return;
+			}
+
+			SceneView.lastActiveSceneView.Focus();
+
+			List<GeometrySelector.SceneInfo> currentscenes = new List<GeometrySelector.SceneInfo>();
+
+			for (int i = 0; i < EditorSceneManager.sceneCount; i++)
+			{
+				Scene sc = EditorSceneManager.GetSceneAt(i);
+				GeometrySelector.SceneInfo si = new GeometrySelector.SceneInfo();
+				si.path = sc.path;
+				si.name = sc.name;
+				if (i == 0)
+				{
+					// first scene should clear the temp scene.
+					si.mode = OpenSceneMode.Single;
+				}
+				else
+				{
+					si.mode = sc.isLoaded ? OpenSceneMode.Additive : OpenSceneMode.AdditiveWithoutLoading;
+				}
+				currentscenes.Add(si);
+			}
+
+			Scene s = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
+			EditorSceneManager.SetActiveScene(s);
+			GameObject obj = EditorUtility.CreateGameObjectWithHideFlags("GeometrySelector", HideFlags.DontSaveInEditor);
+			GeometrySelector geometry = obj.AddComponent<GeometrySelector>();
+
+			if (geometry != null)
+			{
+				Selection.activeGameObject = obj;
+				SceneView.lastActiveSceneView.FrameSelected(true);
+
+				geometry.meshAsset = source;
+				geometry.restoreScenes = currentscenes;
+				geometry.InitializeFromMeshData(source.asset.meshData);
+
+				//temporary, only works on submesh 0
+				geometry.selectedTriangles = new BitArray(source.triangleFlags[0]);
+
+				geometry.UpdateSelectionMesh();
+				SceneView.FrameLastActiveSceneView();
+				SceneView.lastActiveSceneView.FrameSelected();
+			}
+		}

-        private bool GeometrySelectorExists()
-        {
-            if (GameObject.Find("GeometrySelector") != null)
-                return true;
-
-            return false;
-        }
-
-        public override bool HasPreviewGUI()
-        {
-            MeshHideAsset source = target as MeshHideAsset;
-            if (source.asset == null)
-                return false;
-
-            return true;
-        }
-
-        public override void OnPreviewGUI(Rect r, GUIStyle background)
-        {
-            if (_meshPreview == null)
-                return;
-
-            if( _material == null )
-                _material = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Diffuse.mat");
-
-            _drag = Drag2D(_drag, r);
-
-            if (_previewRenderUtility == null)
-            {
-                _previewRenderUtility = new PreviewRenderUtility();
-                ResetPreviewCamera();
-            }
-
-            if( Event.current.type == EventType.repaint )
-            {
-                _previewRenderUtility.BeginPreview(r, background);
-                _previewRenderUtility.DrawMesh(_meshPreview, Vector3.zero, Quaternion.identity, _material, 0);
-
-                _previewRenderUtility.m_Camera.transform.position = Vector2.zero;
-                _previewRenderUtility.m_Camera.transform.rotation = Quaternion.Euler(new Vector3(-_drag.y, -_drag.x, 0));
-                _previewRenderUtility.m_Camera.transform.position = _previewRenderUtility.m_Camera.transform.forward * -6f;
-                _previewRenderUtility.m_Camera.transform.position +=  _meshPreview.bounds.center;
-
-                _previewRenderUtility.m_Camera.Render();
-
-                Texture resultRender = _previewRenderUtility.EndPreview();
-
-                GUI.DrawTexture(r, resultRender, ScaleMode.StretchToFill, false);
-            }
-        }
-
-        public void ResetPreviewCamera()
-        {
-            if (_previewRenderUtility == null)
-                return;
-
-            MeshHideAsset source = target as MeshHideAsset;
-
-            _drag = Vector2.zero;
-            if( source.asset.meshData.rootBoneHash == UMAUtils.StringToHash("Global"))
-                _drag.y = -90;
-
-            _previewRenderUtility.m_Camera.transform.position = new Vector3(0, 0, -6);
-            _previewRenderUtility.m_Camera.transform.rotation = Quaternion.identity;
-        }
-
-        public override void OnPreviewSettings()
-        {
-            if (GUILayout.Button("Refresh", EditorStyles.whiteMiniLabel))
-                UpdateMeshPreview();
-        }
-
-        void OnDestroy()
-        {
-            if( _previewRenderUtility != null )
-                _previewRenderUtility.Cleanup();
-        }
-
-        public static Vector2 Drag2D(Vector2 scrollPosition, Rect position)
-        {
-            int controlID = GUIUtility.GetControlID("Slider".GetHashCode(), FocusType.Passive);
-            Event current = Event.current;
-            switch (current.GetTypeForControl(controlID))
-            {
-                case EventType.MouseDown:
-                    if (position.Contains(current.mousePosition) && position.width > 50f)
-                    {
-                        GUIUtility.hotControl = controlID;
-                        current.Use();
-                        EditorGUIUtility.SetWantsMouseJumping(1);
-                    }
-                    break;
-                case EventType.MouseUp:
-                    if (GUIUtility.hotControl == controlID)
-                    {
-                        GUIUtility.hotControl = 0;
-                    }
-                    EditorGUIUtility.SetWantsMouseJumping(0);
-                    break;
-                case EventType.MouseDrag:
-                    if (GUIUtility.hotControl == controlID)
-                    {
-                        scrollPosition -= current.delta * (float)((!current.shift) ? 1 : 3) / Mathf.Min(position.width, position.height) * 140f;
-                        scrollPosition.y = Mathf.Clamp(scrollPosition.y, -90f, 90f);
-                        current.Use();
-                        GUI.changed = true;
-                    }
-                    break;
-            }
-            return scrollPosition;
+		private bool GeometrySelectorExists()
+		{
+			if (GameObject.Find("GeometrySelector") != null)
+				return true;
+
+			return false;
+		}
+
+		public override bool HasPreviewGUI()
+		{
+			MeshHideAsset source = target as MeshHideAsset;
+			if (source.asset == null)
+				return false;
+
+			return true;
+		}
+
+		public override void OnPreviewGUI(Rect r, GUIStyle background)
+		{
+			if (_meshPreview == null)
+				return;
+
+			if( _material == null )
+				_material = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Diffuse.mat");
+
+			_drag = Drag2D(_drag, r);
+
+			if (_previewRenderUtility == null)
+			{
+				_previewRenderUtility = new PreviewRenderUtility();
+				ResetPreviewCamera();
+			}
+
+			if( Event.current.type == EventType.repaint )
+			{
+				_previewRenderUtility.BeginPreview(r, background);
+				_previewRenderUtility.DrawMesh(_meshPreview, Vector3.zero, Quaternion.identity, _material, 0);
+
+				_previewRenderUtility.m_Camera.transform.position = Vector2.zero;
+				_previewRenderUtility.m_Camera.transform.rotation = Quaternion.Euler(new Vector3(-_drag.y, -_drag.x, 0));
+				_previewRenderUtility.m_Camera.transform.position = _previewRenderUtility.m_Camera.transform.forward * -6f;
+				_previewRenderUtility.m_Camera.transform.position +=  _meshPreview.bounds.center;
+
+				_previewRenderUtility.m_Camera.Render();
+
+				Texture resultRender = _previewRenderUtility.EndPreview();
+
+				GUI.DrawTexture(r, resultRender, ScaleMode.StretchToFill, false);
+			}
+		}
+
+		public void ResetPreviewCamera()
+		{
+			if (_previewRenderUtility == null)
+				return;
+
+			MeshHideAsset source = target as MeshHideAsset;
+
+			_drag = Vector2.zero;
+			if( source.asset.meshData.rootBoneHash == UMAUtils.StringToHash("Global"))
+				_drag.y = -90;
+
+			_previewRenderUtility.m_Camera.transform.position = new Vector3(0, 0, -6);
+			_previewRenderUtility.m_Camera.transform.rotation = Quaternion.identity;
+		}
+
+		public override void OnPreviewSettings()
+		{
+			if (GUILayout.Button("Refresh", EditorStyles.whiteMiniLabel))
+				UpdateMeshPreview();
+		}
+
+		void OnDestroy()
+		{
+			if( _previewRenderUtility != null )
+				_previewRenderUtility.Cleanup();
+		}
+
+		public static Vector2 Drag2D(Vector2 scrollPosition, Rect position)
+		{
+			int controlID = GUIUtility.GetControlID("Slider".GetHashCode(), FocusType.Passive);
+			Event current = Event.current;
+			switch (current.GetTypeForControl(controlID))
+			{
+				case EventType.MouseDown:
+					if (position.Contains(current.mousePosition) && position.width > 50f)
+					{
+						GUIUtility.hotControl = controlID;
+						current.Use();
+						EditorGUIUtility.SetWantsMouseJumping(1);
+					}
+					break;
+				case EventType.MouseUp:
+					if (GUIUtility.hotControl == controlID)
+					{
+						GUIUtility.hotControl = 0;
+					}
+					EditorGUIUtility.SetWantsMouseJumping(0);
+					break;
+				case EventType.MouseDrag:
+					if (GUIUtility.hotControl == controlID)
+					{
+						scrollPosition -= current.delta * (float)((!current.shift) ? 1 : 3) / Mathf.Min(position.width, position.height) * 140f;
+						scrollPosition.y = Mathf.Clamp(scrollPosition.y, -90f, 90f);
+						current.Use();
+						GUI.changed = true;
+					}
+					break;
+			}
+			return scrollPosition;
 		}

 		public void SetRaceLists()


Fixes to WindowsAzurePowwerShellTest

Fixes to WindowsAzurePowwerShellTest

--- WindowsAzurePowershell/src/Management.Test/Tests/Utilities/PowerShellAzureTest.cs
+++ WindowsAzurePowershell/src/Management.Test/Tests/Utilities/PowerShellAzureTest.cs
@@ -34,9 +34,9 @@
         }

         [TestInitialize]
-        public override void SetupTest()
+        public override void TestSetup()
         {
-            base.SetupTest();
+            base.TestSetup();
             this.credentials.SetupPowerShellEnvironment(powershell, this.credentialFile);
         }
     }


Improve test stability.

Improve test stability.

--- cli/test/MsgPack.UnitTest/MessagePackConvertTest.cs
+++ cli/test/MsgPack.UnitTest/MessagePackConvertTest.cs
@@ -266,9 +266,10 @@
 		public void TestFromDateTime_Now_AsUtcUnixEpoc()
 		{
 			// LocalTime will be converted to UtcTime
-			Assert.AreEqual(
-				checked( ( long )DateTime.UtcNow.Subtract( _utcEpoc ).TotalMilliseconds ),
-				MessagePackConvert.FromDateTime( DateTime.Now )
+			var now = DateTime.Now;
+			Assert.AreEqual(
+				checked( ( long )now.ToUniversalTime().Subtract( _utcEpoc ).TotalMilliseconds ),
+				MessagePackConvert.FromDateTime( now )
 			);
 		}


Remove unused using statement

Remove unused using statement

--- osu.Game/Graphics/Containers/IExpandingContainer.cs
+++ osu.Game/Graphics/Containers/IExpandingContainer.cs
@@ -3,7 +3,6 @@

 using osu.Framework.Allocation;
 using osu.Framework.Graphics.Containers;
-using osu.Game.Overlays;

 namespace osu.Game.Graphics.Containers
 {


Use `PausableSkinnableSound` instead

Use `PausableSkinnableSound` instead

--- osu.Game/Rulesets/UI/GameplaySampleTriggerSource.cs
+++ osu.Game/Rulesets/UI/GameplaySampleTriggerSource.cs
@@ -32,7 +32,7 @@
             InternalChild = hitSounds = new Container<SkinnableSound>
             {
                 Name = "concurrent sample pool",
-                ChildrenEnumerable = Enumerable.Range(0, max_concurrent_hitsounds).Select(_ => new SkinnableSound())
+                ChildrenEnumerable = Enumerable.Range(0, max_concurrent_hitsounds).Select(_ => new PausableSkinnableSound())
             };
         }


[変更]Map>IDynamicMapObjectとは別にISelfUpdatableを使うように

--- CoreCode/Map.cs
+++ CoreCode/Map.cs
@@ -42,6 +42,7 @@
         public event EventHandler<MapObjectEventArgs> MapObjectAdded;

         private ICollection<IMapObject> mapObjectCollection;
+        private ICollection<ISelfUpdatable> selfUpdatableMapObjectCollection;
         private ICollection<IDynamicMapObject> dynamicMapObjectCollection;
         private IDictionary<string, IMapObject> namedMapObject;

@@ -73,6 +74,7 @@
             FrameCount = 0;

             mapObjectCollection = new List<IMapObject>();
+            selfUpdatableMapObjectCollection = new List<ISelfUpdatable>();
             dynamicMapObjectCollection = new List<IDynamicMapObject>();
             namedMapObject = new Dictionary<string, IMapObject>();
             areaEnvironmentCollection = new List<AreaEnvironment>();
@@ -86,6 +88,7 @@
         public void AddMapObject(IMapObject mapObject)
         {
             mapObjectCollection.Add(mapObject);
+            if (mapObject is ISelfUpdatable selfUpdatableMapObject) selfUpdatableMapObjectCollection.Add(selfUpdatableMapObject);
             if (mapObject is IDynamicMapObject dynamicMapObject) dynamicMapObjectCollection.Add(dynamicMapObject);
             if (!string.IsNullOrEmpty(mapObject.Name)) namedMapObject[mapObject.Name] = mapObject;

@@ -120,7 +123,7 @@
         private void UpdateMapObjects()
         {
             var args = new UpdateMapObjectArgs(this);
-            foreach (var mapObject in dynamicMapObjectCollection)
+            foreach (var mapObject in selfUpdatableMapObjectCollection)
             {
                 mapObject.UpdateSelf(args);
             }


prevent from bootstrapping twice

prevent from bootstrapping twice

--- Debugger/Mod.cs
+++ Debugger/Mod.cs
@@ -15,6 +15,7 @@

         private static GameObject modToolsGameObject;
         private static ModTools modTools;
+        private static bool bootstrapped;

         public static bool IsModToolsActive()
         {
@@ -41,7 +42,10 @@

         public static void Bootstrap()
         {
-
+            if (bootstrapped)
+            {
+                return;
+            }
             try
             {
                 CODebugBase<LogChannel>.verbose = true;
@@ -56,6 +60,7 @@
                     new[] { typeof(SimulationManager.UpdateMode) });

                 RedirectionHelper.RedirectCalls(target, replacement);
+                bootstrapped = true;
             }
             catch (Exception ex)
             {


Improved logout.

Improved logout.

--- backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs
+++ backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs
@@ -13,6 +13,9 @@
 using System.Security.Claims;
 using System.Text;
 using System.Threading.Tasks;
+using IdentityModel;
+using IdentityServer4;
+using IdentityServer4.Extensions;
 using IdentityServer4.Models;
 using IdentityServer4.Services;
 using Microsoft.AspNetCore.Identity;
@@ -145,9 +148,24 @@
         [Route("account/logout/")]
         public async Task<IActionResult> Logout(string logoutId)
         {
+            await signInManager.SignOutAsync();
+
+            if (User?.Identity.IsAuthenticated == true)
+            {
+                var provider = User.FindFirst(JwtClaimTypes.IdentityProvider)?.Value;
+
+                if (provider != null && provider != IdentityServerConstants.LocalIdentityProvider)
+                {
+                    var providerSupportsSignout = await HttpContext.GetSchemeSupportsSignOutAsync(provider);
+
+                    if (providerSupportsSignout)
+                    {
+                        return SignOut(provider);
+                    }
+                }
+            }
+
             var context = await interactions.GetLogoutContextAsync(logoutId);
-
-            await signInManager.SignOutAsync();

             return RedirectToLogoutUrl(context);
         }


Added some documentation

Added some documentation

--- Server/Forms/FrmRemoteDesktop.cs
+++ Server/Forms/FrmRemoteDesktop.cs
@@ -46,14 +46,17 @@
                 new Core.Packets.ServerPackets.GetMonitors().Execute(_connectClient);
         }

+        /// <summary>
+        /// Subscribes the local mouse and keyboard hooks.
+        /// </summary>
         private void SubscribeEvents()
         {
-            if (PlatformHelper.RunningOnMono)
+            if (PlatformHelper.RunningOnMono) // Mono/Linux
             {
                 this.KeyDown += OnKeyDown;
                 this.KeyUp += OnKeyUp;
             }
-            else
+            else // Windows
             {
                 _keyboardHook = Hook.GlobalEvents();
                 _keyboardHook.KeyDown += OnKeyDown;
@@ -64,21 +67,29 @@
             }
         }

+        /// <summary>
+        /// Unsubscribes the local mouse and keyboard hooks.
+        /// </summary>
         private void UnsubscribeEvents()
         {
-            if (PlatformHelper.RunningOnMono)
+            if (PlatformHelper.RunningOnMono) // Mono/Linux
             {
                 this.KeyDown -= OnKeyDown;
                 this.KeyUp -= OnKeyUp;
             }
-            else if (_keyboardHook != null && _mouseHook != null)
-            {
-                _keyboardHook.KeyDown -= OnKeyDown;
-                _keyboardHook.KeyUp -= OnKeyUp;
-                _mouseHook.MouseWheel -= OnMouseWheelMove;
-
-                _mouseHook.Dispose();
-                _keyboardHook.Dispose();
+            else // Windows
+            {
+                if (_keyboardHook != null)
+                {
+                    _keyboardHook.KeyDown -= OnKeyDown;
+                    _keyboardHook.KeyUp -= OnKeyUp;
+                    _keyboardHook.Dispose();
+                }
+                if (_mouseHook != null)
+                {
+                    _mouseHook.MouseWheel -= OnMouseWheelMove;
+                    _mouseHook.Dispose();
+                }
             }
         }


Add ApplicationName property to public interface

--- SimpleCache.Core/IObjectCache.cs
+++ SimpleCache.Core/IObjectCache.cs
@@ -10,6 +10,7 @@
     /// </summary>
     public interface IObjectCache : IDisposable
     {
+		string ApplicationName { get; set; }
         /// <summary>
         /// Retrieve an object of type T from the key-value cache.
         /// </summary>
@@ -21,7 +22,7 @@
         /// Retrieve all objects of type T from the key-value cache.
         /// </summary>
         /// <returns>Objects of type T stored in the cache.</returns>
-	Task<IEnumerable<T>> GetAll<T>();
+		Task<IEnumerable<T>> GetAll<T>();

         /// <summary>
         /// Insert an object into the cache, with the specified key and expiration


Prevented shadow copy deletion when file is in memory

--- SkyEditor.Core/IO/GenericFile.cs
+++ SkyEditor.Core/IO/GenericFile.cs
@@ -1450,7 +1450,7 @@
                     }

                     // Delete the temporary file if shadow copy is enabled, the current I/O provider is not null, the physical filename exists, and the physical filename is different than the logical one
-                    if (EnableShadowCopy && CurrentIOProvider != null && !string.IsNullOrEmpty(PhysicalFilename) && CurrentIOProvider.FileExists(PhysicalFilename) && Filename != PhysicalFilename)
+                    if (EnableShadowCopy && InMemoryFile == null && CurrentIOProvider != null && !string.IsNullOrEmpty(PhysicalFilename) && CurrentIOProvider.FileExists(PhysicalFilename) && Filename != PhysicalFilename)
                     {
                         CurrentIOProvider.DeleteFile(PhysicalFilename);
                     }


add NodeVector getters

add NodeVector getters

--- Source/Btree/Btree.NodeVector.cs
+++ Source/Btree/Btree.NodeVector.cs
@@ -151,15 +151,19 @@
             public bool IsFound
             { get; private set; }

-            internal Node TopNode => nodeStack[indexStack.Count - 1];
-
-            internal int TopIndex => indexStack[indexStack.Count - 1];
+            internal Node TopNode => nodeStack[indexStack.Count-1];
+
+            internal int TopIndex => indexStack[indexStack.Count-1];

             public int Height => indexStack.Count;

             #endregion

             #region Methods
+
+            internal Node GetNode (int index) { return nodeStack[index]; }
+
+            internal int GetIndex (int index) { return indexStack[index]; }

             public void TiltLeft (int delta)
             {


Fix parentheses in WordBreaker

Fix parentheses in WordBreaker

--- Source/TextParser/WordBreaker.cs
+++ Source/TextParser/WordBreaker.cs
@@ -56,46 +56,46 @@
             else if (IsAlphabeticOrHebrewLetter(fCurrentWordBreak) && IsAlphabeticOrHebrewLetter(fNextWordBreak))
                 result = false;
             // WB6. (without single quotes)
-            else if (IsAlphabeticOrHebrewLetter(fCurrentWordBreak) && (fNextWordBreak == WordBreak.MidLetter ||
-                fNextWordBreak == WordBreak.MidNumberAndLetter)
+            else if (IsAlphabeticOrHebrewLetter(fCurrentWordBreak) && ((fNextWordBreak == WordBreak.MidLetter) ||
+                (fNextWordBreak == WordBreak.MidNumberAndLetter))
                 && IsAlphabeticOrHebrewLetter(fNextOfNextWordBreak))
                 result = false;
             // WB7. (without single quotes)
-            else if (IsAlphabeticOrHebrewLetter(fPreviousWordBreak) && (fCurrentWordBreak == WordBreak.MidLetter
-                || fCurrentWordBreak == WordBreak.MidNumberAndLetter)
+            else if (IsAlphabeticOrHebrewLetter(fPreviousWordBreak) && ((fCurrentWordBreak == WordBreak.MidLetter)
+                || (fCurrentWordBreak == WordBreak.MidNumberAndLetter))
                 && IsAlphabeticOrHebrewLetter(fNextWordBreak))
                 result = false;
             // WB7a.
-            else if (fCurrentWordBreak == WordBreak.HebrewLetter && fNextWordBreak == WordBreak.SingleQuote)
+            else if ((fCurrentWordBreak == WordBreak.HebrewLetter) && (fNextWordBreak == WordBreak.SingleQuote))
                 result = false;
             // WB7b.
-            else if (fCurrentWordBreak == WordBreak.HebrewLetter && fNextWordBreak == WordBreak.DoubleQuote
-                && fNextOfNextWordBreak == WordBreak.HebrewLetter)
+            else if ((fCurrentWordBreak == WordBreak.HebrewLetter) && (fNextWordBreak == WordBreak.DoubleQuote)
+                && (fNextOfNextWordBreak == WordBreak.HebrewLetter))
                 result = false;
             // WB7c.
-            else if (fPreviousWordBreak == WordBreak.HebrewLetter && fCurrentWordBreak == WordBreak.DoubleQuote
-                && fNextWordBreak == WordBreak.HebrewLetter)
+            else if ((fPreviousWordBreak == WordBreak.HebrewLetter) && (fCurrentWordBreak == WordBreak.DoubleQuote)
+                && (fNextWordBreak == WordBreak.HebrewLetter))
                 result = false;
             // WB8.
-            else if (fCurrentWordBreak == WordBreak.Numeric && (fNextWordBreak == WordBreak.Numeric))
+            else if ((fCurrentWordBreak == WordBreak.Numeric) && (fNextWordBreak == WordBreak.Numeric))
                 result = false;
             // WB9.
             else if (IsAlphabeticOrHebrewLetter(fCurrentWordBreak) && fNextWordBreak == WordBreak.Numeric)
                 result = false;
             // WB10.
-            else if (fCurrentWordBreak == WordBreak.Numeric && IsAlphabeticOrHebrewLetter(fNextWordBreak))
+            else if ((fCurrentWordBreak == WordBreak.Numeric) && IsAlphabeticOrHebrewLetter(fNextWordBreak))
                 result = false;
             // WB13.
-            else if (fCurrentWordBreak == WordBreak.Katakana && fNextWordBreak == WordBreak.Katakana)
+            else if ((fCurrentWordBreak == WordBreak.Katakana) && (fNextWordBreak == WordBreak.Katakana))
                 result = false;
             // WB13a.
-            else if ((IsAlphabeticOrHebrewLetter(fCurrentWordBreak) || fCurrentWordBreak == WordBreak.Numeric
-                || fCurrentWordBreak == WordBreak.Katakana || fCurrentWordBreak == WordBreak.ExtenderForNumbersAndLetters)
-                && fNextWordBreak == WordBreak.ExtenderForNumbersAndLetters)
+            else if ((IsAlphabeticOrHebrewLetter(fCurrentWordBreak) || (fCurrentWordBreak == WordBreak.Numeric)
+                || (fCurrentWordBreak == WordBreak.Katakana) || (fCurrentWordBreak == WordBreak.ExtenderForNumbersAndLetters))
+                && (fNextWordBreak == WordBreak.ExtenderForNumbersAndLetters))
                 result = false;
             // WB13b.
             else if ((fCurrentWordBreak == WordBreak.ExtenderForNumbersAndLetters) && (IsAlphabeticOrHebrewLetter(fNextWordBreak)
-                || fNextWordBreak == WordBreak.Numeric || fNextWordBreak == WordBreak.Katakana))
+                || (fNextWordBreak == WordBreak.Numeric) || (fNextWordBreak == WordBreak.Katakana)))
                 result = false;
             // custom: do not break between whitespaces
             else if ((fCurrentWordBreak == WordBreak.Whitespace) && (fNextWordBreak == WordBreak.Whitespace))


make TccWindow.HideWindow() thread safe

make TccWindow.HideWindow() thread safe

--- TCC.Core/UI/Windows/TccWindow.cs
+++ TCC.Core/UI/Windows/TccWindow.cs
@@ -14,7 +14,7 @@
     public class TccWindow : Window
     {

-        private static List<TccWindow> _createdWindows = new List<TccWindow>();
+        private static readonly List<TccWindow> _createdWindows = new List<TccWindow>();

         public event Action Hidden;
         public event Action Showed;
@@ -26,7 +26,7 @@
         public IntPtr Handle { get; private set; }

-        public TccWindow(bool canClose)
+        protected TccWindow(bool canClose)
         {
             _createdWindows.Add(this);
             _canClose = canClose;
@@ -42,8 +42,12 @@
         }

         public virtual void HideWindow()
+
         {
-            BeginAnimation(OpacityProperty, _hideAnim);
+            Dispatcher?.InvokeAsync(() =>
+            {
+                BeginAnimation(OpacityProperty, _hideAnim);
+            });
         }
         public virtual void ShowWindow()
         {


benchmark: write to file

benchmark: write to file

--- TomP2P/TomP2P.Benchmark/Inbox.cs
+++ TomP2P/TomP2P.Benchmark/Inbox.cs
@@ -3,7 +3,6 @@
 using System.Globalization;
 using System.IO;
 using System.Threading.Tasks;
-using NLog.Targets;

 namespace TomP2P.Benchmark
 {
@@ -48,7 +47,7 @@
             for (int i = 0; i < repetitions; i++)
             {
                 Console.WriteLine("Executing repetition {0} / {1}:", i+1, repetitions);
-                double repetitionResult = 0;
+                double repetitionResult;
                 switch (argument)
                 {
                     case "bb1":


[versions] Switched Play Services check to maven

--- Util/VersionChecker/versions.csx
+++ Util/VersionChecker/versions.csx
@@ -73,7 +73,7 @@
     new CocoaPods ("Facebook iOS CoreKit", "4.24.0", "FBSDKCoreKit", OWNER_MX1),

     // Google - Android
-    new XPath ("Google Play Services", "58", "https://dl.google.com/android/repository/addon2-1.xml", "//*[local-name() = 'remotePackage' and @path='extras;google;m2repository']/*[local-name() = 'revision']", OWNER_CA1),
+    new XPath ("Google Play Services", "11.6.0", "https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services/maven-metadata.xml", "/metadata/versioning/release", OWNER_CA1),
     new XPath ("Android Support Libraries", "27.0.2", "https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/maven-metadata.xml", "/metadata/versioning/release", OWNER_CA1),
     new XPath ("Google Glass SDK", "11", "https://dl.google.com/android/repository/glass/addon2-1.xml", "//*[local-name() = 'remotePackage' and @path='add-ons;addon-google_gdk-google-19']/*[local-name() = 'revision']", OWNER_CA1),


Use range op

Use range op

--- WalletWasabi.Packager/Program.cs
+++ WalletWasabi.Packager/Program.cs
@@ -474,7 +474,7 @@
 					var driveLetterUpper = BinDistDirectory[0];
 					var driveLetterLower = char.ToLower(driveLetterUpper);

-					var linuxPath = $"/mnt/{driveLetterLower}/{Tools.LinuxPath(BinDistDirectory.Substring(3))}";
+					var linuxPath = $"/mnt/{driveLetterLower}/{Tools.LinuxPath(BinDistDirectory[3..])}";

 					var commands = new[]
 					{


Fixed evals for forced wins

Fixed evals for forced wins

--- Chase.Engine/Search.cs
+++ Chase.Engine/Search.cs
@@ -267,12 +267,12 @@
             int eval = EvaluatePosition(position, depthUp);

             // See if someone won
-            if (Math.Abs(eval) == Constants.VictoryScore)
+            if (Math.Abs(eval) > Constants.VictoryScore - 100)
             {
                 return new SearchResult()
                 {
                     Score = eval,
-                    PrimaryVariation = eval == Constants.VictoryScore ? "BLUE-WINS" : "RED-WINS"
+                    PrimaryVariation = eval > 0 ? "BLUE-WINS" : "RED-WINS"
                 };
             }


Massively improve surface mode positioning.

--- Client/VesselWorker.cs
+++ Client/VesselWorker.cs
@@ -13,11 +13,6 @@
         private static VesselWorker singleton;
         //Update frequency
         private const float VESSEL_PROTOVESSEL_UPDATE_INTERVAL = 30f;
-        //Pack distances
-        private const float PLAYER_UNPACK_THRESHOLD = 9000;
-        private const float PLAYER_PACK_THRESHOLD = 10000;
-        private const float NORMAL_UNPACK_THRESHOLD = 300;
-        private const float NORMAL_PACK_THRESHOLD = 600;
         private const float SAFETY_BUBBLE_DISTANCE = 100;
         //Spectate stuff
         public const ControlTypes BLOCK_ALL_CONTROLS = ControlTypes.ALL_SHIP_CONTROLS | ControlTypes.ACTIONS_ALL | ControlTypes.EVA_INPUT | ControlTypes.TIMEWARP | ControlTypes.MISC | ControlTypes.GROUPS_ALL | ControlTypes.CUSTOM_ACTION_GROUPS;
@@ -511,31 +506,6 @@
             }
         }

-        private void UpdatePackDistance(string vesselID)
-        {
-            foreach (Vessel v in FlightGlobals.fetch.vessels)
-            {
-                if (v.id.ToString() == vesselID)
-                {
-                    //Bump other players active vessels
-                    if (LockSystem.fetch.LockExists("control-" + vesselID) && !LockSystem.fetch.LockIsOurs("control-" + vesselID))
-                    {
-                        v.distanceLandedUnpackThreshold = PLAYER_UNPACK_THRESHOLD;
-                        v.distanceLandedPackThreshold = PLAYER_PACK_THRESHOLD;
-                        v.distanceUnpackThreshold = PLAYER_UNPACK_THRESHOLD;
-                        v.distancePackThreshold = PLAYER_PACK_THRESHOLD;
-                    }
-                    else
-                    {
-                        v.distanceLandedUnpackThreshold = NORMAL_UNPACK_THRESHOLD;
-                        v.distanceLandedPackThreshold = NORMAL_PACK_THRESHOLD;
-                        v.distanceUnpackThreshold = NORMAL_UNPACK_THRESHOLD;
-                        v.distancePackThreshold = NORMAL_PACK_THRESHOLD;
-                    }
-                }
-            }
-        }
-
         private void CheckVesselHasChanged()
         {
             if (HighLogic.LoadedScene == GameScenes.FLIGHT && FlightGlobals.fetch.activeVessel != null)
@@ -781,10 +751,9 @@
             //Send updates for unpacked vessels that aren't being flown by other players
             bool notRecentlySentProtoUpdate = serverVesselsProtoUpdate.ContainsKey(checkVessel.id.ToString()) ? ((UnityEngine.Time.realtimeSinceStartup - serverVesselsProtoUpdate[checkVessel.id.ToString()]) > VESSEL_PROTOVESSEL_UPDATE_INTERVAL) : true;
             bool notRecentlySentPositionUpdate = serverVesselsPositionUpdate.ContainsKey(checkVessel.id.ToString()) ? ((UnityEngine.Time.realtimeSinceStartup - serverVesselsPositionUpdate[checkVessel.id.ToString()]) > (1f / (float)DynamicTickWorker.fetch.sendTickRate)) : true;
-            bool isServerEVAKerbal = checkVessel.vesselType == VesselType.EVA && serverVessels.Contains(checkVessel.id.ToString());

             //Check that is hasn't been recently sent
-            if (notRecentlySentProtoUpdate && (checkVessel.situation != Vessel.Situations.FLYING) && !isServerEVAKerbal)
+            if (notRecentlySentProtoUpdate && (checkVessel.situation != Vessel.Situations.FLYING))
             {

                 ProtoVessel checkProto = new ProtoVessel(checkVessel);
@@ -1200,6 +1169,13 @@

                 if (currentProto != null)
                 {
+                    //Skip already loaded EVA's
+                    if ((currentProto.vesselType == VesselType.EVA) && (FlightGlobals.fetch.vessels.Find(v => v.id == currentProto.vesselID) != null))
+                    {
+                        return;
+                    }
+
+                    //Register asteroids from other players
                     if (currentProto.vesselType == VesselType.SpaceObject)
                     {
                         if (currentProto.protoPartSnapshots != null)
@@ -1215,12 +1191,14 @@
                         }
                     }

+                    //Skip vessels that try to load in the safety bubble
                     if (isProtoVesselInSafetyBubble(currentProto))
                     {
                         DarkLog.Debug("Removing protovessel " + currentProto.vesselID.ToString() + ", name: " + currentProto.vesselName + " from server - In safety bubble!");
-                        NetworkWorker.fetch.SendVesselRemove(currentProto.vesselID.ToString(), false);
+                        //NetworkWorker.fetch.SendVesselRemove(currentProto.vesselID.ToString(), false);
                         return;
                     }
+
                     RegisterServerVessel(currentProto.vesselID.ToString());
                     DarkLog.Debug("Loading " + currentProto.vesselID + ", name: " + currentProto.vesselName + ", type: " + currentProto.vesselType);

@@ -1262,6 +1240,14 @@
                         Vessel oldVessel = FlightGlobals.fetch.vessels[vesselID];
                         if (oldVessel.id.ToString() == currentProto.vesselID.ToString())
                         {
+                            //Don't replace the vessel if it's unpacked, not landed, close to the ground, and has the same amount of parts.
+                            double hft = oldVessel.GetHeightFromTerrain();
+                            double hfs = oldVessel.GetHeightFromSurface();
+                            DarkLog.Debug("Replacement may be incorrectly killed (HFS: " + hfs + ", HFT: " + hft);
+                            if (!oldVessel.packed && !oldVessel.Landed && (hft < 1000) && (currentProto.protoPartSnapshots.Count == oldVessel.parts.Count))
+                            {
+                                return;
+                            }
                             //Don't kill the active vessel - Kill it after we switch.
                             //Killing the active vessel causes all sorts of crazy problems.
                             if (wasActive)
@@ -1280,7 +1266,6 @@

                     if (currentProto.vesselRef != null)
                     {
-                        UpdatePackDistance(currentProto.vesselRef.id.ToString());
                         if (wasActive)
                         {
                             DarkLog.Debug("ProtoVessel update for active vessel!");
@@ -1672,8 +1657,8 @@
             }
             //Get updating player
             string updatePlayer = LockSystem.fetch.LockExists(update.vesselID) ? LockSystem.fetch.LockOwner(update.vesselID) : "Unknown";
-            //Ignore updates to our own vessel
-            if (!isSpectating && (FlightGlobals.fetch.activeVessel != null ? FlightGlobals.fetch.activeVessel.id.ToString() == update.vesselID : false))
+            //Ignore updates to our own vessel if we are in flight and we aren't spectating
+            if (!isSpectating && (FlightGlobals.fetch.activeVessel != null ? FlightGlobals.fetch.activeVessel.id.ToString() == update.vesselID : false) && HighLogic.LoadedScene == GameScenes.FLIGHT)
             {
                 DarkLog.Debug("ApplyVesselUpdate - Ignoring update for active vessel from " + updatePlayer);
                 return;
@@ -1692,16 +1677,42 @@
             }
             if (update.isSurfaceUpdate)
             {
+                //Get the new position/velocity
+                Vector3d updatePostion = updateBody.GetWorldSurfacePosition(update.position[0], update.position[1], update.position[2]);
+                Vector3d updateVelocity = new Vector3d(update.velocity[0], update.velocity[1], update.velocity[2]);
+                //Figure out how far away we are if we can
                 double updateDistance = Double.PositiveInfinity;
                 if ((HighLogic.LoadedScene == GameScenes.FLIGHT) && (FlightGlobals.fetch.activeVessel != null))
                 {
-                    updateDistance = Vector3.Distance(FlightGlobals.fetch.activeVessel.GetWorldPos3D(), updateVessel.GetWorldPos3D());
-                }
-                bool isUnpacking = (updateDistance < updateVessel.distanceUnpackThreshold) && updateVessel.packed;
-                if (!updateVessel.packed && !isUnpacking)
-                {
-                    Vector3d updatePostion = updateBody.GetWorldSurfacePosition(update.position[0], update.position[1], update.position[2]);
-                    Vector3d updateVelocity = new Vector3d(update.velocity[0], update.velocity[1], update.velocity[2]);
+                    Vector3d ourPos = FlightGlobals.fetch.activeVessel.mainBody.GetWorldSurfacePosition(FlightGlobals.fetch.activeVessel.latitude, FlightGlobals.fetch.activeVessel.longitude, FlightGlobals.fetch.activeVessel.altitude);
+                    Vector3d theirPos = updateVessel.mainBody.GetWorldSurfacePosition(updateVessel.latitude, updateVessel.longitude, updateVessel.altitude);
+                    updateDistance = Vector3.Distance(ourPos, theirPos);
+                    DarkLog.Debug("PosDiff: " + updateDistance);
+                }
+                bool isLoading = (updateDistance < Vessel.loadDistance) && !updateVessel.loaded;
+                bool isUnpacking = (updateDistance < updateVessel.distanceUnpackThreshold) && updateVessel.packed && updateVessel.loaded;
+                //Don't set the position while the vessel is unpacking / loading.
+                if (isUnpacking || isLoading)
+                {
+                    DarkLog.Debug("Skipping update, isUnpacking: " + isUnpacking + " isLoading: " + isLoading);
+                    return;
+                }
+                if (updateVessel.packed)
+                {
+                    updateVessel.latitude = update.position[0];
+                    updateVessel.longitude = update.position[1];
+                    updateVessel.altitude = update.position[2];
+                    Vector3d orbitalPos = updatePostion - updateBody.position;
+                    Vector3d surfaceOrbitVelDiff = updateBody.getRFrmVel(updatePostion);
+                    Vector3d orbitalVel = updateVelocity + surfaceOrbitVelDiff;
+                    //Vector3d oldPos = updateVessel.orbitDriver.orbit.pos;
+                    //Vector3d oldVel = updateVessel.orbitDriver.orbit.vel;
+                    updateVessel.orbitDriver.orbit.UpdateFromStateVectors(orbitalPos.xzy, orbitalVel.xzy, updateBody, update.planetTime);
+                    //DarkLog.Debug("oldPos: " + (Vector3)oldPos + ", newPos: " + (Vector3)updateVessel.orbitDriver.orbit.pos + "oP: " + (Vector3)orbitalPos);
+                    //DarkLog.Debug("oldVel: " + (Vector3)oldVel + ", newVel: " + (Vector3)updateVessel.orbitDriver.orbit.vel + "oV: " + (Vector3)orbitalVel + " sOVD:" + (Vector3)surfaceOrbitVelDiff);
+                }
+                else
+                {
                     Vector3d velocityOffset = updateVelocity - updateVessel.srf_velocity;
                     updateVessel.SetPosition(updatePostion);
                     updateVessel.ChangeWorldVelocity(velocityOffset);