diff --git a/LightlessSync/UI/ContextMenu.cs b/LightlessSync/UI/ContextMenu.cs index e34a694..5a8b291 100644 --- a/LightlessSync/UI/ContextMenu.cs +++ b/LightlessSync/UI/ContextMenu.cs @@ -1,5 +1,4 @@ using Dalamud.Game.ClientState.Objects.SubKinds; -using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Game.Gui.ContextMenu; using Dalamud.Plugin; using Dalamud.Plugin.Services; @@ -81,7 +80,7 @@ internal class ContextMenu : IHostedService if (!_pluginInterface.UiBuilder.ShouldModifyUi) return; - if (!ValidAddons.Contains(args.AddonName)) + if (!ValidAddons.Contains(args.AddonName, StringComparer.Ordinal)) return; if (args.Target is not MenuTargetDefault target) @@ -127,7 +126,7 @@ internal class ContextMenu : IHostedService return; } - var senderCid = (await _dalamudUtil.GetCIDAsync()).ToString().GetHash256(); + var senderCid = (await _dalamudUtil.GetCIDAsync().ConfigureAwait(false)).ToString().GetHash256(); var receiverCid = DalamudUtilService.GetHashedCIDFromPlayerPointer(targetData.Address); _logger.LogInformation("Sending pair request: sender {SenderCid}, receiver {ReceiverCid}", senderCid, receiverCid); diff --git a/LightlessSync/UI/UISharedService.cs b/LightlessSync/UI/UISharedService.cs index e4753dc..7fdf97f 100644 --- a/LightlessSync/UI/UISharedService.cs +++ b/LightlessSync/UI/UISharedService.cs @@ -173,12 +173,14 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase public static string ByteToString(long bytes, bool addSuffix = true) { - string[] suffix = ["B", "KiB", "MiB", "GiB", "TiB"]; - int i; + string[] suffix = { "B", "KB", "MB", "GB", "TB" }; + int i = 0; double dblSByte = bytes; - for (i = 0; i < suffix.Length && bytes >= 1024; i++, bytes /= 1024) + + while (dblSByte >= 1000 && i < suffix.Length - 1) { - dblSByte = bytes / 1024.0; + dblSByte /= 1000.0; + i++; } return addSuffix ? $"{dblSByte:0.00} {suffix[i]}" : $"{dblSByte:0.00}";