forked from github/server
bugfix luxuries. now possible (though not done) to read them from xml.
This commit is contained in:
parent
89e8c622c7
commit
1113d3d7e9
10 changed files with 41 additions and 20 deletions
|
@ -20,12 +20,18 @@
|
||||||
#include "seed.h"
|
#include "seed.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
init_itemtypes(void)
|
register_itemtypes(void)
|
||||||
{
|
{
|
||||||
|
/* registering misc. functions */
|
||||||
register_weapons();
|
register_weapons();
|
||||||
register_xerewards();
|
register_xerewards();
|
||||||
register_artrewards();
|
register_artrewards();
|
||||||
init_weapons();
|
}
|
||||||
register_seed();
|
|
||||||
register_mallornseed();
|
void
|
||||||
|
init_itemtypes(void)
|
||||||
|
{
|
||||||
|
init_weapons();
|
||||||
|
init_seed();
|
||||||
|
init_mallornseed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void init_itemtypes(void);
|
extern void init_itemtypes(void);
|
||||||
|
extern void register_itemtypes(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ limit_seeds(const region * r, const resource_type * rtype)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
register_seed(void)
|
init_seed(void)
|
||||||
{
|
{
|
||||||
attrib * a;
|
attrib * a;
|
||||||
resource_limit * rdata;
|
resource_limit * rdata;
|
||||||
|
@ -82,7 +82,7 @@ limit_mallornseeds(const region * r, const resource_type * rtype)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
register_mallornseed(void)
|
init_mallornseed(void)
|
||||||
{
|
{
|
||||||
attrib * a;
|
attrib * a;
|
||||||
resource_limit * rdata;
|
resource_limit * rdata;
|
||||||
|
|
|
@ -20,10 +20,10 @@ extern "C" {
|
||||||
|
|
||||||
|
|
||||||
extern struct resource_type * rt_seed;
|
extern struct resource_type * rt_seed;
|
||||||
extern void register_seed(void);
|
extern void init_seed(void);
|
||||||
|
|
||||||
extern struct resource_type * rt_mallornseed;
|
extern struct resource_type * rt_mallornseed;
|
||||||
extern void register_mallornseed(void);
|
extern void init_mallornseed(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,7 +276,8 @@ init_oldweapons(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
register_weapons(void) {
|
register_weapons(void)
|
||||||
|
{
|
||||||
register_function((pf_generic)attack_catapult, "attack_catapult");
|
register_function((pf_generic)attack_catapult, "attack_catapult");
|
||||||
register_function((pf_generic)attack_firesword, "attack_firesword");
|
register_function((pf_generic)attack_firesword, "attack_firesword");
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ use_manacrystal(struct unit * u, const struct item_type * itype, int amount, str
|
||||||
void
|
void
|
||||||
register_xerewards(void)
|
register_xerewards(void)
|
||||||
{
|
{
|
||||||
register_function((pf_generic)use_skillpotion, "useskillpotion");
|
register_function((pf_generic)use_skillpotion, "use_skillpotion");
|
||||||
register_function((pf_generic)use_manacrystal, "usemanacrystal");
|
register_function((pf_generic)use_manacrystal, "use_manacrystal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1128,6 +1128,7 @@ init_olditems(void)
|
||||||
switch (itemdata[i].typ) {
|
switch (itemdata[i].typ) {
|
||||||
case IS_LUXURY:
|
case IS_LUXURY:
|
||||||
price = itemdata[i].preis;
|
price = itemdata[i].preis;
|
||||||
|
rtype->ltype = new_luxurytype(itype, price);
|
||||||
break;
|
break;
|
||||||
case IS_RESOURCE:
|
case IS_RESOURCE:
|
||||||
rtype->flags |= RTF_LIMITED;
|
rtype->flags |= RTF_LIMITED;
|
||||||
|
|
|
@ -579,6 +579,13 @@ xml_readpotion(xmlXPathContextPtr xpath, item_type * itype)
|
||||||
return new_potiontype(itype, level);
|
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 *
|
static armor_type *
|
||||||
xml_readarmor(xmlXPathContextPtr xpath, item_type * itype)
|
xml_readarmor(xmlXPathContextPtr xpath, item_type * itype)
|
||||||
|
@ -774,6 +781,17 @@ xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype)
|
||||||
}
|
}
|
||||||
xmlXPathFreeObject(result);
|
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 */
|
/* reading item/armor */
|
||||||
xpath->node = node;
|
xpath->node = node;
|
||||||
result = xmlXPathEvalExpression(BAD_CAST "armor", xpath);
|
result = xmlXPathEvalExpression(BAD_CAST "armor", xpath);
|
||||||
|
|
|
@ -224,6 +224,7 @@ game_init(void)
|
||||||
register_wormholes();
|
register_wormholes();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
register_itemtypes();
|
||||||
register_xmlreader();
|
register_xmlreader();
|
||||||
enable_xml_gamecode();
|
enable_xml_gamecode();
|
||||||
init_data(xmlfile);
|
init_data(xmlfile);
|
||||||
|
|
|
@ -1,25 +1,18 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<!-- luxury items -->
|
|
||||||
<resource name="oil">
|
|
||||||
<item weight="0">
|
|
||||||
<function name="use" value="useskillpotion"/>
|
|
||||||
</item>
|
|
||||||
</resource>
|
|
||||||
|
|
||||||
<!-- XE items -->
|
<!-- XE items -->
|
||||||
<resource name="skillpotion">
|
<resource name="skillpotion">
|
||||||
<!-- gives user one free learning attempt -->
|
<!-- gives user one free learning attempt -->
|
||||||
<item weight="0">
|
<item weight="0">
|
||||||
<function name="use" value="useskillpotion"/>
|
<function name="use" value="use_skillpotion"/>
|
||||||
</item>
|
</item>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<resource name="manacrystal">
|
<resource name="manacrystal">
|
||||||
<!-- gives user free aura -->
|
<!-- gives user free aura -->
|
||||||
<item weight="0">
|
<item weight="0">
|
||||||
<function name="use" value="usemanacrystal"/>
|
<function name="use" value="use_manacrystal"/>
|
||||||
</item>
|
</item>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue