From e0cceab7fad579b43b0ff0e6de9a6c253ee1e508 Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 27 May 2025 16:27:23 +0100 Subject: [PATCH 1/6] Added nullguard to `GetLoadedServerMods()` --- .../Controllers/LauncherController.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Controllers/LauncherController.cs b/Libraries/SPTarkov.Server.Core/Controllers/LauncherController.cs index a81bd754..d4ddef63 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/LauncherController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/LauncherController.cs @@ -242,15 +242,13 @@ public class LauncherController( /// Dictionary of mod name and mod details public Dictionary GetLoadedServerMods() { - var mods = _applicationContext?.GetLatestValue(ContextVariableType.LOADED_MOD_ASSEMBLIES).GetValue>(); - var result = new Dictionary(); - - foreach (var sptMod in mods) + var mods = _applicationContext?.GetLatestValue(ContextVariableType.LOADED_MOD_ASSEMBLIES)?.GetValue>(); + if (mods == null) { - result.Add(sptMod.ModMetadata.Name, sptMod.ModMetadata); + return []; } - return result; + return mods.ToDictionary(sptMod => sptMod.ModMetadata?.Name ?? "UNKNOWN MOD", sptMod => sptMod.ModMetadata); } /// From 64885dd6a236df7e179de7112ec4902d76b9cd17 Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 27 May 2025 16:39:37 +0100 Subject: [PATCH 2/6] Surrounded call to `AddTaskConditionCountersToProfile` with null check inside `AcceptQuest` --- .../Controllers/QuestController.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Controllers/QuestController.cs b/Libraries/SPTarkov.Server.Core/Controllers/QuestController.cs index 4e75622d..170f9d4a 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/QuestController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/QuestController.cs @@ -90,7 +90,14 @@ public class QuestController( // Note that for starting quests, the correct locale field is "description", not "startedMessageText". var questFromDb = _questHelper.GetQuestFromDb(acceptedQuest.QuestId, pmcData); - AddTaskConditionCountersToProfile(questFromDb.Conditions.AvailableForFinish, pmcData, acceptedQuest.QuestId); + if (questFromDb.Conditions?.AvailableForFinish is not null) + { + AddTaskConditionCountersToProfile( + questFromDb.Conditions.AvailableForFinish, + pmcData, + acceptedQuest.QuestId); + } + // Get messageId of text to send to player as text message in game var messageId = _questHelper.GetMessageIdForQuestStart( @@ -136,14 +143,14 @@ public class QuestController( /// Conditions to iterate over and possibly add to profile /// Players PMC profile /// Quest where conditions originated - protected void AddTaskConditionCountersToProfile(List? questConditions, PmcData pmcData, string questId) + protected void AddTaskConditionCountersToProfile(List questConditions, PmcData pmcData, string questId) { foreach (var condition in questConditions) { if (pmcData.TaskConditionCounters.TryGetValue(condition.Id, out var counter)) { _logger.Error( - $"Unable to add new task condition counter: {condition.ConditionType} for quest: {questId} to profile: {pmcData.SessionId} as it already exists:" + $"Unable to add new task condition counter: {condition.ConditionType} for quest: {questId} to profile: {pmcData.SessionId} as it already exists" ); } From f25aaa70f1cc851e7a11540aff22318b0cb6ec42 Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 27 May 2025 17:12:20 +0100 Subject: [PATCH 3/6] Added nullguard to `SaveActiveModsToProfile` --- Libraries/SPTarkov.Server.Core/Callbacks/ClientLogCallbacks.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/SPTarkov.Server.Core/Callbacks/ClientLogCallbacks.cs b/Libraries/SPTarkov.Server.Core/Callbacks/ClientLogCallbacks.cs index 2b5bfb8d..e4df4e8a 100644 --- a/Libraries/SPTarkov.Server.Core/Callbacks/ClientLogCallbacks.cs +++ b/Libraries/SPTarkov.Server.Core/Callbacks/ClientLogCallbacks.cs @@ -48,7 +48,7 @@ public class ClientLogCallbacks( data.IllegalPluginsLoadedText = _localisationService.GetText("release-illegal-plugins-loaded"); data.IllegalPluginsExceptionText = _localisationService.GetText("release-illegal-plugins-exception"); data.ReleaseSummaryText = _localisationService.GetText("release-summary"); - data.IsBeta = ProgramStatics.ENTRY_TYPE() == EntryType.BLEEDING_EDGE || ProgramStatics.ENTRY_TYPE() == EntryType.BLEEDING_EDGE_MODS; + data.IsBeta = ProgramStatics.ENTRY_TYPE() is EntryType.BLEEDING_EDGE or EntryType.BLEEDING_EDGE_MODS; data.IsModdable = ProgramStatics.MODS(); data.IsModded = false; // TODO From f97b8b6f4f53734c40ce0ba4ab7a1fea40aa4bdf Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 27 May 2025 17:16:40 +0100 Subject: [PATCH 4/6] Fixed inverted logic check --- Libraries/SPTarkov.Server.Core/Services/GiftService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/SPTarkov.Server.Core/Services/GiftService.cs b/Libraries/SPTarkov.Server.Core/Services/GiftService.cs index 0e36969b..6de68593 100644 --- a/Libraries/SPTarkov.Server.Core/Services/GiftService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/GiftService.cs @@ -84,7 +84,7 @@ public class GiftService( return GiftSentResult.FAILED_GIFT_ALREADY_RECEIVED; } - if (giftData.Items?.Count > 0 && giftData.CollectionTimeHours is not null) + if (giftData.Items?.Count > 0 && giftData.CollectionTimeHours is null) { _logger.Warning($"Gift {giftId} has items but no collection time limit, defaulting to 48 hours"); } From 2902b757e6ddd2de80440b502f7fdcc2a6b06593 Mon Sep 17 00:00:00 2001 From: Chomp Date: Tue, 27 May 2025 17:17:23 +0100 Subject: [PATCH 5/6] Added nullguard check to `SaveActiveModsToProfile` --- .../SPTarkov.Server.Core/Controllers/GameController.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs b/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs index 5905e64e..59cbe466 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs @@ -472,7 +472,11 @@ public class GameController( protected void SaveActiveModsToProfile(SptProfile fullProfile) { fullProfile.SptData!.Mods ??= []; - var mods = _applicationContext?.GetLatestValue(ContextVariableType.LOADED_MOD_ASSEMBLIES).GetValue>(); + var mods = _applicationContext?.GetLatestValue(ContextVariableType.LOADED_MOD_ASSEMBLIES)?.GetValue>(); + if (mods == null) + { + return; + } foreach (var mod in mods) { From fe2e04b9f8316eea622cb6d8ae51f7b0f76204da Mon Sep 17 00:00:00 2001 From: CWX Date: Tue, 27 May 2025 18:54:53 +0100 Subject: [PATCH 6/6] put logging in debug, fix commit not being added to end of version --- Libraries/SPTarkov.Server.Core/Utils/ProgramStatics.cs | 2 ++ Libraries/SPTarkov.Server.Core/Utils/Watermark.cs | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Utils/ProgramStatics.cs b/Libraries/SPTarkov.Server.Core/Utils/ProgramStatics.cs index 8672f19a..d26d9c0d 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/ProgramStatics.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/ProgramStatics.cs @@ -40,10 +40,12 @@ public static partial class ProgramStatics break; } +#if DEBUG Console.WriteLine($"SPTarkov.Server.Core: entrytype: {_entryType}"); Console.WriteLine($"SPTarkov.Server.Core: debug: {_debug}"); Console.WriteLine($"SPTarkov.Server.Core: compiled: {_compiled}"); Console.WriteLine($"SPTarkov.Server.Core: mods: {_mods}"); +#endif } // Public Static Getters diff --git a/Libraries/SPTarkov.Server.Core/Utils/Watermark.cs b/Libraries/SPTarkov.Server.Core/Utils/Watermark.cs index eb83035f..2b458e58 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/Watermark.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/Watermark.cs @@ -149,10 +149,8 @@ public class Watermark /// label text public string GetInGameVersionLabel() { - var sptVersion = /*ProgramStatics.SPT_VERSION ||*/ sptConfig.SptVersion; - var versionTag = /*ProgramStatics.DEBUG ? */ - $"{sptVersion} - BLEEDINGEDGE { /*ProgramStatics.COMMIT?.slice(0, 6) ?? */""}"; - //: `{sptVersion} - {ProgramStatics.COMMIT?.slice(0, 6) ?? ""}`; + var sptVersion = ProgramStatics.SPT_VERSION(); + var versionTag = ProgramStatics.DEBUG() ? $"{sptVersion} - BLEEDINGEDGE {ProgramStatics.COMMIT()?.Substring(0, 6) ?? ""}" : $"{sptVersion} - {ProgramStatics.COMMIT()?.Substring(0, 6) ?? ""}"; return $"{sptConfig.ProjectName} {versionTag}"; }