remove any reference to old two-stage maintenance.

getting rid of a lot of dead code.
This commit is contained in:
Enno Rehling 2016-08-21 18:06:38 +02:00
parent 901cf97cb2
commit 43090e1492
5 changed files with 26 additions and 111 deletions

View File

@ -7087,13 +7087,6 @@
<text locale="de">"Der Unterhalt von $building($building) konnte nicht gezahlt werden, das Gebäude war diese Woche nicht funktionstüchtig."</text> <text locale="de">"Der Unterhalt von $building($building) konnte nicht gezahlt werden, das Gebäude war diese Woche nicht funktionstüchtig."</text>
<text locale="en">"The upkeep for $building($building) was not paid, the building was not operational this week."</text> <text locale="en">"The upkeep for $building($building) was not paid, the building was not operational this week."</text>
</message> </message>
<message name="maintenance_late" section="errors">
<type>
<arg name="building" type="building"/>
</type>
<text locale="de">"Der Unterhalt von $building($building) konnte nur verspätet gezahlt werden, das Gebäude war diese Woche nicht funktionstüchtig."</text>
<text locale="en">"The upkeep for $building($building) was paid late, the building was not operational this week."</text>
</message>
<message name="income_tradetax" section="economy"> <message name="income_tradetax" section="economy">
<type> <type>
<arg name="unit" type="unit"/> <arg name="unit" type="unit"/>

View File

@ -274,7 +274,7 @@ void process_maintenance(void) {
} }
} }
} }
maintain_buildings(r, false); maintain_buildings(r);
} }
} }

View File

