Updated values to be consts where possible

This commit is contained in:
Chomp
2025-03-08 09:33:04 +00:00
parent 0b38563aa3
commit 33c56e0730
13 changed files with 29 additions and 29 deletions
@@ -542,7 +542,7 @@ public class InsuranceController(
/// <returns>Attachment count to remove</returns>
protected double GetAttachmentCountToRemove(Dictionary<string, double> weightedAttachmentByPrice, string? traderId)
{
var removeCount = 0;
const int removeCount = 0;
if (_randomUtil.GetChance100(_insuranceConfig.ChanceNoAttachmentsTakenPercent))
{
@@ -313,9 +313,9 @@ public class BotEquipmentModGenerator(
// Get lowest and highest plate classes available for this armor
var minMaxArmorPlateClass = GetMinMaxArmorPlateClass(platesFromDb.ToList());
// Increment plate class level in attempt to get useable plate
// Increment plate class level in attempt to get usable plate
var findCompatiblePlateAttempts = 0;
var maxAttempts = 3;
const int maxAttempts = 3;
for (var i = 0; i < maxAttempts; i++)
{
var chosenArmorPlateLevelDouble = int.Parse(chosenArmorPlateLevelString) + 1;
@@ -832,16 +832,16 @@ public class BotEquipmentModGenerator(
var isMount = _itemHelper.IsOfBaseclass(itemTplWithKeysToSort, BaseClasses.MOUNT);
HashSet<string> sortedKeys = [];
var modRecieverKey = "mod_reciever";
var modMount001Key = "mod_mount_001";
var modGasBlockKey = "mod_gas_block";
var modPistolGrip = "mod_pistol_grip";
var modStockKey = "mod_stock";
var modBarrelKey = "mod_barrel";
var modHandguardKey = "mod_handguard";
var modMountKey = "mod_mount";
var modScopeKey = "mod_scope";
var modScope000Key = "mod_scope_000";
const string modRecieverKey = "mod_reciever";
const string modMount001Key = "mod_mount_001";
const string modGasBlockKey = "mod_gas_block";
const string modPistolGrip = "mod_pistol_grip";
const string modStockKey = "mod_stock";
const string modBarrelKey = "mod_barrel";
const string modHandguardKey = "mod_handguard";
const string modMountKey = "mod_mount";
const string modScopeKey = "mod_scope";
const string modScope000Key = "mod_scope_000";
// Mounts are a special case, they need scopes first before more mounts
if (isMount)
@@ -216,7 +216,7 @@ public class PlayerScavGenerator(
/// <returns>IBotType object</returns>
protected BotType ConstructBotBaseTemplate(string botTypeForLoot)
{
var baseScavType = "assault";
const string baseScavType = "assault";
var asssaultBase = _cloner.Clone(_botHelper.GetBotTemplate(baseScavType));
// Loot bot is same as base bot, return base with no modification
@@ -133,7 +133,7 @@ public class RepeatableQuestGenerator(
var maxBodyPartsDifficulty = eliminationConfig.MinKills / bodyPartsConfig.MinProbability();
// maxDistDifficulty is defined by 2, this could be a tuning parameter if we don't like the reward generation
var maxDistDifficulty = 2;
const int maxDistDifficulty = 2;
var maxKillDifficulty = eliminationConfig.MaxKills;
@@ -70,7 +70,7 @@ public class BotHelper(
/// <param name="typeToAdd">bot type to add to friendly list</param>
public void AddBotToFriendlyList(DifficultyCategories difficultySettings, string typeToAdd)
{
var friendlyBotTypesKey = "FRIENDLY_BOT_TYPES";
const string friendlyBotTypesKey = "FRIENDLY_BOT_TYPES";
// Null guard
if (difficultySettings.Mind[friendlyBotTypesKey] is null)
@@ -88,7 +88,7 @@ public class BotHelper(
/// <param name="typesToAdd">bot type to add to revenge list</param>
public void AddBotToRevengeList(DifficultyCategories difficultySettings, string[] typesToAdd)
{
var revengePropKey = "REVENGE_BOT_TYPES";
const string revengePropKey = "REVENGE_BOT_TYPES";
// Nothing to add
if (typesToAdd is null)
@@ -98,7 +98,7 @@ public class HandbookHelper(
var handbookItem = _databaseService.GetHandbook().Items?.FirstOrDefault(item => item.Id == tpl);
if (handbookItem is null)
{
var newValue = 0;
const int newValue = 0;
if (!_handbookPriceCache.Items.ById.TryAdd(tpl, newValue))
{
@@ -913,7 +913,7 @@ public class HideoutHelper(
var globalSkillsDb = _databaseService.GetGlobals().Configuration.SkillsSettings;
// 100 resources last 8 hrs 20 min, 100/8.33/60/60 = 0.00333
var filterDrainRate = 0.00333;
const double filterDrainRate = 0.00333d;
var hideoutManagementConsumptionBonus = GetSkillBonusMultipliedBySkillLevel(
pmcData,
@@ -1028,7 +1028,7 @@ public class QuestHelper(
var clientQuestsClone =
_cloner.Clone(GetClientQuests(sessionID)); // Must be gathered prior to applyQuestReward() & failQuests()
var newQuestState = QuestStatusEnum.Success;
const QuestStatusEnum newQuestState = QuestStatusEnum.Success;
UpdateQuestState(pmcData, newQuestState, completedQuestId);
var questRewards = _questRewardHelper.ApplyQuestReward(
pmcData,
@@ -275,7 +275,7 @@ public class TradeHelper(
IncrementCirculateSoldToTraderCounter(profileWithItemsToSell, profileToReceiveMoney, sellRequest);
}
var pattern = @"\s+";
const string pattern = @"\s+";
// Find item in inventory and remove it
foreach (var itemToBeRemoved in sellRequest.Items)
@@ -320,7 +320,7 @@ public class TradeHelper(
ProcessSellTradeRequestData sellRequest
)
{
var circulateQuestId = "6663149f1d3ec95634095e75";
const string circulateQuestId = "6663149f1d3ec95634095e75";
var activeCirculateQuest = profileToReceiveMoney.Quests.FirstOrDefault(
quest => quest.QId == circulateQuestId && quest.Status == QuestStatusEnum.Started
);
@@ -63,7 +63,7 @@ public class ConfigServer
}
// Get all filepaths
var filepath = "./Assets/configs/";
const string filepath = "./Assets/configs/";
var files = _fileUtil.GetFiles(filepath);
// Add file content to result
@@ -550,7 +550,7 @@ public class LocationLifecycleService
pmcData.CarExtractCounts[extractName]
);
var fenceId = Traders.FENCE;
const string fenceId = Traders.FENCE;
pmcData.TradersInfo[fenceId].Standing = newFenceStanding;
// Check if new standing has leveled up trader
@@ -583,7 +583,7 @@ public class LocationLifecycleService
pmcData.CoopExtractCounts[extractName]
);
var fenceId = Traders.FENCE;
const string fenceId = Traders.FENCE;
pmcData.TradersInfo[fenceId].Standing = newFenceStanding;
// Check if new standing has leveled up trader
@@ -607,7 +607,7 @@ public class LocationLifecycleService
*/
protected double GetFenceStandingAfterExtract(PmcData pmcData, double baseGain, double extractCount)
{
var fenceId = Traders.FENCE;
const string fenceId = Traders.FENCE;
var fenceStanding = pmcData.TradersInfo[fenceId].Standing;
// get standing after taking extract x times, x.xx format, gain from extract can be no smaller than 0.01
@@ -823,7 +823,7 @@ public class LocationLifecycleService
// Must occur AFTER experience is set and stats copied over
pmcProfile.Stats.Eft.TotalSessionExperience = 0;
var fenceId = Traders.FENCE;
const string fenceId = Traders.FENCE;
// Clamp fence standing
var currentFenceStanding = postRaidProfile.TradersInfo[fenceId].Standing;
@@ -53,7 +53,7 @@ public class HideoutCraftQuestIdGenerator(
// Figure out our source and target directories
var projectDir = Directory.GetParent("./").Parent.Parent.Parent.Parent.Parent;
var productionPath = "Libraries\\SPTarkov.Server.Assets\\Assets\\database\\hideout\\production.json";
const string productionPath = "Libraries\\SPTarkov.Server.Assets\\Assets\\database\\hideout\\production.json";
var productionFilePath = Path.Combine(projectDir.FullName, productionPath);
var updatedProductionJson = _jsonUtil.Serialize(_databaseServer.GetTables().Hideout.Production, true);
+1 -1
View File
@@ -304,7 +304,7 @@ public class ItemTplGenerator(
private bool IsValidItem(TemplateItem item)
{
var shrapnelId = "5943d9c186f7745a13413ac9";
const string shrapnelId = "5943d9c186f7745a13413ac9";
if (item.Type != "Item")
{