diff --git a/include/prototypes.h b/include/prototypes.h index 84614d08..d93c5c94 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -584,7 +584,7 @@ extern int ufindpfx(char *, int); 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); diff --git a/src/lib/commands/navi.c b/src/lib/commands/navi.c index c59a16ba..80588449 100644 --- a/src/lib/commands/navi.c +++ b/src/lib/commands/navi.c @@ -157,11 +157,9 @@ do_unit_move(struct emp_qelem *ulist, int *together, 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]; diff --git a/src/lib/subs/radmap.c b/src/lib/subs/radmap.c index 82aee6ee..6f7e625c 100644 --- a/src/lib/subs/radmap.c +++ b/src/lib/subs/radmap.c @@ -55,12 +55,6 @@ radmap(int cx, int cy, int eff, int range, double seesub) 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. */ @@ -202,3 +196,35 @@ delty(struct range *r, coord y) 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); +} diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index f1c6b6e1..54dc821b 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -733,7 +733,6 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor, int stopping = 0; double mobcost; double tech; /* for mapping */ - double tf; /* for mapping */ char dp[80]; int navigate; @@ -788,13 +787,9 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor, /* 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;