diff --git a/Libraries/Core/Controllers/RepeatableQuestController.cs b/Libraries/Core/Controllers/RepeatableQuestController.cs index 2b0a9722..7caa5175 100644 --- a/Libraries/Core/Controllers/RepeatableQuestController.cs +++ b/Libraries/Core/Controllers/RepeatableQuestController.cs @@ -105,7 +105,7 @@ public class RepeatableQuestController( { // Unable to find quest being replaced var message = - $"Unable to generate repeatable quest of type: {repeatableTypeLower} to replace trader: ${replacedQuestTraderId} quest ${changeRequest.QuestId}"; + $"Unable to generate repeatable quest of type: {repeatableTypeLower} to replace trader: ${replacedQuestTraderId} quest: {changeRequest.QuestId}"; _logger.Error(message); return _httpResponseUtil.AppendErrorToOutput(output, message); diff --git a/Libraries/Core/Generators/BotEquipmentModGenerator.cs b/Libraries/Core/Generators/BotEquipmentModGenerator.cs index 30bacb89..23ce9a21 100644 --- a/Libraries/Core/Generators/BotEquipmentModGenerator.cs +++ b/Libraries/Core/Generators/BotEquipmentModGenerator.cs @@ -1105,7 +1105,7 @@ public class BotEquipmentModGenerator( if (!desiredMagazineTpls.Any()) { - _logger.Warning("Magazine size filter for ${ weaponTpl} was too strict, ignoring filter"); + _logger.Warning($"Magazine size filter for { weaponTpl} was too strict, ignoring filter"); return modPool; } diff --git a/Libraries/Core/Generators/LocationLootGenerator.cs b/Libraries/Core/Generators/LocationLootGenerator.cs index 5c3bbbcf..0690af4e 100644 --- a/Libraries/Core/Generators/LocationLootGenerator.cs +++ b/Libraries/Core/Generators/LocationLootGenerator.cs @@ -376,7 +376,7 @@ public class LocationLootGenerator( if(_logger.IsLogEnabled(LogLevel.Debug)) { _logger.Debug( - $"Container {container.Template.Id} with group ${groupData.GroupId} had 100 % chance to spawn was picked as random container, skipping" + $"Container {container.Template.Id} with group: {groupData.GroupId} had 100 % chance to spawn was picked as random container, skipping" ); } @@ -504,7 +504,7 @@ public class LocationLootGenerator( var itemTemplate = _itemHelper.GetItem(rootItem.Template).Value; if (itemTemplate.Properties is null) { - _logger.Error($"Unable to process item: ${{chosenTpl}}. it lacks _props"); + _logger.Error($"Unable to process item: {rootItem.Template}. it lacks _props"); return null; } @@ -1044,7 +1044,7 @@ public class LocationLootGenerator( var itemTemplate = _itemHelper.GetItem(chosenTpl).Value; if (itemTemplate.Properties is null) { - _logger.Error($"Unable to process item: ${{chosenTpl}}. it lacks _props"); + _logger.Error($"Unable to process item: {chosenTpl}. it lacks _props"); return null; } diff --git a/Libraries/Core/Generators/LootGenerator.cs b/Libraries/Core/Generators/LootGenerator.cs index f62838e3..9d8f8aaa 100644 --- a/Libraries/Core/Generators/LootGenerator.cs +++ b/Libraries/Core/Generators/LootGenerator.cs @@ -363,7 +363,7 @@ public class LootGenerator( if (chosenPreset.Encyclopedia is null) { if(_logger.IsLogEnabled(LogLevel.Debug)) { - _logger.Debug("$Preset with id: {chosenPreset?.Id} lacks encyclopedia property, skipping"); + _logger.Debug($"Preset with id: {chosenPreset?.Id} lacks encyclopedia property, skipping"); } return false; diff --git a/Libraries/Core/Generators/RepeatableQuestGenerator.cs b/Libraries/Core/Generators/RepeatableQuestGenerator.cs index 26533f68..aed4d27d 100644 --- a/Libraries/Core/Generators/RepeatableQuestGenerator.cs +++ b/Libraries/Core/Generators/RepeatableQuestGenerator.cs @@ -820,7 +820,7 @@ public class RepeatableQuestGenerator( if (possibleExits.Count == 0) { - _logger.Error("Unable to choose specific exit on map: ${ locationKey}, Possible exit pool was empty"); + _logger.Error($"Unable to choose specific exit on map: {locationKey}, Possible exit pool was empty"); } else { diff --git a/Libraries/Core/Helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.cs b/Libraries/Core/Helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.cs index f2deb2dd..bde97cd0 100644 --- a/Libraries/Core/Helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.cs +++ b/Libraries/Core/Helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.cs @@ -159,7 +159,7 @@ public class GiveSptCommand( _mailSendService.SendUserMessageToPlayer( sessionId, commandHandler, - $"Could not find exact match. Closest matches are:\n\n${itemList}\n\nUse 'spt give [number]' to select one."); + $"Could not find exact match. Closest matches are:\n\n{itemList}\n\nUse 'spt give [number]' to select one."); return request.DialogId; } diff --git a/Libraries/Core/Helpers/Dialogue/Commando/SptCommands/ProfileCommand/ProfileSptCommand.cs b/Libraries/Core/Helpers/Dialogue/Commando/SptCommands/ProfileCommand/ProfileSptCommand.cs index 1ec2ab67..a50f668f 100644 --- a/Libraries/Core/Helpers/Dialogue/Commando/SptCommands/ProfileCommand/ProfileSptCommand.cs +++ b/Libraries/Core/Helpers/Dialogue/Commando/SptCommands/ProfileCommand/ProfileSptCommand.cs @@ -96,7 +96,7 @@ public class ProfileSptCommand( return request.DialogId; } - if (quantity < 0 || quantity > 51) { + if (quantity is < 0 or > 51) { _mailSendService.SendUserMessageToPlayer( sessionId, commandHandler, @@ -116,7 +116,7 @@ public class ProfileSptCommand( _mailSendService.SendUserMessageToPlayer( sessionId, commandHandler, - $"If you are reading this, this is bad. Please report this to SPT staff with a screenshot. Command ${command}." + $"If you are reading this, this is bad. Please report this to SPT staff with a screenshot. Command: {command}." ); return request.DialogId; } diff --git a/Libraries/Core/Helpers/InventoryHelper.cs b/Libraries/Core/Helpers/InventoryHelper.cs index b7f5333a..d246ba78 100644 --- a/Libraries/Core/Helpers/InventoryHelper.cs +++ b/Libraries/Core/Helpers/InventoryHelper.cs @@ -202,7 +202,7 @@ public class InventoryHelper( var stashFS2D = _cloner.Clone(GetStashSlotMap(pmcData, sessionId)); if (stashFS2D is null) { - _logger.Error($"Unable to get stash map for players: ${sessionId} stash"); + _logger.Error($"Unable to get stash map for players: {sessionId} stash"); return false; } diff --git a/Libraries/Core/Helpers/RagfairOfferHelper.cs b/Libraries/Core/Helpers/RagfairOfferHelper.cs index dbdf7309..e66ebe6a 100644 --- a/Libraries/Core/Helpers/RagfairOfferHelper.cs +++ b/Libraries/Core/Helpers/RagfairOfferHelper.cs @@ -542,7 +542,7 @@ public class RagfairOfferHelper( // No trader assort data _logger.Warning( $"Unable to find trader: " + - $"${offer.User.Nickname}assort for item: ${_itemHelper.GetItemName(offer.Items[0].Template)} " + + $"${offer.User.Nickname}assort for item: {_itemHelper.GetItemName(offer.Items[0].Template)} " + $"{offer.Items[0].Template}, cannot check if buy restriction reached" ); @@ -969,33 +969,6 @@ public class RagfairOfferHelper( return offer.Items.Count > 1; } - /// - /// Should a ragfair offer be visible to the player - /// - /// Search request - /// ? - /// Trader assort items - used for filtering out locked trader items - /// The flea offer - /// Player profile - /// Optional parameter - /// True = should be shown to player - public bool DisplayableOffer( - SearchRequestData searchRequest, - List itemsToAdd, - Dictionary traderAssorts, - RagfairOffer offer, - PmcData pmcProfile, - bool? playerIsFleaBanned = null - ) - { - throw new NotImplementedException(); - } - - public bool IsDisplayableOfferThatNeedsItem(SearchRequestData searchRequest, RagfairOffer offer) - { - return offer.Requirements.Any(requirement => requirement.Template == searchRequest.NeededSearchId); - } - /// /// Does the passed in item have a condition property /// diff --git a/Libraries/Core/Services/CustomLocationWaveService.cs b/Libraries/Core/Services/CustomLocationWaveService.cs index c8399d7e..ba820ebf 100644 --- a/Libraries/Core/Services/CustomLocationWaveService.cs +++ b/Libraries/Core/Services/CustomLocationWaveService.cs @@ -66,7 +66,7 @@ public class CustomLocationWaveService( var locationBase = _databaseService.GetLocation(mapKvP.Key).Base; if (locationBase is null) { - _logger.Warning($"Unable to add custom boss wave to location: ${mapKvP}, location not found"); + _logger.Warning($"Unable to add custom boss wave to location: {mapKvP}, location not found"); continue; } diff --git a/Libraries/Core/Services/FenceService.cs b/Libraries/Core/Services/FenceService.cs index db6933b6..42093548 100644 --- a/Libraries/Core/Services/FenceService.cs +++ b/Libraries/Core/Services/FenceService.cs @@ -1257,13 +1257,18 @@ public class FenceService( traderConfig.Fence.ArmorMaxDurabilityPercentMinMax ); - // Find items mod to apply dura changes to - var modItemToAdjust = armorWithMods.FirstOrDefault(mod => mod.SlotId.ToLower() == plateSlot.Name.ToLower()); + // Find items mod to apply durability changes to + var modItemToAdjust = armorWithMods.FirstOrDefault(mod => string.Equals( + mod.SlotId, + plateSlot.Name, + StringComparison.OrdinalIgnoreCase + ) + ); if (modItemToAdjust == null) { logger.Warning( - $"Unable to randomise armor items {armorWithMods[0].Template} ${plateSlot.Name} slot as it cannot be found, skipping" + $"Unable to randomise armor items {armorWithMods[0].Template} {plateSlot.Name} slot as it cannot be found, skipping" ); continue; } @@ -1272,7 +1277,7 @@ public class FenceService( if (modItemToAdjust?.Upd?.Repairable == null) { - modItemToAdjust.Upd.Repairable = new UpdRepairable() + modItemToAdjust.Upd.Repairable = new UpdRepairable { Durability = modItemDbDetails.Properties.MaxDurability, MaxDurability = modItemDbDetails.Properties.MaxDurability diff --git a/Libraries/Core/Services/LocationLifecycleService.cs b/Libraries/Core/Services/LocationLifecycleService.cs index 276948a8..4374416c 100644 --- a/Libraries/Core/Services/LocationLifecycleService.cs +++ b/Libraries/Core/Services/LocationLifecycleService.cs @@ -225,7 +225,7 @@ public class LocationLifecycleService // No matching bot in config, skip if (locationBotHostilityDetails is null) { - _logger.Warning("No bot: ${botId} hostility values found on: ${location.Id}, can only edit existing. Skipping"); + _logger.Warning($"No bot: {botId} hostility values found on: {location.Id}, can only edit existing. Skipping"); continue; } diff --git a/Libraries/Core/Services/RagfairPriceService.cs b/Libraries/Core/Services/RagfairPriceService.cs index 6a3eef0c..74f63235 100644 --- a/Libraries/Core/Services/RagfairPriceService.cs +++ b/Libraries/Core/Services/RagfairPriceService.cs @@ -8,6 +8,7 @@ using Core.Models.Enums; using Core.Servers; using Core.Utils; using Core.Models.Eft.Common; +using LogLevel = Core.Models.Spt.Logging.LogLevel; namespace Core.Services; @@ -480,13 +481,14 @@ public class RagfairPriceService( return new WeaponPreset { IsDefault = true, Preset = defaultPreset }; } var nonDefaultPresets = _presetHelper.GetPresets(weapon.Template); - if (nonDefaultPresets.Count == 1) + + if (_logger.IsLogEnabled(LogLevel.Debug)) { - _logger.Debug($"Item Id: ${ weapon.Template} has no default encyclopedia entry but only one preset(${ nonDefaultPresets[0].Name}), choosing preset(${ nonDefaultPresets[0].Name})"); - } - else - { - _logger.Debug($"Item Id: ${ weapon.Template} has no default encyclopedia entry, choosing first preset(${ nonDefaultPresets[0].Name}) of ${ nonDefaultPresets.Count}"); + _logger.Debug( + nonDefaultPresets.Count == 1 + ? $"Item Id: ${weapon.Template} has no default encyclopedia entry but only one preset: ({nonDefaultPresets[0].Name}), choosing preset: ({nonDefaultPresets[0].Name})" + : $"Item Id: ${weapon.Template} has no default encyclopedia entry, choosing first preset(${nonDefaultPresets[0].Name}) of ${nonDefaultPresets.Count}" + ); } return new WeaponPreset { IsDefault = false, Preset = nonDefaultPresets[0] }; diff --git a/Libraries/Core/Services/RepairService.cs b/Libraries/Core/Services/RepairService.cs index 603bb8b9..6af667ca 100644 --- a/Libraries/Core/Services/RepairService.cs +++ b/Libraries/Core/Services/RepairService.cs @@ -14,6 +14,7 @@ using Core.Utils; using SptCommon.Annotations; using SptCommon.Extensions; using BonusSettings = Core.Models.Spt.Config.BonusSettings; +using LogLevel = Core.Models.Spt.Logging.LogLevel; namespace Core.Services; @@ -97,9 +98,12 @@ public class RepairService( itemRepairCost.Value * repairItemDetails.Count.Value * repairRate.Value * _repairConfig.PriceMultiplier ); - _logger.Debug($"item base repair cost: ${itemRepairCost}"); - _logger.Debug($"price multiplier: ${_repairConfig.PriceMultiplier}"); - _logger.Debug($"repair cost: ${repairCost}"); + if (_logger.IsLogEnabled(LogLevel.Debug)) + { + _logger.Debug($"item base repair cost: {itemRepairCost}"); + _logger.Debug($"price multiplier: {_repairConfig.PriceMultiplier}"); + _logger.Debug($"repair cost: {repairCost}"); + } return new RepairDetails { @@ -455,7 +459,11 @@ public class RepairService( var maxRepairAmount = repairKitDetails.Properties.MaxRepairResource; if (repairKitInInventory.Upd is null) { - _logger.Debug($"Repair kit: ${repairKitInInventory.Id} in inventory lacks upd object, adding"); + if(_logger.IsLogEnabled(LogLevel.Debug)) + { + _logger.Debug($"Repair kit: {repairKitInInventory.Id} in inventory lacks upd object, adding"); + } + repairKitInInventory.Upd = new Upd { RepairKit = new UpdRepairKit { Resource = maxRepairAmount } }; } diff --git a/Libraries/Core/Services/SeasonalEventService.cs b/Libraries/Core/Services/SeasonalEventService.cs index 00842f60..b7e44ad6 100644 --- a/Libraries/Core/Services/SeasonalEventService.cs +++ b/Libraries/Core/Services/SeasonalEventService.cs @@ -785,33 +785,33 @@ public class SeasonalEventService( /// OPTIONAL - Maps to add bosses to protected void AddEventBossesToMaps(string eventType, List mapIdWhitelist = null) { - var botsToAddPerMap = _seasonalEventConfig.EventBossSpawns[eventType.ToLower()]; - if (botsToAddPerMap is null) + if (!_seasonalEventConfig.EventBossSpawns.TryGetValue(eventType.ToLower(), out var botsToAddPerMap)) { - _logger.Warning($"Unable to add: ${eventType} bosses, eventBossSpawns is missing"); + _logger.Warning($"Unable to add: {eventType} bosses, eventBossSpawns is missing"); return; } var mapKeys = botsToAddPerMap; var locations = _databaseService.GetLocations().GetAllPropsAsDict(); - foreach (var map in mapKeys) { - var bossesToAdd = botsToAddPerMap[map.Key]; - if (bossesToAdd is null) + foreach (var (key, _) in mapKeys) { + if (!botsToAddPerMap.TryGetValue(key, out var bossesToAdd)) { - _logger.Warning($"Unable to add: ${ eventType} bosses to: ${map.Key}"); + _logger.Warning($"Unable to add: {eventType} bosses to: {key}"); + continue; } - if (mapIdWhitelist is null || !mapIdWhitelist.Contains(map.Key)) + if (mapIdWhitelist is null || !mapIdWhitelist.Contains(key)) { continue; } foreach (var boss in bossesToAdd) { - var mapBosses = ((Location)locations[map.Key]).Base.BossLocationSpawn; - if (!mapBosses.Any((bossSpawn) => bossSpawn.BossName == boss.BossName)) + var mapBosses = ((Location)locations[key]).Base.BossLocationSpawn; + // If no bosses match by name + if (mapBosses.All(bossSpawn => bossSpawn.BossName != boss.BossName)) { - ((Location)locations[map.Key]).Base.BossLocationSpawn.AddRange(bossesToAdd); + ((Location)locations[key]).Base.BossLocationSpawn.AddRange(bossesToAdd); } } }