diff --git a/src/common/kernel/border.h b/src/common/kernel/border.h index 7a6209add..e05603c6d 100644 --- a/src/common/kernel/border.h +++ b/src/common/kernel/border.h @@ -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; diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index eeb0c6b55..521a604b7 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -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) { diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index 867463706..4ca79866c 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -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));