mirror of
https://github.com/Impostor/Impostor.git
synced 2026-10-20 01:46:11 +00:00
Log MessageFlag name instead of numbers
This commit is contained in:
1 parent
980d172d4f
commit
e0b85c959b
2 files changed
+21
-2
No files matched your search
@@ -1,4 +1,8 @@
|
||||
namespace Impostor.Api.Net.Messages
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Impostor.Api.Net.Messages
|
||||
{
|
||||
public static class MessageFlags
|
||||
{
|
||||
@@ -24,5 +28,20 @@
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace Impostor.Server.Net
|
||||
{
|
||||
var flag = reader.Tag;
|
||||
|
||||
_logger.LogTrace("[{0}] Server got {1}.", Id, flag);
|
||||
_logger.LogTrace("[{0}] Server got {1}.", Id, MessageFlags.FlagToString(flag));
|
||||
|
||||
switch (flag)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user