From 57cef25e27aacefebffd71d738e8ab0da73a5eff Mon Sep 17 00:00:00 2001 From: adman Date: Sun, 10 May 2026 13:01:40 +0200 Subject: [PATCH] manage state transitions in print_replay tool --- cmd/strom/print_replay/main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/strom/print_replay/main.go b/cmd/strom/print_replay/main.go index 6eaf70c..ff8a5f5 100644 --- a/cmd/strom/print_replay/main.go +++ b/cmd/strom/print_replay/main.go @@ -19,6 +19,8 @@ var ( ProtocolVersion = cmd.Int("protocol", -1, "The protocol version") ) +var state = proto_base.Login + func UnpackPacket(r io.Reader) (packet proto_base.EncodeDecodeAble, err error) { var timestamp, length uint32 err = binary.Read(r, binary.BigEndian, ×tamp) @@ -40,7 +42,7 @@ func UnpackPacket(r io.Reader) (packet proto_base.EncodeDecodeAble, err error) { return } - i, ok := proto.LookUpTypeByPacketInfo(proto_base.ToClient, proto_base.Login, packetId, int32(*ProtocolVersion)) + i, ok := proto.LookUpTypeByPacketInfo(proto_base.ToClient, state, packetId, int32(*ProtocolVersion)) if !ok { packet = &proto.UnCodablePacket{Err: proto.BadPacketIdErr, Data: b.Bytes(), Direction: proto_base.ToClient} return @@ -51,6 +53,12 @@ func UnpackPacket(r io.Reader) (packet proto_base.EncodeDecodeAble, err error) { packet = &proto.UnCodablePacket{Err: err, Data: b.Bytes(), Direction: proto_base.ToClient} err = nil } + switch i.Name { + case "success": + state = proto_base.Configuration + case "finish_configuration": + state = proto_base.Play + } return } @@ -78,6 +86,5 @@ func Run(args []string) (err error) { return } fmt.Printf("Packet: %#v\n", packet) - fmt.Printf("Packet lllll: %v\n", packet) } }