Vereinfachte Statistik für Durchreiseregionen anzeigen.

This commit is contained in:
Enno Rehling 2019-01-13 19:17:31 +01:00
parent 765e2c5c61
commit 1f95a46e64
2 changed files with 41 additions and 36 deletions

View file

@ -1399,7 +1399,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
fprintf(F, "%d;Bauern\n", rpeasants(r));
fprintf(F, "%d;Pferde\n", rhorses(r));
if (r->seen.mode >= seen_unit) {
if (r->seen.mode >= seen_travel) {
if (rule_region_owners()) {
faction *owner = region_get_owner(r);
if (owner) {

View file

@ -1160,26 +1160,14 @@ void report_region(struct stream *out, const region * r, faction * f)
static void statistics(struct stream *out, const region * r, const faction * f)
{
const unit *u;
int number = 0, p = rpeasants(r);
int p = rpeasants(r);
message *m;
item *itm, *items = NULL;
char buf[4096];
/* count */
for (u = r->units; u; u = u->next) {
if (u->faction == f && !fval(u_race(u), RCF_INVISIBLE)) {
for (itm = u->items; itm; itm = itm->next) {
i_change(&items, itm->type, itm->number);
}
number += u->number;
}
}
/* print */
m = msg_message("nr_stat_header", "region", r);
nr_render(m, f->locale, buf, sizeof(buf), f);
msg_release(m);
newline(out);
paragraph(out, buf, 0, 0, 0);
newline(out);
@ -1211,6 +1199,21 @@ static void statistics(struct stream *out, const region * r, const faction * f)
paragraph(out, buf, 2, 2, 0);
msg_release(m);
if (r->land->ownership) {
m = msg_message("nr_stat_morale", "morale", region_get_morale(r));
nr_render(m, f->locale, buf, sizeof(buf), f);
paragraph(out, buf, 2, 2, 0);
msg_release(m);
}
}
/* info about units */
if (r->seen.mode >= seen_unit) {
int number;
item *itm, *items = NULL;
unit *u;
if (!markets_module()) {
if (buildingtype_exists(r, bt_find("caravan"), true)) {
m = msg_message("nr_stat_luxuries", "max", (p * 2) / TRADE_FRACTION);
@ -1223,16 +1226,15 @@ static void statistics(struct stream *out, const region * r, const faction * f)
msg_release(m);
}
if (r->land->ownership) {
m = msg_message("nr_stat_morale", "morale", region_get_morale(r));
nr_render(m, f->locale, buf, sizeof(buf), f);
paragraph(out, buf, 2, 2, 0);
msg_release(m);
/* count */
for (number = 0, u = r->units; u; u = u->next) {
if (u->faction == f && !fval(u_race(u), RCF_INVISIBLE)) {
for (itm = u->items; itm; itm = itm->next) {
i_change(&items, itm->type, itm->number);
}
number += u->number;
}
}
/* info about units */
m = msg_message("nr_stat_people", "max", number);
nr_render(m, f->locale, buf, sizeof(buf), f);
paragraph(out, buf, 2, 2, 0);
@ -1245,6 +1247,7 @@ static void statistics(struct stream *out, const region * r, const faction * f)
}
while (items)
i_free(i_remove(&items, items));
}
}
@ -2172,9 +2175,11 @@ report_plaintext(const char *filename, report_context * ctx,
}
newline(out);
if (wants_stats && r->seen.mode >= seen_unit) {
statistics(out, r, f);
if (wants_stats && r->seen.mode >= seen_travel) {
if (r->land || r->seen.mode >= seen_unit) {
newline(out);
statistics(out, r, f);
}
}
/* Nachrichten an REGION in der Region */