Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

Commit

Permalink
Merge branch 'LelouBil-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
js6pak committed Jan 5, 2021
2 parents c634a5a + 0ef29de commit 78f0d8d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
8 changes: 8 additions & 0 deletions Reactor.Greenhouse/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Reactor.Greenhouse.Setup;
using Reactor.Greenhouse.Setup.Provider;
using Reactor.OxygenFilter;

namespace Reactor.Greenhouse
Expand All @@ -33,6 +34,7 @@ private static Task<int> Main(string[] args)
public static async Task GenerateAsync(bool steam, bool itch)
{
var gameManager = new GameManager();

await gameManager.SetupAsync(steam, itch);

JsonConvert.DefaultSettings = () => new JsonSerializerSettings
Expand All @@ -46,6 +48,12 @@ public static async Task GenerateAsync(bool steam, bool itch)
Console.WriteLine($"Generating mappings from {gameManager.PreObfuscation.Name} ({gameManager.PreObfuscation.Version})");
using var old = ModuleDefinition.ReadModule(File.OpenRead(gameManager.PreObfuscation.Dll));

if (!steam && !itch)
{
Console.WriteLine("No game providers used! (use --help for more info)");
return;
}

if (steam)
{
await GenerateAsync(gameManager.Steam, old);
Expand Down
11 changes: 11 additions & 0 deletions Reactor.Greenhouse/Setup/Provider/BaseProvider.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Threading.Tasks;

namespace Reactor.Greenhouse.Setup.Provider
Expand All @@ -10,4 +11,14 @@ public abstract class BaseProvider
public abstract Task DownloadAsync();
public abstract bool IsUpdateNeeded();
}

public class ProviderConnectionException : Exception
{
public BaseProvider Provider { get; }

public ProviderConnectionException(BaseProvider provider, string message) : base(message)
{
Provider = provider;
}
}
}
3 changes: 1 addition & 2 deletions Reactor.Greenhouse/Setup/Provider/ItchProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public override void Setup()

Console.Write("itch.io password: ");
Password = Util.ReadPassword();

Console.WriteLine();
}
}
Expand All @@ -63,7 +62,7 @@ public override async Task DownloadAsync()

if (!loginResponse.IsSuccessStatusCode || (await loginResponse.Content.ReadAsStringAsync()).Contains("Errors"))
{
throw new Exception("itch.io authentication failed");
throw new ProviderConnectionException(this, "Authentication failed");
}

Console.WriteLine("Logged into itch.io");
Expand Down
15 changes: 13 additions & 2 deletions Reactor.Greenhouse/Setup/Provider/SteamProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ public override void Setup()
if (environmentVariable != null)
{
var split = environmentVariable.Split(":");
ContentDownloader.InitializeSteam3(split[0], split[1]);
if (!ContentDownloader.InitializeSteam3(split[0], split[1]))
{
throw new ProviderConnectionException(this, "Incorrect credentials.");
}
}
else
{
Expand All @@ -85,7 +88,15 @@ public override void Setup()
Console.WriteLine();
}

ContentDownloader.InitializeSteam3(username, password);
if (!ContentDownloader.InitializeSteam3(username, password))
{
throw new ProviderConnectionException(this, "Incorrect credentials.");
}
}

if (ContentDownloader.steam3 == null || !ContentDownloader.steam3.bConnected)
{
throw new ProviderConnectionException(this, "Unable to initialize Steam3 session.");
}

ContentDownloader.Config.UsingFileList = true;
Expand Down

0 comments on commit 78f0d8d

Please sign in to comment.