bugfix luxuries. now possible (though not done) to read them from xml.

This commit is contained in:
Enno Rehling 2005-10-29 16:28:10 +00:00
parent 89e8c622c7
commit 1113d3d7e9
10 changed files with 41 additions and 20 deletions

View File

@ -20,12 +20,18 @@
#include "seed.h"
void
init_itemtypes(void)
register_itemtypes(void)
{
/* registering misc. functions */
register_weapons();
register_xerewards();
register_artrewards();
init_weapons();
register_seed();
register_mallornseed();
}
void
init_itemtypes(void)
{
init_weapons();
init_seed();
init_mallornseed();
}

View File

@ -17,6 +17,7 @@ extern "C" {
#endif
extern void init_itemtypes(void);
extern void register_itemtypes(void);
#ifdef __cplusplus
}

View File

@ -46,7 +46,7 @@ limit_seeds(const region * r, const resource_type * rtype)
}
void
register_seed(void)
init_seed(void)
{
attrib * a;
resource_limit * rdata;
@ -82,7 +82,7 @@ limit_mallornseeds(const region * r, const resource_type * rtype)
}
void
register_mallornseed(void)
init_mallornseed(void)
{
attrib * a;
resource_limit * rdata;

View File

@ -20,10 +20,10 @@ extern "C" {
extern struct resource_type * rt_seed;
extern void register_seed(void);
extern void init_seed(void);
extern struct resource_type * rt_mallornseed;
extern void register_mallornseed(void);
extern void init_mallornseed(void);
#ifdef __cplusplus
}

View File

@ -276,7 +276,8 @@ init_oldweapons(void)
}
void
register_weapons(void) {
register_weapons(void)
{
register_function((pf_generic)attack_catapult, "attack_catapult");
register_function((pf_generic)attack_firesword, "attack_firesword");
}

View File

@ -82,7 +82,7 @@ use_manacrystal(struct unit * u, const struct item_type * itype, int amount, str
void
register_xerewards(void)
{
register_function((pf_generic)use_skillpotion, "useskillpotion");
register_function((pf_generic)use_manacrystal, "usemanacrystal");
register_function((pf_generic)use_skillpotion, "use_skillpotion");
register_function((pf_generic)use_manacrystal, "use_manacrystal");
}

View File

@ -1128,6 +1128,7 @@ init_olditems(void)
switch (itemdata[i].typ) {
case IS_LUXURY:
price = itemdata[i].preis;
rtype->ltype = new_luxurytype(itype, price);
break;
case IS_RESOURCE:
rtype->flags |= RTF_LIMITED;

View File

@ -579,6 +579,13 @@ xml_readpotion(xmlXPathContextPtr xpath, item_type * itype)
return new_potiontype(itype, level);
}
static luxury_type *
xml_readluxury(xmlXPathContextPtr xpath, item_type * itype)
{
int price = xml_ivalue(xpath->node, "price", 0);
return new_luxurytype(itype, price);
}
static armor_type *
xml_readarmor(xmlXPathContextPtr xpath, item_type * itype)
@ -774,6 +781,17 @@ xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype)
}
xmlXPathFreeObject(result);
/* reading item/luxury */
xpath->node = node;
result = xmlXPathEvalExpression(BAD_CAST "luxury", xpath);
assert(result->nodesetval->nodeNr<=1);
if (result->nodesetval->nodeNr!=0) {
itype->flags |= ITF_LUXURY;
xpath->node = result->nodesetval->nodeTab[0];
rtype->ltype = xml_readluxury(xpath, itype);
}
xmlXPathFreeObject(result);
/* reading item/armor */
xpath->node = node;
result = xmlXPathEvalExpression(BAD_CAST "armor", xpath);

View File

@ -224,6 +224,7 @@ game_init(void)
register_wormholes();
#endif
register_itemtypes();
register_xmlreader();
enable_xml_gamecode();
init_data(xmlfile);

View File

@ -1,25 +1,18 @@
<?xml version="1.0"?>
<resources>
<!-- luxury items -->
<resource name="oil">
<item weight="0">
<function name="use" value="useskillpotion"/>
</item>
</resource>
<!-- XE items -->
<resource name="skillpotion">
<!-- gives user one free learning attempt -->
<item weight="0">
<function name="use" value="useskillpotion"/>
<function name="use" value="use_skillpotion"/>
</item>
</resource>
<resource name="manacrystal">
<!-- gives user free aura -->
<item weight="0">
<function name="use" value="usemanacrystal"/>
<function name="use" value="use_manacrystal"/>
</item>
</resource>