diff --git a/coords/mapblockcoords.go b/coords/mapblockcoords.go index ac24fd6..c20944e 100644 --- a/coords/mapblockcoords.go +++ b/coords/mapblockcoords.go @@ -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 { diff --git a/initialrenderer/job.go b/initialrenderer/job.go index a0e9464..a9f4ec0 100644 --- a/initialrenderer/job.go +++ b/initialrenderer/job.go @@ -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 diff --git a/mapblockaccessor/mapblockaccessor.go b/mapblockaccessor/mapblockaccessor.go index 4cb7d9e..0d6be51 100644 --- a/mapblockaccessor/mapblockaccessor.go +++ b/mapblockaccessor/mapblockaccessor.go @@ -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 } diff --git a/mapblockparser/mapblock.go b/mapblockparser/mapblock.go index 57225af..6a70651 100644 --- a/mapblockparser/mapblock.go +++ b/mapblockparser/mapblock.go @@ -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"` diff --git a/mapblockparser/parse.go b/mapblockparser/parse.go index 4a384e7..655bf0f 100644 --- a/mapblockparser/parse.go +++ b/mapblockparser/parse.go @@ -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 diff --git a/mapblockparser/parse_test.go b/mapblockparser/parse_test.go index 0a3df2e..1fdfbbd 100644 --- a/mapblockparser/parse_test.go +++ b/mapblockparser/parse_test.go @@ -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)