1
0
forked from MTSR/mapserver

mapblock size

This commit is contained in:
NatureFreshMilk 2019-01-18 15:18:42 +01:00
parent 0a702d240c
commit 8d0fcebb17
5 changed files with 13 additions and 11 deletions

View File

@ -1,6 +1,7 @@
package mapblockparser package mapblockparser
type MapBlock struct { type MapBlock struct {
Size int `json:"size"`
Version byte `json:"version"` Version byte `json:"version"`
Underground bool `json:"underground"` Underground bool `json:"underground"`
Mapdata []byte `json:"mapdata"` Mapdata []byte `json:"mapdata"`

View File

@ -6,13 +6,14 @@ import (
) )
func Parse(data []byte, mtime int64) (*MapBlock, error) { func Parse(data []byte, mtime int64) (*MapBlock, error) {
mapblock := NewMapblock()
mapblock.Mtime = mtime
if len(data) == 0 { if len(data) == 0 {
return nil, errors.New("no data") return nil, errors.New("no data")
} }
mapblock := NewMapblock()
mapblock.Mtime = mtime
mapblock.Size = len(data)
offset := 0 offset := 0
// version // version

View File

@ -7,13 +7,13 @@ import (
type MapData struct { type MapData struct {
//mapblock position //mapblock position
MBPos coords.MapBlockCoords MBPos coords.MapBlockCoords
//block position //block position
X, Y, Z int X, Y, Z int
Type string Type string
Data string Data string
Mtime int64 Mtime int64
} }
type SearchQuery struct { type SearchQuery struct {

View File

@ -12,7 +12,7 @@ type ClearMapData struct {
func (this *ClearMapData) OnParsedMapBlock(block *mapblockparser.MapBlock, pos coords.MapBlockCoords) { func (this *ClearMapData) OnParsedMapBlock(block *mapblockparser.MapBlock, pos coords.MapBlockCoords) {
err := this.db.RemoveMapData(pos) err := this.db.RemoveMapData(pos)
if err != nil { if err != nil {
panic(err) panic(err)
} }
} }

View File

@ -12,7 +12,7 @@ type POI struct {
func (this *POI) OnParsedMapBlock(block *mapblockparser.MapBlock, pos coords.MapBlockCoords) { func (this *POI) OnParsedMapBlock(block *mapblockparser.MapBlock, pos coords.MapBlockCoords) {
var found bool var found bool
for _, v := range(block.BlockMapping) { for _, v := range block.BlockMapping {
if v == "mapserver:poi" { if v == "mapserver:poi" {
found = true found = true
break break