diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 1c86b9f57..eebec3112 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -1121,7 +1121,7 @@ parse_quit(void) if (turn!=f->lastorders) { char info[256]; sprintf(info, "%d Einheiten, %d Personen, %d Silber", - f->no_units, f->number, f->money); + f->no_units, f->num_total, f->money); if (f->subscription) { sql_print(("UPDATE subscriptions SET lastturn=%d, password='%s', info='%s' WHERE id=%u;\n", f->lastorders, f->override, info, f->subscription)); diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index cb88e6c42..310935488 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -3004,7 +3004,7 @@ make_summary(boolean count_new) } ++plang->number; f->nregions = 0; - f->number = 0; + f->num_total = 0; f->money = 0; if (f->alive && (count_new || f->age > 0)) s->factions++; } @@ -3096,7 +3096,7 @@ make_summary(boolean count_new) } } - f->number += u->number; + f->num_total += u->number; f->money += get_money(u); s->poprace[old_race(u->race)] += u->number; } @@ -3338,12 +3338,12 @@ out_faction(FILE *file, faction *f) fprintf(file, "%s (%s/%d) (%.3s/%.3s), %d Einh., %d Pers., $%d, %d %s\n", f->name, itoa36(f->no), f->alliance?f->alliance->id:0, LOC(default_locale, rc_name(f->race, 0)), neue_gebiete[f->magiegebiet], - f->no_units, f->number, f->money, turn - f->lastorders, + f->no_units, f->num_total, f->money, turn - f->lastorders, turn - f->lastorders != 1 ? "NMRs" : "NMR "); } else { fprintf(file, "%s (%.3s/%.3s), %d Einh., %d Pers., $%d, %d %s\n", factionname(f), LOC(default_locale, rc_name(f->race, 0)), - neue_gebiete[f->magiegebiet], f->no_units, f->number, f->money, + neue_gebiete[f->magiegebiet], f->no_units, f->num_total, f->money, turn - f->lastorders, turn - f->lastorders != 1 ? "NMRs" : "NMR "); } } diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index fefc4623c..57102f049 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -1180,6 +1180,7 @@ update_lighthouse(building * lh) int count_all(const faction * f) { +#ifndef NDEBUG int n = 0; unit *u; for (u=f->units;u;u=u->nextF) { @@ -1188,6 +1189,12 @@ count_all(const faction * f) assert(f==u->faction); } } + if (f->num_people != n) { + log_error(("Anzahl Personen für (%s) ist != num_people: %d statt %d.\n", + factionid(f), f->num_migrants, n)); + f->num_people = n; + } +#endif return n; } @@ -1206,8 +1213,11 @@ count_migrants (const faction * f) } u = u->nextF; } - if (f->num_migrants != n) - log_error(("Anzahl Migranten für (%s) ist falsch: %d statt %d.\n", factionid(f), f->num_migrants, n)); + if (f->num_migrants != n) { + log_error(("Anzahl Migranten für (%s) ist != num_migrants: %d statt %d.\n", + factionid(f), f->num_migrants, n)); + f->num_migrants = n; + } #endif return f->num_migrants; } @@ -1869,7 +1879,7 @@ create_unit(region * r, faction * f, int number, const struct race *urace, int i /* Nicht zu der Einheitenzahl zählen sollten auch alle Monster. Da * aber auf die MAXUNITS nur in MACHE TEMP geprüft wird, ist es egal */ - if(!fval(u->race, RCF_UNDEAD)) { + if (playerrace(u->race)) { f->no_units++; } diff --git a/src/common/kernel/faction.h b/src/common/kernel/faction.h index fada66f40..9e3a4a39d 100644 --- a/src/common/kernel/faction.h +++ b/src/common/kernel/faction.h @@ -63,7 +63,8 @@ typedef struct faction { magic_t magiegebiet; int newbies; int num_migrants; /* Anzahl Migranten */ - int num_people; /* Anzahl Personen */ + int num_people; /* Anzahl Personen ohne Monster */ + int num_total; /* Anzahl Personen mit Monstern */ int options; int no_units; int karma; @@ -79,7 +80,6 @@ typedef struct faction { struct strlist *mistakes; /* enno: das muß irgendwann noch ganz raus */ boolean alive; /* enno: sollte ein flag werden */ int nregions; - int number; /* enno: unterschied zu num_people ? */ int money; int score; struct alliance * alliance; diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c index 53c5c0ff3..a95efa6b0 100644 --- a/src/common/kernel/unit.c +++ b/src/common/kernel/unit.c @@ -807,7 +807,9 @@ u_setfaction(unit * u, faction * f) if (u->faction==f) return; if (u->faction) { set_number(u, 0); - --u->faction->no_units; + if (playerrace(u->race)) { + --u->faction->no_units; + } join_group(u, NULL); free_orders(&u->orders); set_order(&u->thisorder, NULL); @@ -831,7 +833,9 @@ u_setfaction(unit * u, faction * f) u->faction = f; if (cnt && f) { set_number(u, cnt); - ++f->no_units; + if (playerrace(u->race)) { + ++f->no_units; + } } } /* vorsicht Sprüche können u->number == 0 (RS_FARVISION) haben! */ @@ -844,11 +848,14 @@ set_number(unit * u, int count) #endif if (u->faction && u->race != u->faction->race && playerrace(u->race) && old_race(u->race) != RC_SPELL && old_race(u->race) != RC_SPECIAL - && !(is_cursed(u->attribs, C_SLAVE, 0))){ + && !(is_cursed(u->attribs, C_SLAVE, 0))) + { u->faction->num_migrants += count - u->number; } - u->faction->num_people += count - u->number; + if (playerrace(u->race)) { + u->faction->num_people += count - u->number; + } u->number = count; } diff --git a/src/common/modules/score.c b/src/common/modules/score.c index efece1e11..6985e5780 100644 --- a/src/common/modules/score.c +++ b/src/common/modules/score.c @@ -243,11 +243,11 @@ score(void) sprintf(buf, "%s/score", basepath()); scoreFP = fopen(buf, "w"); - for (f = factions; f; f = f->next) if(f->number != 0) { + for (f = factions; f; f = f->next) if (f->num_total != 0) { fprintf(scoreFP, "%8d (%8d/%4.2f%%/%5.2f) %30.30s (%3.3s) %5s (%3d)\n", f->score, f->score - average_score_of_age(f->age, f->age / 24 + 1), ((float) f->score / (float) allscores) * 100.0, - (float) f->score / f->number, + (float) f->score / f->num_total, f->name, LOC(default_locale, rc_name(f->race, 0)), factionid(f), f->age); } fclose(scoreFP); @@ -268,7 +268,7 @@ score(void) if(f->alliance && f->alliance->id == a->id) { alliance_factions++; alliance_score += f->score; - alliance_number += f->number; + alliance_number += f->num_total; if (token!=NULL) { unit * u = f->units; while (u!=NULL) {