Skip to content

Commit 557d0e6

Browse files
committed
Fixed using Showcase camera leading to App reset / Fixed Aircraft not being recognized and App using wrong Payload Stations / Fixed App taking long Time to shutdown after Sim was closed / Updates Libraries
1 parent aabb23b commit 557d0e6

File tree

12 files changed

+111
-88
lines changed

12 files changed

+111
-88
lines changed

Installer/AppPackage.zip

54.5 KB
Binary file not shown.

Installer/Installer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<UpdateRequired>false</UpdateRequired>
2727
<MapFileExtensions>true</MapFileExtensions>
2828
<ApplicationRevision>0</ApplicationRevision>
29-
<ApplicationVersion>0.4.3.0</ApplicationVersion>
29+
<ApplicationVersion>0.4.4.0</ApplicationVersion>
3030
<UseApplicationTrust>false</UseApplicationTrust>
3131
<PublishWizardCompleted>true</PublishWizardCompleted>
3232
<BootstrapperEnabled>true</BootstrapperEnabled>

Installer/InstallerFunctions.cs

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,7 @@ public static bool CheckFSUIPC(string version = null)
327327
{
328328
string regVersion = (string)Registry.GetValue(Parameters.ipcRegPath, Parameters.ipcRegValue, null);
329329
if (!string.IsNullOrWhiteSpace(regVersion))
330-
{
331-
regVersion = regVersion.Substring(1);
332-
int index = regVersion.IndexOf("(beta)");
333-
if (index > 0)
334-
regVersion = regVersion.Substring(0, index).TrimEnd();
335-
result = CheckVersion(regVersion, ipcVersion, true, false);
336-
}
330+
result = CheckVersion(regVersion, VersionCompare.GREATER_EQUAL, ipcVersion, out bool compareable) && compareable;
337331
}
338332
catch (Exception e)
339333
{
@@ -342,61 +336,68 @@ public static bool CheckFSUIPC(string version = null)
342336

343337
return result;
344338
}
345-
public static bool CheckVersion(string versionInstalled, string versionRequired, bool majorEqual, bool ignoreBuild)
346-
{
347-
bool majorMatch = false;
348-
bool minorMatch = false;
349-
bool patchMatch = false;
350339

351-
string[] strInst = versionInstalled.Split('.');
352-
string[] strReq = versionRequired.Split('.');
353-
int vInst;
354-
int vReq;
355-
bool prevWasEqual = false;
340+
public static readonly Regex rxNumberMatch = new Regex(@"\D*(\d+)\D*", RegexOptions.Compiled | RegexOptions.IgnoreCase);
356341

357-
for (int i = 0; i < strInst.Length; i++)
342+
public static string[] CleanNumbers(string[] versions)
343+
{
344+
for (int i = 0; i < versions.Length; i++)
358345
{
359-
if (Regex.IsMatch(strInst[i], @"(\d+)\D"))
360-
strInst[i] = strInst[i].Substring(0, strInst[i].Length - 1);
346+
var match = rxNumberMatch.Match(versions[i]);
347+
if (match?.Groups?.Count == 2 && !string.IsNullOrWhiteSpace(match?.Groups[1]?.Value))
348+
versions[i] = match.Groups[1].Value;
349+
else
350+
return null;
361351
}
362352

363-
//Major
364-
if (int.TryParse(strInst[0], out vInst) && int.TryParse(strReq[0], out vReq))
365-
{
366-
if (majorEqual)
367-
majorMatch = vInst == vReq;
368-
else
369-
majorMatch = vInst >= vReq;
353+
return versions;
354+
}
370355

371-
prevWasEqual = vInst == vReq;
372-
}
356+
public enum VersionCompare
357+
{
358+
EQUAL = 1,
359+
LESS,
360+
LESS_EQUAL,
361+
GREATER,
362+
GREATER_EQUAL
363+
}
373364

374-
//Minor
375-
if (int.TryParse(strInst[1], out vInst) && int.TryParse(strReq[1], out vReq))
376-
{
377-
if (prevWasEqual)
378-
minorMatch = vInst >= vReq;
379-
else
380-
minorMatch = true;
365+
public static bool CheckVersion(string leftVersion, VersionCompare comparison, string rightVersion, out bool compareable, int digits = 3)
366+
{
367+
compareable = false;
381368

382-
prevWasEqual = vInst == vReq;
383-
}
369+
if (string.IsNullOrWhiteSpace(leftVersion) || string.IsNullOrWhiteSpace(rightVersion))
370+
return false;
371+
372+
string[] leftParts = leftVersion.Split('.');
373+
string[] rightParts = rightVersion.Split('.');
374+
if (leftParts.Length < digits || rightParts.Length < digits)
375+
return false;
384376

385-
//Patch
386-
if (!ignoreBuild)
377+
leftParts = CleanNumbers(leftParts);
378+
rightParts = CleanNumbers(rightParts);
379+
if (leftParts == null || rightParts == null)
380+
return false;
381+
382+
leftVersion = string.Join(".", leftParts);
383+
rightVersion = string.Join(".", rightParts);
384+
if (!Version.TryParse(leftVersion, out Version left) || !Version.TryParse(rightVersion, out Version right))
385+
return false;
386+
387+
compareable = true;
388+
switch (comparison)
387389
{
388-
if (int.TryParse(strInst[2], out vInst) && int.TryParse(strReq[2], out vReq))
389-
{
390-
if (prevWasEqual)
391-
patchMatch = vInst >= vReq;
392-
else
393-
patchMatch = true;
394-
}
390+
case VersionCompare.LESS:
391+
return left < right;
392+
case VersionCompare.LESS_EQUAL:
393+
return left <= right;
394+
case VersionCompare.GREATER:
395+
return left > right;
396+
case VersionCompare.GREATER_EQUAL:
397+
return left >= right;
398+
default:
399+
return left == right;
395400
}
396-
else
397-
patchMatch = true;
398-
399-
return majorMatch && minorMatch && patchMatch;
400401
}
401402

402403
public static bool CheckPackageVersion(string packagePath, string packageName, string version)
@@ -412,8 +413,8 @@ public static bool CheckPackageVersion(string packagePath, string packageName, s
412413
if (Parameters.wasmRegex.IsMatch(line))
413414
{
414415
var matches = Parameters.wasmRegex.Matches(line);
415-
if (matches.Count == 1 && matches[0].Groups.Count >= 2)
416-
return CheckVersion(matches[0].Groups[1].Value, version, false, false);
416+
if (matches?.Count == 1 && matches[0]?.Groups?.Count >= 2)
417+
return CheckVersion(matches[0]?.Groups[1]?.Value, VersionCompare.GREATER_EQUAL, version, out bool compareable) && compareable;
417418
}
418419
}
419420
}

