mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-06 17:10:13 +00:00
Code review
This commit is contained in:
@@ -236,19 +236,17 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
GamesToFarm.Clear();
|
GamesToFarm.Clear();
|
||||||
|
|
||||||
// Find APPIDs we need to farm
|
CheckPage(htmlDocument);
|
||||||
Logging.LogGenericInfo("Checking other pages...", Bot.BotName);
|
|
||||||
|
|
||||||
List<Task> tasks = new List<Task>(maxPages - 1);
|
if (maxPages > 1) {
|
||||||
for (byte page = 1; page <= maxPages; page++) {
|
Logging.LogGenericInfo("Checking other pages...", Bot.BotName);
|
||||||
if (page == 1) {
|
List<Task> tasks = new List<Task>(maxPages - 1);
|
||||||
CheckPage(htmlDocument); // Because we fetched page number 1 already
|
for (byte page = 2; page <= maxPages; page++) {
|
||||||
} else {
|
|
||||||
byte currentPage = page; // We need a copy of variable being passed when in for loops
|
byte currentPage = page; // We need a copy of variable being passed when in for loops
|
||||||
tasks.Add(CheckPage(currentPage));
|
tasks.Add(CheckPage(currentPage));
|
||||||
}
|
}
|
||||||
|
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (GamesToFarm.Count == 0) {
|
if (GamesToFarm.Count == 0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -279,7 +277,26 @@ namespace ArchiSteamFarm {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint appID = (uint) Utilities.OnlyNumbers(steamLink);
|
int index = steamLink.LastIndexOf('/');
|
||||||
|
if (index < 0) {
|
||||||
|
Logging.LogNullError("index", Bot.BotName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
if (steamLink.Length <= index) {
|
||||||
|
Logging.LogNullError("length", Bot.BotName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
steamLink = steamLink.Substring(index);
|
||||||
|
|
||||||
|
uint appID;
|
||||||
|
if (!uint.TryParse(steamLink, out appID)) {
|
||||||
|
Logging.LogNullError("appID", Bot.BotName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (appID == 0) {
|
if (appID == 0) {
|
||||||
Logging.LogNullError("appID", Bot.BotName);
|
Logging.LogNullError("appID", Bot.BotName);
|
||||||
continue;
|
continue;
|
||||||
@@ -301,13 +318,11 @@ namespace ArchiSteamFarm {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
hoursString = Regex.Match(hoursString, @"[0-9\.,]+").Value;
|
float hours = 0;
|
||||||
|
|
||||||
float hours;
|
Match match = Regex.Match(hoursString, @"[0-9\.,]+");
|
||||||
if (string.IsNullOrEmpty(hoursString)) {
|
if (match.Success) {
|
||||||
hours = 0;
|
float.TryParse(match.Value, NumberStyles.Number, CultureInfo.InvariantCulture, out hours);
|
||||||
} else {
|
|
||||||
hours = float.Parse(hoursString, CultureInfo.InvariantCulture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GamesToFarm[appID] = hours;
|
GamesToFarm[appID] = hours;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ArchiSteamFarm {
|
namespace ArchiSteamFarm {
|
||||||
@@ -33,32 +32,6 @@ namespace ArchiSteamFarm {
|
|||||||
await Task.Delay(miliseconds).ConfigureAwait(false);
|
await Task.Delay(miliseconds).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ulong OnlyNumbers(string inputString) {
|
|
||||||
if (string.IsNullOrEmpty(inputString)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
string resultString = OnlyNumbersString(inputString);
|
|
||||||
if (string.IsNullOrEmpty(resultString)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong result;
|
|
||||||
if (!ulong.TryParse(resultString, out result)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string OnlyNumbersString(string text) {
|
|
||||||
if (string.IsNullOrEmpty(text)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Regex.Replace(text, @"[^\d]", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static uint GetCharCountInString(string s, char c) {
|
internal static uint GetCharCountInString(string s, char c) {
|
||||||
if (string.IsNullOrEmpty(s)) {
|
if (string.IsNullOrEmpty(s)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user