mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 01:10:17 +01:00
Simplified tiles update processing and forwarding.
This commit is contained in:
parent
b59f849d73
commit
da2a6a82d4
@ -27,7 +27,7 @@ type connection struct {
|
||||
}
|
||||
|
||||
type msg struct {
|
||||
tiles map[xz]bool
|
||||
tiles []xz
|
||||
pls []*player
|
||||
}
|
||||
|
||||
@ -57,12 +57,8 @@ func (wsf *websocketForwarder) run() {
|
||||
}
|
||||
encMsg := map[string]interface{}{}
|
||||
|
||||
if tiles := message.tiles; tiles != nil {
|
||||
xzs := make([]xz, 0, len(tiles))
|
||||
for xz := range tiles {
|
||||
xzs = append(xzs, xz)
|
||||
}
|
||||
encMsg["tiles"] = xzs
|
||||
if message.tiles != nil {
|
||||
encMsg["tiles"] = message.tiles
|
||||
}
|
||||
|
||||
if message.pls != nil {
|
||||
@ -101,7 +97,7 @@ func (wsf *websocketForwarder) ServeHTTP(rw http.ResponseWriter, r *http.Request
|
||||
c.reader()
|
||||
}
|
||||
|
||||
func (wsf *websocketForwarder) BaseTilesUpdated(changes map[xz]bool) {
|
||||
func (wsf *websocketForwarder) BaseTilesUpdated(changes []xz) {
|
||||
wsf.broadcast <- msg{tiles: changes}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
)
|
||||
|
||||
type baseTilesUpdates interface {
|
||||
BaseTilesUpdated(map[xz]bool)
|
||||
BaseTilesUpdated([]xz)
|
||||
}
|
||||
|
||||
type tileUpdater struct {
|
||||
@ -165,11 +165,11 @@ func extractChanges(changes map[xz]bool) []xzc {
|
||||
return chs
|
||||
}
|
||||
|
||||
func activeChanges(changes []xzc) map[xz]bool {
|
||||
chs := make(map[xz]bool)
|
||||
func activeChanges(changes []xzc) []xz {
|
||||
chs := make([]xz, 0, len(changes))
|
||||
for i := range changes {
|
||||
if !changes[i].canceled {
|
||||
chs[changes[i].xz] = true
|
||||
chs = append(chs, changes[i].xz)
|
||||
}
|
||||
}
|
||||
return chs
|
||||
@ -222,8 +222,8 @@ func (tu *tileUpdater) doUpdates() {
|
||||
}
|
||||
|
||||
parentJobs := make(map[xz]uint16)
|
||||
for c := range actChs {
|
||||
pxz := c.parent()
|
||||
for i := range actChs {
|
||||
pxz := actChs[i].parent()
|
||||
parentJobs[pxz.P] |= pxz.Mask
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user