diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-25 12:23:44 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-09-25 12:23:44 +0000 |
| commit | aaaba4f4039f3643d1a040dfe1c9715be49371e2 (patch) | |
| tree | c396f83ae65eaa4b0f7799eb3650de6b72276dd9 /src/game/server | |
| parent | 059c2ee4cb4d0860b1faf86f2f3b17511260867c (diff) | |
| download | zcatch-aaaba4f4039f3643d1a040dfe1c9715be49371e2.tar.gz zcatch-aaaba4f4039f3643d1a040dfe1c9715be49371e2.zip | |
continued on the voting
Diffstat (limited to 'src/game/server')
| -rw-r--r-- | src/game/server/gamecontext.cpp | 12 | ||||
| -rw-r--r-- | src/game/server/hooks.cpp | 27 |
2 files changed, 35 insertions, 4 deletions
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; |