New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't short circuit eval_sexp on nodes which contain the special argument. #2942
Don't short circuit eval_sexp on nodes which contain the special argument. #2942
Conversation
b5b86a6
to
38976b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There appears to be some sort of confusion on how when-argument
is used. The existing behavior is the correct behavior. If when-argument
is in an event by itself, with no repeats or trigger counts, then it should only execute once. It should not continue to execute for all of its arguments.
In other words, the behavior described in this post... If it is desired to have the event continue to evaluate its sexps even after the event has been satisfied, then
https://www.hard-light.net/forums/index.php?topic=97146.msg1905733#msg1905733
...is correct, and is the way when-argument
has behaved since it was originally implemented.every-time
should be used.
Nobody has ever, at any point, said that there were no repeats or trigger counts. |
38976b3
to
909f4e9
Compare
It makes absolutely no sense to short-circuit a sexp node based on its result when evaluated with a different special argument. Goober, your example of 'intended' behaviour appears to have nothing at all to do with the semantics of this change. |
Yeah the confusion was on my end. On further investigation this does appear to be a loose end that needs patching. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, I want to put this on hold again. The new code will skip the short-circuiting if the special-arg appears in any node in the sexp tree, which is not what we want.
For this specific point:
It does make sense if the event is supposed to complete after a certain condition. If the event is satisfied, it doesn't matter how many other arguments remain.
Something else must be going on below the surface, or the interaction must be more complex than it appears. |
Ok, I believe the root cause is the short-circuiting within Try this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, after further analysis, with discussion on Discord, my concerns have been resolved.
This is a follow-up to PR scp-fs2open#2942. Given that the short-circuiting is now explicitly skipped for node trees containing the special argument, it should no longer be necessary to flush the conditional branch of the sexp tree. (The .cache field is already skipped for special-arg nodes.) The sexp tree is still explicitly flushed for `every-time` and `every-time-argument`.
This is a follow-up to PR scp-fs2open#2942. Given that the short-circuiting is now explicitly skipped for node trees containing the special argument, it should no longer be necessary to flush the conditional branch of the sexp tree. (The .cache field is already skipped for special-arg nodes.) The sexp tree is still explicitly flushed for `every-time` and `every-time-argument`.
This is a follow-up to scp-fs2open#2942. That PR solved most of the short-circuiting issues with nested conditionals under when-argument, but it was still possible for the code to incorrectly short-circuit on a nested conditional that had `<argument>` in an action operator but not a condition operator. The cleanest way to fix this is to not short-circuit on *any* nodes that are part of a when-argument tree.
This implements (a more efficient version of) the solution I outlined to the problem in this thread: https://www.hard-light.net/forums/index.php?topic=97146
Most (all?) sexps that touch the .cache element of a sexp node are careful to make sure that it isn't dependent on the special argument before doing so. This simply extends those checks to the short-circuit values in .value. Performance impact should be minimal: it's just checking a flag. Testing consisted of playing Her Finest Hour a lot and confirming it didn't break.