diff --git a/src/common/attributes/giveitem.c b/src/common/attributes/giveitem.c index 7cc19b90d..8c992280d 100644 --- a/src/common/attributes/giveitem.c +++ b/src/common/attributes/giveitem.c @@ -56,8 +56,6 @@ a_readgive(attrib * a, FILE * F) variant var; char zText[32]; - if (global.data_versionbuilding = findbuilding(var.i); diff --git a/src/common/items/demonseye.c b/src/common/items/demonseye.c index db9b092c1..78622865f 100644 --- a/src/common/items/demonseye.c +++ b/src/common/items/demonseye.c @@ -45,15 +45,7 @@ summon_igjarjuk(struct unit * u, const struct item_type * itype, int amount, str } } -static resource_type rt_demonseye = { - { "ao_daemon", "ao_daemon_p" }, - { "ao_daemon", "ao_daemon_p" }, - RTF_ITEM, - &res_changeitem -}; - - -boolean +static boolean give_igjarjuk(const struct unit * src, const struct unit * d, const struct item_type * itype, int n, struct order * ord) { sprintf(buf, "Eine höhere Macht hindert %s daran, das Objekt zu übergeben. " @@ -62,19 +54,9 @@ give_igjarjuk(const struct unit * src, const struct unit * d, const struct item_ return false; } -item_type it_demonseye = { - &rt_demonseye, /* resourcetype */ - ITF_NOTLOST|ITF_CURSED, 0, 0, /* flags, weight, capacity */ - NULL, /* construction */ - &summon_igjarjuk, - NULL, - &give_igjarjuk -}; - void register_demonseye(void) { - it_register(&it_demonseye); register_function((pf_generic)summon_igjarjuk, "useigjarjuk"); register_function((pf_generic)give_igjarjuk, "giveigjarjuk"); } diff --git a/src/common/items/demonseye.h b/src/common/items/demonseye.h index b196ad971..a63369f67 100644 --- a/src/common/items/demonseye.h +++ b/src/common/items/demonseye.h @@ -18,10 +18,7 @@ extern "C" { #endif -extern struct item_type it_demonseye; - extern void register_demonseye(void); -extern boolean give_igjarjuk(const struct unit *, const struct unit *, const struct item_type *, int, struct order *); #ifdef __cplusplus } diff --git a/src/common/kernel/alchemy.c b/src/common/kernel/alchemy.c index 476f42907..bbf5900b8 100644 --- a/src/common/kernel/alchemy.c +++ b/src/common/kernel/alchemy.c @@ -176,19 +176,9 @@ a_readeffect(attrib *a, FILE *f) int power; const potion_type * ptype; effect_data * edata = (effect_data*)a->data.v; - if (global.data_version < ITEMTYPE_VERSION) { - union { - int i; - short sa[2]; - } data; - fscanf(f, "%d", &data.i); - ptype = oldpotiontype[data.sa[0]]; - power = data.sa[1]; - } else { - char zText[32]; - fscanf(f, "%s %d", zText, &power); - ptype = pt_find(zText); - } + char zText[32]; + fscanf(f, "%s %d", zText, &power); + ptype = pt_find(zText); if (ptype==NULL || power<=0) return AT_READ_FAIL; edata->type = ptype; edata->value = power; diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index 3c94347c5..8bdb8accd 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -2811,6 +2811,13 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack) const group * g = NULL; const attrib *a = a_find(u->attribs, &at_otherfaction); const faction *stealthfaction = a?get_otherfaction(a):NULL; + static const struct item_type * it_demonseye; + static boolean init = false; + + if (!init) { + it_demonseye = it_find("demonseye"); + init=true; + } if (fval(u, UFL_GROUP)) { const attrib * agroup = a_find(u->attribs, &at_group); @@ -2986,7 +2993,7 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack) } } - if (i_get(u->items, &it_demonseye)) { + if (it_demonseye && i_get(u->items, it_demonseye)) { char lbuf[80]; const char * s = LOC(default_locale, rc_name(u->race, 3)); char * c = lbuf; diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index 91bd0278b..ccf14dc31 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -599,8 +599,6 @@ give_horses(const unit * s, const unit * d, const item_type * itype, int n, stru #define MAXLUXURIES (LASTLUXURY - FIRSTLUXURY) #define item2res(itm) (resource_t)(itm+R_MINITEM) -#define herb2res(itm) (resource_t)(itm+R_MINHERB) -#define potion2res(itm) (resource_t)(itm+R_MINPOTION) item_type * olditemtype[MAXITEMS+1]; resource_type * oldresourcetype[MAXRESOURCES+1]; @@ -1225,12 +1223,6 @@ init_olditems(void) } } -const item_type * -oldherbtype(herb_t h) -{ - return oldresourcetype[herb2res(h)]->itype; -} - static const char *potiontext[MAXPOTIONS] = { /* Stufe 1: */ diff --git a/src/common/kernel/item.h b/src/common/kernel/item.h index ed8d3381a..e3589b7ec 100644 --- a/src/common/kernel/item.h +++ b/src/common/kernel/item.h @@ -214,11 +214,6 @@ extern const weapon_type * resource2weapon(const resource_type * i); extern const potion_type * resource2potion(const resource_type * i); extern const luxury_type * resource2luxury(const resource_type * i); -#define weapon2resource(x) ((x)->itype->rtype) -#define luxury2resource(x) ((x)->itype->rtype) -#define herb2resource(x) ((x)->itype->rtype) -#define potion2resource(x) ((x)->itype->rtype) - extern item ** i_find(item ** pi, const item_type * it); extern item * i_add(item ** pi, item * it); extern void i_merge(item ** pi, item ** si); @@ -239,8 +234,6 @@ extern weapon_type * new_weapontype(item_type * itype, int wflags, double magres extern armor_type * new_armortype(item_type * itype, double penalty, double magres, int prot, unsigned int flags); extern potion_type * new_potiontype(item_type * itype, int level); -extern const item_type * oldherbtype(herb_t h); - /* for lack of another file: */ /* sonstige resourcen */ @@ -379,48 +372,7 @@ enum { R_SACK_OF_CONSERVATION, /* POTIONS: */ - R_FAST, - R_STRONG, R_TREES, - R_DOMORE, - R_UGLY, -#ifdef INSECT_POTION - R_WARMTH, -#else - R_STEEL, -#endif - R_WISE, - R_FOOL, - R_ROSE, - R_HORSEPOTION, - R_BERSERK, - R_PEOPLE, - R_GRASS, - R_ILL, - R_HEAL, - - /* HERBS */ - R_PLAIN_1, /* Flachwurz */ - R_PLAIN_2, /* Würziger Wagemut */ - R_PLAIN_3, /* Eulenauge */ - R_FOREST_1, /* Grüner Spinnerich */ - R_FOREST_2, /* Blauer Baumringel */ - R_FOREST_3, /* Elfenlieb */ - R_SWAMP_1, /* Gurgelkraut */ - R_SWAMP_2, /* Knotiger Saugwurz */ - R_SWAMP_3, /* Blasenmorchel */ - R_DESERT_1, /* Wasserfinder */ - R_DESERT_2, /* Kakteenschwitz */ - R_DESERT_3, /* Sandfäule */ - R_HIGHLAND_1, /* Windbeutel */ - R_HIGHLAND_2, /* Fjordwuchs */ - R_HIGHLAND_3, /* Alraune */ - R_MOUNTAIN_1, /* Steinbeißer */ - R_MOUNTAIN_2, /* Spaltwachs */ - R_MOUNTAIN_3, /* Höhlenglimm */ - R_GLACIER_1, /* Eisblume */ - R_GLACIER_2, /* Weißer Wüterich */ - R_GLACIER_3, /* Schneekristall */ /* SONSTIGE */ R_SILVER, @@ -429,9 +381,7 @@ enum { R_HITPOINTS, /* Trefferpunkte */ R_PEASANTS, /* Regionsbauern */ - R_UNIT, /* Einheit (gib x einheit) */ - R_SWORD, /* for spells */ MAX_RESOURCES, /* do not use outside item.c ! */ NORESOURCE = (resource_t) - 1 diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index bc57c27b0..0d90e3238 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -1027,9 +1027,6 @@ unit * readunit(FILE * F) { skill_t sk; - item_t item; - herb_t herb; - potion_t potion; unit * u; int number, n, p; order ** orderp; @@ -1061,8 +1058,6 @@ readunit(FILE * F) if (u->display && strlen(u->display)>=DISPLAYSIZE) u->display[DISPLAYSIZE] = 0; #endif number = ri(F); - if (global.data_versionage = (short)ri(F); if (global.data_versionrace = new_race[(race_t)ri(F)]; @@ -1189,21 +1184,7 @@ readunit(FILE * F) } } } - if (global.data_version>=ITEMTYPE_VERSION) { - read_items(F, &u->items); - } else { - while ((item = (item_t) ri(F)) >= 0) { - i_change(&u->items, olditemtype[item], ri(F)); - } - - while ((potion = (potion_t) ri(F)) >= 0) { - i_change(&u->items, oldpotiontype[potion]->itype, ri(F)); - } - - while ((herb = (herb_t) ri(F)) >= 0) { - i_change(&u->items, oldherbtype(herb), ri(F)); - } - } + read_items(F, &u->items); u->hp = ri(F); if (u->hp < u->number) { log_error(("Einheit %s hat %u Personen, und %u Trefferpunkte\n", itoa36(u->no), @@ -1434,26 +1415,15 @@ readregion(FILE * F, short x, short y) pres=&res->next; } } - if (global.data_version>=ITEMTYPE_VERSION) { - rs(F, buf); - if (strcmp(buf, "noherb") != 0) { - const resource_type * rtype = rt_find(buf); - assert(rtype && rtype->itype && fval(rtype->itype, ITF_HERB)); - rsetherbtype(r, rtype->itype); - } else { - rsetherbtype(r, NULL); - } - rsetherbs(r, (short)ri(F)); + rs(F, buf); + if (strcmp(buf, "noherb") != 0) { + const resource_type * rtype = rt_find(buf); + assert(rtype && rtype->itype && fval(rtype->itype, ITF_HERB)); + rsetherbtype(r, rtype->itype); } else { - int i = ri(F); - - if (r->terrain->herbs==NULL) - rsetherbtype(r, NULL); - else { - rsetherbtype(r, r->terrain->herbs[i % 3]); - } - rsetherbs(r, (short)ri(F)); + rsetherbtype(r, NULL); } + rsetherbs(r, (short)ri(F)); rsetpeasants(r, ri(F)); rsetmoney(r, ri(F)); } @@ -1464,25 +1434,10 @@ readregion(FILE * F, short x, short y) assert(rmoney(r) >= 0); if (r->land) { - if (global.data_versionattribs); @@ -1832,10 +1787,6 @@ readgame(const char * filename, int backup) if (global.data_version >= GLOBAL_ATTRIB_VERSION) { a_read(F, &global.attribs); } - if (global.data_version < ITEMTYPE_VERSION) { - fprintf(stderr, "kann keine alten datenfiles einlesen"); - exit(-1); - } global.data_turn = turn = ri(F); ri(F); /* max_unique_id = */ nextborder = ri(F); diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index 370cc3eb1..8b982a0a3 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -946,9 +946,6 @@ parse_resources(xmlDocPtr doc) /* make sure old items (used in requirements) are available */ init_resources(); - /* old resources now extern (for spells */ - oldresourcetype[R_SWORD] = rt_find("sword"); - return 0; } diff --git a/src/common/modules/arena.c b/src/common/modules/arena.c index b20c9f9ec..84c535bd8 100644 --- a/src/common/modules/arena.c +++ b/src/common/modules/arena.c @@ -100,22 +100,6 @@ leave_arena(struct unit * u, const struct item_type * itype, int amount, order * return 0; } -static resource_type rt_gryphonwing = { - { "griphonwing", "griphonwing_p" }, - { "griphonwing", "griphonwing_p" }, - RTF_ITEM, - &res_changeitem -}; - -static item_type it_gryphonwing = { - &rt_gryphonwing, /* resourcetype */ - ITF_NOTLOST|ITF_CURSED, 0, 0, /* flags, weight, capacity */ - NULL, /* construction, score */ - &leave_arena, - NULL, - &give_igjarjuk -}; - static int enter_fail(unit * u) { sprintf(buf, "In %s erklingt die Stimme des Torwächters: 'Nur wer ohne materielle Güter und noch lernbegierig ist, der darf die Ebene der Herausforderung betreten. Und vergiß nicht mein Trinkgeld.'. %s erhielt keinen Einlaß.", regionname(u->region, u->faction), unitname(u)); @@ -161,7 +145,7 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord) } sprintf(buf, "In %s öffnet sich ein Portal. Eine Stimme ertönt, und spricht: 'Willkommen in der Ebene der Herausforderung'. %s durchschreitet das Tor zu einer anderen Welt.", regionname(u->region, u->faction), unitname(u)); addmessage(NULL, u->faction, buf, MSG_MESSAGE, ML_IMPORTANT); - new_use_pooled(u, &rt_gryphonwing, GET_SLACK|GET_RESERVE, 1); + new_use_pooled(u, itype->rtype, GET_SLACK|GET_RESERVE, 1); use_pooled(u, r, R_SILVER, fee); set_money(u, 109); fset(u, UFL_PARTEITARNUNG); @@ -169,20 +153,6 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord) return 0; } -static resource_type rt_arenagate = { - { "eyeofdragon", "eyeofdragon_p" }, - { "eyeofdragon", "eyeofdragon_p" }, - RTF_ITEM, - &res_changeitem -}; - -static item_type it_arenagate = { - &rt_arenagate, /* resourcetype */ - ITF_NONE, 0, 0, /* flags, weight, capacity */ - NULL, /* construction, score */ - &enter_arena -}; - /*** ** Szepter der Tränen, Demo-Item ***/ @@ -308,6 +278,9 @@ static void tower_init(void) { int i, first = newarena; + item_type * it_demonseye = it_find("demonseye"); + item_type * it_griphonwing = it_find("griphonwing"); + assert(it_griphonwing && it_demonseye); for (i=0;i!=6;++i) { region * r = tower_region[i] = findregion(arena_center->x+delta_x[i]*3, arena_center->y+delta_y[i]*3); if (r) { @@ -330,8 +303,8 @@ tower_init(void) attrib * a; item * items; - i_add(&items, i_new(&it_gryphonwing, 1)); - i_add(&items, i_new(&it_demonseye, 1)); + i_add(&items, i_new(it_griphonwing, 1)); + i_add(&items, i_new(it_demonseye, 1)); a = a_add(&b->attribs, make_giveitem(b, items)); b->size = 10; @@ -548,9 +521,6 @@ void register_arena(void) { at_register(&at_hurting); - register_demonseye(); - it_register(&it_arenagate); - it_register(&it_gryphonwing); register_function((pf_generic)use_wand_of_tears, "use_wand_of_tears"); register_function((pf_generic)enter_arena, "enter_arena"); register_function((pf_generic)leave_arena, "leave_arena"); diff --git a/src/res/eressea/items.xml b/src/res/eressea/items.xml index 2ff896e4b..38ace0121 100644 --- a/src/res/eressea/items.xml +++ b/src/res/eressea/items.xml @@ -1,50 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - -