(explore_map, nav_map, move_map, fly_map): Don't use snxtsct(), it
obeys conditionals. Use snxtsct_dist(). Closes #785447. Only march and test were actually broken, the other uses zapped conditionals. (move_map, fly_map, nav_map, navi): Don't zap conditionals.
This commit is contained in:
parent
62d95ff6d4
commit
707e1aad72
3 changed files with 16 additions and 58 deletions
|
@ -280,23 +280,15 @@ static int
|
||||||
explore_map(s_char *what, coord curx, coord cury, s_char *arg)
|
explore_map(s_char *what, coord curx, coord cury, s_char *arg)
|
||||||
{
|
{
|
||||||
struct nstr_sect ns;
|
struct nstr_sect ns;
|
||||||
struct natstr *np;
|
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
coord rel_x, rel_y;
|
char view[7];
|
||||||
s_char range[128];
|
|
||||||
s_char view[7];
|
|
||||||
int i;
|
int i;
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
|
||||||
np = getnatp(player->cnum);
|
snxtsct_dist(&ns, curx, cury, 1);
|
||||||
rel_x = xrel(np, curx);
|
|
||||||
rel_y = yrel(np, cury);
|
|
||||||
sprintf(range, "%d:%d,%d:%d", rel_x - 2, rel_x + 2, rel_y - 1,
|
|
||||||
rel_y + 1);
|
|
||||||
if (!snxtsct(&ns, range))
|
|
||||||
return RET_FAIL;
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < 7 && nxtsct(&ns, §)) {
|
while (i < 7 && nxtsct(&ns, §)) {
|
||||||
|
/* Nasty: this relies on the iteration order */
|
||||||
view[i] = dchr[sect.sct_type].d_mnem;
|
view[i] = dchr[sect.sct_type].d_mnem;
|
||||||
switch (sect.sct_type) {
|
switch (sect.sct_type) {
|
||||||
case SCT_WATER:
|
case SCT_WATER:
|
||||||
|
|
|
@ -72,7 +72,6 @@ navi(void)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
shp_sel(&ni_ship, &ship_list);
|
shp_sel(&ni_ship, &ship_list);
|
||||||
shp_nav(&ship_list, &minmob, &maxmob, &together, player->cnum);
|
shp_nav(&ship_list, &minmob, &maxmob, &together, player->cnum);
|
||||||
player->condarg = 0; /* conditions don't apply to nav_map() */
|
|
||||||
if (QEMPTY(&ship_list)) {
|
if (QEMPTY(&ship_list)) {
|
||||||
pr("No ships\n");
|
pr("No ships\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
|
@ -216,7 +215,7 @@ navi(void)
|
||||||
int
|
int
|
||||||
nav_map(int x, int y, int show_designations)
|
nav_map(int x, int y, int show_designations)
|
||||||
{
|
{
|
||||||
s_char *ptr;
|
char *ptr;
|
||||||
struct nstr_sect ns;
|
struct nstr_sect ns;
|
||||||
struct natstr *np;
|
struct natstr *np;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
|
@ -225,20 +224,14 @@ nav_map(int x, int y, int show_designations)
|
||||||
/* Note this is not re-entrant anyway, so we keep the buffers
|
/* Note this is not re-entrant anyway, so we keep the buffers
|
||||||
around */
|
around */
|
||||||
static unsigned char *bitmap = NULL;
|
static unsigned char *bitmap = NULL;
|
||||||
static s_char *wmapbuf = NULL;
|
static char *wmapbuf = NULL;
|
||||||
static s_char **wmap = NULL;
|
static char **wmap = NULL;
|
||||||
s_char what[64];
|
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
|
||||||
np = getnatp(player->cnum);
|
|
||||||
sprintf(what, "%d:%d,%d:%d", xrel(np, x - 2), xrel(np, x + 2),
|
|
||||||
yrel(np, y - 1), yrel(np, y + 1));
|
|
||||||
if (!snxtsct(&ns, what))
|
|
||||||
return RET_FAIL;
|
|
||||||
if (!wmapbuf)
|
if (!wmapbuf)
|
||||||
wmapbuf = malloc(WORLD_Y * MAPWIDTH(1));
|
wmapbuf = malloc(WORLD_Y * MAPWIDTH(1));
|
||||||
if (!wmap) {
|
if (!wmap) {
|
||||||
wmap = malloc(WORLD_Y * sizeof(s_char *));
|
wmap = malloc(WORLD_Y * sizeof(*wmap));
|
||||||
if (wmap && wmapbuf) {
|
if (wmap && wmapbuf) {
|
||||||
for (i = 0; i < WORLD_Y; i++)
|
for (i = 0; i < WORLD_Y; i++)
|
||||||
wmap[i] = &wmapbuf[MAPWIDTH(1) * i];
|
wmap[i] = &wmapbuf[MAPWIDTH(1) * i];
|
||||||
|
@ -255,10 +248,10 @@ nav_map(int x, int y, int show_designations)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8);
|
memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8);
|
||||||
/* zap any conditionals */
|
snxtsct_dist(&ns, x, y, 1);
|
||||||
ns.ncond = 0;
|
np = getnatp(player->cnum);
|
||||||
xyrelrange(np, &ns.range, &range);
|
xyrelrange(np, &ns.range, &range);
|
||||||
blankfill((s_char *)wmapbuf, &ns.range, 1);
|
blankfill(wmapbuf, &ns.range, 1);
|
||||||
while (nxtsct(&ns, §)) {
|
while (nxtsct(&ns, §)) {
|
||||||
ptr = &wmap[ns.dy][ns.dx];
|
ptr = &wmap[ns.dy][ns.dx];
|
||||||
*ptr = dchr[sect.sct_type].d_mnem;
|
*ptr = dchr[sect.sct_type].d_mnem;
|
||||||
|
|
|
@ -253,28 +253,15 @@ static int
|
||||||
move_map(s_char *what, coord curx, coord cury, s_char *arg)
|
move_map(s_char *what, coord curx, coord cury, s_char *arg)
|
||||||
{
|
{
|
||||||
struct nstr_sect ns;
|
struct nstr_sect ns;
|
||||||
struct natstr *np;
|
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
coord rel_x, rel_y;
|
char view[7];
|
||||||
s_char range[128];
|
|
||||||
s_char view[7];
|
|
||||||
int i;
|
int i;
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
|
||||||
np = getnatp(player->cnum);
|
snxtsct_dist(&ns, curx, cury, 1);
|
||||||
rel_x = xrel(np, curx);
|
|
||||||
rel_y = yrel(np, cury);
|
|
||||||
sprintf(range, "%d:%d,%d:%d", rel_x - 2, rel_x + 2, rel_y - 1,
|
|
||||||
rel_y + 1);
|
|
||||||
player->condarg = 0;
|
|
||||||
/* This is necessary, otherwise move_map would attempt to pay */
|
|
||||||
/* attention to the conditional arguments left behind by such */
|
|
||||||
/* a command as "tran p -1,-1 ?eff=100".. It'd then only see */
|
|
||||||
/* 100% efficienct sects, and get all screwed up --ts */
|
|
||||||
if (!snxtsct(&ns, range))
|
|
||||||
return RET_FAIL;
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < 7 && nxtsct(&ns, §)) {
|
while (i < 7 && nxtsct(&ns, §)) {
|
||||||
|
/* Nasty: this relies on the iteration order */
|
||||||
view[i] = dchr[sect.sct_type].d_mnem;
|
view[i] = dchr[sect.sct_type].d_mnem;
|
||||||
switch (sect.sct_type) {
|
switch (sect.sct_type) {
|
||||||
case SCT_WATER:
|
case SCT_WATER:
|
||||||
|
@ -310,28 +297,14 @@ int
|
||||||
fly_map(coord curx, coord cury)
|
fly_map(coord curx, coord cury)
|
||||||
{
|
{
|
||||||
struct nstr_sect ns;
|
struct nstr_sect ns;
|
||||||
struct natstr *np;
|
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
coord rel_x, rel_y;
|
char view[7];
|
||||||
s_char view[7];
|
|
||||||
int i;
|
int i;
|
||||||
s_char range[128];
|
|
||||||
|
|
||||||
np = getnatp(player->cnum);
|
snxtsct_dist(&ns, curx, cury, 1);
|
||||||
rel_x = xrel(np, curx);
|
|
||||||
rel_y = yrel(np, cury);
|
|
||||||
sprintf(range, "%d:%d,%d:%d", rel_x - 2, rel_x + 2, rel_y - 1,
|
|
||||||
rel_y + 1);
|
|
||||||
player->condarg = 0;
|
|
||||||
/* This is necessary, otherwise move_map would attempt to pay */
|
|
||||||
/* attention to the conditional arguments left behind by such */
|
|
||||||
/* a command as "tran p -1,-1 ?eff=100".. It'd then only see */
|
|
||||||
/* 100% efficienct sects, and get all screwed up --ts */
|
|
||||||
|
|
||||||
if (!snxtsct(&ns, range))
|
|
||||||
return RET_FAIL;
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < 7 && nxtsct(&ns, §)) {
|
while (i < 7 && nxtsct(&ns, §)) {
|
||||||
|
/* Nasty: this relies on the iteration order */
|
||||||
if (!(view[i] = player->bmap[sctoff(ns.x, ns.y)]))
|
if (!(view[i] = player->bmap[sctoff(ns.x, ns.y)]))
|
||||||
view[i] = ' ';
|
view[i] = ' ';
|
||||||
i++;
|
i++;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue