Fold draw_map() parameter bmap into map_flags
No functional change.
This commit is contained in:
parent
a4c5d05fe1
commit
5da60a5abb
1 changed files with 52 additions and 46 deletions
|
@ -62,9 +62,15 @@
|
||||||
#define MAP_ALL (MAP_SHIP | MAP_PLANE | MAP_LAND | MAP_NUKE)
|
#define MAP_ALL (MAP_SHIP | MAP_PLANE | MAP_LAND | MAP_NUKE)
|
||||||
/* whether to highlight own sectors */
|
/* whether to highlight own sectors */
|
||||||
#define MAP_HIGH bit(4)
|
#define MAP_HIGH bit(4)
|
||||||
|
/* whether to draw a map or a bmap */
|
||||||
|
#define MAP_BMAP bit(5)
|
||||||
|
/* whether to draw an alternate map: newdes for map, true bmap for bmap */
|
||||||
|
#define MAP_ALT bit(6)
|
||||||
|
/* whether to revert bmap, internal to do_map() */
|
||||||
|
#define MAP_BMAP_REVERT bit(7)
|
||||||
|
|
||||||
static int revert_bmap(struct nstr_sect *);
|
static int revert_bmap(struct nstr_sect *);
|
||||||
static int draw_map(int, char, int, struct nstr_sect *);
|
static int draw_map(char, int, struct nstr_sect *);
|
||||||
static int bmnxtsct(struct nstr_sect *);
|
static int bmnxtsct(struct nstr_sect *);
|
||||||
static char map_char(int, natid, int);
|
static char map_char(int, natid, int);
|
||||||
static int unit_map(int, int, struct nstr_sect *, char *);
|
static int unit_map(int, int, struct nstr_sect *, char *);
|
||||||
|
@ -75,7 +81,7 @@ do_map(int bmap, int unit_type, char *arg, char *map_flags_arg)
|
||||||
struct nstr_sect ns;
|
struct nstr_sect ns;
|
||||||
char origin = '\0';
|
char origin = '\0';
|
||||||
char *b;
|
char *b;
|
||||||
int map_flags = 0;
|
int map_flags;
|
||||||
|
|
||||||
switch (sarg_type(arg)) {
|
switch (sarg_type(arg)) {
|
||||||
case NS_DIST:
|
case NS_DIST:
|
||||||
|
@ -88,6 +94,15 @@ do_map(int bmap, int unit_type, char *arg, char *map_flags_arg)
|
||||||
if (unit_map(unit_type, atoi(arg), &ns, &origin))
|
if (unit_map(unit_type, atoi(arg), &ns, &origin))
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (bmap) {
|
||||||
|
default: CANT_REACH();
|
||||||
|
/* fall through */
|
||||||
|
case 'b': map_flags = MAP_BMAP; break;
|
||||||
|
case 'n': map_flags = MAP_ALT; break;
|
||||||
|
case 0: map_flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (b = map_flags_arg; b && *b; b++) {
|
for (b = map_flags_arg; b && *b; b++) {
|
||||||
switch (*b) {
|
switch (*b) {
|
||||||
case 's':
|
case 's':
|
||||||
|
@ -116,13 +131,13 @@ do_map(int bmap, int unit_type, char *arg, char *map_flags_arg)
|
||||||
case 't':
|
case 't':
|
||||||
if (bmap != 'b')
|
if (bmap != 'b')
|
||||||
goto bad_flag;
|
goto bad_flag;
|
||||||
bmap = 't';
|
map_flags |= MAP_ALT;
|
||||||
*(b + 1) = 0;
|
*(b + 1) = 0;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
if (bmap != 'b')
|
if (bmap != 'b')
|
||||||
goto bad_flag;
|
goto bad_flag;
|
||||||
bmap = 'r';
|
map_flags = MAP_BMAP_REVERT;
|
||||||
*(b + 1) = 0;
|
*(b + 1) = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -132,9 +147,9 @@ do_map(int bmap, int unit_type, char *arg, char *map_flags_arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bmap == 'r')
|
if (map_flags & MAP_BMAP_REVERT)
|
||||||
return revert_bmap(&ns);
|
return revert_bmap(&ns);
|
||||||
return draw_map(bmap, origin, map_flags, &ns);
|
return draw_map(origin, map_flags, &ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -149,7 +164,7 @@ revert_bmap(struct nstr_sect *nsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
draw_map(int bmap, char origin, int map_flags, struct nstr_sect *nsp)
|
draw_map(char origin, int map_flags, struct nstr_sect *nsp)
|
||||||
{
|
{
|
||||||
struct natstr *np;
|
struct natstr *np;
|
||||||
struct range range;
|
struct range range;
|
||||||
|
@ -197,60 +212,51 @@ draw_map(int bmap, char origin, int map_flags, struct nstr_sect *nsp)
|
||||||
xyrelrange(np, &nsp->range, &range);
|
xyrelrange(np, &nsp->range, &range);
|
||||||
border(&range, " ", "");
|
border(&range, " ", "");
|
||||||
blankfill(wmapbuf, &nsp->range, 1);
|
blankfill(wmapbuf, &nsp->range, 1);
|
||||||
if (bmap) {
|
|
||||||
|
if (map_flags & MAP_BMAP) {
|
||||||
int c;
|
int c;
|
||||||
switch (bmap) {
|
|
||||||
default:
|
if (map_flags & MAP_ALT) {
|
||||||
CANT_REACH();
|
|
||||||
/* fall through */
|
|
||||||
case 'b':
|
|
||||||
while (bmnxtsct(nsp)) {
|
|
||||||
if (0 != (c = player->bmap[nsp->id]))
|
|
||||||
wmap[nsp->dy][nsp->dx] = c;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
while (bmnxtsct(nsp)) {
|
while (bmnxtsct(nsp)) {
|
||||||
if (0 != (c = player->map[nsp->id]))
|
if (0 != (c = player->map[nsp->id]))
|
||||||
wmap[nsp->dy][nsp->dx] = c;
|
wmap[nsp->dy][nsp->dx] = c;
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
case 'n':
|
while (bmnxtsct(nsp)) {
|
||||||
{
|
if (0 != (c = player->bmap[nsp->id]))
|
||||||
struct sctstr sect;
|
wmap[nsp->dy][nsp->dx] = c;
|
||||||
|
|
||||||
if (!player->god) {
|
|
||||||
memset(bitmap, 0, (WORLD_SZ() + 7) / 8);
|
|
||||||
bitinit2(nsp, bitmap, player->cnum);
|
|
||||||
}
|
|
||||||
while (nxtsct(nsp, §)) {
|
|
||||||
if (!player->god && !emp_getbit(nsp->x, nsp->y, bitmap))
|
|
||||||
continue;
|
|
||||||
wmap[nsp->dy][nsp->dx]
|
|
||||||
= map_char(sect.sct_newtype, sect.sct_own,
|
|
||||||
player->owner);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
char mapch;
|
|
||||||
int changed = 0;
|
|
||||||
|
|
||||||
if (!player->god) {
|
if (!player->god) {
|
||||||
memset(bitmap, 0, (WORLD_SZ() + 7) / 8);
|
memset(bitmap, 0, (WORLD_SZ() + 7) / 8);
|
||||||
bitinit2(nsp, bitmap, player->cnum);
|
bitinit2(nsp, bitmap, player->cnum);
|
||||||
}
|
}
|
||||||
while (nxtsct(nsp, §)) {
|
if (map_flags & MAP_ALT) {
|
||||||
if (!player->god && !emp_getbit(nsp->x, nsp->y, bitmap))
|
while (nxtsct(nsp, §)) {
|
||||||
continue;
|
if (!player->god && !emp_getbit(nsp->x, nsp->y, bitmap))
|
||||||
mapch = map_char(sect.sct_type, sect.sct_own, player->owner);
|
continue;
|
||||||
wmap[nsp->dy][nsp->dx] = mapch;
|
wmap[nsp->dy][nsp->dx]
|
||||||
changed |= map_set(player->cnum, nsp->x, nsp->y, mapch, 0);
|
= map_char(sect.sct_newtype, sect.sct_own,
|
||||||
|
player->owner);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
struct sctstr sect;
|
||||||
|
char mapch;
|
||||||
|
int changed = 0;
|
||||||
|
|
||||||
|
while (nxtsct(nsp, §)) {
|
||||||
|
if (!player->god && !emp_getbit(nsp->x, nsp->y, bitmap))
|
||||||
|
continue;
|
||||||
|
mapch = map_char(sect.sct_type, sect.sct_own, player->owner);
|
||||||
|
wmap[nsp->dy][nsp->dx] = mapch;
|
||||||
|
changed |= map_set(player->cnum, nsp->x, nsp->y, mapch, 0);
|
||||||
|
}
|
||||||
|
if (changed)
|
||||||
|
writemap(player->cnum);
|
||||||
}
|
}
|
||||||
if (changed)
|
|
||||||
writemap(player->cnum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue