Fix warnings

This commit is contained in:
BruceChen 2026-04-06 20:32:38 +08:00
parent b6bfecc622
commit e81700bf0e
5 changed files with 28 additions and 39 deletions

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
@ -63,16 +63,16 @@ namespace MinecraftClient.Crypto
keys[0] = Unsafe.ReadUnaligned<Vector128<byte>>(ref key[0]);
MakeRoundKey(keys, 1, 0x01);
MakeRoundKey(keys, 2, 0x02);
MakeRoundKey(keys, 3, 0x04);
MakeRoundKey(keys, 4, 0x08);
MakeRoundKey(keys, 5, 0x10);
MakeRoundKey(keys, 6, 0x20);
MakeRoundKey(keys, 7, 0x40);
MakeRoundKey(keys, 8, 0x80);
MakeRoundKey(keys, 9, 0x1b);
MakeRoundKey(keys, 10, 0x36);
ExpandRound(keys, 1, Aes.KeygenAssist(keys[0], 0x01));
ExpandRound(keys, 2, Aes.KeygenAssist(keys[1], 0x02));
ExpandRound(keys, 3, Aes.KeygenAssist(keys[2], 0x04));
ExpandRound(keys, 4, Aes.KeygenAssist(keys[3], 0x08));
ExpandRound(keys, 5, Aes.KeygenAssist(keys[4], 0x10));
ExpandRound(keys, 6, Aes.KeygenAssist(keys[5], 0x20));
ExpandRound(keys, 7, Aes.KeygenAssist(keys[6], 0x40));
ExpandRound(keys, 8, Aes.KeygenAssist(keys[7], 0x80));
ExpandRound(keys, 9, Aes.KeygenAssist(keys[8], 0x1b));
ExpandRound(keys, 10, Aes.KeygenAssist(keys[9], 0x36));
for (int i = 1; i < 10; i++)
{
@ -82,13 +82,11 @@ namespace MinecraftClient.Crypto
return keys;
}
private static void MakeRoundKey(Vector128<byte>[] keys, int i, byte rcon)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void ExpandRound(Vector128<byte>[] keys, int i, Vector128<byte> assist)
{
Vector128<byte> s = keys[i - 1];
Vector128<byte> t = keys[i - 1];
t = Aes.KeygenAssist(t, rcon);
t = Sse2.Shuffle(t.AsUInt32(), 0xFF).AsByte();
Vector128<byte> t = Sse2.Shuffle(assist.AsUInt32(), 0xFF).AsByte();
s = Sse2.Xor(s, Sse2.ShiftLeftLogical128BitLane(s, 4));
s = Sse2.Xor(s, Sse2.ShiftLeftLogical128BitLane(s, 8));

View file

@ -951,7 +951,7 @@ namespace MinecraftClient
offlinePrompt = null;
ConsoleIO.Reset();
}
if (Config.Main.Advanced.PlayerHeadAsIcon) { ConsoleIcon.RevertToMCCIcon(); }
if (Config.Main.Advanced.PlayerHeadAsIcon && OperatingSystem.IsWindows()) { ConsoleIcon.RevertToMCCIcon(); }
ConsoleIO.Backend?.Shutdown();
Environment.Exit(exitcode);
}

View file

@ -803,7 +803,7 @@ public sealed class MccGameApi
{
Id = inventory.ID,
Type = inventory.Type.ToString(),
Title = inventory.Title,
Title = inventory.Title ?? string.Empty,
SlotCount = inventory.Type.SlotCount(),
Slots = slots,
Cursor = TryBuildCursorSnapshot(inventory)
@ -850,7 +850,7 @@ public sealed class MccGameApi
{
InventoryId = entry.Key,
InventoryType = inventory.Type.ToString(),
InventoryTitle = inventory.Title,
InventoryTitle = inventory.Title ?? string.Empty,
Slot = pair.Key,
ItemType = pair.Value.Type.ToString(),
TypeLabel = pair.Value.GetTypeString(),
@ -894,7 +894,7 @@ public sealed class MccGameApi
{
Id = entry.Key,
Type = entry.Value.Type.ToString(),
Title = entry.Value.Title,
Title = entry.Value.Title ?? string.Empty,
SlotCount = entry.Value.Type.SlotCount(),
NonEmptySlots = entry.Value.Items.Count(item => IsSnapshotInventorySlot(entry.Value, item.Key)),
Active = entry.Key > 0 && entry.Key == GetActiveContainerId(client)

View file

@ -19,7 +19,6 @@ namespace MinecraftClient.Tui
public event EventHandler<ConsoleInputBuffer>? OnInputChange;
private MainTuiView? _view;
private volatile bool _readThreadActive;
public bool DisplayUserInput { get; set; } = true;
@ -177,12 +176,10 @@ namespace MinecraftClient.Tui
public void BeginReadThread()
{
_readThreadActive = true;
}
public void StopReadThread()
{
_readThreadActive = false;
DismissOverlay();
}

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Drawing;
using System.IO;
using System.Net.Http;
@ -13,6 +13,7 @@ namespace MinecraftClient.WinAPI
/// Allow to set the player skin as console icon, on Windows only.
/// See StackOverflow no. 2986853
/// </summary>
[SupportedOSPlatform("windows")]
public static class ConsoleIcon
{
[DllImport("kernel32.dll", SetLastError = true)]
@ -31,19 +32,15 @@ namespace MinecraftClient.WinAPI
}
private static void SetWindowIcon(System.Drawing.Icon icon)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
IntPtr mwHandle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
SendMessage(mwHandle, (int)WinMessages.SETICON, 0, icon.Handle);
SendMessage(mwHandle, (int)WinMessages.SETICON, 1, icon.Handle);
}
}
/// <summary>
/// Asynchronously download the player's skin and set the head as console icon
/// </summary>
[SupportedOSPlatform("windows")]
public static void SetPlayerIconAsync(string playerName)
{
Thread t = new(new ThreadStart(delegate
@ -98,8 +95,6 @@ namespace MinecraftClient.WinAPI
/// Set the icon back to the default MCC icon
/// </summary>
public static void RevertToMCCIcon()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) //Windows Only
{
try
{
@ -111,4 +106,3 @@ namespace MinecraftClient.WinAPI
}
}
}
}