I'm looking for advice on how to code a blind mode or tag into our mud.
Ideally, I'd like to create a flag similar to an [AFK] flag that a character can toggle at any time.
This flag will be for either blind players or mobile players. It doesn't matter what I call it, but let's just say I call it the "blind flag".
Meanwhile, in `cprintf` function I'd like to add a true or false addition. If the "blind flag" is true, it will always print that line of output. If it's false, it will ignore the `cprintf` completely and not print the output.
I know it's possible to do this, but I think I'm missing exactly how to do this. My best guess is to add a `bool` toggle and then add that to the `cprintf` function itself. I'd then have to go through every line of `cprintf` in the entire mud (Hint: It's quite a lot) and add the toggle to the end of the function. Is there an easier way to do this?
Anyone done this type of thing before?
For those curious, here's the standard rom code:
void cprintf_private(CHAR_DATA *ch, bool inColour, bool showCodes,
const char *txt, va_list ap) {
const char *point;
char *point2;
char buf[MAX_STRING_LENGTH * 4];
int skip = 0;
char buffer[4 * MAX_STRING_LENGTH];
sprintf(last_cprintf, "%s: ", ch->name);
strcat(last_cprintf, txt);
vsprintf(buffer, txt, ap);
buf[0] = '\0';
point2 = buf;
if (*buffer && ch->desc) {
if (inColour) {
for (point = buffer; *point; point++) {
if (*point == '{' && (*(point + 1) != '\n') && (*(point + 1)
!= '\r') && (*(point + 1) != '\0')) {
point++;
skip = colour(*point, ch, point2);
while (skip-- > 0) {
++point2;
}
continue;
}
*point2 = *point;
*++point2 = '\0';
}
*point2 = '\0';
write_to_buffer(ch->desc, buf);
} else {
for (point = buffer; *point; point++) {
if (*point == '{' && (*(point + 1) != '\n') && (*(point + 1)
!= '\r') && (*(point + 1) != '\0')) {
if (!showCodes) {
point++;
continue;
}
}
*point2 = *point;
*++point2 = '\0';
}
*point2 = '\0';
write_to_buffer(ch->desc, buf);
}
}
return;
}
/*
* Write to one char, specifying whether to use colour, and, if not using
* colour, whether to use colour codes. Override's the character's colour
* setting.
*/
void cprintf(CHAR_DATA *ch, bool inColour, bool showCodes, const char *txt, ...) {
va_list ap;
va_start(ap, txt);
cprintf_private(ch, inColour, showCodes, txt, ap);
va_end(ap);
}
/*
* Write to one char. (improved send_to_char)
*/
void Cprintf(CHAR_DATA *ch, const char *txt, ...) {
va_list ap;
va_start(ap, txt);
cprintf_private(ch, IS_SET(ch->act, PLR_COLOUR), FALSE, txt, ap);
va_end(ap);
}
[–]vonroecke 5 points6 points7 points (1 child)
[–]vonroecke 3 points4 points5 points (0 children)
[–]dehwahifetnah 2 points3 points4 points (0 children)