diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..5e01fdd --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,19 @@ +name: docker + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@master + - name: docker publish + uses: elgohr/Publish-Docker-Github-Action@master + with: + name: minetestmapserver/mapserver + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + tag_names: true + cache: true + diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml new file mode 100644 index 0000000..12b0d6f --- /dev/null +++ b/.github/workflows/go-test.yml @@ -0,0 +1,24 @@ +name: go-test + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-go@v1 + with: + go-version: '1.12' + + - name: get + run: go get github.com/mjibson/esc + + - name: generate + run: go generate + + - name: test + run: go test ./... + diff --git a/.github/workflows/jshint.yml b/.github/workflows/jshint.yml new file mode 100644 index 0000000..916b97c --- /dev/null +++ b/.github/workflows/jshint.yml @@ -0,0 +1,20 @@ +name: jshint + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: apt + run: sudo apt-get install -y nodejs npm + + - name: jshint install + run: sudo npm i -g jshint + + - name: jshint run + run: cd static/js && jshint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0aa7d6b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +name: release + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: build + run: make release + + - name: upload + uses: skx/github-action-publish-binaries@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: 'output/mapserver-*' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 04c67b3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: go -sudo: false - -go: - - 1.11.x - -os: - - linux - -script: - - go get github.com/mjibson/esc - - go generate - - go build - - go test diff --git a/Dockerfile b/Dockerfile index 2f156aa..aa0933a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,17 @@ -FROM ubuntu as builder +FROM golang:1.13-alpine as builder -RUN apt-get update &&\ - apt-get install -y software-properties-common git &&\ - add-apt-repository ppa:longsleep/golang-backports &&\ - apt-get update &&\ - apt-get install -y golang-go +RUN apk --no-cache add ca-certificates gcc libc-dev nodejs npm git make VOLUME /root/go COPY ./ /server RUN cd /server &&\ - go generate &&\ - go test ./... &&\ - CGO_ENABLED=1 go build -ldflags "-linkmode external -extldflags -static -X mapserver/app.Version=docker" + npm install -g jshint rollup &&\ + make test jshint all FROM alpine:latest RUN apk --no-cache add ca-certificates WORKDIR /app -COPY --from=builder /server/mapserver /bin/mapserver +COPY --from=builder /server/output/mapserver-linux-x86_64 /bin/mapserver EXPOSE 8080 CMD ["/bin/mapserver"] diff --git a/Makefile b/Makefile index d7f2c00..e3ee5cc 100644 --- a/Makefile +++ b/Makefile @@ -15,9 +15,9 @@ BINARIES += $(OUT_DIR)/mapserver-windows-x86.exe BINARIES += $(OUT_DIR)/mapserver-windows-x86-64.exe BINARIES += $(OUT_DIR)/mapserver-linux-arm +JS_BUNDLE = static/js/bundle.js -all: $(STATIC_VFS) - go build +all: $(STATIC_VFS) $(OUT_DIR)/mapserver-linux-x86_64 $(OUT_DIR): mkdir $@ @@ -27,23 +27,25 @@ fmt: test: $(OUT_DIR) go generate - go build go vet ./... $(ENV) go test ./... clean: - rm -rf $(STATIC_VFS) test-output + rm -rf $(STATIC_VFS) $(JS_BUNDLE) test-output rm -rf $(OUT_DIR) jshint: - jshint static/js/*.js static/js/util static/js/overlays static/js/search + cd static/js && jshint . -$(STATIC_VFS): +$(JS_BUNDLE): + cd static/js && rollup -c rollup.config.js + +$(STATIC_VFS): $(JS_BUNDLE) go generate $(OUT_DIR)/mapserver-linux-x86_64: $(OUT_DIR) # native (linux x86_64) - GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc $(GO_BUILD) $(GO_LDFLAGS) -o $@ + GOOS=linux GOARCH=amd64 CC=gcc $(GO_BUILD) $(GO_LDFLAGS) -o $@ $(OUT_DIR)/mapserver-linux-x86: $(OUT_DIR) # apt install gcc-8-i686-linux-gnu @@ -63,11 +65,11 @@ $(OUT_DIR)/mapserver-linux-arm: $(OUT_DIR) release: builder_image $(OUT_DIR) $(MOD_ZIP) # build all with the docker image - sudo docker run --rm -it\ - -v $(shell pwd):/app\ - -v mapserver-volume:/root/go\ - -w /app\ - mapserver-builder\ + sudo docker run --rm -i \ + -v $(shell pwd):/app \ + -v mapserver-volume:/root/go \ + -w /app \ + mapserver-builder \ make test jshint release-all VERSION=$(VERSION) # copy generated files to output dir diff --git a/app/setup.go b/app/setup.go index 4398887..50d23b6 100644 --- a/app/setup.go +++ b/app/setup.go @@ -86,10 +86,10 @@ func Setup(p params.ParamsType, cfg *Config) *App { colorfiles := []string{ //https://daconcepts.com/vanessa/hobbies/minetest/colors.txt - "/colors/custom.txt", "/colors/vanessa.txt", "/colors/advtrains.txt", "/colors/scifi_nodes.txt", + "/colors/custom.txt", } for _, colorfile := range colorfiles { diff --git a/doc/changelog.md b/doc/changelog.md index df57321..38e8faf 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -4,6 +4,10 @@ ## Next * Train overlay decluttering +* Updated builtin colors +* Hide travelnets and missions by pattern "(P)" +* Added benchmark +* Minor speed improvements ## 3.0.0 diff --git a/doc/get_trainlines.sh b/doc/get_trainlines.sh new file mode 100644 index 0000000..545fdc0 --- /dev/null +++ b/doc/get_trainlines.sh @@ -0,0 +1,7 @@ +#!/bin/sh +curl -X POST -k -H 'Content-Type: application/json' 'https://pandorabox.io/map/api/mapobjects/' --data '{ + "type":"train", + "pos1":{"x":-2048,"y":-2048,"z":-2048}, + "pos2":{"x":2048,"y":2048,"z":2048} +}' | jq + diff --git a/doc/install.md b/doc/install.md index a7eeda8..dd82528 100644 --- a/doc/install.md +++ b/doc/install.md @@ -3,6 +3,8 @@ **Please make a backup of your world in case something goes wrong** +## Simple installation + * Download the binary from the [releases](https://github.com/minetest-tools/mapserver/releases) for your architecture and platform * Drop the binary into your world folder (the one with the `world.mt` and `map.sqlite` files) * Start the mapserver via command-line: `./mapserver` or `./mapserver.exe` @@ -10,6 +12,36 @@ For additional infos (lag,time,players => active mode) on the mapserver interface you should install the [mapserver-mod](mod.md) +## Docker image + +* Docker-hub: https://hub.docker.com/repository/docker/minetestmapserver/mapserver + +Simple docker run example to run in the world-directory: + +``` +docker run --rm --it -p 8080:8080 -v $(pwd):/minetest -w /minetest minetestmapserver/mapserver +``` + +## Docker compose + +Examplary `docker-compose` config: + +```yml +services: + mapserver: + image: minetesttools/mapserver + restart: always + networks: + - default + depends_on: + - "postgres" + volumes: + - "./data/minetest/world:/minetest" + working_dir: "/minetest" +``` + +* See also: https://github.com/pandorabox-io/pandorabox.io/blob/master/docker-compose.yml + ## Performance / Scalability For small to medium setups the default values should suffice. diff --git a/doc/recommended_specs.md b/doc/recommended_specs.md new file mode 100644 index 0000000..75456aa --- /dev/null +++ b/doc/recommended_specs.md @@ -0,0 +1,76 @@ + +# Recommended specs + +Recommended specs for running the mapserver + +## Storage + +The tiles are cached in several zoom-levels on disk. +Storage usage depends heavily on map-size and explored areas +but it will be in the region of several gigabytes (5 to 10 GB for "older" servers) + +## Memory + +Memory depedends on the amount of caching (see: [Configuration](./config.md)) +Per default there will be around 500 mapblocks cached for quicker access. +This will be around 5 to 10 megabytes depending on the contents. + +The recommendation is to maximize caching so the queries don't slow down the game-database. +If you are willing to spend around 2 GB of memory set the `maxitems` to 5000 mapblocks. +Otherwise leave the defaults and see if it has any impact. + +Example config from `mapserver.json`: +```json +{ + "mapblockaccessor": { + "expiretime": "10s", + "purgetime": "15s", + "maxitems": 500 + } +} +``` + + +## CPU + +The application is more CPU-bound than IO-bound. +It will use all the configured CPU's while rendering: + + + +It is recommended to set the `renderjobs` setting to a number of CPU's +you can spare. + +Per default it will set the setting to the number of cores you have, +but it will also run on just 1 job and take a bit longer... + +Example config from `mapserver.json`: +```json +{ + "renderingjobs": 2 +} +``` + +## Database + +The recommended database is Postgres if you have a busy server. +SQLite will work too if the disk-access is good. + +**Personal experience**: Don't worry about it if you have fast SSD's ;) + +## Network + +I don't recommend serving the map behind a slow residential internet connection. +An upload-bandwidth from 10 MBPS upwards will do the job pretty ok though: + + + +# Recap + +If your setup looks something like this, don't worry about performance: + +* 4+ cores +* 8+ GB RAM +* 20+ GB SSD +* Postgres DB + diff --git a/docker_builder/Dockerfile b/docker_builder/Dockerfile index c8ae46c..ae6a6a3 100644 --- a/docker_builder/Dockerfile +++ b/docker_builder/Dockerfile @@ -10,10 +10,9 @@ RUN add-apt-repository ppa:longsleep/golang-backports &&\ apt-get update &&\ apt-get install -y golang-go -# luacheck -RUN apt-get install -y luarocks liblua5.1-dev -RUN luarocks install luacheck - # jshint RUN apt-get install -y nodejs npm RUN npm install -g jshint + +# rollup +RUN npm install -g rollup diff --git a/go.mod b/go.mod index d3205d1..ec29523 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,16 @@ module mapserver require ( - github.com/disintegration/imaging v1.5.0 - github.com/gorilla/websocket v1.4.0 - github.com/lib/pq v1.0.0 - github.com/mattn/go-sqlite3 v1.10.0 + github.com/disintegration/imaging v1.6.2 + github.com/gorilla/websocket v1.4.1 + github.com/lib/pq v1.2.0 + github.com/mattn/go-sqlite3 v1.13.0 github.com/mjibson/esc v0.1.0 // indirect github.com/patrickmn/go-cache v2.1.0+incompatible - github.com/prometheus/client_golang v0.9.2 - github.com/sirupsen/logrus v1.3.0 - github.com/stretchr/testify v1.2.2 + github.com/prometheus/client_golang v0.9.4 + github.com/sirupsen/logrus v1.4.2 + github.com/stretchr/testify v1.4.0 github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583 - golang.org/x/image v0.0.0-20190118043309-183bebdce1b2 // indirect ) + +go 1.13 diff --git a/go.sum b/go.sum index 8841f62..b5e4d5d 100644 --- a/go.sum +++ b/go.sum @@ -1,54 +1,119 @@ +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/disintegration/imaging v1.5.0 h1:uYqUhwNmLU4K1FN44vhqS4TZJRAA4RhBINgbQlKyGi0= github.com/disintegration/imaging v1.5.0/go.mod h1:9B/deIUIrliYkyMTuXJd6OUFLcrZ2tf+3Qlwnaf/CjU= +github.com/disintegration/imaging v1.6.1 h1:JnBbK6ECIZb1NsWIikP9pd8gIlTIRx7fuDNpU9fsxOE= +github.com/disintegration/imaging v1.6.1/go.mod h1:xuIt+sRxDFrHS0drzXUlCJthkJ8k7lkkUojDSR247MQ= +github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c= +github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q= +github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mattn/go-sqlite3 v1.12.0 h1:u/x3mp++qUxvYfulZ4HKOvVO0JWhk7HtE8lWhbGz/Do= +github.com/mattn/go-sqlite3 v1.12.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mattn/go-sqlite3 v1.13.0 h1:LnJI81JidiW9r7pS/hXe6cFeO5EXNq7KbfvoJLRI69c= +github.com/mattn/go-sqlite3 v1.13.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= 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/mjibson/esc v0.1.0 h1:5ch+murgrcwDFLOE2hwj0f7kE4xJfJhkSCAjSLY182o= github.com/mjibson/esc v0.1.0/go.mod h1:9Hw9gxxfHulMF5OJKCyhYD7PzlSdhzXyaGEBRPH1OPs= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740= github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= +github.com/prometheus/client_golang v0.9.4 h1:Y8E/JaaPbmFSW2V81Ab/d8yZFYQQGbni1b1jPcG9Y6A= +github.com/prometheus/client_golang v0.9.4/go.mod h1:oCXIBxdI62A4cR6aTRJCgetEjecSIYzOEaeAn4iYEpM= +github.com/prometheus/client_golang v1.1.0 h1:BQ53HtBmfOitExawJ6LokA4x8ov/z0SYYb0+HxJfRI8= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 h1:PnBWHBf+6L0jOqq0gIVUe6Yk0/QMZ640k6NvkxcBf+8= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME= github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583 h1:SZPG5w7Qxq7bMcMVl6e3Ht2X7f+AAGQdzjkbyOnNNZ8= github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190118043309-183bebdce1b2 h1:FNSSV4jv1PrPsiM2iKGpqLPPgYACqh9Muav7Pollk1k= golang.org/x/image v0.0.0-20190118043309-183bebdce1b2/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= +golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U= +golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc h1:a3CU5tJYVj92DY2LaA1kUkrsqD5/3mLDhx2NcNqyW+0= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190204203706-41f3e6584952 h1:FDfvYgoVsA7TTZSbgiqjAbfPbK47CNHdWl3h/PJtii0= golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/mapblockparser/mapblock.go b/mapblockparser/mapblock.go index 33f6bf9..36438c0 100644 --- a/mapblockparser/mapblock.go +++ b/mapblockparser/mapblock.go @@ -66,7 +66,7 @@ func getNodePos(x, y, z int) int { } func (inv *Inventory) IsEmpty() bool { - if inv.Size == 0 || len(inv.Items) == 0 { + if len(inv.Items) == 0 { return true } diff --git a/mapblockparser/metadata.go b/mapblockparser/metadata.go index 62abcc0..2387d12 100644 --- a/mapblockparser/metadata.go +++ b/mapblockparser/metadata.go @@ -155,6 +155,7 @@ func parseMetadata(mapblock *MapBlock, data []byte) (int, error) { } currentInventory.Items = append(currentInventory.Items, &item) + currentInventory.Size += 1 } diff --git a/mapblockrenderer/renderer.go b/mapblockrenderer/renderer.go index 5362a6e..a859783 100644 --- a/mapblockrenderer/renderer.go +++ b/mapblockrenderer/renderer.go @@ -4,7 +4,6 @@ import ( "errors" "image" "image/color" - "image/draw" "mapserver/colormapping" "mapserver/coords" "mapserver/mapblockaccessor" @@ -69,7 +68,7 @@ func addColorComponent(c *color.RGBA, value int) *color.RGBA { R: clamp(int(c.R) + value), G: clamp(int(c.G) + value), B: clamp(int(c.B) + value), - A: clamp(int(c.A) + value), + A: c.A, } } @@ -180,7 +179,7 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *coords.MapBlockCoords) (*image.NRG if neighbourMapblock != nil && err == nil { top = neighbourMapblock.GetNodeName(x, y, 0) if y < 15 { - topAbove = neighbourMapblock.GetNodeName(x, y+1, z+0) + topAbove = neighbourMapblock.GetNodeName(x, y+1, 0) } } } @@ -209,10 +208,21 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *coords.MapBlockCoords) (*image.NRG imgX := x * IMG_SCALE imgY := (15 - z) * IMG_SCALE - rect := image.Rect( - imgX, imgY, - imgX+IMG_SCALE, imgY+IMG_SCALE, - ) + r32, g32, b32, a32 := c.RGBA() + r8, g8, b8, a8 := uint8(r32), uint8(g32), uint8(b32), uint8(a32) + for Y := imgY; Y < imgY+IMG_SCALE; Y++ { + ix := (Y*IMG_SIZE + imgX) << 2 + for X := 0; X < IMG_SCALE; X++ { + img.Pix[ix] = r8 + ix++ + img.Pix[ix] = g8 + ix++ + img.Pix[ix] = b8 + ix++ + img.Pix[ix] = a8 + ix++ + } + } if c.A != 0xFF || !r.enableTransparency { //not transparent, mark as rendered @@ -220,8 +230,6 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *coords.MapBlockCoords) (*image.NRG xzOccupationMap[x][z] = true } - draw.Draw(img, rect, &image.Uniform{c}, image.ZP, draw.Src) - if foundBlocks == EXPECTED_BLOCKS_PER_FLAT_MAPBLOCK { return img, nil } diff --git a/mapobject/bones.go b/mapobject/bones.go index f87bf06..232d452 100644 --- a/mapobject/bones.go +++ b/mapobject/bones.go @@ -3,6 +3,7 @@ package mapobject import ( "mapserver/mapblockparser" "mapserver/mapobjectdb" + "strconv" ) type BonesBlock struct{} @@ -10,13 +11,24 @@ type BonesBlock struct{} func (this *BonesBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock) *mapobjectdb.MapObject { md := block.Metadata.GetMetadata(x, y, z) - if md["owner"] == "" { + invMap := block.Metadata.GetInventoryMapAtPos(x, y, z) + mainInv := invMap["main"] + + if mainInv == nil { return nil } o := mapobjectdb.NewMapObject(block.Pos, x, y, z, "bones") o.Attributes["time"] = md["time"] o.Attributes["owner"] = md["owner"] + o.Attributes["info"] = md["infotext"] + + itemCount := 0 + for _, item := range mainInv.Items { + itemCount += item.Count + } + + o.Attributes["item_count"] = strconv.Itoa(itemCount) return o } diff --git a/mapobject/fancyvend.go b/mapobject/fancyvend.go index e211559..3719f42 100644 --- a/mapobject/fancyvend.go +++ b/mapobject/fancyvend.go @@ -19,16 +19,11 @@ func (this *FancyVend) onMapObject(x, y, z int, block *mapblockparser.MapBlock) parser := luaparser.New() isAdmin := false - isDepositor := false if nodename == "fancy_vend:admin_vendor" || nodename == "fancy_vend:admin_depo" { isAdmin = true } - if nodename == "fancy_vend:player_depo" || nodename == "fancy_vend:admin_depo" { - isDepositor = true - } - payInv := invMap["wanted_item"] giveInv := invMap["given_item"] mainInv := invMap["main"] @@ -93,19 +88,11 @@ func (this *FancyVend) onMapObject(x, y, z int, block *mapblockparser.MapBlock) o.Attributes["owner"] = md["owner"] o.Attributes["type"] = "fancyvend" - if !isDepositor { - o.Attributes["in_item"] = in_item - o.Attributes["in_count"] = strconv.Itoa(in_count) - o.Attributes["out_item"] = out_item - o.Attributes["out_count"] = strconv.Itoa(out_count) - } else { - // invert in and out - o.Attributes["out_item"] = in_item - o.Attributes["out_count"] = strconv.Itoa(in_count) - o.Attributes["in_item"] = out_item - o.Attributes["in_count"] = strconv.Itoa(out_count) + o.Attributes["in_item"] = in_item + o.Attributes["in_count"] = strconv.Itoa(in_count) + o.Attributes["out_item"] = out_item + o.Attributes["out_count"] = strconv.Itoa(out_count) - } o.Attributes["stock"] = strconv.Itoa(stock_factor) return o diff --git a/mapobject/smartshop.go b/mapobject/smartshop.go index 072a35a..df4dfd7 100644 --- a/mapobject/smartshop.go +++ b/mapobject/smartshop.go @@ -15,6 +15,7 @@ func (this *SmartShopBlock) onMapObject(x, y, z int, block *mapblockparser.MapBl md := block.Metadata.GetMetadata(x, y, z) invMap := block.Metadata.GetInventoryMapAtPos(x, y, z) mainInv := invMap["main"] + isCreative := md["type"] == "0" if mainInv.IsEmpty() { return list @@ -27,7 +28,7 @@ func (this *SmartShopBlock) onMapObject(x, y, z int, block *mapblockparser.MapBl pay := invMap[payInvName] give := invMap[giveInvName] - if pay.IsEmpty() || give.IsEmpty() { + if len(pay.Items) == 0 || len(give.Items) == 0 { continue } @@ -43,10 +44,16 @@ func (this *SmartShopBlock) onMapObject(x, y, z int, block *mapblockparser.MapBl stock := 0 - for _, item := range mainInv.Items { - if item.Name == out_item { - stock += item.Count + if isCreative { + stock = 999 + + } else { + for _, item := range mainInv.Items { + if item.Name == out_item { + stock += item.Count + } } + } //multiples of out_count diff --git a/pics/cpu_graph.png b/pics/cpu_graph.png new file mode 100644 index 0000000..1f8491d Binary files /dev/null and b/pics/cpu_graph.png differ diff --git a/pics/network_graph.png b/pics/network_graph.png new file mode 100644 index 0000000..2b3dc46 Binary files /dev/null and b/pics/network_graph.png differ diff --git a/readme.md b/readme.md index bfc3145..35c0625 100644 --- a/readme.md +++ b/readme.md @@ -1,13 +1,15 @@ Minetest mapserver ======= - -[![Dependencies](https://img.shields.io/librariesio/github/minetest-tools/mapserver.svg)](https://github.com/minetest-tools/mapserver) -[![Build Status](https://travis-ci.org/minetest-tools/mapserver.svg?branch=master)](https://travis-ci.org/minetest-tools/mapserver) +![](https://github.com/minetest-mapserver/mapserver/workflows/jshint/badge.svg) +![](https://github.com/minetest-mapserver/mapserver/workflows/go-test/badge.svg) + ![GitHub repo size](https://img.shields.io/github/repo-size/minetest-tools/mapserver.svg) ![GitHub closed issues](https://img.shields.io/github/issues-closed/minetest-tools/mapserver.svg) + + Realtime mapserver for [Minetest](https://minetest.net) Demo: [Pandorabox Server map](https://pandorabox.io/map/#-1782.25/493.5/10) @@ -20,6 +22,7 @@ Demo: [Pandorabox Server map](https://pandorabox.io/map/#-1782.25/493.5/10) * [Parameters](doc/params.md) * [Search](doc/search.md) * [Configuration](doc/config.md) +* [Recommended specs](doc/recommended_specs.md) * [Contribution](doc/contrib.md) * [Development](doc/dev.md) * [License](doc/license.md) @@ -53,6 +56,7 @@ See: [Incremental rendering](doc/incrementalrendering.md) ## Planned Features * Isometric view +* Skin support * Route planning (via travelnets / trains) # Supported map-databases diff --git a/static/colors/custom.txt b/static/colors/custom.txt index f3a4e18..8593096 100644 --- a/static/colors/custom.txt +++ b/static/colors/custom.txt @@ -4,4 +4,13 @@ planetoidgen:sun 255 100 0 # beacon beacon:redbeam 255 0 0 -beacon:greenbeam 0 255 0 \ No newline at end of file +beacon:greenbeam 0 255 0 + +# ores (thx to MilesDyson) +default:stone_with_coal 36 36 36 +default:stone_with_copper 115 113 66 +default:stone_with_diamond 108 255 255 +default:stone_with_gold 255 228 0 +default:stone_with_iron 146 73 36 +default:stone_with_mese 186 194 0 +default:stone_with_tin 202 202 202 diff --git a/static/css/custom.css b/static/css/custom.css index 343f9a5..3f5f1b3 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -1,14 +1,15 @@ body { height: 100%; margin: 0; - overflow: hidden; } -#image-map { +#app { + height: 100%; +} + +.full-screen { width: 100%; height: 100%; - border: 1px solid #ccc; - margin-bottom: 10px; } .leaflet-custom-display { @@ -16,15 +17,6 @@ body { padding: 5px; } -#search-menu { - position: absolute; - top: 5%; - bottom: 5%; - left: 5%; - right: 5%; - z-index: 99999; -} - .mapserver-label-icon { margin-left: -100px !important; margin-top: -100px !important; diff --git a/static/index.html b/static/index.html index 5b98d85..1c467ce 100644 --- a/static/index.html +++ b/static/index.html @@ -15,8 +15,10 @@