forked from github/server
remote the item_type.use funpointer.
This commit is contained in:
parent
9e239c88f4
commit
49d8a03eca
|
@ -54,30 +54,22 @@
|
||||||
<!-- museum items -->
|
<!-- museum items -->
|
||||||
<resource name="questkey1" appearance="key">
|
<resource name="questkey1" appearance="key">
|
||||||
<!-- Key for an old quest. placeholder item -->
|
<!-- Key for an old quest. placeholder item -->
|
||||||
<item notlost="yes" weight="0" >
|
<item notlost="yes" weight="0" use="yes" />
|
||||||
<function name="use" value="use_museumkey"/>
|
|
||||||
</item>
|
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<resource name="questkey2" appearance="key">
|
<resource name="questkey2" appearance="key">
|
||||||
<!-- Key for an old quest. placeholder item -->
|
<!-- Key for an old quest. placeholder item -->
|
||||||
<item notlost="yes" weight="0" >
|
<item notlost="yes" weight="0" use="yes" />
|
||||||
<function name="use" value="use_museumkey"/>
|
|
||||||
</item>
|
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<resource name="museumexitticket">
|
<resource name="museumexitticket">
|
||||||
<!-- you get your stuff back when leaving the museum -->
|
<!-- you get your stuff back when leaving the museum -->
|
||||||
<item notlost="yes" weight="0">
|
<item notlost="yes" weight="0" use="yes" />
|
||||||
<function name="use" value="use_museumexitticket"/>
|
|
||||||
</item>
|
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<resource name="museumticket">
|
<resource name="museumticket">
|
||||||
<!-- you get your stuff back when leaving the museum -->
|
<!-- you get your stuff back when leaving the museum -->
|
||||||
<item weight="0">
|
<item weight="0" use="yes" />
|
||||||
<function name="use" value="use_museumticket"/>
|
|
||||||
</item>
|
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<!-- gimmicks, etc. -->
|
<!-- gimmicks, etc. -->
|
||||||
|
|
|
@ -529,9 +529,6 @@ use_item_lua(unit *u, const item_type *itype, int amount, struct order *ord)
|
||||||
} else {
|
} else {
|
||||||
log_error("no such callout: %s", fname);
|
log_error("no such callout: %s", fname);
|
||||||
}
|
}
|
||||||
if (itype->use) {
|
|
||||||
return itype->use(u, itype, amount, ord);
|
|
||||||
}
|
|
||||||
log_error("use(%s) calling '%s': not a function.\n", unitname(u), fname);
|
log_error("use(%s) calling '%s': not a function.\n", unitname(u), fname);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
|
|
@ -126,8 +126,6 @@ extern "C" {
|
||||||
/* --- functions --- */
|
/* --- functions --- */
|
||||||
bool(*canuse) (const struct unit * user,
|
bool(*canuse) (const struct unit * user,
|
||||||
const struct item_type * itype);
|
const struct item_type * itype);
|
||||||
int(*use) (struct unit * user, const struct item_type * itype, int amount,
|
|
||||||
struct order * ord);
|
|
||||||
int(*give) (struct unit * src, struct unit * dest,
|
int(*give) (struct unit * src, struct unit * dest,
|
||||||
const struct item_type * itm, int number, struct order * ord);
|
const struct item_type * itm, int number, struct order * ord);
|
||||||
int score;
|
int score;
|
||||||
|
@ -310,8 +308,6 @@ extern "C" {
|
||||||
const struct item_type *, int, struct order *), const char *name);
|
const struct item_type *, int, struct order *), const char *name);
|
||||||
void register_item_use(int(*foo) (struct unit *,
|
void register_item_use(int(*foo) (struct unit *,
|
||||||
const struct item_type *, int, struct order *), const char *name);
|
const struct item_type *, int, struct order *), const char *name);
|
||||||
void register_item_useonother(int(*foo) (struct unit *, int,
|
|
||||||
const struct item_type *, int, struct order *), const char *name);
|
|
||||||
|
|
||||||
void free_resources(void);
|
void free_resources(void);
|
||||||
|
|
||||||
|
|
|
@ -854,13 +854,6 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype)
|
||||||
(int(*)(struct unit *, struct unit *, const struct item_type *, int,
|
(int(*)(struct unit *, struct unit *, const struct item_type *, int,
|
||||||
struct order *))fun;
|
struct order *))fun;
|
||||||
}
|
}
|
||||||
else if (strcmp((const char *)propValue, "use") == 0) {
|
|
||||||
log_error("%s has a use function", rtype->_name);
|
|
||||||
itype->flags |= ITF_CANUSE;
|
|
||||||
itype->use =
|
|
||||||
(int(*)(struct unit *, const struct item_type *, int,
|
|
||||||
struct order *))fun;
|
|
||||||
}
|
|
||||||
else if (strcmp((const char *)propValue, "canuse") == 0) {
|
else if (strcmp((const char *)propValue, "canuse") == 0) {
|
||||||
itype->canuse =
|
itype->canuse =
|
||||||
(bool(*)(const struct unit *, const struct item_type *))fun;
|
(bool(*)(const struct unit *, const struct item_type *))fun;
|
||||||
|
|
|
@ -497,9 +497,10 @@ void register_museum(void)
|
||||||
at_register(&at_museumgivebackcookie);
|
at_register(&at_museumgivebackcookie);
|
||||||
at_register(&at_museumgiveback);
|
at_register(&at_museumgiveback);
|
||||||
|
|
||||||
register_item_use(use_museumticket, "use_museumticket");
|
|
||||||
register_item_use(use_museumkey, "use_museumkey");
|
|
||||||
register_item_use(use_museumexitticket, "use_museumexitticket");
|
register_item_use(use_museumexitticket, "use_museumexitticket");
|
||||||
|
register_item_use(use_museumticket, "use_museumticket");
|
||||||
|
register_item_use(use_museumkey, "use_questkey1");
|
||||||
|
register_item_use(use_museumkey, "use_questkey2");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue