(do_unit_move): Replace shp_path() and lnd_path() with unit_path().
(shp_path, lnd_path): Remove shp_path() and lnd_path(),
not used any more.
extern double lnd_pathcost(struct lndstr *, double);
extern int lnd_mobtype(struct lndstr *);
extern double lnd_mobcost(struct lndstr *, struct sctstr *);
-extern char *lnd_path(int, struct lndstr *, char *);
extern double attack_val(int, struct lndstr *);
extern double defense_val(struct lndstr *);
extern void shp_sel(struct nstr_item *, struct emp_qelem *);
extern void shp_nav(struct emp_qelem *, double *, double *, int *, natid);
extern int shp_sweep(struct emp_qelem *, int, int, natid);
-extern char *shp_path(int, struct shpstr *, char *);
extern int shp_check_nav(struct sctstr *, struct shpstr *);
extern int sect_has_dock(struct sctstr *);
extern int shp_hardtarget(struct shpstr *);
extern void unit_list(struct emp_qelem *);
extern void unit_put(struct emp_qelem *list, natid actor);
+extern char *unit_path(int, struct empobj *, char *);
if (player->argp[2]) {
strcpy(buf, player->argp[2]);
- if (type == EF_SHIP) {
- if (!(cp = shp_path(*together, (struct shpstr *)leader, buf)))
- cp = player->argp[2];
- } else {
- if (!(cp = lnd_path(*together, (struct lndstr *)leader, buf)))
- cp = player->argp[2];
- }
+ if (!(cp = unit_path(*together, leader, buf)))
+ cp = player->argp[2];
}
*pt = '\0';
stopping = 1;
continue;
}
- if (type == EF_SHIP) {
- if (!(cp = shp_path(*together, (struct shpstr *)leader,
- buf)))
- cp = buf;
- } else {
- if (!(cp = lnd_path(*together, (struct lndstr *)leader,
- buf)))
- cp = buf;
- }
+ if (!(cp = unit_path(*together, leader, buf)))
+ cp = buf;
}
if (type == EF_SHIP) {
radmapnopr(leader->x, leader->y, (int)leader->effic,
}
return (int)dam;
}
-
-char *
-lnd_path(int together, struct lndstr *lp, char *buf)
-{
- coord destx;
- coord desty;
- struct sctstr d_sect, sect;
- char *cp;
- double dummy;
- int mtype;
-
- if (!sarg_xy(buf, &destx, &desty))
- return 0;
- if (!together) {
- pr("Cannot go to a destination sector if not all starting in the same sector\n");
- return 0;
- }
- if (!getsect(destx, desty, &d_sect)) {
- pr("%d,%d is not a sector\n", destx, desty);
- return 0;
- }
- getsect(lp->lnd_x, lp->lnd_y, §);
- mtype = lnd_mobtype(lp);
- cp = BestLandPath(buf, §, &d_sect, &dummy, mtype);
- if (!cp) {
- pr("No owned %s from %s to %s!\n",
- mtype == MOB_RAIL ? "railway" : "path",
- xyas(lp->lnd_x, lp->lnd_y, player->cnum),
- xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
- return 0;
- }
- pr("Using path '%s'\n", cp);
- return cp;
-}
-
int
lnd_can_attack(struct lndstr *lp)
{
return 0; /* all attempts failed */
}
-char *
-shp_path(int together, struct shpstr *shp, char *buf)
-{
- coord destx;
- coord desty;
- struct sctstr d_sect;
- char *cp;
-
- if (!sarg_xy(buf, &destx, &desty))
- return 0;
- if (!together) {
- mpr(shp->shp_own,
- "Cannot go to a destination sector if not all starting in the same sector\n");
- return 0;
- }
- if (!getsect(destx, desty, &d_sect)) {
- mpr(shp->shp_own, "%d,%d is not a sector\n", destx, desty);
- return 0;
- }
-
- cp = BestShipPath(buf, shp->shp_x, shp->shp_y,
- d_sect.sct_x, d_sect.sct_y, player->cnum);
- if (!cp || shp->shp_mobil <= 0) {
- mpr(shp->shp_own, "Can't get to '%s' right now.\n",
- xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
- return 0;
- }
- return cp;
-}
/* Fire missiles at a ship which has fired shells */
void
#include "empobj.h"
#include "file.h"
+#include "player.h"
#include "prototypes.h"
#include "unit.h"
}
}
+char *
+unit_path(int together, struct empobj *unit, char *buf)
+{
+ coord destx;
+ coord desty;
+ struct sctstr d_sect, sect;
+ char *cp;
+ double dummy;
+ int mtype;
+ if (!sarg_xy(buf, &destx, &desty))
+ return 0;
+ if (!together) {
+ if (unit->ef_type == EF_SHIP)
+ mpr(unit->own,
+ "Cannot go to a destination sector if not all starting in the same sector\n");
+ else
+ pr("Cannot go to a destination sector if not all starting in the same sector\n");
+ return 0;
+ }
+ if (!getsect(destx, desty, &d_sect)) {
+ if (unit->ef_type == EF_SHIP)
+ mpr(unit->own, "%d,%d is not a sector\n", destx, desty);
+ else
+ pr("%d,%d is not a sector\n", destx, desty);
+ return 0;
+ }
+ if (unit->ef_type == EF_SHIP) {
+ cp = BestShipPath(buf, unit->x, unit->y,
+ d_sect.sct_x, d_sect.sct_y, player->cnum);
+ if (!cp || unit->mobil <= 0) {
+ mpr(unit->own, "Can't get to '%s' right now.\n",
+ xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
+ return 0;
+ }
+ } else {
+ getsect(unit->x, unit->y, §);
+ mtype = lnd_mobtype((struct lndstr *)unit);
+ cp = BestLandPath(buf, §, &d_sect, &dummy, mtype);
+ if (!cp) {
+ pr("No owned %s from %s to %s!\n",
+ mtype == MOB_RAIL ? "railway" : "path",
+ xyas(unit->x, unit->y, player->cnum),
+ xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
+ return 0;
+ }
+ pr("Using path '%s'\n", cp);
+ }
+ return cp;
+}