diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-03-18 02:14:35 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-03-18 02:14:35 +0000 |
| commit | 6d07a560a662b336b6c35105b37b6323d0c3ad8b (patch) | |
| tree | 5f8c8409a0616fccf9f8af9a91fb12fa05bae1b0 /src/game | |
| parent | c662df41eedb585412e445145b9233e20b2ffe46 (diff) | |
| download | zcatch-6d07a560a662b336b6c35105b37b6323d0c3ad8b.tar.gz zcatch-6d07a560a662b336b6c35105b37b6323d0c3ad8b.zip | |
fixed so that you can bind chat to enter and it still works
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/client/gc_client.cpp | 24 | ||||
| -rw-r--r-- | src/game/client/gc_console.cpp | 25 | ||||
| -rw-r--r-- | src/game/g_protocol.def | 2 | ||||
| -rw-r--r-- | src/game/server/gs_server.cpp | 3 |
4 files changed, 30 insertions, 24 deletions
diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp index 6bb6f582..80e7bd40 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 37e50948..ca1e20cb 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 d731b37e..cac4bfdf 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 816e2531..049268c6 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) { |