Skip to content

Commit

Permalink
Crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Feb 26, 2024
1 parent 301b667 commit 035b7a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions BoosterManager/Data/ItemListing.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Text.Json;
using System.Text.Json.Nodes;
using ArchiSteamFarm.Core;
using ArchiSteamFarm.Helpers.Json;

namespace BoosterManager {
internal sealed class ItemListing {
Expand Down Expand Up @@ -38,19 +38,19 @@ internal ItemListing(JsonObject listing) {
throw new InvalidOperationException();
}

uint? appID = listing["asset"]?["appid"]?.GetValue<uint>();
uint? appID = listing["asset"]?["appid"]?.ToString().ToJsonObject<uint>();
if (appID == null) {
ASF.ArchiLogger.LogNullError(appID);
throw new InvalidOperationException();
}

ulong? contextID = listing["asset"]?["contextid"]?.GetValue<ulong>();
ulong? contextID = listing["asset"]?["contextid"]?.ToString().ToJsonObject<ulong>();
if (contextID == null) {
ASF.ArchiLogger.LogNullError(contextID);
throw new InvalidOperationException();
}

ulong? classID = listing["asset"]?["classid"]?.GetValue<ulong>();
ulong? classID = listing["asset"]?["classid"]?.ToString().ToJsonObject<ulong>();
if (classID == null) {
ASF.ArchiLogger.LogNullError(classID);
throw new InvalidOperationException();
Expand Down
5 changes: 3 additions & 2 deletions BoosterManager/Handlers/MarketHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using ArchiSteamFarm.Helpers.Json;
using ArchiSteamFarm.Localization;
using ArchiSteamFarm.Steam;
using ArchiSteamFarm.Steam.Data;
Expand Down Expand Up @@ -42,7 +43,7 @@ internal static async Task<string> GetValue(Bot bot, uint subtractFrom = 0) {

uint listingsValue = 0;
foreach (JsonObject listing in listings.Values) {
uint? price = listing["price"]?.GetValue<uint>();
uint? price = listing["price"]?.ToString().ToJsonObject<uint>();
if (price == null) {
bot.ArchiLogger.LogNullError(price);

Expand Down Expand Up @@ -141,7 +142,7 @@ internal static async Task<string> FindAndRemoveListings(Bot bot, List<ItemIdent
return null;
}

ulong? listingid = listing["listingid"]?.GetValue<ulong>();
ulong? listingid = listing["listingid"]?.ToString().ToJsonObject<ulong>();
if (listingid == null) {
bot.ArchiLogger.LogNullError(listingid);

Expand Down

0 comments on commit 035b7a9

Please sign in to comment.