Skip to content

Commit

Permalink
Merge branch 'master' into mapparser-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay authored Jan 30, 2022
2 parents 571825e + e43f883 commit e7b7ce2
Show file tree
Hide file tree
Showing 21 changed files with 2,350 additions and 1,536 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.4
- uses: actions/setup-go@v2.1.5
with:
go-version: '1.16'

- name: test
run: go test ./... -coverprofile=profile.cov

- uses: shogo82148/actions-goveralls@v1.4.7
- uses: shogo82148/actions-goveralls@v1.5.1
with:
path-to-profile: profile.cov
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17.0-alpine as builder
FROM golang:1.17.6-alpine as builder

RUN apk --no-cache add ca-certificates gcc libc-dev nodejs npm git make

Expand All @@ -8,7 +8,7 @@ RUN cd /server &&\
npm install -g jshint rollup &&\
make test jshint all

FROM alpine:3.14.2
FROM alpine:3.15.0
RUN apk --no-cache add ca-certificates curl
WORKDIR /app
COPY --from=builder /server/output/mapserver-linux-x86_64 /bin/mapserver
Expand Down
3 changes: 2 additions & 1 deletion app/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ func Setup(p params.ParamsType, cfg *Config) *App {
"colors/vanessa.txt",
"colors/advtrains.txt",
"colors/scifi_nodes.txt",
"colors/mcl2_colors.txt",
"colors/mc2.txt",
"colors/mtg.txt",
"colors/miles.txt",
"colors/custom.txt",
}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
command: ["npm", "i"]

mapserver:
image: golang:1.17.0
image: golang:1.17.6
depends_on:
- minetest
- mapserver_frontend
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,16 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg=
github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA=
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/Sfk=
github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/minetest-go/mapparser v0.1.0 h1:wjVrS2QXURnphPlqqPRD6vt1gvkT55RRUjroT3G5Two=
Expand Down
2 changes: 1 addition & 1 deletion mapblockaccessor/legacyblocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (a *MapBlockAccessor) FindNextLegacyBlocks(s settings.Settings, layers []*l
"z": block.Pos.Z,
"err": err,
}
logrus.WithFields(fields).Error("mapblock-pars")
logrus.WithFields(fields).Error("mapblock-parse")

return nil, err
}
Expand Down
2 changes: 2 additions & 0 deletions mapobject/train.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ func (this *TrainBlock) onMapObject(mbpos *coords.MapBlockCoords, x, y, z int, b
o.Attributes["index"] = md["index"]
o.Attributes["owner"] = md["owner"]
o.Attributes["color"] = md["color"]
o.Attributes["rail_pos"] = md["rail_pos"]
o.Attributes["linepath_from_prv"] = md["linepath_from_prv"]

return o
}
16 changes: 6 additions & 10 deletions mapobjectdb/postgres/mapobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,23 @@ import (
"database/sql"
"mapserver/coords"
"mapserver/mapobjectdb"
"github.com/sirupsen/logrus"
"unicode/utf8"

"github.com/sirupsen/logrus"
)

