extern int deltx(struct range *, coord);
extern int delty(struct range *, coord);
extern void radmap(int, int, int, int, double);
-extern void radmapupd(int, int, int, int, int, double);
+extern void rad_map_set(natid, int, int, int, int);
/* rej.c */
extern int setrel(natid, natid, int);
extern int setcont(natid, natid, int);
cp = buf;
}
if (type == EF_SHIP) {
- radmapupd(player->cnum, leader->x, leader->y, leader->effic,
- (int)techfact(leader->tech,
- mchr[leader->type].m_vrnge),
- (mchr[leader->type].m_flags & M_SONAR)
- ? techfact(leader->tech, 1.0) : 0.0);
+ rad_map_set(player->cnum, leader->x, leader->y, leader->effic,
+ (int)techfact(leader->tech,
+ mchr[leader->type].m_vrnge));
}
if (cp == NULL || *cp == '\0')
cp = &dirch[DIR_STOP];
radmap2(player->cnum, cx, cy, eff, range, seesub, 1);
}
-void
-radmapupd(int own, int cx, int cy, int eff, int range, double seesub)
-{
- radmap2(own, cx, cy, eff, range, seesub, 0);
-}
-
/* 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. */
return y - r->ly;
return y + WORLD_Y - r->ly;
}
+
+/*
+ * Update OWNER's bmap for radar at CX,CY.
+ * EFF is the radar's efficiency, and RANGE its range at 100%
+ * efficiency.
+ */
+void
+rad_map_set(natid owner, int cx, int cy, int eff, int range)
+{
+ struct nstr_sect ns;
+ struct sctstr sect;
+ int changed = 0;
+ char ch;
+
+ range = (int)(range * (eff / 100.0));
+ if (range < 1)
+ range = 1;
+ snxtsct_dist(&ns, cx, cy, range);
+ while (nxtsct(&ns, §)) {
+ if (sect.sct_own == owner
+ || sect.sct_type == SCT_WATER
+ || sect.sct_type == SCT_MOUNT
+ || sect.sct_type == SCT_WASTE
+ || ns.curdist <= range / 3)
+ ch = dchr[sect.sct_type].d_mnem;
+ else
+ ch = '?';
+ changed += map_set(owner, ns.x, ns.y, ch, 0);
+ }
+ if (changed)
+ writemap(owner);
+}
int stopping = 0;
double mobcost;
double tech; /* for mapping */
- double tf; /* for mapping */
char dp[80];
int navigate;
/* Now update the map for this ship */
tech = techfact(mlp->unit.ship.shp_tech,
((struct mchrstr *)mlp->chrp)->m_vrnge);
- if (((struct mchrstr *)mlp->chrp)->m_flags & M_SONAR)
- tf = techfact(mlp->unit.ship.shp_tech, 1.0);
- else
- tf = 0.0;
- radmapupd(mlp->unit.ship.shp_own,
- mlp->unit.ship.shp_x, mlp->unit.ship.shp_y,
- (int)mlp->unit.ship.shp_effic, (int)tech, tf);
+ rad_map_set(mlp->unit.ship.shp_own,
+ mlp->unit.ship.shp_x, mlp->unit.ship.shp_y,
+ mlp->unit.ship.shp_effic, (int)tech);
}
if (QEMPTY(list))
return stopping;