"Selling luxury goods did not work in some instances."
- fix for accounting bug when material pool off
This commit is contained in:
Enno Rehling 2008-02-03 21:39:22 +00:00
parent bd7d2e1271
commit ee652fa3f3
3 changed files with 8 additions and 1 deletions

View File

@ -2334,6 +2334,7 @@ sell(unit * u, request ** sellorders, struct order * ord)
if (o->type.ltype==ltype && o->unit->faction == u->faction) { if (o->type.ltype==ltype && o->unit->faction == u->faction) {
int fpool = o->qty - get_pooled(o->unit, itype->rtype, GET_RESERVE, INT_MAX); int fpool = o->qty - get_pooled(o->unit, itype->rtype, GET_RESERVE, INT_MAX);
available -= max(0, fpool); available -= max(0, fpool);
assert(available>=0);
} }
} }

View File

@ -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) { } else if (itype->give==NULL || itype->give(src, dest, itype, n, ord)!=0) {
int use = use_pooled(src, item2resource(itype), GET_SLACK, n); 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 (use<n) use += use_pooled(src, item2resource(itype), GET_RESERVE|GET_POOLED_SLACK, n-use);
assert(n>=use);
n = use;
if (dest) { if (dest) {
i_change(&dest->items, itype, n); i_change(&dest->items, itype, n);
#ifdef RESERVE_GIVE #ifdef RESERVE_GIVE

View File

@ -110,7 +110,11 @@ change_resource(unit * u, const resource_type * rtype, int change)
int int
get_reservation(const unit * u, const resource_type * rtype) get_reservation(const unit * u, const resource_type * rtype)
{ {
faction * f = u->faction;
struct reservation * res = u->reservations; 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(); if (!rc_stonegolem) init_static();