diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-12 20:53:09 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-09-16 21:39:42 +0300 |
| commit | 82871ba1bac1d62f69e1933b66659e62d2e5e063 (patch) | |
| tree | a906310fba89b670bcfda9625a6d776553d482f6 /pkg/messages/types/netSetConVar.go | |
| parent | net/svc messages finally getting parsed correctly (diff) | |
| download | sdp.go-82871ba1bac1d62f69e1933b66659e62d2e5e063.tar.gz sdp.go-82871ba1bac1d62f69e1933b66659e62d2e5e063.tar.bz2 sdp.go-82871ba1bac1d62f69e1933b66659e62d2e5e063.zip | |
another rewrite, v1.0.0
Diffstat (limited to 'pkg/messages/types/netSetConVar.go')
| -rw-r--r-- | pkg/messages/types/netSetConVar.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/pkg/messages/types/netSetConVar.go b/pkg/messages/types/netSetConVar.go new file mode 100644 index 0000000..08042ae --- /dev/null +++ b/pkg/messages/types/netSetConVar.go | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | package messages | ||
| 2 | |||
| 3 | import "github.com/pektezol/bitreader" | ||
| 4 | |||
| 5 | type NetSetConVar struct { | ||
| 6 | Length int8 | ||
| 7 | ConVars []conVar | ||
| 8 | } | ||
| 9 | |||
| 10 | type conVar struct { | ||
| 11 | Name string | ||
| 12 | Value string | ||
| 13 | } | ||
| 14 | |||
| 15 | func ParseNetSetConVar(reader *bitreader.ReaderType) NetSetConVar { | ||
| 16 | length := reader.TryReadBits(8) | ||
| 17 | convars := []conVar{} | ||
| 18 | for count := 0; count < int(length); count++ { | ||
| 19 | convar := conVar{ | ||
| 20 | Name: reader.TryReadString(), | ||
| 21 | Value: reader.TryReadString(), | ||
| 22 | } | ||
| 23 | convars = append(convars, convar) | ||
| 24 | } | ||
| 25 | return NetSetConVar{ | ||
| 26 | Length: int8(length), | ||
| 27 | ConVars: convars, | ||
| 28 | } | ||
| 29 | } | ||