forked from github/server
units that have no factions crashed the score-module
This commit is contained in:
parent
4f5c8e1878
commit
869c17bf39
1 changed files with 115 additions and 108 deletions
|
@ -68,31 +68,35 @@ score(void)
|
||||||
{
|
{
|
||||||
FILE *scoreFP;
|
FILE *scoreFP;
|
||||||
region *r;
|
region *r;
|
||||||
unit *u, *u2;
|
faction *f;
|
||||||
faction *f, *fbo;
|
|
||||||
building *b;
|
|
||||||
ship *s;
|
|
||||||
int allscores = 0;
|
int allscores = 0;
|
||||||
int c;
|
|
||||||
|
|
||||||
for (f = factions; f; f = f->next) f->score = 0;
|
for (f = factions; f; f = f->next) f->score = 0;
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
for (b = r->buildings; b; b = b->next) {
|
unit * u;
|
||||||
if ((u = buildingowner(r, b)) != 0) {
|
building * b;
|
||||||
fbo = u->faction;
|
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)
|
if (u->number <= b->size)
|
||||||
fbo->score += u->number * 5;
|
fbo->score += u->number * 5;
|
||||||
|
|
||||||
fbo->score += b->size;
|
fbo->score += b->size;
|
||||||
|
}
|
||||||
c = b->size - u->number;
|
|
||||||
|
|
||||||
for (u2 = r->units; u2 && c > 0; u2 = u2->next) {
|
for (u2 = r->units; u2 && c > 0; u2 = u2->next) {
|
||||||
if (u2->building == b && u2 != u && u2->number <= c) {
|
if (u2->building == b && u2 != u && u2->number <= c) {
|
||||||
c -= u2->number;
|
c -= u2->number;
|
||||||
|
|
||||||
|
if (u2->faction) {
|
||||||
if (u2->faction == fbo) {
|
if (u2->faction == fbo) {
|
||||||
u2->faction->score += u2->number * 5;
|
u2->faction->score += u2->number * 5;
|
||||||
} else {
|
} else {
|
||||||
|
@ -102,8 +106,10 @@ score(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (s = r->ships; s; s = s->next) {
|
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;
|
u->faction->score += s->size * 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,11 +117,11 @@ score(void)
|
||||||
item * itm;
|
item * itm;
|
||||||
int itemscore = 0;
|
int itemscore = 0;
|
||||||
int i;
|
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;
|
continue;
|
||||||
|
}
|
||||||
f = u->faction;
|
|
||||||
|
|
||||||
if (old_race(u->race) <= RC_AQUARIAN) {
|
if (old_race(u->race) <= RC_AQUARIAN) {
|
||||||
f->score += (u->race->recruitcost * u->number) / 50;
|
f->score += (u->race->recruitcost * u->number) / 50;
|
||||||
|
@ -150,11 +156,13 @@ score(void)
|
||||||
|
|
||||||
for (f = factions; f; f = f->next) {
|
for (f = factions; f; f = f->next) {
|
||||||
f->score = f->score / 5;
|
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;
|
allscores += f->score;
|
||||||
}
|
}
|
||||||
if( allscores == 0 )
|
}
|
||||||
|
if (allscores == 0) {
|
||||||
allscores = 1;
|
allscores = 1;
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(buf, "%s/score", basepath());
|
sprintf(buf, "%s/score", basepath());
|
||||||
scoreFP = fopen(buf, "w");
|
scoreFP = fopen(buf, "w");
|
||||||
|
@ -203,7 +211,6 @@ score(void)
|
||||||
}
|
}
|
||||||
fclose(scoreFP);
|
fclose(scoreFP);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue