(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:
parent
ad0a37eca4
commit
6db2e6ec63
5 changed files with 26 additions and 17 deletions
|
@ -444,7 +444,7 @@ extern int check_cost(int, int, long, int *, char *);
|
||||||
/* cnumb.c */
|
/* cnumb.c */
|
||||||
extern int cnumb(char *);
|
extern int cnumb(char *);
|
||||||
/* coastal.c */
|
/* coastal.c */
|
||||||
extern void set_coastal(struct sctstr *sp, int des);
|
extern void set_coastal(struct sctstr *, int, int);
|
||||||
/* control.c */
|
/* control.c */
|
||||||
extern int military_control(struct sctstr *);
|
extern int military_control(struct sctstr *);
|
||||||
/* detonate.c */
|
/* detonate.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 (sect.sct_type != des && (sect.sct_effic < 5 || player->god)) {
|
||||||
if (player->god)
|
if (player->god)
|
||||||
set_coastal(§, des);
|
set_coastal(§, sect.sct_type, des);
|
||||||
sect.sct_type = des;
|
sect.sct_type = des;
|
||||||
sect.sct_effic = 0;
|
sect.sct_effic = 0;
|
||||||
changed += map_set(player->cnum, sect.sct_x, sect.sct_y,
|
changed += map_set(player->cnum, sect.sct_x, sect.sct_y,
|
||||||
|
|
|
@ -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",
|
pr("Designation for sector %s changed from %c to %c\n",
|
||||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||||
dchr[sect->sct_type].d_mnem, dchr[des].d_mnem);
|
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;
|
sect->sct_type = des;
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
|
|
|
@ -44,8 +44,7 @@ static void print_res(struct sctstr *);
|
||||||
int
|
int
|
||||||
swaps(void)
|
swaps(void)
|
||||||
{
|
{
|
||||||
struct sctstr secta, sectb;
|
struct sctstr secta, sectb, tmp;
|
||||||
coord x, y;
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
|
@ -61,20 +60,25 @@ swaps(void)
|
||||||
print_res(§b);
|
print_res(§b);
|
||||||
if (!confirm ("Are you sure these are the two sectors you wish to swap? "))
|
if (!confirm ("Are you sure these are the two sectors you wish to swap? "))
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
/* save x and y from secta */
|
tmp = secta;
|
||||||
x = secta.sct_x;
|
|
||||||
y = secta.sct_y;
|
|
||||||
/* change the location of secta to that of sectb */
|
/* change the location of secta to that of sectb */
|
||||||
secta.sct_x = sectb.sct_x;
|
secta.sct_x = sectb.sct_x;
|
||||||
secta.sct_y = sectb.sct_y;
|
secta.sct_y = sectb.sct_y;
|
||||||
secta.sct_dist_x = sectb.sct_x;
|
secta.sct_dist_x = sectb.sct_x;
|
||||||
secta.sct_dist_y = sectb.sct_y;
|
secta.sct_dist_y = sectb.sct_y;
|
||||||
|
secta.sct_coastal = sectb.sct_coastal;
|
||||||
/* change the location of sectb to where secta was */
|
/* change the location of sectb to where secta was */
|
||||||
sectb.sct_x = x;
|
sectb.sct_x = tmp.sct_x;
|
||||||
sectb.sct_y = y;
|
sectb.sct_y = tmp.sct_y;
|
||||||
sectb.sct_dist_x = x;
|
sectb.sct_dist_x = tmp.sct_x;
|
||||||
sectb.sct_dist_y = y;
|
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);
|
putsect(§a);
|
||||||
|
getsect(sectb.sct_x, sectb.sct_y, §b);
|
||||||
|
set_coastal(§b, secta.sct_type, sectb.sct_type);
|
||||||
putsect(§b);
|
putsect(§b);
|
||||||
pr("done\n");
|
pr("done\n");
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
|
|
|
@ -91,13 +91,18 @@ coastal_land_to_sea(coord x, coord y)
|
||||||
return 1;
|
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
|
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
|
int old_water = olddes == SCT_WATER
|
||||||
|| sp->sct_type == SCT_BTOWER || sp->sct_type == SCT_BSPAN;
|
|| olddes == SCT_BTOWER || olddes == SCT_BSPAN;
|
||||||
int new_water = des == SCT_WATER
|
int new_water = newdes == SCT_WATER
|
||||||
|| des == SCT_BTOWER || des == SCT_BSPAN;
|
|| newdes == SCT_BTOWER || newdes == SCT_BSPAN;
|
||||||
|
|
||||||
if (new_water != old_water)
|
if (new_water != old_water)
|
||||||
sp->sct_coastal = new_water
|
sp->sct_coastal = new_water
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue