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,6 +1521,9 @@ report_computer(const char * filename, report_context * ctx, const char * charse
} }
fprintf(F, "\"%s\";Beschr\n", description); fprintf(F, "\"%s\";Beschr\n", description);
if (ptype->itype->construction) {
requirement * m = ptype->itype->construction->materials;
fprintf(F, "ZUTATEN\n"); fprintf(F, "ZUTATEN\n");
while (m->number) { while (m->number) {
@ -1531,6 +1532,7 @@ report_computer(const char * filename, report_context * ctx, const char * charse
m++; m++;
} }
} }
}
/* traverse all regions */ /* traverse all regions */
for (r=ctx->first;sr==NULL && r!=ctx->last;r=r->next) { for (r=ctx->first;sr==NULL && r!=ctx->last;r=r->next) {

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,6 +2193,9 @@ 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();
if (ptype->itype->construction) {
requirement * m = ptype->itype->construction->materials;
while (m->number) { while (m->number) {
bytes = (int)strlcpy(bufp, LOC(f->locale, resourcename(m->rtype, 0)), size); bytes = (int)strlcpy(bufp, LOC(f->locale, resourcename(m->rtype, 0)), size);
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER(); if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
@ -2203,6 +2204,7 @@ report_plaintext(const char * filename, report_context * ctx, const char * chars
bytes = (int)strlcpy(bufp, ", ", size); bytes = (int)strlcpy(bufp, ", ", size);
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER(); if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
} }
}
*bufp = 0; *bufp = 0;
centre(F, buf, true); centre(F, buf, true);
rnl(F); rnl(F);