Simplify radmap() and radmap2()

radmap() is now radmap2()'s only caller.  Inline radmap2() and
simplify.  This cleans up a suspicious-looking use of xyas(): it
relied on the fact that owner == player->cnum if pr_flag.
This commit is contained in:
Markus Armbruster 2010-06-20 13:55:52 +02:00
parent 0d477e5df1
commit a65ee5e9b2

View file

@ -47,14 +47,6 @@
#include "ship.h"
#include "xy.h"
static void radmap2(int, int, int, int, int, double, int);
void
radmap(int cx, int cy, int eff, int range, double seesub)
{
radmap2(player->cnum, cx, cy, eff, range, seesub, 1);
}
/* More dynamic world sized buffers. We create 'em once, and then
* never again. No need to keep creating/tearing apart. We may
* want to do this in other places too where it doesn't matter. */
@ -63,9 +55,14 @@ static char *radbuf;
static signed char **vis;
static signed char *visbuf;
static void
radmap2(int owner,
int cx, int cy, int eff, int range, double seesub, int pr_flag)
/*
* Draw a radar map for radar at CX,CY.
* EFF is the radar's efficiency, and RANGE its range at 100%
* efficiency.
* Submarines are detected at fraction SEESUB of the range.
*/
void
radmap(int cx, int cy, int eff, int range, double seesub)
{
int visib, rng;
struct sctstr sect;
@ -105,13 +102,12 @@ radmap2(int owner,
range = (int)(range * (eff / 100.0));
if (range < 1)
range = 1;
if (pr_flag)
pr("%s efficiency %d%%, max range %d\n",
xyas(cx, cy, owner), eff, range);
pr("%s efficiency %d%%, max range %d\n",
xyas(cx, cy, player->cnum), eff, range);
snxtsct_dist(&ns, cx, cy, range);
blankfill(radbuf, &ns.range, 1);
while (nxtsct(&ns, &sect)) {
if (sect.sct_own == owner
if (sect.sct_own == player->cnum
|| sect.sct_type == SCT_WATER
|| sect.sct_type == SCT_MOUNT
|| sect.sct_type == SCT_WASTE
@ -119,12 +115,10 @@ radmap2(int owner,
rad[ns.dy][ns.dx] = dchr[sect.sct_type].d_mnem;
else
rad[ns.dy][ns.dx] = '?';
changed += map_set(owner, ns.x, ns.y, rad[ns.dy][ns.dx], 0);
changed += map_set(player->cnum, ns.x, ns.y, rad[ns.dy][ns.dx], 0);
}
if (changed)
writemap(owner);
if (!pr_flag)
return;
writemap(player->cnum);
snxtitem_dist(&ni, EF_PLANE, cx, cy, range);
while (nxtitem(&ni, &plane)) {
if (plane.pln_own == 0)
@ -133,7 +127,7 @@ radmap2(int owner,
x = deltx(&ns.range, (int)plane.pln_x);
y = delty(&ns.range, (int)plane.pln_y);
if (pln_is_in_orbit(&plane) && plane.pln_own != owner) {
if (pln_is_in_orbit(&plane) && plane.pln_own != player->cnum) {
vis[y][x] = 100;
rad[y][x] = '$';
}