I tried to write a color parser similar to something that Wheel of Fish posted awhile ago (which I seem to have lost), anyway it would enable players to add color to their input (as well as Mud text files). An example would be '%1Hello%0 would print Sean says Hello -- the Hello being in red. Anyway what happens is that NO output gets printed whatsoever!! Nothing. The player can only see what he or she types, no room descriptions, not even the passwd prompt once you enter your name!! Here is the code, any help would greatly be appreciated: char *get_rid_of_that_damn_color(unsigned char *src) { char *dest; static char string[LARGE_BUFSIZE + GARBAGE_SPACE]; dest = string; while (*src != 0) { if (*src != '%') *dest++ = *src++; else if ((*(src - 1) == '%') && (*src == '%')) *dest++ = *src++; else src++; } strcpy((char *) dest, "\033[0m\0"); return(dest); } char *parse_color(struct char_data *ch, unsigned char *src) { char *dest; static char string[LARGE_BUFSIZE + GARBAGE_SPACE]; int changed = 0; dest = string; if (ch == NULL) return(src); while (*src != 0) { if (!PRF_FLAGGED(ch, PRF_COLOR_1)) return(get_rid_of_that_damn_color(src)); else if (!PRF_FLAGGED(ch, PRF_COLOR_2)) return(get_rid_of_that_damn_color(src)); else if (!PRF_FLAGGED(ch, PRF_ANSI)) return(get_rid_of_that_damn_color(src)); else { /* for those who have color */ if (*src != '%') *dest++ = *src++; else { /* src == % */ src++; switch (*src) { case '%': /* %% - print the % character */ *dest++ = '%'; break; case '0': case 'n': case 'N': sprintf(dest, "%s%s", dest, KNRM); changed = 1; break; case 'B': case 'b': sprintf(dest, "%s%s", dest, MOD_BOLD); changed = 1; break; case 'F': case 'f': sprintf(dest, "%s%s", dest, MOD_BLINK); changed = 1; break; /* not used in ansi that I know of */ case 'U': case 'u': sprintf(dest, "%s%s", dest, MOD_UNDERLINE); changed = 1; break; case 'I': case 'i': sprintf(dest, "%s%s", dest, MOD_REVERSE); changed = 1; break; case '1': sprintf(dest, "%s%s", dest, KRED); changed = 1; break; case '2': sprintf(dest, "%s%s", dest, KGRN); changed = 1; break; case '3': sprintf(dest, "%s%s", dest, KGLD); changed = 1; break; case '4': sprintf(dest, "%s%s", dest, KBLU); changed = 1; break; case '5': sprintf(dest, "%s%s", dest, KCYN); changed = 1; break; case '6': sprintf(dest, "%s%s", dest, KMAG); changed = 1; break; case '7': sprintf(dest, "%s%s", dest, KWHT); changed = 1; break; default: sprintf(dest, "%s%s", dest, KNRM); changed = 1; break; } src++; changed = 1; } } } if (changed == 1) strcat(dest, KNRM); strcat(dest, "\0"); return(dest); } Many thanks in advance, - Sean Sean Mountcastle ---------------- Have you ever noticed that the people who are always trying to tell you, "There's a time for work and a time for play," never find the time for play?
This archive was generated by hypermail 2b30 : 12/18/00 PST