forked from github/server
BUG 2279: too many resources used.
diddling the resource-save formula until test passes.
This commit is contained in:
parent
5902a6922f
commit
50083fc668
|
@ -1038,8 +1038,6 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
|
||||||
static int required(int want, double save)
|
static int required(int want, double save)
|
||||||
{
|
{
|
||||||
int req = (int)(want * save);
|
int req = (int)(want * save);
|
||||||
if (req < want * save)
|
|
||||||
++req;
|
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1095,14 +1093,14 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist)
|
||||||
if (avail > 0) {
|
if (avail > 0) {
|
||||||
int want = required(al->want - al->get, al->save);
|
int want = required(al->want - al->get, al->save);
|
||||||
int x = avail * want / nreq;
|
int x = avail * want / nreq;
|
||||||
/* Wenn Rest, dann w<>rfeln, ob ich was bekomme: */
|
int r = (avail * want) % nreq;
|
||||||
if (rng_int() % nreq < (avail * want) % nreq)
|
/* Wenn Rest, dann wuerfeln, ob ich etwas bekomme: */
|
||||||
++x;
|
if (r > 0 && rng_int() % nreq < r) ++x;
|
||||||
avail -= x;
|
avail -= x;
|
||||||
use += x;
|
use += x;
|
||||||
nreq -= want;
|
nreq -= want;
|
||||||
need -= x;
|
need -= x;
|
||||||
al->get = MIN(al->want, al->get + (int)(x / al->save));
|
al->get = MIN(al->want, al->get + (int)(1 + x / al->save));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (use) {
|
if (use) {
|
||||||
|
|
Loading…
Reference in New Issue