fix LookupPacketInfoByType for undecoable

This commit is contained in:
adman
2026-03-27 12:59:10 +01:00
parent e921e9e9d2
commit ca33185f20
2 changed files with 9 additions and 0 deletions
+2
View File
@@ -80,6 +80,7 @@ func (c *Conn) OnLoginTick(_ LoginTick) (err error) {
if err != nil { if err != nil {
return return
} }
slog.Debug("logintick recv", "actor", c.Actor, "packet", fmt.Sprintf("%#v", packet))
err = c.Fire(packet) err = c.Fire(packet)
return return
} }
@@ -135,6 +136,7 @@ func (c *Conn) ActivateReceiveRoutine() (chSending <-chan any) {
ch <- err ch <- err
return return
} }
slog.Debug("recv", "actor", c.Actor, "packet", fmt.Sprintf("%#v", packet))
ch <- packet ch <- packet
} }
} }
+7
View File
@@ -41,6 +41,13 @@ func LookUpTypeByPacketInfoAndCopyType(direction proto_base.Direction, state pro
} }
func LookupPacketInfoByType(packet proto_base.EncodeDecodeAble) (p proto_base.PacketInfo, ok bool) { func LookupPacketInfoByType(packet proto_base.EncodeDecodeAble) (p proto_base.PacketInfo, ok bool) {
undecodedPacket, isUndecoable := packet.(*UnCodablePacket)
if isUndecoable {
p = proto_base.PacketInfo{Type: &UnCodablePacket{}, Name: "un_codable", Direction: undecodedPacket.Direction, State: proto_base.Handshaking, PacketId: -1, ProtocolVersion: -1}
ok = true
return
}
for _, p := range proto_generated.Packets { for _, p := range proto_generated.Packets {
if reflect.TypeOf(p.Type) == reflect.TypeOf(packet) { if reflect.TypeOf(p.Type) == reflect.TypeOf(packet) {
return p, true return p, true