forked from github/server
rconnect is not as nice as get_neighbours
This commit is contained in:
parent
c08fba8308
commit
d8abd09076
1 changed files with 19 additions and 19 deletions
|
@ -260,14 +260,16 @@ static boolean room_for_race_in_region(region * r, const race * rc)
|
||||||
|
|
||||||
static direction_t random_neighbour(region * r, unit * u)
|
static direction_t random_neighbour(region * r, unit * u)
|
||||||
{
|
{
|
||||||
direction_t i;
|
int i;
|
||||||
region *rc;
|
region *rc;
|
||||||
|
region * next[MAXDIRECTIONS];
|
||||||
int rr, c = 0, c2 = 0;
|
int rr, c = 0, c2 = 0;
|
||||||
|
|
||||||
|
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 = rconnect(r, i);
|
rc = next[i];
|
||||||
if (rc && can_survive(u, rc)) {
|
if (rc && can_survive(u, rc)) {
|
||||||
if (room_for_race_in_region(rc, u->race)) {
|
if (room_for_race_in_region(rc, u->race)) {
|
||||||
c++;
|
c++;
|
||||||
|
@ -293,7 +295,7 @@ 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 = rconnect(r, i);
|
rc = next[i];
|
||||||
if (rc && can_survive(u, rc)) {
|
if (rc && can_survive(u, rc)) {
|
||||||
if (c2 == 0) {
|
if (c2 == 0) {
|
||||||
c++;
|
c++;
|
||||||
|
@ -301,7 +303,7 @@ static direction_t random_neighbour(region * r, unit * u)
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
if (c == rr)
|
if (c == rr)
|
||||||
return i;
|
return (direction_t)i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,18 +313,18 @@ static direction_t random_neighbour(region * r, unit * u)
|
||||||
|
|
||||||
static direction_t treeman_neighbour(region * r)
|
static direction_t treeman_neighbour(region * r)
|
||||||
{
|
{
|
||||||
direction_t i;
|
int i;
|
||||||
int rr;
|
int rr;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
region * next[MAXDIRECTIONS];
|
||||||
|
|
||||||
|
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++) {
|
||||||
if (rconnect(r, i)
|
if (next[i] && rterrain(next[i]) != T_OCEAN
|
||||||
&& rterrain(rconnect(r, i)) != T_OCEAN
|
&& rterrain(next[i]) != T_GLACIER && rterrain(next[i]) != T_DESERT) {
|
||||||
&& rterrain(rconnect(r, i)) != T_GLACIER
|
++c;
|
||||||
&& rterrain(rconnect(r, i)) != T_DESERT) {
|
|
||||||
c++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,18 +339,15 @@ static direction_t treeman_neighbour(region * r)
|
||||||
|
|
||||||
c = -1;
|
c = -1;
|
||||||
for (i = 0; i != MAXDIRECTIONS; i++) {
|
for (i = 0; i != MAXDIRECTIONS; i++) {
|
||||||
if (rconnect(r, i)
|
if (next[i] && rterrain(next[i]) != T_OCEAN
|
||||||
&& rterrain(rconnect(r, i)) != T_OCEAN
|
&& rterrain(next[i]) != T_GLACIER && rterrain(next[i]) != T_DESERT) {
|
||||||
&& rterrain(rconnect(r, i)) != T_GLACIER
|
if (++c == rr) {
|
||||||
&& rterrain(rconnect(r, i)) != T_DESERT) {
|
return (direction_t)i;
|
||||||
c++;
|
|
||||||
if (c == rr) {
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(1 == 0); /* Bis hierhin sollte er niemals kommen. */
|
assert(!"this should never happen"); /* Bis hierhin sollte er niemals kommen. */
|
||||||
return NODIRECTION;
|
return NODIRECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,8 +355,9 @@ static order *monster_move(region * r, unit * u)
|
||||||
{
|
{
|
||||||
direction_t d = NODIRECTION;
|
direction_t d = NODIRECTION;
|
||||||
|
|
||||||
if (monster_is_waiting(u))
|
if (monster_is_waiting(u)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
switch (old_race(u->race)) {
|
switch (old_race(u->race)) {
|
||||||
case RC_FIREDRAGON:
|
case RC_FIREDRAGON:
|
||||||
case RC_DRAGON:
|
case RC_DRAGON:
|
||||||
|
|
Loading…
Reference in a new issue