From 214ddf63a19d66b1ea039ea05b0f5a099f682b9d Mon Sep 17 00:00:00 2001 From: raven Date: Thu, 26 Mar 2026 14:49:58 -0500 Subject: initial broken attempt at implementing this idea it doesn't work. I may have made a silly mistake somewhere, or didn't properly understand the RFC specification --- server/map.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'server/map.go') diff --git a/server/map.go b/server/map.go index e84ca55..f210d42 100644 --- a/server/map.go +++ b/server/map.go @@ -95,6 +95,9 @@ func (v *blockVolume) unsyncSetBlock(p blockPos, t blockType) { } func (v *blockVolume) unsyncFlushChanges() { + if len(v.changes) == 0 { + return + } var ( oldRuns = v.blockRuns changes = v.changes @@ -198,21 +201,14 @@ func (v *blockVolume) unsyncBlocksInRange(min, max blockPos) []blockType { func (v *blockVolume) syncCompressForNetwork(/*highBits bool*/) io.ReadCloser { rd, wr := io.Pipe() go func() { - defer wr.Close() - z := gzip.NewWriter(wr) - defer z.Close() - bw := bufio.NewWriter(z) - defer bw.Flush() - v.RLock() defer v.RUnlock() - binary.Write(bw, binary.BigEndian, uint32(v.size.X*v.size.Y*v.size.Z)) - for block := range v.unsyncGetAll() { - err := bw.WriteByte(byte(block)) - if err != nil { - return - } - } + bw := bufio.NewWriter(wr) + defer bw.Flush() + writePointlessGzipHeader(bw) + len := uint32(v.size.X*v.size.Y*v.size.Z) + deflateRuns(wr, v.blockRuns, v.changes, len) + writePointlessGzipTrailer(bw, len) }() return rd } -- cgit v1.2.3