From 320d8bf5280ff8b54e636edd3aaac5fa3579282d Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Fri, 1 Feb 2019 13:54:59 +0100 Subject: [PATCH] mapblock compat see PR: https://github.com/thomasrudin-mt/minetest-tile-server/pull/46 Previous issue: https://github.com/thomasrudin-mt/minetest-tile-server/issues/7 --- server/mapblockparser/parse.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server/mapblockparser/parse.go b/server/mapblockparser/parse.go index 2d782d6..73991f3 100644 --- a/server/mapblockparser/parse.go +++ b/server/mapblockparser/parse.go @@ -21,6 +21,10 @@ func Parse(data []byte, mtime int64, pos coords.MapBlockCoords) (*MapBlock, erro // version mapblock.Version = data[0] + if mapblock.Version < 25 || mapblock.Version > 28 { + return nil, errors.New("mapblock-version not supported: " + strconv.Itoa(int(mapblock.Version))) + } + //flags flags := data[1] mapblock.Underground = (flags & 0x01) == 0x01 @@ -37,7 +41,13 @@ func Parse(data []byte, mtime int64, pos coords.MapBlockCoords) (*MapBlock, erro } //mapdata (blocks) - offset = 6 + if mapblock.Version >= 27 { + offset = 6 + + } else { + offset = 4 + + } //metadata count, err := parseMapdata(mapblock, data[offset:])