summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-06-08 15:12:00 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-06-08 15:12:00 +0200
commitf8780650f70938f13539aa15cfa63af1734017d1 (patch)
treecd7bcbb6a6039386790fdd4c2d035897d1a94c36
parent64825b4e1a1a0e20ee7907bef3e72bd155446c9d (diff)
fix mapblock compression
-rw-r--r--mapblk.go2
-rw-r--r--serialize.go244
-rw-r--r--tocltcmds.go4
3 files changed, 121 insertions, 129 deletions
diff --git a/mapblk.go b/mapblk.go
index c91c082..5f4be42 100644
--- a/mapblk.go
+++ b/mapblk.go
@@ -24,11 +24,9 @@ type MapBlk struct {
//mt:const uint8(2) // Size of param0 in bytes.
//mt:const uint8(1 + 1) // Size of param1 and param2 combined, in bytes.
- //mt:zstd
Param0 [4096]Content
Param1 [4096]uint8
Param2 [4096]uint8
- //mt:end
NodeMetas map[uint16]*NodeMeta
diff --git a/serialize.go b/serialize.go
index 7e66247..3b236b8 100644
--- a/serialize.go
+++ b/serialize.go
@@ -2142,52 +2142,68 @@ func (obj *ToCltKick) deserialize(r io.Reader) {
func (obj *ToCltBlkData) serialize(w io.Writer) {
for local65 := range (*(*(struct {
Blkpos [3]int16
- Blk MapBlk
+ //mt:zstd
+ Blk MapBlk
}))(obj)).Blkpos {
{
x := ((*(*(struct {
Blkpos [3]int16
- Blk MapBlk
+ //mt:zstd
+ Blk MapBlk
}))(obj)).Blkpos)[local65]
write16(w, uint16(x))
}
}
- if err := pcall(func() {
- ((*(*(struct {
- Blkpos [3]int16
- Blk MapBlk
- }))(obj)).Blk).serialize(w)
- }); err != nil {
- if err == io.EOF {
- chk(io.EOF)
+ {
+ w, err := zstd.NewWriter(w)
+ chk(err)
+ if err := pcall(func() {
+ ((*(*(struct {
+ Blkpos [3]int16
+ //mt:zstd
+ Blk MapBlk
+ }))(obj)).Blk).serialize(w)
+ }); err != nil {
+ if err == io.EOF {
+ chk(io.EOF)
+ }
+ chk(fmt.Errorf("%s: %w", "github.com/HimbeerserverDE/mt.MapBlk", err))
}
- chk(fmt.Errorf("%s: %w", "github.com/HimbeerserverDE/mt.MapBlk", err))
+ chk(w.Close())
}
}
func (obj *ToCltBlkData) deserialize(r io.Reader) {
for local66 := range (*(*(struct {
Blkpos [3]int16
- Blk MapBlk
+ //mt:zstd
+ Blk MapBlk
}))(obj)).Blkpos {
{
p := &((*(*(struct {
Blkpos [3]int16
- Blk MapBlk
+ //mt:zstd
+ Blk MapBlk
}))(obj)).Blkpos)[local66]
*p = int16(read16(r))
}
}
- if err := pcall(func() {
- ((*(*(struct {
- Blkpos [3]int16
- Blk MapBlk
- }))(obj)).Blk).deserialize(r)
- }); err != nil {
- if err == io.EOF {
- chk(io.EOF)
+ {
+ r, err := zstd.NewReader(byteReader{r})
+ chk(err)
+ if err := pcall(func() {
+ ((*(*(struct {
+ Blkpos [3]int16
+ //mt:zstd
+ Blk MapBlk
+ }))(obj)).Blk).deserialize(r)
+ }); err != nil {
+ if err == io.EOF {
+ chk(io.EOF)
+ }
+ chk(fmt.Errorf("%s: %w", "github.com/HimbeerserverDE/mt.MapBlk", err))
}
- chk(fmt.Errorf("%s: %w", "github.com/HimbeerserverDE/mt.MapBlk", err))
+ r.Close()
}
}
@@ -22709,7 +22725,6 @@ func (obj *MapBlk) serialize(w io.Writer) {
Flags MapBlkFlags
LitFrom LitFromBlks
- //mt:zstd
Param0 [4096]Content
Param1 [4096]uint8
Param2 [4096]uint8
@@ -22727,7 +22742,6 @@ func (obj *MapBlk) serialize(w io.Writer) {
Flags MapBlkFlags
LitFrom LitFromBlks
- //mt:zstd
Param0 [4096]Content
Param1 [4096]uint8
Param2 [4096]uint8
@@ -22754,75 +22768,65 @@ func (obj *MapBlk) serialize(w io.Writer) {
write8(w, uint8(x))
}
}
- {
- w, err := zstd.NewWriter(w)
- chk(err)
- for local287 := range (*(*(struct {
- Flags MapBlkFlags
- LitFrom LitFromBlks
+ for local287 := range (*(*(struct {
+ Flags MapBlkFlags
+ LitFrom LitFromBlks
- //mt:zstd
- Param0 [4096]Content
- Param1 [4096]uint8
- Param2 [4096]uint8
+ Param0 [4096]Content
+ Param1 [4096]uint8
+ Param2 [4096]uint8
- NodeMetas map[uint16]*NodeMeta
- }))(obj)).Param0 {
- if err := pcall(func() {
- (((*(*(struct {
- Flags MapBlkFlags
- LitFrom LitFromBlks
-
- //mt:zstd
- Param0 [4096]Content
- Param1 [4096]uint8
- Param2 [4096]uint8
-
- NodeMetas map[uint16]*NodeMeta
- }))(obj)).Param0)[local287]).serialize(w)
- }); err != nil {
- if err == io.EOF {
- chk(io.EOF)
- }
- chk(fmt.Errorf("%s: %w", "github.com/HimbeerserverDE/mt.Content", err))
- }
- }
- {
- _, err := w.Write(((*(*(struct {
+ NodeMetas map[uint16]*NodeMeta
+ }))(obj)).Param0 {
+ if err := pcall(func() {
+ (((*(*(struct {
Flags MapBlkFlags
LitFrom LitFromBlks
- //mt:zstd
Param0 [4096]Content
Param1 [4096]uint8
Param2 [4096]uint8
NodeMetas map[uint16]*NodeMeta
- }))(obj)).Param1)[:])
- chk(err)
+ }))(obj)).Param0)[local287]).serialize(w)
+ }); err != nil {
+ if err == io.EOF {
+ chk(io.EOF)
+ }
+ chk(fmt.Errorf("%s: %w", "github.com/HimbeerserverDE/mt.Content", err))
}
- {
- _, err := w.Write(((*(*(struct {
- Flags MapBlkFlags
- LitFrom LitFromBlks
+ }
+ {
+ _, err := w.Write(((*(*(struct {
+ Flags MapBlkFlags
+ LitFrom LitFromBlks
- //mt:zstd
- Param0 [4096]Content
- Param1 [4096]uint8
- Param2 [4096]uint8
+ Param0 [4096]Content
+ Param1 [4096]uint8
+ Param2 [4096]uint8
- NodeMetas map[uint16]*NodeMeta
- }))(obj)).Param2)[:])
- chk(err)
- }
- chk(w.Close())
+ NodeMetas map[uint16]*NodeMeta
+ }))(obj)).Param1)[:])
+ chk(err)
+ }
+ {
+ _, err := w.Write(((*(*(struct {
+ Flags MapBlkFlags
+ LitFrom LitFromBlks
+
+ Param0 [4096]Content
+ Param1 [4096]uint8
+ Param2 [4096]uint8
+
+ NodeMetas map[uint16]*NodeMeta
+ }))(obj)).Param2)[:])
+ chk(err)
}
{
x := (*(*(struct {
Flags MapBlkFlags
LitFrom LitFromBlks
- //mt:zstd
Param0 [4096]Content
Param1 [4096]uint8
Param2 [4096]uint8
@@ -22879,7 +22883,6 @@ func (obj *MapBlk) deserialize(r io.Reader) {
Flags MapBlkFlags
LitFrom LitFromBlks
- //mt:zstd
Param0 [4096]Content
Param1 [4096]uint8
Param2 [4096]uint8
@@ -22897,7 +22900,6 @@ func (obj *MapBlk) deserialize(r io.Reader) {
Flags MapBlkFlags
LitFrom LitFromBlks
- //mt:zstd
Param0 [4096]Content
Param1 [4096]uint8
Param2 [4096]uint8
@@ -22932,75 +22934,65 @@ func (obj *MapBlk) deserialize(r io.Reader) {
chk(fmt.Errorf("const %v: %v", "uint8(1 + 1) // Size of param1 and param2 combined, in bytes.", local291))
}
}
- {
- r, err := zstd.NewReader(byteReader{r})
- chk(err)
- for local293 := range (*(*(struct {
- Flags MapBlkFlags
- LitFrom LitFromBlks
-
- //mt:zstd
- Param0 [4096]Content
- Param1 [4096]uint8
- Param2 [4096]uint8
-
- NodeMetas map[uint16]*NodeMeta
- }))(obj)).Param0 {
- if err := pcall(func() {
- (((*(*(struct {
- Flags MapBlkFlags
- LitFrom LitFromBlks
+ for local293 := range (*(*(struct {
+ Flags MapBlkFlags
+ LitFrom LitFromBlks
- //mt:zstd
- Param0 [4096]Content
- Param1 [4096]uint8
- Param2 [4096]uint8
+ Param0 [4096]Content
+ Param1 [4096]uint8
+ Param2 [4096]uint8
- NodeMetas map[uint16]*NodeMeta
- }))(obj)).Param0)[local293]).deserialize(r)
- }); err != nil {
- if err == io.EOF {
- chk(io.EOF)
- }
- chk(fmt.Errorf("%s: %w", "github.com/HimbeerserverDE/mt.Content", err))
- }
- }
- {
- _, err := io.ReadFull(r, ((*(*(struct {
+ NodeMetas map[uint16]*NodeMeta
+ }))(obj)).Param0 {
+ if err := pcall(func() {
+ (((*(*(struct {
Flags MapBlkFlags
LitFrom LitFromBlks
- //mt:zstd
Param0 [4096]Content
Param1 [4096]uint8
Param2 [4096]uint8
NodeMetas map[uint16]*NodeMeta
- }))(obj)).Param1)[:])
- chk(err)
+ }))(obj)).Param0)[local293]).deserialize(r)
+ }); err != nil {
+ if err == io.EOF {
+ chk(io.EOF)
+ }
+ chk(fmt.Errorf("%s: %w", "github.com/HimbeerserverDE/mt.Content", err))
}
- {
- _, err := io.ReadFull(r, ((*(*(struct {
- Flags MapBlkFlags
- LitFrom LitFromBlks
+ }
+ {
+ _, err := io.ReadFull(r, ((*(*(struct {
+ Flags MapBlkFlags
+ LitFrom LitFromBlks
- //mt:zstd
- Param0 [4096]Content
- Param1 [4096]uint8
- Param2 [4096]uint8
+ Param0 [4096]Content
+ Param1 [4096]uint8
+ Param2 [4096]uint8
- NodeMetas map[uint16]*NodeMeta
- }))(obj)).Param2)[:])
- chk(err)
- }
- r.Close()
+ NodeMetas map[uint16]*NodeMeta
+ }))(obj)).Param1)[:])
+ chk(err)
+ }
+ {
+ _, err := io.ReadFull(r, ((*(*(struct {
+ Flags MapBlkFlags
+ LitFrom LitFromBlks
+
+ Param0 [4096]Content
+ Param1 [4096]uint8
+ Param2 [4096]uint8
+
+ NodeMetas map[uint16]*NodeMeta
+ }))(obj)).Param2)[:])
+ chk(err)
}
{
p := &(*(*(struct {
Flags MapBlkFlags
LitFrom LitFromBlks
- //mt:zstd
Param0 [4096]Content
Param1 [4096]uint8
Param2 [4096]uint8
diff --git a/tocltcmds.go b/tocltcmds.go
index 76c4c6f..814ac73 100644
--- a/tocltcmds.go
+++ b/tocltcmds.go
@@ -123,7 +123,9 @@ func (cmd ToCltKick) String() (msg string) {
// ToCltBlkData tells the client the contents of a nearby MapBlk.
type ToCltBlkData struct {
Blkpos [3]int16
- Blk MapBlk
+ //mt:zstd
+ Blk MapBlk
+ //mt:end
}
// ToCltAddNode tells the client that a nearby node changed