2024-06-22 02:38:06 +00:00
|
|
|
package messages7
|
|
|
|
|
|
|
|
import (
|
|
|
|
"slices"
|
|
|
|
|
2024-06-22 05:59:27 +00:00
|
|
|
"github.com/teeworlds-go/go-teeworlds-protocol/chunk7"
|
|
|
|
"github.com/teeworlds-go/go-teeworlds-protocol/network7"
|
|
|
|
"github.com/teeworlds-go/go-teeworlds-protocol/packer"
|
2024-06-22 02:38:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type MapChange struct {
|
|
|
|
ChunkHeader *chunk7.ChunkHeader
|
|
|
|
|
|
|
|
Name string
|
|
|
|
Crc int
|
|
|
|
Size int
|
|
|
|
NumResponseChunksPerRequest int
|
|
|
|
ChunkSize int
|
|
|
|
Sha256 [32]byte
|
|
|
|
}
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
func (msg *MapChange) MsgId() int {
|
2024-06-22 02:38:06 +00:00
|
|
|
return network7.MsgSysMapChange
|
|
|
|
}
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
func (msg *MapChange) MsgType() network7.MsgType {
|
2024-06-22 02:38:06 +00:00
|
|
|
return network7.TypeNet
|
|
|
|
}
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
func (msg *MapChange) System() bool {
|
2024-06-22 02:38:06 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
func (msg *MapChange) Vital() bool {
|
2024-06-22 02:38:06 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
func (msg *MapChange) Pack() []byte {
|
2024-06-22 02:38:06 +00:00
|
|
|
return slices.Concat(
|
|
|
|
packer.PackStr(msg.Name),
|
|
|
|
packer.PackInt(msg.Crc),
|
|
|
|
packer.PackInt(msg.Size),
|
|
|
|
packer.PackInt(msg.NumResponseChunksPerRequest),
|
|
|
|
packer.PackInt(msg.ChunkSize),
|
|
|
|
msg.Sha256[:],
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-06-23 19:18:54 +00:00
|
|
|
func (msg *MapChange) Unpack(u *packer.Unpacker) error {
|
2024-06-25 04:19:51 +00:00
|
|
|
msg.Name, _ = u.GetString()
|
2024-06-22 02:38:06 +00:00
|
|
|
msg.Crc = u.GetInt()
|
|
|
|
msg.Size = u.GetInt()
|
|
|
|
msg.NumResponseChunksPerRequest = u.GetInt()
|
|
|
|
msg.ChunkSize = u.GetInt()
|
|
|
|
msg.Sha256 = [32]byte(u.Rest())
|
2024-06-23 19:18:54 +00:00
|
|
|
return nil
|
2024-06-22 02:38:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (msg *MapChange) Header() *chunk7.ChunkHeader {
|
|
|
|
return msg.ChunkHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
func (msg *MapChange) SetHeader(header *chunk7.ChunkHeader) {
|
|
|
|
msg.ChunkHeader = header
|
|
|
|
}
|