Skip to content

fix(Engine): reject play sound wait+loop combination instead of hanging forever - #2170

Merged
alexwarren merged 1 commit into
mainfrom
fix/play-sound-wait-loop-hang
Aug 31, 2026
Merged

fix(Engine): reject play sound wait+loop combination instead of hanging forever#2170
alexwarren merged 1 commit into
mainfrom
fix/play-sound-wait-loop-hang

Conversation

@alexwarren

Copy link
Copy Markdown
Contributor

Summary

  • play sound's synchronous (wait) and loop options had no cross-validation; setting both together made ExecuteAsync await a TaskCompletionSource that only completes when the sound finishes naturally — which never happens while looping, hanging the turn forever.
  • Now raises a script error (throw new Exception(...), same convention as ErrorScript/AskScript/etc.) when both are true, before ever touching the wait path. Surfaces to the player as "Error running script: ...", same as any other invalid script call.
  • No elegant editor-side fix is available: CoreEditorScriptsOutput.aslx's play sound block defines the two checkboxes as fully independent controls, and the XML editor schema has no cross-field constraint primitive (only onlydisplayif, which gates on external game state, not sibling attribute values). Execution-time validation is the correct enforcement point here, matching the issue's own recommendation.

Fixes #2098

Test plan

  • Added TestPlaySoundWaitAndLoopThrowsAsync (tests/EngineTests/AsyncScriptTests.cs) asserting play sound ("test.mp3", true, true) throws
  • dotnet test tests/EngineTests --configuration Release — 316/316 passed

…ng forever

When both the "wait" and "loop" options are set, ExecuteAsync awaited a
TaskCompletionSource that only completes when the sound finishes playing
naturally - which never happens while looping, hanging the turn forever.
Raise a script error instead, same as any other invalid script parameter
combination.

Fixes #2098
@alexwarren
alexwarren merged commit a3dc09e into main Aug 31, 2026
16 checks passed
@alexwarren
alexwarren deleted the fix/play-sound-wait-loop-hang branch August 31, 2026 16:13
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.

play sound: wait + loop together hangs forever, no validation prevents it

1 participant