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:
parent
0d477e5df1
commit
a65ee5e9b2
1 changed files with 14 additions and 20 deletions
|
@ -47,14 +47,6 @@
|
||||||
#include "ship.h"
|
#include "ship.h"
|
||||||
#include "xy.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
|
/* More dynamic world sized buffers. We create 'em once, and then
|
||||||
* never again. No need to keep creating/tearing apart. We may
|
* never again. No need to keep creating/tearing apart. We may
|
||||||
* want to do this in other places too where it doesn't matter. */
|
* 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 **vis;
|
||||||
static signed char *visbuf;
|
static signed char *visbuf;
|
||||||
|
|
||||||
static void
|
/*
|
||||||
radmap2(int owner,
|
* Draw a radar map for radar at CX,CY.
|
||||||
int cx, int cy, int eff, int range, double seesub, int pr_flag)
|
* 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;
|
int visib, rng;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
|
@ -105,13 +102,12 @@ radmap2(int owner,
|
||||||
range = (int)(range * (eff / 100.0));
|
range = (int)(range * (eff / 100.0));
|
||||||
if (range < 1)
|
if (range < 1)
|
||||||
range = 1;
|
range = 1;
|
||||||
if (pr_flag)
|
pr("%s efficiency %d%%, max range %d\n",
|
||||||
pr("%s efficiency %d%%, max range %d\n",
|
xyas(cx, cy, player->cnum), eff, range);
|
||||||
xyas(cx, cy, owner), eff, range);
|
|
||||||
snxtsct_dist(&ns, cx, cy, range);
|
snxtsct_dist(&ns, cx, cy, range);
|
||||||
blankfill(radbuf, &ns.range, 1);
|
blankfill(radbuf, &ns.range, 1);
|
||||||
while (nxtsct(&ns, §)) {
|
while (nxtsct(&ns, §)) {
|
||||||
if (sect.sct_own == owner
|
if (sect.sct_own == player->cnum
|
||||||
|| sect.sct_type == SCT_WATER
|
|| sect.sct_type == SCT_WATER
|
||||||
|| sect.sct_type == SCT_MOUNT
|
|| sect.sct_type == SCT_MOUNT
|
||||||
|| sect.sct_type == SCT_WASTE
|
|| sect.sct_type == SCT_WASTE
|
||||||
|
@ -119,12 +115,10 @@ radmap2(int owner,
|
||||||
rad[ns.dy][ns.dx] = dchr[sect.sct_type].d_mnem;
|
rad[ns.dy][ns.dx] = dchr[sect.sct_type].d_mnem;
|
||||||
else
|
else
|
||||||
rad[ns.dy][ns.dx] = '?';
|
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)
|
if (changed)
|
||||||
writemap(owner);
|
writemap(player->cnum);
|
||||||
if (!pr_flag)
|
|
||||||
return;
|
|
||||||
snxtitem_dist(&ni, EF_PLANE, cx, cy, range);
|
snxtitem_dist(&ni, EF_PLANE, cx, cy, range);
|
||||||
while (nxtitem(&ni, &plane)) {
|
while (nxtitem(&ni, &plane)) {
|
||||||
if (plane.pln_own == 0)
|
if (plane.pln_own == 0)
|
||||||
|
@ -133,7 +127,7 @@ radmap2(int owner,
|
||||||
x = deltx(&ns.range, (int)plane.pln_x);
|
x = deltx(&ns.range, (int)plane.pln_x);
|
||||||
y = delty(&ns.range, (int)plane.pln_y);
|
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;
|
vis[y][x] = 100;
|
||||||
rad[y][x] = '$';
|
rad[y][x] = '$';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue