mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-23 16:50:18 +01:00
Silence all warnings of golint not related to missing comments.
This commit is contained in:
parent
cf14aed031
commit
ea57c7c35f
@ -15,10 +15,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
createSql = "CREATE TABLE blocks (pos INT NOT NULL PRIMARY KEY, data BLOB)"
|
createSQL = "CREATE TABLE blocks (pos INT NOT NULL PRIMARY KEY, data BLOB)"
|
||||||
insertSql = "INSERT INTO blocks (pos, data) VALUES (?, ?)"
|
insertSQL = "INSERT INTO blocks (pos, data) VALUES (?, ?)"
|
||||||
deleteSql = "DELETE FROM blocks"
|
deleteSQL = "DELETE FROM blocks"
|
||||||
selectSql = "SELECT pos, data FROM blocks"
|
selectSQL = "SELECT pos, data FROM blocks"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrDatabaseNotExists = errors.New("Database does not exists.")
|
var ErrDatabaseNotExists = errors.New("Database does not exists.")
|
||||||
@ -58,19 +58,19 @@ func NewSQLiteBlockConsumer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if createNew {
|
if createNew {
|
||||||
if _, err = db.Exec(createSql); err != nil {
|
if _, err = db.Exec(createSQL); err != nil {
|
||||||
db.Close()
|
db.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if _, err = db.Exec(deleteSql); err != nil {
|
if _, err = db.Exec(deleteSQL); err != nil {
|
||||||
db.Close()
|
db.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var insertStmt *sql.Stmt
|
var insertStmt *sql.Stmt
|
||||||
if insertStmt, err = db.Prepare(insertSql); err != nil {
|
if insertStmt, err = db.Prepare(insertSQL); err != nil {
|
||||||
db.Close()
|
db.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ func NewSQLiteBlockProducer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rows *sql.Rows
|
var rows *sql.Rows
|
||||||
if rows, err = db.Query(selectSql); err != nil {
|
if rows, err = db.Query(selectSQL); err != nil {
|
||||||
db.Close()
|
db.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -123,12 +123,12 @@ func NewSqliteBackend(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SqliteBackend) buildCoverage() (err error) {
|
func (sqlb *SqliteBackend) buildCoverage() (err error) {
|
||||||
log.Println("INFO: Start building coverage index (this may take some time)...")
|
log.Println("INFO: Start building coverage index (this may take some time)...")
|
||||||
sb.coverage = common.NewCoverage3D()
|
sqlb.coverage = common.NewCoverage3D()
|
||||||
|
|
||||||
var rows *sql.Rows
|
var rows *sql.Rows
|
||||||
if rows, err = sb.keysStmt.Query(); err != nil {
|
if rows, err = sqlb.keysStmt.Query(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
@ -138,7 +138,7 @@ func (sb *SqliteBackend) buildCoverage() (err error) {
|
|||||||
if err = rows.Scan(&key); err != nil {
|
if err = rows.Scan(&key); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sb.coverage.Insert(common.PlainToCoord(key))
|
sqlb.coverage.Insert(common.PlainToCoord(key))
|
||||||
}
|
}
|
||||||
err = rows.Err()
|
err = rows.Err()
|
||||||
log.Println("INFO: Finished building coverage index.")
|
log.Println("INFO: Finished building coverage index.")
|
||||||
|
@ -53,8 +53,8 @@ type (
|
|||||||
Version byte
|
Version byte
|
||||||
Transparent bool
|
Transparent bool
|
||||||
MapContent []byte
|
MapContent []byte
|
||||||
AirId int32
|
AirID int32
|
||||||
IgnoreId int32
|
IgnoreID int32
|
||||||
IndexMap map[int32]int32
|
IndexMap map[int32]int32
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -196,7 +196,7 @@ func NewDecodedBlock(data []byte, colors *Colors) (db *DecodedBlock, err error)
|
|||||||
}
|
}
|
||||||
offset += 4
|
offset += 4
|
||||||
|
|
||||||
airId, ignoreId := int32(-1), int32(-1)
|
airID, ignoreID := int32(-1), int32(-1)
|
||||||
indexMap := make(map[int32]int32)
|
indexMap := make(map[int32]int32)
|
||||||
var transparent bool
|
var transparent bool
|
||||||
if version >= 22 {
|
if version >= 22 {
|
||||||
@ -216,7 +216,7 @@ func NewDecodedBlock(data []byte, colors *Colors) (db *DecodedBlock, err error)
|
|||||||
log.Println(outOfBounds)
|
log.Println(outOfBounds)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
nodeId := int32(binary.BigEndian.Uint16(data[offset:]))
|
nodeID := int32(binary.BigEndian.Uint16(data[offset:]))
|
||||||
offset += 2
|
offset += 2
|
||||||
if offset+1 >= dataLen {
|
if offset+1 >= dataLen {
|
||||||
log.Println(outOfBounds)
|
log.Println(outOfBounds)
|
||||||
@ -232,12 +232,12 @@ func NewDecodedBlock(data []byte, colors *Colors) (db *DecodedBlock, err error)
|
|||||||
offset += nameLen
|
offset += nameLen
|
||||||
switch name {
|
switch name {
|
||||||
case "air":
|
case "air":
|
||||||
airId = nodeId
|
airID = nodeID
|
||||||
case "ignore":
|
case "ignore":
|
||||||
ignoreId = nodeId
|
ignoreID = nodeID
|
||||||
default:
|
default:
|
||||||
if index, found := colors.NameIndex[name]; found {
|
if index, found := colors.NameIndex[name]; found {
|
||||||
indexMap[nodeId] = index
|
indexMap[nodeID] = index
|
||||||
if !transparent && colors.IsTransparent(index) {
|
if !transparent && colors.IsTransparent(index) {
|
||||||
transparent = true
|
transparent = true
|
||||||
}
|
}
|
||||||
@ -252,8 +252,8 @@ func NewDecodedBlock(data []byte, colors *Colors) (db *DecodedBlock, err error)
|
|||||||
Version: version,
|
Version: version,
|
||||||
Transparent: transparent,
|
Transparent: transparent,
|
||||||
MapContent: mapContent,
|
MapContent: mapContent,
|
||||||
AirId: airId,
|
AirID: airID,
|
||||||
IgnoreId: ignoreId,
|
IgnoreID: ignoreID,
|
||||||
IndexMap: indexMap}
|
IndexMap: indexMap}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -274,7 +274,7 @@ func logMissing(name string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (db *DecodedBlock) AirOnly() bool {
|
func (db *DecodedBlock) AirOnly() bool {
|
||||||
return db.AirId != -1 && len(db.IndexMap) == 0
|
return db.AirID != -1 && len(db.IndexMap) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DecodedBlock) Content(x, y, z int) (content int32, found bool) {
|
func (db *DecodedBlock) Content(x, y, z int) (content int32, found bool) {
|
||||||
@ -293,7 +293,7 @@ func (db *DecodedBlock) Content(x, y, z int) (content int32, found bool) {
|
|||||||
default:
|
default:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if content != db.AirId && content != db.IgnoreId {
|
if content != db.AirID && content != db.IgnoreID {
|
||||||
content, found = db.IndexMap[content]
|
content, found = db.IndexMap[content]
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -15,7 +15,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Dim transparent 2% every node.
|
// DefaultTransparentDim sets the default dimming
|
||||||
|
// factor of transparent nodes to 2%.
|
||||||
const DefaultTransparentDim = 2.0 / 100.0
|
const DefaultTransparentDim = 2.0 / 100.0
|
||||||
|
|
||||||
type Colors struct {
|
type Colors struct {
|
||||||
|
@ -271,34 +271,34 @@ func unsetbits(p uint8, v int64) int64 {
|
|||||||
|
|
||||||
func BigMin(minz, maxz, zcode int64) int64 {
|
func BigMin(minz, maxz, zcode int64) int64 {
|
||||||
const (
|
const (
|
||||||
_001_ = 1
|
b001 = 1
|
||||||
_010_ = 2
|
b010 = 2
|
||||||
_011_ = 2 | 1
|
b011 = 2 | 1
|
||||||
_100_ = 4
|
b100 = 4
|
||||||
_101_ = 4 | 1
|
b101 = 4 | 1
|
||||||
)
|
)
|
||||||
bigmin := maxz
|
bigmin := maxz
|
||||||
pos := msb
|
pos := msb
|
||||||
for m := int64(1) << msb; m != 0; m >>= 1 {
|
for m := int64(1) << msb; m != 0; m >>= 1 {
|
||||||
var v uint8
|
var v uint8
|
||||||
if zcode&m == m {
|
if zcode&m == m {
|
||||||
v = _100_
|
v = b100
|
||||||
}
|
}
|
||||||
if minz&m == m {
|
if minz&m == m {
|
||||||
v |= _010_
|
v |= b010
|
||||||
}
|
}
|
||||||
if maxz&m == m {
|
if maxz&m == m {
|
||||||
v |= _001_
|
v |= b001
|
||||||
}
|
}
|
||||||
switch v {
|
switch v {
|
||||||
case _001_:
|
case b001:
|
||||||
bigmin = unsetbits(pos, minz)
|
bigmin = unsetbits(pos, minz)
|
||||||
maxz = setbits(pos, maxz)
|
maxz = setbits(pos, maxz)
|
||||||
case _011_:
|
case b011:
|
||||||
return minz
|
return minz
|
||||||
case _100_:
|
case b100:
|
||||||
return bigmin
|
return bigmin
|
||||||
case _101_:
|
case b101:
|
||||||
minz = unsetbits(pos, minz)
|
minz = unsetbits(pos, minz)
|
||||||
}
|
}
|
||||||
pos--
|
pos--
|
||||||
|
@ -292,8 +292,9 @@ func areasContain(areas []Area, x, z int16) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Greedy algorithm to figure out a list of disjunct areas
|
// UncoveredAreas implements a greedy algorithm to figure out
|
||||||
// of free regions in the domain to the (x, z) block plane.
|
// a list of disjunct areas of free regions in the domain
|
||||||
|
// to the (x, z) block plane.
|
||||||
// oldAreas are searched and found free areas are appended
|
// oldAreas are searched and found free areas are appended
|
||||||
// to newAreas which ist return.
|
// to newAreas which ist return.
|
||||||
// This is useful to spatial query only blocks from db
|
// This is useful to spatial query only blocks from db
|
||||||
|
Loading…
Reference in New Issue
Block a user