forked from github/server
"Pferde verschwinden nach GIB 0" fixed the give_horses function being used.
This commit is contained in:
parent
e3079f88cc
commit
bfc801b6b7
5 changed files with 24 additions and 10 deletions
|
@ -116,9 +116,7 @@ give_item(int want, const item_type * itype, unit * src, unit * dest, struct ord
|
|||
error = 36;
|
||||
} else if (itype->flags & ITF_CURSED) {
|
||||
error = 25;
|
||||
} else if (itype->give && !itype->give(src, dest, itype, n, ord)) {
|
||||
return -1;
|
||||
} else {
|
||||
} else if (itype->give==NULL || itype->give(src, dest, itype, n, ord)!=0) {
|
||||
int use = use_pooled(src, item2resource(itype), GET_SLACK, n);
|
||||
if (use<n) use += use_pooled(src, item2resource(itype), GET_RESERVE|GET_POOLED_SLACK, n-use);
|
||||
if (dest) {
|
||||
|
|
|
@ -567,12 +567,24 @@ i_new(const item_type * itype, int size)
|
|||
|
||||
#include "region.h"
|
||||
|
||||
static boolean
|
||||
give_horses(const unit * s, const unit * d, const item_type * itype, int n, struct order * ord)
|
||||
static int
|
||||
give_horses(unit * s, unit * d, const item_type * itype, int n, struct order * ord)
|
||||
{
|
||||
if (d==NULL && itype == olditemtype[I_HORSE])
|
||||
if (d==NULL) {
|
||||
rsethorses(s->region, rhorses(s->region) + n);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
return -1; /* use the mechanism */
|
||||
}
|
||||
|
||||
static int
|
||||
give_money(unit * s, unit * d, const item_type * itype, int n, struct order * ord)
|
||||
{
|
||||
if (d==NULL) {
|
||||
rsetmoney(s->region, rmoney(s->region) + n);
|
||||
return 0;
|
||||
}
|
||||
return -1; /* use the mechanism */
|
||||
}
|
||||
|
||||
#define R_MINOTHER R_SILVER
|
||||
|
@ -901,6 +913,7 @@ init_resources(void)
|
|||
r_silver = new_resourcetype(&names[0], NULL, RTF_ITEM|RTF_POOLED);
|
||||
i_silver = new_itemtype(r_silver, ITF_NONE, 1/*weight*/, 0);
|
||||
r_silver->uchange = res_changeitem;
|
||||
i_silver->give = give_money;
|
||||
|
||||
r_permaura = new_resourcetype(&names[4], NULL, RTF_NONE);
|
||||
r_permaura->uchange = res_changepermaura;
|
||||
|
|
|
@ -128,7 +128,7 @@ typedef struct item_type {
|
|||
/* --- functions --- */
|
||||
int (*use)(struct unit * user, const struct item_type * itype, int amount, struct order * ord);
|
||||
int (*useonother)(struct unit * user, int targetno, const struct item_type * itype, int amount, struct order * ord);
|
||||
boolean (*give)(const struct unit * src, const struct unit * dest, const struct item_type * itm, int number, struct order * ord);
|
||||
int (*give)(struct unit * src, struct unit * dest, const struct item_type * itm, int number, struct order * ord);
|
||||
#ifdef SCORE_MODULE
|
||||
int score;
|
||||
#endif
|
||||
|
|
|
@ -836,7 +836,7 @@ xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype)
|
|||
}
|
||||
assert(propValue!=NULL);
|
||||
if (strcmp((const char*)propValue, "give")==0) {
|
||||
itype->give = (boolean (*)(const struct unit*, const struct unit*, const struct item_type *, int, struct order *))fun;
|
||||
itype->give = (int (*)(struct unit*, struct unit*, const struct item_type *, int, struct order *))fun;
|
||||
} else if (strcmp((const char*)propValue, "use")==0) {
|
||||
itype->use = (int (*)(struct unit *, const struct item_type *, int, struct order *))fun;
|
||||
} else if (strcmp((const char*)propValue, "useonother")==0) {
|
||||
|
|
|
@ -70,7 +70,9 @@
|
|||
</resource>
|
||||
|
||||
<resource name="elvenhorse">
|
||||
<item weight="5000" notlost="yes" big="yes" score="6000" capacity="7000" animal="yes"/>
|
||||
<item weight="5000" notlost="yes" big="yes" score="6000" capacity="7000" animal="yes">
|
||||
<function name="give" value="givehorses"/>
|
||||
</item>
|
||||
</resource>
|
||||
|
||||
<resource name="dolphin">
|
||||
|
@ -112,6 +114,7 @@
|
|||
<resource name="horse" limited="yes">
|
||||
<item weight="5000" score="10" capacity="7000" animal="yes">
|
||||
<construction skill="training" minskill="1" reqsize="1"/>
|
||||
<function name="give" value="givehorses"/>
|
||||
</item>
|
||||
<resourcelimit>
|
||||
<function name="produce" value="lua_produceresource"/>
|
||||
|
|
Loading…
Reference in a new issue