bugfix init_oditems: if a resource was later in the list than one that used it, the game would crash

This commit is contained in:
Enno Rehling 2005-10-29 11:39:34 +00:00
parent 91da1f6e89
commit 43e44a083e
3 changed files with 46 additions and 41 deletions

View File

@ -20,10 +20,6 @@ extern "C" {
extern struct item_type it_hornofdancing; extern struct item_type it_hornofdancing;
extern struct item_type it_trappedairelemental; extern struct item_type it_trappedairelemental;
extern struct item_type it_aurapotion50;
extern struct item_type it_bagpipeoffear;
extern struct item_type it_instantartacademy;
extern struct item_type it_instantartsculpture;
extern void register_artrewards(void); extern void register_artrewards(void);

View File

@ -1112,7 +1112,6 @@ init_olditems(void)
for (i=0; i!=MAXITEMS; ++i) { for (i=0; i!=MAXITEMS; ++i) {
int iflags = ITF_NONE; int iflags = ITF_NONE;
int rflags = RTF_ITEM|RTF_POOLED; int rflags = RTF_ITEM|RTF_POOLED;
int m, n;
const char * name[2]; const char * name[2];
const char * appearance[2]; const char * appearance[2];
int weight = itemdata[i].gewicht; int weight = itemdata[i].gewicht;
@ -1120,33 +1119,7 @@ init_olditems(void)
int price; int price;
attrib * a; attrib * a;
item_type * itype; item_type * itype;
construction * con = calloc(sizeof(construction), 1);
con->minskill = itemdata[i].minskill;
if (i==I_LAEN && SkillCap(SK_QUARRYING)) {
/* at least 4 levels on which you can mine laen */
con->minskill = SkillCap(SK_QUARRYING)-3;
}
con->skill = itemdata[i].skill;
con->maxsize = -1;
con->reqsize = 1;
con->improvement = NULL;
for (m=0, n=0;m!=M_MAX_MAT;++m)
if (itemdata[i].material[m]>0) ++n;
if (n>0) {
con->materials = calloc(sizeof(requirement), n+1);
for (m=0, n=0;m!=M_MAX_MAT;++m) {
if (itemdata[i].material[m]>0) {
con->materials[n].rtype = oldresourcetype[matresource[m]];
con->materials[n].number = itemdata[i].material[m];
con->materials[n].recycle = 0.0;
++n;
if (m==M_EISEN) {
}
}
}
}
if (itemdata[i].flags & FL_ITEM_CURSED) iflags |= ITF_CURSED; if (itemdata[i].flags & FL_ITEM_CURSED) iflags |= ITF_CURSED;
if (itemdata[i].flags & FL_ITEM_NOTLOST) iflags |= ITF_NOTLOST; if (itemdata[i].flags & FL_ITEM_NOTLOST) iflags |= ITF_NOTLOST;
if (itemdata[i].flags & FL_ITEM_NOTINBAG) iflags |= ITF_BIG; if (itemdata[i].flags & FL_ITEM_NOTINBAG) iflags |= ITF_BIG;
@ -1217,10 +1190,43 @@ init_olditems(void)
if (itemdata[i].benutze_funktion) { if (itemdata[i].benutze_funktion) {
itype->use = use_olditem; itype->use = use_olditem;
} }
itype->construction = con;
olditemtype[i] = itype; olditemtype[i] = itype;
oldresourcetype[item2res(i)] = rtype; oldresourcetype[item2res(i)] = rtype;
} }
for (i=0; i!=MAXITEMS; ++i) {
construction * con = calloc(sizeof(construction), 1);
item_type * itype = olditemtype[i];
int m, n;
con->minskill = itemdata[i].minskill;
if (i==I_LAEN && SkillCap(SK_QUARRYING)) {
/* at least 4 levels on which you can mine laen */
con->minskill = SkillCap(SK_QUARRYING)-3;
}
con->skill = itemdata[i].skill;
con->maxsize = -1;
con->reqsize = 1;
con->improvement = NULL;
for (m=0, n=0;m!=M_MAX_MAT;++m)
if (itemdata[i].material[m]>0) ++n;
if (n>0) {
con->materials = calloc(sizeof(requirement), n+1);
for (m=0, n=0;m!=M_MAX_MAT;++m) {
if (itemdata[i].material[m]>0) {
assert(oldresourcetype[matresource[m]]);
con->materials[n].rtype = oldresourcetype[matresource[m]];
con->materials[n].number = itemdata[i].material[m];
con->materials[n].recycle = 0.0;
++n;
if (m==M_EISEN) {
}
}
}
}
itype->construction = con;
}
} }
static const char *potiontext[MAXPOTIONS] = static const char *potiontext[MAXPOTIONS] =

View File

@ -589,6 +589,9 @@
<string name="iceberg_trail"> <string name="iceberg_trail">
<text locale="de">der Eisberg von %s</text> <text locale="de">der Eisberg von %s</text>
</string> </string>
<string name="iceberg_sleep_trail">
<text locale="de">der Gletscher von %s</text>
</string>
<string name="thickfog_trail"> <string name="thickfog_trail">
<text locale="de">%s</text> <text locale="de">%s</text>
</string> </string>