layer find cleanup

This commit is contained in:
NatureFreshMilk 2019-04-15 08:08:28 +02:00
parent 16d691abf0
commit 6583d6c3a5
2 changed files with 5 additions and 17 deletions

View File

@ -12,19 +12,13 @@ const (
func GetTileCoordsFromMapBlock(mbc *MapBlockCoords, layers []*layer.Layer) *TileCoords { func GetTileCoordsFromMapBlock(mbc *MapBlockCoords, layers []*layer.Layer) *TileCoords {
tc := TileCoords{X: mbc.X, Y: (mbc.Z + 1) * -1, Zoom: MAX_ZOOM} tc := TileCoords{X: mbc.X, Y: (mbc.Z + 1) * -1, Zoom: MAX_ZOOM}
var layerid *int currentLayer := layer.FindLayerByY(layers, mbc.Y)
for _, l := range layers {
if mbc.Y >= l.From && mbc.Y <= l.To {
layerid = &l.Id
break
}
}
if layerid == nil { if currentLayer == nil {
return nil return nil
} }
tc.LayerId = *layerid tc.LayerId = currentLayer.Id
return &tc return &tc
} }

View File

@ -50,15 +50,9 @@ func (a *MapBlockAccessor) FindMapBlocksByMtime(lastmtime int64, limit int, laye
result.LastMtime = block.Mtime result.LastMtime = block.Mtime
} }
inLayer := false currentLayer := layer.FindLayerByY(layerfilter, block.Pos.Y)
for _, l := range layerfilter {
if block.Pos.Y >= l.From && block.Pos.Y <= l.To {
inLayer = true
break
}
}
if !inLayer { if currentLayer == nil {
continue continue
} }