noch mehr funktionen mit new_ prefix aus pool.h bekommen den entfernt.

This commit is contained in:
Enno Rehling 2005-10-30 15:42:15 +00:00
parent 9b7128b660
commit eba19999f4
14 changed files with 72 additions and 72 deletions

View File

@ -345,9 +345,9 @@ do_recruiting(recruitment * recruits, int available)
number = min(req->qty, get / multi); number = min(req->qty, get / multi);
if (rc->recruitcost) { if (rc->recruitcost) {
int afford = new_get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT) / rc->recruitcost; int afford = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT) / rc->recruitcost;
number = min(number, afford); number = min(number, afford);
new_use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, rc->recruitcost*number); use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, rc->recruitcost*number);
} }
add_recruits(u, number, req->qty); add_recruits(u, number, req->qty);
if ((rc->ec_flags & ECF_REC_ETHEREAL)==0) { if ((rc->ec_flags & ECF_REC_ETHEREAL)==0) {
@ -504,7 +504,7 @@ recruit(unit * u, struct order * ord, request ** recruitorders)
return; return;
} }
if (new_get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT) < recruitcost) { if (get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT) < recruitcost) {
cmistake(u, ord, 142, MSG_EVENT); cmistake(u, ord, 142, MSG_EVENT);
return; return;
} }
@ -536,7 +536,7 @@ recruit(unit * u, struct order * ord, request ** recruitorders)
cmistake(u, ord, 156, MSG_EVENT); cmistake(u, ord, 156, MSG_EVENT);
return; return;
} }
if (recruitcost) n = min(n, new_get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT) / recruitcost); if (recruitcost) n = min(n, get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT) / recruitcost);
u->wants = n; u->wants = n;
@ -904,15 +904,15 @@ maintain(building * b, boolean first)
/* first ist im ersten versuch true, im zweiten aber false! Das /* first ist im ersten versuch true, im zweiten aber false! Das
* bedeutet, das in der Runde in die Region geschafften Resourcen * bedeutet, das in der Runde in die Region geschafften Resourcen
* nicht genutzt werden können, weil die reserviert sind! */ * nicht genutzt werden können, weil die reserviert sind! */
if (!first) need -= new_get_pooled(u, m->rtype, GET_ALL); if (!first) need -= get_pooled(u, m->rtype, GET_ALL);
else need -= new_get_pooled(u, m->rtype, GET_DEFAULT); else need -= get_pooled(u, m->rtype, GET_DEFAULT);
if (!first && need > 0) { if (!first && need > 0) {
unit * ua; unit * ua;
for (ua=r->units;ua;ua=ua->next) freset(ua->faction, FL_DH); for (ua=r->units;ua;ua=ua->next) freset(ua->faction, FL_DH);
fset(u->faction, FL_DH); /* hat schon */ fset(u->faction, FL_DH); /* hat schon */
for (ua=r->units;ua;ua=ua->next) { for (ua=r->units;ua;ua=ua->next) {
if (!fval(ua->faction, FL_DH) && (ua->faction == u->faction || alliedunit(ua, u->faction, HELP_MONEY))) { if (!fval(ua->faction, FL_DH) && (ua->faction == u->faction || alliedunit(ua, u->faction, HELP_MONEY))) {
need -= new_get_pooled(ua, m->rtype, GET_ALL); need -= get_pooled(ua, m->rtype, GET_ALL);
fset(ua->faction, FL_DH); fset(ua->faction, FL_DH);
if (need<=0) break; if (need<=0) break;
} }
@ -945,15 +945,15 @@ maintain(building * b, boolean first)
if (!fval(m, MTF_VITAL) && !work) continue; if (!fval(m, MTF_VITAL) && !work) continue;
if (fval(m, MTF_VARIABLE)) cost = cost * b->size; if (fval(m, MTF_VARIABLE)) cost = cost * b->size;
if (!first) cost -= new_use_pooled(u, m->rtype, GET_ALL, cost); if (!first) cost -= use_pooled(u, m->rtype, GET_ALL, cost);
else cost -= new_use_pooled(u, m->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, cost); else cost -= use_pooled(u, m->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, cost);
if (!first && cost > 0) { if (!first && cost > 0) {
unit * ua; unit * ua;
for (ua=r->units;ua;ua=ua->next) freset(ua->faction, FL_DH); for (ua=r->units;ua;ua=ua->next) freset(ua->faction, FL_DH);
fset(u->faction, FL_DH); /* hat schon */ fset(u->faction, FL_DH); /* hat schon */
for (ua=r->units;ua;ua=ua->next) { for (ua=r->units;ua;ua=ua->next) {
if (!fval(ua->faction, FL_DH) && alliedunit(ua, u->faction, HELP_MONEY)) { if (!fval(ua->faction, FL_DH) && alliedunit(ua, u->faction, HELP_MONEY)) {
int give = new_use_pooled(ua, m->rtype, GET_ALL, cost); int give = use_pooled(ua, m->rtype, GET_ALL, cost);
if (!give) continue; if (!give) continue;
cost -= give; cost -= give;
fset(ua->faction, FL_DH); fset(ua->faction, FL_DH);
@ -1804,7 +1804,7 @@ expandbuying(region * r, request * buyorders)
if (trade->number + 1 > max_products) ++multi; if (trade->number + 1 > max_products) ++multi;
price = ltype->price * multi; price = ltype->price * multi;
if (new_get_pooled(oa[j].unit, oldresourcetype[R_SILVER], GET_DEFAULT) >= price) { if (get_pooled(oa[j].unit, oldresourcetype[R_SILVER], GET_DEFAULT) >= price) {
unit * u = oa[j].unit; unit * u = oa[j].unit;
/* litems zählt die Güter, die verkauft wurden, u->n das Geld, das /* 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)); if (a==NULL) a = a_add(&u->attribs, a_new(&at_luxuries));
i_change((item**)&a->data.v, ltype->itype, 1); i_change((item**)&a->data.v, ltype->itype, 1);
i_change(&oa[j].unit->items, ltype->itype, 1); i_change(&oa[j].unit->items, ltype->itype, 1);
new_use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, price); use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, price);
if (u->n < 0) if (u->n < 0)
u->n = 0; u->n = 0;
u->n += price; u->n += price;
@ -2096,9 +2096,9 @@ expandselling(region * r, request * sellorders, int limit)
} }
if (use>0) { if (use>0) {
#ifdef NDEBUG #ifdef NDEBUG
new_use_pooled(oa[j].unit, ltype->itype->rtype, GET_DEFAULT, use); use_pooled(oa[j].unit, ltype->itype->rtype, GET_DEFAULT, use);
#else #else
/* int i = */ new_use_pooled(oa[j].unit, ltype->itype->rtype, GET_DEFAULT, use); /* int i = */ use_pooled(oa[j].unit, ltype->itype->rtype, GET_DEFAULT, use);
/* assert(i==use); */ /* assert(i==use); */
#endif #endif
} }
@ -2229,13 +2229,13 @@ sell(unit * u, request ** sellorders, struct order * ord)
cmistake(u, ord, 263, MSG_COMMERCE); cmistake(u, ord, 263, MSG_COMMERCE);
return false; return false;
} }
available = new_get_pooled(u, itype->rtype, GET_DEFAULT); available = get_pooled(u, itype->rtype, GET_DEFAULT);
/* Wenn andere Einheiten das selbe verkaufen, muß ihr Zeug abgezogen /* Wenn andere Einheiten das selbe verkaufen, muß ihr Zeug abgezogen
* werden damit es nicht zweimal verkauft wird: */ * werden damit es nicht zweimal verkauft wird: */
for (o=*sellorders;o;o=o->next) { for (o=*sellorders;o;o=o->next) {
if (o->type.ltype==ltype && o->unit->faction == u->faction) { if (o->type.ltype==ltype && o->unit->faction == u->faction) {
int fpool = o->qty - new_get_pooled(o->unit, itype->rtype, GET_RESERVE); int fpool = o->qty - get_pooled(o->unit, itype->rtype, GET_RESERVE);
available -= max(0, fpool); available -= max(0, fpool);
} }
} }
@ -2296,7 +2296,7 @@ expandstealing(region * r, request * stealorders)
for (i = 0; i != norders && oa[i].unit->n <= oa[i].unit->wants; i++) { for (i = 0; i != norders && oa[i].unit->n <= oa[i].unit->wants; i++) {
unit *u = findunitg(oa[i].no, r); unit *u = findunitg(oa[i].no, r);
int n = 0; int n = 0;
if (u && u->region==r) n = new_get_pooled(u, r_silver, GET_ALL); if (u && u->region==r) n = get_pooled(u, r_silver, GET_ALL);
#ifndef GOBLINKILL #ifndef GOBLINKILL
if (oa[i].type.goblin) { /* Goblin-Spezialklau */ if (oa[i].type.goblin) { /* Goblin-Spezialklau */
int uct = 0; int uct = 0;
@ -2314,7 +2314,7 @@ expandstealing(region * r, request * stealorders)
} }
if (n > 0) { if (n > 0) {
n = min(n, oa[i].unit->wants); n = min(n, oa[i].unit->wants);
new_use_pooled(u, r_silver, GET_ALL, n); use_pooled(u, r_silver, GET_ALL, n);
oa[i].unit->n = n; oa[i].unit->n = n;
change_money(oa[i].unit, n); change_money(oa[i].unit, n);
ADDMSG(&u->faction->msgs, msg_message("stealeffect", "unit region amount", u, u->region, n)); ADDMSG(&u->faction->msgs, msg_message("stealeffect", "unit region amount", u, u->region, n));
@ -2353,12 +2353,12 @@ plant(region *r, unit *u, int raw)
return; return;
} }
/* Wasser des Lebens prüfen */ /* Wasser des Lebens prüfen */
if (new_get_pooled(u, rt_water, GET_DEFAULT) == 0) { if (get_pooled(u, rt_water, GET_DEFAULT) == 0) {
add_message(&u->faction->msgs, add_message(&u->faction->msgs,
msg_feedback(u, u->thisorder, "resource_missing", "missing", rt_water)); msg_feedback(u, u->thisorder, "resource_missing", "missing", rt_water));
return; return;
} }
n = new_get_pooled(u, itype->rtype, GET_DEFAULT); n = get_pooled(u, itype->rtype, GET_DEFAULT);
/* Kräuter prüfen */ /* Kräuter prüfen */
if (n==0) { if (n==0) {
add_message(&u->faction->msgs, add_message(&u->faction->msgs,
@ -2376,8 +2376,8 @@ plant(region *r, unit *u, int raw)
produceexp(u, SK_HERBALISM, u->number); produceexp(u, SK_HERBALISM, u->number);
/* Alles ok. Abziehen. */ /* Alles ok. Abziehen. */
new_use_pooled(u, rt_water, GET_DEFAULT, 1); use_pooled(u, rt_water, GET_DEFAULT, 1);
new_use_pooled(u, itype->rtype, GET_DEFAULT, n); use_pooled(u, itype->rtype, GET_DEFAULT, n);
rsetherbs(r, rherbs(r)+planted); rsetherbs(r, rherbs(r)+planted);
ADDMSG(&u->faction->msgs, msg_message("plant", "unit region amount herb", ADDMSG(&u->faction->msgs, msg_message("plant", "unit region amount herb",
u, r, planted, itype->rtype)); u, r, planted, itype->rtype));
@ -2415,7 +2415,7 @@ planttrees(region *r, unit *u, int raw)
return; return;
} }
n = new_get_pooled(u, rtype, GET_DEFAULT); n = get_pooled(u, rtype, GET_DEFAULT);
/* Samen prüfen */ /* Samen prüfen */
if (n==0) { if (n==0) {
add_message(&u->faction->msgs, add_message(&u->faction->msgs,
@ -2435,7 +2435,7 @@ planttrees(region *r, unit *u, int raw)
/* Alles ok. Abziehen. */ /* Alles ok. Abziehen. */
produceexp(u, SK_HERBALISM, u->number); produceexp(u, SK_HERBALISM, u->number);
new_use_pooled(u, rtype, GET_DEFAULT, n); use_pooled(u, rtype, GET_DEFAULT, n);
ADDMSG(&u->faction->msgs, msg_message("plant", ADDMSG(&u->faction->msgs, msg_message("plant",
"unit region amount herb", u, r, planted, rtype)); "unit region amount herb", u, r, planted, rtype));
@ -2474,7 +2474,7 @@ breedtrees(region *r, unit *u, int raw)
planttrees(r, u, raw); planttrees(r, u, raw);
return; return;
} }
n = new_get_pooled(u, rtype, GET_DEFAULT); n = get_pooled(u, rtype, GET_DEFAULT);
/* Samen prüfen */ /* Samen prüfen */
if (n==0) { if (n==0) {
add_message(&u->faction->msgs, add_message(&u->faction->msgs,
@ -2494,7 +2494,7 @@ breedtrees(region *r, unit *u, int raw)
/* Alles ok. Abziehen. */ /* Alles ok. Abziehen. */
produceexp(u, SK_HERBALISM, u->number); produceexp(u, SK_HERBALISM, u->number);
new_use_pooled(u, rtype, GET_DEFAULT, n); use_pooled(u, rtype, GET_DEFAULT, n);
add_message(&u->faction->msgs, new_message(u->faction, add_message(&u->faction->msgs, new_message(u->faction,
"plant%u:unit%r:region%i:amount%X:herb", u, r, planted, rtype)); "plant%u:unit%r:region%i:amount%X:herb", u, r, planted, rtype));

View File

@ -153,7 +153,7 @@ use_antimagiccrystal(unit * u, const struct item_type * itype, int amount, struc
create_curse(u, &r->attribs, ct_find("antimagiczone"), force, duration, var, 0); create_curse(u, &r->attribs, ct_find("antimagiczone"), force, duration, var, 0);
} }
} }
new_use_pooled(u, rt_crystal, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, amount); use_pooled(u, rt_crystal, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, amount);
ADDMSG(&u->faction->msgs, msg_message("use_antimagiccrystal", ADDMSG(&u->faction->msgs, msg_message("use_antimagiccrystal",
"unit region", u, r)); "unit region", u, r));
return 0; return 0;

View File

@ -2509,7 +2509,7 @@ promotion_cmd(unit * u, struct order * ord)
u->race)); u->race));
return 0; return 0;
} }
money = new_get_pooled(u, i_silver->rtype, GET_ALL); money = get_pooled(u, i_silver->rtype, GET_ALL);
people = count_all(u->faction) * u->number; people = count_all(u->faction) * u->number;
if (people>money) { if (people>money) {
@ -2517,7 +2517,7 @@ promotion_cmd(unit * u, struct order * ord)
people, money)); people, money));
return 0; return 0;
} }
new_use_pooled(u, i_silver->rtype, GET_ALL, people); use_pooled(u, i_silver->rtype, GET_ALL, people);
fset(u, UFL_HERO); fset(u, UFL_HERO);
ADDMSG(&u->faction->msgs, msg_message("hero_promotion", "unit cost", ADDMSG(&u->faction->msgs, msg_message("hero_promotion", "unit cost",
u, people)); u, people));
@ -3602,7 +3602,7 @@ use_item(unit * u, const item_type * itype, int amount, struct order * ord)
int i; int i;
int target = read_unitid(u->faction, u->region); int target = read_unitid(u->faction, u->region);
i = new_get_pooled(u, itype->rtype, GET_DEFAULT); i = get_pooled(u, itype->rtype, GET_DEFAULT);
if (amount>i) { if (amount>i) {
amount = i; amount = i;

View File

@ -194,7 +194,7 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
int j = study_cost(student, sk); int j = study_cost(student, sk);
j = max(50, j * 2); j = max(50, j * 2);
/* kann Einheit das zahlen? */ /* kann Einheit das zahlen? */
if (new_get_pooled(student, oldresourcetype[R_SILVER], GET_DEFAULT) >= j) { if (get_pooled(student, oldresourcetype[R_SILVER], GET_DEFAULT) >= j) {
/* Jeder Schüler zusätzlich +10 Tage wenn in Uni. */ /* Jeder Schüler zusätzlich +10 Tage wenn in Uni. */
teach->value += (n / 30) * 10; /* learning erhöhen */ teach->value += (n / 30) * 10; /* learning erhöhen */
/* Lehrer zusätzlich +1 Tag pro Schüler. */ /* Lehrer zusätzlich +1 Tag pro Schüler. */
@ -608,7 +608,7 @@ learn(void)
} }
} }
if (studycost) { if (studycost) {
money = new_get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT); money = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT);
money = min(money, studycost * u->number); money = min(money, studycost * u->number);
} }
if (money < studycost * u->number) { if (money < studycost * u->number) {
@ -631,7 +631,7 @@ learn(void)
teach->teachers[0] = 0; teach->teachers[0] = 0;
} }
if (money>0) { if (money>0) {
new_use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, money); use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, money);
add_message(&u->faction->msgs, msg_message("studycost", add_message(&u->faction->msgs, msg_message("studycost",
"unit region cost skill", u, u->region, money, sk)); "unit region cost skill", u, u->region, money, sk));
} }

View File

@ -173,7 +173,7 @@ attack_catapult(const troop * at, const struct weapon_type * wtype, int * casual
assert(af->person[at->index].reload==0); assert(af->person[at->index].reload==0);
if (it_catapultammo!=NULL) { if (it_catapultammo!=NULL) {
if (new_get_pooled(au, it_catapultammo->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK) <= 0) { if (get_pooled(au, it_catapultammo->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK) <= 0) {
/* No ammo. Use other weapon if available. */ /* No ammo. Use other weapon if available. */
return true; return true;
} }
@ -194,7 +194,7 @@ attack_catapult(const troop * at, const struct weapon_type * wtype, int * casual
n = min(CATAPULT_ATTACKS, count_enemies(b, af->side, minrow, maxrow, true)); n = min(CATAPULT_ATTACKS, count_enemies(b, af->side, minrow, maxrow, true));
if (it_catapultammo!=NULL) { if (it_catapultammo!=NULL) {
new_use_pooled(au, it_catapultammo->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, 1); use_pooled(au, it_catapultammo->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, 1);
} }
while (--n >= 0) { while (--n >= 0) {

View File

@ -106,10 +106,10 @@ use_potion(unit * u, const item_type * itype, int amount, struct order *ord)
/* für die Aufforstung von Mallornwäldern braucht man Mallorn */ /* für die Aufforstung von Mallornwäldern braucht man Mallorn */
if (fval(r, RF_MALLORN)) { if (fval(r, RF_MALLORN)) {
holz = new_use_pooled(u, oldresourcetype[R_MALLORN], holz = use_pooled(u, oldresourcetype[R_MALLORN],
GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, 10*amount); GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, 10*amount);
} else { } else {
holz = new_use_pooled(u, oldresourcetype[R_WOOD], holz = use_pooled(u, oldresourcetype[R_WOOD],
GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, 10*amount); GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, 10*amount);
} }
if (r->land==0) holz=0; if (r->land==0) holz=0;
@ -139,7 +139,7 @@ use_potion(unit * u, const item_type * itype, int amount, struct order *ord)
} else { } else {
change_effect(u, ptype, 10*amount); change_effect(u, ptype, 10*amount);
} }
new_use_pooled(u, ptype->itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, amount); use_pooled(u, ptype->itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, amount);
usetpotionuse(u, ptype); usetpotionuse(u, ptype);
ADDMSG(&u->faction->msgs, msg_message("usepotion", ADDMSG(&u->faction->msgs, msg_message("usepotion",

View File

@ -221,7 +221,7 @@ siege_cmd(unit * u, order * ord)
/* schaden durch katapulte */ /* schaden durch katapulte */
d = min(u->number, d = min(u->number,
min(new_get_pooled(u, it_catapultammo->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK), get_item(u, I_CATAPULT))); min(get_pooled(u, it_catapultammo->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK), get_item(u, I_CATAPULT)));
if (eff_skill(u, SK_CATAPULT, r) >= 1) { if (eff_skill(u, SK_CATAPULT, r) >= 1) {
katapultiere = d; katapultiere = d;
d *= eff_skill(u, SK_CATAPULT, r); d *= eff_skill(u, SK_CATAPULT, r);
@ -255,7 +255,7 @@ siege_cmd(unit * u, order * ord)
/* meldung, schaden anrichten */ /* meldung, schaden anrichten */
if (d && !curse_active(get_curse(b->attribs, magicwalls_ct))) { if (d && !curse_active(get_curse(b->attribs, magicwalls_ct))) {
b->size -= d; b->size -= d;
new_use_pooled(u, it_catapultammo->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, d); use_pooled(u, it_catapultammo->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, d);
d = 100 * d / b->size; d = 100 * d / b->size;
} else d = 0; } else d = 0;
@ -508,7 +508,7 @@ build_road(region * r, unit * u, int size, direction_t d)
return; return;
} }
} }
if (!new_get_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT) && u->race != new_race[RC_STONEGOLEM]) { if (!get_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT) && u->race != new_race[RC_STONEGOLEM]) {
cmistake(u, u->thisorder, 151, MSG_PRODUCE); cmistake(u, u->thisorder, 151, MSG_PRODUCE);
return; return;
} }
@ -527,7 +527,7 @@ build_road(region * r, unit * u, int size, direction_t d)
if (u->race == new_race[RC_STONEGOLEM]){ if (u->race == new_race[RC_STONEGOLEM]){
n = u->number * GOLEM_STONE; n = u->number * GOLEM_STONE;
} else { } else {
n = new_get_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT); n = get_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT);
} }
left = min(n, left); left = min(n, left);
if (size>0) left = min(size, 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); scale_number(u, u->number - golemsused);
} else { } else {
new_use_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT, n); use_pooled(u, oldresourcetype[R_STONE], GET_DEFAULT, n);
/* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */ /* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */
produceexp(u, SK_ROAD_BUILDING, min(n, u->number)); produceexp(u, SK_ROAD_BUILDING, min(n, u->number));
} }
@ -718,7 +718,7 @@ build(unit * u, const construction * ctype, int completed, int want)
if (type->materials) for (c=0;n>0 && type->materials[c].number;c++) { if (type->materials) for (c=0;n>0 && type->materials[c].number;c++) {
const struct resource_type * rtype = type->materials[c].rtype; const struct resource_type * rtype = type->materials[c].rtype;
int need; int need;
int have = new_get_pooled(u, rtype, GET_DEFAULT); int have = get_pooled(u, rtype, GET_DEFAULT);
int prebuilt; int prebuilt;
int canuse = have; int canuse = have;
if (inside_building(u)) { if (inside_building(u)) {
@ -756,7 +756,7 @@ build(unit * u, const construction * ctype, int completed, int want)
multi = canuse/100; multi = canuse/100;
if (canuse<0) return canuse; /* pass errors to caller */ if (canuse<0) return canuse; /* pass errors to caller */
new_use_pooled(u, rtype, GET_DEFAULT, (need-prebuilt+multi-1)/multi); use_pooled(u, rtype, GET_DEFAULT, (need-prebuilt+multi-1)/multi);
} }
made += n; made += n;
skills -= n * type->minskill; skills -= n * type->minskill;
@ -778,7 +778,7 @@ maxbuild(const unit * u, const construction * cons)
int maximum = INT_MAX; int maximum = INT_MAX;
for (c=0;cons->materials[c].number;c++) { for (c=0;cons->materials[c].number;c++) {
const resource_type * rtype = cons->materials[c].rtype; const resource_type * rtype = cons->materials[c].rtype;
int have = new_get_pooled(u, rtype, GET_DEFAULT); int have = get_pooled(u, rtype, GET_DEFAULT);
int need = required(1, cons->reqsize, cons->materials[c].number); int need = required(1, cons->reqsize, cons->materials[c].number);
if (have<need) { if (have<need) {
cmistake(u, u->thisorder, 88, MSG_PRODUCE); cmistake(u, u->thisorder, 88, MSG_PRODUCE);

View File

@ -96,7 +96,7 @@ give_item(int want, const item_type * itype, unit * src, unit * dest, struct ord
int n; int n;
assert(itype!=NULL); assert(itype!=NULL);
n = new_get_pooled(src, item2resource(itype), GET_DEFAULT); n = get_pooled(src, item2resource(itype), GET_DEFAULT);
n = min(want, n); n = min(want, n);
if (dest && src->faction != dest->faction && src->faction->age < GiveRestriction()) { if (dest && src->faction != dest->faction && src->faction->age < GiveRestriction()) {
if (ord!=NULL) { if (ord!=NULL) {
@ -111,8 +111,8 @@ give_item(int want, const item_type * itype, unit * src, unit * dest, struct ord
} else if (itype->give && !itype->give(src, dest, itype, n, ord)) { } else if (itype->give && !itype->give(src, dest, itype, n, ord)) {
return -1; return -1;
} else { } else {
int use = new_use_pooled(src, item2resource(itype), GET_SLACK, n); int use = use_pooled(src, item2resource(itype), GET_SLACK, n);
if (use<n) use += new_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);
if (dest) { if (dest) {
i_change(&dest->items, itype, n); i_change(&dest->items, itype, n);
#ifdef RESERVE_GIVE #ifdef RESERVE_GIVE

View File

@ -690,7 +690,7 @@ use_tacticcrystal(region * r, unit * u, int amount, struct order * ord)
c->data.i = SK_TACTICS; c->data.i = SK_TACTICS;
unused(ord); unused(ord);
} }
new_use_pooled(u, oldresourcetype[R_TACTICCRYSTAL], GET_DEFAULT, amount); use_pooled(u, oldresourcetype[R_TACTICCRYSTAL], GET_DEFAULT, amount);
add_message(&u->faction->msgs, add_message(&u->faction->msgs,
new_message(u->faction, "use_tacticcrystal%u:unit%r:region", u, r)); new_message(u->faction, "use_tacticcrystal%u:unit%r:region", u, r));
return; return;
@ -1266,7 +1266,7 @@ use_healingpotion(struct unit *user, const struct item_type *itype, int amount,
} }
u = u->next; u = u->next;
} }
new_use_pooled(user, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, amount); use_pooled(user, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, amount);
usetpotionuse(user, itype->rtype->ptype); usetpotionuse(user, itype->rtype->ptype);
ADDMSG(&user->faction->msgs, msg_message("usepotion", ADDMSG(&user->faction->msgs, msg_message("usepotion",
@ -1284,7 +1284,7 @@ use_warmthpotion(struct unit *u, const struct item_type *itype, int amount, stru
cmistake(u, ord, 163, MSG_EVENT); cmistake(u, ord, 163, MSG_EVENT);
return ECUSTOM; return ECUSTOM;
} }
new_use_pooled(u, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, amount); use_pooled(u, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, amount);
usetpotionuse(u, itype->rtype->ptype); usetpotionuse(u, itype->rtype->ptype);
ADDMSG(&u->faction->msgs, msg_message("usepotion", ADDMSG(&u->faction->msgs, msg_message("usepotion",
@ -1308,7 +1308,7 @@ use_foolpotion(struct unit *u, int targetno, const struct item_type *itype, int
"unit recipient amount", u, target, amount)); "unit recipient amount", u, target, amount));
change_effect(target, itype->rtype->ptype, amount); change_effect(target, itype->rtype->ptype, amount);
new_use_pooled(u, itype->rtype, GET_DEFAULT, amount); use_pooled(u, itype->rtype, GET_DEFAULT, amount);
return 0; return 0;
} }
@ -1324,7 +1324,7 @@ use_bloodpotion(struct unit *u, const struct item_type *itype, int amount, struc
add_trigger(&u->attribs, "timer", trigger_timeout(duration, trestore)); add_trigger(&u->attribs, "timer", trigger_timeout(duration, trestore));
u->irace = u->race = new_race[RC_TOAD]; u->irace = u->race = new_race[RC_TOAD];
} }
new_use_pooled(u, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, amount); use_pooled(u, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, amount);
usetpotionuse(u, itype->rtype->ptype); usetpotionuse(u, itype->rtype->ptype);
ADDMSG(&u->faction->msgs, msg_message("usepotion", ADDMSG(&u->faction->msgs, msg_message("usepotion",
@ -1336,14 +1336,14 @@ use_bloodpotion(struct unit *u, const struct item_type *itype, int amount, struc
static int static int
use_mistletoe(struct unit * user, const struct item_type * itype, int amount, struct order * ord) use_mistletoe(struct unit * user, const struct item_type * itype, int amount, struct order * ord)
{ {
int mtoes = new_get_pooled(user, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK); int mtoes = get_pooled(user, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK);
if (user->number>mtoes) { if (user->number>mtoes) {
ADDMSG(&user->faction->msgs, msg_message("use_singleperson", ADDMSG(&user->faction->msgs, msg_message("use_singleperson",
"unit item region command", user, itype->rtype, user->region, ord)); "unit item region command", user, itype->rtype, user->region, ord));
return -1; return -1;
} }
new_use_pooled(user, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, user->number); use_pooled(user, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, user->number);
a_add(&user->attribs, make_fleechance((float)1.0)); a_add(&user->attribs, make_fleechance((float)1.0));
ADDMSG(&user->faction->msgs, msg_message("use_item", ADDMSG(&user->faction->msgs, msg_message("use_item",
"unit item", user, itype->rtype)); "unit item", user, itype->rtype));
@ -1354,7 +1354,7 @@ use_mistletoe(struct unit * user, const struct item_type * itype, int amount, st
static int static int
use_magicboost(struct unit * user, const struct item_type * itype, int amount, struct order * ord) use_magicboost(struct unit * user, const struct item_type * itype, int amount, struct order * ord)
{ {
int mtoes = new_get_pooled(user, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK); int mtoes = get_pooled(user, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK);
faction * f = user->faction; faction * f = user->faction;
if (user->number>mtoes) { if (user->number>mtoes) {
ADDMSG(&user->faction->msgs, msg_message("use_singleperson", ADDMSG(&user->faction->msgs, msg_message("use_singleperson",
@ -1365,7 +1365,7 @@ use_magicboost(struct unit * user, const struct item_type * itype, int amount, s
cmistake(user, user->thisorder, 214, MSG_EVENT); cmistake(user, user->thisorder, 214, MSG_EVENT);
return -1; return -1;
} }
new_use_pooled(user, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, user->number); use_pooled(user, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, user->number);
a_add(&f->attribs, make_key(atoi36("mbst"))); a_add(&f->attribs, make_key(atoi36("mbst")));
set_level(user, sk_find("magic"), 3); set_level(user, sk_find("magic"), 3);

View File

@ -381,7 +381,7 @@ sacrifice_cmd(unit * u, struct order * ord)
switch(findparam(s, u->faction->locale)) { switch(findparam(s, u->faction->locale)) {
case P_SILVER: case P_SILVER:
n = new_use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, n); n = use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, n);
if(n < 10000) { if(n < 10000) {
cmistake(u, ord, 51, MSG_EVENT); cmistake(u, ord, 51, MSG_EVENT);
return 0; return 0;

View File

@ -782,7 +782,7 @@ eff_spelllevel(unit *u, const spell * sp, int cast_level, int range)
} else { } else {
needplevel = sp->components[k].amount * range; needplevel = sp->components[k].amount * range;
} }
maxlevel = new_get_pooled(u, sp->components[k].type, GET_DEFAULT)/needplevel; maxlevel = get_pooled(u, sp->components[k].type, GET_DEFAULT)/needplevel;
/* sind die Kosten fix, so muss die Komponente nur einmal vorhanden /* sind die Kosten fix, so muss die Komponente nur einmal vorhanden
* sein und der cast_level ändert sich nicht */ * sein und der cast_level ändert sich nicht */
@ -836,7 +836,7 @@ pay_spell(unit * u, const spell * sp, int cast_level, int range)
resuse *= cast_level; resuse *= cast_level;
} }
new_use_pooled(u, sp->components[k].type, GET_DEFAULT, resuse); use_pooled(u, sp->components[k].type, GET_DEFAULT, resuse);
} }
} }
@ -927,7 +927,7 @@ cancast(unit * u, const spell * sp, int level, int range, struct order * ord)
break; break;
} }
if (new_get_pooled(u, rtype, GET_DEFAULT) < itemanz) { if (get_pooled(u, rtype, GET_DEFAULT) < itemanz) {
if (b == false) { if (b == false) {
/* es fehlte schon eine andere Komponente, wir basteln die /* es fehlte schon eine andere Komponente, wir basteln die
* Meldung weiter zusammen */ * Meldung weiter zusammen */

View File

@ -166,7 +166,7 @@ new_set_resvalue(unit * u, const resource_type * rtype, int value)
} }
int int
new_get_pooled(const unit * u, const resource_type * rtype, unsigned int mode) get_pooled(const unit * u, const resource_type * rtype, unsigned int mode)
{ {
const faction * f = u->faction; const faction * f = u->faction;
unit *v; unit *v;
@ -202,14 +202,14 @@ new_get_pooled(const unit * u, const resource_type * rtype, unsigned int mode)
} }
else if (alliedunit(v, f, HELP_MONEY)) mask = (mode >> 6) & (GET_SLACK|GET_RESERVE); else if (alliedunit(v, f, HELP_MONEY)) mask = (mode >> 6) & (GET_SLACK|GET_RESERVE);
else continue; else continue;
use += new_get_pooled(v, rtype, mask); use += get_pooled(v, rtype, mask);
} }
} }
return use; return use;
} }
int int
new_use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count) use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
{ {
const faction *f = u->faction; const faction *f = u->faction;
unit *v; unit *v;
@ -253,7 +253,7 @@ new_use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int cou
} }
else if (alliedunit(v, f, HELP_MONEY)) mask = (mode >> 6) & (GET_SLACK|GET_RESERVE); else if (alliedunit(v, f, HELP_MONEY)) mask = (mode >> 6) & (GET_SLACK|GET_RESERVE);
else continue; else continue;
use -= new_use_pooled(v, rtype, mask, use); use -= use_pooled(v, rtype, mask, use);
} }
} }
return count-use; return count-use;
@ -284,7 +284,7 @@ init_pool(void)
if (rtype == NULL) continue; if (rtype == NULL) continue;
new_set_resvalue(u, rtype, 0); /* make sure the pool is empty */ new_set_resvalue(u, rtype, 0); /* make sure the pool is empty */
use = new_use_pooled(u, rtype, GET_DEFAULT, count); use = use_pooled(u, rtype, GET_DEFAULT, count);
if (use) { if (use) {
new_set_resvalue(u, rtype, use); new_set_resvalue(u, rtype, use);
change_resource(u, rtype, use); change_resource(u, rtype, use);

View File

@ -32,8 +32,8 @@ extern "C" {
#define GET_DEFAULT (GET_RESERVE|GET_SLACK|GET_POOLED_SLACK) #define GET_DEFAULT (GET_RESERVE|GET_SLACK|GET_POOLED_SLACK)
#define GET_ALL (GET_SLACK|GET_RESERVE|GET_POOLED_SLACK|GET_POOLED_RESERVE|GET_POOLED_FORCE) #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, unsigned int mode); int get_pooled(const struct unit * u, const struct resource_type * res, unsigned int mode);
int new_use_pooled(struct unit * u, const struct resource_type * res, unsigned int mode, int count); int use_pooled(struct unit * u, const struct resource_type * res, unsigned int mode, int count);
/** use_pooled /** use_pooled
* verbraucht 'count' Objekte der resource 'itm' * verbraucht 'count' Objekte der resource 'itm'
* unter zuhilfenahme des Pools der struct region und Aufbrauch des * unter zuhilfenahme des Pools der struct region und Aufbrauch des

View File

@ -120,7 +120,7 @@ enter_arena(unit * u, const item_type * itype, int amount, order * ord)
if (fee>2000) fee = 2000; if (fee>2000) fee = 2000;
if (getplane(r)==arena) return -1; if (getplane(r)==arena) return -1;
if (u->number!=1 && enter_fail(u)) return -1; if (u->number!=1 && enter_fail(u)) return -1;
if (new_get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT) < fee && enter_fail(u)) return -1; if (get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT) < fee && enter_fail(u)) return -1;
for (sk=0;sk!=MAXSKILLS;++sk) { for (sk=0;sk!=MAXSKILLS;++sk) {
if (get_level(u, sk)>1 && enter_fail(u)) return -1; if (get_level(u, sk)>1 && enter_fail(u)) return -1;
} }
@ -145,8 +145,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)); 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); addmessage(NULL, u->faction, buf, MSG_MESSAGE, ML_IMPORTANT);
new_use_pooled(u, itype->rtype, GET_SLACK|GET_RESERVE, 1); use_pooled(u, itype->rtype, GET_SLACK|GET_RESERVE, 1);
new_use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, fee); use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, fee);
set_money(u, 109); set_money(u, 109);
fset(u, UFL_PARTEITARNUNG); fset(u, UFL_PARTEITARNUNG);
move_unit(u, start_region[rand() % 6], NULL); move_unit(u, start_region[rand() % 6], NULL);