mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-10 17:00:18 +01:00
cmd/mtredisalize/leveldb.go
This commit is contained in:
parent
5442fab97d
commit
7f69467f26
@ -44,7 +44,8 @@ func NewRedisParser(reader *bufio.Reader,
|
||||
}
|
||||
|
||||
func (rp *RedisParser) Parse() {
|
||||
for line := rp.nextLine(); line != nil && rp.dispatch(line); line = rp.nextLine() {
|
||||
for line := rp.nextLine(); line != nil && rp.dispatch(line); {
|
||||
line = rp.nextLine()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ func (ss *SQLiteSession) txStmt(stmt *sql.Stmt) *sql.Stmt {
|
||||
return stmt
|
||||
}
|
||||
|
||||
func (ss *SQLiteSession) Del(hash, key []byte) (success bool, err error) {
|
||||
func (ss *SQLiteSession) Del(_, key []byte) (success bool, err error) {
|
||||
var pos int64
|
||||
if pos, err = ss.backend.decoder(key); err != nil {
|
||||
return
|
||||
@ -226,7 +226,7 @@ func (ss *SQLiteSession) Del(hash, key []byte) (success bool, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (ss *SQLiteSession) Fetch(hash, key []byte) (data []byte, err error) {
|
||||
func (ss *SQLiteSession) Fetch(_, key []byte) (data []byte, err error) {
|
||||
var pos int64
|
||||
if pos, err = ss.backend.decoder(key); err != nil {
|
||||
return
|
||||
@ -248,7 +248,7 @@ func (ss *SQLiteSession) InTransaction() bool {
|
||||
return ss.tx != nil
|
||||
}
|
||||
|
||||
func (ss *SQLiteSession) Store(hash, key, value []byte) (exists bool, err error) {
|
||||
func (ss *SQLiteSession) Store(_, key, value []byte) (exists bool, err error) {
|
||||
var pos int64
|
||||
if pos, err = ss.backend.decoder(key); err != nil {
|
||||
return
|
||||
@ -322,7 +322,7 @@ func (ss *SQLiteSession) CommitTransaction() error {
|
||||
}
|
||||
|
||||
func (ss *SQLiteSession) AllKeys(
|
||||
hash []byte,
|
||||
_ []byte,
|
||||
done <-chan struct{}) (<-chan []byte, int, error) {
|
||||
globalLock.RLock()
|
||||
|
||||
@ -373,7 +373,7 @@ func (ss *SQLiteSession) AllKeys(
|
||||
}
|
||||
|
||||
func (ss *SQLiteSession) SpatialQuery(
|
||||
hash, first, second []byte,
|
||||
_, first, second []byte,
|
||||
done <-chan struct{}) (<-chan Block, error) {
|
||||
|
||||
if ss.backend.interleaved {
|
||||
|
@ -177,7 +177,7 @@ func (ps *players) initConnection(wsf *websocketForwarder, c *connection) {
|
||||
wsf.singleSend(c, &plsMsg{Pls: ps.current()})
|
||||
}
|
||||
|
||||
func (ps *players) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
func (ps *players) ServeHTTP(rw http.ResponseWriter, _ *http.Request) {
|
||||
rw.Header().Set("Content-Type", "application/json")
|
||||
pls := ps.current()
|
||||
encoder := json.NewEncoder(rw)
|
||||
|
@ -37,7 +37,7 @@ func areasContain(areas []Area, x, z int16) bool {
|
||||
// to newAreas which ist return.
|
||||
// This is useful to spatial query only blocks from db
|
||||
// that are not below already rendered blocks.
|
||||
func (area Area) recalculate(r *Renderer, nareas []Area) []Area {
|
||||
func (a Area) recalculate(r *Renderer, nareas []Area) []Area {
|
||||
yM := r.yMin
|
||||
|
||||
const ex = 1
|
||||
@ -45,28 +45,28 @@ func (area Area) recalculate(r *Renderer, nareas []Area) []Area {
|
||||
|
||||
nas := len(nareas)
|
||||
|
||||
for z := area.Z1; z <= area.Z2; z++ {
|
||||
for z := a.Z1; z <= a.Z2; z++ {
|
||||
row := z * int16(r.width)
|
||||
for x := area.X1; x <= area.X2; x++ {
|
||||
for x := a.X1; x <= a.X2; x++ {
|
||||
// Uncovered and not in list of new areas?
|
||||
if yM[row+x] > math.MinInt32 || areasContain(nareas[nas:], x, z) {
|
||||
continue
|
||||
}
|
||||
a := Area{X1: x, Z1: z, X2: x, Z2: z}
|
||||
ar := Area{X1: x, Z1: z, X2: x, Z2: z}
|
||||
// Try to extend the area in x and/or z till no further extension is possible.
|
||||
ext:
|
||||
for extend := ex | ez; extend != 0; {
|
||||
// If we extending in both directions a the current area
|
||||
// is higher than wide we gain more block if extend
|
||||
// in the x direction first.
|
||||
if (extend == ex|ez && a.higher()) || extend&ex == ex { // check x
|
||||
nx := a.X2 + 1
|
||||
if nx > area.X2 { // reached border of area
|
||||
if (extend == ex|ez && ar.higher()) || extend&ex == ex { // check x
|
||||
nx := ar.X2 + 1
|
||||
if nx > a.X2 { // reached border of area
|
||||
extend &= ^ex
|
||||
continue
|
||||
}
|
||||
// Check column right of the current area if its fully free.
|
||||
for nz := a.Z1; nz <= a.Z2; nz++ {
|
||||
for nz := ar.Z1; nz <= ar.Z2; nz++ {
|
||||
if yM[nz*int16(r.width)+nx] > math.MinInt32 ||
|
||||
areasContain(nareas[nas:], nx, nz) {
|
||||
extend &= ^ex
|
||||
@ -74,16 +74,16 @@ func (area Area) recalculate(r *Renderer, nareas []Area) []Area {
|
||||
}
|
||||
}
|
||||
// free -> extend
|
||||
a.X2 = nx
|
||||
ar.X2 = nx
|
||||
} else if extend&ez == ez { // check z
|
||||
nz := a.Z2 + 1
|
||||
if nz > area.Z2 {
|
||||
nz := ar.Z2 + 1
|
||||
if nz > a.Z2 {
|
||||
extend &= ^ez
|
||||
continue
|
||||
}
|
||||
// Check line right below the current area if its free.
|
||||
row2 := nz * int16(r.width)
|
||||
for nx := a.X1; nx <= a.X2; nx++ {
|
||||
for nx := ar.X1; nx <= ar.X2; nx++ {
|
||||
if yM[row2+nx] > math.MinInt32 ||
|
||||
areasContain(nareas[nas:], nx, nz) {
|
||||
extend &= ^ez
|
||||
@ -91,11 +91,11 @@ func (area Area) recalculate(r *Renderer, nareas []Area) []Area {
|
||||
}
|
||||
}
|
||||
// free -> extend
|
||||
a.Z2 = nz
|
||||
ar.Z2 = nz
|
||||
}
|
||||
}
|
||||
// At this point the area is extended to max.
|
||||
nareas = append(nareas, a)
|
||||
nareas = append(nareas, ar)
|
||||
}
|
||||
}
|
||||
return nareas
|
||||
|
@ -109,7 +109,8 @@ func BlendColor(c1, c2 color.RGBA, a float32) color.RGBA {
|
||||
func (colors *Colors) BlendColors(span *Span, col color.RGBA, pos int32) color.RGBA {
|
||||
curr := span
|
||||
// Ignore colors below pos.
|
||||
for ; curr != nil && pos >= curr.To; curr = curr.Next {
|
||||
for curr != nil && pos >= curr.To {
|
||||
curr = curr.Next
|
||||
}
|
||||
if curr == nil {
|
||||
return col
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
_ "github.com/jackc/pgx/v4/stdlib"
|
||||
_ "github.com/jackc/pgx/v4/stdlib" // link PostgreSQL driver
|
||||
)
|
||||
|
||||
const queryCuboidSQL = `
|
||||
|
@ -137,7 +137,8 @@ func (s *Span) Len() int {
|
||||
}
|
||||
|
||||
func (s *Span) Top() int32 {
|
||||
for ; s.Next != nil; s = s.Next {
|
||||
for s.Next != nil {
|
||||
s = s.Next
|
||||
}
|
||||
return s.To
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user