From da5644cfa27d6ec7689f9a718eae079e42311fd2 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 28 Jun 2025 12:53:21 +0100 Subject: [PATCH] made properties readonly --- .../Controllers/AchievementController.cs | 2 +- .../Controllers/DialogueController.cs | 4 ++-- .../Controllers/InRaidController.cs | 4 ++-- .../Controllers/InsuranceController.cs | 3 ++- .../Controllers/LauncherController.cs | 2 +- .../Controllers/LauncherV2Controller.cs | 2 +- .../Controllers/RepeatableQuestController.cs | 2 +- .../Controllers/TradeController.cs | 4 ++-- .../Generators/BotEquipmentModGenerator.cs | 2 +- .../Generators/BotGenerator.cs | 4 ++-- .../Generators/BotLootGenerator.cs | 4 ++-- .../Generators/BotWeaponGenerator.cs | 8 ++++---- .../Generators/FenceBaseAssortGenerator.cs | 2 +- .../Generators/PlayerScavGenerator.cs | 3 ++- .../Generators/RagfairOfferGenerator.cs | 4 ++-- .../Generators/ScavCaseRewardGenerator.cs | 2 +- .../Generators/WeatherGenerator.cs | 2 +- .../Helpers/BotDifficultyHelper.cs | 2 +- .../Helpers/Dialogue/AbstractDialogChatBot.cs | 4 ++-- .../SptCommands/GiveCommand/GiveSptCommand.cs | 2 +- .../TraderCommand/TraderSptCommand.cs | 2 +- .../Helpers/Dialogue/CommandoDialogChatBot.cs | 2 +- .../Helpers/Dialogue/SptDialogueChatBot.cs | 7 +++---- .../Helpers/HttpServerHelper.cs | 2 +- .../Helpers/NotifierHelper.cs | 2 +- .../Helpers/ProfileHelper.cs | 3 ++- .../Helpers/QuestRewardHelper.cs | 2 +- .../Helpers/RagfairSellHelper.cs | 2 +- .../Helpers/RepeatableQuestHelper.cs | 2 +- .../Helpers/TraderHelper.cs | 10 +++++++--- .../Helpers/WeatherHelper.cs | 2 +- .../SPTarkov.Server.Core/Routers/HttpRouter.cs | 4 ++-- .../SPTarkov.Server.Core/Servers/SaveServer.cs | 4 ++-- .../Servers/Ws/SptWebSocketConnectionHandler.cs | 4 ++-- .../Services/BotGenerationCacheService.cs | 2 +- .../Services/BotLootCacheService.cs | 2 +- .../Services/BotNameService.cs | 4 ++-- .../Services/BotWeaponModLimitService.cs | 2 +- .../Services/BtrDeliveryService.cs | 7 ++++--- .../Services/CustomLocationWaveService.cs | 2 +- .../Services/FenceService.cs | 4 ++-- .../Services/GiftService.cs | 2 +- .../Services/Image/ImageRouterService.cs | 2 +- .../Services/InMemoryCacheService.cs | 2 +- .../Services/InsuranceService.cs | 2 +- .../Services/ItemFilterService.cs | 6 +++--- .../Services/MailSendService.cs | 4 ++-- .../Services/MatchLocationService.cs | 2 +- .../Services/NotificationService.cs | 2 +- .../Services/OpenZoneService.cs | 2 +- .../Services/PaymentService.cs | 3 ++- .../Services/PmcChatResponseService.cs | 3 ++- .../Services/PostDbLoadService.cs | 16 ++++++++-------- .../Services/ProfileFixerService.cs | 4 ++-- .../Services/RagfairOfferService.cs | 2 +- .../Services/RagfairTaxService.cs | 5 ++++- .../Services/RaidTimeAdjustmentService.cs | 2 +- .../Services/RaidWeatherService.cs | 4 ++-- .../Services/RepairService.cs | 2 +- .../Services/SeasonalEventService.cs | 17 +++++++++++------ .../Services/TraderPurchasePersisterService.cs | 2 +- .../Utils/HttpResponseUtil.cs | 2 +- .../SPTarkov.Server.Core/Utils/TimerUtil.cs | 2 +- 63 files changed, 119 insertions(+), 102 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Controllers/AchievementController.cs b/Libraries/SPTarkov.Server.Core/Controllers/AchievementController.cs index dc6da8d1..5d6d9158 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/AchievementController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/AchievementController.cs @@ -14,7 +14,7 @@ public class AchievementController( ConfigServer configServer ) { - protected CoreConfig coreConfig = configServer.GetConfig(); + protected readonly CoreConfig coreConfig = configServer.GetConfig(); /// /// Get base achievements diff --git a/Libraries/SPTarkov.Server.Core/Controllers/DialogueController.cs b/Libraries/SPTarkov.Server.Core/Controllers/DialogueController.cs index 31aa1a69..deae37cf 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/DialogueController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/DialogueController.cs @@ -27,8 +27,8 @@ public class DialogueController( IEnumerable dialogueChatBots ) { - protected CoreConfig _coreConfig = _configServer.GetConfig(); - protected List _dialogueChatBots = dialogueChatBots.ToList(); + protected readonly CoreConfig _coreConfig = _configServer.GetConfig(); + protected readonly List _dialogueChatBots = dialogueChatBots.ToList(); /// /// diff --git a/Libraries/SPTarkov.Server.Core/Controllers/InRaidController.cs b/Libraries/SPTarkov.Server.Core/Controllers/InRaidController.cs index 209bc75e..8b659658 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/InRaidController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/InRaidController.cs @@ -15,8 +15,8 @@ public class InRaidController( ConfigServer _configServer ) { - protected BotConfig _botConfig = _configServer.GetConfig(); - protected InRaidConfig _inRaidConfig = _configServer.GetConfig(); + protected readonly BotConfig _botConfig = _configServer.GetConfig(); + protected readonly InRaidConfig _inRaidConfig = _configServer.GetConfig(); /// /// Save locationId to active profiles in-raid object AND app context diff --git a/Libraries/SPTarkov.Server.Core/Controllers/InsuranceController.cs b/Libraries/SPTarkov.Server.Core/Controllers/InsuranceController.cs index 8025a706..dbafc1f5 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/InsuranceController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/InsuranceController.cs @@ -44,7 +44,8 @@ public class InsuranceController( ICloner _cloner ) { - protected InsuranceConfig _insuranceConfig = _configServer.GetConfig(); + protected readonly InsuranceConfig _insuranceConfig = + _configServer.GetConfig(); /// /// Process insurance items of all profiles prior to being given back to the player through the mail service diff --git a/Libraries/SPTarkov.Server.Core/Controllers/LauncherController.cs b/Libraries/SPTarkov.Server.Core/Controllers/LauncherController.cs index f83d4fd3..3932a228 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/LauncherController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/LauncherController.cs @@ -28,7 +28,7 @@ public class LauncherController( ConfigServer _configServer ) { - protected CoreConfig _coreConfig = _configServer.GetConfig(); + protected readonly CoreConfig _coreConfig = _configServer.GetConfig(); /// /// Handle launcher connecting to server diff --git a/Libraries/SPTarkov.Server.Core/Controllers/LauncherV2Controller.cs b/Libraries/SPTarkov.Server.Core/Controllers/LauncherV2Controller.cs index 03548481..25df7595 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/LauncherV2Controller.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/LauncherV2Controller.cs @@ -25,7 +25,7 @@ public class LauncherV2Controller( Watermark _watermark ) { - protected CoreConfig _coreConfig = _configServer.GetConfig(); + protected readonly CoreConfig _coreConfig = _configServer.GetConfig(); /// /// Returns a simple string of Pong! diff --git a/Libraries/SPTarkov.Server.Core/Controllers/RepeatableQuestController.cs b/Libraries/SPTarkov.Server.Core/Controllers/RepeatableQuestController.cs index 6c9136d0..713f7e3a 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/RepeatableQuestController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/RepeatableQuestController.cs @@ -46,7 +46,7 @@ public class RepeatableQuestController( ) { protected static readonly List _questTypes = ["PickUp", "Exploration", "Elimination"]; - protected QuestConfig QuestConfig = _configServer.GetConfig(); + protected readonly QuestConfig QuestConfig = _configServer.GetConfig(); /// /// Handle the client accepting a repeatable quest and starting it diff --git a/Libraries/SPTarkov.Server.Core/Controllers/TradeController.cs b/Libraries/SPTarkov.Server.Core/Controllers/TradeController.cs index 95f34706..9cf33005 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/TradeController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/TradeController.cs @@ -38,8 +38,8 @@ public class TradeController( ConfigServer _configServer ) { - protected RagfairConfig _ragfairConfig = _configServer.GetConfig(); - protected TraderConfig _traderConfig = _configServer.GetConfig(); + protected readonly RagfairConfig _ragfairConfig = _configServer.GetConfig(); + protected readonly TraderConfig _traderConfig = _configServer.GetConfig(); /// /// Handle TradingConfirm event diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotEquipmentModGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotEquipmentModGenerator.cs index a2c4a9ef..b1863659 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotEquipmentModGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotEquipmentModGenerator.cs @@ -85,7 +85,7 @@ public class BotEquipmentModGenerator( "cartridges", ]; - protected BotConfig _botConfig = _configServer.GetConfig(); + protected readonly BotConfig _botConfig = _configServer.GetConfig(); /// /// Check mods are compatible and add to array diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs index aeb6a8bb..b731d165 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotGenerator.cs @@ -37,8 +37,8 @@ public class BotGenerator( ICloner _cloner ) { - protected BotConfig _botConfig = _configServer.GetConfig(); - protected PmcConfig _pmcConfig = _configServer.GetConfig(); + protected readonly BotConfig _botConfig = _configServer.GetConfig(); + protected readonly PmcConfig _pmcConfig = _configServer.GetConfig(); /// /// Generate a player scav bot object diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotLootGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotLootGenerator.cs index 19886ed4..02794ce7 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotLootGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotLootGenerator.cs @@ -32,8 +32,8 @@ public class BotLootGenerator( ICloner _cloner ) { - protected BotConfig _botConfig = _configServer.GetConfig(); - protected PmcConfig _pmcConfig = _configServer.GetConfig(); + protected readonly BotConfig _botConfig = _configServer.GetConfig(); + protected readonly PmcConfig _pmcConfig = _configServer.GetConfig(); /// /// diff --git a/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs index a87b2406..fca89967 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/BotWeaponGenerator.cs @@ -35,12 +35,12 @@ public class BotWeaponGenerator( ) { protected const string _modMagazineSlotId = "mod_magazine"; - protected BotConfig _botConfig = _configServer.GetConfig(); - protected IEnumerable _inventoryMagGenComponents = MagGenSetUp( + protected readonly BotConfig _botConfig = _configServer.GetConfig(); + protected readonly IEnumerable _inventoryMagGenComponents = MagGenSetUp( inventoryMagGenComponents ); - protected PmcConfig _pmcConfig = _configServer.GetConfig(); - protected RepairConfig _repairConfig = _configServer.GetConfig(); + protected readonly PmcConfig _pmcConfig = _configServer.GetConfig(); + protected readonly RepairConfig _repairConfig = _configServer.GetConfig(); protected static List MagGenSetUp(IEnumerable components) { diff --git a/Libraries/SPTarkov.Server.Core/Generators/FenceBaseAssortGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/FenceBaseAssortGenerator.cs index 77c41b12..9c6d00df 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/FenceBaseAssortGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/FenceBaseAssortGenerator.cs @@ -27,7 +27,7 @@ public class FenceBaseAssortGenerator( ICloner _cloner ) { - protected TraderConfig traderConfig = configServer.GetConfig(); + protected readonly TraderConfig traderConfig = configServer.GetConfig(); /// /// Create base fence assorts dynamically and store in memory diff --git a/Libraries/SPTarkov.Server.Core/Generators/PlayerScavGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/PlayerScavGenerator.cs index 4d971446..fb955822 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/PlayerScavGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/PlayerScavGenerator.cs @@ -37,7 +37,8 @@ public class PlayerScavGenerator( TimeUtil _timeUtil ) { - protected PlayerScavConfig _playerScavConfig = _configServer.GetConfig(); + protected readonly PlayerScavConfig _playerScavConfig = + _configServer.GetConfig(); /// /// Update a player profile to include a new player scav profile diff --git a/Libraries/SPTarkov.Server.Core/Generators/RagfairOfferGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/RagfairOfferGenerator.cs index dacb15d9..9e26521b 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/RagfairOfferGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/RagfairOfferGenerator.cs @@ -40,12 +40,12 @@ public class RagfairOfferGenerator( ) { protected List? allowedFleaPriceItemsForBarter; - protected BotConfig botConfig = configServer.GetConfig(); + protected readonly BotConfig botConfig = configServer.GetConfig(); /// Internal counter to ensure each offer created has a unique value for its intId property protected int offerCounter; - protected RagfairConfig ragfairConfig = configServer.GetConfig(); + protected readonly RagfairConfig ragfairConfig = configServer.GetConfig(); /// /// Create a flea offer and store it in the Ragfair server offers array diff --git a/Libraries/SPTarkov.Server.Core/Generators/ScavCaseRewardGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/ScavCaseRewardGenerator.cs index c00e35c2..527e6059 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/ScavCaseRewardGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/ScavCaseRewardGenerator.cs @@ -33,7 +33,7 @@ public class ScavCaseRewardGenerator( { protected List _dbAmmoItemsCache = []; protected List _dbItemsCache = []; - protected ScavCaseConfig _scavCaseConfig = _configServer.GetConfig(); + protected readonly ScavCaseConfig _scavCaseConfig = _configServer.GetConfig(); /// /// Create an array of rewards that will be given to the player upon completing their scav case build diff --git a/Libraries/SPTarkov.Server.Core/Generators/WeatherGenerator.cs b/Libraries/SPTarkov.Server.Core/Generators/WeatherGenerator.cs index 3901c893..f4964117 100644 --- a/Libraries/SPTarkov.Server.Core/Generators/WeatherGenerator.cs +++ b/Libraries/SPTarkov.Server.Core/Generators/WeatherGenerator.cs @@ -19,7 +19,7 @@ public class WeatherGenerator( RandomUtil _randomUtil ) { - protected WeatherConfig _weatherConfig = _configServer.GetConfig(); + protected readonly WeatherConfig _weatherConfig = _configServer.GetConfig(); /// /// Get current + raid datetime and format into correct BSG format. diff --git a/Libraries/SPTarkov.Server.Core/Helpers/BotDifficultyHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/BotDifficultyHelper.cs index a5dbcb61..833505ea 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/BotDifficultyHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/BotDifficultyHelper.cs @@ -21,7 +21,7 @@ public class BotDifficultyHelper( ICloner _cloner ) { - protected PmcConfig _pmcConfig = _configServer.GetConfig(); + protected readonly PmcConfig _pmcConfig = _configServer.GetConfig(); /// /// Get difficulty settings for desired bot type, if not found use assault bot types diff --git a/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/AbstractDialogChatBot.cs b/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/AbstractDialogChatBot.cs index 1b0cb3f2..78e252d0 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/AbstractDialogChatBot.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/AbstractDialogChatBot.cs @@ -14,8 +14,8 @@ public abstract class AbstractDialogChatBot( IEnumerable chatCommands ) : IDialogueChatBot { - protected IDictionary _chatCommands = chatCommands.ToDictionary(command => - command.GetCommandPrefix() + protected readonly IDictionary _chatCommands = chatCommands.ToDictionary( + command => command.GetCommandPrefix() ); public abstract UserDialogInfo GetChatBot(); diff --git a/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.cs b/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.cs index 163a73fe..24979c0a 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.cs @@ -40,7 +40,7 @@ public class GiveSptCommand( ItemTpl.FLARE_RSP30_REACTIVE_SIGNAL_CARTRIDGE_YELLOW, ]; - protected Dictionary _savedCommand = new(); + protected readonly Dictionary _savedCommand = new(); public string GetCommand() { diff --git a/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/Commando/SptCommands/TraderCommand/TraderSptCommand.cs b/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/Commando/SptCommands/TraderCommand/TraderSptCommand.cs index 8bcd613c..92b72982 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/Commando/SptCommands/TraderCommand/TraderSptCommand.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/Commando/SptCommands/TraderCommand/TraderSptCommand.cs @@ -21,7 +21,7 @@ public class TraderSptCommand( MailSendService _mailSendService ) : ISptCommand { - protected Regex _commandRegex = new( + protected readonly Regex _commandRegex = new( @"^spt trader (?[\w]+) (?rep|spend) (?(?!0+)[0-9]+)$" ); diff --git a/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/CommandoDialogChatBot.cs b/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/CommandoDialogChatBot.cs index fb8bd028..4087dc53 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/CommandoDialogChatBot.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/CommandoDialogChatBot.cs @@ -18,7 +18,7 @@ public class CommandoDialogChatBot( IEnumerable chatCommands ) : AbstractDialogChatBot(logger, mailSendService, localisationService, chatCommands) { - protected CoreConfig _coreConfig = _configServer.GetConfig(); + protected readonly CoreConfig _coreConfig = _configServer.GetConfig(); public override UserDialogInfo GetChatBot() { diff --git a/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/SptDialogueChatBot.cs b/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/SptDialogueChatBot.cs index 030267db..a6f10e5c 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/SptDialogueChatBot.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/SptDialogueChatBot.cs @@ -21,10 +21,9 @@ public class SptDialogueChatBot( IEnumerable chatMessageHandlers ) : IDialogueChatBot { - protected IEnumerable _chatMessageHandlers = ChatMessageHandlerSetup( - chatMessageHandlers - ); - protected CoreConfig _coreConfig = _configServer.GetConfig(); + protected readonly IEnumerable _chatMessageHandlers = + ChatMessageHandlerSetup(chatMessageHandlers); + protected readonly CoreConfig _coreConfig = _configServer.GetConfig(); public UserDialogInfo GetChatBot() { diff --git a/Libraries/SPTarkov.Server.Core/Helpers/HttpServerHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/HttpServerHelper.cs index bffb11bc..2e29f1fa 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/HttpServerHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/HttpServerHelper.cs @@ -11,7 +11,7 @@ public class HttpServerHelper(ConfigServer configServer) { protected readonly HttpConfig _httpConfig = configServer.GetConfig(); - protected Dictionary mime = new() + protected readonly Dictionary mime = new() { { "css", "text/css" }, { "bin", "application/octet-stream" }, diff --git a/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs index 1ba1ebf2..6c208a8e 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs @@ -8,7 +8,7 @@ namespace SPTarkov.Server.Core.Helpers; [Injectable(InjectionType.Singleton)] public class NotifierHelper(HttpServerHelper httpServerHelper, HashUtil hashUtil) { - protected static WsPing ping = new(); + protected static readonly WsPing ping = new(); public WsNotificationEvent GetDefaultNotification() { diff --git a/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs index ef54876e..7488e228 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs @@ -34,7 +34,8 @@ public class ProfileHelper( "edge_of_darkness", "unheard_edition", ]; - protected InventoryConfig _inventoryConfig = _configServer.GetConfig(); + protected readonly InventoryConfig _inventoryConfig = + _configServer.GetConfig(); /// /// Remove/reset a completed quest condtion from players profile quest data diff --git a/Libraries/SPTarkov.Server.Core/Helpers/QuestRewardHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/QuestRewardHelper.cs index bb2cef75..91cacdb5 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/QuestRewardHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/QuestRewardHelper.cs @@ -27,7 +27,7 @@ public class QuestRewardHelper( /// Value can be modified by modders by overriding this value with new traders. /// Ensure to add Lightkeeper's ID (638f541a29ffd1183d187f57) and BTR Driver's ID (656f0f98d80a697f855d34b1) /// - protected string[] InGameTraders = [Traders.LIGHTHOUSEKEEPER, Traders.BTR]; + protected readonly string[] InGameTraders = [Traders.LIGHTHOUSEKEEPER, Traders.BTR]; /// /// Give player quest rewards - Skills/exp/trader standing/items/assort unlocks - Returns reward items player earned diff --git a/Libraries/SPTarkov.Server.Core/Helpers/RagfairSellHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/RagfairSellHelper.cs index 11bf2bf9..d057b587 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/RagfairSellHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/RagfairSellHelper.cs @@ -18,7 +18,7 @@ public class RagfairSellHelper( ConfigServer _configServer ) { - protected RagfairConfig _ragfairConfig = _configServer.GetConfig(); + protected readonly RagfairConfig _ragfairConfig = _configServer.GetConfig(); /// /// Get the percent chance to sell an item based on its average listed price vs player chosen listing price diff --git a/Libraries/SPTarkov.Server.Core/Helpers/RepeatableQuestHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/RepeatableQuestHelper.cs index 02db4fe9..995703f0 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/RepeatableQuestHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/RepeatableQuestHelper.cs @@ -19,7 +19,7 @@ public class RepeatableQuestHelper( ConfigServer configServer ) { - protected QuestConfig QuestConfig = configServer.GetConfig(); + protected readonly QuestConfig QuestConfig = configServer.GetConfig(); /// /// Get the relevant elimination config based on the current players PMC level diff --git a/Libraries/SPTarkov.Server.Core/Helpers/TraderHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/TraderHelper.cs index f6c26bbb..12a94c81 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/TraderHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/TraderHelper.cs @@ -30,9 +30,13 @@ public class TraderHelper( ConfigServer _configServer ) { - protected List _gameVersions = [GameEditions.EDGE_OF_DARKNESS, GameEditions.UNHEARD]; - protected Dictionary _highestTraderPriceItems = new(); - protected TraderConfig _traderConfig = _configServer.GetConfig(); + protected readonly List _gameVersions = + [ + GameEditions.EDGE_OF_DARKNESS, + GameEditions.UNHEARD, + ]; + protected readonly Dictionary _highestTraderPriceItems = new(); + protected readonly TraderConfig _traderConfig = _configServer.GetConfig(); public TraderBase? GetTraderByNickName(string traderName) { diff --git a/Libraries/SPTarkov.Server.Core/Helpers/WeatherHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/WeatherHelper.cs index 92b29eec..b82db79f 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/WeatherHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/WeatherHelper.cs @@ -14,7 +14,7 @@ public class WeatherHelper( ConfigServer _configServer ) { - protected WeatherConfig _weatherConfig = _configServer.GetConfig(); + protected readonly WeatherConfig _weatherConfig = _configServer.GetConfig(); /// /// Assumes current time diff --git a/Libraries/SPTarkov.Server.Core/Routers/HttpRouter.cs b/Libraries/SPTarkov.Server.Core/Routers/HttpRouter.cs index d0e37f60..4edb72b1 100644 --- a/Libraries/SPTarkov.Server.Core/Routers/HttpRouter.cs +++ b/Libraries/SPTarkov.Server.Core/Routers/HttpRouter.cs @@ -6,8 +6,8 @@ namespace SPTarkov.Server.Core.Routers; [Injectable] public class HttpRouter { - protected IEnumerable _dynamicRoutes; - protected IEnumerable _staticRouters; + protected readonly IEnumerable _dynamicRoutes; + protected readonly IEnumerable _staticRouters; public HttpRouter( IEnumerable staticRouters, diff --git a/Libraries/SPTarkov.Server.Core/Servers/SaveServer.cs b/Libraries/SPTarkov.Server.Core/Servers/SaveServer.cs index cd86ad67..fdab3c52 100644 --- a/Libraries/SPTarkov.Server.Core/Servers/SaveServer.cs +++ b/Libraries/SPTarkov.Server.Core/Servers/SaveServer.cs @@ -29,8 +29,8 @@ public class SaveServer( protected readonly Dictionary> onBeforeSaveCallbacks = new(); - protected ConcurrentDictionary profiles = new(); - protected ConcurrentDictionary saveMd5 = new(); + protected readonly ConcurrentDictionary profiles = new(); + protected readonly ConcurrentDictionary saveMd5 = new(); /// /// Add callback to occur prior to saving profile changes diff --git a/Libraries/SPTarkov.Server.Core/Servers/Ws/SptWebSocketConnectionHandler.cs b/Libraries/SPTarkov.Server.Core/Servers/Ws/SptWebSocketConnectionHandler.cs index 61b1f8f6..985de7ed 100644 --- a/Libraries/SPTarkov.Server.Core/Servers/Ws/SptWebSocketConnectionHandler.cs +++ b/Libraries/SPTarkov.Server.Core/Servers/Ws/SptWebSocketConnectionHandler.cs @@ -20,8 +20,8 @@ public class SptWebSocketConnectionHandler( IEnumerable _messageHandlers ) : IWebSocketConnectionHandler { - protected Dictionary> _sockets = new(); - protected Lock _socketsLock = new(); + protected readonly Dictionary> _sockets = new(); + protected readonly Lock _socketsLock = new(); public string GetHookUrl() { diff --git a/Libraries/SPTarkov.Server.Core/Services/BotGenerationCacheService.cs b/Libraries/SPTarkov.Server.Core/Services/BotGenerationCacheService.cs index 42eab3ea..1c87db19 100644 --- a/Libraries/SPTarkov.Server.Core/Services/BotGenerationCacheService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/BotGenerationCacheService.cs @@ -13,7 +13,7 @@ public class BotGenerationCacheService( ) { protected Queue _activeBotsInRaid = []; - protected ConcurrentDictionary> _storedBots = new(); + protected readonly ConcurrentDictionary> _storedBots = new(); /// /// Store list of bots in cache, shuffle results before storage diff --git a/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs b/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs index 7176c965..beef5f60 100644 --- a/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs @@ -20,7 +20,7 @@ public class BotLootCacheService( ICloner _cloner ) { - protected ConcurrentDictionary _lootCache = new(); + protected readonly ConcurrentDictionary _lootCache = new(); private readonly Lock _drugLock = new(); private readonly Lock _foodLock = new(); private readonly Lock _drinkLock = new(); diff --git a/Libraries/SPTarkov.Server.Core/Services/BotNameService.cs b/Libraries/SPTarkov.Server.Core/Services/BotNameService.cs index e849e5f1..3e8411d3 100644 --- a/Libraries/SPTarkov.Server.Core/Services/BotNameService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/BotNameService.cs @@ -21,8 +21,8 @@ public class BotNameService( ) { protected readonly Lock _lockObject = new(); - protected BotConfig _botConfig = _configServer.GetConfig(); - protected HashSet _usedNameCache = new(); + protected readonly BotConfig _botConfig = _configServer.GetConfig(); + protected readonly HashSet _usedNameCache = new(); /// /// Clear out any entries in Name Set diff --git a/Libraries/SPTarkov.Server.Core/Services/BotWeaponModLimitService.cs b/Libraries/SPTarkov.Server.Core/Services/BotWeaponModLimitService.cs index 833f33dc..4dfd6de6 100644 --- a/Libraries/SPTarkov.Server.Core/Services/BotWeaponModLimitService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/BotWeaponModLimitService.cs @@ -17,7 +17,7 @@ public class BotWeaponModLimitService( ItemHelper _itemHelper ) { - protected BotConfig _botConfig = _configServer.GetConfig(); + protected readonly BotConfig _botConfig = _configServer.GetConfig(); /// /// Initalise mod limits to be used when generating a weapon diff --git a/Libraries/SPTarkov.Server.Core/Services/BtrDeliveryService.cs b/Libraries/SPTarkov.Server.Core/Services/BtrDeliveryService.cs index 36ada693..d828b386 100644 --- a/Libraries/SPTarkov.Server.Core/Services/BtrDeliveryService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/BtrDeliveryService.cs @@ -24,10 +24,11 @@ public class BtrDeliveryService( LocalisationService _localisationService ) { - protected BtrDeliveryConfig _btrDeliveryConfig = _configServer.GetConfig(); - protected TraderConfig _traderConfig = _configServer.GetConfig(); + protected readonly BtrDeliveryConfig _btrDeliveryConfig = + _configServer.GetConfig(); + protected readonly TraderConfig _traderConfig = _configServer.GetConfig(); - protected static List _transferTypes = new() { "btr", "transit" }; + protected static readonly List _transferTypes = new() { "btr", "transit" }; /// /// Check if player used BTR or transit item sending service and send items to player via mail if found diff --git a/Libraries/SPTarkov.Server.Core/Services/CustomLocationWaveService.cs b/Libraries/SPTarkov.Server.Core/Services/CustomLocationWaveService.cs index adb29329..d19f9fec 100644 --- a/Libraries/SPTarkov.Server.Core/Services/CustomLocationWaveService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/CustomLocationWaveService.cs @@ -14,7 +14,7 @@ public class CustomLocationWaveService( ConfigServer _configServer ) { - protected LocationConfig _locationConfig = _configServer.GetConfig(); + protected readonly LocationConfig _locationConfig = _configServer.GetConfig(); /// /// Add a boss wave to a map diff --git a/Libraries/SPTarkov.Server.Core/Services/FenceService.cs b/Libraries/SPTarkov.Server.Core/Services/FenceService.cs index 8b316280..f9cfad09 100644 --- a/Libraries/SPTarkov.Server.Core/Services/FenceService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/FenceService.cs @@ -44,7 +44,7 @@ public class FenceService( /// protected TraderAssort? fenceDiscountAssort; - protected HashSet fenceItemUpdCompareProperties = + protected readonly HashSet fenceItemUpdCompareProperties = [ "Buff", "Repairable", @@ -62,7 +62,7 @@ public class FenceService( /// protected long nextPartialRefreshTimestamp; - protected TraderConfig traderConfig = configServer.GetConfig(); + protected readonly TraderConfig traderConfig = configServer.GetConfig(); /// /// Replace main fence assort with new assort diff --git a/Libraries/SPTarkov.Server.Core/Services/GiftService.cs b/Libraries/SPTarkov.Server.Core/Services/GiftService.cs index 70025678..af502a6b 100644 --- a/Libraries/SPTarkov.Server.Core/Services/GiftService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/GiftService.cs @@ -22,7 +22,7 @@ public class GiftService( ConfigServer _configServer ) { - protected GiftsConfig _giftConfig = _configServer.GetConfig(); + protected readonly GiftsConfig _giftConfig = _configServer.GetConfig(); /// /// Does a gift with a specific ID exist in db diff --git a/Libraries/SPTarkov.Server.Core/Services/Image/ImageRouterService.cs b/Libraries/SPTarkov.Server.Core/Services/Image/ImageRouterService.cs index 61d55992..59fb9bf8 100644 --- a/Libraries/SPTarkov.Server.Core/Services/Image/ImageRouterService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/Image/ImageRouterService.cs @@ -5,7 +5,7 @@ namespace SPTarkov.Server.Core.Services.Image; [Injectable(InjectionType.Singleton)] public class ImageRouterService { - protected Dictionary routes = new(); + protected readonly Dictionary routes = new(); public void AddRoute(string urlKey, string route) { diff --git a/Libraries/SPTarkov.Server.Core/Services/InMemoryCacheService.cs b/Libraries/SPTarkov.Server.Core/Services/InMemoryCacheService.cs index 7d849602..4010a559 100644 --- a/Libraries/SPTarkov.Server.Core/Services/InMemoryCacheService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/InMemoryCacheService.cs @@ -6,7 +6,7 @@ namespace SPTarkov.Server.Core.Services; [Injectable(InjectionType.Singleton)] public class InMemoryCacheService(ICloner _cloner) { - protected Dictionary _cacheData = new(); + protected readonly Dictionary _cacheData = new(); /// /// Store data into an in-memory object diff --git a/Libraries/SPTarkov.Server.Core/Services/InsuranceService.cs b/Libraries/SPTarkov.Server.Core/Services/InsuranceService.cs index bdc3f741..49581e1b 100644 --- a/Libraries/SPTarkov.Server.Core/Services/InsuranceService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/InsuranceService.cs @@ -34,7 +34,7 @@ public class InsuranceService( { protected readonly InsuranceConfig _insuranceConfig = _configServer.GetConfig(); - protected Dictionary>?> _insured = new(); + protected readonly Dictionary>?> _insured = new(); /// /// Does player have insurance dictionary exists diff --git a/Libraries/SPTarkov.Server.Core/Services/ItemFilterService.cs b/Libraries/SPTarkov.Server.Core/Services/ItemFilterService.cs index bb9e2340..451bca0f 100644 --- a/Libraries/SPTarkov.Server.Core/Services/ItemFilterService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/ItemFilterService.cs @@ -16,10 +16,10 @@ public class ItemFilterService( ConfigServer _configServer ) { - protected HashSet? _itemBlacklistCache = []; - protected ItemConfig _itemConfig = _configServer.GetConfig(); + protected readonly HashSet? _itemBlacklistCache = []; + protected readonly ItemConfig _itemConfig = _configServer.GetConfig(); - protected HashSet? _lootableItemBlacklistCache = []; + protected readonly HashSet? _lootableItemBlacklistCache = []; /// /// Check if the provided template id is blacklisted in config/item.json/blacklist diff --git a/Libraries/SPTarkov.Server.Core/Services/MailSendService.cs b/Libraries/SPTarkov.Server.Core/Services/MailSendService.cs index a21b82da..395bf631 100644 --- a/Libraries/SPTarkov.Server.Core/Services/MailSendService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/MailSendService.cs @@ -30,12 +30,12 @@ public class MailSendService( ) { private const string _systemSenderId = "59e7125688a45068a6249071"; - protected HashSet _messageTypes = + protected readonly HashSet _messageTypes = [ MessageType.NpcTraderMessage, MessageType.FleamarketMessage, ]; - protected HashSet _slotNames = ["hideout", "main"]; + protected readonly HashSet _slotNames = ["hideout", "main"]; /// /// Send a message from an NPC (e.g. prapor) to the player with or without items using direct message text, do not look up any locale diff --git a/Libraries/SPTarkov.Server.Core/Services/MatchLocationService.cs b/Libraries/SPTarkov.Server.Core/Services/MatchLocationService.cs index d8c8113c..62e3e731 100644 --- a/Libraries/SPTarkov.Server.Core/Services/MatchLocationService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/MatchLocationService.cs @@ -6,7 +6,7 @@ namespace SPTarkov.Server.Core.Services; [Injectable(InjectionType.Singleton)] public class MatchLocationService { - protected Dictionary _locations = new(); + protected readonly Dictionary _locations = new(); /// /// DisbandRaidGroup diff --git a/Libraries/SPTarkov.Server.Core/Services/NotificationService.cs b/Libraries/SPTarkov.Server.Core/Services/NotificationService.cs index d2970764..4f615051 100644 --- a/Libraries/SPTarkov.Server.Core/Services/NotificationService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/NotificationService.cs @@ -6,7 +6,7 @@ namespace SPTarkov.Server.Core.Services; [Injectable(InjectionType.Singleton)] public class NotificationService { - protected Dictionary> _messageQueue = new(); + protected readonly Dictionary> _messageQueue = new(); public Dictionary> GetMessageQueue() { diff --git a/Libraries/SPTarkov.Server.Core/Services/OpenZoneService.cs b/Libraries/SPTarkov.Server.Core/Services/OpenZoneService.cs index 836d8ada..d0a413fa 100644 --- a/Libraries/SPTarkov.Server.Core/Services/OpenZoneService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/OpenZoneService.cs @@ -16,7 +16,7 @@ public class OpenZoneService( ConfigServer _configServer ) { - protected LocationConfig _locationConfig = _configServer.GetConfig(); + protected readonly LocationConfig _locationConfig = _configServer.GetConfig(); /// /// Add open zone to specified map diff --git a/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs b/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs index 05243a03..8d8866a0 100644 --- a/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/PaymentService.cs @@ -29,7 +29,8 @@ public class PaymentService( ConfigServer _configServer ) { - protected InventoryConfig _inventoryConfig = _configServer.GetConfig(); + protected readonly InventoryConfig _inventoryConfig = + _configServer.GetConfig(); /// /// Take money and insert items into return to server request diff --git a/Libraries/SPTarkov.Server.Core/Services/PmcChatResponseService.cs b/Libraries/SPTarkov.Server.Core/Services/PmcChatResponseService.cs index ff53260a..13fedb3b 100644 --- a/Libraries/SPTarkov.Server.Core/Services/PmcChatResponseService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/PmcChatResponseService.cs @@ -28,7 +28,8 @@ public class PmcChatResponseService( ) { protected GiftsConfig _giftConfig = _configServer.GetConfig(); - protected PmcChatResponse _pmcResponsesConfig = _configServer.GetConfig(); + protected readonly PmcChatResponse _pmcResponsesConfig = + _configServer.GetConfig(); /// /// For each PMC victim of the player, have a chance to send a message to the player, can be positive or negative diff --git a/Libraries/SPTarkov.Server.Core/Services/PostDbLoadService.cs b/Libraries/SPTarkov.Server.Core/Services/PostDbLoadService.cs index 15d3fa83..6f440a9c 100644 --- a/Libraries/SPTarkov.Server.Core/Services/PostDbLoadService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/PostDbLoadService.cs @@ -24,14 +24,14 @@ public class PostDbLoadService( ICloner _cloner ) { - protected BotConfig _botConfig = _configServer.GetConfig(); - protected CoreConfig _coreConfig = _configServer.GetConfig(); - protected HideoutConfig _hideoutConfig = _configServer.GetConfig(); - protected ItemConfig _itemConfig = _configServer.GetConfig(); - protected LocationConfig _locationConfig = _configServer.GetConfig(); - protected LootConfig _lootConfig = _configServer.GetConfig(); - protected PmcConfig _pmcConfig = _configServer.GetConfig(); - protected RagfairConfig _ragfairConfig = _configServer.GetConfig(); + protected readonly BotConfig _botConfig = _configServer.GetConfig(); + protected readonly CoreConfig _coreConfig = _configServer.GetConfig(); + protected readonly HideoutConfig _hideoutConfig = _configServer.GetConfig(); + protected readonly ItemConfig _itemConfig = _configServer.GetConfig(); + protected readonly LocationConfig _locationConfig = _configServer.GetConfig(); + protected readonly LootConfig _lootConfig = _configServer.GetConfig(); + protected readonly PmcConfig _pmcConfig = _configServer.GetConfig(); + protected readonly RagfairConfig _ragfairConfig = _configServer.GetConfig(); public void PerformPostDbLoadActions() { diff --git a/Libraries/SPTarkov.Server.Core/Services/ProfileFixerService.cs b/Libraries/SPTarkov.Server.Core/Services/ProfileFixerService.cs index d89d8e14..01e6e7b1 100644 --- a/Libraries/SPTarkov.Server.Core/Services/ProfileFixerService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/ProfileFixerService.cs @@ -30,8 +30,8 @@ public class ProfileFixerService( InventoryHelper _inventoryHelper ) { - protected List _areas = ["hideout", "main"]; - protected CoreConfig _coreConfig = _configServer.GetConfig(); + protected readonly List _areas = ["hideout", "main"]; + protected readonly CoreConfig _coreConfig = _configServer.GetConfig(); /// /// Find issues in the pmc profile data that may cause issues and fix them diff --git a/Libraries/SPTarkov.Server.Core/Services/RagfairOfferService.cs b/Libraries/SPTarkov.Server.Core/Services/RagfairOfferService.cs index 215861a5..de879b29 100644 --- a/Libraries/SPTarkov.Server.Core/Services/RagfairOfferService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/RagfairOfferService.cs @@ -31,7 +31,7 @@ public class RagfairOfferService( ) { private bool _playerOffersLoaded; - protected RagfairConfig _ragfairConfig = configServer.GetConfig(); + protected readonly RagfairConfig _ragfairConfig = configServer.GetConfig(); /// /// Get all offers diff --git a/Libraries/SPTarkov.Server.Core/Services/RagfairTaxService.cs b/Libraries/SPTarkov.Server.Core/Services/RagfairTaxService.cs index eaba6f9a..55ae0de8 100644 --- a/Libraries/SPTarkov.Server.Core/Services/RagfairTaxService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/RagfairTaxService.cs @@ -21,7 +21,10 @@ public class RagfairTaxService( ICloner _cloner ) { - protected Dictionary _playerOfferTaxCache = new(); + protected readonly Dictionary< + string, + StorePlayerOfferTaxAmountRequestData + > _playerOfferTaxCache = new(); public void StoreClientOfferTaxValue( string sessionId, diff --git a/Libraries/SPTarkov.Server.Core/Services/RaidTimeAdjustmentService.cs b/Libraries/SPTarkov.Server.Core/Services/RaidTimeAdjustmentService.cs index 266148ef..cb89ca54 100644 --- a/Libraries/SPTarkov.Server.Core/Services/RaidTimeAdjustmentService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/RaidTimeAdjustmentService.cs @@ -21,7 +21,7 @@ public class RaidTimeAdjustmentService( ConfigServer _configServer ) { - protected LocationConfig _locationConfig = _configServer.GetConfig(); + protected readonly LocationConfig _locationConfig = _configServer.GetConfig(); /// /// Make alterations to the base map data passed in diff --git a/Libraries/SPTarkov.Server.Core/Services/RaidWeatherService.cs b/Libraries/SPTarkov.Server.Core/Services/RaidWeatherService.cs index 891af91f..2afdbc8f 100644 --- a/Libraries/SPTarkov.Server.Core/Services/RaidWeatherService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/RaidWeatherService.cs @@ -18,8 +18,8 @@ public class RaidWeatherService( ConfigServer _configServer ) { - protected WeatherConfig _weatherConfig = _configServer.GetConfig(); - protected List _weatherForecast = []; + protected readonly WeatherConfig _weatherConfig = _configServer.GetConfig(); + protected readonly List _weatherForecast = []; /// /// Generate 24 hours of weather data starting from midnight today diff --git a/Libraries/SPTarkov.Server.Core/Services/RepairService.cs b/Libraries/SPTarkov.Server.Core/Services/RepairService.cs index 5534b4b1..22328a5a 100644 --- a/Libraries/SPTarkov.Server.Core/Services/RepairService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/RepairService.cs @@ -34,7 +34,7 @@ public class RepairService( WeightedRandomHelper _weightedRandomHelper ) { - protected RepairConfig _repairConfig = _configServer.GetConfig(); + protected readonly RepairConfig _repairConfig = _configServer.GetConfig(); /// /// Use trader to repair an items durability diff --git a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs index 752ed530..4ead2f83 100644 --- a/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/SeasonalEventService.cs @@ -84,13 +84,18 @@ public class SeasonalEventService( ItemTpl.RANDOMLOOTCONTAINER_PUMPKIN_RAND_LOOT_CONTAINER, ]; - protected HttpConfig _httpConfig = _configServer.GetConfig(); - protected LocationConfig _locationConfig = _configServer.GetConfig(); - protected HashSet _lootContainersToFilter = ["Backpack", "Pockets", "TacticalVest"]; - protected QuestConfig _questConfig = _configServer.GetConfig(); - protected SeasonalEventConfig _seasonalEventConfig = + protected readonly HttpConfig _httpConfig = _configServer.GetConfig(); + protected readonly LocationConfig _locationConfig = _configServer.GetConfig(); + protected readonly HashSet _lootContainersToFilter = + [ + "Backpack", + "Pockets", + "TacticalVest", + ]; + protected readonly QuestConfig _questConfig = _configServer.GetConfig(); + protected readonly SeasonalEventConfig _seasonalEventConfig = _configServer.GetConfig(); - protected WeatherConfig _weatherConfig = _configServer.GetConfig(); + protected readonly WeatherConfig _weatherConfig = _configServer.GetConfig(); /// /// Get an array of christmas items found in bots inventories as loot diff --git a/Libraries/SPTarkov.Server.Core/Services/TraderPurchasePersisterService.cs b/Libraries/SPTarkov.Server.Core/Services/TraderPurchasePersisterService.cs index c1c1820f..780c5c89 100644 --- a/Libraries/SPTarkov.Server.Core/Services/TraderPurchasePersisterService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/TraderPurchasePersisterService.cs @@ -18,7 +18,7 @@ public class TraderPurchasePersisterService( ConfigServer _configServer ) { - protected TraderConfig _traderConfig = _configServer.GetConfig(); + protected readonly TraderConfig _traderConfig = _configServer.GetConfig(); /// /// Get the purchases made from a trader for this profile before the last trader reset diff --git a/Libraries/SPTarkov.Server.Core/Utils/HttpResponseUtil.cs b/Libraries/SPTarkov.Server.Core/Utils/HttpResponseUtil.cs index d97bb886..fb34fd39 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/HttpResponseUtil.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/HttpResponseUtil.cs @@ -14,7 +14,7 @@ public class HttpResponseUtil protected readonly JsonUtil _jsonUtil; protected readonly LocalisationService _localisationService; - protected ImmutableList _cleanupRegexList = + protected readonly ImmutableList _cleanupRegexList = [ new("[\\b]"), new("[\\f]"), diff --git a/Libraries/SPTarkov.Server.Core/Utils/TimerUtil.cs b/Libraries/SPTarkov.Server.Core/Utils/TimerUtil.cs index 454b27cb..bb73a12f 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/TimerUtil.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/TimerUtil.cs @@ -6,7 +6,7 @@ namespace SPTarkov.Server.Core.Utils; [Injectable] public class TimerUtil { - protected Stopwatch _stopwatch; + protected readonly Stopwatch _stopwatch; public TimerUtil() {