-
Notifications
You must be signed in to change notification settings - Fork 192
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
Enhances Roundstart Antagonist Selection to Prevent Roundstart Fail and Allocate All Antags #1339
base: master
Are you sure you want to change the base?
Enhances Roundstart Antagonist Selection to Prevent Roundstart Fail and Allocate All Antags #1339
Conversation
We might never see the end of new antags being added using MakeAntag so better just cut it off by the root and mitigating the issue by preventing it from causing the round to not start.
Current implementation can lead to no antags being selected in the round at all. IMO if this error happens, the antag selection should reselect player for that role |
Agreed, but given the reason why it fails to assign I didn't figure a way to retry to assign the role without risking freezing on that loop on the case every candidate is not going to pass the checks. |
Well. |
Set a constant to determine the max number of attempts. Retry until that number or until the required slots are assigned. It wouldn't be too bad. I can do that later tonight. |
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.
Make it return a bool. If it fails, try try again up to a constant number of tries.
Would changing the signature of MakeAntag for this be worth it? It would make EE antag code less compatabol. |
Mm, true, should be fine as is. |
So. I ended up changing MakeAntag a lot while preserving APIs. But now I need to properly test this, since it's not tiny anymore. |
There's only one thing which I'm not sure about these last changes. Calling MakeAntag(ent, null, def) to fill up unused slots makes sense, but it may have unintended consequences. |
Instead of writing a quick hack I tried to make ChooseAntags better in a non-hacky way. |
Tested it briefly with a single connection. It did add Thief at roundstart with no issues and didn't break when there weren't any thief available at roundstart either. |
Made this portion of the code identical to wizden so to not conflict
This looks relevant but I am not sure how to fix it. It's the Log.Error in the changes. |
I think this error is supposed to happen in the tests. This new ChooseAntags will detect the failure and try to assign the roles, so I could change it from an error to a info or at least a warning. But since I already copied the state of that code region from wizden I don't think it's worth it to change it to reduce the log level. Feel free to fix the test as you think is appropriate and merge if you want, if it's convenient |
Could check if the player is valid, like IsTerminatingOrDeleted, and if not choose another. |
Right, after you say it it seems so obvious :P |
We might never see the end of new antags being added using MakeAntag so better just cut it off by the root and mitigate the issue by preventing it from causing the round not to start.
Description
Since this issue still persisted to manifest even after an attempt to fix it, this PR simply prevents the rounds from not starting due to the error by changing the exception into a log error.
Catching and treating could be done instead, but I don't see many benefits from that at all, so an error it is.
Also important, after asking a player in ahelp about what settings they had, I concluded it gets triggered when a player has Thief antagonist enabled, and have jobs set up in such a way that they remain in lobby even when they ready up. So they seem "elligible" but they have no entity at roundstart due to their setting to not get spawned at roundstart as assistant and wait in lobby when you don't have the jobs you had selected.
I tried to figure a way to still add the same antagonist it failed to assign in ChooseAntags, and considered decrementing
i
inside that loop, but then I didn't due to how decrementingi
would make the loop prone to stalling. So we lose one of the antagonist slots, but get the round to start, best effort.Cheers.
Edit: Please read my last comments.
TODO
Media
Changelog
🆑