- status flee does not immediately remove the guard status,  but delayed.
This commit is contained in:
Enno Rehling 2009-07-10 19:36:26 +00:00
parent bfcba5e94e
commit 9124a86e0e
2 changed files with 47 additions and 50 deletions

View file

@ -949,26 +949,26 @@ static boolean
maintain(building * b, boolean first) maintain(building * b, boolean first)
/* first==false -> take money from wherever you can */ /* first==false -> take money from wherever you can */
{ {
int c; int c;
region * r = b->region; region * r = b->region;
boolean paid = true, work = first; boolean paid = true, work = first;
unit * u; unit * u;
if (fval(b, BLD_MAINTAINED) || b->type==NULL || b->type->maintenance==NULL || is_cursed(b->attribs, C_NOCOST, 0)) { if (fval(b, BLD_MAINTAINED) || b->type==NULL || b->type->maintenance==NULL || is_cursed(b->attribs, C_NOCOST, 0)) {
fset(b, BLD_MAINTAINED); fset(b, BLD_MAINTAINED);
fset(b, BLD_WORKING); fset(b, BLD_WORKING);
return true; return true;
} }
u = buildingowner(r, b); u = buildingowner(r, b);
if (u==NULL) return false; if (u==NULL) return false;
for (c=0;b->type->maintenance[c].number;++c) { for (c=0;b->type->maintenance[c].number;++c) {
const maintenance * m = b->type->maintenance+c; const maintenance * m = b->type->maintenance+c;
int need = m->number; int need = m->number;
if (fval(m, MTF_VARIABLE)) need = need * b->size; if (fval(m, MTF_VARIABLE)) need = need * b->size;
if (u) { if (u) {
/* 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 -= get_pooled(u, m->rtype, GET_ALL, need); if (!first) need -= get_pooled(u, m->rtype, GET_ALL, need);
else need -= get_pooled(u, m->rtype, GET_DEFAULT, need); else need -= get_pooled(u, m->rtype, GET_DEFAULT, need);
if (!first && need > 0) { if (!first && need > 0) {
@ -995,46 +995,46 @@ maintain(building * b, boolean first)
if (paid && c>0) { if (paid && c>0) {
/* TODO: wieviel von was wurde bezahlt */ /* TODO: wieviel von was wurde bezahlt */
if (first) { if (first) {
ADDMSG(&u->faction->msgs, msg_message("maintenance", "unit building", u, b)); ADDMSG(&u->faction->msgs, msg_message("maintenance", "unit building", u, b));
} else { } else {
ADDMSG(&u->faction->msgs, msg_message("maintenance_late", "building", b)); ADDMSG(&u->faction->msgs, msg_message("maintenance_late", "building", b));
} }
fset(b, BLD_MAINTAINED); fset(b, BLD_MAINTAINED);
if (work) { if (work) {
fset(b, BLD_WORKING); fset(b, BLD_WORKING);
} }
for (c=0;b->type->maintenance[c].number;++c) { for (c=0;b->type->maintenance[c].number;++c) {
const maintenance * m = b->type->maintenance+c; const maintenance * m = b->type->maintenance+c;
int cost = m->number; int cost = m->number;
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 -= use_pooled(u, m->rtype, GET_ALL, cost); if (!first) cost -= use_pooled(u, m->rtype, GET_ALL, cost);
else cost -= 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, FFL_SELECT); for (ua=r->units;ua;ua=ua->next) freset(ua->faction, FFL_SELECT);
fset(u->faction, FFL_SELECT); /* hat schon */ fset(u->faction, FFL_SELECT); /* hat schon */
for (ua=r->units;ua;ua=ua->next) { for (ua=r->units;ua;ua=ua->next) {
if (!fval(ua->faction, FFL_SELECT) && alliedunit(ua, u->faction, HELP_MONEY)) { if (!fval(ua->faction, FFL_SELECT) && alliedunit(ua, u->faction, HELP_MONEY)) {
int give = 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, FFL_SELECT); fset(ua->faction, FFL_SELECT);
if (m->rtype==r_silver) add_spende(ua->faction, u->faction, give, r); if (m->rtype==r_silver) add_spende(ua->faction, u->faction, give, r);
if (cost<=0) break; if (cost<=0) break;
} }
} }
} }
assert(cost==0); assert(cost==0);
} }
} else { } else {
ADDMSG(&u->faction->msgs, ADDMSG(&u->faction->msgs,
msg_message("maintenancefail", "unit building", u, b)); msg_message("maintenancefail", "unit building", u, b));
return false; return false;
} }
return true; return true;
} }
#ifdef COLLAPSE_CHANCE #ifdef COLLAPSE_CHANCE

View file

@ -2246,9 +2246,6 @@ setstatus(struct unit * u, int status)
assert(status>=ST_AGGRO && status<=ST_FLEE); assert(status>=ST_AGGRO && status<=ST_FLEE);
if (u->status!=status) { if (u->status!=status) {
u->status = (status_t)status; u->status = (status_t)status;
if (u->status==ST_FLEE) {
setguard(u, GUARD_NONE);
}
} }
} }