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/client/components/voting.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/game/client/components/voting.cpp') diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index b81cfb97..d90e617f 100644 --- a/src/game/client/components/voting.cpp +++ b/src/game/client/components/voting.cpp @@ -4,12 +4,29 @@ void VOTING::con_callvote(void *result, void *user_data) { + NETMSG_CL_CALLVOTE msg = {0}; + msg.type = console_arg_string(result, 0); + msg.value = console_arg_string(result, 1); + msg.pack(MSGFLAG_VITAL); + client_send_msg(); } void VOTING::con_vote(void *result, void *user_data) { + VOTING *self = (VOTING *)user_data; + if(str_comp_nocase(console_arg_string(result, 0), "yes") == 0) + self->vote(1); + else if(str_comp_nocase(console_arg_string(result, 0), "no") == 0) + self->vote(-1); } - + +void VOTING::vote(int v) +{ + NETMSG_CL_VOTE msg = {v}; + msg.pack(MSGFLAG_VITAL); + client_send_msg(); +} + VOTING::VOTING() { on_reset(); @@ -26,7 +43,7 @@ void VOTING::on_reset() void VOTING::on_console_init() { - MACRO_REGISTER_COMMAND("callvote", "r", con_callvote, this); + MACRO_REGISTER_COMMAND("callvote", "sr", con_callvote, this); MACRO_REGISTER_COMMAND("vote", "r", con_vote, this); } -- cgit 1.4.1