1
0
forked from MTSR/mapserver
This commit is contained in:
NatureFreshMilk 2019-03-01 07:29:27 +01:00
commit dec3d32cfe
4 changed files with 24 additions and 9 deletions

View File

@ -4,11 +4,12 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"errors" "errors"
"github.com/sirupsen/logrus"
"image/color" "image/color"
"mapserver/vfs" "mapserver/vfs"
"strconv" "strconv"
"strings" "strings"
"github.com/sirupsen/logrus"
) )
type ColorMapping struct { type ColorMapping struct {
@ -65,10 +66,10 @@ func (m *ColorMapping) LoadBytes(buffer []byte) (int, error) {
if len(parts) >= 5 { if len(parts) >= 5 {
//with alpha //with alpha
a, err = strconv.ParseInt(parts[4], 10, 32) //a, err = strconv.ParseInt(parts[4], 10, 32)
if err != nil { //if err != nil {
return 0, err // return 0, err
} //}
} }
c := color.RGBA{uint8(r), uint8(g), uint8(b), uint8(a)} c := color.RGBA{uint8(r), uint8(g), uint8(b), uint8(a)}

View File

@ -21,8 +21,8 @@ func TestNewMapping(t *testing.T) {
panic("no color") panic("no color")
} }
if c.A != 128 { //if c.A != 128 {
panic("wrong alpha") // panic("wrong alpha")
} //}
} }

View File

@ -48,6 +48,14 @@ func (a *MapBlockAccessor) FindNextLegacyBlocks(s settings.Settings, layers []*l
mapblock, err := mapblockparser.Parse(block.Data, block.Mtime, block.Pos) mapblock, err := mapblockparser.Parse(block.Data, block.Mtime, block.Pos)
if err != nil { if err != nil {
fields := logrus.Fields{
"x": block.Pos.X,
"y": block.Pos.Y,
"z": block.Pos.Z,
"err": err,
}
logrus.WithFields(fields).Error("mapblock-pars")
return nil, err return nil, err
} }

View File

@ -5,10 +5,11 @@ import (
"bytes" "bytes"
"compress/zlib" "compress/zlib"
"errors" "errors"
"github.com/sirupsen/logrus"
"io" "io"
"strconv" "strconv"
"strings" "strings"
"github.com/sirupsen/logrus"
) )
/* /*
@ -95,6 +96,11 @@ func parseMetadata(mapblock *MapBlock, data []byte) (int, error) {
valueLength := readU32(metadata, offset) valueLength := readU32(metadata, offset)
offset += 4 offset += 4
if len(metadata) <= valueLength+offset {
return 0, errors.New("metadata too short: " + strconv.Itoa(len(metadata)) +
", valuelength: " + strconv.Itoa(int(valueLength)))
}
value := string(metadata[offset : valueLength+offset]) value := string(metadata[offset : valueLength+offset])
offset += valueLength offset += valueLength