mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 22:20:52 +00:00
Implement workaround for #380
This commit is contained in:
@@ -193,13 +193,13 @@ namespace ArchiSteamFarm {
|
||||
await RestartOrExit().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
internal static void InitBots() {
|
||||
internal static async Task InitBots() {
|
||||
if (Bot.Bots.Count != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Before attempting to connect, initialize our list of CMs
|
||||
Bot.InitializeCMs(Program.GlobalDatabase.CellID, Program.GlobalDatabase.ServerListProvider);
|
||||
await Bot.InitializeCMs(Program.GlobalDatabase.CellID, Program.GlobalDatabase.ServerListProvider).ConfigureAwait(false);
|
||||
|
||||
foreach (string botName in Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension)) {
|
||||
switch (botName) {
|
||||
|
||||
@@ -302,7 +302,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
|
||||
internal static void InitializeCMs(uint cellID, IServerListProvider serverListProvider) {
|
||||
internal static async Task InitializeCMs(uint cellID, IServerListProvider serverListProvider) {
|
||||
if (serverListProvider == null) {
|
||||
Program.ArchiLogger.LogNullError(nameof(serverListProvider));
|
||||
return;
|
||||
@@ -310,6 +310,12 @@ namespace ArchiSteamFarm {
|
||||
|
||||
CMClient.Servers.CellID = cellID;
|
||||
CMClient.Servers.ServerListProvider = serverListProvider;
|
||||
|
||||
// Normally we wouldn't need to do this, but there is a case where our list might be invalid or outdated
|
||||
// Ensure that we always ask once for list of up-to-date servers, even if we have list saved
|
||||
Program.ArchiLogger.LogGenericInfo("Initializing SteamDirectory...");
|
||||
await SteamDirectory.Initialize(cellID).ConfigureAwait(false);
|
||||
Program.ArchiLogger.LogGenericInfo("Done!");
|
||||
}
|
||||
|
||||
internal async Task LootIfNeeded() {
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace ArchiSteamFarm {
|
||||
ShutdownResetEvent.Set();
|
||||
}
|
||||
|
||||
private static void Init(string[] args) {
|
||||
private static async Task Init(string[] args) {
|
||||
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
|
||||
TaskScheduler.UnobservedTaskException += UnobservedTaskExceptionHandler;
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
// Parse post-init args
|
||||
if (args != null) {
|
||||
ParsePostInitArgs(args);
|
||||
await ParsePostInitArgs(args).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// If we ran ASF as a client, we're done by now
|
||||
@@ -203,8 +203,8 @@ namespace ArchiSteamFarm {
|
||||
Exit();
|
||||
}
|
||||
|
||||
ASF.CheckForUpdate().Wait();
|
||||
ASF.InitBots();
|
||||
await ASF.CheckForUpdate().ConfigureAwait(false);
|
||||
await ASF.InitBots().ConfigureAwait(false);
|
||||
ASF.InitFileWatcher();
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace ArchiSteamFarm {
|
||||
private static void Main(string[] args) {
|
||||
if (Runtime.IsUserInteractive) {
|
||||
// App
|
||||
Init(args);
|
||||
Init(args).Wait();
|
||||
|
||||
// Wait for signal to shutdown
|
||||
ShutdownResetEvent.Wait();
|
||||
@@ -268,7 +268,7 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
}
|
||||
|
||||
private static void ParsePostInitArgs(IEnumerable<string> args) {
|
||||
private static async Task ParsePostInitArgs(IEnumerable<string> args) {
|
||||
if (args == null) {
|
||||
ArchiLogger.LogNullError(nameof(args));
|
||||
return;
|
||||
@@ -284,7 +284,7 @@ namespace ArchiSteamFarm {
|
||||
case "--server":
|
||||
Mode |= EMode.Server;
|
||||
WCF.StartServer();
|
||||
ASF.InitBots();
|
||||
await ASF.InitBots().ConfigureAwait(false);
|
||||
break;
|
||||
default:
|
||||
if (arg.StartsWith("--", StringComparison.Ordinal)) {
|
||||
@@ -364,8 +364,8 @@ namespace ArchiSteamFarm {
|
||||
ServiceName = SharedInfo.ServiceName;
|
||||
}
|
||||
|
||||
protected override void OnStart(string[] args) => Task.Run(() => {
|
||||
Init(args);
|
||||
protected override void OnStart(string[] args) => Task.Run(async () => {
|
||||
await Init(args).ConfigureAwait(false);
|
||||
ShutdownResetEvent.Wait();
|
||||
Stop();
|
||||
});
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace GUI {
|
||||
await ASF.CheckForUpdate().ConfigureAwait(false);
|
||||
|
||||
// Before attempting to connect, initialize our list of CMs
|
||||
Bot.InitializeCMs(Program.GlobalDatabase.CellID, Program.GlobalDatabase.ServerListProvider);
|
||||
await Bot.InitializeCMs(Program.GlobalDatabase.CellID, Program.GlobalDatabase.ServerListProvider).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
foreach (string botName in Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension)) {
|
||||
|
||||
Reference in New Issue
Block a user