diff --git a/src/TileGenerator.cpp b/src/TileGenerator.cpp index fa7b147..2822b80 100644 --- a/src/TileGenerator.cpp +++ b/src/TileGenerator.cpp @@ -859,8 +859,8 @@ void TileGenerator::renderPlayers(const std::string &input_path) PlayerAttributes players(input); for (auto &player : players) { - if (player.x < m_xMin * 16 || player.x > m_xMax * 16 || - player.z < m_zMin * 16 || player.z > m_zMax * 16) + if (player.x < m_xMin * 16 || player.x >= (m_xMax+1) * 16 || + player.z < m_zMin * 16 || player.z >= (m_zMax+1) * 16) continue; if (player.y < m_yMin || player.y > m_yMax) continue; @@ -869,6 +869,7 @@ void TileGenerator::renderPlayers(const std::string &input_path) m_image->drawFilledRect(imageX - 1, imageY, 3, 1, m_playerColor); m_image->drawFilledRect(imageX, imageY - 1, 1, 3, m_playerColor); + assert(!player.name.empty()); m_image->drawText(imageX + 2, imageY, player.name, m_playerColor); } } diff --git a/util/ci/test.sh b/util/ci/test.sh index 60a5e74..1ab290f 100755 --- a/util/ci/test.sh +++ b/util/ci/test.sh @@ -1,5 +1,6 @@ #!/bin/bash set -eo pipefail +mapdir=./testmap msg () { echo @@ -14,15 +15,15 @@ encodepos () { # create map file with sql statements writemap () { - mkdir -p testmap - echo "backend = sqlite3" >testmap/world.mt - echo "default:stone 255 0 0" >testmap/colors.txt - rm -f testmap/map.sqlite + rm -rf $mapdir + mkdir $mapdir + echo "backend = sqlite3" >$mapdir/world.mt + echo "default:stone 10 10 10" >$mapdir/colors.txt printf '%s\n' \ "CREATE TABLE d(d BLOB);" \ "INSERT INTO d VALUES (x'$(cat util/ci/test_block)');" \ "$1" \ - "DROP TABLE d;" | sqlite3 testmap/map.sqlite + "DROP TABLE d;" | sqlite3 $mapdir/map.sqlite } # check that a non-empty ($1=1) or empty map ($1=0) was written with the args ($2 ...) @@ -98,3 +99,13 @@ checkmap 1 --geometry 32:32+16+16 --min-y 32 --max-y $((32+16-1)) msg "new schema: empty map" writemap "$schema_new" checkmap 0 + +msg "drawplayers" +writemap " +$schema_new +INSERT INTO blocks SELECT 0, 0, 0, d FROM d; +" +mkdir $mapdir/players +printf '%s\n' "name = cat" "position = (80,0,80)" >$mapdir/players/cat +# we can't check that it actually worked, however +checkmap 1 --drawplayers --zoom 4