Skip to content

Commit

Permalink
More bugs slained
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Oct 28, 2015
1 parent 03885ba commit 639067d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
7 changes: 5 additions & 2 deletions ArchiSteamFarm/ArchiSteamFarm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<AssemblyName>ArchiSteamFarm</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -23,7 +24,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand All @@ -39,14 +39,17 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>
</DocumentationFile>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="HtmlAgilityPack, Version=1.4.9.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
Expand Down
2 changes: 1 addition & 1 deletion ArchiSteamFarm/ArchiWebHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal ArchiWebHandler(Bot bot, string apiKey) {
}

internal void Init(SteamClient steamClient, string webAPIUserNonce, string vanityURL) {
if (steamClient == null || steamClient.SteamID == null || string.IsNullOrEmpty(webAPIUserNonce) || string.IsNullOrEmpty(vanityURL)) {
if (steamClient == null || steamClient.SteamID == null || string.IsNullOrEmpty(webAPIUserNonce)) {
return;
}

Expand Down
13 changes: 8 additions & 5 deletions ArchiSteamFarm/CardsFarmer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,21 @@ internal async Task StartFarming() {
// Find the number of badge pages
HtmlDocument badgesDocument = await Bot.ArchiWebHandler.GetBadgePage(1).ConfigureAwait(false);
if (badgesDocument == null) {
Logging.LogGenericWarning(Bot.BotName, "Could not get badges information, farming is stopped!");
return;
}

var maxPages = 1;
HtmlNodeCollection badgesPagesNodeCollection = badgesDocument.DocumentNode.SelectNodes("//a[@class='pagelink']");
if (badgesPagesNodeCollection != null) {
maxPages = (byte) (badgesPagesNodeCollection.Count / 2 + 1); // Don't do this at home
maxPages = (badgesPagesNodeCollection.Count / 2) + 1; // Don't do this at home
}

// Find APPIDs we need to farm
List<uint> appIDs = new List<uint>();
for (var page = 1; page <= maxPages; page++) {
Logging.LogGenericInfo(Bot.BotName, "Checking page: " + page + "/" + maxPages);

if (page > 1) { // Because we fetched page number 1 already
badgesDocument = await Bot.ArchiWebHandler.GetBadgePage(page).ConfigureAwait(false);
if (badgesDocument == null) {
Expand All @@ -71,14 +74,14 @@ internal async Task StartFarming() {
foreach (HtmlNode badgesPageNode in badgesPageNodes) {
string steamLink = badgesPageNode.GetAttributeValue("href", null);
if (steamLink == null) {
page = maxPages; // Break from outer loop
break;
Logging.LogGenericWarning(Bot.BotName, "Couldn't get steamLink for one of the games: " + badgesPageNode.OuterHtml);
continue;
}

uint appID = (uint) Utilities.OnlyNumbers(steamLink);
if (appID == 0) {
page = maxPages; // Break from outer loop
break;
Logging.LogGenericWarning(Bot.BotName, "Couldn't get appID for one of the games: " + badgesPageNode.OuterHtml);
continue;
}

appIDs.Add(appID);
Expand Down
3 changes: 3 additions & 0 deletions ArchiSteamFarm/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ limitations under the License.
*/

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace ArchiSteamFarm {
Expand All @@ -49,10 +50,12 @@ internal static void LogGenericInfo(string botName, string message, [CallerMembe
Log("[*] INFO: " + previousMethodName + "() <" + botName + "> " + message);
}

[Conditional("DEBUG")]
internal static void LogGenericDebug(string botName, string message, [CallerMemberName] string previousMethodName = "") {
Log("[#] DEBUG: " + previousMethodName + "() <" + botName + "> " + message);
}

[Conditional("DEBUG")]
internal static void LogGenericDebug(string message, [CallerMemberName] string previousMethodName = "") {
LogGenericDebug("DEBUG", message, previousMethodName);
}
Expand Down
3 changes: 2 additions & 1 deletion ArchiSteamFarm/Trading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ internal Trading(Bot bot) {
}

internal void CheckTrades() {
Logging.LogGenericDebug("");
if (ParsingTasks < 2) {
ParsingTasks++;
Task.Run(() => ParseActiveTrades());
Expand Down Expand Up @@ -87,7 +88,7 @@ private async Task ParseTrade(SteamTradeOffer tradeOffer) {
}

if (!success) {
Logging.LogGenericWarning(Bot.BotName, "Response to trade " + tradeID + " failed!");
Logging.LogGenericWarning(Bot.BotName, "Response <accept: " + tradeAccepted + "> to trade " + tradeID + " failed!");
}

if (tradeAccepted && success) {
Expand Down

0 comments on commit 639067d

Please sign in to comment.