Skip to content

Commit f1085b8

Browse files
authored
Don't always warn about a missing PacketHandlerClass attribute (#829)
1 parent 725b8fb commit f1085b8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Source/Common/Networking/MpConnectionState.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ public static void SetImplementation(ConnectionStateEnum state, Type type)
3636

3737
stateImpls[(int)state] = type;
3838

39+
// The point of this attribute is to explicitly mark how to handle packet listeners from the base type.
40+
// If the base type is the lowest possible (MpConnectionState, which doesn't have any listeners), there is
41+
// no reason to warn when the annotation is missing.
3942
var typeAttr = type.GetAttribute<PacketHandlerClassAttribute>();
40-
if (typeAttr == null)
43+
if (typeAttr == null &&
44+
type.BaseType != typeof(MpConnectionState) &&
45+
type.BaseType != typeof(AsyncConnectionState))
4146
ServerLog.Log($"Packet handler {type.FullName} does not have a PacketHandlerClass attribute");
4247

4348
var bindingFlags = BindingFlags.Instance | BindingFlags.Public;

0 commit comments

Comments
 (0)