Suffix everything 0.7 specific with 7

This commit is contained in:
ChillerDragon 2024-06-20 08:26:04 +08:00
parent 5fd1c39039
commit 7cf7cfdb8c
7 changed files with 20 additions and 20 deletions

View file

@ -1,4 +1,4 @@
package chunk package chunk7
const ( const (
chunkFlagVital = 1 chunkFlagVital = 1

View file

@ -1,4 +1,4 @@
package chunk package chunk7
import ( import (
"reflect" "reflect"

View file

@ -1,4 +1,4 @@
package chunk package chunk7
// data has to be the uncompressed payload of a teeworlds packet // data has to be the uncompressed payload of a teeworlds packet
// without the packet header // without the packet header

View file

@ -1,4 +1,4 @@
package chunk package chunk7
import ( import (
"fmt" "fmt"

View file

@ -1,4 +1,4 @@
package packet package packet7
import "slices" import "slices"

View file

@ -1,4 +1,4 @@
package packet package packet7
import ( import (
"reflect" "reflect"

View file

@ -8,11 +8,11 @@ import (
"slices" "slices"
"github.com/teeworlds-go/huffman" "github.com/teeworlds-go/huffman"
"github.com/teeworlds-go/teeworlds/chunk" "github.com/teeworlds-go/teeworlds/chunk7"
"github.com/teeworlds-go/teeworlds/messages7" "github.com/teeworlds-go/teeworlds/messages7"
"github.com/teeworlds-go/teeworlds/network7" "github.com/teeworlds-go/teeworlds/network7"
"github.com/teeworlds-go/teeworlds/packer" "github.com/teeworlds-go/teeworlds/packer"
"github.com/teeworlds-go/teeworlds/packet" "github.com/teeworlds-go/teeworlds/packet7"
) )
type Player struct { type Player struct {
@ -45,8 +45,8 @@ func (c *Connection) SendCtrlToken(myToken []byte) {
} }
func (c *Connection) SendCtrlMsg(data []byte) { func (c *Connection) SendCtrlMsg(data []byte) {
header := packet.PacketHeader{ header := packet7.PacketHeader{
Flags: packet.PacketFlags{ Flags: packet7.PacketFlags{
Connless: false, Connless: false,
Compression: false, Compression: false,
Resend: false, Resend: false,
@ -75,7 +75,7 @@ func (c *Connection) SendReady() {
type ChunkArgs struct { type ChunkArgs struct {
MsgId network7.NetMsg MsgId network7.NetMsg
System bool System bool
Flags chunk.ChunkFlags Flags chunk7.ChunkFlags
Payload []byte Payload []byte
} }
@ -88,7 +88,7 @@ func (client *Connection) PackChunk(c ChunkArgs) []byte {
client.Sequence++ client.Sequence++
msgAndSys := packer.PackMsg(c.MsgId) msgAndSys := packer.PackMsg(c.MsgId)
chunkHeader := chunk.ChunkHeader{ chunkHeader := chunk7.ChunkHeader{
Flags: c.Flags, Flags: c.Flags,
Size: len(msgAndSys) + len(c.Payload), Size: len(msgAndSys) + len(c.Payload),
Seq: client.Sequence, Seq: client.Sequence,
@ -106,8 +106,8 @@ func (client *Connection) PackChunk(c ChunkArgs) []byte {
} }
func (client *Connection) SendPacket(payload []byte, numChunks int) { func (client *Connection) SendPacket(payload []byte, numChunks int) {
header := packet.PacketHeader{ header := packet7.PacketHeader{
Flags: packet.PacketFlags{ Flags: packet7.PacketFlags{
Connless: false, Connless: false,
Compression: false, Compression: false,
Resend: false, Resend: false,
@ -159,7 +159,7 @@ func (client *Connection) SendStartInfo() {
payload := client.PackChunk(ChunkArgs{ payload := client.PackChunk(ChunkArgs{
MsgId: network7.MsgGameClStartInfo, MsgId: network7.MsgGameClStartInfo,
Flags: chunk.ChunkFlags{ Flags: chunk7.ChunkFlags{
Vital: true, Vital: true,
}, },
Payload: info.Pack(), Payload: info.Pack(),
@ -184,7 +184,7 @@ func byteSliceToString(s []byte) string {
return string(s) return string(s)
} }
func (client *Connection) OnSystemMsg(msg network7.NetMsg, chunk chunk.Chunk, u *packer.Unpacker) { func (client *Connection) OnSystemMsg(msg network7.NetMsg, chunk chunk7.Chunk, u *packer.Unpacker) {
if msg == network7.MsgSysMapChange { if msg == network7.MsgSysMapChange {
fmt.Println("got map change") fmt.Println("got map change")
client.SendReady() client.SendReady()
@ -209,7 +209,7 @@ func (client *Connection) OnMotd(motd string) {
fmt.Printf("[motd] %s\n", motd) fmt.Printf("[motd] %s\n", motd)
} }
func (client *Connection) OnGameMsg(msg network7.NetMsg, chunk chunk.Chunk, u *packer.Unpacker) { func (client *Connection) OnGameMsg(msg network7.NetMsg, chunk chunk7.Chunk, u *packer.Unpacker) {
if msg == network7.MsgGameReadyToEnter { if msg == network7.MsgGameReadyToEnter {
fmt.Println("got ready to enter") fmt.Println("got ready to enter")
client.SendEnterGame() client.SendEnterGame()
@ -234,7 +234,7 @@ func (client *Connection) OnGameMsg(msg network7.NetMsg, chunk chunk.Chunk, u *p
} }
} }
func (client *Connection) OnMessage(chunk chunk.Chunk) { func (client *Connection) OnMessage(chunk chunk7.Chunk) {
// fmt.Printf("got chunk size=%d data=%v\n", chunk.Header.Size, chunk.Data) // fmt.Printf("got chunk size=%d data=%v\n", chunk.Header.Size, chunk.Data)
if chunk.Header.Flags.Vital { if chunk.Header.Flags.Vital {
@ -257,7 +257,7 @@ func (client *Connection) OnMessage(chunk chunk.Chunk) {
} }
func (client *Connection) OnPacketPayload(header []byte, data []byte) { func (client *Connection) OnPacketPayload(header []byte, data []byte) {
chunks := chunk.UnpackChunks(data) chunks := chunk7.UnpackChunks(data)
for _, c := range chunks { for _, c := range chunks {
client.OnMessage(c) client.OnMessage(c)
@ -265,7 +265,7 @@ func (client *Connection) OnPacketPayload(header []byte, data []byte) {
} }
func (client *Connection) OnPacket(data []byte) { func (client *Connection) OnPacket(data []byte) {
header := packet.PacketHeader{} header := packet7.PacketHeader{}
headerRaw := data[:7] headerRaw := data[:7]
payload := data[7:] payload := data[7:]
header.Unpack(headerRaw) header.Unpack(headerRaw)