Skip to content

Allow polygon and spline startboxes alongside legacy rectangles#615

Open
burnhamrobertp wants to merge 9 commits into
beyond-all-reason:mainfrom
burnhamrobertp:feature/polygon-startboxes
Open

Allow polygon and spline startboxes alongside legacy rectangles#615
burnhamrobertp wants to merge 9 commits into
beyond-all-reason:mainfrom
burnhamrobertp:feature/polygon-startboxes

Conversation

@burnhamrobertp

@burnhamrobertp burnhamrobertp commented May 5, 2026

Copy link
Copy Markdown
Contributor

Closes #605

Summary

Widens the startbox poly schema to accept either the legacy 2-point rectangle (current shape every existing map ships) or an N-point polygon ring with optional Catmull-Rom spline strength per anchor. Discriminated via JSON Schema oneOf so existing data validates unchanged. Generators that target rect-only consumers (TEIServer's Tachyon protocol, SPADS' mapBoxes.conf) compute a bounding-box rectangle from polygon vertices; the polygon shape is preserved through gen_lobby_maps.ts for the polygon-aware new lobby and through sync_to_webflow.ts's existing startpos-code field unchanged.

Changes

schemas/map_list.yaml

  • Replaced inline poly definition with oneOf: [startboxRect, startboxPolygon]
  • New $defs.startboxRect — exactly 2 points, top-left/bottom-right corners (the existing format)
  • New $defs.startboxPolygon — 3+ points, each with optional strength in [0, 1] for Catmull-Rom spline tessellation
  • Range-only validation on strength. No multipleOf constraint to avoid float-comparison flakiness across validators; the Rowy editor enforces a 0.025 snap step at write time

scripts/js/src/check_startboxes.ts

  • Branch on poly.length === 2
  • Rectangle branch keeps the existing corner-ordering check
  • Polygon branch checks for non-degenerate area via the shoelace formula

scripts/js/src/gen_teiserver_maps.ts

  • New rectifyStartboxes() helper collapses N-point polygons to bounding-box rectangles before writing teiserver_maps.json — TEIServer's data model and Tachyon protocol stay rect-only

scripts/js/src/gen_map_boxes_conf.ts

  • New polyToRectCorners() helper applies the same bounding-box fallback for SPADS' mapBoxes.conf format

gen_lobby_maps.ts (no change)

  • bar-lobby is the polygon-aware consumer; the schema's poly passes through unchanged

Verification

  • All 942 existing rectangle entries across all maps validate against the new schema (Python jsonschema + Draft 2020-12)
  • Synthetic polygon (no strength) and synthetic spline (mixed strengths including 0.025 and 1) both validate
  • Counter-tests rejected as expected: 1-point poly, strength: 2, 2-point poly with strength on a corner, polygon with extra property

Related PRs

AI / LLM usage statement

Claude Opus 4.7 used to assist in implementation, schema design, and validation.

Comment thread .github/workflows/ci.yaml Outdated
Comment thread scripts/js/src/gen_teiserver_maps.ts Outdated
Comment thread scripts/js/src/gen_teiserver_maps.ts Outdated
p2004a pushed a commit to beyond-all-reason/bar-lobby that referenced this pull request Jun 25, 2026
Picks up where #574 left off, which rendered polygon startboxes in the
preview but still handed the game a plain bounding-box rectangle at
launch, so an offline game never got the real shape. Now the offline
start script sends the start areas as modoptions, the way the game PR
settled on: a selected preset goes out as the set
(`mapmetadata_startboxes_set`, the server-owned default), and custom
drag-edited boxes go out as the override
(`mapmetadata_startbox_override`, lobby-owned) which the game prefers
over the set. So an offline game enforces the real shape, custom boxes
aren't silently replaced by the map's default, and online games get the
set from the server.

It also brings the preview's spline in line with the game and Chobby so
the curves match exactly. The old math overshot at sharp corners and
could draw a small curl the game never showed.

Related PRs:
- Core game:
beyond-all-reason/Beyond-All-Reason#7513
- Chobby: beyond-all-reason/BYAR-Chobby#1184
- Maps-metadata:
beyond-all-reason/maps-metadata#615
- Rowy fork: p2004a/rowy#1
- Original bar-lobby PR (merged):
#574

Assisted by Claude Code (Opus 4.8); all code reviewed and verified
locally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support polygon startboxes through the Rowy pipeline

2 participants