From c550e34abdc06fea8b49a34d686d8333609f929b Mon Sep 17 00:00:00 2001 From: Christian Schlittchen Date: Sun, 15 Jun 2003 08:06:22 +0000 Subject: [PATCH] =?UTF-8?q?-=20Fix=20Resourcenabbau=20in=20Regionen=20ohne?= =?UTF-8?q?=20diese=20Resource.=20leveled=5Fallocation()=20=20=20sollte=20?= =?UTF-8?q?auch=20mit=20avail=20<=3D=200=20klarkommen.=20Brachialfix,=20bi?= =?UTF-8?q?tte=20pr=C3=BCfen!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/gamecode/economy.c | 93 ++++++++++++++++++++--------------- src/corwin@amber.mk | 6 +-- 2 files changed, 55 insertions(+), 44 deletions(-) diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index c54f86398..52176f7f6 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -1608,12 +1608,13 @@ allocate_resource(unit * u, const resource_type * rtype, int want) const struct building_type * btype = b?b->type:NULL; if (btype==bt_find("mine")) al->save *= 0.5; - if (u->race == new_race[RC_DWARF]) + if (u->race == new_race[RC_DWARF]) { #if RACE_ADJUSTMENTS al->save *= 0.75; #else - al->save *= 0.5; + al->save *= 0.5; #endif + } } else if (itype==olditemtype[I_STONE]) { struct building * b = inside_building(u); const struct building_type * btype = b?b->type:NULL; @@ -1692,54 +1693,64 @@ leveled_allocation(const allocator * self, region * r, allocation * alist) int need; boolean first = true; - if (rm!=NULL) do { - int avail = rm->amount; - int norders = 0; - allocation * al; + if (rm!=NULL) { + do { + int avail = rm->amount; + int norders = 0; + allocation * al; - assert (avail>0); + if(avail <= 0) { + for (al=alist;al;al=al->next) { + al->get = 0; + } + break; + } - for (al=alist;al;al=al->next) if (!fval(al, AFL_DONE)) { - int req = required(al->want-al->get, al->save); - assert(al->get<=al->want && al->get >= 0); - if (eff_skill(al->unit, itype->construction->skill, r) >= rm->level+itype->construction->minskill-1) { - if (req) { - norders += req; + assert(avail>0); + + for (al=alist;al;al=al->next) if (!fval(al, AFL_DONE)) { + int req = required(al->want-al->get, al->save); + assert(al->get<=al->want && al->get >= 0); + if (eff_skill(al->unit, itype->construction->skill, r) + >= rm->level+itype->construction->minskill-1) { + if (req) { + norders += req; + } else { + fset(al, AFL_DONE); + } } else { fset(al, AFL_DONE); + if (first) fset(al, AFL_LOWSKILL); } - } else { - fset(al, AFL_DONE); - if (first) fset(al, AFL_LOWSKILL); } - } - need = norders; + need = norders; - avail = min(avail, norders); - if (need>0) { - int use = 0; - for (al=alist;al;al=al->next) if (!fval(al, AFL_DONE)) { - if (avail > 0) { - int want = required(al->want-al->get, al->save); - int x = avail*want/norders; - /* Wenn Rest, dann würfeln, ob ich was bekomme: */ - if (rand() % norders < (avail*want) % norders) - ++x; - avail -= x; - use += x; - norders -= want; - need -= x; - al->get = min(al->want, al->get+(int)(x/al->save)); + avail = min(avail, norders); + if (need>0) { + int use = 0; + for (al=alist;al;al=al->next) if (!fval(al, AFL_DONE)) { + if (avail > 0) { + int want = required(al->want-al->get, al->save); + int x = avail*want/norders; + /* Wenn Rest, dann würfeln, ob ich was bekomme: */ + if (rand() % norders < (avail*want) % norders) + ++x; + avail -= x; + use += x; + norders -= want; + need -= x; + al->get = min(al->want, al->get+(int)(x/al->save)); + } } + if (use) { + assert(use<=rm->amount); + rm->type->use(rm, r, use); + } + assert(avail==0 || norders==0); } - if (use) { - assert(use<=rm->amount); - rm->type->use(rm, r, use); - } - assert(avail==0 || norders==0); - } - first = false; - } while (need>0); + first = false; + } while (need>0); + } } #endif diff --git a/src/corwin@amber.mk b/src/corwin@amber.mk index 91d9a78e4..a61e8a30d 100644 --- a/src/corwin@amber.mk +++ b/src/corwin@amber.mk @@ -4,12 +4,12 @@ ifndef ERESSEA endif # Hier definieren, damit nicht '@gcc' -CC = gcc-3.2 -D_GNU_SOURCE -ansi -pedantic -DEPEND = @gcc-3.2 -MM -MG -r +CC = gcc-3.3 -D_GNU_SOURCE -ansi -pedantic +DEPEND = @gcc-3.3 -MM -MG -r # CC = gcc -D_GNU_SOURCE AR = ar CTAGS = ctags-exuberant -LD = gcc-3.2 +LD = gcc-3.3 INSTALL = cp CFLAGS += -march=athlon -minline-all-stringops