Skip to content

Unbind sequential properties and script text limits - #359

Merged
DCurrent merged 11 commits into
masterfrom
unbind-sequential-properties
Aug 12, 2026
Merged

Unbind sequential properties and script text limits#359
DCurrent merged 11 commits into
masterfrom
unbind-sequential-properties

Conversation

@DCurrent

Copy link
Copy Markdown
Owner

Summary

Remove legacy whole-line limits from sequential properties, file-stream arguments, and generated @cmd calls. Strengthen script-string handling throughout preprocessing, compilation, conversion, and text rendering.

Changes

  • Read open-ended property lists one argument at a time instead of collecting complete lines into fixed ArgList storage.
  • Retain the existing per-item limits where appropriate without imposing aggregate argument-count or line-length ceilings.
  • Store complete allowselect values dynamically in runtime and save state.
  • Remove the obsolete fixed allowselect save field and advance save compatibility for the new record layout.
  • Read file-stream arguments directly through the shared sequential token reader.
  • Consume @cmd function names and arguments directly from the source line.
  • Decode grouped single-quoted and double-quoted arguments without retaining delimiters.
  • Preserve embedded whitespace, comment markers, opposite quote types, apostrophes, empty arguments, and multiline file-stream values.
  • Reject unterminated quotations with a graceful fatal error instead of generating incomplete script calls.
  • Represent script string literals as pointer-and-length views until complete values are materialized in the string cache.
  • Enforce the 65,535-character script-string limit during compilation, conversion, concatenation, and file-stream decoding.
  • Pass script text directly to length-aware measurement and rendering functions without fixed intermediate buffers.
  • Preserve nocmdcompatible merging for adjacent same-frame @cmd calls.
  • Prevent compatibility merging from truncating inline scripts or unrelated generated output by tracking merge eligibility and validating the complete expected suffix before removal.

Compatibility

General command parsing, paths, save fields, and other intentionally bounded values retain their existing limits.

The saved-game compatibility version is advanced because the obsolete fixed allowselect record was removed. Saves using older record layouts are rejected rather than interpreted incorrectly.

Validation

  • Syntax-compiled all 14 changed translation units.
  • Passed sanitizer-backed script-string boundary tests.
  • Passed sanitizer-backed @cmd, quoting, compatibility-merging, frame-transition, and high-argument-count tests.
  • Passed length-aware font rendering and formatting spill tests.
  • Passed standalone preprocessor validation.
  • Passed full-branch git diff --check.
  • Passed GitHub Actions builds on macOS, Ubuntu x64, Android arm64, and Windows x64.

Replace whole-line `ArgList` collection for multi-value properties with sequential argument reading.

* Read each argument directly from the source line into a reusable 64-byte buffer.
* Remove aggregate `MAX_ARG_LEN` and `MAX_ARG_COUNT` limits from open-ended property lists.
* Preserve quoting, comments, and the existing 63-character per-item limit.
* Count weapon arguments before allocating the persistent weapon list exactly once.
* Apply complete `allowselect` lists at runtime while retaining only whole entries that fit its legacy save field.
* Keep the legacy 512-byte limit unchanged for general parsing, paths, save fields, and script file-stream arguments.
Store complete allowselect command lines in dynamically sized runtime and per-difficulty save state.

Append length-prefixed allowselect data after the legacy fixed save records so current builds can round-trip lists of any practical size. Preserve a whole-argument compatibility mirror for older saves and older engine builds.

Load the legacy fixed field when no dynamic extension is present, validate extension lengths against the remaining file, and release all owned state during save resets, level-order resizing, and shutdown.
Delete the fixed 1,024-byte compatibility mirror and fallback path. Require dynamic allowselect save data and advance the saved-game compatibility version so older record layouts are rejected.
Remove the fixed 512-byte findarg buffer and read requested file-stream arguments through the shared sequential token reader. Allocate script storage for only the requested argument, preserve missing-value conversions, and move model frame lookahead onto the same token reader.
Consume @cmd function names and parameters directly from the original command line one item at a time. This removes ParseArgs' whole-line and argument-count ceilings from generated script calls.

Restore the dedicated per-command-argument buffer to 512 bytes for paths and other bounded values, and append function names directly to the dynamic script buffer.
Represent script string literals as non-owning pointer-and-length views through preprocessing and lexing, then materialize complete decoded values directly in StrCache when CONSTSTR instructions are emitted. Keep fixed token storage for identifiers and diagnostics only.

Pass @cmd source tokens directly into its dynamic generated-script buffer so long quoted arguments do not pass through the 512-byte command scratch buffer. Preserve length-aware macro handling, escape behavior, switch-case lifetimes, and legacy unary-not string behavior.
Replace capacityless ScriptVariant_ToString() calls with explicit-capacity conversion or direct string views. Bound script string inputs and concatenation at 65,535 characters through MAX_SCRIPT_STRING_LENGTH, expose the limit to script, and reject oversized literals during compilation.
Treat matching single and double quotes as grouping syntax when parsing sequential command and file-stream arguments.

* Remove opening and closing quote delimiters from decoded output.
* Allow double-quoted spans to appear within arguments and concatenate with adjacent unquoted text.
* Recognize single-quoted spans only at argument boundaries, preserving apostrophes in ordinary words.
* Preserve the opposite quote type as literal content within a quoted span.
* Allow quoted file-stream arguments to contain whitespace, comment markers, and newlines.
* Support empty quoted arguments.
* Track source and decoded lengths separately to avoid unnecessary temporary allocations.
* Decode file-stream arguments directly into exact-sized script string storage.
* Apply the 65,535-character policy to decoded content.
* Reject unterminated quotes and insufficient destination capacity cleanly.

File streams can now return complete sentences and multi-line paragraphs as individual arguments without retaining their grouping delimiters.
Prevent `nocmdcompatible` optimization from corrupting generated animation scripts when same-frame `@cmd` calls are separated by other script content.

* Track whether the preceding generated section is eligible for `@cmd` merging.
* Invalidate merge eligibility after inline scripts, animation changes, and frame changes.
* Verify the exact generated `return;` and frame-closing suffix before removing either.
* Remove the complete suffix atomically only after successful validation.
* Open a fresh frame condition when the preceding output is not safely mergeable.
* Preserve normal merging of adjacent same-frame `@cmd` calls.

This prevents intervening `@script` content or unexpected generated output from being truncated while retaining the existing compatibility optimization.
@DCurrent
DCurrent merged commit e9f5312 into master Aug 12, 2026
8 checks passed
@DCurrent
DCurrent deleted the unbind-sequential-properties branch August 12, 2026 19:46
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.

1 participant