From 8bfaea274e735a2f5331e6b76501299d29681c68 Mon Sep 17 00:00:00 2001 From: Jakob Fries Date: Sun, 29 Jul 2007 22:56:25 +0000 Subject: join and quit messages --- src/game/client/game_client.cpp | 21 +++++++++++++++++++++ src/game/game.h | 2 ++ src/game/server/game_server.cpp | 17 +++++++++++++++++ 3 files changed, 40 insertions(+) (limited to 'src') diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp index ff212006..0fd93972 100644 --- a/src/game/client/game_client.cpp +++ b/src/game/client/game_client.cpp @@ -411,6 +411,13 @@ void chat_add_line(int client_id, const char *line) sprintf(chat_lines[chat_current_line].text, "%s: %s", client_datas[client_id].name, line); // TODO: abit nasty } +void status_add_line(const char *line) +{ + chat_current_line = (chat_current_line+1)%chat_max_lines; + chat_lines[chat_current_line].tick = client_tick(); + strcpy(chat_lines[chat_current_line].text, line); +} + struct killmsg { int weapon; @@ -1808,4 +1815,18 @@ void modc_message(int msg) killmsgs[killmsg_current].weapon = msg_unpack_int(); killmsgs[killmsg_current].tick = client_tick(); } + else if(msg == MSG_JOIN) + { + int cid = msg_unpack_int(); + char message[256]; + sprintf(message, "%s joined the game", client_datas[cid].name); + status_add_line(message); + } + else if(msg == MSG_QUIT) + { + int cid = msg_unpack_int(); + char message[256]; + sprintf(message, "%s quit the game", client_datas[cid].name); + status_add_line(message); + } } diff --git a/src/game/game.h b/src/game/game.h index e2da27dc..bcb5007c 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -51,6 +51,8 @@ enum MSG_SETNAME, MSG_KILLMSG, MSG_SWITCHTEAM, + MSG_JOIN, + MSG_QUIT, }; enum diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp index f366b2c7..10760130 100644 --- a/src/game/server/game_server.cpp +++ b/src/game/server/game_server.cpp @@ -1753,10 +1753,13 @@ void mods_client_enter(int client_id) server_send_msg(client_id); } } + + mods_message(MSG_JOIN, client_id); } void mods_client_drop(int client_id) { + mods_message(MSG_QUIT, client_id); dbg_msg("mods", "client drop %d", client_id); world.remove_entity(&players[client_id]); players[client_id].client_id = -1; @@ -1779,6 +1782,20 @@ void mods_message(int msg, int client_id) players[client_id].die(client_id, -1); players[client_id].score--; } + else if (msg == MSG_JOIN) + { + msg_pack_start(MSG_JOIN, MSGFLAG_VITAL); + msg_pack_int(client_id); + msg_pack_end(); + server_send_msg(-1); + } + else if (msg == MSG_QUIT) + { + msg_pack_start(MSG_QUIT, MSGFLAG_VITAL); + msg_pack_int(client_id); + msg_pack_end(); + server_send_msg(-1); + } } extern unsigned char internal_data[]; -- cgit 1.4.1