Fix pathrange() for paths spanning whole world (with border)
pathrange() screwed up when the result should have been as wide or as high as the whole world. This made the path command show a broken map.
This commit is contained in:
parent
f6e62bd929
commit
0f458d2c0c
1 changed files with 22 additions and 17 deletions
|
@ -34,6 +34,7 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
#include "optlist.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
|
@ -237,30 +238,34 @@ pathtoxy(char *path, coord *xp, coord *yp,
|
||||||
void
|
void
|
||||||
pathrange(coord cx, coord cy, char *pp, int border, struct range *range)
|
pathrange(coord cx, coord cy, char *pp, int border, struct range *range)
|
||||||
{
|
{
|
||||||
int dir;
|
int dir, lx, ly, hx, hy;
|
||||||
|
|
||||||
range->lx = cx;
|
lx = hx = cx;
|
||||||
range->hx = cx;
|
ly = hy = cy;
|
||||||
range->ly = cy;
|
|
||||||
range->hy = cy;
|
|
||||||
for (; *pp; pp++) {
|
for (; *pp; pp++) {
|
||||||
dir = diridx(*pp);
|
dir = diridx(*pp);
|
||||||
if (dir == DIR_STOP)
|
if (dir == DIR_STOP)
|
||||||
break;
|
break;
|
||||||
cx += diroff[dir][0];
|
cx += diroff[dir][0];
|
||||||
cy += diroff[dir][1];
|
cy += diroff[dir][1];
|
||||||
if (cx < range->lx)
|
if (cx < lx)
|
||||||
range->lx = cx;
|
lx = cx;
|
||||||
if (cx > range->hx)
|
if (cx > hx)
|
||||||
range->hx = cx;
|
hx = cx;
|
||||||
if (cy < range->ly)
|
if (cy < ly)
|
||||||
range->ly = cy;
|
ly = cy;
|
||||||
if (cy > range->hy)
|
if (cy > hy)
|
||||||
range->hy = cy;
|
hy = cy;
|
||||||
}
|
}
|
||||||
range->lx = xnorm(range->lx - border * 2);
|
|
||||||
range->ly = ynorm(range->ly - border);
|
lx -= border * 2;
|
||||||
range->hx = xnorm(range->hx + border * 2);
|
hx += border * 2;
|
||||||
range->hy = ynorm(range->hy + border);
|
ly -= border;
|
||||||
|
hy += border;
|
||||||
|
|
||||||
|
range->lx = xnorm(lx);
|
||||||
|
range->hx = ynorm(hx - lx < WORLD_X ? hx : lx - 1);
|
||||||
|
range->ly = ynorm(ly);
|
||||||
|
range->hy = ynorm(hy - ly < WORLD_Y ? hy : ly - 1);
|
||||||
xysize_range(range);
|
xysize_range(range);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue