(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.
This commit is contained in:
Markus Armbruster 2006-07-21 18:10:09 +00:00
parent ad0a37eca4
commit 6db2e6ec63
5 changed files with 26 additions and 17 deletions

View file

@ -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 */

View file

@ -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(&sect, des);
set_coastal(&sect, sect.sct_type, des);
sect.sct_type = des;
sect.sct_effic = 0;
changed += map_set(player->cnum, sect.sct_x, sect.sct_y,

View file

@ -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':

View file

@ -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(&sectb);
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(&sectb);
set_coastal(&secta, sectb.sct_type, secta.sct_type);
putsect(&secta);
getsect(sectb.sct_x, sectb.sct_y, &sectb);
set_coastal(&sectb, secta.sct_type, sectb.sct_type);
putsect(&sectb);
pr("done\n");
return RET_OK;

View file

@ -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