forked from github/server
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:
parent
f3311da168
commit
41c4568c02
|
@ -78,7 +78,7 @@ extern "C" {
|
||||||
/* is the border in a valid state,
|
/* is the border in a valid state,
|
||||||
* or should it be erased at the end of this turn to save space?
|
* 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 */
|
/* executed when the units traverses this border */
|
||||||
struct border_type * next; /* for internal use only */
|
struct border_type * next; /* for internal use only */
|
||||||
} border_type;
|
} border_type;
|
||||||
|
|
|
@ -1070,7 +1070,7 @@ make_route(unit * u, order * ord, region_list ** routep)
|
||||||
}
|
}
|
||||||
while (b!=NULL) {
|
while (b!=NULL) {
|
||||||
if (b->type->move) {
|
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) {
|
if (rto!=next) {
|
||||||
/* the target region was changed (bt_wisps, for example). check the
|
/* the target region was changed (bt_wisps, for example). check the
|
||||||
* new target region for borders */
|
* 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) {
|
while (iroute && iroute!=route_end) {
|
||||||
region * next = iroute->data;
|
region * next = iroute->data;
|
||||||
direction_t reldir = reldirection(current, next);
|
direction_t reldir = reldirection(current, next);
|
||||||
|
border * b = get_borders(current, next);
|
||||||
|
|
||||||
/* check if we are caught by guarding units */
|
/* check if we are caught by guarding units */
|
||||||
if (iroute!=route_begin && mode!=TRAVEL_RUNNING && mode!=TRAVEL_TRANSPORTED) {
|
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;
|
current = next;
|
||||||
iroute = iroute->next;
|
iroute = iroute->next;
|
||||||
++steps;
|
++steps;
|
||||||
|
if (u->number==0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iroute!=route_begin) {
|
if (iroute!=route_begin) {
|
||||||
|
|
|
@ -2981,11 +2981,12 @@ wall_write(const border * b, FILE * f)
|
||||||
}
|
}
|
||||||
|
|
||||||
static region *
|
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;
|
wall_data * fd = (wall_data*)b->data;
|
||||||
int hp = dice(3, fd->force) * u->number;
|
if (routing) return to;
|
||||||
if (fd->active) {
|
if (fd->active) {
|
||||||
|
int hp = dice(3, fd->force) * u->number;
|
||||||
hp = min (u->hp, hp);
|
hp = min (u->hp, hp);
|
||||||
u->hp -= hp;
|
u->hp -= hp;
|
||||||
if (u->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;
|
u->hp = u->number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unused(from);
|
return NULL;
|
||||||
return to;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
border_type bt_firewall = {
|
border_type bt_firewall = {
|
||||||
|
@ -3094,12 +3094,13 @@ wisps_name(const border * b, const region * r, const faction * f, int gflags)
|
||||||
}
|
}
|
||||||
|
|
||||||
static region *
|
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);
|
direction_t reldir = reldirection(from, next);
|
||||||
wall_data * wd = (wall_data*)b->data;
|
wall_data * wd = (wall_data*)b->data;
|
||||||
assert(reldir!=D_SPECIAL);
|
assert(reldir!=D_SPECIAL);
|
||||||
|
|
||||||
|
if (!routing) return NULL;
|
||||||
if (wd->active) {
|
if (wd->active) {
|
||||||
/* pick left and right region: */
|
/* pick left and right region: */
|
||||||
region * rl = rconnect(from, (direction_t)((reldir+MAXDIRECTIONS-1)%MAXDIRECTIONS));
|
region * rl = rconnect(from, (direction_t)((reldir+MAXDIRECTIONS-1)%MAXDIRECTIONS));
|
||||||
|
|
Loading…
Reference in New Issue