diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp index 6bb6f582d..80e7bd405 100644 --- a/src/game/client/gc_client.cpp +++ b/src/game/client/gc_client.cpp @@ -741,6 +741,9 @@ void chat_enable_mode(int team) mem_zero(chat_input, sizeof(chat_input)); chat_input_len = 0; + + // make sure that we don't trigger something weird + inp_clear_events(); } } @@ -779,7 +782,7 @@ void render_game() anim_eval(&data->animations[ANIM_BASE], 0, &idlestate); anim_eval_add(&idlestate, &data->animations[ANIM_IDLE], 0, 1.0f); - if (inp_key_down(KEY_ESC)) + if(inp_key_down(KEY_ESC)) { if (chat_mode) chat_mode = CHATMODE_NONE; @@ -806,15 +809,6 @@ void render_game() { if(chat_mode != CHATMODE_NONE) { - if(inp_key_down(KEY_ENTER) || inp_key_down(KEY_KP_ENTER)) - { - // send message - if(chat_input_len) - chat_say(chat_mode == CHATMODE_ALL ? 0 : 1, chat_input); - - chat_mode = CHATMODE_NONE; - } - for(int i = 0; i < inp_num_events(); i++) { INPUT_EVENT e = inp_get_event(i); @@ -829,6 +823,16 @@ void render_game() } } + if((e.key == KEY_ENTER || e.key == KEY_KP_ENTER) && (e.flags&INPFLAG_PRESS)) + { + // send message + if(chat_input_len) + chat_say(chat_mode == CHATMODE_ALL ? 0 : 1, chat_input); + + chat_mode = CHATMODE_NONE; + break; + } + if(e.key == KEY_BACKSPACE && (e.flags&INPFLAG_PRESS)) { if(chat_input_len > 0) diff --git a/src/game/client/gc_console.cpp b/src/game/client/gc_console.cpp index 37e509489..ca1e20cb1 100644 --- a/src/game/client/gc_console.cpp +++ b/src/game/client/gc_console.cpp @@ -215,6 +215,20 @@ static void con_sayteam(void *result, void *user_data) chat_say(1, console_arg_string(result, 0)); } + + +static void con_chat(void *result, void *user_data) +{ + const char *mode = console_arg_string(result, 0); + if(strcmp(mode, "all") == 0) + chat_enable_mode(0); + else if(strcmp(mode, "team") == 0) + chat_enable_mode(1); + else + dbg_msg("console", "expected all or team as mode"); +} + + void send_kill(int client_id); static void con_kill(void *result, void *user_data) @@ -330,17 +344,6 @@ static void con_key_input_weapon(void *result, void *user_data) input_data.wanted_weapon = w; } -static void con_chat(void *result, void *user_data) -{ - const char *mode = console_arg_string(result, 0); - if(strcmp(mode, "all") == 0) - chat_enable_mode(0); - else if(strcmp(mode, "team") == 0) - chat_enable_mode(1); - else - dbg_msg("console", "expected all or team as mode"); -} - static void con_toggle_local_console(void *result, void *user_data) { console_toggle(0); diff --git a/src/game/g_protocol.def b/src/game/g_protocol.def index d731b37e6..cac4bfdff 100644 --- a/src/game/g_protocol.def +++ b/src/game/g_protocol.def @@ -197,7 +197,7 @@ message cl_say end message sv_chat - range(0, 1) team + range(-1, 1) team range(-1,MAX_CLIENTS-1) cid string message end diff --git a/src/game/server/gs_server.cpp b/src/game/server/gs_server.cpp index 816e2531d..049268c64 100644 --- a/src/game/server/gs_server.cpp +++ b/src/game/server/gs_server.cpp @@ -2070,13 +2070,12 @@ void mods_message(int msgtype, int client_id) if(msgtype == NETMSGTYPE_CL_SAY) { NETMSG_CL_SAY *msg = (NETMSG_CL_SAY *)rawmsg; - int team = msg->team; if(team) team = players[client_id].team; else team = -1; - send_chat(client_id, msg->team, msg->message); + send_chat(client_id, team, msg->message); } else if (msgtype == NETMSGTYPE_CL_SETTEAM) {