forked from MTSR/mapserver
pointer rulez
This commit is contained in:
parent
f6979d18c1
commit
fced5f03d2
@ -9,7 +9,7 @@ const (
|
|||||||
maxValue = 1<<(numBitsPerComponent-1) - 1
|
maxValue = 1<<(numBitsPerComponent-1) - 1
|
||||||
)
|
)
|
||||||
|
|
||||||
func CoordToPlain(c MapBlockCoords) int64 {
|
func CoordToPlain(c *MapBlockCoords) int64 {
|
||||||
return int64(c.Z)<<(2*numBitsPerComponent) +
|
return int64(c.Z)<<(2*numBitsPerComponent) +
|
||||||
int64(c.Y)<<numBitsPerComponent +
|
int64(c.Y)<<numBitsPerComponent +
|
||||||
int64(c.X)
|
int64(c.X)
|
||||||
@ -31,12 +31,12 @@ func pythonModulo(i int16) int16 {
|
|||||||
return modulo - -i&mask
|
return modulo - -i&mask
|
||||||
}
|
}
|
||||||
|
|
||||||
func PlainToCoord(i int64) MapBlockCoords {
|
func PlainToCoord(i int64) *MapBlockCoords {
|
||||||
c := MapBlockCoords{}
|
c := MapBlockCoords{}
|
||||||
c.X = unsignedToSigned(pythonModulo(int16(i)))
|
c.X = unsignedToSigned(pythonModulo(int16(i)))
|
||||||
i = (i - int64(c.X)) >> numBitsPerComponent
|
i = (i - int64(c.X)) >> numBitsPerComponent
|
||||||
c.Y = unsignedToSigned(pythonModulo(int16(i)))
|
c.Y = unsignedToSigned(pythonModulo(int16(i)))
|
||||||
i = (i - int64(c.Y)) >> numBitsPerComponent
|
i = (i - int64(c.Y)) >> numBitsPerComponent
|
||||||
c.Z = unsignedToSigned(pythonModulo(int16(i)))
|
c.Z = unsignedToSigned(pythonModulo(int16(i)))
|
||||||
return c
|
return &c
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ func init() {
|
|||||||
log = logrus.WithFields(logrus.Fields{"prefix": "coords/convert_test"})
|
log = logrus.WithFields(logrus.Fields{"prefix": "coords/convert_test"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCoordConvert(t *testing.T, mb MapBlockCoords) {
|
func testCoordConvert(t *testing.T, mb *MapBlockCoords) {
|
||||||
log.WithFields(logrus.Fields{"coords": mb}).Info("MapblockCoords")
|
log.WithFields(logrus.Fields{"coords": mb}).Info("MapblockCoords")
|
||||||
|
|
||||||
p := CoordToPlain(mb)
|
p := CoordToPlain(mb)
|
||||||
|
@ -6,12 +6,12 @@ type MapBlockCoords struct {
|
|||||||
Z int `json:"z"`
|
Z int `json:"z"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMapBlockCoords(x, y, z int) MapBlockCoords {
|
func NewMapBlockCoords(x, y, z int) *MapBlockCoords {
|
||||||
return MapBlockCoords{X: x, Y: y, Z: z}
|
return &MapBlockCoords{X: x, Y: y, Z: z}
|
||||||
}
|
}
|
||||||
|
|
||||||
type MapBlockRange struct {
|
type MapBlockRange struct {
|
||||||
Pos1, Pos2 MapBlockCoords
|
Pos1, Pos2 *MapBlockCoords
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -9,7 +9,7 @@ const (
|
|||||||
MAX_ZOOM = 13
|
MAX_ZOOM = 13
|
||||||
)
|
)
|
||||||
|
|
||||||
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
|
var layerid *int
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Block struct {
|
type Block struct {
|
||||||
Pos coords.MapBlockCoords
|
Pos *coords.MapBlockCoords
|
||||||
Data []byte
|
Data []byte
|
||||||
Mtime int64
|
Mtime int64
|
||||||
}
|
}
|
||||||
@ -13,9 +13,9 @@ type Block struct {
|
|||||||
type DBAccessor interface {
|
type DBAccessor interface {
|
||||||
Migrate() error
|
Migrate() error
|
||||||
|
|
||||||
FindBlocksByMtime(gtmtime int64, limit int) ([]Block, error)
|
FindBlocksByMtime(gtmtime int64, limit int) ([]*Block, error)
|
||||||
FindLegacyBlocksByPos(lastpos coords.MapBlockCoords, limit int) ([]Block, error)
|
FindLegacyBlocksByPos(lastpos *coords.MapBlockCoords, limit int) ([]*Block, error)
|
||||||
|
|
||||||
CountBlocks(frommtime, tomtime int64) (int, error)
|
CountBlocks(frommtime, tomtime int64) (int, error)
|
||||||
GetBlock(pos coords.MapBlockCoords) (*Block, error)
|
GetBlock(pos *coords.MapBlockCoords) (*Block, error)
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,14 @@ func (db *PostgresAccessor) Migrate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertRows(pos int64, data []byte, mtime int64) db.Block {
|
func convertRows(pos int64, data []byte, mtime int64) *db.Block {
|
||||||
c := coords.PlainToCoord(pos)
|
c := coords.PlainToCoord(pos)
|
||||||
return db.Block{Pos: c, Data: data, Mtime: mtime}
|
return &db.Block{Pos: c, Data: data, Mtime: mtime}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (this *PostgresAccessor) FindBlocksByMtime(gtmtime int64, limit int) ([]db.Block, error) {
|
func (this *PostgresAccessor) FindBlocksByMtime(gtmtime int64, limit int) ([]*db.Block, error) {
|
||||||
blocks := make([]db.Block, 0)
|
blocks := make([]*db.Block, 0)
|
||||||
|
|
||||||
rows, err := this.db.Query(getBlocksByMtimeQuery, gtmtime, limit)
|
rows, err := this.db.Query(getBlocksByMtimeQuery, gtmtime, limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -49,8 +49,8 @@ func (this *PostgresAccessor) FindBlocksByMtime(gtmtime int64, limit int) ([]db.
|
|||||||
return blocks, nil
|
return blocks, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *PostgresAccessor) FindLegacyBlocksByPos(lastpos coords.MapBlockCoords, limit int) ([]db.Block, error) {
|
func (this *PostgresAccessor) FindLegacyBlocksByPos(lastpos *coords.MapBlockCoords, limit int) ([]*db.Block, error) {
|
||||||
blocks := make([]db.Block, 0)
|
blocks := make([]*db.Block, 0)
|
||||||
pc := coords.CoordToPlain(lastpos)
|
pc := coords.CoordToPlain(lastpos)
|
||||||
|
|
||||||
rows, err := this.db.Query(getLastBlockQuery, pc, limit)
|
rows, err := this.db.Query(getLastBlockQuery, pc, limit)
|
||||||
@ -101,7 +101,7 @@ func (this *PostgresAccessor) CountBlocks(frommtime, tomtime int64) (int, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (this *PostgresAccessor) GetBlock(pos coords.MapBlockCoords) (*db.Block, error) {
|
func (this *PostgresAccessor) GetBlock(pos *coords.MapBlockCoords) (*db.Block, error) {
|
||||||
ppos := coords.CoordToPlain(pos)
|
ppos := coords.CoordToPlain(pos)
|
||||||
|
|
||||||
rows, err := this.db.Query(getBlockQuery, ppos)
|
rows, err := this.db.Query(getBlockQuery, ppos)
|
||||||
@ -122,7 +122,7 @@ func (this *PostgresAccessor) GetBlock(pos coords.MapBlockCoords) (*db.Block, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
mb := convertRows(pos, data, mtime)
|
mb := convertRows(pos, data, mtime)
|
||||||
return &mb, nil
|
return mb, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -50,14 +50,14 @@ func (db *Sqlite3Accessor) Migrate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertRows(pos int64, data []byte, mtime int64) db.Block {
|
func convertRows(pos int64, data []byte, mtime int64) *db.Block {
|
||||||
c := coords.PlainToCoord(pos)
|
c := coords.PlainToCoord(pos)
|
||||||
return db.Block{Pos: c, Data: data, Mtime: mtime}
|
return &db.Block{Pos: c, Data: data, Mtime: mtime}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (this *Sqlite3Accessor) FindBlocksByMtime(gtmtime int64, limit int) ([]db.Block, error) {
|
func (this *Sqlite3Accessor) FindBlocksByMtime(gtmtime int64, limit int) ([]*db.Block, error) {
|
||||||
blocks := make([]db.Block, 0)
|
blocks := make([]*db.Block, 0)
|
||||||
|
|
||||||
rows, err := this.db.Query(getBlocksByMtimeQuery, gtmtime, limit)
|
rows, err := this.db.Query(getBlocksByMtimeQuery, gtmtime, limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -84,8 +84,8 @@ func (this *Sqlite3Accessor) FindBlocksByMtime(gtmtime int64, limit int) ([]db.B
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (this *Sqlite3Accessor) FindLegacyBlocksByPos(lastpos coords.MapBlockCoords, limit int) ([]db.Block, error) {
|
func (this *Sqlite3Accessor) FindLegacyBlocksByPos(lastpos *coords.MapBlockCoords, limit int) ([]*db.Block, error) {
|
||||||
blocks := make([]db.Block, 0)
|
blocks := make([]*db.Block, 0)
|
||||||
pc := coords.CoordToPlain(lastpos)
|
pc := coords.CoordToPlain(lastpos)
|
||||||
|
|
||||||
rows, err := this.db.Query(getLastBlockQuery, pc, limit)
|
rows, err := this.db.Query(getLastBlockQuery, pc, limit)
|
||||||
@ -136,7 +136,7 @@ func (db *Sqlite3Accessor) CountBlocks(frommtime, tomtime int64) (int, error) {
|
|||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Sqlite3Accessor) GetBlock(pos coords.MapBlockCoords) (*db.Block, error) {
|
func (db *Sqlite3Accessor) GetBlock(pos *coords.MapBlockCoords) (*db.Block, error) {
|
||||||
ppos := coords.CoordToPlain(pos)
|
ppos := coords.CoordToPlain(pos)
|
||||||
|
|
||||||
rows, err := db.db.Query(getBlockQuery, ppos)
|
rows, err := db.db.Query(getBlockQuery, ppos)
|
||||||
@ -157,7 +157,7 @@ func (db *Sqlite3Accessor) GetBlock(pos coords.MapBlockCoords) (*db.Block, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
mb := convertRows(pos, data, mtime)
|
mb := convertRows(pos, data, mtime)
|
||||||
return &mb, nil
|
return mb, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -20,7 +20,7 @@ type MapBlockAccessor struct {
|
|||||||
Eventbus *eventbus.Eventbus
|
Eventbus *eventbus.Eventbus
|
||||||
}
|
}
|
||||||
|
|
||||||
func getKey(pos coords.MapBlockCoords) string {
|
func getKey(pos *coords.MapBlockCoords) string {
|
||||||
return fmt.Sprintf("Coord %d/%d/%d", pos.X, pos.Y, pos.Z)
|
return fmt.Sprintf("Coord %d/%d/%d", pos.X, pos.Y, pos.Z)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ func NewMapBlockAccessor(accessor db.DBAccessor) *MapBlockAccessor {
|
|||||||
Eventbus: eventbus.New(),
|
Eventbus: eventbus.New(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (a *MapBlockAccessor) Update(pos coords.MapBlockCoords, mb *mapblockparser.MapBlock) {
|
func (a *MapBlockAccessor) Update(pos *coords.MapBlockCoords, mb *mapblockparser.MapBlock) {
|
||||||
key := getKey(pos)
|
key := getKey(pos)
|
||||||
a.c.Set(key, mb, cache.DefaultExpiration)
|
a.c.Set(key, mb, cache.DefaultExpiration)
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ func (a *MapBlockAccessor) FindMapBlocksByMtime(lastmtime int64, limit int, laye
|
|||||||
result.UnfilteredCount = len(blocks)
|
result.UnfilteredCount = len(blocks)
|
||||||
|
|
||||||
for _, block := range blocks {
|
for _, block := range blocks {
|
||||||
newlastpos = &block.Pos
|
newlastpos = block.Pos
|
||||||
if result.LastMtime < block.Mtime {
|
if result.LastMtime < block.Mtime {
|
||||||
result.LastMtime = block.Mtime
|
result.LastMtime = block.Mtime
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ func (a *MapBlockAccessor) FindMapBlocksByMtime(lastmtime int64, limit int, laye
|
|||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *MapBlockAccessor) FindMapBlocksByPos(lastpos coords.MapBlockCoords, limit int, layerfilter []layer.Layer) (*FindMapBlocksResult, error) {
|
func (a *MapBlockAccessor) FindMapBlocksByPos(lastpos *coords.MapBlockCoords, limit int, layerfilter []layer.Layer) (*FindMapBlocksResult, error) {
|
||||||
|
|
||||||
fields := logrus.Fields{
|
fields := logrus.Fields{
|
||||||
"x": lastpos.X,
|
"x": lastpos.X,
|
||||||
@ -136,7 +136,7 @@ func (a *MapBlockAccessor) FindMapBlocksByPos(lastpos coords.MapBlockCoords, lim
|
|||||||
result.UnfilteredCount = len(blocks)
|
result.UnfilteredCount = len(blocks)
|
||||||
|
|
||||||
for _, block := range blocks {
|
for _, block := range blocks {
|
||||||
newlastpos = &block.Pos
|
newlastpos = block.Pos
|
||||||
if result.LastMtime < block.Mtime {
|
if result.LastMtime < block.Mtime {
|
||||||
result.LastMtime = block.Mtime
|
result.LastMtime = block.Mtime
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ func (a *MapBlockAccessor) FindMapBlocksByPos(lastpos coords.MapBlockCoords, lim
|
|||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *MapBlockAccessor) GetMapBlock(pos coords.MapBlockCoords) (*mapblockparser.MapBlock, error) {
|
func (a *MapBlockAccessor) GetMapBlock(pos *coords.MapBlockCoords) (*mapblockparser.MapBlock, error) {
|
||||||
key := getKey(pos)
|
key := getKey(pos)
|
||||||
|
|
||||||
cachedblock, found := a.c.Get(key)
|
cachedblock, found := a.c.Get(key)
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MapBlock struct {
|
type MapBlock struct {
|
||||||
Pos coords.MapBlockCoords `json:"pos"`
|
Pos *coords.MapBlockCoords `json:"pos"`
|
||||||
Size int `json:"size"`
|
Size int `json:"size"`
|
||||||
Version byte `json:"version"`
|
Version byte `json:"version"`
|
||||||
Underground bool `json:"underground"`
|
Underground bool `json:"underground"`
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Parse(data []byte, mtime int64, pos coords.MapBlockCoords) (*MapBlock, error) {
|
func Parse(data []byte, mtime int64, pos *coords.MapBlockCoords) (*MapBlock, error) {
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
return nil, errors.New("no data")
|
return nil, errors.New("no data")
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ func addColorComponent(c *color.RGBA, value int) *color.RGBA {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *MapBlockRenderer) Render(pos1, pos2 coords.MapBlockCoords) (*image.NRGBA, error) {
|
func (r *MapBlockRenderer) Render(pos1, pos2 *coords.MapBlockCoords) (*image.NRGBA, error) {
|
||||||
if pos1.X != pos2.X {
|
if pos1.X != pos2.X {
|
||||||
return nil, errors.New("X does not line up")
|
return nil, errors.New("X does not line up")
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type JobData struct {
|
type JobData struct {
|
||||||
Pos1, Pos2 coords.MapBlockCoords
|
Pos1, Pos2 *coords.MapBlockCoords
|
||||||
}
|
}
|
||||||
|
|
||||||
type JobResult struct {
|
type JobResult struct {
|
||||||
|
@ -14,7 +14,7 @@ func (this *BonesBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "bones")
|
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "bones")
|
||||||
o.Attributes["time"] = md["time"]
|
o.Attributes["time"] = md["time"]
|
||||||
o.Attributes["owner"] = md["owner"]
|
o.Attributes["owner"] = md["owner"]
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ type DigilineLcdBlock struct{}
|
|||||||
func (this *DigilineLcdBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
func (this *DigilineLcdBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
||||||
md := block.Metadata.GetMetadata(x, y, z)
|
md := block.Metadata.GetMetadata(x, y, z)
|
||||||
|
|
||||||
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "digilinelcd")
|
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "digilinelcd")
|
||||||
o.Attributes["text"] = md["text"]
|
o.Attributes["text"] = md["text"]
|
||||||
o.Attributes["channel"] = md["channel"]
|
o.Attributes["channel"] = md["channel"]
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ type JumpdriveBlock struct{}
|
|||||||
func (this *JumpdriveBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
func (this *JumpdriveBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
||||||
md := block.Metadata.GetMetadata(x, y, z)
|
md := block.Metadata.GetMetadata(x, y, z)
|
||||||
|
|
||||||
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "jumpdrive")
|
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "jumpdrive")
|
||||||
o.Attributes["owner"] = md["owner"]
|
o.Attributes["owner"] = md["owner"]
|
||||||
o.Attributes["radius"] = md["radius"]
|
o.Attributes["radius"] = md["radius"]
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ type MissionBlock struct{}
|
|||||||
func (this *MissionBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
func (this *MissionBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
||||||
md := block.Metadata.GetMetadata(x, y, z)
|
md := block.Metadata.GetMetadata(x, y, z)
|
||||||
|
|
||||||
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "mission")
|
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "mission")
|
||||||
o.Attributes["name"] = md["name"]
|
o.Attributes["name"] = md["name"]
|
||||||
o.Attributes["time"] = md["time"]
|
o.Attributes["time"] = md["time"]
|
||||||
o.Attributes["owner"] = md["owner"]
|
o.Attributes["owner"] = md["owner"]
|
||||||
|
@ -10,7 +10,7 @@ type NuclearReactorBlock struct{}
|
|||||||
func (this *NuclearReactorBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
func (this *NuclearReactorBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
||||||
md := block.Metadata.GetMetadata(x, y, z)
|
md := block.Metadata.GetMetadata(x, y, z)
|
||||||
|
|
||||||
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "nuclearreactor")
|
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "nuclearreactor")
|
||||||
o.Attributes["burn_time"] = md["burn_time"]
|
o.Attributes["burn_time"] = md["burn_time"]
|
||||||
o.Attributes["structure_accumulated_badness"] = md["structure_accumulated_badness"]
|
o.Attributes["structure_accumulated_badness"] = md["structure_accumulated_badness"]
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ type PoiBlock struct{}
|
|||||||
func (this *PoiBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
func (this *PoiBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
||||||
md := block.Metadata.GetMetadata(x, y, z)
|
md := block.Metadata.GetMetadata(x, y, z)
|
||||||
|
|
||||||
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "poi")
|
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "poi")
|
||||||
o.Attributes["name"] = md["name"]
|
o.Attributes["name"] = md["name"]
|
||||||
o.Attributes["category"] = md["category"]
|
o.Attributes["category"] = md["category"]
|
||||||
o.Attributes["url"] = md["url"]
|
o.Attributes["url"] = md["url"]
|
||||||
|
@ -10,7 +10,7 @@ type ProtectorBlock struct{}
|
|||||||
func (this *ProtectorBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
func (this *ProtectorBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
||||||
md := block.Metadata.GetMetadata(x, y, z)
|
md := block.Metadata.GetMetadata(x, y, z)
|
||||||
|
|
||||||
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "protector")
|
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "protector")
|
||||||
o.Attributes["owner"] = md["owner"]
|
o.Attributes["owner"] = md["owner"]
|
||||||
|
|
||||||
return o
|
return o
|
||||||
|
@ -14,7 +14,7 @@ func (this *QuarryBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "technicquarry")
|
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "technicquarry")
|
||||||
o.Attributes["owner"] = md["owner"]
|
o.Attributes["owner"] = md["owner"]
|
||||||
o.Attributes["dug"] = md["dug"]
|
o.Attributes["dug"] = md["dug"]
|
||||||
o.Attributes["enabled"] = md["enabled"]
|
o.Attributes["enabled"] = md["enabled"]
|
||||||
|
@ -27,7 +27,7 @@ func (this *Listener) OnEvent(eventtype string, o interface{}) {
|
|||||||
|
|
||||||
block := o.(*mapblockparser.MapBlock)
|
block := o.(*mapblockparser.MapBlock)
|
||||||
|
|
||||||
err := this.ctx.Objectdb.RemoveMapData(&block.Pos)
|
err := this.ctx.Objectdb.RemoveMapData(block.Pos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ type TechnicAnchorBlock struct{}
|
|||||||
func (this *TechnicAnchorBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
func (this *TechnicAnchorBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
||||||
md := block.Metadata.GetMetadata(x, y, z)
|
md := block.Metadata.GetMetadata(x, y, z)
|
||||||
|
|
||||||
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "technicanchor")
|
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "technicanchor")
|
||||||
o.Attributes["owner"] = md["owner"]
|
o.Attributes["owner"] = md["owner"]
|
||||||
o.Attributes["radius"] = md["radius"]
|
o.Attributes["radius"] = md["radius"]
|
||||||
o.Attributes["locked"] = md["locked"]
|
o.Attributes["locked"] = md["locked"]
|
||||||
|
@ -10,7 +10,7 @@ type TrainBlock struct{}
|
|||||||
func (this *TrainBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
func (this *TrainBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
||||||
md := block.Metadata.GetMetadata(x, y, z)
|
md := block.Metadata.GetMetadata(x, y, z)
|
||||||
|
|
||||||
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "train")
|
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "train")
|
||||||
o.Attributes["station"] = md["station"]
|
o.Attributes["station"] = md["station"]
|
||||||
o.Attributes["line"] = md["line"]
|
o.Attributes["line"] = md["line"]
|
||||||
o.Attributes["index"] = md["index"]
|
o.Attributes["index"] = md["index"]
|
||||||
|
@ -10,7 +10,7 @@ type TravelnetBlock struct{}
|
|||||||
func (this *TravelnetBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
func (this *TravelnetBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
||||||
md := block.Metadata.GetMetadata(x, y, z)
|
md := block.Metadata.GetMetadata(x, y, z)
|
||||||
|
|
||||||
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "travelnet")
|
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "travelnet")
|
||||||
o.Attributes["owner"] = md["owner"]
|
o.Attributes["owner"] = md["owner"]
|
||||||
o.Attributes["station_name"] = md["station_name"]
|
o.Attributes["station_name"] = md["station_name"]
|
||||||
o.Attributes["station_network"] = md["station_network"]
|
o.Attributes["station_network"] = md["station_network"]
|
||||||
|
@ -10,7 +10,7 @@ type XPProtectorBlock struct{}
|
|||||||
func (this *XPProtectorBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
func (this *XPProtectorBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject {
|
||||||
md := block.Metadata.GetMetadata(x, y, z)
|
md := block.Metadata.GetMetadata(x, y, z)
|
||||||
|
|
||||||
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "xpprotector")
|
o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "xpprotector")
|
||||||
o.Attributes["owner"] = md["owner"]
|
o.Attributes["owner"] = md["owner"]
|
||||||
o.Attributes["xpthreshold"] = md["xpthreshold"]
|
o.Attributes["xpthreshold"] = md["xpthreshold"]
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ func NewMapObject(MBPos *coords.MapBlockCoords, x int, y int, z int, _type strin
|
|||||||
|
|
||||||
type SearchQuery struct {
|
type SearchQuery struct {
|
||||||
//mapblock position
|
//mapblock position
|
||||||
Pos1 coords.MapBlockCoords `json:"pos1"`
|
Pos1 *coords.MapBlockCoords `json:"pos1"`
|
||||||
Pos2 coords.MapBlockCoords `json:"pos2"`
|
Pos2 *coords.MapBlockCoords `json:"pos2"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ func TestNewMapBlockCoords(t *testing.T) {
|
|||||||
pos := coords.NewMapBlockCoords(1, 2, 3)
|
pos := coords.NewMapBlockCoords(1, 2, 3)
|
||||||
fmt.Println(pos)
|
fmt.Println(pos)
|
||||||
|
|
||||||
obj := NewMapObject(&pos, 10, 12, 14, "xy")
|
obj := NewMapObject(pos, 10, 12, 14, "xy")
|
||||||
fmt.Println(obj)
|
fmt.Println(obj)
|
||||||
|
|
||||||
if obj.X != 26 {
|
if obj.X != 26 {
|
||||||
|
@ -43,7 +43,7 @@ func (db *Sqlite3Accessor) GetMapData(q mapobjectdb.SearchQuery) ([]*mapobjectdb
|
|||||||
if currentId == nil || *currentId != id {
|
if currentId == nil || *currentId != id {
|
||||||
pos := coords.NewMapBlockCoords(posx, posy, posz)
|
pos := coords.NewMapBlockCoords(posx, posy, posz)
|
||||||
mo := mapobjectdb.NewMapObject(
|
mo := mapobjectdb.NewMapObject(
|
||||||
&pos,
|
pos,
|
||||||
x, y, z,
|
x, y, z,
|
||||||
Type,
|
Type,
|
||||||
)
|
)
|
||||||
|
@ -89,7 +89,7 @@ func TestMapObjects(t *testing.T) {
|
|||||||
pos := coords.NewMapBlockCoords(0, 0, 0)
|
pos := coords.NewMapBlockCoords(0, 0, 0)
|
||||||
|
|
||||||
o := mapobjectdb.MapObject{
|
o := mapobjectdb.MapObject{
|
||||||
MBPos: &pos,
|
MBPos: pos,
|
||||||
X: 15,
|
X: 15,
|
||||||
Y: 15,
|
Y: 15,
|
||||||
Z: 15,
|
Z: 15,
|
||||||
|
@ -57,7 +57,7 @@ func initialRender(ctx *app.App, jobs chan *coords.TileCoords) {
|
|||||||
|
|
||||||
tiles := renderMapblocks(ctx, jobs, result.List)
|
tiles := renderMapblocks(ctx, jobs, result.List)
|
||||||
|
|
||||||
lastcoords = *result.LastPos
|
lastcoords = result.LastPos
|
||||||
rstate.LastMtime = result.LastMtime
|
rstate.LastMtime = result.LastMtime
|
||||||
|
|
||||||
//Save current positions of initial run
|
//Save current positions of initial run
|
||||||
|
Loading…
Reference in New Issue
Block a user