From 7c88cfdb659578ce7d79c6a2bda33d2907d6e246 Mon Sep 17 00:00:00 2001 From: skotlex Date: Tue, 13 Jun 2006 17:02:03 +0000 Subject: - Added irc_channel_pass setting and prevent crashing when irc server lookup by host fails. Thanks to Trancid for the details. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7133 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/irc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/map/irc.c b/src/map/irc.c index 1d1b41617..4c14d81d6 100644 --- a/src/map/irc.c +++ b/src/map/irc.c @@ -54,6 +54,7 @@ char irc_nick[30]=""; char irc_password[32]=""; char irc_channel[32]=""; +char irc_channel_pass[32]=""; char irc_trade_channel[32]=""; unsigned char irc_ip_str[128]=""; @@ -251,7 +252,7 @@ void irc_parse_sub(int fd, char *incoming_string) ShowStatus("IRC: Connected to IRC.\n"); sprintf(send_string, "PRIVMSG nickserv :identify %s", irc_password); irc_send(send_string); - sprintf(send_string, "JOIN %s", irc_channel); + sprintf(send_string, "JOIN %s %s", irc_channel, irc_channel_pass); irc_send(send_string); sprintf(send_string,"NAMES %s",irc_channel); irc_send(send_string); @@ -319,7 +320,7 @@ void irc_parse_sub(int fd, char *incoming_string) // Autojoin on kick [Zido] else if((strcmpi(command,"kick")==0)&&(irc_autojoin==1)) { - sprintf(send_string,"JOIN %s",target); + sprintf(send_string, "JOIN %s %s", target, irc_channel_pass); irc_send(send_string); } } @@ -363,6 +364,12 @@ void do_init_irc(void) if (irc_ip_str[strlen(irc_ip_str)-1] == '\n') irc_ip_str[strlen(irc_ip_str)-1] = '\0'; irc_hostname=gethostbyname(irc_ip_str); + if (!irc_hostname) + { + ShowError("Unable to resolve %s! Cannot connect to IRC server, disabling irc_bot.\n", irc_ip_str); + use_irc = 0; + return; + } irc_ip_str[0]='\0'; sprintf(irc_ip_str, "%d.%d.%d.%d", (unsigned char)irc_hostname->h_addr[0], (unsigned char)irc_hostname->h_addr[1], (unsigned char)irc_hostname->h_addr[2], (unsigned char)irc_hostname->h_addr[3]); @@ -539,6 +546,8 @@ int irc_read_conf(char *file) { irc_autojoin=atoi(w2); else if(strcmpi(w1,"irc_channel")==0) strcpy(irc_channel,w2); + else if(strcmpi(w1,"irc_channel_pass")==0) + strcpy(irc_channel_pass,w2); else if(strcmpi(w1,"irc_trade_channel")==0) strcpy(irc_trade_channel,w2); else if(strcmpi(w1,"irc_nick")==0) -- cgit v1.2.3-70-g09d2