Installer/Parameters.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ public static class Parameters
1818

1919
public static readonly int netMajor = 7;
2020
public static readonly int netMinor = 0;
21-
public static readonly int netPatch = 14;
21+
public static readonly int netPatch = 20;
2222
public static readonly string netVersion = $"{netMajor}.{netMinor}.{netPatch}";
23-
public static readonly string netUrl = "https://download.visualstudio.microsoft.com/download/pr/8f5b0079-2bb4-49cd-874e-0f58703eff6e/7010b5f213a2c436a307eb385dbb16ff/windowsdesktop-runtime-7.0.14-win-x64.exe";
24-
public static readonly string netUrlFile = "windowsdesktop-runtime-7.0.14-win-x64.exe";
23+
public static readonly string netUrl = "https://download.visualstudio.microsoft.com/download/pr/08bbfe8f-812d-479f-803b-23ea0bffce47/c320e4b037f3e92ab7ea92c3d7ea3ca1/windowsdesktop-runtime-7.0.20-win-x64.exe";
24+
public static readonly string netUrlFile = "windowsdesktop-runtime-7.0.20-win-x64.exe";
2525

2626
public static readonly string ipcRegPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FSUIPC7";
2727
public static readonly string ipcRegInstallDirValue = "InstallDir";
2828
public static readonly string ipcRegValue = "DisplayVersion";
29-
public static readonly string ipcVersion = "7.3.24";
29+
public static readonly string ipcVersion = "7.4.17";
3030

3131
public static readonly Regex wasmRegex = new Regex("^\\s*\"package_version\":\\s*\"([0-9\\.]+)\"\\s*,\\s*$", RegexOptions.Compiled);
3232
public static readonly string wasmMobiName = "mobiflight-event-module";
33-
public static readonly string wasmMobiVersion = "0.7.1";
34-
public static readonly string wasmUrl = "https://github.com/MobiFlight/MobiFlight-WASM-Module/releases/download/0.7.1/mobiflight-event-module-0.7.1.zip";
35-
public static readonly string wasmUrlFile = "mobiflight-event-module-0.7.1.zip";
33+
public static readonly string wasmMobiVersion = "1.0.1";
34+
public static readonly string wasmUrl = "https://github.com/MobiFlight/MobiFlight-WASM-Module/releases/download/1.0.1/mobiflight-event-module.1.0.1.zip";
35+
public static readonly string wasmUrlFile = "mobiflight-event-module.1.0.1.zip";
3636

