diff options
author | shennetsind <ind@henn.et> | 2013-06-01 22:23:12 -0300 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-06-01 22:23:12 -0300 |
commit | c9d08b4d92a6fdab0e13dcff140b70e8d9f0abe9 (patch) | |
tree | fb71ec73064d0b4cb41651943c7beca0412fb68f | |
parent | 3a3d37f5950c5236aac557fbe34a5524fbcda591 (diff) | |
download | hercules-c9d08b4d92a6fdab0e13dcff140b70e8d9f0abe9.tar.gz hercules-c9d08b4d92a6fdab0e13dcff140b70e8d9f0abe9.tar.bz2 hercules-c9d08b4d92a6fdab0e13dcff140b70e8d9f0abe9.tar.xz hercules-c9d08b4d92a6fdab0e13dcff140b70e8d9f0abe9.zip |
IRC Bridge Fix/Adjustments
All Credits to Haruna~!
Thank you very much!
Signed-off-by: shennetsind <ind@henn.et>
-rw-r--r-- | src/map/clif.c | 4 | ||||
-rw-r--r-- | src/map/clif.h | 2 | ||||
-rw-r--r-- | src/map/irc-bot.c | 12 | ||||
-rw-r--r-- | src/map/irc-bot.h | 3 |
4 files changed, 12 insertions, 9 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index f1aac302e..319be6b3e 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2762,7 +2762,7 @@ void read_channels_config(void) { ShowWarning("channels.conf : irc channel enabled but irc_channel_network wasn't found, disabling irc channel...\n"); } if( config_setting_lookup_string(settings, "irc_channel_channel", &irc_channel) ) - safestrncpy(hChSys.irc_channel, irc_channel, 20); + safestrncpy(hChSys.irc_channel, irc_channel, 50); else { hChSys.irc = false; ShowWarning("channels.conf : irc channel enabled but irc_channel_channel wasn't found, disabling irc channel...\n"); @@ -2771,7 +2771,7 @@ void read_channels_config(void) { if( strcmpi(irc_nick,"Hercules_chSysBot") == 0 ) { sprintf(hChSys.irc_nick, "Hercules_chSysBot%d",rand()%777); } else - safestrncpy(hChSys.irc_nick, irc_nick, 30); + safestrncpy(hChSys.irc_nick, irc_nick, 40); } else { hChSys.irc = false; ShowWarning("channels.conf : irc channel enabled but irc_channel_nick wasn't found, disabling irc channel...\n"); diff --git a/src/map/clif.h b/src/map/clif.h index 94b29db9a..a0959f92a 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -412,7 +412,7 @@ struct { unsigned char local_color, ally_color, irc_color; bool closing; bool allow_user_channel_creation; - char irc_server[40], irc_channel[20], irc_nick[30], irc_nick_pw[30]; + char irc_server[40], irc_channel[50], irc_nick[40], irc_nick_pw[30]; unsigned short irc_server_port; } hChSys; diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index bfaf18af0..fea5f523a 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -118,14 +118,14 @@ void irc_parse_source(char *source, char *nick, char *ident, char *host) { for(i = 0; i < len; i++) { if( stage == 0 && source[i] == '!' ) { - memcpy(nick, &source[0], len - i); + memcpy(nick, &source[0], min(i,IRC_NICK_LENGTH)); nick[i] = '\0'; pos = i+1; stage = 1; } else if( stage == 1 && source[i] == '@' ) { - memcpy(ident, &source[pos], i - pos); + memcpy(ident, &source[pos], min(i - pos,IRC_IDENT_LENGTH)); ident[i-pos] = '\0'; - memcpy(host, &source[i+1], len); + memcpy(host, &source[i+1], min(len - i,IRC_HOST_LENGTH)); host[len] = '\0'; break; } @@ -177,7 +177,7 @@ void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) { if( strcmpi(target,hChSys.irc_nick) == 0 ) { if( msg[0] == ':' ) msg++; if( strcmpi(msg,"VERSION") == 0 ) { - char source_nick[40], source_ident[40], source_host[100]; + char source_nick[IRC_NICK_LENGTH], source_ident[IRC_IDENT_LENGTH], source_host[IRC_HOST_LENGTH]; source_nick[0] = source_ident[0] = source_host[0] = '\0'; @@ -189,13 +189,13 @@ void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) { return; } } else if( strcmpi(target,hChSys.irc_channel) == 0 ) { - char source_nick[40], source_ident[40], source_host[100]; + char source_nick[IRC_NICK_LENGTH], source_ident[IRC_IDENT_LENGTH], source_host[IRC_HOST_LENGTH]; source_nick[0] = source_ident[0] = source_host[0] = '\0'; if( source[0] != '\0' ) ircbot->parse_source(source,source_nick,source_ident,source_host); - + if( ircbot->channel ) { snprintf(send_string, 150, "[ #%s ] IRC.%s : %s",ircbot->channel->name,source_nick,msg); clif->chsys_msg2(ircbot->channel,send_string); diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h index f4244e024..911a15b0e 100644 --- a/src/map/irc-bot.h +++ b/src/map/irc-bot.h @@ -6,6 +6,9 @@ #ifndef _IRC_BOT_H_ #define _IRC_BOT_H_ +#define IRC_NICK_LENGTH 40 +#define IRC_IDENT_LENGTH 40 +#define IRC_HOST_LENGTH 63 #define IRC_FUNC_LENGTH 30 struct hChSysCh; |