Add a test case for --drawplayers

(also fixes off-by-one error in clipping players to draw)
This commit is contained in:
sfan5
2025-02-19 18:13:07 +01:00
parent 7a0bc15d21
commit 46cb386fef
2 changed files with 19 additions and 7 deletions

View File

@ -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);
}
}