Updated acceptableFileExtensions to be a frozenSet
Removed more boxing
This commit is contained in:
@@ -198,12 +198,12 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
/// <param name="items">List of items (item + possible children)</param>
|
||||
/// <param name="baseItemId">Parent item's id</param>
|
||||
/// <returns>list of child item ids</returns>
|
||||
public static List<string> FindAndReturnChildrenByItems(
|
||||
public static List<MongoId> FindAndReturnChildrenByItems(
|
||||
this IEnumerable<Item> items,
|
||||
string baseItemId
|
||||
MongoId baseItemId
|
||||
)
|
||||
{
|
||||
List<string> list = [];
|
||||
List<MongoId> list = [];
|
||||
|
||||
foreach (var childItem in items)
|
||||
{
|
||||
@@ -312,7 +312,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
if (
|
||||
!result.ContainsKey(childItem.Id)
|
||||
&& childItem.ParentId != "hideout"
|
||||
&& childItem.ParentId == baseItemId
|
||||
&& childItem.ParentId == baseItemId.ToString()
|
||||
)
|
||||
{
|
||||
foreach (var item in FindAndReturnChildrenAsItems(items, childItem.Id))
|
||||
@@ -367,7 +367,7 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
/// </summary>
|
||||
/// <param name="items">Inventory items to look for secure container in</param>
|
||||
/// <returns>List of ids</returns>
|
||||
public static List<string> GetSecureContainerItems(this List<Item> items)
|
||||
public static List<MongoId> GetSecureContainerItems(this List<Item> items)
|
||||
{
|
||||
var secureContainer = items.First(x => x.SlotId == "SecuredContainer");
|
||||
|
||||
|
||||
@@ -761,7 +761,7 @@ public class RagfairOfferGenerator(
|
||||
if (!(profileHelper.IsPlayer(userID) || ragfairServerHelper.IsTrader(userID)))
|
||||
{
|
||||
var parentId = GetDynamicConditionIdForTpl(itemDetails.Id);
|
||||
if (string.IsNullOrEmpty(parentId))
|
||||
if (parentId == null)
|
||||
// No condition details found, don't proceed with modifying item conditions
|
||||
{
|
||||
return;
|
||||
@@ -770,11 +770,11 @@ public class RagfairOfferGenerator(
|
||||
// Roll random chance to randomise item condition
|
||||
if (
|
||||
randomUtil.GetChance100(
|
||||
ragfairConfig.Dynamic.Condition[parentId].ConditionChance * 100
|
||||
ragfairConfig.Dynamic.Condition[parentId.Value].ConditionChance * 100
|
||||
)
|
||||
)
|
||||
{
|
||||
RandomiseItemCondition(parentId, itemWithMods, itemDetails);
|
||||
RandomiseItemCondition(parentId.Value, itemWithMods, itemDetails);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -784,7 +784,7 @@ public class RagfairOfferGenerator(
|
||||
/// </summary>
|
||||
/// <param name="tpl"> Item to look for matching condition object</param>
|
||||
/// <returns> Condition ID </returns>
|
||||
protected string? GetDynamicConditionIdForTpl(MongoId tpl)
|
||||
protected MongoId? GetDynamicConditionIdForTpl(MongoId tpl)
|
||||
{
|
||||
// Get keys from condition config dictionary
|
||||
var configConditions = ragfairConfig.Dynamic.Condition.Keys;
|
||||
@@ -806,7 +806,7 @@ public class RagfairOfferGenerator(
|
||||
/// <param name="itemWithMods"> Item to adjust condition details of </param>
|
||||
/// <param name="itemDetails"> DB Item details of first item in list </param>
|
||||
protected void RandomiseItemCondition(
|
||||
string conditionSettingsId,
|
||||
MongoId conditionSettingsId,
|
||||
List<Item> itemWithMods,
|
||||
TemplateItem itemDetails
|
||||
)
|
||||
|
||||
@@ -1856,29 +1856,33 @@ public class ItemHelper(
|
||||
return GetRemovablePlateSlotIds().Contains(slotName.ToLowerInvariant());
|
||||
}
|
||||
|
||||
// Get a list of slot names that hold removable plates
|
||||
// Returns Array of slot ids (e.g. front_plate)
|
||||
/// <summary>
|
||||
/// Get a list of slot names that hold removable plates
|
||||
/// </summary>
|
||||
/// <returns>Array of slot ids (e.g. front_plate)</returns>
|
||||
public FrozenSet<string> GetRemovablePlateSlotIds()
|
||||
{
|
||||
return _removablePlateSlotIds;
|
||||
}
|
||||
|
||||
// Generate new unique ids for child items while preserving hierarchy
|
||||
// Base/primary item
|
||||
// Primary item + children of primary item
|
||||
// Returns Item array with updated IDs
|
||||
/// <summary>
|
||||
/// Generate new unique ids for child items while preserving hierarchy
|
||||
/// </summary>
|
||||
/// <param name="rootItem">Base/primary item</param>
|
||||
/// <param name="itemWithChildren">Primary item + children of primary item</param>
|
||||
/// <returns>Item array with updated IDs</returns>
|
||||
public List<Item> ReparentItemAndChildren(Item rootItem, List<Item> itemWithChildren)
|
||||
{
|
||||
var oldRootId = itemWithChildren[0].Id;
|
||||
Dictionary<string, MongoId> idMappings = new();
|
||||
Dictionary<string, MongoId> idMappings = [];
|
||||
|
||||
idMappings[oldRootId] = rootItem.Id;
|
||||
idMappings[oldRootId.ToString()] = rootItem.Id;
|
||||
|
||||
foreach (var mod in itemWithChildren)
|
||||
{
|
||||
if (!idMappings.ContainsKey(mod.Id))
|
||||
{
|
||||
idMappings[mod.Id] = new MongoId();
|
||||
idMappings[mod.Id.ToString()] = new MongoId();
|
||||
}
|
||||
|
||||
// Has parentId + no remapping exists for its parent
|
||||
@@ -1891,7 +1895,7 @@ public class ItemHelper(
|
||||
idMappings[mod.ParentId] = new MongoId();
|
||||
}
|
||||
|
||||
mod.Id = idMappings[mod.Id];
|
||||
mod.Id = idMappings[mod.Id.ToString()];
|
||||
if (mod.ParentId != null)
|
||||
{
|
||||
mod.ParentId = idMappings[mod.ParentId];
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Frozen;
|
||||
using SPTarkov.DI.Annotations;
|
||||
using SPTarkov.Server.Core.Models.Enums;
|
||||
using SPTarkov.Server.Core.Models.Spt.Config;
|
||||
@@ -10,7 +11,7 @@ namespace SPTarkov.Server.Core.Servers;
|
||||
[Injectable(InjectionType.Singleton)]
|
||||
public class ConfigServer
|
||||
{
|
||||
protected readonly string[] acceptableFileExtensions = ["json", "jsonc"];
|
||||
protected readonly FrozenSet<string> acceptableFileExtensions = ["json", "jsonc"];
|
||||
protected readonly FileUtil _fileUtil;
|
||||
protected readonly JsonUtil _jsonUtil;
|
||||
protected readonly ISptLogger<ConfigServer> _logger;
|
||||
|
||||
@@ -1472,7 +1472,7 @@ public class FenceService(
|
||||
protected void RemoveRandomModsOfItem(List<Item> itemAndMods)
|
||||
{
|
||||
// Items to be removed from inventory
|
||||
var toDelete = new HashSet<string>();
|
||||
var toDelete = new HashSet<MongoId>();
|
||||
|
||||
// Find mods to remove from item that could've been scavenged by other players in-raid
|
||||
foreach (var itemMod in itemAndMods)
|
||||
@@ -1507,7 +1507,7 @@ public class FenceService(
|
||||
/// <param name="weaponMod"> Weapon mod being checked </param>
|
||||
/// <param name="itemsBeingDeleted"> Current list of items on weapon being deleted </param>
|
||||
/// <returns> True if item will be removed </returns>
|
||||
protected bool PresetModItemWillBeRemoved(Item weaponMod, HashSet<string> itemsBeingDeleted)
|
||||
protected bool PresetModItemWillBeRemoved(Item weaponMod, HashSet<MongoId> itemsBeingDeleted)
|
||||
{
|
||||
var slotIdsThatCanFail = traderConfig.Fence.PresetSlotsToRemoveChancePercent;
|
||||
if (
|
||||
|
||||
@@ -312,7 +312,7 @@ public class RagfairPriceService(
|
||||
// Make adjustments for unreasonably priced items.
|
||||
foreach (var (key, value) in _ragfairConfig.Dynamic.UnreasonableModPrices)
|
||||
{
|
||||
if (!itemHelper.IsOfBaseclass(itemTemplateId, key) || !value.Enabled)
|
||||
if (!value.Enabled || !itemHelper.IsOfBaseclass(itemTemplateId, key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user