diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/game_variables.h | 3 | ||||
| -rw-r--r-- | src/game/server/game_server.cpp | 72 |
2 files changed, 43 insertions, 32 deletions
diff --git a/src/game/game_variables.h b/src/game/game_variables.h index de79ed96..7be4c86b 100644 --- a/src/game/game_variables.h +++ b/src/game/game_variables.h @@ -36,3 +36,6 @@ MACRO_CONFIG_INT(team, -10, -1, 0) MACRO_CONFIG_INT(dbg_new_gui, 0, 0, 1) + +MACRO_CONFIG_STR(sv_msg, 512, "") + diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp index 517b297b..ff5dbd84 100644 --- a/src/game/server/game_server.cpp +++ b/src/game/server/game_server.cpp @@ -1320,6 +1320,40 @@ player* intersect_player(vec2 pos0, vec2 pos1, vec2& new_pos, entity* notthis) return 0; } + +void send_chat(int cid, int team, const char *msg) +{ + if(cid >= 0 && cid < MAX_CLIENTS) + dbg_msg("chat", "%d:%d:%s: %s", cid, team, players[cid].name, msg); + else + dbg_msg("chat", "*** %s", msg); + + if(team == -1) + { + msg_pack_start(MSG_CHAT, MSGFLAG_VITAL); + msg_pack_int(cid); + msg_pack_int(0); + msg_pack_string(msg, 512); + msg_pack_end(); + server_send_msg(-1); + } + else + { + msg_pack_start(MSG_CHAT, MSGFLAG_VITAL); + msg_pack_int(cid); + msg_pack_int(1); + msg_pack_string(msg, 512); + msg_pack_end(); + + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(players[i].client_id != -1 && players[i].team == team) + server_send_msg(i); + } + } +} + + // Server hooks void mods_tick() { @@ -1339,6 +1373,12 @@ void mods_tick() config.restart = 0; } + + if(config.sv_msg[0] != 0) + { + send_chat(-1, 0, config.sv_msg); + config.sv_msg[0] = 0; + } } void mods_snap(int client_id) @@ -1359,38 +1399,6 @@ void mods_client_input(int client_id, void *input) } } -void send_chat(int cid, int team, const char *msg) -{ - if(cid >= 0 && cid < MAX_CLIENTS) - dbg_msg("chat", "%d:%d:%s: %s", cid, team, players[cid].name, msg); - else - dbg_msg("chat", "*** %s", msg); - - if(team == -1) - { - msg_pack_start(MSG_CHAT, MSGFLAG_VITAL); - msg_pack_int(cid); - msg_pack_int(0); - msg_pack_string(msg, 512); - msg_pack_end(); - server_send_msg(-1); - } - else - { - msg_pack_start(MSG_CHAT, MSGFLAG_VITAL); - msg_pack_int(cid); - msg_pack_int(1); - msg_pack_string(msg, 512); - msg_pack_end(); - - for(int i = 0; i < MAX_CLIENTS; i++) - { - if(players[i].client_id != -1 && players[i].team == team) - server_send_msg(i); - } - } -} - void send_set_name(int cid, const char *old_name, const char *new_name) { msg_pack_start(MSG_SETNAME, MSGFLAG_VITAL); |