version 1.8 | | version 1.9 |
---|
| | |
/* | | /* |
* static char *rcsid_c_chat_c = | | * static char *rcsid_c_chat_c = |
* "$Id: c_chat.c,v 1.8 2002/07/15 04:25:40 mwedel Exp $"; | | * "$Id: c_chat.c,v 1.9 2002/10/17 07:15:39 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
char buf[MAX_BUF]; | | char buf[MAX_BUF]; |
| | |
if (!params) return 0; | | if (!params) return 0; |
/* This broken apart from one sprintf to avoid buffer overuns. | | snprintf(buf, MAX_BUF-1, "%s says: %s",op->name, params); |
* This could be done via snprintf, but I am not sure how widely | | |
* available that is. MSW 5/22/2000 | | |
*/ | | |
sprintf(buf, "%s says: ",op->name); | | |
strncat(buf, params, MAX_BUF - strlen(buf)-1); | | |
buf[MAX_BUF-1]=0; | | |
| | |
new_info_map(NDI_WHITE,op->map, buf); | | new_info_map(NDI_WHITE,op->map, buf); |
communicate(op, params); | | communicate(op, params); |
| | |
| | |
| | |
int command_shout (object *op, char *params) | | int command_shout (object *op, char *params) |
{ | | { |
char buf[MAX_BUF]; | | |
#ifdef PLUGINS | | #ifdef PLUGINS |
int evtid; | | int evtid; |
CFParm CFP; | | CFParm CFP; |
| | |
new_draw_info(NDI_UNIQUE, 0,op,"Shout what?"); | | new_draw_info(NDI_UNIQUE, 0,op,"Shout what?"); |
return 1; | | return 1; |
} | | } |
strcpy(buf,op->name); | | new_draw_info_format(NDI_UNIQUE | NDI_ALL | NDI_RED, 1, NULL, |
strcat(buf," shouts: "); | | "%s shouts: %s", op->name, params); |
strncat(buf, params, MAX_BUF-30); | | |
buf[MAX_BUF - 30] = '\0'; | | |
new_draw_info(NDI_UNIQUE | NDI_ALL | NDI_RED, 1, NULL, buf); | | |
#ifdef PLUGINS | | #ifdef PLUGINS |
/* GROS : Here we handle the SHOUT global event */ | | /* GROS : Here we handle the SHOUT global event */ |
evtid = EVENT_SHOUT; | | evtid = EVENT_SHOUT; |
| | |
int command_tell (object *op, char *params) | | int command_tell (object *op, char *params) |
{ | | { |
char buf[MAX_BUF],*name = NULL ,*msg = NULL; | | char buf[MAX_BUF],*name = NULL ,*msg = NULL; |
char buf2[MAX_BUF]; | | |
player *pl; | | player *pl; |
| | |
if ( params != NULL){ | | if ( params != NULL){ |
name = params; | | name = params; |
msg = strchr(name, ' '); | | msg = strchr(name, ' '); |
| | |
new_draw_info(NDI_UNIQUE, 0,op,"Tell whom what?"); | | new_draw_info(NDI_UNIQUE, 0,op,"Tell whom what?"); |
return 1; | | return 1; |
} else if ( msg == NULL){ | | } else if ( msg == NULL){ |
sprintf(buf, "Tell %s what?", name); | | new_draw_info_format(NDI_UNIQUE, 0,op,"Tell %s what?", name); |
new_draw_info(NDI_UNIQUE, 0,op,buf); | | |
return 1; | | return 1; |
} | | } |
| | |
sprintf(buf,"%s tells you: ",op->name); | | snprintf(buf,MAX_BUF-1, "%s tells you: %s",op->name, msg); |
strncat(buf, msg, MAX_BUF-strlen(buf)-1); | | |
buf[MAX_BUF-1]=0; | | |
| | |
for(pl=first_player;pl!=NULL;pl=pl->next) | | for(pl=first_player;pl!=NULL;pl=pl->next) |
if(strncasecmp(pl->ob->name,name,MAX_NAME)==0) | | if(strncasecmp(pl->ob->name,name,MAX_NAME)==0) { |
{ | | |
new_draw_info(NDI_UNIQUE | NDI_ORANGE, 0, pl->ob, buf); | | new_draw_info(NDI_UNIQUE | NDI_ORANGE, 0, pl->ob, buf); |
sprintf(buf2, "You tell to %s: %s",name,msg); | | new_draw_info_format(NDI_UNIQUE | NDI_ORANGE, 0, op, |
new_draw_info(NDI_UNIQUE | NDI_ORANGE, 0, op, buf2); | | "You tell %s: %s", name, msg); |
| | |
/* Update last_tell value [mids 01/14/2002] */ | | /* Update last_tell value [mids 01/14/2002] */ |
strcpy(pl->last_tell, op->name); | | strcpy(pl->last_tell, op->name); |
| | |
| | |
/* Reply to last person who told you something [mids 01/14/2002] */ | | /* Reply to last person who told you something [mids 01/14/2002] */ |
int command_reply (object *op, char *params) { | | int command_reply (object *op, char *params) { |
char buf[MAX_BUF]; | | |
char buf2[MAX_BUF]; | | |
player *pl; | | player *pl; |
| | |
if (params == NULL) { | | if (params == NULL) { |
| | |
return 1; | | return 1; |
} | | } |
| | |
| | |
if (op->contr->last_tell[0] == '\0') { | | if (op->contr->last_tell[0] == '\0') { |
new_draw_info(NDI_UNIQUE, 0, op, "You can't reply to nobody."); | | new_draw_info(NDI_UNIQUE, 0, op, "You can't reply to nobody."); |
return 1; | | return 1; |
| | |
return 1; | | return 1; |
} | | } |
| | |
sprintf(buf, "%s tells you: ", op->name); | | |
strncat(buf, params, MAX_BUF-strlen(buf)-1); | | |
buf[MAX_BUF-1] = 0; | | |
| | |
/* Update last_tell value */ | | /* Update last_tell value */ |
strcpy(pl->last_tell, op->name); | | strcpy(pl->last_tell, op->name); |
| | |
new_draw_info(NDI_UNIQUE | NDI_ORANGE, 0, pl->ob, buf); | | new_draw_info_format(NDI_UNIQUE | NDI_ORANGE, 0, pl->ob, |
sprintf(buf2, "You tell to %s: %s", pl->ob->name, params); | | "%s tells you: %s", op->name, params); |
new_draw_info(NDI_UNIQUE | NDI_ORANGE, 0, op, buf2); | | new_draw_info_format(NDI_UNIQUE | NDI_ORANGE, 0, op, |
| | "You tell to %s: %s", pl->ob->name, params); |
return 1; | | return 1; |
} | | } |
| | |
| | |
return(0); | | return(0); |
}/*if self*/ | | }/*if self*/ |
}/*for*/ | | }/*for*/ |
sprintf(buf, "%s is not around.", params); | | new_draw_info_format(NDI_UNIQUE, 0, op, "%s is not around.", params); |
new_draw_info(NDI_UNIQUE, 0, op, buf); | | |
return(1); | | return(1); |
} /*else*/ | | } /*else*/ |
| | |