3737
public static readonly string msConfigStore = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\UserCfg.opt";
3838
public static readonly string msConfigSteam = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft Flight Simulator\UserCfg.opt";

Installer/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@
4949
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
5050
// indem Sie "*" wie unten gezeigt eingeben:
5151
// [assembly: AssemblyVersion("1.0.*")]
52-
[assembly: AssemblyVersion("0.4.3.0")]
53-
[assembly: AssemblyFileVersion("0.4.3.0")]
52+
[assembly: AssemblyVersion("0.4.4.0")]
53+
[assembly: AssemblyFileVersion("0.4.4.0")]

WorkingTitle2GSX/Aircraft.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public void StopDeboarding()
327327

328328
public void SetEmpty()
329329
{
330-
Logger.Log(LogLevel.Information, "Aircraft:SetEmpty", $"Resetting Paylod & Fuel (Empty Plane)");
330+
Logger.Log(LogLevel.Information, "Aircraft:SetEmpty", $"Resetting Payload & Fuel (Empty Plane)");
331331
Stations.Refresh();
332332
fuelLeftOffset.Reconnect();
333333
fuelRightOffset.Reconnect();

WorkingTitle2GSX/ConfigurationFile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public void SaveConfiguration()
3636

3737
public string GetSetting(string key, string defaultValue = "")
3838
{
39-
if (appSettings.ContainsKey(key))
40-
return appSettings[key];
39+
if (appSettings.TryGetValue(key, out string value))
40+
return value;
4141
else
4242
{
4343
XmlNode newNode = xmlDoc.CreateElement("add");

WorkingTitle2GSX/FlightPlan.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public bool Load()
9696
WeightPax = Convert.ToDouble(sbOFP["weights"]["pax_weight"].InnerText, new RealInvariantFormat(sbOFP["weights"]["pax_weight"].InnerText));
9797
WeightBag = Convert.ToDouble(sbOFP["weights"]["bag_weight"].InnerText, new RealInvariantFormat(sbOFP["weights"]["bag_weight"].InnerText));
9898

99-
if (lastID != FlightPlanID && Model.AcIndentified == sbOFP["aircraft"]["name"].InnerText)
99+
if (lastID != FlightPlanID)
100100
{
101101
Logger.Log(LogLevel.Information, "FlightPlan:Load", $"New OFP for Flight {Flight} loaded. ({Origin} -> {Destination})");
102102
}

WorkingTitle2GSX/IPCManager.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ public bool WaitForConnection()
7676
Logger.Log(LogLevel.Critical, "IPCManager:WaitForConnection", $"Exception while opening FSUIPC! (Exception: {ex.GetType()})");
7777
}
7878

79-
if (!FSUIPCConnection.IsOpen)
79+
if (!FSUIPCConnection.IsOpen && IsSimRunning())
8080
{
8181
Logger.Log(LogLevel.Information, "IPCManager:WaitForConnection", $"FSUIPC Connection not established - waiting {waitDuration / 2 / 1000}s");
8282
Thread.Sleep(waitDuration / 2);
8383
}
8484

85-
return FSUIPCConnection.IsOpen && offInMenu.IsConnected;
85+
return FSUIPCConnection.IsOpen && offInMenu.IsConnected && IsSimRunning();
8686
}
8787

8888
public string CheckAircraft(ServiceModel model)
@@ -159,7 +159,7 @@ public bool WaitForSessionReady(ServiceModel model)
159159
isReady = IsCamReady();
160160
}
161161

