From 6db2e6ec6372986ad20a19f681fc323624bec860 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 21 Jul 2006 18:10:09 +0000 Subject: [PATCH] (swaps): Failed to update coastal flags. Was missed in the changeset containing coastal.c rev. 1.1. (set_coastal): New parameter olddes, to simplify fixing swaps(). Callers changed. --- include/prototypes.h | 2 +- src/lib/commands/desi.c | 2 +- src/lib/commands/edit.c | 2 +- src/lib/commands/swap.c | 22 +++++++++++++--------- src/lib/subs/coastal.c | 15 ++++++++++----- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/include/prototypes.h b/include/prototypes.h index d4c20b3ab..2e1ce9ad7 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -444,7 +444,7 @@ extern int check_cost(int, int, long, int *, char *); /* cnumb.c */ extern int cnumb(char *); /* coastal.c */ -extern void set_coastal(struct sctstr *sp, int des); +extern void set_coastal(struct sctstr *, int, int); /* control.c */ extern int military_control(struct sctstr *); /* detonate.c */ diff --git a/src/lib/commands/desi.c b/src/lib/commands/desi.c index b5b2f74ea..dde5c4d36 100644 --- a/src/lib/commands/desi.c +++ b/src/lib/commands/desi.c @@ -168,7 +168,7 @@ do_desi(struct natstr *natp, char *sects, char *deschar, long cash, } if (sect.sct_type != des && (sect.sct_effic < 5 || player->god)) { if (player->god) - set_coastal(§, des); + set_coastal(§, sect.sct_type, des); sect.sct_type = des; sect.sct_effic = 0; changed += map_set(player->cnum, sect.sct_x, sect.sct_y, diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index 77647e75f..5e659895a 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -613,7 +613,7 @@ doland(char op, int arg, char *p, struct sctstr *sect) pr("Designation for sector %s changed from %c to %c\n", xyas(sect->sct_x, sect->sct_y, player->cnum), dchr[sect->sct_type].d_mnem, dchr[des].d_mnem); - set_coastal(sect, des); + set_coastal(sect, sect->sct_type, des); sect->sct_type = des; break; case 'S': diff --git a/src/lib/commands/swap.c b/src/lib/commands/swap.c index 68c892d4f..754456783 100644 --- a/src/lib/commands/swap.c +++ b/src/lib/commands/swap.c @@ -44,8 +44,7 @@ static void print_res(struct sctstr *); int swaps(void) { - struct sctstr secta, sectb; - coord x, y; + struct sctstr secta, sectb, tmp; char buf[1024]; char *p; @@ -61,20 +60,25 @@ swaps(void) print_res(§b); if (!confirm ("Are you sure these are the two sectors you wish to swap? ")) return RET_FAIL; - /* save x and y from secta */ - x = secta.sct_x; - y = secta.sct_y; + tmp = secta; /* change the location of secta to that of sectb */ secta.sct_x = sectb.sct_x; secta.sct_y = sectb.sct_y; secta.sct_dist_x = sectb.sct_x; secta.sct_dist_y = sectb.sct_y; + secta.sct_coastal = sectb.sct_coastal; /* change the location of sectb to where secta was */ - sectb.sct_x = x; - sectb.sct_y = y; - sectb.sct_dist_x = x; - sectb.sct_dist_y = y; + sectb.sct_x = tmp.sct_x; + sectb.sct_y = tmp.sct_y; + sectb.sct_dist_x = tmp.sct_x; + sectb.sct_dist_y = tmp.sct_y; + sectb.sct_coastal = tmp.sct_coastal; + /* update coastal flag & put sectors */ + putsect(§b); + set_coastal(§a, sectb.sct_type, secta.sct_type); putsect(§a); + getsect(sectb.sct_x, sectb.sct_y, §b); + set_coastal(§b, secta.sct_type, sectb.sct_type); putsect(§b); pr("done\n"); return RET_OK; diff --git a/src/lib/subs/coastal.c b/src/lib/subs/coastal.c index e4b192470..c81df4915 100644 --- a/src/lib/subs/coastal.c +++ b/src/lib/subs/coastal.c @@ -91,13 +91,18 @@ coastal_land_to_sea(coord x, coord y) return 1; } +/* + * Compute coastal flags for a change of SP from OLDDES to NEWDES. + * Update adjacent sectors, but don't touch SP. + * Return new coastal flag for SP. + */ void -set_coastal(struct sctstr *sp, int des) +set_coastal(struct sctstr *sp, int olddes, int newdes) { - int old_water = sp->sct_type == SCT_WATER - || sp->sct_type == SCT_BTOWER || sp->sct_type == SCT_BSPAN; - int new_water = des == SCT_WATER - || des == SCT_BTOWER || des == SCT_BSPAN; + int old_water = olddes == SCT_WATER + || olddes == SCT_BTOWER || olddes == SCT_BSPAN; + int new_water = newdes == SCT_WATER + || newdes == SCT_BTOWER || newdes == SCT_BSPAN; if (new_water != old_water) sp->sct_coastal = new_water -- 2.43.0