Fix computation of map buffer indexes
The correct method to compute indexes into a map buffer for a struct range is deltx(), delty(). path() used deltax(), deltay() instead, which yield correct results only for indexes up to half the world size. Pathes spanning larger areas were screwed up. sona(), radmap2(), satmap() also used deltax(), deltay(), but only with arguments where those yield correct results. draw_map() used xnorm(), ynorm() instead, which is correct, but less clear and less efficient.
This commit is contained in:
parent
42a8b315e5
commit
3ca882714d
5 changed files with 8 additions and 20 deletions
|
@ -100,7 +100,7 @@ path(void)
|
|||
i = diridx(*pp);
|
||||
if (i == DIR_STOP)
|
||||
break;
|
||||
memcpy(&map[deltay(cy, ns.range.ly)][deltax(cx, ns.range.lx) * 2],
|
||||
memcpy(&map[delty(&ns.range, cy)][deltx(&ns.range, cx) * 2],
|
||||
routech[i][0],
|
||||
3);
|
||||
cx += diroff[i][0];
|
||||
|
|
|
@ -122,8 +122,8 @@ sona(void)
|
|||
}
|
||||
}
|
||||
snxtsct_dist(&ns, ship.shp_x, ship.shp_y, srange);
|
||||
cx = deltax(ship.shp_x, ns.range.lx);
|
||||
cy = deltay(ship.shp_y, ns.range.ly);
|
||||
cx = deltx(&ns.range, ship.shp_x);
|
||||
cy = delty(&ns.range, ship.shp_y);
|
||||
while (nxtsct(&ns, §)) {
|
||||
if (!line_of_sight(rad, cx, cy, ns.dx, ns.dy)) {
|
||||
rad[ns.dy][ns.dx] = ' ';
|
||||
|
|
|
@ -249,8 +249,8 @@ draw_map(int bmap, char origin, int map_flags, struct nstr_sect *nsp)
|
|||
if (!xyinrange(unit.gen.x, unit.gen.y, &nsp->range))
|
||||
continue;
|
||||
|
||||
x = xnorm(unit.gen.x - nsp->range.lx);
|
||||
y = ynorm(unit.gen.y - nsp->range.ly);
|
||||
x = deltx(&nsp->range, unit.gen.x);
|
||||
y = delty(&nsp->range, unit.gen.y);
|
||||
|
||||
if (ef_mappable[i] == EF_NUKE)
|
||||
wmap[y][x] = 'N';
|
||||
|
|
|
@ -175,15 +175,9 @@ radmap2(int owner,
|
|||
* make the center of the display 0
|
||||
* so ve et al can find it.
|
||||
*/
|
||||
rad[deltay(cy, ns.range.ly)][deltax(cx, ns.range.lx)] = '0';
|
||||
/* won't work for radar maps > WORLD_Y/2 */
|
||||
#ifdef HAY
|
||||
/* This is not correct for small, hitech worlds. */
|
||||
n = deltay(ns.range.hy, ns.range.ly);
|
||||
#else
|
||||
/* This is already available, so why not use it. */
|
||||
rad[delty(&ns.range, cy)][deltx(&ns.range, cx)] = '0';
|
||||
|
||||
n = ns.range.height;
|
||||
#endif
|
||||
for (row = 0; row < n; row++)
|
||||
pr("%s\n", rad[row]);
|
||||
pr("\n");
|
||||
|
|
|
@ -240,16 +240,10 @@ satmap(int x, int y, int eff, int range, int flags, int type)
|
|||
* We have to make the center a '0' for ve
|
||||
* ve needs a garbage line to terminate the map
|
||||
*/
|
||||
rad[deltay(y, ns.range.ly)][deltax(x, ns.range.lx)] = '0';
|
||||
rad[delty(&ns.range, y)][deltx(&ns.range, y)] = '0';
|
||||
|
||||
pr("Satellite radar report\n");
|
||||
#ifdef HAY
|
||||
/* This is wrong for small, hitech worlds. */
|
||||
n = deltay(ns.range.hy, ns.range.ly);
|
||||
#else
|
||||
/* This is already available, so why not use it. */
|
||||
n = ns.range.height;
|
||||
#endif
|
||||
for (row = 0; row < n; row++)
|
||||
pr("%s\n", rad[row]);
|
||||
pr("\n(c) 1989 Imaginative Images Inc.\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue