Mercurial > hg > batmud > maputils
changeset 290:33dfb99a19e4
Fixed label location adjusting.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 18 Jun 2007 05:03:32 +0000 |
parents | d1b07f8c27da |
children | b78d089a0cf4 |
files | mkloc.c |
diffstat | 1 files changed, 27 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/mkloc.c Mon Jun 18 05:03:06 2007 +0000 +++ b/mkloc.c Mon Jun 18 05:03:32 2007 +0000 @@ -533,6 +533,31 @@ } +int printType(FILE *outFile, locinfo_t *loc, BOOL doPrint) +{ + char *s = NULL; + + switch (loc->flags & LOCF_M_MASK) { + case LOCF_M_PCITY: s = "PCITY"; break; + case LOCF_M_CITY: s = "CITY"; break; + + default: + switch (loc->flags & LOCF_T_MASK) { + case LOCF_T_SHRINE: s = "SHRINE"; break; + case LOCF_T_GUILD: s = "GUILD"; break; + case LOCF_T_SS: s = "SS"; break; + } + } + + if (s) { + if (doPrint) + fprintf(outFile, "%s ", s); + return strlen(s) + 1; + } else + return 0; +} + + /* Adjust location label coordinates for the ASCII-CTRL map */ void adjustLocInfoCoords(mapblock_t *map, locations_t *l) @@ -543,10 +568,7 @@ int y, x0, x1, len; locinfo_t *tmp = l->locations[i]; - if ((tmp->flags & LOCF_M_MASK) == LOCF_M_PCITY) { - len = strlen(tmp->desc) + 6; - } else - len = strlen(tmp->desc); + len = printType(NULL, tmp, FALSE) + strlen(tmp->desc); /* Compute text location */ switch (tmp->dir) { @@ -588,30 +610,6 @@ } -int printType(FILE *outFile, locinfo_t *loc) -{ - char *s = NULL; - - switch (loc->flags & LOCF_M_MASK) { - case LOCF_M_PCITY: s = "PCITY"; break; - case LOCF_M_CITY: s = "CITY"; break; - - default: - switch (loc->flags & LOCF_T_MASK) { - case LOCF_T_SHRINE: s = "SHRINE"; break; - case LOCF_T_GUILD: s = "GUILD"; break; - case LOCF_T_SS: s = "SS"; break; - } - } - - if (s) { - fprintf(outFile, "%s ", s); - return strlen(s) + 1; - } else - return 0; -} - - /* Output the map with labels and location markers, etc. in * special ASCII-CTRL format understood by colormap utility. */ @@ -683,7 +681,7 @@ break; } - x += printType(outFile, tloc); + x += printType(outFile, tloc, TRUE); fputs(tloc->desc, outFile); fputc(0xfe, outFile);