forked from github/server
"Selling luxury goods did not work in some instances." - fix for accounting bug when material pool off
This commit is contained in:
parent
bd7d2e1271
commit
ee652fa3f3
3 changed files with 8 additions and 1 deletions
|
@ -2256,7 +2256,7 @@ sell(unit * u, request ** sellorders, struct order * ord)
|
|||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
s = getstrtoken();
|
||||
s = getstrtoken();
|
||||
|
||||
if (findparam(s, u->faction->locale) == P_ANY) {
|
||||
unlimited = false;
|
||||
|
@ -2334,6 +2334,7 @@ sell(unit * u, request ** sellorders, struct order * ord)
|
|||
if (o->type.ltype==ltype && o->unit->faction == u->faction) {
|
||||
int fpool = o->qty - get_pooled(o->unit, itype->rtype, GET_RESERVE, INT_MAX);
|
||||
available -= max(0, fpool);
|
||||
assert(available>=0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,8 @@ give_item(int want, const item_type * itype, unit * src, unit * dest, struct ord
|
|||
} 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);
|
||||
assert(n>=use);
|
||||
n = use;
|
||||
if (dest) {
|
||||
i_change(&dest->items, itype, n);
|
||||
#ifdef RESERVE_GIVE
|
||||
|
|
|
@ -110,7 +110,11 @@ change_resource(unit * u, const resource_type * rtype, int change)
|
|||
int
|
||||
get_reservation(const unit * u, const resource_type * rtype)
|
||||
{
|
||||
faction * f = u->faction;
|
||||
struct reservation * res = u->reservations;
|
||||
if ((rtype==r_silver && !(f->options & want_sp)) || (rtype!=r_silver && !(f->options & want_mp))) {
|
||||
return get_resource(u, rtype);
|
||||
}
|
||||
|
||||
if (!rc_stonegolem) init_static();
|
||||
|
||||
|
|
Loading…
Reference in a new issue