Borders müssen doppelt geprüft werden - einmal bei der Erstellung des Pfads, einmal um ihre Auswirkungen auf die Einheit auszuführen.

Einheiten mit number=0 laufen nicht weiter.
This commit is contained in:
Enno Rehling 2004-12-19 17:30:32 +00:00
parent f3311da168
commit 41c4568c02
3 changed files with 19 additions and 7 deletions

View File

@ -78,7 +78,7 @@ extern "C" {
/* is the border in a valid state,
* or should it be erased at the end of this turn to save space?
*/
struct region * (*move)(const border *, struct unit * u, struct region * from, struct region * to);
struct region * (*move)(const border *, struct unit * u, struct region * from, struct region * to, boolean routing);
/* executed when the units traverses this border */
struct border_type * next; /* for internal use only */
} border_type;

View File

@ -1070,7 +1070,7 @@ make_route(unit * u, order * ord, region_list ** routep)
}
while (b!=NULL) {
if (b->type->move) {
region * rto = b->type->move(b, u, current, next);
region * rto = b->type->move(b, u, current, next, true);
if (rto!=next) {
/* the target region was changed (bt_wisps, for example). check the
* new target region for borders */
@ -1198,6 +1198,7 @@ travel_route(unit * u, region_list * route_begin, region_list * route_end, order
while (iroute && iroute!=route_end) {
region * next = iroute->data;
direction_t reldir = reldirection(current, next);
border * b = get_borders(current, next);
/* check if we are caught by guarding units */
if (iroute!=route_begin && mode!=TRAVEL_RUNNING && mode!=TRAVEL_TRANSPORTED) {
@ -1281,9 +1282,19 @@ travel_route(unit * u, region_list * route_begin, region_list * route_end, order
}
}
/* effect of borders */
while (b!=NULL) {
if (b->type->move) {
region * rto = b->type->move(b, u, current, next, false);
assert(rto==NULL); /* should return NULL when not routing */
}
b = b->next;
}
current = next;
iroute = iroute->next;
++steps;
if (u->number==0) break;
}
if (iroute!=route_begin) {

View File

@ -2981,11 +2981,12 @@ wall_write(const border * b, FILE * f)
}
static region *
wall_move(const border * b, struct unit * u, struct region * from, struct region * to)
wall_move(const border * b, struct unit * u, struct region * from, struct region * to, boolean routing)
{
wall_data * fd = (wall_data*)b->data;
int hp = dice(3, fd->force) * u->number;
if (routing) return to;
if (fd->active) {
int hp = dice(3, fd->force) * u->number;
hp = min (u->hp, hp);
u->hp -= hp;
if (u->hp) {
@ -2998,8 +2999,7 @@ wall_move(const border * b, struct unit * u, struct region * from, struct region
u->hp = u->number;
}
}
unused(from);
return to;
return NULL;
}
border_type bt_firewall = {
@ -3094,12 +3094,13 @@ wisps_name(const border * b, const region * r, const faction * f, int gflags)
}
static region *
wisps_move(const border * b, struct unit * u, struct region * from, struct region * next)
wisps_move(const border * b, struct unit * u, struct region * from, struct region * next, boolean routing)
{
direction_t reldir = reldirection(from, next);
wall_data * wd = (wall_data*)b->data;
assert(reldir!=D_SPECIAL);
if (!routing) return NULL;
if (wd->active) {
/* pick left and right region: */
region * rl = rconnect(from, (direction_t)((reldir+MAXDIRECTIONS-1)%MAXDIRECTIONS));