From 00fab33aaffe6e7a39e2386f7e824f7bcbed6f05 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 25 Oct 2005 08:45:59 +0000 Subject: [PATCH] nachbesserung zu den letzten 2 commits --- src/common/kernel/item.c | 14 ++++++++------ src/common/kernel/item.h | 2 +- src/common/kernel/save.c | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index caa829384..2d83602e6 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -620,7 +620,6 @@ give_horses(const unit * s, const unit * d, const item_type * itype, int n, stru item_type * olditemtype[MAXITEMS+1]; resource_type * oldresourcetype[MAXRESOURCES+1]; -herb_type * oldherbtype[MAXHERBS+1]; luxury_type * oldluxurytype[MAXLUXURIES+1]; potion_type * oldpotiontype[MAXPOTIONS+1]; @@ -1327,7 +1326,6 @@ init_oldherbs(void) for (h=0;h!=MAXHERBS;++h) { item_type * itype; - terrain_t t; resource_type * rtype; names[0] = NULL; @@ -1348,13 +1346,17 @@ init_oldherbs(void) rtype = new_resourcetype(names, appearance, RTF_ITEM|RTF_POOLED); itype = new_itemtype(rtype, ITF_HERB, 0, 0); - t = (terrain_t)(h/3+1); - if (t>T_PLAIN) --t; - oldherbtype[h] = new_herbtype(itype, t); oldresourcetype[herb2res(h)] = rtype; } } +const resource_type * +newherbtype(herb_t h) +{ + return oldresourcetype[herb2res(h)]; +} + + static const char *potionnames[3][MAXPOTIONS] = { { @@ -1787,7 +1789,7 @@ init_oldpotions(void) con->materials = calloc(sizeof(requirement), i + 1); for (i=0;i!=MAXHERBSPERPOTION && potionherbs[p][i]!=NOHERB;++i) { #ifdef NO_OLD_ITEMS - con->materials[i].rtype = oldherbtype[potionherbs[p][i]]->itype->rtype; + con->materials[i].rtype = oldresourcetype[herb2res(potionherbs[p][i])]; #else con->materials[i].type = herb2res(potionherbs[p][i]); #endif diff --git a/src/common/kernel/item.h b/src/common/kernel/item.h index 5ca7e7f74..320aeafc1 100644 --- a/src/common/kernel/item.h +++ b/src/common/kernel/item.h @@ -139,6 +139,7 @@ typedef struct herb_type { terrain_t terrain; } herb_type; extern herb_type * herbtypes; +extern const resource_type * newherbtype(herb_t h); typedef struct potion_type { struct potion_type * next; @@ -451,7 +452,6 @@ extern struct luxury_type * oldluxurytype[]; extern struct potion_type * oldpotiontype[]; extern struct item_type * olditemtype[]; extern struct resource_type * oldresourcetype[]; -extern struct herb_type * oldherbtype[]; int get_item(const struct unit *, item_t); int set_item(struct unit *, item_t, int); diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index f82a47677..3d81a0b52 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -1199,7 +1199,7 @@ readunit(FILE * F) } while ((herb = (herb_t) ri(F)) >= 0) { - i_change(&u->items, oldherbtype[herb]->itype, ri(F)); + i_change(&u->items, newherbtype(herb)->itype, ri(F)); } } u->hp = ri(F); @@ -1440,7 +1440,7 @@ readregion(FILE * F, short x, short y) if (ter > T_GLACIER || ter == T_OCEAN) rsetherbtype(r, NULL); else - rsetherbtype(r, oldherbtype[(i-1)+3*(ter-1)]); + rsetherbtype(r, newherbtype((i-1)+3*(ter-1))->htype); rsetherbs(r, (short)ri(F)); } rsetpeasants(r, ri(F));