Removed unnecessary nulls from Globals class

This commit is contained in:
Chomp
2025-07-16 12:20:19 +01:00
parent 8dce055acf
commit f3482e28d9
13 changed files with 1318 additions and 1323 deletions
@@ -842,7 +842,7 @@ public class HideoutController(
SkillTypes.Crafting,
databaseService
.GetGlobals()
.Configuration.SkillsSettings.Crafting.CraftTimeReductionPerLevel ?? 0
.Configuration.SkillsSettings.Crafting.CraftTimeReductionPerLevel
);
var modifiedScavCaseTime = GetScavCaseTime(pmcData, adjustedCraftTime);
@@ -980,9 +980,7 @@ public class RepeatableQuestController(
{
questCount += databaseService
.GetGlobals()
.Configuration.SkillsSettings.Charisma.BonusSettings.EliteBonusSettings.RepeatableQuestExtraCount.GetValueOrDefault(
0
);
.Configuration.SkillsSettings.Charisma.BonusSettings.EliteBonusSettings.RepeatableQuestExtraCount;
}
// Add any extra repeatable quests the profile has unlocked
@@ -189,7 +189,7 @@ namespace SPTarkov.Server.Core.Extensions
var accExp = 0;
for (var i = 0; i < expTable.Length; i++)
{
accExp += expTable[i].Experience ?? 0;
accExp += expTable[i].Experience;
if (pmcData.Info.Experience < accExp)
{
@@ -50,13 +50,13 @@ public class BotLevelGenerator(
); // TODO - nasty double to string to int conversion
for (var i = 0; i < level; i++)
{
exp += expTable[i].Experience.Value;
exp += expTable[i].Experience;
}
// Sprinkle in some random exp within the level, unless we are at max level.
if (level < expTable.Length - 1)
{
exp += randomUtil.GetInt(0, expTable[level].Experience.Value - 1);
exp += randomUtil.GetInt(0, expTable[level].Experience - 1);
}
return new RandomisedBotLevelResult { Level = level, Exp = exp };
@@ -420,7 +420,7 @@ public class PlayerScavGenerator(
.Sum(bonus => (bonus?.Value ?? 1) / 100);
var fenceInfo = fenceService.GetFenceInfo(pmcData);
modifier *= fenceInfo.SavageCooldownModifier ?? 1d;
modifier *= fenceInfo.SavageCooldownModifier;
// Make sure to apply ScavCooldownTimer bonus from Hideout if the player has it.
var scavLockDuration =
@@ -440,9 +440,7 @@ public class PlayerScavGenerator(
if (scavData?.Info != null)
{
scavData.Info.SavageLockTime = Math.Round(
timeUtil.GetTimeStamp() + (scavLockDuration ?? 0)
);
scavData.Info.SavageLockTime = Math.Round(timeUtil.GetTimeStamp() + (scavLockDuration));
}
return scavData;
@@ -792,7 +792,7 @@ public class HideoutHelper(
pmcData,
recipe.ProductionTime ?? 0,
SkillTypes.Crafting,
globalSkillsDb.Crafting.ProductionTimeReductionPerLevel ?? 0
globalSkillsDb.Crafting.ProductionTimeReductionPerLevel
);
}
@@ -803,7 +803,7 @@ public class HideoutHelper(
pmcData,
recipe.ProductionTime ?? 0,
SkillTypes.HideoutManagement,
globalSkillsDb.HideoutManagement.ConsumptionReductionPerLevel ?? 0
globalSkillsDb.HideoutManagement.ConsumptionReductionPerLevel
);
}
@@ -961,12 +961,12 @@ public class HideoutHelper(
var hideoutManagementConsumptionBonus = GetSkillBonusMultipliedBySkillLevel(
pmcData,
SkillTypes.HideoutManagement,
globalSkillsDb.HideoutManagement.ConsumptionReductionPerLevel ?? 0
globalSkillsDb.HideoutManagement.ConsumptionReductionPerLevel
);
var craftSkillTimeReductionMultiplier = GetSkillBonusMultipliedBySkillLevel(
pmcData,
SkillTypes.Crafting,
globalSkillsDb.Crafting.CraftTimeReductionPerLevel ?? 0
globalSkillsDb.Crafting.CraftTimeReductionPerLevel
);
// Never let bonus become 0
@@ -186,9 +186,16 @@ public class PresetHelper(DatabaseService databaseService, ItemHelper itemHelper
}
// Use default preset id from above cache to find the weapon/equipment preset
if (!_defaultWeaponPresets.TryGetValue(presetDetails.DefaultId, out var defaultPreset))
if (
!_defaultWeaponPresets.TryGetValue(presetDetails.DefaultId.Value, out var defaultPreset)
)
{
if (!_defaultEquipmentPresets.TryGetValue(presetDetails.DefaultId, out defaultPreset))
if (
!_defaultEquipmentPresets.TryGetValue(
presetDetails.DefaultId.Value,
out defaultPreset
)
)
{
// Default not found in weapon or equipment, return first preset in list
return cloner.Clone(
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Common;
namespace SPTarkov.Server.Core.Models.Spt.Presets;
@@ -8,8 +9,8 @@ public record PresetCacheDetails
public Dictionary<string, object>? ExtensionData { get; set; }
// Preset Ids related to the tpl
public HashSet<string> PresetIds { get; set; }
public HashSet<MongoId> PresetIds { get; set; }
// Id of the default preset for this tpl
public string? DefaultId { get; set; }
public MongoId? DefaultId { get; set; }
}
@@ -194,8 +194,7 @@ public class InsuranceService(
randomisedReturnTimeSeconds *= globals
.Configuration
.Insurance
.CoefOfHavingMarkOfUnknown
.Value;
.CoefOfHavingMarkOfUnknown;
}
// EoD has 30% faster returns
@@ -206,7 +205,7 @@ public class InsuranceService(
)
)
{
randomisedReturnTimeSeconds *= editionModifier.Multiplier.Value;
randomisedReturnTimeSeconds *= editionModifier.Multiplier;
}
// Calculate the final return time based on our bonus percent
@@ -488,7 +488,7 @@ public class ProfileFixerService(
AddEmptyObjectsToHideoutAreaSlots(
HideoutAreas.Generator,
(int)(6 + extraGenSlots ?? 0),
(int)(6 + extraGenSlots),
pmcProfile
);
}
@@ -516,7 +516,7 @@ public class ProfileFixerService(
AddEmptyObjectsToHideoutAreaSlots(
HideoutAreas.WaterCollector,
(int)(1 + extraWaterCollSlots ?? 0),
(int)(1 + extraWaterCollSlots),
pmcProfile
);
}
@@ -543,7 +543,7 @@ public class ProfileFixerService(
AddEmptyObjectsToHideoutAreaSlots(
HideoutAreas.AirFilteringUnit,
(int)(3 + extraFilterSlots ?? 0),
(int)(3 + extraFilterSlots),
pmcProfile
);
}
@@ -571,7 +571,7 @@ public class ProfileFixerService(
AddEmptyObjectsToHideoutAreaSlots(
HideoutAreas.BitcoinFarm,
(int)(50 + extraBtcSlots ?? 0),
(int)(50 + extraBtcSlots),
pmcProfile
);
}
@@ -120,16 +120,11 @@ public class RagfairTaxService(
{
BuffType.DamageReduction => itemEnhancementSettings
.DamageReduction
.PriceModifierValue
.Value,
.PriceModifierValue,
BuffType.MalfunctionProtections => itemEnhancementSettings
.MalfunctionProtections
.PriceModifierValue
.Value,
BuffType.WeaponSpread => itemEnhancementSettings
.WeaponSpread
.PriceModifierValue
.Value,
.PriceModifierValue,
BuffType.WeaponSpread => itemEnhancementSettings.WeaponSpread.PriceModifierValue,
_ => 1d,
};
discountedTax *= 1.0 + Math.Abs(item.Upd.Buff.Value.Value - 1.0) * priceModiferValue;
@@ -440,17 +440,14 @@ public class RepairService(
var armorClassDivisor = globals.Configuration.RepairSettings.ArmorClassDivisor;
var armorClassMultiplier = 1.0 + armorClass / armorClassDivisor;
return durabilityPointCostArmor.Value
* armorBonus.Value
* destructability.Value
* armorClassMultiplier.Value;
return durabilityPointCostArmor * armorBonus * destructability * armorClassMultiplier;
}
var repairWeaponBonus = GetBonusMultiplierValue(BonusType.RepairWeaponBonus, pmcData) - 1;
var repairPointMultiplier = 1.0 - repairWeaponBonus - intellectPointReduction;
var durabilityPointCostGuns = globals.Configuration.RepairSettings.DurabilityPointCostGuns;
return durabilityPointCostGuns.Value * repairPointMultiplier.Value;
return durabilityPointCostGuns * repairPointMultiplier;
}
/// <summary>
@@ -688,7 +685,7 @@ public class RepairService(
var durabilityToRestorePercent =
repairDetails.RepairPoints / template.Properties.MaxDurability;
var durabilityMultiplier = GetDurabilityMultiplier(
receivedDurabilityMaxPercent.Value,
receivedDurabilityMaxPercent,
durabilityToRestorePercent.Value
);