From 86b135b3e0a76680af677cca491b471d6c0d6429 Mon Sep 17 00:00:00 2001 From: EyesOfAHawk Date: Tue, 16 Oct 2018 19:53:33 +1300 Subject: Add config for '@channel setopt MessageDelay '. --- src/map/atcommand.c | 4 ++-- src/map/channel.c | 13 ++++++++++++- src/map/channel.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index a7dc5dd95..0fdbe107f 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -9398,8 +9398,8 @@ ACMD(channel) } else { int v = atoi(sub3); if (k == HCS_OPT_MSG_DELAY) { - if (v < 0 || v > 10) { - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1451), v, opt_str[k]);// value '%d' for option '%s' is out of range (limit is 0-10) + if (v < 0 || v > channel->config->channel_opt_msg_delay) { + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 1451), v, opt_str[k], channel->config->channel_opt_msg_delay);// value '%d' for option '%s' is out of range (limit is 0-%d) clif->message(fd, atcmd_output); return false; } diff --git a/src/map/channel.c b/src/map/channel.c index f1946385d..73398c152 100644 --- a/src/map/channel.c +++ b/src/map/channel.c @@ -622,7 +622,8 @@ static void read_channels_config(void) irc_autojoin = 0, irc_flood_protection_rate = 0, irc_flood_protection_burst = 0, - irc_flood_protection_enabled = 0; + irc_flood_protection_enabled = 0, + channel_opt_msg_delay = 10; if( !libconfig->setting_lookup_string(settings, "map_local_channel_name", &local_name) ) local_name = "map"; @@ -818,6 +819,16 @@ static void read_channels_config(void) } } + libconfig->setting_lookup_int(settings, "channel_opt_msg_delay", &channel_opt_msg_delay); + if (channel_opt_msg_delay < 0) { + ShowWarning("channels.conf: channel_opt_msg_delay value '%d' must be from 0-255. Defaulting to 0...\n", channel_opt_msg_delay); + channel_opt_msg_delay = 0; + } else if (channel_opt_msg_delay > 255) { + ShowWarning("channels.conf: channel_opt_msg_delay value '%d' must be from 0-255. Defaulting to 255...\n", channel_opt_msg_delay); + channel_opt_msg_delay = 255; + } + channel->config->channel_opt_msg_delay = channel_opt_msg_delay; + ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' channels in '"CL_WHITE"%s"CL_RESET"'.\n", db_size(channel->db), config_filename); } libconfig->destroy(&channels_conf); diff --git a/src/map/channel.h b/src/map/channel.h index 4ac3c6037..c56227c66 100644 --- a/src/map/channel.h +++ b/src/map/channel.h @@ -75,6 +75,7 @@ struct Channel_Config { char irc_server[40], irc_channel[50], irc_nick[40], irc_nick_pw[30]; unsigned short irc_server_port; bool irc_use_ghost; + int channel_opt_msg_delay; }; struct channel_ban_entry { -- cgit v1.2.3-70-g09d2