From 8f23204eef956177855ee8fb9c1cc21cd08560f4 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Wed, 27 Aug 2008 19:41:02 +0000 Subject: fixed the chat --- src/game/client/components/chat.cpp | 51 +++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'src/game/client/components/chat.cpp') diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index ecd29ab8..2e481215 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -1,3 +1,9 @@ +#include // strcmp + +extern "C" { + #include +} + #include #include #include @@ -17,6 +23,35 @@ void CHAT::on_reset() } + +void CHAT::con_say(void *result, void *user_data) +{ + ((CHAT*)user_data)->say(0, console_arg_string(result, 0)); +} + +void CHAT::con_sayteam(void *result, void *user_data) +{ + ((CHAT*)user_data)->say(1, console_arg_string(result, 0)); +} + +void CHAT::con_chat(void *result, void *user_data) +{ + const char *mode = console_arg_string(result, 0); + if(strcmp(mode, "all") == 0) + ((CHAT*)user_data)->enable_mode(0); + else if(strcmp(mode, "team") == 0) + ((CHAT*)user_data)->enable_mode(1); + else + dbg_msg("console", "expected all or team as mode"); +} + +void CHAT::on_init() +{ + MACRO_REGISTER_COMMAND("say", "r", con_say, this); + MACRO_REGISTER_COMMAND("say_team", "r", con_sayteam, this); + MACRO_REGISTER_COMMAND("chat", "s", con_chat, this); +} + bool CHAT::on_input(INPUT_EVENT e) { if(mode == MODE_NONE) @@ -63,8 +98,6 @@ void CHAT::on_message(int msgtype, void *rawmsg) } } - - void CHAT::add_line(int client_id, int team, const char *line) { current_line = (current_line+1)%MAX_LINES; @@ -176,20 +209,6 @@ void CHAT::on_render() gfx_text_color(1,1,1,1); } -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 CHAT::say(int team, const char *line) { // send chat message -- cgit 1.4.1