Fix a lot of the analyzer warnings too
This commit is contained in:
@@ -25,11 +25,11 @@ public sealed class CharaDataCharacterHandler : DisposableMediatorSubscriberBase
|
||||
_gameObjectHandlerFactory = gameObjectHandlerFactory;
|
||||
_dalamudUtilService = dalamudUtilService;
|
||||
_ipcManager = ipcManager;
|
||||
mediator.Subscribe<GposeEndMessage>(this, (_) =>
|
||||
mediator.Subscribe<GposeEndMessage>(this, msg =>
|
||||
{
|
||||
foreach (var chara in _handledCharaData)
|
||||
{
|
||||
RevertHandledChara(chara, false);
|
||||
_ = RevertHandledChara(chara, reapplyPose: false);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ public sealed class CharaDataCharacterHandler : DisposableMediatorSubscriberBase
|
||||
base.Dispose(disposing);
|
||||
foreach (var chara in _handledCharaData)
|
||||
{
|
||||
RevertHandledChara(chara, false);
|
||||
_ = RevertHandledChara(chara, reapplyPose: false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
|
||||
{
|
||||
data[fileEntry.Hash] = new FileDataEntry(fileEntry.Hash, ext,
|
||||
[.. fileEntry.GamePaths],
|
||||
fileCacheEntries.Select(c => c.ResolvedFilepath).Distinct().ToList(),
|
||||
fileCacheEntries.Select(c => c.ResolvedFilepath).Distinct(StringComparer.Ordinal).ToList(),
|
||||
entry.Size > 0 ? entry.Size.Value : 0,
|
||||
entry.CompressedSize > 0 ? entry.CompressedSize.Value : 0,
|
||||
tris);
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
private readonly Lazy<GameChatHooks> _gameChatHooks;
|
||||
|
||||
public ChatService(ILogger<ChatService> logger, DalamudUtilService dalamudUtil, MareMediator mediator, ApiController apiController,
|
||||
PairManager pairManager, ILogger<GameChatHooks> logger2, IGameInteropProvider gameInteropProvider, IChatGui chatGui,
|
||||
PairManager pairManager, LoggerFactory loggerFactory, IGameInteropProvider gameInteropProvider, IChatGui chatGui,
|
||||
MareConfigService mareConfig, ServerConfigurationManager serverConfigurationManager) : base(logger, mediator)
|
||||
{
|
||||
_logger = logger;
|
||||
@@ -45,7 +45,7 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
Mediator.Subscribe<UserChatMsgMessage>(this, HandleUserChat);
|
||||
Mediator.Subscribe<GroupChatMsgMessage>(this, HandleGroupChat);
|
||||
|
||||
_gameChatHooks = new(() => new GameChatHooks(logger2, gameInteropProvider));
|
||||
_gameChatHooks = new(() => new GameChatHooks(loggerFactory.CreateLogger<GameChatHooks>(), gameInteropProvider));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
@@ -109,7 +109,7 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
if (color != 0)
|
||||
msg.AddUiForeground((ushort)color);
|
||||
msg.AddText($"[SS{shellNumber}]<");
|
||||
if (message.ChatMsg.Sender.UID == _apiController.UID)
|
||||
if (message.ChatMsg.Sender.UID.Equals(_apiController.UID, StringComparison.Ordinal))
|
||||
{
|
||||
// Don't link to your own character
|
||||
msg.AddText(chatMsg.SenderName);
|
||||
@@ -137,7 +137,7 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
|
||||
foreach (var group in _pairManager.Groups)
|
||||
{
|
||||
if (group.Key.GID == gid)
|
||||
if (group.Key.GID.Equals(gid, StringComparison.Ordinal))
|
||||
{
|
||||
int shellChatType = _serverConfigurationManager.GetShellConfigForGid(gid).LogKind;
|
||||
if (shellChatType != 0)
|
||||
@@ -166,7 +166,7 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
if (_gameChatHooks.IsValueCreated && _gameChatHooks.Value.ChatChannelOverride != null)
|
||||
{
|
||||
// Very dumb and won't handle re-numbering -- need to identify the active chat channel more reliably later
|
||||
if (_gameChatHooks.Value.ChatChannelOverride.ChannelName.StartsWith($"SS [{shellNumber}]"))
|
||||
if (_gameChatHooks.Value.ChatChannelOverride.ChannelName.StartsWith($"SS [{shellNumber}]", StringComparison.Ordinal))
|
||||
SwitchChatShell(shellNumber);
|
||||
}
|
||||
}
|
||||
@@ -207,8 +207,8 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
var shellConfig = _serverConfigurationManager.GetShellConfigForGid(group.Key.GID);
|
||||
if (shellConfig.Enabled && shellConfig.ShellNumber == shellNumber)
|
||||
{
|
||||
Task.Run(async () => {
|
||||
// TODO: Cache the name and home world instead of fetching it every time
|
||||
_ = Task.Run(async () => {
|
||||
// Should cache the name and home world instead of fetching it every time
|
||||
var chatMsg = await _dalamudUtil.RunOnFrameworkThread(() => {
|
||||
return new ChatMessage()
|
||||
{
|
||||
@@ -216,9 +216,9 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
SenderHomeWorldId = _dalamudUtil.GetHomeWorldId(),
|
||||
PayloadContent = chatBytes
|
||||
};
|
||||
});
|
||||
await _apiController.GroupChatSendMsg(new(group.Key), chatMsg);
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
await _apiController.GroupChatSendMsg(new(group.Key), chatMsg).ConfigureAwait(false);
|
||||
}).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,6 @@ public class GuiHookService : DisposableMediatorSubscriberBase
|
||||
_namePlateGui.OnNamePlateUpdate += OnNamePlateUpdate;
|
||||
_namePlateGui.RequestRedraw();
|
||||
|
||||
gameConfig.TryGet(Dalamud.Game.Config.UiConfigOption.NamePlateSetRoleColor, out bool isNameplateSetRoleColor);
|
||||
|
||||
Mediator.Subscribe<DelayedFrameworkUpdateMessage>(this, (_) => GameSettingsCheck());
|
||||
Mediator.Subscribe<PairHandlerVisibleMessage>(this, (_) => RequestRedraw());
|
||||
Mediator.Subscribe<NameplateRedrawMessage>(this, (_) => RequestRedraw());
|
||||
@@ -55,8 +53,8 @@ public class GuiHookService : DisposableMediatorSubscriberBase
|
||||
_isModified = false;
|
||||
}
|
||||
|
||||
Task.Run(async () => {
|
||||
await _dalamudUtil.RunOnFrameworkThread(() => _namePlateGui.RequestRedraw());
|
||||
_ = Task.Run(async () => {
|
||||
await _dalamudUtil.RunOnFrameworkThread(() => _namePlateGui.RequestRedraw()).ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,8 +63,8 @@ public class GuiHookService : DisposableMediatorSubscriberBase
|
||||
base.Dispose(disposing);
|
||||
_namePlateGui.OnNamePlateUpdate -= OnNamePlateUpdate;
|
||||
|
||||
Task.Run(async () => {
|
||||
await _dalamudUtil.RunOnFrameworkThread(() => _namePlateGui.RequestRedraw());
|
||||
_ = Task.Run(async () => {
|
||||
await _dalamudUtil.RunOnFrameworkThread(() => _namePlateGui.RequestRedraw()).ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class MareProfileManager : MediatorSubscriberBase
|
||||
_mareProfiles[data] = _loadingProfileData;
|
||||
var profile = await _apiController.UserGetProfile(new API.Dto.User.UserDto(data)).ConfigureAwait(false);
|
||||
bool isSupporter = !string.Equals(data.Alias, data.UID, StringComparison.Ordinal);
|
||||
if (_serverConfigurationManager.CurrentApiUrl != ApiController.MainServiceUri)
|
||||
if (!_serverConfigurationManager.CurrentApiUrl.Equals(ApiController.MainServiceUri, StringComparison.Ordinal))
|
||||
isSupporter = false;
|
||||
MareProfileData profileData = new(profile.Disabled, profile.IsNSFW ?? false,
|
||||
string.IsNullOrEmpty(profile.ProfilePictureBase64) ? _mareLogo : profile.ProfilePictureBase64,
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace MareSynchronos.Services.Mediator;
|
||||
|
||||
public sealed class MareMediator : IHostedService
|
||||
{
|
||||
private readonly object _addRemoveLock = new();
|
||||
private readonly ConcurrentDictionary<object, DateTime> _lastErrorTime = [];
|
||||
private readonly Lock _addRemoveLock = new();
|
||||
private readonly ConcurrentDictionary<SubscriberAction, DateTime> _lastErrorTime = [];
|
||||
private readonly ILogger<MareMediator> _logger;
|
||||
private readonly CancellationTokenSource _loopCts = new();
|
||||
private readonly ConcurrentQueue<MessageBase> _messageQueue = new();
|
||||
|
||||
@@ -153,7 +153,7 @@ public sealed class PairAnalyzer : DisposableMediatorSubscriberBase
|
||||
{
|
||||
data[fileEntry.Hash] = new CharacterAnalyzer.FileDataEntry(fileEntry.Hash, ext,
|
||||
[.. fileEntry.GamePaths],
|
||||
fileCacheEntries.Select(c => c.ResolvedFilepath).Distinct().ToList(),
|
||||
fileCacheEntries.Select(c => c.ResolvedFilepath).Distinct(StringComparer.Ordinal).ToList(),
|
||||
entry.Size > 0 ? entry.Size.Value : 0,
|
||||
entry.CompressedSize > 0 ? entry.CompressedSize.Value : 0,
|
||||
tris);
|
||||
|
||||
@@ -184,7 +184,6 @@ public class PlayerPerformanceService : DisposableMediatorSubscriberBase
|
||||
public async Task<bool> ShrinkTextures(PairHandler pairHandler, CharacterData charaData, CancellationToken token)
|
||||
{
|
||||
var config = _playerPerformanceConfigService.Current;
|
||||
var pair = pairHandler.Pair;
|
||||
|
||||
if (config.TextureShrinkMode == MareConfiguration.Models.TextureShrinkMode.Never)
|
||||
return false;
|
||||
@@ -208,7 +207,7 @@ public class PlayerPerformanceService : DisposableMediatorSubscriberBase
|
||||
if (fileEntry == null) return;
|
||||
if (fileEntry.IsSubstEntry) return;
|
||||
|
||||
var texFormat = await Task.Run(() => _xivDataAnalyzer.GetTexFormatByHash(hash));
|
||||
var texFormat = _xivDataAnalyzer.GetTexFormatByHash(hash);
|
||||
var filePath = fileEntry.ResolvedFilepath;
|
||||
var tmpFilePath = _fileCacheManager.GetSubstFilePath(Guid.NewGuid().ToString(), "tmp");
|
||||
var newFilePath = _fileCacheManager.GetSubstFilePath(hash, "tex");
|
||||
@@ -295,7 +294,7 @@ public class PlayerPerformanceService : DisposableMediatorSubscriberBase
|
||||
outFile.Position = 80;
|
||||
inFile.Position = 80 + offsetDelta;
|
||||
|
||||
await inFile.CopyToAsync(outFile, 81920, token);
|
||||
await inFile.CopyToAsync(outFile, 81920, token).ConfigureAwait(false);
|
||||
|
||||
reader.Dispose();
|
||||
writer.Dispose();
|
||||
@@ -326,7 +325,7 @@ public class PlayerPerformanceService : DisposableMediatorSubscriberBase
|
||||
File.Delete(tmpFilePath);
|
||||
}
|
||||
}
|
||||
);
|
||||
).ConfigureAwait(false);
|
||||
|
||||
return shrunken;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class PluginWatcherService : MediatorSubscriberBase
|
||||
|
||||
private CapturedPluginState[] _prevInstalledPluginState = [];
|
||||
|
||||
#pragma warning disable
|
||||
private static bool ExposedPluginsEqual(IEnumerable<IExposedPlugin> plugins, IEnumerable<CapturedPluginState> other)
|
||||
{
|
||||
if (plugins.Count() != other.Count()) return false;
|
||||
@@ -58,6 +59,7 @@ public class PluginWatcherService : MediatorSubscriberBase
|
||||
if (enumeratorOriginal.Current.InternalName != enumeratorOther.Current.InternalName) return false;
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
|
||||
public PluginWatcherService(ILogger<PluginWatcherService> logger, IDalamudPluginInterface pluginInterface, MareMediator mediator) : base(logger, mediator)
|
||||
{
|
||||
@@ -85,22 +87,22 @@ public class PluginWatcherService : MediatorSubscriberBase
|
||||
// The same plugin can be installed multiple times -- InternalName is not unique
|
||||
|
||||
var oldDict = _prevInstalledPluginState.Where(x => x.InternalName.Length > 0)
|
||||
.GroupBy(x => x.InternalName)
|
||||
.ToDictionary(x => x.Key);
|
||||
.GroupBy(x => x.InternalName, StringComparer.Ordinal)
|
||||
.ToDictionary(x => x.Key, StringComparer.Ordinal);
|
||||
|
||||
var newDict = state.Where(x => x.InternalName.Length > 0)
|
||||
.GroupBy(x => x.InternalName)
|
||||
.ToDictionary(x => x.Key);
|
||||
.GroupBy(x => x.InternalName, StringComparer.Ordinal)
|
||||
.ToDictionary(x => x.Key, StringComparer.Ordinal);
|
||||
|
||||
_prevInstalledPluginState = state;
|
||||
|
||||
foreach (var internalName in newDict.Keys.Except(oldDict.Keys))
|
||||
foreach (var internalName in newDict.Keys.Except(oldDict.Keys, StringComparer.Ordinal))
|
||||
{
|
||||
var p = newDict[internalName].OrderBy(p => (!p.IsLoaded, p.Version)).First();
|
||||
Mediator.Publish(new PluginChangeMessage(internalName, p.Version, p.IsLoaded));
|
||||
}
|
||||
|
||||
foreach (var internalName in oldDict.Keys.Except(newDict.Keys))
|
||||
foreach (var internalName in oldDict.Keys.Except(newDict.Keys, StringComparer.Ordinal))
|
||||
{
|
||||
var p = newDict[internalName].OrderBy(p => (!p.IsLoaded, p.Version)).First();
|
||||
Mediator.Publish(new PluginChangeMessage(p.InternalName, p.Version, p.IsLoaded));
|
||||
|
||||
@@ -13,19 +13,17 @@ public class ServerConfigurationManager
|
||||
private readonly ServerConfigService _configService;
|
||||
private readonly DalamudUtilService _dalamudUtil;
|
||||
private readonly ILogger<ServerConfigurationManager> _logger;
|
||||
private readonly MareMediator _mareMediator;
|
||||
private readonly NotesConfigService _notesConfig;
|
||||
private readonly ServerBlockConfigService _blockConfig;
|
||||
private readonly ServerTagConfigService _serverTagConfig;
|
||||
private readonly SyncshellConfigService _syncshellConfig;
|
||||
|
||||
private HashSet<string>? CachedWhitelistedUIDs = null;
|
||||
private HashSet<string>? CachedBlacklistedUIDs = null;
|
||||
private HashSet<string>? _cachedWhitelistedUIDs = null;
|
||||
private HashSet<string>? _cachedBlacklistedUIDs = null;
|
||||
|
||||
public ServerConfigurationManager(ILogger<ServerConfigurationManager> logger, ServerConfigService configService,
|
||||
ServerTagConfigService serverTagConfig, SyncshellConfigService syncshellConfig, NotesConfigService notesConfig,
|
||||
ServerBlockConfigService blockConfig,
|
||||
DalamudUtilService dalamudUtil, MareMediator mareMediator)
|
||||
ServerBlockConfigService blockConfig, DalamudUtilService dalamudUtil)
|
||||
{
|
||||
_logger = logger;
|
||||
_configService = configService;
|
||||
@@ -34,7 +32,6 @@ public class ServerConfigurationManager
|
||||
_notesConfig = notesConfig;
|
||||
_blockConfig = blockConfig;
|
||||
_dalamudUtil = dalamudUtil;
|
||||
_mareMediator = mareMediator;
|
||||
EnsureMainExists();
|
||||
}
|
||||
|
||||
@@ -49,8 +46,8 @@ public class ServerConfigurationManager
|
||||
set
|
||||
{
|
||||
_configService.Current.CurrentServer = value;
|
||||
CachedWhitelistedUIDs = null;
|
||||
CachedBlacklistedUIDs = null;
|
||||
_cachedWhitelistedUIDs = null;
|
||||
_cachedBlacklistedUIDs = null;
|
||||
_configService.Save();
|
||||
}
|
||||
get
|
||||
@@ -399,7 +396,7 @@ public class ServerConfigurationManager
|
||||
{
|
||||
if (string.IsNullOrEmpty(uid)) return;
|
||||
|
||||
if (CurrentNotesStorage().UidLastSeenNames.TryGetValue(uid, out var currentName) && currentName == name)
|
||||
if (CurrentNotesStorage().UidLastSeenNames.TryGetValue(uid, out var currentName) && currentName.Equals(name, StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
CurrentNotesStorage().UidLastSeenNames[uid] = name;
|
||||
@@ -418,24 +415,24 @@ public class ServerConfigurationManager
|
||||
|
||||
internal bool IsUidWhitelisted(string uid)
|
||||
{
|
||||
CachedWhitelistedUIDs ??= [.. CurrentBlockStorage().Whitelist];
|
||||
return CachedWhitelistedUIDs.Contains(uid);
|
||||
_cachedWhitelistedUIDs ??= [.. CurrentBlockStorage().Whitelist];
|
||||
return _cachedWhitelistedUIDs.Contains(uid);
|
||||
}
|
||||
|
||||
internal bool IsUidBlacklisted(string uid)
|
||||
{
|
||||
CachedBlacklistedUIDs ??= [.. CurrentBlockStorage().Blacklist];
|
||||
return CachedBlacklistedUIDs.Contains(uid);
|
||||
_cachedBlacklistedUIDs ??= [.. CurrentBlockStorage().Blacklist];
|
||||
return _cachedBlacklistedUIDs.Contains(uid);
|
||||
}
|
||||
|
||||
internal void AddWhitelistUid(string uid)
|
||||
{
|
||||
if (IsUidWhitelisted(uid))
|
||||
return;
|
||||
if (CurrentBlockStorage().Blacklist.RemoveAll(u => u == uid) > 0)
|
||||
CachedBlacklistedUIDs = null;
|
||||
if (CurrentBlockStorage().Blacklist.RemoveAll(u => u.Equals(uid, StringComparison.Ordinal)) > 0)
|
||||
_cachedBlacklistedUIDs = null;
|
||||
CurrentBlockStorage().Whitelist.Add(uid);
|
||||
CachedWhitelistedUIDs = null;
|
||||
_cachedWhitelistedUIDs = null;
|
||||
_blockConfig.Save();
|
||||
}
|
||||
|
||||
@@ -443,24 +440,24 @@ public class ServerConfigurationManager
|
||||
{
|
||||
if (IsUidBlacklisted(uid))
|
||||
return;
|
||||
if (CurrentBlockStorage().Whitelist.RemoveAll(u => u == uid) > 0)
|
||||
CachedWhitelistedUIDs = null;
|
||||
if (CurrentBlockStorage().Whitelist.RemoveAll(u => u.Equals(uid, StringComparison.Ordinal)) > 0)
|
||||
_cachedWhitelistedUIDs = null;
|
||||
CurrentBlockStorage().Blacklist.Add(uid);
|
||||
CachedBlacklistedUIDs = null;
|
||||
_cachedBlacklistedUIDs = null;
|
||||
_blockConfig.Save();
|
||||
}
|
||||
|
||||
internal void RemoveWhitelistUid(string uid)
|
||||
{
|
||||
if (CurrentBlockStorage().Whitelist.RemoveAll(u => u == uid) > 0)
|
||||
CachedWhitelistedUIDs = null;
|
||||
if (CurrentBlockStorage().Whitelist.RemoveAll(u => u.Equals(uid, StringComparison.Ordinal)) > 0)
|
||||
_cachedWhitelistedUIDs = null;
|
||||
_blockConfig.Save();
|
||||
}
|
||||
|
||||
internal void RemoveBlacklistUid(string uid)
|
||||
{
|
||||
if (CurrentBlockStorage().Blacklist.RemoveAll(u => u == uid) > 0)
|
||||
CachedBlacklistedUIDs = null;
|
||||
if (CurrentBlockStorage().Blacklist.RemoveAll(u => u.Equals(uid, StringComparison.Ordinal)) > 0)
|
||||
_cachedBlacklistedUIDs = null;
|
||||
_blockConfig.Save();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,7 @@ namespace MareSynchronos.Services;
|
||||
public class VisibilityService : DisposableMediatorSubscriberBase
|
||||
{
|
||||
private readonly DalamudUtilService _dalamudUtil;
|
||||
private ConcurrentDictionary<string, bool> _trackedPlayerVisibility = new();
|
||||
private ConcurrentQueue<string> _removedPlayerMessageQueue = new();
|
||||
private readonly ConcurrentDictionary<string, bool> _trackedPlayerVisibility = new(StringComparer.Ordinal);
|
||||
|
||||
public VisibilityService(ILogger<PairAnalyzer> logger, MareMediator mediator, DalamudUtilService dalamudUtil)
|
||||
: base(logger, mediator)
|
||||
@@ -20,7 +19,7 @@ public class VisibilityService : DisposableMediatorSubscriberBase
|
||||
|
||||
public void StartTracking(string ident)
|
||||
{
|
||||
_trackedPlayerVisibility.TryAdd(ident, false);
|
||||
_trackedPlayerVisibility.TryAdd(ident, value: false);
|
||||
}
|
||||
|
||||
public void StopTracking(string ident)
|
||||
|
||||
@@ -236,7 +236,7 @@ public sealed class XivDataAnalyzer
|
||||
using var r = new LuminaBinaryReader(stream);
|
||||
var texHeader = r.ReadStructure<Lumina.Data.Files.TexFile.TexHeader>();
|
||||
|
||||
if (texHeader.Format == 0 || texHeader.MipCount == 0 || texHeader.ArraySize != 0 || texHeader.MipCount > 13)
|
||||
if (texHeader.Format == default || texHeader.MipCount == 0 || texHeader.ArraySize != 0 || texHeader.MipCount > 13)
|
||||
{
|
||||
_failedCalculatedTex.Add(hash);
|
||||
_configService.Current.TexDictionary[hash] = default;
|
||||
|
||||
Reference in New Issue
Block a user