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