func (db *PostgresAccessor) GetMapData(q *mapobjectdb.SearchQuery) ([]*mapobjectdb.MapObject, error) {

var rows *sql.Rows
var err error
var limit = 1000

if q.Limit != nil {
limit = *q.Limit
}

if q.AttributeLike == nil {
//plain pos search
rows, err = db.db.Query(getMapDataPosQuery,
q.Type,
q.Pos1.X, q.Pos1.Y, q.Pos1.Z,
q.Pos2.X, q.Pos2.Y, q.Pos2.Z,
limit,
*q.Limit,
)

} else {
Expand All @@ -34,7 +30,7 @@ func (db *PostgresAccessor) GetMapData(q *mapobjectdb.SearchQuery) ([]*mapobject
q.Pos1.X, q.Pos1.Y, q.Pos1.Z,
q.Pos2.X, q.Pos2.Y, q.Pos2.Z,
q.AttributeLike.Key, q.AttributeLike.Value,
limit,
*q.Limit,
)
}

Expand Down Expand Up @@ -101,9 +97,9 @@ func (db *PostgresAccessor) AddMapData(data *mapobjectdb.MapObject) error {
if !utf8.Valid([]byte(v)) {
// invalid utf8, skip insert into db
fields := logrus.Fields{
"type": data.Type,
"type": data.Type,
"value": v,
"key": k,
"key": k,
}
log.WithFields(fields).Info("Migration completed")
return nil
Expand Down
16 changes: 6 additions & 10 deletions mapobjectdb/sqlite/mapobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,23 @@ import (
"database/sql"
"mapserver/coords"
"mapserver/mapobjectdb"
"github.com/sirupsen/logrus"
"unicode/utf8"

"github.com/sirupsen/logrus"
)

func (db *Sqlite3Accessor) GetMapData(q *mapobjectdb.SearchQuery) ([]*mapobjectdb.MapObject, error) {

var rows *sql.Rows
var err error

var limit = 1000
if q.Limit != nil {
limit = *q.Limit
}

if q.AttributeLike == nil {
//plain pos search
rows, err = db.db.Query(getMapDataPosQuery,
q.Type,
q.Pos1.X, q.Pos1.Y, q.Pos1.Z,
q.Pos2.X, q.Pos2.Y, q.Pos2.Z,
limit,
*q.Limit,
)

} else {
Expand All @@ -34,7 +30,7 @@ func (db *Sqlite3Accessor) GetMapData(q *mapobjectdb.SearchQuery) ([]*mapobjectd
q.Type,
q.Pos1.X, q.Pos1.Y, q.Pos1.Z,
q.Pos2.X, q.Pos2.Y, q.Pos2.Z,
limit,
*q.Limit,
)
}

Expand Down Expand Up @@ -101,9 +97,9 @@ func (db *Sqlite3Accessor) AddMapData(data *mapobjectdb.MapObject) error {
if !utf8.Valid([]byte(v)) {
// invalid utf8, skip insert into db
fields := logrus.Fields{
"type": data.Type,
"type": data.Type,
"value": v,
"key": k,
"key": k,
}
log.WithFields(fields).Info("Migration completed")
return nil
Expand Down
12 changes: 9 additions & 3 deletions mapobjectdb/sqlite/mapobjects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ func TestMapObjects(t *testing.T) {
panic(err)
}

limit := 1000
q := mapobjectdb.SearchQuery{
Pos1: pos,
Pos2: pos,
Type: "xy",
Pos1: pos,
Pos2: pos,
Type: "xy",
Limit: &limit,
}

objs, err := db.GetMapData(&q)
Expand Down Expand Up @@ -120,6 +122,7 @@ func TestMapObjectsQueryWithAttribute(t *testing.T) {
panic(err)
}

limit := 1000
q := mapobjectdb.SearchQuery{
Pos1: pos,
Pos2: pos,
Expand All @@ -128,6 +131,7 @@ func TestMapObjectsQueryWithAttribute(t *testing.T) {
Key: "X",
Value: "%y",
},
Limit: &limit,
}

objs, err := db.GetMapData(&q)
Expand Down Expand Up @@ -182,6 +186,7 @@ func TestMapObjectsQueryWithAttributeIgnoreCase(t *testing.T) {
panic(err)
}

limit := 1000
q := mapobjectdb.SearchQuery{
Pos1: pos,
Pos2: pos,
Expand All @@ -190,6 +195,7 @@ func TestMapObjectsQueryWithAttributeIgnoreCase(t *testing.T) {
Key: "X",
Value: "%bc",
},
Limit: &limit,
}

objs, err := db.GetMapData(&q)
Expand Down
2 changes: 1 addition & 1 deletion postgres_test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "2"

services:
postgres:
image: postgres:13
image: postgres:14
restart: always
environment:
POSTGRES_PASSWORD: enter
Expand Down
15 changes: 15 additions & 0 deletions public/colors/custom.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

# Assorted node-colors
# move them to their own file if the list gets bigger

# planetoidgen
planetoidgen:sun 255 100 0

Expand All @@ -15,4 +18,16 @@ default:stone_with_iron 146 73 36
default:stone_with_mese 186 194 0
default:stone_with_tin 202 202 202

# technic
technic:sulfur_block 189 169 00

# planet_mars
planet_mars:blackmarble 50 50 50
planet_mars:blackmarble_bricks 57 57 57
planet_mars:blackmarble_polished 43 43 43
planet_mars:bluemarble 59 77 101
planet_mars:bluemarble_bricks 64 79 99
planet_mars:bluemarble_polished 99 128 167
planet_mars:redmarble 167 74 63
planet_mars:redmarble_bricks 170 81 73
planet_mars:redmarble_polished 166 75 65
Loading

0 comments on commit e7b7ce2

Please sign in to comment.