Ring der flinken Finger funktioniert nicht beim Strassenbau

Aussedem ist die Berechnung der benötigten Schaffenstrünke ungeschickt gewesen. Besseres limitieren der Baumenge implementiert.
Issue: 559
This commit is contained in:
Enno Rehling 2005-06-13 19:27:11 +00:00
parent 9a86f30fa0
commit e0da91327d
1 changed files with 35 additions and 25 deletions

View File

@ -467,7 +467,7 @@ destroy_cmd(unit * u, struct order * ord)
void
build_road(region * r, unit * u, int size, direction_t d)
{
int n, dm, left;
int n, left;
if (!eff_skill(u, SK_ROAD_BUILDING, r)) {
cmistake(u, u->thisorder, 103, MSG_PRODUCE);
@ -520,41 +520,50 @@ build_road(region * r, unit * u, int size, direction_t d)
/* left kann man noch bauen */
left = terrain[rterrain(r)].roadreq - rroad(r, d);
if (size > 0) {
n = min(size, left);
} else {
n = left;
}
/* hoffentlich ist r->road <= terrain[rterrain(r)].roadreq, n also >= 0 */
if (n <= 0) {
if (left <= 0) {
sprintf(buf, "In %s gibt es keine Brücken und Straßen "
"mehr zu bauen", regionname(r, u->faction));
mistake(u, u->thisorder, buf, MSG_PRODUCE);
return;
}
/* max Bauten anhand des Talentes */
n = min(n, u->number * eff_skill(u, SK_ROAD_BUILDING, r));
/* baumaximum anhand der rohstoffe */
if (u->race == new_race[RC_STONEGOLEM]){
n = u->number * GOLEM_STONE;
} else {
n = get_pooled(u, r, R_STONE);
}
left = min(n, left);
if (size>0) left = min(size, left);
if ((dm = get_effect(u, oldpotiontype[P_DOMORE])) != 0) {
/* n = maximum by skill. try to maximize it */
n = u->number * eff_skill(u, SK_ROAD_BUILDING, r);
if (n < left) {
item * itm = *i_find(&u->items, olditemtype[I_RING_OF_NIMBLEFINGER]);
if (itm!=NULL && itm->number>0) {
int rings = min(u->number, itm->number);
n = n * (9*rings+u->number) / u->number;
}
}
if (n < left) {
int dm = get_effect(u, oldpotiontype[P_DOMORE]);
if (dm != 0) {
int sk = eff_skill(u, SK_ROAD_BUILDING, r);
dm = (left - n + sk - 1) / sk;
dm = min(dm, u->number);
change_effect(u, oldpotiontype[P_DOMORE], -dm);
n += dm * eff_skill(u, SK_ROAD_BUILDING, r);
n += dm * sk;
} /* Auswirkung Schaffenstrunk */
/* und anhand der rohstoffe */
if (u->race == new_race[RC_STONEGOLEM]){
n = min(n, u->number * GOLEM_STONE);
} else {
n = use_pooled(u, r, R_STONE, n);
}
/* make minimum of possible and available: */
n = min(left, n);
/* n is now modified by several special effects, so we have to
* minimize it again to make sure the road will not grow beyond
* maximum. */
rsetroad(r, d, rroad(r, d) + (short)min(n, left));
rsetroad(r, d, rroad(r, d) + (short)n);
if (u->race == new_race[RC_STONEGOLEM]) {
int golemsused = n / GOLEM_STONE;
@ -563,6 +572,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);
/* Nur soviel PRODUCEEXP wie auch tatsaechlich gemacht wurde */
produceexp(u, SK_ROAD_BUILDING, min(n, u->number));
}