Compare commits

...

29 Commits

Author SHA1 Message Date
JustArchi
10381dfdba Add extra safeguard in STD against zeros 2020-11-21 17:07:18 +01:00
JustArchi
310048acf9 Bump 2020-11-21 15:43:43 +01:00
Vitaliy
3ac04c6aaf Fix parsing tags in GetActiveTradeOffers (#2060)
* Fix parsing tags in GetActiveTradeOffers

* Accept empty values in Tag constructor

* Throw on null value in constructor

* Fix mindless copypaste
2020-11-21 15:42:19 +01:00
JustArchi
6a8a3b9c8a Travis: using you is a mistake 2020-11-21 14:39:17 +01:00
JustArchi
d892661acd Travis: OS updates 2020-11-21 14:34:35 +01:00
JustArchi
dd1bb75b8a Make --ignore-unsupported-environment emit a warning instead of nothing 2020-11-21 14:18:23 +01:00
JustArchi
2d7979e9ee STD: Save information about submitted tokens/keys
This also allows us to resubmit the same app/package/depot upon token/key change, which didn't happen previously.
2020-11-21 13:54:09 +01:00
GitHub Action
f6c1c04394 Automatic translations update 2020-11-21 02:09:09 +00:00
GitHub Action
38e1ece16f Automatic translations update 2020-11-20 02:09:16 +00:00
dependabot-preview[bot]
7513f136ba Bump ASF-ui from d066be5 to 1f52d6a
Bumps [ASF-ui](https://github.com/JustArchiNET/ASF-ui) from `d066be5` to `1f52d6a`.
- [Release notes](https://github.com/JustArchiNET/ASF-ui/releases)
- [Commits](d066be50da...1f52d6a635)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-20 01:31:20 +00:00
JustArchi
f429a7b618 Misc CIs 2020-11-19 21:32:06 +01:00
JustArchi
1c1c9d107b Try to guess what is wrong with GitHub 2020-11-19 21:21:48 +01:00
JustArchi
f259d2a846 Misc fixes 2020-11-19 21:08:50 +01:00
JustArchi
792babb049 Misc cleanup 2020-11-19 21:04:45 +01:00
JustArchi
a34b1724b1 Misc cleanup 2020-11-19 21:03:09 +01:00
JustArchi
51ad3b0c76 Improve runtime compatibility
This commit does 3 things:
- adds safeguard against running generic-netf in unsupported environments
- adds notice about providing ASF with unknown command-line arguments
- refactors old pre+post args parsing into a single window
2020-11-19 21:01:17 +01:00
GitHub Action
fc36174953 Automatic translations update 2020-11-19 02:08:54 +00:00
dependabot-preview[bot]
7e731b9826 Bump ASF-ui from c4f2a07 to d066be5
Bumps [ASF-ui](https://github.com/JustArchiNET/ASF-ui) from `c4f2a07` to `d066be5`.
- [Release notes](https://github.com/JustArchiNET/ASF-ui/releases)
- [Commits](c4f2a0703a...d066be50da)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-19 01:33:57 +00:00
GitHub Action
63bec34d7a Automatic translations update 2020-11-18 02:09:09 +00:00
dependabot-preview[bot]
fc97cc7d70 Bump wiki from 748e008 to f32a499
Bumps [wiki](https://github.com/JustArchiNET/ArchiSteamFarm.wiki) from `748e008` to `f32a499`.
- [Release notes](https://github.com/JustArchiNET/ArchiSteamFarm.wiki/releases)
- [Commits](748e0087ff...f32a499cf9)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-18 01:48:04 +00:00
dependabot-preview[bot]
4e302d0b7a Bump ASF-ui from 021a4e0 to c4f2a07
Bumps [ASF-ui](https://github.com/JustArchiNET/ASF-ui) from `021a4e0` to `c4f2a07`.
- [Release notes](https://github.com/JustArchiNET/ASF-ui/releases)
- [Commits](021a4e0f26...c4f2a0703a)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-18 01:32:43 +00:00
JustArchi
3bdd6c76b9 Update ArchiSteamFarm.sln.DotSettings 2020-11-17 20:13:29 +01:00
JustArchi
e0e26f57aa Bump 2020-11-17 14:14:20 +01:00
JustArchi
b51e4c459c Fix ASF being unable to chmod +x things anymore 2020-11-17 14:13:36 +01:00
JustArchi
f4a4f0c19d Update Directory.Build.props 2020-11-17 11:55:11 +01:00
JustArchi
88c659ac77 Update TrimmerRoots.xml 2020-11-17 11:50:00 +01:00
GitHub Action
49841fa27e Automatic translations update 2020-11-17 02:08:37 +00:00
dependabot-preview[bot]
96ed2fa316 Bump wiki from d586a43 to 1b93223
Bumps [wiki](https://github.com/JustArchiNET/ArchiSteamFarm.wiki) from `d586a43` to `1b93223`.
- [Release notes](https://github.com/JustArchiNET/ArchiSteamFarm.wiki/releases)
- [Commits](d586a43238...1b932239e3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-17 01:32:28 +00:00
JustArchi
39c5529de0 Bump 2020-11-16 19:21:39 +01:00
47 changed files with 1365 additions and 1240 deletions

View File

@@ -248,7 +248,7 @@ jobs:
Start-Job -Name "$variant" $PublishBlock -ArgumentList "$variant"
}
Get-Job | Receive-Job -Wait -AutoRemoveJob
Get-Job | Receive-Job -Wait
- name: Upload ASF-generic
continue-on-error: true

View File

@@ -113,4 +113,4 @@ matrix:
- os: osx
# Ref: https://docs.travis-ci.com/user/reference/osx
dotnet: 5.0.100 # For OSX, we need absolute dotnet version until https://github.com/dotnet/core-setup/issues/4187 is resolved
osx_image: xcode11.4
osx_image: xcode12.2

2
ASF-ui

Submodule ASF-ui updated: 021a4e0f26...1f52d6a635

View File

@@ -25,7 +25,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using ArchiSteamFarm.Collections;
using ArchiSteamFarm.Helpers;
using Newtonsoft.Json;
using SteamKit2;
@@ -47,13 +46,13 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
private readonly ConcurrentDictionary<uint, ulong> PackageTokens = new();
[JsonProperty(Required = Required.DisallowNull)]
private readonly ConcurrentHashSet<uint> SubmittedAppIDs = new();
private readonly ConcurrentDictionary<uint, ulong> SubmittedApps = new();
[JsonProperty(Required = Required.DisallowNull)]
private readonly ConcurrentHashSet<uint> SubmittedDepotIDs = new();
private readonly ConcurrentDictionary<uint, string> SubmittedDepots = new();
[JsonProperty(Required = Required.DisallowNull)]
private readonly ConcurrentHashSet<uint> SubmittedPackageIDs = new();
private readonly ConcurrentDictionary<uint, ulong> SubmittedPackages = new();
[JsonProperty(Required = Required.DisallowNull)]
internal uint LastChangeNumber { get; private set; }
@@ -62,9 +61,9 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
internal ulong GetAppToken(uint appID) => AppTokens[appID];
internal Dictionary<uint, ulong> GetAppTokensForSubmission() => AppTokens.Where(appToken => !SubmittedAppIDs.Contains(appToken.Key)).ToDictionary(appToken => appToken.Key, appToken => appToken.Value);
internal Dictionary<uint, string> GetDepotKeysForSubmission() => DepotKeys.Where(depotKey => !SubmittedDepotIDs.Contains(depotKey.Key)).ToDictionary(depotKey => depotKey.Key, depotKey => depotKey.Value);
internal Dictionary<uint, ulong> GetPackageTokensForSubmission() => PackageTokens.Where(packageToken => !SubmittedPackageIDs.Contains(packageToken.Key)).ToDictionary(packageToken => packageToken.Key, packageToken => packageToken.Value);
internal Dictionary<uint, ulong> GetAppTokensForSubmission() => AppTokens.Where(appToken => (appToken.Value > 0) && (!SubmittedApps.TryGetValue(appToken.Key, out ulong token) || (appToken.Value != token))).ToDictionary(appToken => appToken.Key, appToken => appToken.Value);
internal Dictionary<uint, string> GetDepotKeysForSubmission() => DepotKeys.Where(depotKey => !string.IsNullOrEmpty(depotKey.Value) && (!SubmittedDepots.TryGetValue(depotKey.Key, out string? key) || (depotKey.Value != key))).ToDictionary(depotKey => depotKey.Key, depotKey => depotKey.Value);
internal Dictionary<uint, ulong> GetPackageTokensForSubmission() => PackageTokens.Where(packageToken => (packageToken.Value > 0) && (!SubmittedPackages.TryGetValue(packageToken.Key, out ulong token) || (packageToken.Value != token))).ToDictionary(packageToken => packageToken.Key, packageToken => packageToken.Value);
internal static async Task<GlobalCache> Load() {
if (!File.Exists(SharedFilePath)) {
@@ -180,12 +179,6 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
}
AppTokens[appID] = appToken;
if (appToken == 0) {
// Backend is not interested in zero access tokens
SubmittedAppIDs.Add(appID);
}
save = true;
}
@@ -195,10 +188,6 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
}
AppTokens[appID] = 0;
// Backend is not interested in zero access tokens
SubmittedAppIDs.Add(appID);
save = true;
}
@@ -226,12 +215,6 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
}
DepotKeys[depotKeyResult.DepotID] = depotKey;
if (string.IsNullOrEmpty(depotKey)) {
// Backend is not interested in zero depot keys
SubmittedDepotIDs.Add(depotKeyResult.DepotID);
}
save = true;
}
@@ -253,12 +236,6 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
}
PackageTokens[packageID] = packageToken;
if (packageToken == 0) {
// Backend is not interested in zero access tokens
SubmittedPackageIDs.Add(packageID);
}
save = true;
}
@@ -267,36 +244,32 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
}
}
internal async Task UpdateSubmittedData(IReadOnlyCollection<uint> appIDs, IReadOnlyCollection<uint> packageIDs, IReadOnlyCollection<uint> depotIDs) {
if (appIDs == null) {
throw new ArgumentNullException(nameof(appIDs));
internal async Task UpdateSubmittedData(IReadOnlyDictionary<uint, ulong> apps, IReadOnlyDictionary<uint, ulong> packages, IReadOnlyDictionary<uint, string> depots) {
if (apps == null) {
throw new ArgumentNullException(nameof(apps));
}
if (packageIDs == null) {
throw new ArgumentNullException(nameof(packageIDs));
if (packages == null) {
throw new ArgumentNullException(nameof(packages));
}
if (depotIDs == null) {
throw new ArgumentNullException(nameof(depotIDs));
if (depots == null) {
throw new ArgumentNullException(nameof(depots));
}
bool save = false;
foreach (uint _ in appIDs.Where(appID => SubmittedAppIDs.Add(appID))) {
save = true;
foreach ((uint appID, ulong token) in apps) {
SubmittedApps[appID] = token;
}
foreach (uint _ in packageIDs.Where(packageID => SubmittedPackageIDs.Add(packageID))) {
save = true;
foreach ((uint packageID, ulong token) in packages) {
SubmittedPackages[packageID] = token;
}
foreach (uint _ in depotIDs.Where(depotID => SubmittedDepotIDs.Add(depotID))) {
save = true;
foreach ((uint depotID, string key) in depots) {
SubmittedDepots[depotID] = key;
}
if (save) {
await Save().ConfigureAwait(false);
}
}
}
}

View File

@@ -482,7 +482,7 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper {
ASF.ArchiLogger.LogGenericInfo($"Data successfully submitted. Newly registered apps/subs/depots: {response.Content.Data.NewAppsCount}/{response.Content.Data.NewSubsCount}/{response.Content.Data.NewDepotsCount}.");
await GlobalCache.UpdateSubmittedData(appTokens.Keys, packageTokens.Keys, depotKeys.Keys).ConfigureAwait(false);
await GlobalCache.UpdateSubmittedData(appTokens, packageTokens, depotKeys).ConfigureAwait(false);
} finally {
SubmissionSemaphore.Release();
}

View File

@@ -3,7 +3,7 @@
<s:Boolean x:Key="/Default/CodeEditing/TypingAssist/Asp/FormatOnEnter/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeEditing/TypingAssist/FormatOnPaste/@EntryValue">FullFormat</s:String>
<s:Boolean x:Key="/Default/CodeEditing/TypingAssist/SmartIndentOnEnter/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/TypingAssist/VirtualSpaceOnEnter/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/TypingAssist/VirtualSpaceOnEnter/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=Strings_002E_003F_003F_002D_003F_003F_002Eresx/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=CF84911C_002D2C4C_002D4195_002D8AF3_002DABBB6D3DE9AA_002Fd_003Awww/@EntryIndexedValue">ExplicitlyExcluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/GeneratedFilesAndFolders/=CF84911C_002D2C4C_002D4195_002D8AF3_002DABBB6D3DE9AA_002Fd_003Awww/@EntryIndexedValue">CF84911C-2C4C-4195-8AF3-ABBB6D3DE9AA/d:www</s:String>

View File

@@ -1527,7 +1527,8 @@ namespace ArchiSteamFarm {
string? value = tag["internal_name"].AsString();
if (string.IsNullOrEmpty(value)) {
// Apparently, name can be empty, but not null
if (value == null) {
Bot.ArchiLogger.LogNullError(nameof(value));
return null;

View File

@@ -261,7 +261,7 @@ namespace ArchiSteamFarm.Json {
internal Tag(string identifier, string value) {
Identifier = !string.IsNullOrEmpty(identifier) ? identifier : throw new ArgumentNullException(nameof(identifier));
Value = !string.IsNullOrEmpty(value) ? value : throw new ArgumentNullException(nameof(value));
Value = value ?? throw new ArgumentNullException(nameof(value));
}
[JsonConstructor]

File diff suppressed because it is too large Load Diff

View File

@@ -724,4 +724,6 @@
</root>

View File

@@ -723,4 +723,6 @@ StackTrace:
</root>

View File

@@ -723,4 +723,6 @@ StackTrace:
</root>

View File

@@ -736,4 +736,6 @@ Prozesslaufzeit: {1}</value>
<value>Ergebnis: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
</root>

View File

@@ -692,4 +692,6 @@ StackTrace:
</root>

View File

@@ -735,4 +735,10 @@ Tiempo de actividad del proceso: {1}</value>
<value>Resultado: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
<data name="WarningUnsupportedEnvironment" xml:space="preserve">
<value>Estás intentando ejecutar la variante {0} de ASF en un entorno no soportado: {1}. Proporciona el argumento --ignore-unsupported-environment si realmente sabes lo que estás haciendo.</value>
</data>
<data name="WarningUnknownCommandLineArgument" xml:space="preserve">
<value>Argumento de línea de comandos desconocido: {0}</value>
</data>
</root>

View File

@@ -717,4 +717,6 @@ StackTrace:
</root>

View File

@@ -366,7 +366,7 @@ StackTrace :
<value>Commande inconnue !</value>
</data>
<data name="WarningCouldNotCheckBadges" xml:space="preserve">
<value>Impossible d'obtenir les informations des badges, nous réessayerons plus tard !</value>
<value>Impossible d'obtenir des informations sur les badges, nous allons réessayer plus tard !</value>
</data>
<data name="WarningCouldNotCheckCardsStatus" xml:space="preserve">
<value>Impossible de vérifier les cartes restantes pour : {0} ({1}), nous réessayerons plus tard !</value>
@@ -724,7 +724,18 @@ Durée de fonctionnement : {1}</value>
<data name="IPCConfigChanged" xml:space="preserve">
<value>La configuration IPC a été modifiée !</value>
</data>
<data name="BotTradeOfferResult" xml:space="preserve">
<value>L'offre d'échange {0} est déterminée comme étant {1} à cause de {2}.</value>
<comment>{0} will be replaced by trade offer ID (number), {1} will be replaced by internal ASF enum name, {2} will be replaced by technical reason why the trade was determined to be in this state</comment>
</data>
<data name="BotInvalidPasswordDuringLogin" xml:space="preserve">
<value>Le code d'erreur InvalidPassword a été reçu {0} fois de suite. Votre mot de passe pour ce compte est probablement erroné, abandon!</value>
<comment>{0} will be replaced by maximum allowed number of failed login attempts</comment>
</data>
<data name="Result" xml:space="preserve">
<value>Résultat: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
</root>

View File

@@ -642,6 +642,8 @@ StackTrace:

View File

@@ -721,4 +721,6 @@ StackTrace: {2}</value>
</root>

View File

@@ -673,4 +673,6 @@
</root>

View File

@@ -734,4 +734,6 @@ Tempo di attività: {1}</value>
<value>Risultato: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
</root>

View File

@@ -733,4 +733,6 @@ Process uptime: {1}</value>
<value>結果: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
</root>

View File

@@ -723,4 +723,6 @@ StackTrace:
</root>

View File

@@ -723,4 +723,6 @@ StackTrace:
</root>

View File

@@ -736,4 +736,6 @@ Darbspējas laiks: {1}</value>
<value>Rezultāts: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
</root>

View File

@@ -735,4 +735,6 @@ Proces uptime: {1}</value>
<value>Resultaat: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
</root>

View File

@@ -736,4 +736,10 @@ Czas procesu: {1}</value>
<value>Wynik: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
<data name="WarningUnsupportedEnvironment" xml:space="preserve">
<value>Próbujesz uruchomić wariant ASF {0} w nieobsługiwanym środowisku: {1}. Podaj argument --ignore-unsupported-environment, jeśli naprawdę wiesz, co robisz.</value>
</data>
<data name="WarningUnknownCommandLineArgument" xml:space="preserve">
<value>Nieznany argument wiersza poleceń: {0}</value>
</data>
</root>

View File

@@ -736,4 +736,6 @@ Tempo de execução: {1}</value>
<value>Resultado: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
</root>

View File

@@ -557,4 +557,6 @@ StackTrace:
</root>

View File

@@ -736,4 +736,10 @@ Process uptime: {1}</value>
<value>Result: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
<data name="WarningUnsupportedEnvironment" xml:space="preserve">
<value>You're attempting to run {0} variant of ASF in unsupported environment: {1}. Supply --ignore-unsupported-environment argument if you really know what you're doing.</value>
</data>
<data name="WarningUnknownCommandLineArgument" xml:space="preserve">
<value>Unknown command-line argument: {0}</value>
</data>
</root>

View File

@@ -727,4 +727,6 @@ Proces: {1}</value>
</root>

View File

@@ -736,4 +736,10 @@
<value>Результат: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
<data name="WarningUnsupportedEnvironment" xml:space="preserve">
<value>Вы пытаетесь запустить ASF в варианте {0} в неподдерживаемом окружении: {1}. Используйте аргумент --ignore-unsupported-environment если вы действительно понимаете, что делаете.</value>
</data>
<data name="WarningUnknownCommandLineArgument" xml:space="preserve">
<value>Неизвестный аргумент командной строки: {0}</value>
</data>
</root>

View File

@@ -705,4 +705,6 @@ Interaktívna konzola je teraz aktívna, napíšte "c" pre vstup do príkazovéh
</root>

View File

@@ -571,6 +571,8 @@ StackTrace:

View File

@@ -624,6 +624,8 @@ StackTrace:

View File

@@ -736,4 +736,6 @@ Süreç çalışma zamanı: {1}</value>
<value>Sonuç: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
</root>

View File

@@ -736,4 +736,10 @@
<value>Результат: {0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
<data name="WarningUnsupportedEnvironment" xml:space="preserve">
<value>Ви намагаєтеся запустити ASF у варіанті {0} у непідтримуваному середовищі: {1}. Скористуйтеся аргументом --ignore-unsupported-environment якщо ви справді розумієте, що робите.</value>
</data>
<data name="WarningUnknownCommandLineArgument" xml:space="preserve">
<value>Невідомий аргумент командного рядка: {0}</value>
</data>
</root>

View File

@@ -723,4 +723,6 @@ StackTrace:
</root>

View File

@@ -736,4 +736,10 @@
<value>结果:{0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
<data name="WarningUnsupportedEnvironment" xml:space="preserve">
<value>您正尝试在不受支持的环境 {1} 中运行 ASF 的 {0} 版本。如果您了解自己在做什么,请提供 --ignore-unsupported-environment 参数。</value>
</data>
<data name="WarningUnknownCommandLineArgument" xml:space="preserve">
<value>未知命令行参数:{0}</value>
</data>
</root>

View File

@@ -723,4 +723,6 @@
</root>

View File

@@ -729,4 +729,6 @@
<value>結果:{0}</value>
<comment>{0} will be replaced by generic result of various functions that use this string</comment>
</data>
</root>

View File

@@ -40,8 +40,13 @@ namespace ArchiSteamFarm {
private static Mutex? SingleInstance;
internal static void CoreInit() {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Console.IsOutputRedirected) {
internal static void CoreInit(bool systemRequired) {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
if (systemRequired) {
WindowsKeepSystemActive();
}
if (!Console.IsOutputRedirected) {
// Normally we should use UTF-8 encoding as it's the most correct one for our case, and we already use it on other OSes such as Linux
// However, older Windows versions, mainly 7/8.1 can't into UTF-8 without appropriate console font, and expecting from users to change it manually is unwanted
// As irrational as it can sound, those versions actually can work with unicode encoding instead, as they magically map it into proper chars despite of incorrect font
@@ -56,6 +61,7 @@ namespace ArchiSteamFarm {
WindowsDisableQuickEditMode();
}
}
}
internal static ICrossProcessSemaphore CreateCrossProcessSemaphore(string objectName) {
if (string.IsNullOrEmpty(objectName)) {
@@ -67,17 +73,11 @@ namespace ArchiSteamFarm {
return new CrossProcessFileBasedSemaphore(resourceName);
}
internal static void Init(bool systemRequired, GlobalConfig.EOptimizationMode optimizationMode) {
internal static void Init(GlobalConfig.EOptimizationMode optimizationMode) {
if (!Enum.IsDefined(typeof(GlobalConfig.EOptimizationMode), optimizationMode)) {
throw new ArgumentNullException(nameof(optimizationMode));
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
if (systemRequired) {
WindowsKeepSystemActive();
}
}
switch (optimizationMode) {
case GlobalConfig.EOptimizationMode.MaxPerformance:
// No specific tuning required for now, ASF is optimized for max performance by default
@@ -151,6 +151,36 @@ namespace ArchiSteamFarm {
SingleInstance = null;
}
internal static bool VerifyEnvironment() {
#if NETFRAMEWORK
// This is .NET Framework build, we support that one only on mono for platforms not supported by .NET Core
// We're not going to analyze source builds, as we don't know what changes the author has made, assume they have a point
if (SharedInfo.BuildInfo.IsCustomBuild) {
return true;
}
// All windows variants have valid .NET Core build, and generic-netf is supported only on mono
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || !RuntimeCompatibility.IsRunningOnMono) {
return false;
}
return RuntimeInformation.OSArchitecture switch {
// Sadly we can't tell a difference between ARMv6 and ARMv7 reliably, we'll believe that this linux-arm user knows what he's doing and he's indeed in need of generic-netf on ARMv6
Architecture.Arm => true,
// Apart from real x86, this also covers all unknown architectures, such as sparc, ppc64, and anything else Mono might support, we're fine with that
Architecture.X86 => true,
// Everything else is covered by .NET Core
_ => false
};
#else
// This is .NET Core build, we support all scenarios
return true;
#endif
}
private static string GetOsResourceName(string objectName) {
if (string.IsNullOrEmpty(objectName)) {
throw new ArgumentNullException(nameof(objectName));
@@ -215,8 +245,10 @@ namespace ArchiSteamFarm {
internal const uint EnableQuickEditMode = 0x0040;
internal const sbyte StandardInputHandle = -10;
[DllImport("libc", CharSet = CharSet.Unicode, EntryPoint = "chmod", SetLastError = true)]
#pragma warning disable CA2101
[DllImport("libc", EntryPoint = "chmod", SetLastError = true)]
internal static extern int Chmod(string path, int mode);
#pragma warning restore CA2101
[DllImport("kernel32.dll")]
internal static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode);

View File

@@ -45,6 +45,7 @@ namespace ArchiSteamFarm {
private static readonly TaskCompletionSource<byte> ShutdownResetEvent = new();
private static bool IgnoreUnsupportedEnvironment;
private static bool SystemRequired;
internal static async Task Exit(byte exitCode = 0) {
@@ -119,38 +120,29 @@ namespace ArchiSteamFarm {
Target.Register<HistoryTarget>(HistoryTarget.TargetName);
Target.Register<SteamTarget>(SteamTarget.TargetName);
if (!await InitCore(args).ConfigureAwait(false)) {
if (!await InitCore(args).ConfigureAwait(false) || !await InitASF().ConfigureAwait(false)) {
await Exit(1).ConfigureAwait(false);
return;
}
}
await InitASF(args).ConfigureAwait(false);
}
private static async Task InitASF(IReadOnlyCollection<string>? args) {
OS.CoreInit();
Console.Title = SharedInfo.ProgramIdentifier;
ASF.ArchiLogger.LogGenericInfo(SharedInfo.ProgramIdentifier);
private static async Task<bool> InitASF() {
if (!await InitGlobalConfigAndLanguage().ConfigureAwait(false)) {
return;
return false;
}
if (ASF.GlobalConfig == null) {
throw new InvalidOperationException(nameof(ASF.GlobalConfig));
}
// Parse post-init args
if (args != null) {
ParsePostInitArgs(args);
OS.Init(ASF.GlobalConfig.OptimizationMode);
if (!await InitGlobalDatabaseAndServices().ConfigureAwait(false)) {
return false;
}
OS.Init(SystemRequired, ASF.GlobalConfig.OptimizationMode);
await InitGlobalDatabaseAndServices().ConfigureAwait(false);
await ASF.Init().ConfigureAwait(false);
return true;
}
private static async Task<bool> InitCore(IReadOnlyCollection<string>? args) {
@@ -173,9 +165,9 @@ namespace ArchiSteamFarm {
}
}
// Parse pre-init args
// Parse args
if (args != null) {
ParsePreInitArgs(args);
ParseArgs(args);
}
bool uniqueInstance = OS.RegisterProcess();
@@ -188,6 +180,24 @@ namespace ArchiSteamFarm {
return false;
}
OS.CoreInit(SystemRequired);
Console.Title = SharedInfo.ProgramIdentifier;
ASF.ArchiLogger.LogGenericInfo(SharedInfo.ProgramIdentifier);
if (!OS.VerifyEnvironment()) {
string errorMessage = string.Format(CultureInfo.CurrentCulture, Strings.WarningUnsupportedEnvironment, SharedInfo.BuildInfo.Variant, OS.Variant);
if (!IgnoreUnsupportedEnvironment) {
ASF.ArchiLogger.LogGenericError(errorMessage);
await Task.Delay(10000).ConfigureAwait(false);
return false;
}
ASF.ArchiLogger.LogGenericWarning(errorMessage);
}
return true;
}
@@ -205,8 +215,7 @@ namespace ArchiSteamFarm {
if (globalConfig == null) {
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorGlobalConfigNotLoaded, globalConfigFile));
await Task.Delay(5 * 1000).ConfigureAwait(false);
await Exit(1).ConfigureAwait(false);
await Task.Delay(5000).ConfigureAwait(false);
return false;
}
@@ -287,7 +296,7 @@ namespace ArchiSteamFarm {
return true;
}
private static async Task InitGlobalDatabaseAndServices() {
private static async Task<bool> InitGlobalDatabaseAndServices() {
string globalDatabaseFile = ASF.GetFilePath(ASF.EFileType.Database);
if (string.IsNullOrEmpty(globalDatabaseFile)) {
@@ -296,19 +305,18 @@ namespace ArchiSteamFarm {
if (!File.Exists(globalDatabaseFile)) {
ASF.ArchiLogger.LogGenericInfo(Strings.Welcome);
await Task.Delay(10 * 1000).ConfigureAwait(false);
await Task.Delay(10000).ConfigureAwait(false);
ASF.ArchiLogger.LogGenericWarning(Strings.WarningPrivacyPolicy);
await Task.Delay(5 * 1000).ConfigureAwait(false);
await Task.Delay(5000).ConfigureAwait(false);
}
GlobalDatabase? globalDatabase = await GlobalDatabase.CreateOrLoad(globalDatabaseFile).ConfigureAwait(false);
if (globalDatabase == null) {
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorDatabaseInvalid, globalDatabaseFile));
await Task.Delay(5 * 1000).ConfigureAwait(false);
await Exit(1).ConfigureAwait(false);
await Task.Delay(5000).ConfigureAwait(false);
return;
return false;
}
ASF.InitGlobalDatabase(globalDatabase);
@@ -343,6 +351,8 @@ namespace ArchiSteamFarm {
}
WebBrowser.Init();
return true;
}
private static async Task<bool> InitShutdownSequence() {
@@ -413,7 +423,7 @@ namespace ArchiSteamFarm {
e.SetObserved();
}
private static void ParsePostInitArgs(IReadOnlyCollection<string> args) {
private static void ParseArgs(IReadOnlyCollection<string> args) {
if (args == null) {
throw new ArgumentNullException(nameof(args));
}
@@ -424,49 +434,7 @@ namespace ArchiSteamFarm {
if (!string.IsNullOrEmpty(envCryptKey)) {
HandleCryptKeyArgument(envCryptKey!);
}
} catch (Exception e) {
ASF.ArchiLogger.LogGenericException(e);
}
bool cryptKeyNext = false;
foreach (string arg in args) {
switch (arg) {
case "--cryptkey" when !cryptKeyNext:
cryptKeyNext = true;
break;
case "--no-restart" when !cryptKeyNext:
RestartAllowed = false;
break;
case "--process-required" when !cryptKeyNext:
ProcessRequired = true;
break;
case "--system-required" when !cryptKeyNext:
SystemRequired = true;
break;
default:
if (cryptKeyNext) {
cryptKeyNext = false;
HandleCryptKeyArgument(arg);
} else if ((arg.Length > 11) && arg.StartsWith("--cryptkey=", StringComparison.Ordinal)) {
HandleCryptKeyArgument(arg.Substring(11));
}
break;
}
}
}
private static void ParsePreInitArgs(IReadOnlyCollection<string> args) {
if (args == null) {
throw new ArgumentNullException(nameof(args));
}
try {
string? envNetworkGroup = Environment.GetEnvironmentVariable(SharedInfo.EnvironmentVariableNetworkGroup);
if (!string.IsNullOrEmpty(envNetworkGroup)) {
@@ -482,21 +450,45 @@ namespace ArchiSteamFarm {
ASF.ArchiLogger.LogGenericException(e);
}
bool cryptKeyNext = false;
bool networkGroupNext = false;
bool pathNext = false;
foreach (string arg in args) {
switch (arg) {
case "--network-group" when !networkGroupNext && !pathNext:
case "--cryptkey" when !cryptKeyNext && !networkGroupNext && !pathNext:
cryptKeyNext = true;
break;
case "--ignore-unsupported-environment" when !cryptKeyNext && !networkGroupNext && !pathNext:
IgnoreUnsupportedEnvironment = true;
break;
case "--network-group" when !cryptKeyNext && !networkGroupNext && !pathNext:
networkGroupNext = true;
break;
case "--path" when !networkGroupNext && !pathNext:
case "--no-restart" when !cryptKeyNext && !networkGroupNext && !pathNext:
RestartAllowed = false;
break;
case "--process-required" when !cryptKeyNext && !networkGroupNext && !pathNext:
ProcessRequired = true;
break;
case "--path" when !cryptKeyNext && !networkGroupNext && !pathNext:
pathNext = true;
break;
case "--system-required" when !cryptKeyNext && !networkGroupNext && !pathNext:
SystemRequired = true;
break;
default:
if (networkGroupNext) {
if (cryptKeyNext) {
cryptKeyNext = false;
HandleCryptKeyArgument(arg);
} else if (networkGroupNext) {
networkGroupNext = false;
HandleNetworkGroupArgument(arg);
} else if (pathNext) {
@@ -507,10 +499,18 @@ namespace ArchiSteamFarm {
case > 16 when arg.StartsWith("--network-group=", StringComparison.Ordinal):
HandleNetworkGroupArgument(arg.Substring(16));
break;
case > 11 when arg.StartsWith("--cryptkey=", StringComparison.Ordinal):
HandleCryptKeyArgument(arg.Substring(11));
break;
case > 7 when arg.StartsWith("--path=", StringComparison.Ordinal):
HandlePathArgument(arg.Substring(7));
break;
default:
ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownCommandLineArgument, arg));
break;
}
}

View File

@@ -1,4 +1,8 @@
<linker>
<!-- We include System.Runtime for plugins usage -->
<!-- All below entries are dedicated to our official STD plugin -->
<assembly fullname="System.Collections.Immutable">
<type fullname="System.Collections.Immutable.ImmutableDictionary" />
</assembly>
<assembly fullname="System.Runtime" />
</linker>

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>5.0.0.0</Version>
<Version>5.0.0.4</Version>
</PropertyGroup>
<PropertyGroup>

View File

@@ -279,7 +279,7 @@ after_test:
}
Get-Job | Receive-Job -Wait -AutoRemoveJob
Get-Job | Receive-Job -Wait
deploy: off
notifications:
- provider: Webhook

2
wiki

Submodule wiki updated: d586a43238...c9702b50e3