diff --git a/Reactor.Greenhouse/Program.cs b/Reactor.Greenhouse/Program.cs index 744d047..616d7e4 100644 --- a/Reactor.Greenhouse/Program.cs +++ b/Reactor.Greenhouse/Program.cs @@ -11,6 +11,7 @@ using Mono.Cecil; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using Reactor.Greenhouse.Setup; +using Reactor.Greenhouse.Setup.Provider; using Reactor.OxygenFilter; namespace Reactor.Greenhouse @@ -33,6 +34,7 @@ namespace Reactor.Greenhouse public static async Task GenerateAsync(bool steam, bool itch) { var gameManager = new GameManager(); + await gameManager.SetupAsync(steam, itch); JsonConvert.DefaultSettings = () => new JsonSerializerSettings @@ -46,6 +48,12 @@ namespace Reactor.Greenhouse 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); diff --git a/Reactor.Greenhouse/Setup/Provider/BaseProvider.cs b/Reactor.Greenhouse/Setup/Provider/BaseProvider.cs index b552ab7..5c72ef5 100644 --- a/Reactor.Greenhouse/Setup/Provider/BaseProvider.cs +++ b/Reactor.Greenhouse/Setup/Provider/BaseProvider.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; namespace Reactor.Greenhouse.Setup.Provider @@ -10,4 +11,14 @@ namespace Reactor.Greenhouse.Setup.Provider 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; + } + } } diff --git a/Reactor.Greenhouse/Setup/Provider/ItchProvider.cs b/Reactor.Greenhouse/Setup/Provider/ItchProvider.cs index 4d3144c..e56d5aa 100644 --- a/Reactor.Greenhouse/Setup/Provider/ItchProvider.cs +++ b/Reactor.Greenhouse/Setup/Provider/ItchProvider.cs @@ -41,7 +41,6 @@ namespace Reactor.Greenhouse.Setup.Provider Console.Write("itch.io password: "); Password = Util.ReadPassword(); - Console.WriteLine(); } } @@ -63,7 +62,7 @@ namespace Reactor.Greenhouse.Setup.Provider 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"); diff --git a/Reactor.Greenhouse/Setup/Provider/SteamProvider.cs b/Reactor.Greenhouse/Setup/Provider/SteamProvider.cs index 543e323..6efbe84 100644 --- a/Reactor.Greenhouse/Setup/Provider/SteamProvider.cs +++ b/Reactor.Greenhouse/Setup/Provider/SteamProvider.cs @@ -67,7 +67,10 @@ namespace Reactor.Greenhouse.Setup.Provider 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 { @@ -85,7 +88,15 @@ namespace Reactor.Greenhouse.Setup.Provider 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;