forked from ddnet/ddnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix server handling when vote creator leaves
Reset the vote creator client ID `CGameContext::m_VoteCreator` to `-1` when the player that started the vote leaves instead of keeping the invalid client ID around. Previously, this was causing the server to crash due an assertion in the `IServer::GetAuthedState` function when a ban vote was aborted due rcon authentication change in the `CGameContext::OnSetAuthed` function while the vote creator has already left the server. It was possible to cause this situation as the target of a vote by executing `rcon_auth "<password>"; rcon "kick <vote creator>"; rcon "logout"` (`ban` works for the same effect). This also caused existing votes to use the wrong vote creator if the same client ID was reused by a new client while a vote from a client that left is still running. Ban votes are now only aborted in the `CGameContext::OnSetAuthed` function when 1) a vote is actually active (this was previously not checked), 2) a client logged in (previously logout was also affected), and 3) the vote creator is unset or has a lower authentication level than the player logging in (previously used invalid vote creator). In particular also improve the handling for the `random_map` and `random_unfinished_map` commands when the vote creator leaves. Use the name `nameless tee` instead of `(invalid)` (returned by `IServer::ClientName`) as the requesting player name in queries. Handle requesting player not being set when the sending result message. Avoid overriding the `m_VoteCreator` value in the callback of the `random_unfinished_map` command, which is not necessary and would cause incorrect vote behavior when the command is used while a vote is active. Also ensure that the voting state is initialized properly on server start.
- Loading branch information
Showing
2 changed files
with
39 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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