mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fixed remote console
This commit is contained in:
parent
ebbe51718e
commit
e55ba53ba7
|
@ -299,6 +299,15 @@ static void client_send_error(const char *error)
|
|||
}
|
||||
|
||||
|
||||
void client_rcon(const char *cmd)
|
||||
{
|
||||
msg_pack_start_system(NETMSG_CMD, MSGFLAG_VITAL);
|
||||
msg_pack_string(config.rcon_password, 32);
|
||||
msg_pack_string(cmd, 256);
|
||||
msg_pack_end();
|
||||
client_send_msg();
|
||||
}
|
||||
|
||||
static void client_send_input()
|
||||
{
|
||||
if(current_predtick <= 0)
|
||||
|
|
|
@ -6,6 +6,7 @@ MACRO_CONFIG_STR(player_name, 32, "nameless tee")
|
|||
MACRO_CONFIG_STR(clan_name, 32, "")
|
||||
MACRO_CONFIG_STR(password, 32, "")
|
||||
|
||||
MACRO_CONFIG_STR(rcon_password, 32, "")
|
||||
|
||||
MACRO_CONFIG_INT(debug, 0, 0, 1)
|
||||
MACRO_CONFIG_INT(stress, 0, 0, 0)
|
||||
|
|
|
@ -782,6 +782,8 @@ void client_connect(const char *address);
|
|||
void client_disconnect();
|
||||
void client_quit();
|
||||
|
||||
void client_rcon(const char *cmd);
|
||||
|
||||
void client_serverbrowse_refresh(int lan);
|
||||
int client_serverbrowse_getlist(SERVER_INFO **servers);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ enum
|
|||
/* sent by client */
|
||||
NETMSG_ENTERGAME,
|
||||
NETMSG_INPUT,
|
||||
NETMSG_CMD,
|
||||
|
||||
/* sent by both */
|
||||
NETMSG_ERROR,
|
||||
|
|
|
@ -465,6 +465,16 @@ static void server_process_client_packet(NETPACKET *packet)
|
|||
clients[cid].current_input++;
|
||||
clients[cid].current_input %= 200;
|
||||
}
|
||||
else if(msg == NETMSG_CMD)
|
||||
{
|
||||
const char *pw = msg_unpack_string();
|
||||
const char *cmd = msg_unpack_string();
|
||||
if(config.rcon_password[0] != 0 && strcmp(pw, config.rcon_password) == 0)
|
||||
{
|
||||
dbg_msg("server", "cid=%d rcon='%s'", cid, cmd);
|
||||
config_set(cmd);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_msg("server", "strange message cid=%d msg=%d data_size=%d", cid, msg, packet->data_size);
|
||||
|
|
|
@ -1649,10 +1649,15 @@ void render_game()
|
|||
config_set(&chat_input[1]);
|
||||
else
|
||||
{
|
||||
msg_pack_start(MSG_SAY, MSGFLAG_VITAL);
|
||||
msg_pack_string(chat_input, 512);
|
||||
msg_pack_end();
|
||||
client_send_msg();
|
||||
if(inp_key_pressed(KEY_RSHIFT) || inp_key_pressed(KEY_LSHIFT))
|
||||
client_rcon(chat_input);
|
||||
else
|
||||
{
|
||||
msg_pack_start(MSG_SAY, MSGFLAG_VITAL);
|
||||
msg_pack_string(chat_input, 512);
|
||||
msg_pack_end();
|
||||
client_send_msg();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue