mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
If the player who should be kicked by a vote leaves the game, the vote is aborted. ticket 523
This commit is contained in:
parent
1e961fdece
commit
37abbcbd28
|
@ -1,3 +1,4 @@
|
|||
#include <string.h>
|
||||
#include <new>
|
||||
#include <engine/e_server_interface.h>
|
||||
#include "gamecontext.hpp"
|
||||
|
@ -285,6 +286,12 @@ void GAMECONTEXT::send_vote_status(int cid)
|
|||
|
||||
}
|
||||
|
||||
void GAMECONTEXT::abort_vote_kick_on_disconnect(int client_id)
|
||||
{
|
||||
if(vote_closetime && !strncmp(vote_command, "kick ", 5) && atoi(&vote_command[5]) == client_id)
|
||||
vote_closetime = -1;
|
||||
}
|
||||
|
||||
void GAMECONTEXT::tick()
|
||||
{
|
||||
world.core.tuning = tuning;
|
||||
|
@ -301,6 +308,14 @@ void GAMECONTEXT::tick()
|
|||
|
||||
// update voting
|
||||
if(vote_closetime)
|
||||
{
|
||||
// abort the kick-vote on player-leave
|
||||
if(vote_closetime == -1)
|
||||
{
|
||||
send_chat(-1, GAMECONTEXT::CHAT_ALL, "Vote aborted");
|
||||
end_vote();
|
||||
}
|
||||
else
|
||||
{
|
||||
// count votes
|
||||
int total = 0, yes = 0, no = 0;
|
||||
|
@ -332,6 +347,7 @@ void GAMECONTEXT::tick()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GAMECONTEXT::snap(int client_id)
|
||||
{
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
void end_vote();
|
||||
void send_vote_set(int cid);
|
||||
void send_vote_status(int cid);
|
||||
void abort_vote_kick_on_disconnect(int client_id);
|
||||
int vote_creator;
|
||||
int64 vote_closetime;
|
||||
char vote_description[512];
|
||||
|
|
|
@ -112,6 +112,7 @@ void mods_connected(int client_id)
|
|||
|
||||
void mods_client_drop(int client_id)
|
||||
{
|
||||
game.abort_vote_kick_on_disconnect(client_id);
|
||||
game.players[client_id]->on_disconnect();
|
||||
delete game.players[client_id];
|
||||
game.players[client_id] = 0;
|
||||
|
|
Loading…
Reference in a new issue