scripts: maps: Fixed divide-by-zero when packing blocks into small maps

This can be hit when dealing with very small maps, which is common since
we're rendering to the terminal. Not crashing here at least allows the
header/usage string to be shown.
This commit is contained in:
Christopher Haster
2025-04-11 01:46:00 -05:00
parent cffa9ec67e
commit f0b8d34230
3 changed files with 9 additions and 9 deletions
+3 -3
View File
@@ -4598,11 +4598,11 @@ def main_(ring, disk, mroots=None, *,
# well for things that are often powers-of-two
block_cols_ = 1
block_rows_ = len(bmap)
while (abs(((canvas.width/(block_cols_ * 2))
/ (canvas.height/mt.ceil(block_rows_ / 2)))
while (abs(((canvas.width/(block_cols_*2))
/ max(canvas.height/mt.ceil(block_rows_/2), 1))
- block_ratio)
< abs(((canvas.width/block_cols_)
/ (canvas.height/block_rows_)))
/ max(canvas.height/block_rows_, 1)))
- block_ratio):
block_cols_ *= 2
block_rows_ = mt.ceil(block_rows_ / 2)