Skip to content

Commit

Permalink
fixed crash, release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rynchodon committed Oct 29, 2016
1 parent 172ab9e commit 9cd7433
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Injector/ArmsUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Rynchodon
{
public static class ArmsUpdater
{
private const string ArmsDll = "ARMS.dll";
public const string ArmsDll = "ARMS.dll", ArmsReleaseNotes = "ARMS - Release Notes.txt";

public static void UpdateArms()
{
Expand Down Expand Up @@ -66,6 +66,7 @@ public static void UpdateArms()
response.GetResponseStream().CopyTo(file);
file.Close();

File.WriteAllText(ArmsReleaseNotes, bestRelease.body);
WriteLine("ARMS has been updated");
}

Expand Down
48 changes: 35 additions & 13 deletions Injector/DllInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class DllInjector

static void Main(string[] args)
{
Run();
Thread.Sleep(10000);
try { Run(); }
catch (Exception ex) { Console.Error.WriteLine(ex); }
Thread.Sleep(60000);
}

private static void Run()
Expand Down Expand Up @@ -61,8 +62,16 @@ private static void Run()
{
WriteLine("Alternate launch");
Process.Start(launcher);
process = WaitForGameStart(false);
process.WaitForExit(3000);
process = WaitForGameStart(false, false);
while (!process.WaitForExit(100))
{
process.Refresh();
if (!string.IsNullOrWhiteSpace(process.MainWindowTitle))
{
WriteLine("Window has title");
break;
}
}
}
else
{
Expand All @@ -75,14 +84,27 @@ private static void Run()
WriteLine("Game launched");
}

update.Wait();

if (!File.Exists(ArmsUpdater.ArmsReleaseNotes))
{
WriteLine("ERROR: No release notes found");
}
else
{
StreamReader reader = new StreamReader(ArmsUpdater.ArmsReleaseNotes);
Version currentVersion = new Version(FileVersionInfo.GetVersionInfo(ArmsUpdater.ArmsDll));

Console.WriteLine();
Console.Write("Release notes for ARMS version ");
Console.WriteLine(currentVersion.ToString());
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine();
}

process = WaitForGameStart(isDedicatedServer);
if (process == null)
return;

// TODO: this is arbitrary, come up with a test
Thread.Sleep(5000);

update.Wait();
Inject(process, dllPath);
}

Expand All @@ -105,7 +127,7 @@ private static Process GetGameProcess(bool isDedicatedServer)
return newest;
}

private static Process WaitForGameStart(bool isDedicatedServer, int seconds = 600)
private static Process WaitForGameStart(bool isDedicatedServer, bool needTitle = true, int seconds = 600)
{
Process process = null;

Expand All @@ -127,7 +149,7 @@ private static Process WaitForGameStart(bool isDedicatedServer, int seconds = 60
return null;
}

if (!isDedicatedServer)
if (!needTitle)
return process;

// wait for title
Expand All @@ -145,11 +167,11 @@ private static Process WaitForGameStart(bool isDedicatedServer, int seconds = 60
process.Refresh();
if (!string.IsNullOrWhiteSpace(process.MainWindowTitle))
{
if ((process.MainWindowTitle.Contains("Select Instance") || process.MainWindowTitle.Contains("configurator")))
if ((process.MainWindowTitle.Contains(" - Select Instance of Dedicated server") || process.MainWindowTitle.Contains(" - Dedicated server configurator"))) // these are hard-coded
{
WriteLine("Configurator is running");
process.WaitForExit();
return WaitForGameStart(isDedicatedServer, 10);
return WaitForGameStart(isDedicatedServer, seconds: 10);
}
return process;
}
Expand Down
2 changes: 1 addition & 1 deletion Injector/Release.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private class Create
}

[DataMember]
public string tag_name, name;
public string tag_name, name, body;
[DataMember]
public long id;
[DataMember]
Expand Down

0 comments on commit 9cd7433

Please sign in to comment.