Various code linting changes

This commit is contained in:
Chomp
2025-01-18 11:49:21 +00:00
parent e926379b4a
commit 566deba507
23 changed files with 213 additions and 198 deletions
+2 -3
View File
@@ -333,12 +333,11 @@ public class CustomizationController
/// <summary>
/// Applies a purchased suit to the players doll
/// </summary>
/// <param name="customization">Suit to apply to profile</param>
/// <param name="customisation">Suit to apply to profile</param>
/// <param name="pmcData">Profile to update</param>
private void ApplyClothingItemToProfile(CustomizationSetOption customisation, PmcData pmcData)
{
var dbSuit = _databaseService.GetCustomization()[customisation?.Id];
if (dbSuit == null)
if (!_databaseService.GetCustomization().TryGetValue(customisation?.Id, out var dbSuit))
{
_logger.Error($"Unable to find suit customisation id: {customisation?.Id}, cannot apply clothing to player profile: {pmcData.Id}");
return;
+3 -4
View File
@@ -167,11 +167,10 @@ public class DialogueController
var profile = _saveServer.GetProfile(sessionId);
// User to user messages are special in that they need the player to exist in them, add if they don't
if (
messageType == MessageType.USER_MESSAGE &&
!dialog.Users.Any((userDialog) => userDialog.Id == profile.CharacterData.PmcData.SessionId))
if (messageType == MessageType.USER_MESSAGE &&
dialog.Users.All(userDialog => userDialog.Id != profile.CharacterData.PmcData.SessionId))
{
// nullguard
// Nullguard
dialog.Users ??= [];
dialog.Users.Add( new UserDialogInfo
+1
View File
@@ -184,6 +184,7 @@ public class HideoutController
{
foreach (var poseKvP in request.Poses)
{
// Nullguard
pmcData.Hideout.MannequinPoses ??= new Dictionary<string, string>();
pmcData.Hideout.MannequinPoses[poseKvP.Key] = poseKvP.Value;
}
+7 -7
View File
@@ -84,7 +84,7 @@ public class LauncherController
{
var result = new Dictionary<string, string>();
var dbProfiles = _databaseService.GetProfiles();
foreach (var templatesProperty in typeof(ProfileTemplates).GetProperties().Where(p => p.CanWrite == true))
foreach (var templatesProperty in typeof(ProfileTemplates).GetProperties().Where(p => p.CanWrite))
{
var propertyValue = templatesProperty.GetValue(dbProfiles);
if (propertyValue == null) {
@@ -106,10 +106,10 @@ public class LauncherController
public string? Login(LoginRequestData info)
{
foreach (var sessionID in _saveServer.GetProfiles()) {
var account = _saveServer.GetProfile(sessionID.Key).ProfileInfo;
foreach (var kvp in _saveServer.GetProfiles()) {
var account = _saveServer.GetProfile(kvp.Key).ProfileInfo;
if (info.Username == account.Username) {
return sessionID.Key;
return kvp.Key;
}
}
@@ -118,8 +118,8 @@ public class LauncherController
public string Register(RegisterData info)
{
foreach (var sessionID in _saveServer.GetProfiles()) {
if (info.Username == _saveServer.GetProfile(sessionID.Key).ProfileInfo.Username) {
foreach (var kvp in _saveServer.GetProfiles()) {
if (info.Username == _saveServer.GetProfile(kvp.Key).ProfileInfo.Username) {
return "";
}
}
@@ -131,7 +131,7 @@ public class LauncherController
{
var profileId = GenerateProfileId();
var scavId = GenerateProfileId();
var newProfileDetails = new Info(){
var newProfileDetails = new Info{
ProfileId = profileId,
ScavengerId = scavId,
Aid = _hashUtil.GenerateAccountId(),
+3 -3
View File
@@ -43,12 +43,12 @@ public class LocationController
// keyed by _id location property
var locationResult = new Dictionary<string, LocationBase>();
foreach (var location in maps)
foreach (var kvp in maps)
{
var mapBase = location.Value?.Base;
var mapBase = kvp.Value?.Base;
if (mapBase == null)
{
_logger.Debug($"Map: {location} has no base json file, skipping generation");
_logger.Debug($"Map: {kvp} has no base json file, skipping generation");
continue;
}
+3 -3
View File
@@ -32,12 +32,12 @@ public class PresetController
{
var presets = _databaseService.GetGlobals().ItemPresets;
var reverse = new Dictionary<string, List<string>>();
foreach (var (id, preset) in presets)
foreach (var (key, preset) in presets)
{
if (id != preset.Id)
if (key != preset.Id)
{
this._logger.Error(
$"Preset for template tpl: '{preset.Items[0].Template} {preset.Name}' has invalid key: ({id} != {preset.Id}). Skipping"
$"Preset for template tpl: '{preset.Items[0].Template} {preset.Name}' has invalid key: ({key} != {preset.Id}). Skipping"
);
continue;
@@ -304,11 +304,11 @@ public class RepeatableQuestController
var locations = GetAllowedLocationsForPmcLevel(repeatableConfig.Locations, pmcLevel.Value);
// Populate Exploration and Pickup quest locations
foreach (var location in locations) {
if (location.Key != ELocationName.any)
foreach (var (location, value) in locations) {
if (location != ELocationName.any)
{
questPool.Pool.Exploration.Locations[location.Key] = location.Value;
questPool.Pool.Pickup.Locations[location.Key] = location.Value;
questPool.Pool.Exploration.Locations[location] = value;
questPool.Pool.Pickup.Locations[location] = value;
}
}
@@ -374,9 +374,9 @@ public class RepeatableQuestController
{
var allowedLocation = new Dictionary<ELocationName, List<string>>();
foreach (var locationKvP in locations) {
foreach (var (location, value) in locations) {
var locationNames = new List<string>();
foreach (var locationName in locationKvP.Value) {
foreach (var locationName in value) {
if (IsPmcLevelAllowedOnLocation(locationName, pmcLevel))
{
locationNames.Add(locationName);
@@ -385,7 +385,7 @@ public class RepeatableQuestController
if (locationNames.Count > 0)
{
allowedLocation[locationKvP.Key] = locationNames;
allowedLocation[location] = locationNames;
}
}
+20 -21
View File
@@ -97,9 +97,9 @@ public class TraderController
// Adjust price by traderPriceMultipler config property
if (_traderConfig.TraderPriceMultipler != 1)
{
foreach (var scheme in trader.Value?.Assort?.BarterScheme)
foreach (var kvp in trader.Value?.Assort?.BarterScheme)
{
var barterSchemeItem = scheme.Value[0][0];
var barterSchemeItem = kvp.Value[0][0];
if (barterSchemeItem != null && _paymentHelper.IsMoneyTpl(barterSchemeItem?.Template))
{
@@ -130,26 +130,28 @@ public class TraderController
/// <returns></returns>
public bool Update()
{
foreach (var trader in _databaseService.GetTables().Traders)
foreach (var (traderId, data) in _databaseService.GetTables().Traders)
{
if (trader.Key == "ragfair" || trader.Key == Traders.LIGHTHOUSEKEEPER)
continue;
if (trader.Key == Traders.FENCE)
switch (traderId)
{
if (_fenceService.NeedsPartialRefresh())
_fenceService.GenerateFenceAssorts();
case Traders.LIGHTHOUSEKEEPER:
continue;
case Traders.FENCE:
{
if (_fenceService.NeedsPartialRefresh())
_fenceService.GenerateFenceAssorts();
continue;
continue;
}
}
// Trader needs to be refreshed
if (_traderAssortHelper.TraderAssortsHaveExpired(trader.Key))
if (_traderAssortHelper.TraderAssortsHaveExpired(traderId))
{
_traderAssortHelper.ResetExpiredTrader(trader.Value);
_traderAssortHelper.ResetExpiredTrader(data);
// Reset purchase data per trader as they have independent reset times
_traderPurchasePersisterService.ResetTraderPurchasesStoredInProfile(trader.Key);
_traderPurchasePersisterService.ResetTraderPurchasesStoredInProfile(traderId);
}
}
@@ -165,18 +167,15 @@ public class TraderController
{
var traders = new List<TraderBase>();
var pmcData = _profileHelper.GetPmcProfile(sessionId);
foreach (var trader in _databaseService.GetTables().Traders)
foreach (var (traderId, data) in _databaseService.GetTables().Traders)
{
if (trader.Value.Base.Id == "ragfair")
continue;
traders.Add(_traderHelper.GetTrader(trader.Key, sessionId));
traders.Add(_traderHelper.GetTrader(traderId, sessionId));
if (pmcData?.Info != null)
_traderHelper.LevelUp(trader.Key, pmcData);
_traderHelper.LevelUp(traderId, pmcData);
}
traders.Sort((a, b) => SortByTraderId(a, b));
traders.Sort(SortByTraderId);
return traders;
}
@@ -188,7 +187,7 @@ public class TraderController
/// <returns>1,-1 or 0</returns>
private int SortByTraderId(TraderBase traderA, TraderBase traderB)
{
return string.Compare(traderA.Id, traderB.Id);
return string.CompareOrdinal(traderA.Id, traderB.Id);
}
/// <summary>