From 8fe61a96f4294741f1950e5dc4b9b5c413755c0e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Feb 2007 19:40:19 +0000 Subject: [PATCH] http://eressea.upb.de/mantis/view.php?id=592 "Irrlichter haben keinen Effekt auf Einheiten, die sich mit FOLGE bewegen" Irrlichter lenken jetzt _alle_ Durchreisenden Einheiten in die gleiche Richtung ab, wenn sie aus der selben Region kommen. --- src/common/spells/spells.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/common/spells/spells.c b/src/common/spells/spells.c index 7b4388f0f..41f42e38b 100644 --- a/src/common/spells/spells.c +++ b/src/common/spells/spells.c @@ -3009,28 +3009,45 @@ wisps_name(const border * b, const region * r, const faction * f, int gflags) return "Irrlichter"; } +typedef struct wisps_data { + wall_data wall; + int rnd; +} wisps_data; + static region * 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.v; + wisps_data * wd = (wisps_data*)b->data.v; assert(reldir!=D_SPECIAL); - if (routing && wd->active) { - /* pick left and right region: */ + if (routing && wd->wall.active) { region * rl = rconnect(from, (direction_t)((reldir+MAXDIRECTIONS-1)%MAXDIRECTIONS)); region * rr = rconnect(from, (direction_t)((reldir+1)%MAXDIRECTIONS)); - int j = rng_int() % 3; - if (j==1 && rl && fval(rl->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rl; - if (j==2 && rr && fval(rr->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rr; + /* pick left and right region: */ + if (wd->rnd<0) { + wd->rnd = rng_int() % 3; + } + + if (wd->rnd == 1 && rl && fval(rl->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rl; + if (wd->rnd == 2 && rr && fval(rr->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rr; } return next; } +static void +wisps_init(border * b) +{ + wisps_data * wd = (wisps_data*)calloc(sizeof(wisps_data), 1); + + b->data.v = wd; + wd->rnd = -1; +} + border_type bt_wisps = { "wisps", VAR_VOIDPTR, b_transparent, /* transparent */ - wall_init, /* init */ + wisps_init, /* init */ wall_destroy, /* destroy */ wall_read, /* read */ wall_write, /* write */