fix crashes in potion-descriptions (E3)

This commit is contained in:
Enno Rehling 2010-02-11 04:43:57 +00:00
parent ef60ac9ece
commit e6fcd984bc
2 changed files with 20 additions and 16 deletions

View File

@ -1505,12 +1505,10 @@ report_computer(const char * filename, report_context * ctx, const char * charse
} }
for (a=a_find(f->attribs, &at_showitem);a && a->type==&at_showitem;a=a->next) { for (a=a_find(f->attribs, &at_showitem);a && a->type==&at_showitem;a=a->next) {
const potion_type * ptype = resource2potion(((const item_type*)a->data.v)->rtype); const potion_type * ptype = resource2potion(((const item_type*)a->data.v)->rtype);
requirement * m;
const char * ch; const char * ch;
const char * description = NULL; const char * description = NULL;
if (ptype==NULL) continue; if (ptype==NULL) continue;
m = ptype->itype->construction->materials;
ch = resourcename(ptype->itype->rtype, 0); ch = resourcename(ptype->itype->rtype, 0);
fprintf(F, "TRANK %d\n", hashstring(ch)); fprintf(F, "TRANK %d\n", hashstring(ch));
fprintf(F, "\"%s\";Name\n", add_translation(ch, locale_string(f->locale, ch))); fprintf(F, "\"%s\";Name\n", add_translation(ch, locale_string(f->locale, ch)));
@ -1523,12 +1521,16 @@ report_computer(const char * filename, report_context * ctx, const char * charse
} }
fprintf(F, "\"%s\";Beschr\n", description); fprintf(F, "\"%s\";Beschr\n", description);
fprintf(F, "ZUTATEN\n"); if (ptype->itype->construction) {
requirement * m = ptype->itype->construction->materials;
while (m->number) { fprintf(F, "ZUTATEN\n");
ch = resourcename(m->rtype, 0);
fprintf(F, "\"%s\"\n", add_translation(ch, locale_string(f->locale, ch))); while (m->number) {
m++; ch = resourcename(m->rtype, 0);
fprintf(F, "\"%s\"\n", add_translation(ch, locale_string(f->locale, ch)));
m++;
}
} }
} }

View File

@ -2174,11 +2174,9 @@ report_plaintext(const char * filename, report_context * ctx, const char * chars
for (a=a_find(f->attribs, &at_showitem);a && a->type==&at_showitem;a=a->next) { for (a=a_find(f->attribs, &at_showitem);a && a->type==&at_showitem;a=a->next) {
const potion_type * ptype = resource2potion(((const item_type*)a->data.v)->rtype); const potion_type * ptype = resource2potion(((const item_type*)a->data.v)->rtype);
const char * description = NULL; const char * description = NULL;
requirement * m;
if (ptype!=NULL) { if (ptype!=NULL) {
const char * pname = resourcename(ptype->itype->rtype, 0); const char * pname = resourcename(ptype->itype->rtype, 0);
m = ptype->itype->construction->materials;
if (ch==0) { if (ch==0) {
rnl(F); rnl(F);
centre(F, LOC(f->locale, "section_newpotions"), true); centre(F, LOC(f->locale, "section_newpotions"), true);
@ -2195,13 +2193,17 @@ report_plaintext(const char * filename, report_context * ctx, const char * chars
size = sizeof(buf) - 1; size = sizeof(buf) - 1;
bytes = snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_herbsrequired")); bytes = snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_herbsrequired"));
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER(); if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
while (m->number) {
bytes = (int)strlcpy(bufp, LOC(f->locale, resourcename(m->rtype, 0)), size); if (ptype->itype->construction) {
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER(); requirement * m = ptype->itype->construction->materials;
++m; while (m->number) {
if (m->number) bytes = (int)strlcpy(bufp, LOC(f->locale, resourcename(m->rtype, 0)), size);
bytes = (int)strlcpy(bufp, ", ", size); if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER(); ++m;
if (m->number)
bytes = (int)strlcpy(bufp, ", ", size);
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
}
} }
*bufp = 0; *bufp = 0;
centre(F, buf, true); centre(F, buf, true);