mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1506] world_grid_atlas: harden geometry, alignment, linear_fit, DDS/MHIU bounds, manifests, and strict JSON (WORLD-GRID-ATLAS-VALIDATION-HARDENING) #1537
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1537
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1506
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/world-grid-atlas-hardening📝 Commits (1)
6b984f2world_grid_atlas: harden geometry, alignment, linear_fit, DDS/MHIU bounds, manifests, and strict JSON (WORLD-GRID-ATLAS-VALIDATION-HARDENING)📊 Changes
2 files changed (+227 additions, -30 deletions)
View changed files
📝
tests/test_world_grid_atlas.py(+116 -0)📝
tools/world_grid_atlas.py(+111 -30)📄 Description
Claimed in the coordination issue as: WORLD-GRID-ATLAS-VALIDATION-HARDENING (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7150859873)
What and why
Hardens
tools/world_grid_atlas.pyagainst malformed geometry, alignment, regression-fit, DDS, MHIU, manifest, and JSON inputs:geometry(): rejectswidth <= 0,height <= 0,booldimensions/values, non-3-tuple or non-finiteorigin, and negative or non-finitezInflation(previouslywidth=0/-512passed% tileand triggeredZeroDivisionError/inverted boxes, and negativezInflationproducedz_min > z_max).cell_box(): rejectsbool/ non-intcells (previously1.5orTruesilently returned a box) and non-positive grid dimensions.fill_by_order(): rejects negative/booln_tiles, duplicate cells inorder, out-of-range/boolanchor tile indices, and anchor cells absent fromorder(raisingValueErrorinstead ofKeyErroror out-of-range placement keys).align(): rejects ragged score rows and non-finite/boolscores, and verifies backtrack indices are valid (previouslyNaN/-infscores leftarg[j] == -1, silently returning-1and indexingorder[-1]).linear_fit(): checkslen(xs) == len(ys)(previouslymy = fsum(ys) / len(xs)silently computed wrong means and regression parameters on mismatched inputs), rejects non-finite/boolpoints, and clamps Pearsonrto[-1.0, 1.0].read_image(): checkswidth > 0,height > 0, andlen(data) >= DX10_HEADERbeforestruct.unpack_from(..., 128)so a truncatedDDS/DX10file raises a cleanValueErrorinstead of an unhandledstruct.errortraceback.split_cells()/tile_step(): reject non-positiverows,columns,w,h, andpwithValueErrorinstead ofZeroDivisionError.water_fit()&run(): skip degenerate zero-span / non-finite / truncated MHIU heightmaps cleanly without divide-by-zero warnings, and runwater_fitonly onWaterSystemHeightMapitself rather than every grid sharing a dictionary set.load_manifests()&write_json(): validate JSON manifest root/items/textures structure (cleanValueErrorinstead ofAttributeError) and passallow_nan=Falsetojson.dump().Tested
python3 -I tests/test_world_grid_atlas.py: 42/42 (26 stdlib tests run and OK; 16 numpy/PIL tests skipped under-I).python3 tests/test_world_grid_atlas.py: 42/42 OK (all stdlib + numpy/PIL forward tests pass).main(3ff2a2adc): all 10 new regression tests fail (failures=19, errors=5plusRuntimeWarning: divide by zeroonwater_fit).python3 -I tests/test_text_write_line_endings.py: 3/3 OK.python3 -I scripts/check_no_game_data.py tools/world_grid_atlas.py tests/test_world_grid_atlas.py: clean.python3 -m compileall -q tools/world_grid_atlas.py tests/test_world_grid_atlas.py: clean.GPUs tested: n/a (Python atlas/analysis tool only)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — no translator rule changed)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.