inheitliche Zählung von Personen/Einheiten einer Partei
This commit is contained in:
Enno Rehling 2005-03-06 13:47:23 +00:00
parent f242d80832
commit d7cb8c517e
6 changed files with 34 additions and 17 deletions

View File

@ -1121,7 +1121,7 @@ parse_quit(void)
if (turn!=f->lastorders) { if (turn!=f->lastorders) {
char info[256]; char info[256];
sprintf(info, "%d Einheiten, %d Personen, %d Silber", 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) { if (f->subscription) {
sql_print(("UPDATE subscriptions SET lastturn=%d, password='%s', info='%s' WHERE id=%u;\n", sql_print(("UPDATE subscriptions SET lastturn=%d, password='%s', info='%s' WHERE id=%u;\n",
f->lastorders, f->override, info, f->subscription)); f->lastorders, f->override, info, f->subscription));

View File

@ -3004,7 +3004,7 @@ make_summary(boolean count_new)
} }
++plang->number; ++plang->number;
f->nregions = 0; f->nregions = 0;
f->number = 0; f->num_total = 0;
f->money = 0; f->money = 0;
if (f->alive && (count_new || f->age > 0)) s->factions++; 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); f->money += get_money(u);
s->poprace[old_race(u->race)] += u->number; 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", 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, f->name, itoa36(f->no), f->alliance?f->alliance->id:0,
LOC(default_locale, rc_name(f->race, 0)), neue_gebiete[f->magiegebiet], 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 "); turn - f->lastorders != 1 ? "NMRs" : "NMR ");
} else { } else {
fprintf(file, "%s (%.3s/%.3s), %d Einh., %d Pers., $%d, %d %s\n", fprintf(file, "%s (%.3s/%.3s), %d Einh., %d Pers., $%d, %d %s\n",
factionname(f), LOC(default_locale, rc_name(f->race, 0)), 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 "); turn - f->lastorders, turn - f->lastorders != 1 ? "NMRs" : "NMR ");
} }
} }

View File

@ -1180,6 +1180,7 @@ update_lighthouse(building * lh)
int int
count_all(const faction * f) count_all(const faction * f)
{ {
#ifndef NDEBUG
int n = 0; int n = 0;
unit *u; unit *u;
for (u=f->units;u;u=u->nextF) { for (u=f->units;u;u=u->nextF) {
@ -1188,6 +1189,12 @@ count_all(const faction * f)
assert(f==u->faction); 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; return n;
} }
@ -1206,8 +1213,11 @@ count_migrants (const faction * f)
} }
u = u->nextF; u = u->nextF;
} }
if (f->num_migrants != n) if (f->num_migrants != n) {
log_error(("Anzahl Migranten für (%s) ist falsch: %d statt %d.\n", factionid(f), 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 #endif
return f->num_migrants; 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 /* 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 */ * 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++; f->no_units++;
} }

View File

@ -63,7 +63,8 @@ typedef struct faction {
magic_t magiegebiet; magic_t magiegebiet;
int newbies; int newbies;
int num_migrants; /* Anzahl Migranten */ 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 options;
int no_units; int no_units;
int karma; int karma;
@ -79,7 +80,6 @@ typedef struct faction {
struct strlist *mistakes; /* enno: das muß irgendwann noch ganz raus */ struct strlist *mistakes; /* enno: das muß irgendwann noch ganz raus */
boolean alive; /* enno: sollte ein flag werden */ boolean alive; /* enno: sollte ein flag werden */
int nregions; int nregions;
int number; /* enno: unterschied zu num_people ? */
int money; int money;
int score; int score;
struct alliance * alliance; struct alliance * alliance;

View File

@ -807,7 +807,9 @@ u_setfaction(unit * u, faction * f)
if (u->faction==f) return; if (u->faction==f) return;
if (u->faction) { if (u->faction) {
set_number(u, 0); set_number(u, 0);
if (playerrace(u->race)) {
--u->faction->no_units; --u->faction->no_units;
}
join_group(u, NULL); join_group(u, NULL);
free_orders(&u->orders); free_orders(&u->orders);
set_order(&u->thisorder, NULL); set_order(&u->thisorder, NULL);
@ -831,9 +833,11 @@ u_setfaction(unit * u, faction * f)
u->faction = f; u->faction = f;
if (cnt && f) { if (cnt && f) {
set_number(u, cnt); set_number(u, cnt);
if (playerrace(u->race)) {
++f->no_units; ++f->no_units;
} }
} }
}
/* vorsicht Sprüche können u->number == 0 (RS_FARVISION) haben! */ /* vorsicht Sprüche können u->number == 0 (RS_FARVISION) haben! */
void void
set_number(unit * u, int count) set_number(unit * u, int count)
@ -844,11 +848,14 @@ set_number(unit * u, int count)
#endif #endif
if (u->faction && u->race != u->faction->race && playerrace(u->race) if (u->faction && u->race != u->faction->race && playerrace(u->race)
&& old_race(u->race) != RC_SPELL && old_race(u->race) != RC_SPECIAL && 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_migrants += count - u->number;
} }
if (playerrace(u->race)) {
u->faction->num_people += count - u->number; u->faction->num_people += count - u->number;
}
u->number = count; u->number = count;
} }

View File

@ -243,11 +243,11 @@ score(void)
sprintf(buf, "%s/score", basepath()); sprintf(buf, "%s/score", basepath());
scoreFP = fopen(buf, "w"); 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", 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), f->score, f->score - average_score_of_age(f->age, f->age / 24 + 1),
((float) f->score / (float) allscores) * 100.0, ((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); f->name, LOC(default_locale, rc_name(f->race, 0)), factionid(f), f->age);
} }
fclose(scoreFP); fclose(scoreFP);
@ -268,7 +268,7 @@ score(void)
if(f->alliance && f->alliance->id == a->id) { if(f->alliance && f->alliance->id == a->id) {
alliance_factions++; alliance_factions++;
alliance_score += f->score; alliance_score += f->score;
alliance_number += f->number; alliance_number += f->num_total;
if (token!=NULL) { if (token!=NULL) {
unit * u = f->units; unit * u = f->units;
while (u!=NULL) { while (u!=NULL) {