little bit of refactoring and better variable names.

This commit is contained in:
Enno Rehling 2016-10-03 16:26:40 +02:00
parent f6beda43f4
commit 42e75007c3
2 changed files with 11 additions and 11 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.vscode/
*.orig
eressea.ini
Debug

View File

@ -277,27 +277,26 @@ static bool room_for_race_in_region(region * r, const race * rc)
c += u->number;
}
if (c > (rc->splitsize * 2))
return false;
return true;
return (c <= (rc->splitsize * 2));
}
static direction_t random_neighbour(region * r, unit * u)
{
int i;
region *rc;
region * next[MAXDIRECTIONS];
int rr, c = 0, c2 = 0;
const race *rc = u_race(u);
get_neighbours(r, next);
/* Nachsehen, wieviele Regionen in Frage kommen */
for (i = 0; i != MAXDIRECTIONS; i++) {
rc = next[i];
if (rc && can_survive(u, rc)) {
if (room_for_race_in_region(rc, u_race(u))) {
region *rn = next[i];
if (rn && can_survive(u, rn)) {
if (room_for_race_in_region(rn, rc)) {
c++;
} else {
next[i] = NULL;
}
c2++;
}
@ -321,12 +320,12 @@ static direction_t random_neighbour(region * r, unit * u)
c = -1;
for (i = 0; i != MAXDIRECTIONS; i++) {
rc = next[i];
if (rc && can_survive(u, rc)) {
region *rn = next[i];
if (rn && can_survive(u, rn)) {
if (c2 == 0) {
c++;
}
else if (room_for_race_in_region(rc, u_race(u))) {
else if (room_for_race_in_region(rn, rc)) {
c++;
}
if (c == rr)