render tile z:13 on initial rendering

This commit is contained in:
NatureFreshMilk 2019-01-21 11:31:50 +01:00
parent 99e55b0319
commit 3b2741f390
6 changed files with 26 additions and 10 deletions

View File

@ -1,7 +1,9 @@
package coords
type MapBlockCoords struct {
X, Y, Z int
X int `json:"x"`
Y int `json:"y"`
Z int `json:"z"`
}
func NewMapBlockCoords(x, y, z int) MapBlockCoords {

View File

@ -32,8 +32,14 @@ func Job(ctx *app.App) {
lastcoords = *newlastcoords
//for _, mb := range mblist {
//}
for _, mb := range mblist {
tc := coords.GetTileCoordsFromMapBlock(mb.Pos)
_, err = ctx.Tilerenderer.Render(tc)
if err != nil {
panic(err)
}
}
//Save current positions of initial run
rstate.LastX = lastcoords.X

View File

@ -62,7 +62,7 @@ func (a *MapBlockAccessor) FindLegacyMapBlocks(lastpos coords.MapBlockCoords, li
key := getKey(block.Pos)
mapblock, err := mapblockparser.Parse(block.Data, block.Mtime)
mapblock, err := mapblockparser.Parse(block.Data, block.Mtime, block.Pos)
if err != nil {
return nil, nil, err
}
@ -100,7 +100,7 @@ func (a *MapBlockAccessor) FindLatestMapBlocks(mintime int64, limit int) ([]*map
key := getKey(block.Pos)
mapblock, err := mapblockparser.Parse(block.Data, block.Mtime)
mapblock, err := mapblockparser.Parse(block.Data, block.Mtime, block.Pos)
if err != nil {
return nil, err
}
@ -133,7 +133,7 @@ func (a *MapBlockAccessor) GetMapBlock(pos coords.MapBlockCoords) (*mapblockpars
return nil, nil
}
mapblock, err := mapblockparser.Parse(block.Data, block.Mtime)
mapblock, err := mapblockparser.Parse(block.Data, block.Mtime, pos)
if err != nil {
return nil, err
}

View File

@ -1,6 +1,11 @@
package mapblockparser
import (
"mapserver/coords"
)
type MapBlock struct {
Pos coords.MapBlockCoords `json:"pos"`
Size int `json:"size"`
Version byte `json:"version"`
Underground bool `json:"underground"`

View File

@ -3,15 +3,17 @@ package mapblockparser
import (
"errors"
"strconv"
"mapserver/coords"
)
func Parse(data []byte, mtime int64) (*MapBlock, error) {
func Parse(data []byte, mtime int64, pos coords.MapBlockCoords) (*MapBlock, error) {
if len(data) == 0 {
return nil, errors.New("no data")
}
mapblock := NewMapblock()
mapblock.Mtime = mtime
mapblock.Pos = pos
mapblock.Size = len(data)
offset := 0

View File

@ -5,6 +5,7 @@ import (
"io/ioutil"
"strconv"
"testing"
"mapserver/coords"
)
func TestReadU16(t *testing.T) {
@ -38,7 +39,7 @@ func TestParse(t *testing.T) {
t.Error(err)
}
mapblock, err := Parse(data, 0)
mapblock, err := Parse(data, 0, coords.NewMapBlockCoords(0,0,0))
if err != nil {
t.Error(err)
@ -69,7 +70,7 @@ func TestParse2(t *testing.T) {
t.Error(err)
}
mapblock, err := Parse(data, 0)
mapblock, err := Parse(data, 0, coords.NewMapBlockCoords(0,0,0))
if err != nil {
t.Error(err)
@ -87,7 +88,7 @@ func TestParse3(t *testing.T) {
t.Error(err)
}
_, err = Parse(data, 0)
_, err = Parse(data, 0, coords.NewMapBlockCoords(0,0,0))
if err != nil {
t.Error(err)