Quote Axanon:
Easily enough, I change ... "%s\r\n" ... to ... "@G%s@n\r\n" ... and continue on, finding similar lines in the same area and do the same. Now, my problem is that not everything seems to be handled the same way. With the person using the social (with no arguments supplied), a message shows in green as expected. Everybody else in the room sees it in grey (@n/NRM) though. Socials with a target supplied show in (@n/NRM) in all instances.
Can somebody tell me where else I need to add colour codes for all instances of social commands?? I don't know what I am looking for exactly. Thanks.
You are looking in the right place, but need to change all outputs, not just those for the player. First, open db.c and find the first function, fread_action():
char *fread_action(FILE *fl, int nr)
{
- char buf[MAX_STRING_LENGTH];
+ char buf[MAX_STRING_LENGTH-10];
char *buf1;
- buf1 = fgets(buf, MAX_STRING_LENGTH, fl);
+ buf1 = fgets(buf, MAX_STRING_LENGTH-10, fl);
if (feof(fl)) {
log("SYSERR: fread_action: unexpected EOF near action #%d", nr);
/* SYSERR_DESC: fread_action() will fail if it discovers an end of file
* marker before it is able to read in the expected string. This can be
* caused by a truncated socials file. */
exit(1);
}
if (*buf == '#')
return (NULL);
...
You should have no problems with this change - no socials are anywhere near 48k in length. This is just to ensure consistency, so snprintf below will work as expected every time.
Next, go to act.social.c, and the function you are quoting from ACMD(do_action):
ACMD(do_action)
{
- char arg[MAX_INPUT_LENGTH], part[MAX_INPUT_LENGTH];
+ char arg[MAX_INPUT_LENGTH], part[MAX_INPUT_LENGTH], message[MAX_STRING_LENGTH];
int act_nr;
struct social_messg *action;
struct char_data *vict;
struct obj_data *targ;
if ((act_nr = find_action(cmd)) < 0) {
send_to_char(ch, "That action is not supported.\r\n");
return;
}
action = &soc_mess_list[act_nr];
if (!argument || !*argument) {
- send_to_char(ch, "%s\r\n", action->char_no_arg);
+ send_to_char(ch, "@G%s@n\r\n", action->char_no_arg);
- act(action->others_no_arg, action->hide, ch, 0, 0, TO_ROOM);
+ snprintf(message, MAX_STRING_LENGTH, "@G%s@n", action->others_no_arg);
+ act(message, action->hide, ch, 0, 0, TO_ROOM);
return;
}
two_arguments(argument, arg, part);
...
Similarly, you change later calls to act(something, ...) to snprintf(message, MAX_STRING_LENGTH, "@G%s@n", something); act(message, ...) throughout the function.
(lines with - are removed, lines with + are added)