mapobjects stub

This commit is contained in:
NatureFreshMilk 2019-01-18 15:10:46 +01:00
parent 9f9e50329c
commit 0a702d240c
6 changed files with 61 additions and 14 deletions

View File

@ -30,7 +30,6 @@ func Render(tr *tilerenderer.TileRenderer,
}
logrus.WithFields(fields).Info("Starting initial render progress")
for i := 0; i < runtime.NumCPU(); i++ {
go worker(tr, jobs)
}

View File

@ -16,7 +16,7 @@ type MapBlockAccessor struct {
}
type MapBlockListener interface {
OnParsedMapBlock(block *mapblockparser.MapBlock)
OnParsedMapBlock(block *mapblockparser.MapBlock, pos coords.MapBlockCoords)
}
func getKey(pos coords.MapBlockCoords) string {
@ -55,8 +55,8 @@ func (a *MapBlockAccessor) FindLatestMapBlocks(mintime int64, limit int) ([]*map
return nil, err
}
for _, listener := range(a.listeners) {
listener.OnParsedMapBlock(mapblock)
for _, listener := range a.listeners {
listener.OnParsedMapBlock(mapblock, block.Pos)
}
a.c.Set(key, mapblock, cache.DefaultExpiration)
@ -88,8 +88,8 @@ func (a *MapBlockAccessor) GetMapBlock(pos coords.MapBlockCoords) (*mapblockpars
return nil, err
}
for _, listener := range(a.listeners) {
listener.OnParsedMapBlock(mapblock)
for _, listener := range a.listeners {
listener.OnParsedMapBlock(mapblock, pos)
}
a.c.Set(key, mapblock, cache.DefaultExpiration)

View File

@ -7,8 +7,10 @@ import (
type MapData struct {
//mapblock position
MBPos coords.MapBlockCoords
//block position
X, Y, Z int
Type string
Data string
Mtime int64
@ -23,5 +25,6 @@ type SearchQuery struct {
type DBAccessor interface {
Migrate() error
GetMapData(q SearchQuery) ([]MapData, error)
SetMapData(pos coords.MapBlockCoords, data []MapData) error
RemoveMapData(pos coords.MapBlockCoords) error
AddMapData(data MapData) error
}

18
mapobject/clearmapdata.go Normal file
View File

@ -0,0 +1,18 @@
package mapobject
import (
"mapserver/coords"
"mapserver/mapblockparser"
"mapserver/mapdb"
)
type ClearMapData struct {
db mapdb.DBAccessor
}
func (this *ClearMapData) OnParsedMapBlock(block *mapblockparser.MapBlock, pos coords.MapBlockCoords) {
err := this.db.RemoveMapData(pos)
if err != nil {
panic(err)
}
}

27
mapobject/poi.go Normal file
View File

@ -0,0 +1,27 @@
package mapobject
import (
"mapserver/coords"
"mapserver/mapblockparser"
"mapserver/mapdb"
)
type POI struct {
db mapdb.DBAccessor
}
func (this *POI) OnParsedMapBlock(block *mapblockparser.MapBlock, pos coords.MapBlockCoords) {
var found bool
for _, v := range(block.BlockMapping) {
if v == "mapserver:poi" {
found = true
break
}
}
if !found {
return
}
panic("OK") //XXX
}