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 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) { 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); } /// 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" ); } 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"); } 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}"; }