Add pattern format v1 with 128x128 canvas support - #4972
Conversation
|
Hi @Nebualaxy, thanks for the contribution. This PR was automatically closed because it doesn't fit our contribution workflow:
To contribute to OpenFront:
If you believe this was closed in error, please reach out on our Discord or comment below. See CONTRIBUTING.md for the full contribution process. — Automated PR gate. Source. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughPattern decoding now supports v0 and v1 formats with shared size limits and header-aware payload handling. WebGL frame storage and renderer texture operations use the shared row capacity. Tests cover validation, dimensions, scaling, offsets, and tiling. ChangesPattern format and rendering
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant PatternData
participant PatternDecoder
participant WebGLFrameBuilder
participant Renderer
PatternData->>PatternDecoder: decodePatternData
PatternDecoder-->>WebGLFrameBuilder: dimensions, bytes, headerBytes
WebGLFrameBuilder->>Renderer: bounded pattern row
Renderer->>Renderer: upload pattern texture row
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/core/PatternDecoder.ts`:
- Around line 34-47: Replace the Math.ceil-based calculations for
MAX_PATTERN_BYTES, MAX_PATTERN_DATA_LENGTH, and PATTERN_ROW_BYTES with
integer-only arithmetic or fixed integer constants, preserving the existing
rounded-up byte and base64url limits. Keep the exported constants and their
current values unchanged while removing floating-point operations from this
PatternDecoder limit calculation.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 85728c98-4c3a-4a5f-b4f2-2a345499d04e
📒 Files selected for processing (5)
src/client/WebGLFrameBuilder.tssrc/client/render/gl/Renderer.tssrc/core/CosmeticSchemas.tssrc/core/PatternDecoder.tstests/PatternDecoder.test.ts
|
Hi @Nebualaxy, thanks for the contribution. This PR was automatically closed because it doesn't fit our contribution workflow:
To contribute to OpenFront:
If you believe this was closed in error, please reach out on our Discord or comment below. See CONTRIBUTING.md for the full contribution process. — Automated PR gate. Source. |
|
Removed floating point calculations |
Add approved & assigned issue number here:#4957
Resolves #4957
Description:
Adds a v1 pattern format so artist canvases can be square rather than capped at 129×65. v0 decoding is unchanged, so every existing cosmetic decodes exactly the same.
Describe the PR.
The v0 header packs scale(3) | width_lo(5) and width_hi(2) | height(6) into two bytes with nothing spare — width gets 7 bits, height only 6, purely because 16 bits doesn't divide evenly. There's no mask to widen. v1 uses a 4-byte header with 9 bits each for width and height and 3 bits reserved.
Bug fixed on the way. WebGLFrameBuilder reserves a 1024-byte row per player, but a maximum-size v0 pattern (129×65) needs 1049. .set() doesn't throw on overflow — it writes 25 bytes into the next player's row. It has never fired because no pattern has been that large, but it's live in main today. Related: slice(3) hardcoded the v0 header size, so any longer header would have misaligned every pixel.
Silent truncation fixed. v0 length checking is a minimum, so a pattern one pixel over the height limit wrapped and rendered wrong rather than erroring. v1 requires an exact payload length.
Hardening. Raising the schema cap would have let a v0 pattern carry ~8KB of trailing data through to Privilege.ts, since v0 length checking is lenient. v0 now rejects payloads over 1049 bytes — every currently-valid v0 pattern is well under the old 1403-character cap, so nothing that works today can fail this.
Sizing. MAX_PATTERN_DIMENSION is a single constant; the schema's max length, the CPU buffer, and the GPU texture width all derive from it, so they can't drift from the format again. Set to 128 → a 2048-byte row: 16MB across CPU buffer and GPU texture, against 8MB today. The v1 header can express up to 513, so raising the ceiling later is one line and needs no format change. 176 is the largest dimension that keeps the texture width inside the 4096 MAX_TEXTURE_SIZE that capped devices report.
No shader change — territory.frag.glsl already reads dimensions from patternMeta.
This makes the game able to read larger patterns. The pattern maker still needs to emit v1 headers before artists can author at that size, so nothing changes visibly on merge.






Please complete the following:
No user facing text added
Please put your Discord username so you can be contacted if a bug or regression is found:
DISCORD_USERNAME
Nebualaxy