@ -709,13 +709,11 @@ static int forget_cmd(unit * u, order * ord)
return 0; return 0;
} }
static int maintain(building * b, bool first) static int maintain(building * b)
/* first==false -> take money from wherever you can */
{ {
const resource_type *rsilver = get_resourcetype(R_SILVER);
int c; int c;
region *r = b->region; region *r = b->region;
bool paid = true, work = first; bool paid = true, work = true;
unit *u; unit *u;
if (fval(b, BLD_MAINTAINED) || b->type == NULL || b->type->maintenance == NULL) { if (fval(b, BLD_MAINTAINED) || b->type == NULL || b->type->maintenance == NULL) {
@ -746,25 +744,7 @@ static int maintain(building * b, bool 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 -= get_pooled(u, m->rtype, GET_DEFAULT, need);
need -= get_pooled(u, m->rtype, GET_ALL, need);
else
need -= get_pooled(u, m->rtype, GET_DEFAULT, need);
if (!first && need > 0) {
unit *ua;
for (ua = r->units; ua; ua = ua->next)
freset(ua->faction, FFL_SELECT);
fset(u->faction, FFL_SELECT); /* hat schon */
for (ua = r->units; ua; ua = ua->next) {
if (!fval(ua->faction, FFL_SELECT) && (ua->faction == u->faction
|| alliedunit(ua, u->faction, HELP_MONEY))) {
need -= get_pooled(ua, m->rtype, GET_ALL, need);
fset(ua->faction, FFL_SELECT);
if (need <= 0)
break;
}
}
}
} }
if (need > 0) { if (need > 0) {
if (!fval(m, MTF_VITAL)) if (!fval(m, MTF_VITAL))
@ -789,32 +769,10 @@ static int maintain(building * b, bool first)
if (fval(m, MTF_VARIABLE)) if (fval(m, MTF_VARIABLE))
need = need * b->size; need = need * b->size;
if (u) { if (u) {
/* first ist im ersten versuch true, im zweiten aber false! Das need -= get_pooled(u, m->rtype, GET_DEFAULT, need);
* bedeutet, das in der Runde in die Region geschafften Resourcen
* nicht genutzt werden können, weil die reserviert sind! */
if (!first)
need -= get_pooled(u, m->rtype, GET_ALL, need);
else
need -= get_pooled(u, m->rtype, GET_DEFAULT, need);
if (!first && need > 0) {
unit *ua;
for (ua = r->units; ua; ua = ua->next)
freset(ua->faction, FFL_SELECT);
fset(u->faction, FFL_SELECT); /* hat schon */
for (ua = r->units; ua; ua = ua->next) {
if (!fval(ua->faction, FFL_SELECT) && (ua->faction == u->faction
|| alliedunit(ua, u->faction, HELP_MONEY))) {
need -= get_pooled(ua, m->rtype, GET_ALL, need);
fset(ua->faction, FFL_SELECT);
if (need <= 0)
break;
}
}
}
if (need > 0) { if (need > 0) {
work = false; work = false;
if (fval(m, MTF_VITAL)) if (fval(m, MTF_VITAL)) {
{
paid = false; paid = false;
break; break;
} }
@ -822,7 +780,7 @@ static int maintain(building * b, bool first)
} }
} }
if (paid && c > 0) { if (paid && c > 0) {
if (first && !work) { if (!work) {
ADDMSG(&u->faction->msgs, msg_message("maintenancefail", "unit building", u, b)); ADDMSG(&u->faction->msgs, msg_message("maintenancefail", "unit building", u, b));
return 0; return 0;
} }
@ -836,39 +794,12 @@ static int maintain(building * b, bool first)
if (fval(m, MTF_VARIABLE)) if (fval(m, MTF_VARIABLE))
cost = cost * b->size; cost = cost * b->size;
if (!first) cost -=
cost -= use_pooled(u, m->rtype, GET_ALL, cost);
else
cost -=
use_pooled(u, m->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, use_pooled(u, m->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK,
cost); cost);
if (!first && cost > 0) {
unit *ua;
for (ua = r->units; ua; ua = ua->next)
freset(ua->faction, FFL_SELECT);
fset(u->faction, FFL_SELECT); /* hat schon */
for (ua = r->units; ua; ua = ua->next) {
if (!fval(ua->faction, FFL_SELECT)
&& alliedunit(ua, u->faction, HELP_MONEY)) {
int give = use_pooled(ua, m->rtype, GET_ALL, cost);
if (!give)
continue;
cost -= give;
fset(ua->faction, FFL_SELECT);
if (m->rtype == rsilver)
add_donation(ua->faction, u->faction, give, r);
if (cost <= 0)
break;
}
}
}
assert(cost == 0); assert(cost == 0);
} }
if (!first) { if (work) {
ADDMSG(&u->faction->msgs, msg_message("maintenance_late", "building", b));
return (BLD_MAINTAINED);
}
else if (work) {
ADDMSG(&u->faction->msgs, msg_message("maintenance", "unit building", u, b)); ADDMSG(&u->faction->msgs, msg_message("maintenance", "unit building", u, b));
return (BLD_MAINTAINED | BLD_WORKING); return (BLD_MAINTAINED | BLD_WORKING);
} }
@ -877,7 +808,7 @@ static int maintain(building * b, bool first)
return 0; return 0;
} }
void maintain_buildings(region * r, bool crash) void maintain_buildings(region * r)
{ {
const curse_type *nocost_ct = ct_find("nocostbuilding"); const curse_type *nocost_ct = ct_find("nocostbuilding");
building **bp = &r->buildings; building **bp = &r->buildings;
@ -886,27 +817,24 @@ void maintain_buildings(region * r, bool crash)
int flags = (BLD_MAINTAINED | BLD_WORKING); int flags = (BLD_MAINTAINED | BLD_WORKING);
if (!curse_active(get_curse(b->attribs, nocost_ct))) { if (!curse_active(get_curse(b->attribs, nocost_ct))) {
flags = maintain(b, !crash); flags = maintain(b);
} }
fset(b, flags); fset(b, flags);
/* the second time, send a message */ if (!fval(b, BLD_WORKING)) {
if (crash) { unit *u = building_owner(b);
if (!fval(b, BLD_WORKING)) { const char *msgtype =
unit *u = building_owner(b); flags ? "maintenance_nowork" : "maintenance_none";
const char *msgtype = struct message *msg = msg_message(msgtype, "building", b);
flags ? "maintenance_nowork" : "maintenance_none";
struct message *msg = msg_message(msgtype, "building", b);
if (u) { if (u) {
add_message(&u->faction->msgs, msg); add_message(&u->faction->msgs, msg);
r_addmessage(r, u->faction, msg); r_addmessage(r, u->faction, msg);
}
else {
add_message(&r->msgs, msg);
}
msg_release(msg);
} }
else {
add_message(&r->msgs, msg);
}
msg_release(msg);
} }
bp = &b->next; bp = &b->next;
} }

View File

@ -54,7 +54,7 @@ extern "C" {
void auto_work(struct region *r); void auto_work(struct region *r);
enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC, IC_LOOT }; enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC, IC_LOOT };
void maintain_buildings(struct region *r, bool crash); void maintain_buildings(struct region *r);
int make_cmd(struct unit *u, struct order *ord); int make_cmd(struct unit *u, struct order *ord);
void split_allocations(struct region *r); void split_allocations(struct region *r);
int give_control_cmd(struct unit *u, struct order *ord); int give_control_cmd(struct unit *u, struct order *ord);

View File

@ -4251,11 +4251,6 @@ bool rule_force_leave(int flags) {
return (rules&flags) == flags; return (rules&flags) == flags;
} }
static void maintain_buildings_1(region * r)
{
maintain_buildings(r, false);
}
void init_processor(void) void init_processor(void)
{ {
int p; int p;
@ -4340,10 +4335,9 @@ void init_processor(void)
p += 10; p += 10;
if (!keyword_disabled(K_PAY)) { if (!keyword_disabled(K_PAY)) {
add_proc_order(p, K_PAY, pay_cmd, 0, "Gebaeudeunterhalt (disable)"); add_proc_order(p, K_PAY, pay_cmd, 0, "Gebaeudeunterhalt (BEZAHLE NICHT)");
} }
add_proc_postregion(p, maintain_buildings_1, add_proc_postregion(p, maintain_buildings, "Gebaeudeunterhalt");
"Gebaeudeunterhalt (1. Versuch)");
p += 10; /* QUIT fuer sich alleine */ p += 10; /* QUIT fuer sich alleine */
add_proc_global(p, quit, "Sterben"); add_proc_global(p, quit, "Sterben");