From 2e10d4395d9a2dd2f68d486f2aba5506101f81ab Mon Sep 17 00:00:00 2001 From: Nikhil Banerjee <97465665+nikbanerjee-unity@users.noreply.github.com> Date: Fri, 24 Feb 2023 14:37:25 +0000 Subject: [PATCH] feat: Support tf2e-v10 protocol in go-svrquery (#32) This adds support for the latest TF2E-V10 protocol. --- lib/svrquery/protocol/titanfall/query.go | 6 ++++- lib/svrquery/protocol/titanfall/query_test.go | 22 ++++++++++++++++++ lib/svrquery/protocol/titanfall/register.go | 1 + .../protocol/titanfall/testdata/request-v10 | Bin 0 -> 1200 bytes .../protocol/titanfall/testdata/response-v10 | Bin 0 -> 205 bytes lib/svrquery/protocol/titanfall/types.go | 10 ++++++++ 6 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 lib/svrquery/protocol/titanfall/testdata/request-v10 create mode 100644 lib/svrquery/protocol/titanfall/testdata/response-v10 diff --git a/lib/svrquery/protocol/titanfall/query.go b/lib/svrquery/protocol/titanfall/query.go index c2c6b7e..c31a981 100644 --- a/lib/svrquery/protocol/titanfall/query.go +++ b/lib/svrquery/protocol/titanfall/query.go @@ -174,7 +174,11 @@ func (q *queryer) Query() (resp protocol.Responser, err error) { } if i.Version > 2 { - if i.Version >= 9 { + if i.Version >= 10 { + if err = r.Read(&i.MatchStateV10); err != nil { + return nil, err + } + } else if i.Version >= 9 { if err = r.Read(&i.MatchStateV9); err != nil { return nil, err } diff --git a/lib/svrquery/protocol/titanfall/query_test.go b/lib/svrquery/protocol/titanfall/query_test.go index 23332e0..c4fc793 100644 --- a/lib/svrquery/protocol/titanfall/query_test.go +++ b/lib/svrquery/protocol/titanfall/query_test.go @@ -106,6 +106,19 @@ func TestQuery(t *testing.T) { } v9.MatchState = MatchState{} + v10 := v9 + v10.Version = 10 + v10.MatchStateV10 = MatchStateV10{ + MatchStateV9: MatchStateV9{ + Phase: 3, + TimePassed: 0, + TeamsLeftWithPlayersNum: 0, + }, + CurrentEntityPropertyCount: 2, + MaxEntityPropertyCount: 5, + } + v10.MatchStateV9 = MatchStateV9{} + cases := []struct { name string version byte @@ -147,6 +160,15 @@ func TestQuery(t *testing.T) { key: testKey, expEncypted: true, }, + { + name: "v10", + version: 10, + request: "request-v10", + response: "response-v10", + expected: v10, + key: testKey, + expEncypted: true, + }, { name: "keyed", version: 5, diff --git a/lib/svrquery/protocol/titanfall/register.go b/lib/svrquery/protocol/titanfall/register.go index fb9d5a1..c0180d7 100644 --- a/lib/svrquery/protocol/titanfall/register.go +++ b/lib/svrquery/protocol/titanfall/register.go @@ -10,4 +10,5 @@ func init() { protocol.MustRegister("tf2e-v7", newQueryer(7)) protocol.MustRegister("tf2e-v8", newQueryer(8)) protocol.MustRegister("tf2e-v9", newQueryer(9)) + protocol.MustRegister("tf2e-v10", newQueryer(10)) } diff --git a/lib/svrquery/protocol/titanfall/testdata/request-v10 b/lib/svrquery/protocol/titanfall/testdata/request-v10 new file mode 100644 index 0000000000000000000000000000000000000000..4c925c03e47ad01340e3d21fb67dec1aa46c4921 GIT binary patch literal 1200 acmezW|Nnnq4u(-M8UmvsFd71bJ_G#4=)n7^A}uPi60k>dZ~6B!%tF z V-o