null guards go brr
This commit is contained in:
@@ -480,7 +480,7 @@ public class ProfileHelper(
|
||||
pointsToAddToSkill *= skillProgressRate;
|
||||
}
|
||||
|
||||
if (_inventoryConfig.SkillGainMultipliers[skill.ToString()] != null)
|
||||
if (_inventoryConfig.SkillGainMultipliers.TryGetValue(skill.ToString(), out var _))
|
||||
pointsToAddToSkill *= _inventoryConfig.SkillGainMultipliers[skill.ToString()];
|
||||
|
||||
profileSkill.Progress += pointsToAddToSkill;
|
||||
|
||||
@@ -414,7 +414,7 @@ public class TradeHelper(
|
||||
(double)assortBeingPurchased.Upd?.BuyRestrictionMax,
|
||||
pmcData.Info.GameVersion
|
||||
);
|
||||
if ((traderPurchaseData?.PurchaseCount ?? 0 + count) > traderItemPurchaseLimit)
|
||||
if (((traderPurchaseData?.PurchaseCount ?? 0) + count) > traderItemPurchaseLimit)
|
||||
{
|
||||
throw new Exception(
|
||||
$"Unable to purchase: {count} items, this would exceed your purchase limit of {traderItemPurchaseLimit} from the trader: {traderId} assort: {assortId} this refresh"
|
||||
|
||||
@@ -92,7 +92,7 @@ public class TraderAssortHelper(
|
||||
continue;
|
||||
}
|
||||
|
||||
assortToAdjust.Upd.BuyRestrictionCurrent = (int)assortPurchasesfromTrader[assortId.Key].PurchaseCount;
|
||||
assortToAdjust.Upd.BuyRestrictionCurrent = (int)(assortPurchasesfromTrader[assortId.Key].PurchaseCount ?? 0);
|
||||
}
|
||||
|
||||
// Get rid of quest locked assorts
|
||||
|
||||
@@ -441,7 +441,8 @@ public class TraderHelper(
|
||||
|
||||
// Null guard when dict doesnt exist
|
||||
|
||||
if (profile.TraderPurchases[traderId][purchasedItem.ItemId] is null)
|
||||
if (profile.TraderPurchases[traderId][purchasedItem.ItemId].PurchaseCount is null
|
||||
|| profile.TraderPurchases[traderId][purchasedItem.ItemId].PurchaseTimestamp is null)
|
||||
{
|
||||
profile.TraderPurchases[traderId][purchasedItem.ItemId] = new TraderPurchaseData
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user