From ee652fa3f3c3a822e51013b121aabd08bf9dbc74 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Feb 2008 21:39:22 +0000 Subject: [PATCH] http://eressea.upb.de/mantis/view.php?id=1350 "Selling luxury goods did not work in some instances." - fix for accounting bug when material pool off --- src/common/gamecode/economy.c | 3 ++- src/common/gamecode/give.c | 2 ++ src/common/kernel/pool.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index bfdd4826d..f6be521a1 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -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); } } diff --git a/src/common/gamecode/give.c b/src/common/gamecode/give.c index 09974053b..31ff1ea62 100644 --- a/src/common/gamecode/give.c +++ b/src/common/gamecode/give.c @@ -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=use); + n = use; if (dest) { i_change(&dest->items, itype, n); #ifdef RESERVE_GIVE diff --git a/src/common/kernel/pool.c b/src/common/kernel/pool.c index b6d4bb201..10b9a3c83 100644 --- a/src/common/kernel/pool.c +++ b/src/common/kernel/pool.c @@ -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();