162-
if (!isReady)
162+
if (!isReady || !IsSimRunning())
163163
{
164164
Logger.Log(LogLevel.Error, "IPCManager:WaitForSessionReady", $"SimConnect or Simulator not available - aborting");
165165
return false;
@@ -179,9 +179,8 @@ public bool IsCamReady()
179179
{
180180
FSUIPCConnection.Process(ServiceModel.IpcGroupName);
181181
short value = offCamReady.Value;
182-
byte menu = offInMenu.Value;
183182

184-
return value >= 2 && value <= 5 && menu == 0;
183+
return value < 11;
185184
}
186185

187186
public void CloseSafe()

WorkingTitle2GSX/PayloadStations.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ public void SetWeights(FlightPlan OFP)
5252

5353
public static void SelectDistribution(ServiceModel model, out string distPax, out string distCargo)
5454
{
55-
if (model.AcIndentified.Contains("HorizonSim_B787_9"))
55+
if (model.AcIndentified.Contains("HorizonSim_B787_9", StringComparison.InvariantCultureIgnoreCase))
5656
{
5757
distPax = model.DistributionPaxHS;
5858
distCargo = model.DistributionCargoHS;
5959
}
60-
else if (model.AcIndentified.Contains("Kuro_B787_8"))
60+
else if (model.AcIndentified.Contains("Kuro_B787_8", StringComparison.InvariantCultureIgnoreCase))
6161
{
6262
distPax = model.DistributionPaxKU;
6363
distCargo = model.DistributionCargoKU;
6464
}
65-
else if (model.AcIndentified.Contains("B787_9"))
65+
else if (model.AcIndentified.Contains("B787_9", StringComparison.InvariantCultureIgnoreCase))
6666
{
6767
distPax = model.DistributionPaxWT;
6868
distCargo = model.DistributionCargoWT;
@@ -93,9 +93,15 @@ public void SetPax(int num)
9393
weightPax = (double)num * paxWeight * station.Value;
9494
weightPilots = 2 * (85 / Model.ConstKilo) * station.Value;
9595
if (weightPax - weightPilots >= 0)
96+
{
97+
Logger.Log(LogLevel.Debug, "PayloadStations:SetPax", $"Setting {weightPax - weightPilots}lbs ({(weightPax - weightPilots) * Model.ConstKilo}kg) to Station '{station.Key}' ({ipcStations[station.Key].Name})");
9698
ipcStations[station.Key].WeightLbs = weightPax - weightPilots;
99+
}
97100
else
101+
{
102+
Logger.Log(LogLevel.Debug, "PayloadStations:SetPax", $"Setting {weightPax}lbs ({weightPax * Model.ConstKilo}kg) to Station '{station.Key}' ({ipcStations[station.Key].Name})");
98103
ipcStations[station.Key].WeightLbs = weightPax;
104+
}
99105
}
100106
FSUIPCConnection.PayloadServices.WriteChanges();
101107
}
@@ -114,15 +120,15 @@ public int GetPax()
114120

115121
public void SetCargo(double percent)
116122
{
117-
if (Model.AcIndentified.Contains("HorizonSim_B787_9"))
123+
if (Model.AcIndentified.Contains("HorizonSim_B787_9", StringComparison.InvariantCultureIgnoreCase))
118124
{
119125
SetCargoHS(percent);
120126
}
121-
else if (Model.AcIndentified.Contains("Kuro_B787_8"))
127+
else if (Model.AcIndentified.Contains("Kuro_B787_8", StringComparison.InvariantCultureIgnoreCase))
122128
{
123129
SetCargoKU(percent);
124130
}
125-
else if (Model.AcIndentified.Contains("B787_9"))
131+
else if (Model.AcIndentified.Contains("B787_9", StringComparison.InvariantCultureIgnoreCase))
126132
{
127133
SetCargoWT(percent);
128134
}
@@ -137,10 +143,15 @@ private void SetCargoHS(double percent)
137143
{
138144
var ipcStations = FSUIPCConnection.PayloadServices.PayloadStations;
139145
if (percent * payloadCargo < Model.RearCargoMaxHS)
146+
{
147+
Logger.Log(LogLevel.Debug, "PayloadStations:SetCargoHS", $"Setting {percent * payloadCargo}lbs ({(percent * payloadCargo) * Model.ConstKilo}kg) to Station '{cargoStations[1].Key}' ({ipcStations[cargoStations[1].Key].Name})");
140148
ipcStations[cargoStations[1].Key].WeightLbs = percent * payloadCargo;
149+
}
141150
else
142151
{
152+
Logger.Log(LogLevel.Debug, "PayloadStations:SetCargoHS", $"Setting {Model.RearCargoMaxHS}lbs ({Model.RearCargoMaxHS * Model.ConstKilo}kg) to Station '{cargoStations[1].Key}' ({ipcStations[cargoStations[1].Key].Name})");
143153
ipcStations[cargoStations[1].Key].WeightLbs = Model.RearCargoMaxHS;
154+
Logger.Log(LogLevel.Debug, "PayloadStations:SetCargoHS", $"Setting {(percent * payloadCargo) - Model.RearCargoMaxHS}lbs ({((percent * payloadCargo) - Model.RearCargoMaxHS) * Model.ConstKilo}kg) to Station '{cargoStations[0].Key}' ({ipcStations[cargoStations[0].Key].Name})");
144155
ipcStations[cargoStations[0].Key].WeightLbs = (percent * payloadCargo) - Model.RearCargoMaxHS;
145156
}
146157
}

0 commit comments

Comments
 (0)