Skip to content

Commit

Permalink
Merge pull request #477 from ciribob/beta
Browse files Browse the repository at this point in the history
Release 1.9.2.0
  • Loading branch information
ciribob authored Jul 11, 2020
2 parents 23ec1f0 + eb4daf6 commit c8f233a
Show file tree
Hide file tree
Showing 57 changed files with 2,536 additions and 2,155 deletions.
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf

*.c text eol=crlf
*.h text eol=crlf

*.cpp text eol=crlf
*.cs text eol=crlf
*.xml text eol=crlf
*.xaml text eol=crlf
*.conf text eol=crlf
*.lua text eol=crlf
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,5 @@ install-build/serverlog.txt

install-build/
sign.bat

.leu

.leu
125 changes: 109 additions & 16 deletions AutoUpdater/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using Octokit;
using MessageBox = System.Windows.MessageBox;
Expand All @@ -42,6 +32,8 @@ public partial class MainWindow : Window
private DispatcherTimer _progressCheckTimer;
private double _lastValue = -1;

private bool _finished = false;

private string changelogURL = "";

public MainWindow()
Expand Down Expand Up @@ -121,7 +113,30 @@ private async Task<Uri> GetPathToLatestVersion()
{
changelogURL = release.HtmlUrl;
Status.Content = "Downloading Version "+release.TagName;
return new System.Uri(releaseAsset.BrowserDownloadUrl);

if (ServerInstall())
{
//check the path and version
var path = ServerPath();

if (path.Length > 0)
{
var latestVersion = new Version(release.TagName.Replace("v", ""));
var serverVersion = Assembly.LoadFile(Path.Combine(path, "SR-Server.exe")).GetName().Version;

if (serverVersion < latestVersion)
{
return new Uri(releaseAsset.BrowserDownloadUrl);
}
else
{
//no update
return null;
}

}
}
return new Uri(releaseAsset.BrowserDownloadUrl);
}

}
Expand All @@ -146,6 +161,36 @@ private bool AllowBeta()

}

private string ServerPath()
{
foreach (var commandLineArg in Environment.GetCommandLineArgs())
{
if (commandLineArg.Trim().StartsWith("-path="))
{
var line = commandLineArg.Trim();
line = line.Replace("-path=", "");

return line;
}
}

return "";
}

private bool ServerInstall()
{
foreach (var arg in Environment.GetCommandLineArgs())
{
if (arg.Trim().Equals("-server"))
{
return true;
}

}

return false;
}

