From aaaba4f4039f3643d1a040dfe1c9715be49371e2 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Thu, 25 Sep 2008 12:23:44 +0000 Subject: continued on the voting --- src/game/server/gamecontext.cpp | 12 ++++++++---- src/game/server/hooks.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'src/game/server') diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index f896a140..ca335896 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -264,7 +264,7 @@ void GAMECONTEXT::send_vote_status(int cid) msg.total++; if(players[i]->vote > 0) msg.yes++; - else if(players[i]->vote > 0) + else if(players[i]->vote < 0) msg.no++; else msg.pass++; @@ -302,18 +302,22 @@ void GAMECONTEXT::tick() total++; if(players[i]->vote > 0) yes++; - else if(players[i]->vote > 0) + else if(players[i]->vote < 0) no++; } } - if(yes > (total+1)/2) + if(yes >= (total+1)/2) { console_execute_line(vote_command); vote_closetime = 0; + send_chat(-1, GAMECONTEXT::CHAT_ALL, "Vote passed"); } - else if(time_get() > vote_closetime || no > (total+1)/2) + else if(time_get() > vote_closetime || no >= (total+1)/2) + { + send_chat(-1, GAMECONTEXT::CHAT_ALL, "Vote failed"); vote_closetime = 0; + } } } diff --git a/src/game/server/hooks.cpp b/src/game/server/hooks.cpp index 494f4f62..3a034a97 100644 --- a/src/game/server/hooks.cpp +++ b/src/game/server/hooks.cpp @@ -126,6 +126,33 @@ void mods_message(int msgtype, int client_id) game.send_chat(client_id, team, msg->message); } + else if(msgtype == NETMSGTYPE_CL_CALLVOTE) + { + char chatmsg[512] = {0}; + char desc[512] = {0}; + char cmd[512] = {0}; + NETMSG_CL_CALLVOTE *msg = (NETMSG_CL_CALLVOTE *)rawmsg; + if(str_comp_nocase(msg->type, "map") == 0) + { + str_format(chatmsg, sizeof(chatmsg), "Vote called to change map to '%s'", msg->value); + str_format(desc, sizeof(desc), "Change map to '%s'", msg->value); + str_format(cmd, sizeof(cmd), "sv_map %s", msg->value); + } + + if(cmd[0]) + { + game.send_chat(-1, GAMECONTEXT::CHAT_ALL, chatmsg); + game.start_vote(desc, cmd); + p->vote = 1; + game.send_vote_status(-1); + } + } + else if(msgtype == NETMSGTYPE_CL_VOTE) + { + NETMSG_CL_VOTE *msg = (NETMSG_CL_VOTE *)rawmsg; + p->vote = msg->vote; + game.send_vote_status(-1); + } else if (msgtype == NETMSGTYPE_CL_SETTEAM) { NETMSG_CL_SETTEAM *msg = (NETMSG_CL_SETTEAM *)rawmsg; -- cgit 1.4.1