diff --git a/Libraries/SPTarkov.Server.Core/Controllers/InventoryController.cs b/Libraries/SPTarkov.Server.Core/Controllers/InventoryController.cs
index 0571cc8a..8d22f7e6 100644
--- a/Libraries/SPTarkov.Server.Core/Controllers/InventoryController.cs
+++ b/Libraries/SPTarkov.Server.Core/Controllers/InventoryController.cs
@@ -179,7 +179,7 @@ public class InventoryController(
/// Players PMC profile
///
/// Session/Player id
- public void SetFavoriteItem(PmcData pmcData, SetFavoriteItems request, string sessionId)
+ public void SetFavoriteItem(PmcData pmcData, SetFavoriteItems request, MongoId sessionId)
{
// The client sends the full list of favorite items, so clear the current favorites
pmcData.Inventory.FavoriteItems = [];
diff --git a/Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs b/Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs
index a1838685..05835aba 100644
--- a/Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs
+++ b/Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs
@@ -989,7 +989,7 @@ public class RagfairController(
/// Is this a pack offer
/// RagfairOffer
protected RagfairOffer CreatePlayerOffer(
- string sessionId,
+ MongoId sessionId,
List requirements,
List- items,
bool sellInOnePiece
@@ -1272,7 +1272,7 @@ public class RagfairController(
return ragfairPriceService.GetAllStaticPrices();
}
- public RagfairOffer? GetOfferByInternalId(string sessionId, GetRagfairOfferByIdRequest request)
+ public RagfairOffer? GetOfferByInternalId(MongoId sessionId, GetRagfairOfferByIdRequest request)
{
var offers = ragfairOfferService.GetOffers();
var offerToReturn = offers.FirstOrDefault(offer => offer.InternalId == request.Id);
diff --git a/Libraries/SPTarkov.Server.Core/Controllers/RepeatableQuestController.cs b/Libraries/SPTarkov.Server.Core/Controllers/RepeatableQuestController.cs
index 48bf4ca1..cf06c5cd 100644
--- a/Libraries/SPTarkov.Server.Core/Controllers/RepeatableQuestController.cs
+++ b/Libraries/SPTarkov.Server.Core/Controllers/RepeatableQuestController.cs
@@ -422,7 +422,7 @@ public class RepeatableQuestController(
public RepeatableQuest? PickAndGenerateRandomRepeatableQuest(
MongoId sessionId,
int pmcLevel,
- Dictionary pmcTraderInfo,
+ Dictionary pmcTraderInfo,
QuestTypePool questTypePool,
RepeatableQuestConfig repeatableConfig
)
diff --git a/Libraries/SPTarkov.Server.Core/Extensions/CurrencyTypeExtensions.cs b/Libraries/SPTarkov.Server.Core/Extensions/CurrencyTypeExtensions.cs
index a1fa64ea..b4233c3d 100644
--- a/Libraries/SPTarkov.Server.Core/Extensions/CurrencyTypeExtensions.cs
+++ b/Libraries/SPTarkov.Server.Core/Extensions/CurrencyTypeExtensions.cs
@@ -1,4 +1,5 @@
-using SPTarkov.Server.Core.Models.Enums;
+using SPTarkov.Server.Core.Models.Common;
+using SPTarkov.Server.Core.Models.Enums;
namespace SPTarkov.Server.Core.Extensions
{
@@ -9,7 +10,7 @@ namespace SPTarkov.Server.Core.Extensions
///
///
/// Tpl of currency
- public static string GetCurrencyTpl(this CurrencyType currency)
+ public static MongoId GetCurrencyTpl(this CurrencyType currency)
{
return currency switch
{
diff --git a/Libraries/SPTarkov.Server.Core/Extensions/ItemEventRouterResponseExtensions.cs b/Libraries/SPTarkov.Server.Core/Extensions/ItemEventRouterResponseExtensions.cs
index 6654f063..83bc1d41 100644
--- a/Libraries/SPTarkov.Server.Core/Extensions/ItemEventRouterResponseExtensions.cs
+++ b/Libraries/SPTarkov.Server.Core/Extensions/ItemEventRouterResponseExtensions.cs
@@ -1,4 +1,5 @@
-using SPTarkov.Server.Core.Models.Eft.Common.Tables;
+using SPTarkov.Server.Core.Models.Common;
+using SPTarkov.Server.Core.Models.Eft.Common.Tables;
using SPTarkov.Server.Core.Models.Eft.ItemEvent;
namespace SPTarkov.Server.Core.Extensions
@@ -13,10 +14,11 @@ namespace SPTarkov.Server.Core.Extensions
/// Item that was adjusted
public static void AddItemStackSizeChangeIntoEventResponse(
this ItemEventRouterResponse output,
- string sessionId,
+ MongoId sessionId,
Item item
)
{
+ // TODO: replace with something safer like TryGet
output
.ProfileChanges[sessionId]
.Items.ChangedItems.Add(
diff --git a/Libraries/SPTarkov.Server.Core/Generators/RagfairOfferGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/RagfairOfferGenerator.cs
index b9291d5f..6778458c 100644
--- a/Libraries/SPTarkov.Server.Core/Generators/RagfairOfferGenerator.cs
+++ b/Libraries/SPTarkov.Server.Core/Generators/RagfairOfferGenerator.cs
@@ -60,7 +60,7 @@ public class RagfairOfferGenerator(
/// Flags sellInOnePiece to be true
/// RagfairOffer
public RagfairOffer CreateAndAddFleaOffer(
- string userId,
+ MongoId userId,
long time,
List
- items,
List barterScheme,
@@ -95,7 +95,7 @@ public class RagfairOfferGenerator(
/// Is offer being created flagged as a pack
/// RagfairOffer
protected RagfairOffer CreateOffer(
- string userId,
+ MongoId userId,
long time,
List
- items,
List barterScheme,
@@ -177,7 +177,7 @@ public class RagfairOfferGenerator(
/// User creating the offer
/// Is the user creating the offer a trader
/// RagfairOfferUser
- protected RagfairOfferUser CreateUserDataForFleaOffer(string userId, bool isTrader)
+ protected RagfairOfferUser CreateUserDataForFleaOffer(MongoId userId, bool isTrader)
{
// Trader offer
if (isTrader)
@@ -191,7 +191,7 @@ public class RagfairOfferGenerator(
var playerProfile = profileHelper.GetPmcProfile(userId);
return new RagfairOfferUser
{
- Id = playerProfile.Id,
+ Id = playerProfile.Id.Value,
MemberType = playerProfile.Info.MemberCategory,
SelectedMemberCategory = playerProfile.Info.SelectedMemberCategory,
Nickname = playerProfile.Info.Nickname,
diff --git a/Libraries/SPTarkov.Server.Core/Helpers/InventoryHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/InventoryHelper.cs
index 751e3dce..36c3e030 100644
--- a/Libraries/SPTarkov.Server.Core/Helpers/InventoryHelper.cs
+++ b/Libraries/SPTarkov.Server.Core/Helpers/InventoryHelper.cs
@@ -39,6 +39,7 @@ public class InventoryHelper(
BaseClasses.FUNCTIONAL_MOD,
BaseClasses.MOD,
];
+
protected readonly InventoryConfig _inventoryConfig = configServer.GetConfig();
///
@@ -213,7 +214,7 @@ public class InventoryHelper(
/// Player id
/// Array of items with children to try and fit
/// True all items fit
- public bool CanPlaceItemsInInventory(string sessionId, List
> itemsWithChildren)
+ public bool CanPlaceItemsInInventory(MongoId sessionId, List> itemsWithChildren)
{
var pmcData = profileHelper.GetPmcProfile(sessionId);
diff --git a/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs
index 44208ebd..2e57720e 100644
--- a/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs
+++ b/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs
@@ -63,8 +63,8 @@ public class NotifierHelper(HttpServerHelper httpServerHelper)
};
}
- public string GetWebSocketServer(string sessionId)
+ public string GetWebSocketServer(MongoId sessionId)
{
- return $"{httpServerHelper.GetWebsocketUrl()}/notifierServer/getwebsocket/{sessionId}";
+ return $"{httpServerHelper.GetWebsocketUrl()}/notifierServer/getwebsocket/{sessionId.ToString()}";
}
}
diff --git a/Libraries/SPTarkov.Server.Core/Helpers/TraderHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/TraderHelper.cs
index 2466bab5..cd298064 100644
--- a/Libraries/SPTarkov.Server.Core/Helpers/TraderHelper.cs
+++ b/Libraries/SPTarkov.Server.Core/Helpers/TraderHelper.cs
@@ -1,3 +1,4 @@
+using System.Collections.Frozen;
using SPTarkov.DI.Annotations;
using SPTarkov.Server.Core.Extensions;
using SPTarkov.Server.Core.Models.Common;
@@ -29,7 +30,7 @@ public class TraderHelper(
ConfigServer configServer
)
{
- protected readonly List _gameVersions =
+ protected readonly FrozenSet _gameVersionsWithHigherBuyRestrictions =
[
GameEditions.EDGE_OF_DARKNESS,
GameEditions.UNHEARD,
@@ -37,6 +38,11 @@ public class TraderHelper(
protected readonly Dictionary _highestTraderPriceItems = new();
protected readonly TraderConfig _traderConfig = configServer.GetConfig();
+ ///
+ /// Get a traders base data from its nickname, case insensitive
+ ///
+ /// Nickname of trader, e.g. prapor
+ /// TraderBase
public TraderBase? GetTraderByNickName(string traderName)
{
return databaseService
@@ -244,7 +250,7 @@ public class TraderHelper(
{
if (rawProfileTemplate.InitialStanding.TryGetValue(traderId, out var standing))
{
- // Edge case for Lightkeeper, 0 standing means seeing `Make Amends - Buyout` quest
+ // Edge case for Lightkeeper trader, 0 standing means seeing `Make Amends - Buyout` quest
if (traderId == Traders.LIGHTHOUSEKEEPER && standing == 0)
{
return 0.01;
@@ -515,7 +521,7 @@ public class TraderHelper(
string gameVersion
)
{
- if (_gameVersions.Contains(gameVersion))
+ if (_gameVersionsWithHigherBuyRestrictions.Contains(gameVersion))
{
return Math.Floor(buyRestrictionMax * 1.2);
}
diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/BotBase.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/BotBase.cs
index ff9796ef..8c2e98df 100644
--- a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/BotBase.cs
+++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/BotBase.cs
@@ -69,7 +69,7 @@ public record BotBase
public List? Quests { get; set; }
[JsonPropertyName("TradersInfo")]
- public Dictionary? TradersInfo { get; set; }
+ public Dictionary TradersInfo { get; set; }
[JsonPropertyName("UnlockedInfo")]
public UnlockedInfo? UnlockedInfo { get; set; }
diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/ItemEvent/ItemEventRouterBase.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/ItemEvent/ItemEventRouterBase.cs
index 6a768d8a..a4a45582 100644
--- a/Libraries/SPTarkov.Server.Core/Models/Eft/ItemEvent/ItemEventRouterBase.cs
+++ b/Libraries/SPTarkov.Server.Core/Models/Eft/ItemEvent/ItemEventRouterBase.cs
@@ -80,7 +80,7 @@ public record ProfileChange
public BotBaseHealth Health { get; set; }
[JsonPropertyName("traderRelations")]
- public Dictionary? TraderRelations { get; set; }
+ public Dictionary? TraderRelations { get; set; }
[JsonPropertyName("moneyTransferLimitData")]
public MoneyTransferLimits? MoneyTransferLimitData { get; set; }
diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Ragfair/RagfairOffer.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Ragfair/RagfairOffer.cs
index 43bbad0c..dd3c41ab 100644
--- a/Libraries/SPTarkov.Server.Core/Models/Eft/Ragfair/RagfairOffer.cs
+++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Ragfair/RagfairOffer.cs
@@ -18,11 +18,7 @@ public record RagfairOffer
public List? SellResults { get; set; }
[JsonPropertyName("_id")]
- public string? Id
- {
- get { return _id; }
- set { _id = string.Intern(value); }
- }
+ public MongoId Id { get; set; }
[JsonPropertyName("items")]
public List- ? Items { get; set; }
@@ -31,11 +27,7 @@ public record RagfairOffer
public List? Requirements { get; set; }
[JsonPropertyName("root")]
- public string? Root
- {
- get { return _root; }
- set { _root = string.Intern(value); }
- }
+ public MongoId Root { get; set; }
[JsonPropertyName("intId")]
public int? InternalId { get; set; }
@@ -128,11 +120,7 @@ public record RagfairOfferUser
private string? _id;
[JsonPropertyName("id")]
- public string? Id
- {
- get { return _id; }
- set { _id = string.Intern(value); }
- }
+ public MongoId Id { get; set; }
[JsonPropertyName("nickname")]
public string? Nickname { get; set; }
diff --git a/Libraries/SPTarkov.Server.Core/Routers/EventOutputHolder.cs b/Libraries/SPTarkov.Server.Core/Routers/EventOutputHolder.cs
index fae38207..71653ff9 100644
--- a/Libraries/SPTarkov.Server.Core/Routers/EventOutputHolder.cs
+++ b/Libraries/SPTarkov.Server.Core/Routers/EventOutputHolder.cs
@@ -52,7 +52,7 @@ public class EventOutputHolder(
sessionId,
new ItemEventRouterResponse
{
- ProfileChanges = new Dictionary
+ ProfileChanges = new Dictionary
{
{
sessionId,
@@ -79,7 +79,7 @@ public class EventOutputHolder(
Points = 0,
},
Health = cloner.Clone(pmcProfile.Health),
- TraderRelations = new Dictionary(),
+ TraderRelations = new Dictionary(),
QuestsStatus = [],
}
},
@@ -255,8 +255,8 @@ public class EventOutputHolder(
///
/// Server data for traders
/// Dict of trader id + TraderData
- protected Dictionary ConstructTraderRelations(
- Dictionary traderData
+ protected Dictionary ConstructTraderRelations(
+ Dictionary traderData
)
{
return traderData.ToDictionary(
diff --git a/Libraries/SPTarkov.Server.Core/Services/FenceService.cs b/Libraries/SPTarkov.Server.Core/Services/FenceService.cs
index 95711259..eda5dbc6 100644
--- a/Libraries/SPTarkov.Server.Core/Services/FenceService.cs
+++ b/Libraries/SPTarkov.Server.Core/Services/FenceService.cs
@@ -1755,7 +1755,7 @@ public class FenceService(
///
/// Assort ID to adjust
/// `Count of items bought
- public void AmendOrRemoveFenceOffer(string assortId, int buyCount)
+ public void AmendOrRemoveFenceOffer(MongoId assortId, int buyCount)
{
var isNormalAssort = true;
var fenceAssortItem = fenceAssort.Items.FirstOrDefault(item => item.Id == assortId);
@@ -1786,7 +1786,7 @@ public class FenceService(
fenceAssortItem.Upd.StackObjectsCount -= buyCount;
}
- protected void DeleteOffer(string assortId, List- assorts)
+ protected void DeleteOffer(MongoId assortId, List
- assorts)
{
// Assort could have child items, remove those too
var itemWithChildrenToRemove = assorts.FindAndReturnChildrenAsItems(assortId);
diff --git a/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs b/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs
index 2f014fad..11430ec7 100644
--- a/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs
+++ b/Libraries/SPTarkov.Server.Core/Services/LocationLifecycleService.cs
@@ -1117,8 +1117,8 @@ public class LocationLifecycleService(
/// Server
/// Client
protected void ApplyTraderStandingAdjustments(
- Dictionary? tradersServerProfile,
- Dictionary? tradersClientProfile
+ Dictionary? tradersServerProfile,
+ Dictionary? tradersClientProfile
)
{
foreach (var traderId in tradersClientProfile)
diff --git a/Libraries/SPTarkov.Server.Core/Services/MatchBotDetailsCacheService.cs b/Libraries/SPTarkov.Server.Core/Services/MatchBotDetailsCacheService.cs
index 9f0af264..413253e9 100644
--- a/Libraries/SPTarkov.Server.Core/Services/MatchBotDetailsCacheService.cs
+++ b/Libraries/SPTarkov.Server.Core/Services/MatchBotDetailsCacheService.cs
@@ -25,7 +25,7 @@ public class MatchBotDetailsCacheService(ISptLogger
/// Bot details to cache
public void CacheBot(BotBase botToCache)
{
- if (botToCache is null || botToCache.Id is null)
+ if (botToCache?.Id is null)
{
return;
}
diff --git a/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs b/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs
index dd55bc75..cbb868cd 100644
--- a/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs
+++ b/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs
@@ -47,7 +47,8 @@ public class PaymentService(
{
// May need to convert to trader currency
var trader = traderHelper.GetTrader(request.TransactionId, sessionID);
- var payToTrader = traderHelper.TraderExists(request.TransactionId);
+ var payToTrader =
+ request.TransactionId != "ragfair" && traderHelper.TraderExists(request.TransactionId);
// Track the amounts of each type of currency involved in the trade.
var currencyAmounts = new Dictionary();
diff --git a/Libraries/SPTarkov.Server.Core/Services/RagfairOfferService.cs b/Libraries/SPTarkov.Server.Core/Services/RagfairOfferService.cs
index 49a59a51..722a10d5 100644
--- a/Libraries/SPTarkov.Server.Core/Services/RagfairOfferService.cs
+++ b/Libraries/SPTarkov.Server.Core/Services/RagfairOfferService.cs
@@ -190,7 +190,9 @@ public class RagfairOfferService(
}
// Handle dynamic offer from PMCs
- var isPlayer = profileHelper.IsPlayer(staleOffer.User.Id.RegexReplace("^pmc", ""));
+ var isPlayer = profileHelper.IsPlayer(
+ staleOffer.User.Id.ToString().RegexReplace("^pmc", "")
+ );
if (flagOfferAsExpired && !isPlayer)
{
// Not trader or a player offer