Mercurial > hg > batmud > maputils
changeset 963:fb6b2170a6e7
Loc file parsing was segfaulting due to the new changes, fixed.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 12 Jun 2010 00:23:27 +0000 |
parents | 432549cf67a6 |
children | cea0da0a0787 |
files | mkloc.c |
diffstat | 1 files changed, 25 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/mkloc.c Sat Jun 12 00:22:44 2010 +0000 +++ b/mkloc.c Sat Jun 12 00:23:27 2010 +0000 @@ -109,7 +109,7 @@ tm_t added; BOOL addedValid; int nnames, ncoders; - locname_t *names[LOC_MAX_NAMES], *coders[LOC_MAX_NAMES]; + locname_t names[LOC_MAX_NAMES], coders[LOC_MAX_NAMES]; char *uri, *freeform; fileinfo_t *file; } marker_t; @@ -373,7 +373,7 @@ } } -void addLocName(locname_t **dst, int *ndst, char **src, const int nsrc) +void addLocName(locname_t *dst, int *ndst, char *src[], const int nsrc) { if (src != NULL && src[nsrc] != NULL) { int flags = 0; @@ -383,8 +383,8 @@ case '!': n++; flags |= NAME_RECODER; break; case '%': n++; flags |= NAME_MAINTAINER; break; } - dst[*ndst]->name = th_strdup(src[nsrc] + n); - dst[*ndst]->flags = flags; + dst[*ndst].name = th_strdup(&src[nsrc][n]); + dst[*ndst].flags = flags; (*ndst)++; } } @@ -1029,7 +1029,7 @@ int y, x0, x1, len; marker_t *tmp = l->locations[i]; - len = strlen(tmp->names[0]->name); + len = strlen(tmp->names[0].name); if (optLabelType) len += printLocType(NULL, tmp, FALSE); /* Compute text location */ @@ -1118,7 +1118,7 @@ tmpl = worldLoc->locations[n]; tmpFlags = LOCF_M_PCITY | LOCF_INVIS; snprintf(tmpDesc, sizeof(tmpDesc), - "%s", tmpl->names[0]->name); + "%s", tmpl->names[0].name); } else { numNewLoc++; @@ -1171,8 +1171,8 @@ { marker_t *vp1 = *(marker_t **) p1, *vp2 = *(marker_t **) p2; - if (vp1->names[0]->name && vp2->names[0]->name) - return strcmp(vp1->names[0]->name, vp2->names[0]->name); + if (vp1->names[0].name && vp2->names[0].name) + return strcmp(vp1->names[0].name, vp2->names[0].name); else return 0; } @@ -1261,11 +1261,11 @@ x += printLocType(outFile, tmp, TRUE); } - fputs(tmp->names[0]->name, outFile); + fputs(tmp->names[0].name, outFile); fputc(0xfe, outFile); if (!optNoAdjust) - x += strlen(tmp->names[0]->name) - 1; + x += strlen(tmp->names[0].name) - 1; else fputc(d[(map->w * y) + x], outFile); } else { @@ -1294,7 +1294,7 @@ if ((tmp->flags & LOCF_INVIS) == 0) { fprintf(outFile, "<option value=\"loc%d_%d\">", tmp->ox, tmp->oy); printLocType(outFile, tmp, TRUE); - fprinte(outFile, tmp->names[0]->name); + fprinte(outFile, tmp->names[0].name); fprintf(outFile, "</option>\n"); } } @@ -1344,7 +1344,7 @@ if (s) { fprintf(outFile, "\n# %s #%d: %s\n", - s, i, tmp->names[0]->name); + s, i, tmp->names[0].name); } } @@ -1374,18 +1374,18 @@ fputc('-', outFile); fprintf(outFile, "\t;"); - printLocNameEsc(outFile, tmp->names[0]); + printLocNameEsc(outFile, &tmp->names[0]); for (n = 1; n < tmp->nnames; n++) { fprintf(outFile, "|"); - printLocNameEsc(outFile, tmp->names[n]); + printLocNameEsc(outFile, &tmp->names[n]); } fprintf(outFile, ";"); if (tmp->ncoders > 0) { - printLocNameEsc(outFile, tmp->coders[0]); + printLocNameEsc(outFile, &tmp->coders[0]); for (n = 1; n < tmp->ncoders; n++) { fprintf(outFile, ","); - printLocNameEsc(outFile, tmp->coders[n]); + printLocNameEsc(outFile, &tmp->coders[n]); } } @@ -1434,7 +1434,7 @@ /* Is location visible? */ if ((tmp->flags & LOCF_INVIS) == 0) { - leftMove = ((float) strlen(tmp->names[0]->name)) * optFontScale; + leftMove = ((float) strlen(tmp->names[0].name)) * optFontScale; switch (tmp->dir) { case LOCD_LEFTDOWN: @@ -1502,7 +1502,7 @@ fprintf(outFile, "-fill %s -box '#00000080' -draw \"text %d,%d '", cs, x, y); - fprintEsc1(outFile, tmp->names[0]->name); + fprintEsc1(outFile, tmp->names[0].name); fprintf(outFile, "'\" "); } @@ -1578,7 +1578,7 @@ fprintf(outFile, "%d,%d,", tmp->x, tmp->y); printLocType(outFile, tmp, TRUE); - fprintf(outFile, "%s\n", tmp->names[0]->name); + fprintf(outFile, "%s\n", tmp->names[0].name); } } @@ -1603,7 +1603,7 @@ tmp->ox, tmp->oy, tmp->dir); /* Location name */ - str = (tmp->names[0]->name != NULL) ? tmp->names[0]->name : "UNKNOWN"; + str = (tmp->names[0].name != NULL) ? tmp->names[0].name : "UNKNOWN"; printLocType(outFile, tmp, TRUE); fprinte(outFile, str); fprintf(outFile, "\" html=\""); @@ -1616,8 +1616,8 @@ if (tmp->nnames > 1) { fprinte(outFile, "Also known as <i>"); for (n = 1; n < tmp->nnames; n++) { - fprinte(outFile, tmp->names[n]->name); - if (tmp->names[n]->flags & NAME_ORIG) + fprinte(outFile, tmp->names[n].name); + if (tmp->names[n].flags & NAME_ORIG) fprintf(outFile, " (*)"); if (n < tmp->nnames - 1) fprinte(outFile, " ; "); @@ -1636,7 +1636,7 @@ if (tmp->flags & LOCF_M_PCITY) { fprinte(outFile, "Societies: "); for (n = 0; n < tmp->ncoders; n++) { - fprinte(outFile, tmp->coders[n]->name); + fprinte(outFile, tmp->coders[n].name); if (n < tmp->ncoders - 1) fprinte(outFile, ", "); } @@ -1644,13 +1644,13 @@ fprinte(outFile, "Coders: "); for (n = 0; n < tmp->ncoders; n++) { char *info = ""; - switch (tmp->coders[n]->flags) { + switch (tmp->coders[n].flags) { case NAME_ORIG: info = " (O)"; break; case NAME_RECODER: info = " (R)"; break; case NAME_MAINTAINER: info = " (M)"; break; } fprintfe(outFile, "<a target=\"_blank\" href=\"http://www.bat.org/char/%s\">%s%s</a>", - tmp->coders[n]->name, tmp->coders[n]->name, info); + tmp->coders[n].name, tmp->coders[n].name, info); if (n < tmp->ncoders - 1) fprinte(outFile, ", "); }