diff --git a/src/economy.c b/src/economy.c index a3b300788..248344e47 100644 --- a/src/economy.c +++ b/src/economy.c @@ -2130,7 +2130,7 @@ static void planttrees(unit * u, int raw) } /* Mallornb�ume kann man nur in Mallornregionen z�chten */ - rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORNSEED : R_SEED); + rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORN_SEED : R_SEED); /* Skill pr�fen */ skill = effskill(u, SK_HERBALISM, 0); @@ -2195,7 +2195,7 @@ static void breedtrees(unit * u, int raw) } /* Mallornb�ume kann man nur in Mallornregionen z�chten */ - rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORNSEED : R_SEED); + rtype = get_resourcetype(fval(r, RF_MALLORN) ? R_MALLORN_SEED : R_SEED); /* Skill pr�fen */ skill = effskill(u, SK_HERBALISM, 0); @@ -2313,7 +2313,7 @@ static void breed_cmd(unit * u, struct order *ord) default: if (p != P_ANY) { rtype = findresourcetype(s, u->faction->locale); - if (rtype == get_resourcetype(R_SEED) || rtype == get_resourcetype(R_MALLORNSEED)) { + if (rtype == get_resourcetype(R_SEED) || rtype == get_resourcetype(R_MALLORN_SEED)) { breedtrees(u, m); break; } diff --git a/src/kernel/item.c b/src/kernel/item.c index 6e64c147f..58e3326a2 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -614,25 +614,24 @@ struct order *ord) #define R_MINHERB R_PLAIN_1 #define R_MINPOTION R_FAST #define R_MINITEM R_IRON -#define MAXITEMS MAX_ITEMS -#define MAXRESOURCES MAX_RESOURCES -#define MAXHERBS MAX_HERBS -#define MAXPOTIONS MAX_POTIONS #define MAXHERBSPERPOTION 6 -const potion_type *oldpotiontype[MAXPOTIONS + 1]; +const potion_type *oldpotiontype[MAX_POTIONS + 1]; /*** alte items ***/ static const char *resourcenames[MAX_RESOURCES] = { + "money", "aura", "permaura", + "hp", "peasant", "person", + "sapling", "mallornsapling", + "tree", "mallorntree", + "seed", "mallornseed", "iron", "stone", "horse", "ao_healing", "aots", "roi", "rop", "ao_chastity", "laen", "fairyboot", "aoc", "pegasus", "elvenhorse", "charger", "dolphin", "roqf", "trollbelt", "aurafocus", "sphereofinv", "magicbag", - "magicherbbag", "dreameye", "p2", "seed", "mallornseed", - "money", "aura", "permaura", - "hp", "peasant", "person" + "magicherbbag", "dreameye", "p2" }; const resource_type *get_resourcetype(resource_t type) { @@ -966,7 +965,7 @@ static void init_oldpotions(void) }; int p; - for (p = 0; p != MAXPOTIONS; ++p) { + for (p = 0; p != MAX_POTIONS; ++p) { item_type *itype = it_find(potionnames[p]); if (itype != NULL) { oldpotiontype[p] = itype->rtype->ptype; @@ -978,6 +977,11 @@ void init_resources(void) { resource_type *rtype; + /* there are resources that are special and must be hard-coded. + * these are not items, but things like trees or hitpoints + * which can be used in a construction recipe or as a spell ingredient. + */ + rt_get_or_create(resourcenames[R_PERSON]); /* lousy hack */ rtype = rt_get_or_create(resourcenames[R_PEASANT]); diff --git a/src/kernel/item.h b/src/kernel/item.h index c1ac38517..c08c676be 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -252,8 +252,27 @@ extern "C" { variant magres, int prot, unsigned int flags); potion_type *new_potiontype(item_type * itype, int level); + + /* these constants are used with get_resourcetype. + * The order of the enum is not important for stored data. + * The resourcenames array must be updated to match. + */ + typedef enum { + /* SPECIAL */ + R_SILVER, + R_AURA, /* Aura */ + R_PERMAURA, /* Permanente Aura */ + R_LIFE, + R_PEASANT, + R_PERSON, + R_SAPLING, + R_MALLORN_SAPLING, + R_TREE, + R_MALLORN_TREE, /* ITEMS: */ + R_SEED, + R_MALLORN_SEED, R_IRON, R_STONE, R_HORSE, @@ -277,15 +296,7 @@ extern "C" { R_SACK_OF_CONSERVATION, R_TACTICCRYSTAL, R_WATER_OF_LIFE, - R_SEED, - R_MALLORNSEED, /* SONSTIGE */ - R_SILVER, - R_AURA, /* Aura */ - R_PERMAURA, /* Permanente Aura */ - R_LIFE, - R_PEASANT, - R_PERSON, MAX_RESOURCES, /* do not use outside item.c ! */ NORESOURCE = -1 diff --git a/src/modules/arena.c b/src/modules/arena.c index fbc3f0673..aada12234 100644 --- a/src/modules/arena.c +++ b/src/modules/arena.c @@ -149,7 +149,7 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord) assert(!"not implemented"); /* - for (res=0;res!=MAXRESOURCES;++res) if (res!=R_SILVER && res!=R_ARENA_GATE && (is_item(res) || is_herb(res) || is_potion(res))) { + for (res=0;res!=MAX_RESOURCES;++res) if (res!=R_SILVER && res!=R_ARENA_GATE && (is_item(res) || is_herb(res) || is_potion(res))) { int x = get_resource(u, res); if (x) { if (u2) {