Coloured Prefixes by Blimey This patch implements coloured prefixes. It works by automatically appending the character sequence "^N" to the end of any newly entered prefix which contains the wand character '^'. A bug in the original implementation of the prefix command meant that there were an extra two characters storage space available, which is adequate to accommodate the extra "^N". Prefixes can be just as long as they originally were. You do not need to perform any conversion of existing player files. Thanks to James Antill for bug reports. To install: 1. Remove everything in this file up to and including ==here== 2. Save it in the src directory 3. Use patch -p0 < filename to install 4. Recompile ==here== --- commands.orig Wed Aug 1 20:02:20 2001 +++ commands.c Thu Aug 2 21:09:00 2001 @@ -563,6 +563,16 @@ "...\n%s %s\n", p->name, p->title); } +int dangle(char * str) +{ + int result = 0, i; + if (str) + for (i = strlen(str) - 1; i >= 0 && str[i] == '^'; i--) + result++; + return result; +} + + void set_pretitle(player * p, char *str) { char *oldstack, *scan; @@ -582,10 +592,6 @@ { switch (*scan) { - case '^': - tell_player(p, " You may not have colors in your prefix.\n"); - return; - break; case '&': tell_player(p, " You may not have dynatext in your prefix.\n"); return; @@ -607,7 +613,21 @@ "for a prefix.\n"); return; } - strncpy(p->pretitle, str, MAX_PRETITLE - 3); + strncpy(p->pretitle, str, MAX_PRETITLE - 1); + /* blimey's kludge to allow wands in prefixes */ + if (strchr(p->pretitle, '^')) + { + if (strlen(p->pretitle) >= MAX_PRETITLE - 2) + { + p->pretitle[MAX_PRETITLE - 1] = '\0'; + p->pretitle[MAX_PRETITLE - 2] = '\0'; + p->pretitle[MAX_PRETITLE - 3] = '\0'; + if (dangle(p->pretitle) % 2) + p->pretitle[MAX_PRETITLE - 4] = '\0'; + } + strcat(p->pretitle, "^N"); + } + /* end of kludge */ sprintf(stack, " You change your prefix so you become: %s %s\n", p->pretitle, p->name); stack = end_string(stack);