forked from github/server
little bit of refactoring and better variable names.
This commit is contained in:
parent
f6beda43f4
commit
42e75007c3
|
@ -1,3 +1,4 @@
|
||||||
|
.vscode/
|
||||||
*.orig
|
*.orig
|
||||||
eressea.ini
|
eressea.ini
|
||||||
Debug
|
Debug
|
||||||
|
|
|
@ -277,27 +277,26 @@ static bool room_for_race_in_region(region * r, const race * rc)
|
||||||
c += u->number;
|
c += u->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c > (rc->splitsize * 2))
|
return (c <= (rc->splitsize * 2));
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static direction_t random_neighbour(region * r, unit * u)
|
static direction_t random_neighbour(region * r, unit * u)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
region *rc;
|
|
||||||
region * next[MAXDIRECTIONS];
|
region * next[MAXDIRECTIONS];
|
||||||
int rr, c = 0, c2 = 0;
|
int rr, c = 0, c2 = 0;
|
||||||
|
const race *rc = u_race(u);
|
||||||
|
|
||||||
get_neighbours(r, next);
|
get_neighbours(r, next);
|
||||||
/* Nachsehen, wieviele Regionen in Frage kommen */
|
/* Nachsehen, wieviele Regionen in Frage kommen */
|
||||||
|
|
||||||
for (i = 0; i != MAXDIRECTIONS; i++) {
|
for (i = 0; i != MAXDIRECTIONS; i++) {
|
||||||
rc = next[i];
|
region *rn = next[i];
|
||||||
if (rc && can_survive(u, rc)) {
|
if (rn && can_survive(u, rn)) {
|
||||||
if (room_for_race_in_region(rc, u_race(u))) {
|
if (room_for_race_in_region(rn, rc)) {
|
||||||
c++;
|
c++;
|
||||||
|
} else {
|
||||||
|
next[i] = NULL;
|
||||||
}
|
}
|
||||||
c2++;
|
c2++;
|
||||||
}
|
}
|
||||||
|
@ -321,12 +320,12 @@ static direction_t random_neighbour(region * r, unit * u)
|
||||||
|
|
||||||
c = -1;
|
c = -1;
|
||||||
for (i = 0; i != MAXDIRECTIONS; i++) {
|
for (i = 0; i != MAXDIRECTIONS; i++) {
|
||||||
rc = next[i];
|
region *rn = next[i];
|
||||||
if (rc && can_survive(u, rc)) {
|
if (rn && can_survive(u, rn)) {
|
||||||
if (c2 == 0) {
|
if (c2 == 0) {
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
else if (room_for_race_in_region(rc, u_race(u))) {
|
else if (room_for_race_in_region(rn, rc)) {
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
if (c == rr)
|
if (c == rr)
|
||||||
|
|
Loading…
Reference in New Issue