Skip to content

Commit

Permalink
Added support for target-less commands in the IRC bridge
Browse files Browse the repository at this point in the history
Needed for future updates (such as receiving "QUIT" commands

Signed-off-by: Haru <haru@dotalux.com>
  • Loading branch information
MishimaHaruna committed Aug 12, 2013
1 parent 3fb307b commit d205960
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/map/clif.c
Original file line number Diff line number Diff line change
Expand Up @@ -3711,7 +3711,7 @@ void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok)
}
}

void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data *sd, char *msg) {
void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data *sd, const char *msg) {
if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), iTimer->gettick()) > 0 && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
clif->colormes(sd->fd,COLOR_RED,msg_txt(1455));
return;
Expand Down Expand Up @@ -5715,7 +5715,7 @@ void clif_broadcast(struct block_list* bl, const char* mes, int len, int type, e
* Used by npc_globalmessage
*------------------------------------------*/
void clif_GlobalMessage(struct block_list* bl, const char* message) {
char buf[100];
char buf[256];
int len;
nullpo_retv(bl);

Expand Down
2 changes: 1 addition & 1 deletion src/map/clif.h
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ struct clif_interface {
void (*chsys_create) (struct hChSysCh *channel, char *name, char *pass, unsigned char color);
void (*chsys_msg) (struct hChSysCh *channel, struct map_session_data *sd, char *msg);
void (*chsys_msg2) (struct hChSysCh *channel, char *msg);
void (*chsys_send) (struct hChSysCh *channel, struct map_session_data *sd, char *msg);
void (*chsys_send) (struct hChSysCh *channel, struct map_session_data *sd, const char *msg);
void (*chsys_join) (struct hChSysCh *channel, struct map_session_data *sd);
void (*chsys_left) (struct hChSysCh *channel, struct map_session_data *sd);
void (*chsys_delete) (struct hChSysCh *channel);
Expand Down
13 changes: 9 additions & 4 deletions src/map/irc-bot.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,20 @@ void irc_parse_source(char *source, char *nick, char *ident, char *host) {
}
}
void irc_parse_sub(int fd, char *str) {
char source[180], command[60], target[60], message[200];
char source[180], command[60], buf1[500], buf2[500];
char *target = buf1, *message = buf2;
struct irc_func *func;

source[0] = command[0] = target[0] = message[0] = '\0';
source[0] = command[0] = buf1[0] = buf2[0] = '\0';

if( str[0] == ':' )
str++;

sscanf(str, "%179s %59s %59s :%199[^\r\n]", source, command, target, message);
if (sscanf(str, "%179s %59s %499s :%499[^\r\n]", source, command, buf1, buf2) == 3 && buf1[0] == ':') {
// source command :message (i.e. QUIT)
message = buf1+1;
target = buf2;
}

if( command[0] == '\0' )
return;
Expand Down Expand Up @@ -202,7 +207,7 @@ void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) {
}
}

void irc_relay (char *name, char *msg) {
void irc_relay (char *name, const char *msg) {
if( !ircbot->isIn )
return;
sprintf(send_string,"PRIVMSG %s :[ %s ] : %s",hChSys.irc_channel,name,msg);
Expand Down
2 changes: 1 addition & 1 deletion src/map/irc-bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct irc_bot_interface {
int (*join_timer) (int tid, unsigned int tick, int id, intptr_t data);
/* */
void (*send)(char *str);
void (*relay) (char *name, char *msg);
void (*relay) (char *name, const char *msg);
/* */
void (*pong) (int fd, char *cmd, char *source, char *target, char *msg);
void (*join) (int fd, char *cmd, char *source, char *target, char *msg);
Expand Down

0 comments on commit d205960

Please sign in to comment.