fix(Engine): reject play sound wait+loop combination instead of hanging forever - #2170
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
play sound'ssynchronous(wait) andloopoptions had no cross-validation; setting both together madeExecuteAsyncawait aTaskCompletionSourcethat only completes when the sound finishes naturally — which never happens while looping, hanging the turn forever.throw new Exception(...), same convention asErrorScript/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.CoreEditorScriptsOutput.aslx'splay soundblock defines the two checkboxes as fully independent controls, and the XML editor schema has no cross-field constraint primitive (onlyonlydisplayif, 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
TestPlaySoundWaitAndLoopThrowsAsync(tests/EngineTests/AsyncScriptTests.cs) assertingplay sound ("test.mp3", true, true)throwsdotnet test tests/EngineTests --configuration Release— 316/316 passed