diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 2094b6961..5e1657180 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -345,9 +345,9 @@ do_recruiting(recruitment * recruits, int available) number = min(req->qty, get / multi); if (rc->recruitcost) { - int afford = get_pooled(u, u->region, R_SILVER) / rc->recruitcost; + int afford = new_get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT) / rc->recruitcost; number = min(number, afford); - use_pooled(u, u->region, R_SILVER, rc->recruitcost*number); + new_use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, rc->recruitcost*number); } add_recruits(u, number, req->qty); if ((rc->ec_flags & ECF_REC_ETHEREAL)==0) { @@ -504,8 +504,8 @@ recruit(unit * u, struct order * ord, request ** recruitorders) return; } - if (get_pooled(u, r, R_SILVER) < recruitcost) { - cmistake(u, ord, 142, MSG_EVENT); + if (new_get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT) < recruitcost) { + cmistake(u, ord, 142, MSG_EVENT); return; } } @@ -536,7 +536,7 @@ recruit(unit * u, struct order * ord, request ** recruitorders) cmistake(u, ord, 156, MSG_EVENT); return; } - if (recruitcost) n = min(n, get_pooled(u, r, R_SILVER) / recruitcost); + if (recruitcost) n = min(n, new_get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT) / recruitcost); u->wants = n; @@ -904,7 +904,7 @@ maintain(building * b, boolean first) /* first ist im ersten versuch true, im zweiten aber false! Das * bedeutet, das in der Runde in die Region geschafften Resourcen * nicht genutzt werden können, weil die reserviert sind! */ - if (!first) need -= get_all(u, m->rtype); + if (!first) need -= new_get_pooled(u, m->rtype, GET_ALL); else need -= new_get_pooled(u, m->rtype, GET_DEFAULT); if (!first && need > 0) { unit * ua; @@ -912,7 +912,7 @@ maintain(building * b, boolean first) fset(u->faction, FL_DH); /* hat schon */ for (ua=r->units;ua;ua=ua->next) { if (!fval(ua->faction, FL_DH) && (ua->faction == u->faction || alliedunit(ua, u->faction, HELP_MONEY))) { - need -= get_all(ua, m->rtype); + need -= new_get_pooled(ua, m->rtype, GET_ALL); fset(ua->faction, FL_DH); if (need<=0) break; } @@ -945,7 +945,7 @@ maintain(building * b, boolean first) if (!fval(m, MTF_VITAL) && !work) continue; if (fval(m, MTF_VARIABLE)) cost = cost * b->size; - if (!first) cost -= use_all(u, m->rtype, cost); + if (!first) cost -= new_use_pooled(u, m->rtype, GET_ALL, cost); else cost -= new_use_pooled(u, m->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, cost); if (!first && cost > 0) { unit * ua; @@ -953,7 +953,7 @@ maintain(building * b, boolean first) fset(u->faction, FL_DH); /* hat schon */ for (ua=r->units;ua;ua=ua->next) { if (!fval(ua->faction, FL_DH) && alliedunit(ua, u->faction, HELP_MONEY)) { - int give = use_all(ua, m->rtype, cost); + int give = new_use_pooled(ua, m->rtype, GET_ALL, cost); if (!give) continue; cost -= give; fset(ua->faction, FL_DH); @@ -1804,7 +1804,7 @@ expandbuying(region * r, request * buyorders) if (trade->number + 1 > max_products) ++multi; price = ltype->price * multi; - if (get_pooled(oa[j].unit, r, R_SILVER) >= price) { + if (new_get_pooled(oa[j].unit, oldresourcetype[R_SILVER], GET_DEFAULT) >= price) { unit * u = oa[j].unit; /* litems zählt die Güter, die verkauft wurden, u->n das Geld, das @@ -1815,7 +1815,7 @@ expandbuying(region * r, request * buyorders) if (a==NULL) a = a_add(&u->attribs, a_new(&at_luxuries)); i_change((item**)&a->data.v, ltype->itype, 1); i_change(&oa[j].unit->items, ltype->itype, 1); - use_pooled(u, r, R_SILVER, price); + new_use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, price); if (u->n < 0) u->n = 0; u->n += price; @@ -2296,7 +2296,7 @@ expandstealing(region * r, request * stealorders) for (i = 0; i != norders && oa[i].unit->n <= oa[i].unit->wants; i++) { unit *u = findunitg(oa[i].no, r); int n = 0; - if (u && u->region==r) n = get_all(u, r_silver); + if (u && u->region==r) n = new_get_pooled(u, r_silver, GET_ALL); #ifndef GOBLINKILL if (oa[i].type.goblin) { /* Goblin-Spezialklau */ int uct = 0; @@ -2314,7 +2314,7 @@ expandstealing(region * r, request * stealorders) } if (n > 0) { n = min(n, oa[i].unit->wants); - use_all(u, r_silver, n); + new_use_pooled(u, r_silver, GET_ALL, n); oa[i].unit->n = n; change_money(oa[i].unit, n); ADDMSG(&u->faction->msgs, msg_message("stealeffect", "unit region amount", u, u->region, n)); @@ -2350,7 +2350,7 @@ plant(region *r, unit *u, int raw) return; } /* Wasser des Lebens prüfen */ - if (get_pooled(u, r, R_TREES) == 0) { + if (new_get_pooled(u, oldresourcetype[R_TREES], GET_DEFAULT) == 0) { add_message(&u->faction->msgs, msg_feedback(u, u->thisorder, "resource_missing", "missing", oldresourcetype[R_TREES])); diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 53cad5f22..88d741970 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -2509,7 +2509,7 @@ promotion_cmd(unit * u, struct order * ord) u->race)); return 0; } - money = get_all(u, i_silver->rtype); + money = new_get_pooled(u, i_silver->rtype, GET_ALL); people = count_all(u->faction) * u->number; if (people>money) { @@ -2517,7 +2517,7 @@ promotion_cmd(unit * u, struct order * ord) people, money)); return 0; } - use_all(u, i_silver->rtype, people); + new_use_pooled(u, i_silver->rtype, GET_ALL, people); fset(u, UFL_HERO); ADDMSG(&u->faction->msgs, msg_message("hero_promotion", "unit cost", u, people)); diff --git a/src/common/gamecode/study.c b/src/common/gamecode/study.c index 3bbe5f4c0..59ef95f2f 100644 --- a/src/common/gamecode/study.c +++ b/src/common/gamecode/study.c @@ -194,7 +194,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk, int j = study_cost(student, sk); j = max(50, j * 2); /* kann Einheit das zahlen? */ - if (get_pooled(student, student->region, R_SILVER) >= j) { + if (new_get_pooled(student, oldresourcetype[R_SILVER], GET_DEFAULT) >= j) { /* Jeder Schüler zusätzlich +10 Tage wenn in Uni. */ teach->value += (n / 30) * 10; /* learning erhöhen */ /* Lehrer zusätzlich +1 Tag pro Schüler. */ @@ -608,7 +608,7 @@ learn(void) } } if (studycost) { - money = get_pooled(u, r, R_SILVER); + money = new_get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT); money = min(money, studycost * u->number); } if (money < studycost * u->number) { @@ -631,7 +631,7 @@ learn(void) teach->teachers[0] = 0; } if (money>0) { - use_pooled(u, r, R_SILVER, money); + new_use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, money); add_message(&u->faction->msgs, msg_message("studycost", "unit region cost skill", u, u->region, money, sk)); } diff --git a/src/common/kernel/build.c b/src/common/kernel/build.c index e2229bdd3..7489bc381 100644 --- a/src/common/kernel/build.c +++ b/src/common/kernel/build.c @@ -508,7 +508,7 @@ build_road(region * r, unit * u, int size, direction_t d) return; } } - if (!get_pooled(u, r, R_STONE) && u->race != new_race[RC_STONEGOLEM]) { + if (!new_get_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT) && u->race != new_race[RC_STONEGOLEM]) { cmistake(u, u->thisorder, 151, MSG_PRODUCE); return; } @@ -527,7 +527,7 @@ build_road(region * r, unit * u, int size, direction_t d) if (u->race == new_race[RC_STONEGOLEM]){ n = u->number * GOLEM_STONE; } else { - n = get_pooled(u, r, R_STONE); + n = new_get_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT); } left = min(n, left); if (size>0) left = min(size, left); @@ -568,7 +568,7 @@ build_road(region * r, unit * u, int size, direction_t d) } scale_number(u, u->number - golemsused); } else { - use_pooled(u, r, R_STONE, n); + new_use_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT, n); /* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */ produceexp(u, SK_ROAD_BUILDING, min(n, u->number)); } diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index 10eee5fe6..c2f3e2c33 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -747,7 +747,7 @@ use_tacticcrystal(region * r, unit * u, int amount, struct order * ord) c->data.i = SK_TACTICS; unused(ord); } - use_pooled(u, u->region, R_TACTICCRYSTAL, amount); + new_use_pooled(u, oldresourcetype[R_TACTICCRYSTAL], GET_DEFAULT, amount); add_message(&u->faction->msgs, new_message(u->faction, "use_tacticcrystal%u:unit%r:region", u, r)); return; @@ -1219,8 +1219,6 @@ init_olditems(void) con->materials[n].number = itemdata[i].material[m]; con->materials[n].recycle = 0.0; ++n; - if (m==M_EISEN) { - } } } } diff --git a/src/common/kernel/karma.c b/src/common/kernel/karma.c index a54d6c4b0..7ab94fe9f 100644 --- a/src/common/kernel/karma.c +++ b/src/common/kernel/karma.c @@ -331,7 +331,7 @@ buy_special(unit *u, struct order * ord, fspecial_t special) /* Alles ok, attribut geben */ - if(a2) { + if (a2) { if(a2->data.sa[1] < fspecials[special].maxlevel) { a2->data.sa[1]++; add_message(&f->msgs, new_message(f, @@ -364,7 +364,6 @@ fspecial(const faction *f, fspecial_t special) static int sacrifice_cmd(unit * u, struct order * ord) { - region *r = u->region; int n = 1, karma; const char *s; @@ -382,7 +381,7 @@ sacrifice_cmd(unit * u, struct order * ord) switch(findparam(s, u->faction->locale)) { case P_SILVER: - n = use_pooled(u, r, R_SILVER, n); + n = new_use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, n); if(n < 10000) { cmistake(u, ord, 51, MSG_EVENT); return 0; diff --git a/src/common/kernel/pool.c b/src/common/kernel/pool.c index 85f31a620..d49f7013f 100644 --- a/src/common/kernel/pool.c +++ b/src/common/kernel/pool.c @@ -270,64 +270,6 @@ new_use_pooled(unit * u, const resource_type * rtype, int mode, int count) return count-use; } -int -get_reserved(const unit * u, resource_t resource) -{ - return new_get_pooled(u, oldresourcetype[resource], GET_RESERVE); -} - -int -use_reserved(unit * u, resource_t resource, int count) -{ - return new_use_pooled(u, oldresourcetype[resource], GET_RESERVE, count); -} - -int -get_slack(const unit * u, resource_t resource) -{ - return new_get_pooled(u, oldresourcetype[resource], GET_SLACK); -} - -int -use_slack(unit * u, resource_t resource, int count) -{ - return new_use_pooled(u, oldresourcetype[resource], GET_SLACK, count); -} - - -int -get_pooled(const unit * u, const region * r, resource_t resource) -{ - return new_get_pooled(u, oldresourcetype[resource], GET_DEFAULT); -} - - -int -use_pooled(unit * u, region * r, resource_t resource, int count) -{ - return new_use_pooled(u, oldresourcetype[resource], GET_DEFAULT, count); -} - -int -use_pooled_give(unit * u, region * r, resource_t resource, int count) -{ - int use = count; - use -= new_use_pooled(u, oldresourcetype[resource], GET_SLACK, use); - if (use>0) use -= new_use_pooled(u, oldresourcetype[resource], GET_RESERVE|GET_POOLED_SLACK, use); - return count-use; -} - -int -get_all(const unit * u, const resource_type * rtype) -{ - return new_get_pooled(u, rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK|GET_POOLED_RESERVE|GET_POOLED_FORCE); -} - -int -use_all(unit * u, const resource_type * rtype, int count) -{ - return new_use_pooled(u, rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK|GET_POOLED_RESERVE|GET_POOLED_FORCE, count); -} void init_pool(void) diff --git a/src/common/kernel/pool.h b/src/common/kernel/pool.h index 6d3fe4b20..a03aa895e 100644 --- a/src/common/kernel/pool.h +++ b/src/common/kernel/pool.h @@ -18,22 +18,6 @@ extern "C" { #endif -int get_pooled(const struct unit * u, const struct region * r, resource_t itm); -int use_pooled(struct unit * u, struct region * r, resource_t itm, int count); -int use_pooled_give(struct unit * u, struct region * r, resource_t itm, int count); - -/** use_pooled - * verbraucht 'count' Objekte der resource 'itm' - * unter zuhilfenahme des Pools der struct region und Aufbrauch des - * von der Einheit reservierten Resourcen - * - * use_pooled_give - * verbraucht 'count' Objekte der resource 'itm' wie use_pooled, jedoch - * zuerst vom nicht reservierten. - * (wichtig bei gib, da sonst beim zweiten GIB des selben Gegenstandes - * jede Reservierung gelöscht wird) - */ - /* bitfield values for get/use/change operations */ #define GET_SLACK 0x01 #define GET_RESERVE 0x02 @@ -46,39 +30,7 @@ int use_pooled_give(struct unit * u, struct region * r, resource_t itm, int coun /* for convenience: */ #define GET_DEFAULT (GET_RESERVE|GET_SLACK|GET_POOLED_SLACK) - - -extern int get_all(const struct unit * u, const struct resource_type * rtype); -extern int use_all(struct unit * u, const struct resource_type * rtype, int count); - -/** use_all - * verbraucht 'count' Objekte der resource 'itm' - * unter zuhilfenahme aller Einheiten der struct region - */ - -int get_allied(const struct unit * u, struct region * r, resource_t itm); -int use_allied(struct unit * u, struct region * r, resource_t itm, int count); - -/** use_allied - * verbraucht 'count' Objekte der resource 'itm' - * unter zuhilfenahme des alliierten in der struct region - */ - -int get_reserved(const struct unit * u, resource_t itm); -int use_reserved(struct unit * u, resource_t itm, int count); - -/** use_reserved - * verbraucht 'count' Objekte der resource 'itm' - * aus den reservierten Objekten der Einheit. - */ - -int use_slack(struct unit * u, resource_t itm, int count); -int get_slack(const struct unit * u, resource_t itm); - -/** use_slack - * verbraucht 'count' Objekte der resource 'itm' - * aus den nicht-reservierten Objekten der Einheit. - */ +#define GET_ALL (GET_SLACK|GET_RESERVE|GET_POOLED_SLACK|GET_POOLED_RESERVE|GET_POOLED_FORCE) int new_get_pooled(const struct unit * u, const struct resource_type * res, int mode); int new_use_pooled(struct unit * u, const struct resource_type * res, int mode, int count); diff --git a/src/common/modules/arena.c b/src/common/modules/arena.c index 84c535bd8..3c93f1cdd 100644 --- a/src/common/modules/arena.c +++ b/src/common/modules/arena.c @@ -120,7 +120,7 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord) if (fee>2000) fee = 2000; if (getplane(r)==arena) return -1; if (u->number!=1 && enter_fail(u)) return -1; - if (get_pooled(u, r, R_SILVER) < fee && enter_fail(u)) return -1; + if (new_get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT) < fee && enter_fail(u)) return -1; for (sk=0;sk!=MAXSKILLS;++sk) { if (get_level(u, sk)>1 && enter_fail(u)) return -1; } @@ -146,8 +146,8 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord) sprintf(buf, "In %s öffnet sich ein Portal. Eine Stimme ertönt, und spricht: 'Willkommen in der Ebene der Herausforderung'. %s durchschreitet das Tor zu einer anderen Welt.", regionname(u->region, u->faction), unitname(u)); addmessage(NULL, u->faction, buf, MSG_MESSAGE, ML_IMPORTANT); new_use_pooled(u, itype->rtype, GET_SLACK|GET_RESERVE, 1); - use_pooled(u, r, R_SILVER, fee); - set_money(u, 109); + new_use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, fee); + set_money(u, 109); fset(u, UFL_PARTEITARNUNG); move_unit(u, start_region[rand() % 6], NULL); return 0;