diff --git a/src/kernel/connection.c b/src/kernel/connection.c index 3572dff6e..26aca8d72 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -106,7 +106,7 @@ connection *get_borders(const region * r1, const region * r2) return *bp; } -connection *new_border(border_type * type, region * from, region * to) +connection *new_border(border_type * type, region * from, region * to, int id) { connection *b, **bp; @@ -120,10 +120,11 @@ connection *new_border(border_type * type, region * from, region * to) b->type = type; b->from = from; b->to = to; - b->id = ++nextborder; + b->id = (id > 0) ? id : ++nextborder; - if (type->init) + if (type->init) { type->init(b); + } return b; } @@ -612,9 +613,7 @@ int read_borders(gamedata *data) } } if (b == NULL) { - b = new_border(type, from, to); - nextborder--; /* new_border erhoeht den Wert */ - b->id = bid; + b = new_border(type, from, to, bid); assert(bid <= nextborder); } type->read(b, data); diff --git a/src/kernel/connection.h b/src/kernel/connection.h index f5cc9fc9c..1f7c06bd7 100644 --- a/src/kernel/connection.h +++ b/src/kernel/connection.h @@ -86,8 +86,7 @@ extern "C" { connection *get_borders(const struct region *r1, const struct region *r2); /* returns the list of borders between r1 and r2 or r2 and r1 */ - connection *new_border(border_type * type, struct region *from, - struct region *to); + connection *new_border(border_type *type, struct region *from, struct region *to, int id); /* creates a connection of the specified type */ void erase_border(connection * b); /* remove the connection from memory */ diff --git a/src/kernel/region.c b/src/kernel/region.c index 43c9b041c..6f700ae03 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -539,7 +539,7 @@ void rsetroad(region * r, direction_t d, int val) } if (!b) { if (!val) return; - b = new_border(&bt_road, r, r2); + b = new_border(&bt_road, r, r2, 0); } if (r == b->from) { b->data.sa[0] = (short)val; diff --git a/src/spells.c b/src/spells.c index 6a1f78c23..aee808c3a 100644 --- a/src/spells.c +++ b/src/spells.c @@ -2657,7 +2657,7 @@ static int sp_firewall(castorder * co) b = b->next; } if (b == NULL) { - b = new_border(&bt_firewall, r, r2); + b = new_border(&bt_firewall, r, r2, 0); fd = (wall_data *)b->data.v; fd->force = (int)(force / 2 + 0.5); fd->mage = caster; @@ -3094,7 +3094,7 @@ static int sp_chaossuction(castorder * co) /* TODO: implement with a building */ create_special_direction(r, rt, 2, "vortex_desc", "vortex", false); create_special_direction(rt, r, 2, "vortex_desc", "vortex", false); - new_border(&bt_chaosgate, r, rt); + new_border(&bt_chaosgate, r, rt, 0); ADDMSG(&r->msgs, msg_message("chaosgate_effect_1", "mage", caster)); ADDMSG(&rt->msgs, msg_message("chaosgate_effect_2", ""));