forked from github/server
units that have no factions crashed the score-module
This commit is contained in:
parent
4f5c8e1878
commit
869c17bf39
|
@ -68,31 +68,35 @@ score(void)
|
|||
{
|
||||
FILE *scoreFP;
|
||||
region *r;
|
||||
unit *u, *u2;
|
||||
faction *f, *fbo;
|
||||
building *b;
|
||||
ship *s;
|
||||
faction *f;
|
||||
int allscores = 0;
|
||||
int c;
|
||||
|
||||
for (f = factions; f; f = f->next) f->score = 0;
|
||||
|
||||
for (r = regions; r; r = r->next) {
|
||||
for (b = r->buildings; b; b = b->next) {
|
||||
if ((u = buildingowner(r, b)) != 0) {
|
||||
fbo = u->faction;
|
||||
unit * u;
|
||||
building * b;
|
||||
ship * s;
|
||||
|
||||
for (b = r->buildings; b; b = b->next) {
|
||||
u = buildingowner(r, b);
|
||||
if (u!=NULL) {
|
||||
unit * u2;
|
||||
faction * fbo = u->faction;
|
||||
int c = b->size - u->number;
|
||||
|
||||
if (fbo) {
|
||||
if (u->number <= b->size)
|
||||
fbo->score += u->number * 5;
|
||||
|
||||
fbo->score += b->size;
|
||||
|
||||
c = b->size - u->number;
|
||||
}
|
||||
|
||||
for (u2 = r->units; u2 && c > 0; u2 = u2->next) {
|
||||
if (u2->building == b && u2 != u && u2->number <= c) {
|
||||
c -= u2->number;
|
||||
|
||||
if (u2->faction) {
|
||||
if (u2->faction == fbo) {
|
||||
u2->faction->score += u2->number * 5;
|
||||
} else {
|
||||
|
@ -102,8 +106,10 @@ score(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (s = r->ships; s; s = s->next) {
|
||||
if ((u = shipowner(s)) != 0) {
|
||||
unit * u = shipowner(s);
|
||||
if (u && u->faction) {
|
||||
u->faction->score += s->size * 2;
|
||||
}
|
||||
}
|
||||
|
@ -111,11 +117,11 @@ score(void)
|
|||
item * itm;
|
||||
int itemscore = 0;
|
||||
int i;
|
||||
faction * f = u->faction;
|
||||
|
||||
if (u->race == new_race[RC_SPELL] || u->race == new_race[RC_BIRTHDAYDRAGON])
|
||||
if (f==NULL || u->race == new_race[RC_SPELL] || u->race == new_race[RC_BIRTHDAYDRAGON]) {
|
||||
continue;
|
||||
|
||||
f = u->faction;
|
||||
}
|
||||
|
||||
if (old_race(u->race) <= RC_AQUARIAN) {
|
||||
f->score += (u->race->recruitcost * u->number) / 50;
|
||||
|
@ -150,11 +156,13 @@ score(void)
|
|||
|
||||
for (f = factions; f; f = f->next) {
|
||||
f->score = f->score / 5;
|
||||
if (f->no != MONSTER_FACTION && f->race != new_race[RC_TEMPLATE])
|
||||
if (f->no != MONSTER_FACTION && f->race != new_race[RC_TEMPLATE]) {
|
||||
allscores += f->score;
|
||||
}
|
||||
if( allscores == 0 )
|
||||
}
|
||||
if (allscores == 0) {
|
||||
allscores = 1;
|
||||
}
|
||||
|
||||
sprintf(buf, "%s/score", basepath());
|
||||
scoreFP = fopen(buf, "w");
|
||||
|
@ -180,7 +188,7 @@ score(void)
|
|||
int grails = 0;
|
||||
|
||||
for (f = factions; f; f = f->next) {
|
||||
if(f->alliance && f->alliance->id == a->id) {
|
||||
if (f->alliance && f->alliance->id == a->id) {
|
||||
alliance_factions++;
|
||||
alliance_score += f->score;
|
||||
alliance_number += f->num_total;
|
||||
|
@ -203,7 +211,6 @@ score(void)
|
|||
}
|
||||
fclose(scoreFP);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue