-namespace Impostor.Api.Net.Messages
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
+namespace Impostor.Api.Net.Messages
{
public static class MessageFlags
{
public const byte SetActivePodType = 21;
public const byte QueryPlatformIds = 22;
public const byte QueryLobbyInfo = 23;
+
+ private static readonly Dictionary<byte, string> FlagCache;
+
+ static MessageFlags()
+ {
+ FlagCache = typeof(MessageFlags)
+ .GetFields(BindingFlags.Public | BindingFlags.Static)
+ .Where(fi => fi.IsLiteral && !fi.IsInitOnly)
+ .ToDictionary(x => (byte) x.GetValue(null)!, y => y.Name);
+ }
+
+ public static string FlagToString(byte flag)
+ {
+ return FlagCache[flag];
+ }
}
}
{
var flag = reader.Tag;
- _logger.LogTrace("[{0}] Server got {1}.", Id, flag);
+ _logger.LogTrace("[{0}] Server got {1}.", Id, MessageFlags.FlagToString(flag));
switch (flag)
{