From e521c5ee8bb5b49c41fe4933f82536a425ae48cb Mon Sep 17 00:00:00 2001 From: Chomp Date: Wed, 16 Jul 2025 12:23:29 +0100 Subject: [PATCH] Improved handling of mongoId casting inside `PayMoney` --- .../SPTarkov.Server.Core/Services/PaymentService.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs b/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs index 9465552b..42883b5e 100644 --- a/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs @@ -92,6 +92,11 @@ public class PaymentService( // Track the total amount of all currencies. var totalCurrencyAmount = 0d; + // Convert id to mongoId if we know it'll be valid (trader id) + var requestTransactionId = payToTrader + ? new MongoId(request.TransactionId) + : MongoId.Empty(); // Likely flea, use default + // Loop through each type of currency involved in the trade. foreach (var (currencyTpl, currencyAmount) in currencyAmounts) { @@ -120,7 +125,7 @@ public class PaymentService( ); // Only update traders - pmcData.TradersInfo[request.TransactionId].SalesSum += costOfPurchaseInCurrency; + pmcData.TradersInfo[requestTransactionId].SalesSum += costOfPurchaseInCurrency; } } @@ -131,16 +136,16 @@ public class PaymentService( // Convert the handbook price to the trader's currency and update the sales sum. var costOfPurchaseInCurrency = handbookHelper.FromRUB( - GetTraderItemHandbookPriceRouble(request.ItemId, request.TransactionId) ?? 0, + GetTraderItemHandbookPriceRouble(request.ItemId, requestTransactionId) ?? 0, trader.Currency.Value.GetCurrencyTpl() ); - pmcData.TradersInfo[request.TransactionId].SalesSum += costOfPurchaseInCurrency; + pmcData.TradersInfo[requestTransactionId].SalesSum += costOfPurchaseInCurrency; } if (payToTrader) { - traderHelper.LevelUp(request.TransactionId, pmcData); + traderHelper.LevelUp(requestTransactionId, pmcData); } if (logger.IsLogEnabled(LogLevel.Debug))