public void ShowError()
{
MessageBox.Show("Error Auto Updating SRS - Please check internet connection and try again \n\nAlternatively: \n1. Download the latest DCS-SimpleRadioStandalone.zip from the SRS Github Release page\n2. Extract all the files to a temporary directory\n3. Run the installer.",
Expand All @@ -162,6 +207,12 @@ public async void DownloadLatestVersion()
{
_uri = await GetPathToLatestVersion();

if (_uri == null)
{
Environment.Exit(0);
}


_directory = GetTemporaryDirectory();
_file = _directory + "\\temp.zip";

Expand All @@ -188,7 +239,7 @@ public async void DownloadLatestVersion()

private void CheckProgress(object sender, EventArgs e)
{
if (_lastValue == DownloadProgress.Value)
if (_lastValue == DownloadProgress.Value && _finished == false)
{
//no progress
ShowError();
Expand All @@ -199,23 +250,65 @@ private void CheckProgress(object sender, EventArgs e)

}

private bool ShouldRestart()
{
foreach (var arg in Environment.GetCommandLineArgs())
{
if (arg.Trim().Equals("-restart"))
{
return true;
}

}

return false;
}

private void DownloadComplete(object sender, AsyncCompletedEventArgs e)
{
_finished = true;
if (!_cancel)
{
ZipFile.ExtractToDirectory(_file, Path.Combine(_directory, "extract"));

Thread.Sleep(400);

if (!ServerInstall())
{
var releaseNotes = MessageBox.Show(
"Do you want to read the release notes? \n\nHighly recommended before installing! \n\n",
"Read Release Notes?",
MessageBoxButton.YesNo, MessageBoxImage.Information);

if (releaseNotes == MessageBoxResult.Yes)
{
Process.Start(changelogURL);
}
}

ProcessStartInfo procInfo = new ProcessStartInfo();
procInfo.WorkingDirectory = Path.Combine(_directory, "extract");
procInfo.Arguments = "-autoupdate";
procInfo.WorkingDirectory = Path.Combine(_directory, "extract");
if (ServerInstall())
{
procInfo.Arguments = "-autoupdate";
procInfo.Arguments += " -server ";
procInfo.Arguments += " -path=\"" + ServerPath() + "\"";

if (ShouldRestart())
{
procInfo.Arguments += " -restart ";
}
}
else
{
procInfo.Arguments = "-autoupdate";
}
procInfo.FileName = Path.Combine(Path.Combine(_directory, "extract"), "installer.exe");
procInfo.UseShellExecute = false;
Process.Start(procInfo);


Process.Start(changelogURL);
//Process.Start(changelogURL);
}

Close();
Expand Down
4 changes: 2 additions & 2 deletions AutoUpdater/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.9.0.1")]
[assembly: AssemblyFileVersion("1.9.0.1")]
[assembly: AssemblyVersion("1.9.0.2")]
[assembly: AssemblyFileVersion("1.9.0.2")]
13 changes: 10 additions & 3 deletions DCS-SR-Client/App.config
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="SharpDX" publicKeyToken="b4dcf0f35e5521f1" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Sentry.PlatformAbstractions" publicKeyToken="fba2ec45388e2af0" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.1.0" newVersion="1.1.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
</configuration>
28 changes: 15 additions & 13 deletions DCS-SR-Client/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using NLog.Config;
using NLog.Targets;
using NLog.Targets.Wrappers;
using Sentry;

namespace DCS_SR_Client
{
Expand All @@ -29,6 +30,7 @@ public partial class App : Application

public App()
{
SentrySdk.Init("https://[email protected]/5304752");
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionHandler);

var location = AppDomain.CurrentDomain.BaseDirectory;
Expand Down Expand Up @@ -59,9 +61,6 @@ public App()

ListArgs();

RequireAdmin();


#if !DEBUG
if (IsClientRunning())
{
Expand Down Expand Up @@ -99,6 +98,9 @@ public App()
}
}
#endif

RequireAdmin();

InitNotificationIcon();

}
Expand Down Expand Up @@ -222,21 +224,21 @@ private bool IsClientRunning()
private void SetupLogging()
{
// If there is a configuration file then this will already be set
if(LogManager.Configuration != null)
{
if(LogManager.Configuration != null)
{
loggingReady = true;
return;
return;
}

var config = new LoggingConfiguration();
var fileTarget = new FileTarget
{
FileName = "clientlog.txt",
ArchiveFileName = "clientlog.old.txt",
MaxArchiveFiles = 1,
ArchiveAboveSize = 104857600,
var fileTarget = new FileTarget
{
FileName = "clientlog.txt",
ArchiveFileName = "clientlog.old.txt",
MaxArchiveFiles = 1,
ArchiveAboveSize = 104857600,
Layout =
@"${longdate} | ${logger} | ${message} ${exception:format=toString,Data:maxInnerExceptionLevel=1}"
@"${longdate} | ${logger} | ${message} ${exception:format=toString,Data:maxInnerExceptionLevel=1}"
};

var wrapper = new AsyncTargetWrapper(fileTarget, 5000, AsyncTargetWrapperOverflowAction.Discard);
Expand Down
10 changes: 5 additions & 5 deletions DCS-SR-Client/Audio/Providers/CachedLoopingAudioProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public int Read(byte[] buffer, int offset, int count)
{
int read = source.Read(buffer, offset, count);

if (!GlobalSettingsStore.Instance.ProfileSettingsStore.GetClientSettingBool(ProfileSettingsKeys.NATOTone))
{
return read;
if (!GlobalSettingsStore.Instance.ProfileSettingsStore.GetClientSettingBool(ProfileSettingsKeys.NATOTone))
{
return read;
}

var effectBytes = GetEffect(read / 2);
Expand All @@ -60,8 +60,8 @@ public int Read(byte[] buffer, int offset, int count)

buffer[(offset + i) * 2] = byte1;
buffer[((i + offset) * 2) + 1] = byte2;
}

}

return read;
}

Expand Down
10 changes: 5 additions & 5 deletions DCS-SR-Client/Audio/Providers/RadioFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ public int Read(float[] buffer, int offset, int sampleCount)
{
var samplesRead = _source.Read(buffer, offset, sampleCount);
if (!_globalSettings.ProfileSettingsStore.GetClientSettingBool(ProfileSettingsKeys.RadioEffects) || samplesRead <= 0)
{
return samplesRead;
{
return samplesRead;
}

for (var n = 0; n < sampleCount; n++)
{
var audio = (double) buffer[offset + n];
if (audio == 0)
{
continue;
if (audio == 0)
{
continue;
}
// because we have silence in one channel (if a user picks radio left or right ear) we don't want to transform it or it'll play in both

Expand Down
4 changes: 2 additions & 2 deletions DCS-SR-Client/Audio/Utility/SpeexWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public Preprocessor(int frameSize, int sampleRate)
_frameSize = frameSize;
_format = new WaveFormat(1, sampleRate);

Reset();
Reset();
RefreshSettings(true);
}

Expand Down Expand Up @@ -319,7 +319,7 @@ public void Reset()

//every 40ms so 500
private int count = 0;
private void RefreshSettings(bool force)
private void RefreshSettings(bool force)
{
//only check every 5 seconds - 5000/40ms is 125 frames
if (count > 125 || force)
Expand Down
Loading

0 comments on commit c8f233a

Please sign in to comment.