do_commands is showing corrupted info when the wizhelp subcommand is used with a mortal as its argument.
It doesn't appear to be an issue with do_commands itself, it seems to be an issue with the string being passed to column_list already having info in it when it is being substantiated. When you use social or commands, the pre-existing information in the string is being overwritten and thus hidden from view, but because mortals don't have any access to immortal commands, nothing is being added to the string when wizhelp is called as the subcommand so it's showing whatever content it had still stored in it.
On a brand new character wizhelp <name> shows nothing.
If the mortal uses the socials or commands, commands, then wizhelp <mortal> then shows you the info they most recently saw. If however the mortals most recent commands were something entirely different then it often shows corrupted nonsensical info, such as the name of mobs from zones the mortal has never been to, or random characters.
Code:
ACMD(do_commands)
{
int no, i, cmd_num;
int wizhelp = 0, socials = 0;
struct char_data *vict;
char arg[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
const char *commands[1000];
int overflow = sizeof(commands) / sizeof(commands[0]);
if (!ch->desc)
return;
one_argument(argument, arg);
if (*arg) {
if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_WORLD)) || IS_NPC(vict)) {
send_to_char(ch, "Who is that?\r\n");
return;
}
} else
vict = ch;
if (subcmd == SCMD_SOCIALS)
socials = 1;
else if (subcmd == SCMD_WIZHELP)
wizhelp = 1;
sprintf(buf, "The following %s%s are available to %s:\r\n",
wizhelp ? "privileged " : "",
socials ? "socials" : "commands",
vict == ch ? "you" : GET_NAME(vict));
/* cmd_num starts at 1, not 0, to remove 'RESERVED' */
for (no = 0, cmd_num = 1;
complete_cmd_info[cmd_sort_info[cmd_num]].command[0] != '\n';
++cmd_num) {
i = cmd_sort_info[cmd_num];
if (complete_cmd_info[i].minimum_level < 0 || GET_LEVEL(vict) < complete_cmd_info[i].minimum_level)
continue;
if ((complete_cmd_info[i].minimum_level >= LVL_IMMORT) != wizhelp)
continue;
if (!wizhelp && socials != (complete_cmd_info[i].command_pointer == do_action))
continue;
if (wizhelp && complete_cmd_info[i].command_pointer == do_action)
continue;
if (--overflow < 0)
continue;
/* matching command: copy to commands list */
commands[no++] = complete_cmd_info[i].command;
}
/* display commands list in a nice columnized format */
column_list(ch, 0, commands, no, FALSE);
}
The only issue I see with do_commands itself is there's a completely useless buf char created, that has info put inside of it, but is never actually sent anywhere. I'd just remove the buf and send the string via send_to_char, but that part really isn't important as it's not related to the corrupted info winding up inside of commands.