From cf615602666d22e44fe94c448225f48b76aadc23 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 29 Jun 2025 09:33:11 +0100 Subject: [PATCH] Cleaned up comments Set properties as readonly --- .../Controllers/GameController.cs | 10 +++--- .../Models/Enums/ModSpawn.cs | 18 +++++------ .../HideoutCraftQuestIdGenerator.cs | 2 -- Tools/ItemTplGenerator/ItemTplGenerator.cs | 32 +++++++++---------- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs b/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs index 9b47250c..c20a239d 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs @@ -36,11 +36,11 @@ public class GameController( ProfileActivityService _profileActivityService ) { - protected BotConfig _botConfig = _configServer.GetConfig(); - protected CoreConfig _coreConfig = _configServer.GetConfig(); - protected double _deviation = 0.0001; - protected HideoutConfig _hideoutConfig = _configServer.GetConfig(); - protected HttpConfig _httpConfig = _configServer.GetConfig(); + protected readonly BotConfig _botConfig = _configServer.GetConfig(); + protected readonly CoreConfig _coreConfig = _configServer.GetConfig(); + protected readonly double _deviation = 0.0001; + protected readonly HideoutConfig _hideoutConfig = _configServer.GetConfig(); + protected readonly HttpConfig _httpConfig = _configServer.GetConfig(); /// /// Handle client/game/start diff --git a/Libraries/SPTarkov.Server.Core/Models/Enums/ModSpawn.cs b/Libraries/SPTarkov.Server.Core/Models/Enums/ModSpawn.cs index 774f8010..b4962815 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Enums/ModSpawn.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Enums/ModSpawn.cs @@ -2,18 +2,18 @@ namespace SPTarkov.Server.Core.Models.Enums; public enum ModSpawn { - /** - * Chosen mod should be the tpl from the default weapon template - */ + /// + /// Chosen mod should be the tpl from the default weapon template + /// DEFAULT_MOD = 0, - /** - * Normal behaviour - */ + /// + /// Normal behaviour + /// SPAWN = 1, - /** - * Item should not be chosen - */ + /// + /// Item should not be chosen + /// SKIP = 2, } diff --git a/Tools/HideoutCraftQuestIdGenerator/HideoutCraftQuestIdGenerator.cs b/Tools/HideoutCraftQuestIdGenerator/HideoutCraftQuestIdGenerator.cs index 59501f13..1bea69cf 100644 --- a/Tools/HideoutCraftQuestIdGenerator/HideoutCraftQuestIdGenerator.cs +++ b/Tools/HideoutCraftQuestIdGenerator/HideoutCraftQuestIdGenerator.cs @@ -5,7 +5,6 @@ using SPTarkov.Server.Core.Models.Eft.Hideout; using SPTarkov.Server.Core.Models.Enums; using SPTarkov.Server.Core.Models.Utils; using SPTarkov.Server.Core.Servers; -using SPTarkov.Server.Core.Services; using SPTarkov.Server.Core.Utils; using Path = System.IO.Path; @@ -17,7 +16,6 @@ public class HideoutCraftQuestIdGenerator( FileUtil _fileUtil, JsonUtil _jsonUtil, DatabaseServer _databaseServer, - LocaleService _localeService, ItemHelper _itemHelper, DatabaseImporter _databaseImporter ) diff --git a/Tools/ItemTplGenerator/ItemTplGenerator.cs b/Tools/ItemTplGenerator/ItemTplGenerator.cs index 3674791f..9a24e226 100644 --- a/Tools/ItemTplGenerator/ItemTplGenerator.cs +++ b/Tools/ItemTplGenerator/ItemTplGenerator.cs @@ -24,13 +24,13 @@ public class ItemTplGenerator( ) { private readonly HashSet collidedEnumKeys = []; - private string enumDir; - private IDictionary itemOverrides; - private Dictionary items; + private string _enumDir; + private IDictionary _itemOverrides; + private Dictionary _items; public async Task Run() { - itemOverrides = ItemOverrides.ItemOverridesDictionary; + _itemOverrides = ItemOverrides.ItemOverridesDictionary; // Load all onload components, this gives us access to most of SPTs injections foreach (var onLoad in _onLoadComponents) { @@ -44,21 +44,21 @@ public class ItemTplGenerator( // Figure out our source and target directories var projectDir = Directory.GetParent("./").Parent.Parent.Parent.Parent.Parent; - enumDir = Path.Combine( + _enumDir = Path.Combine( projectDir.FullName, "Libraries", "SPTarkov.Server.Core", "Models", "Enums" ); - items = _databaseServer.GetTables().Templates.Items; + _items = _databaseServer.GetTables().Templates.Items; // Generate an object containing all item name to ID associations var orderedItemsObject = GenerateItemsObject(); // Log any changes to enum values, so the source can be updated as required LogEnumValueChanges(orderedItemsObject, "ItemTpl", typeof(ItemTpl)); - var itemTplOutPath = Path.Combine(enumDir, "ItemTpl.cs"); + var itemTplOutPath = Path.Combine(_enumDir, "ItemTpl.cs"); WriteEnumsToFile( itemTplOutPath, new Dictionary> @@ -70,7 +70,7 @@ public class ItemTplGenerator( // Handle the weapon type enums var weaponsObject = GenerateWeaponsObject(); LogEnumValueChanges(weaponsObject, "Weapons", typeof(Weapons)); - var weaponTypeOutPath = Path.Combine(enumDir, "Weapons.cs"); + var weaponTypeOutPath = Path.Combine(_enumDir, "Weapons.cs"); WriteEnumsToFile( weaponTypeOutPath, new Dictionary> @@ -89,7 +89,7 @@ public class ItemTplGenerator( private Dictionary GenerateItemsObject() { var itemsObject = new Dictionary(); - foreach (var item in items.Values) + foreach (var item in _items.Values) { // Skip invalid items (Non-Item types, and shrapnel) if (!IsValidItem(item)) @@ -148,7 +148,7 @@ public class ItemTplGenerator( if (itemsObject.ContainsKey(itemKey)) { var oldItemId = itemsObject[itemKey]; - var oldItemNameSuffix = GetItemNameSuffix(items[oldItemId]); + var oldItemNameSuffix = GetItemNameSuffix(_items[oldItemId]); if (!string.IsNullOrEmpty(oldItemNameSuffix)) { var oldItemNewKey = SanitizeEnumKey($"{itemKey}_{oldItemNameSuffix}"); @@ -192,7 +192,7 @@ public class ItemTplGenerator( var weaponsObject = new Dictionary(); foreach ( var kv /*[itemId, item]*/ - in items + in _items ) { if (!_itemHelper.IsOfBaseclass(kv.Key, BaseClasses.WEAPON)) @@ -313,7 +313,7 @@ public class ItemTplGenerator( } var parentId = item.Parent; - return items[parentId].Name.ToUpper(); + return _items[parentId].Name.ToUpper(); } private bool IsValidItem(TemplateItem item) @@ -424,7 +424,7 @@ public class ItemTplGenerator( 0 ]?.Filter?.FirstOrDefault(); - return GetAmmoPrefix(items[ammoItem]); + return GetAmmoPrefix(_items[ammoItem]); } private string GetMagazinePrefix(TemplateItem item) @@ -433,7 +433,7 @@ public class ItemTplGenerator( 0 ]?.Filter?.FirstOrDefault(); - return GetAmmoPrefix(items[ammoItem]); + return GetAmmoPrefix(_items[ammoItem]); } /// @@ -447,9 +447,9 @@ public class ItemTplGenerator( var localeDb = _localeService.GetLocaleDb(); // Manual item name overrides - if (itemOverrides.ContainsKey(item.Id)) + if (_itemOverrides.ContainsKey(item.Id)) { - itemName = itemOverrides[item.Id].ToUpper(); + itemName = _itemOverrides[item.Id].ToUpper(); } // For the listed types, user the item's _name property else if (