(unit_path): New, create by combining shp_path() and lnd_path().
(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.
This commit is contained in:
parent
d94d269769
commit
aee2bc78e2
7 changed files with 55 additions and 82 deletions
|
@ -191,7 +191,6 @@ extern int lnd_check_mines(struct emp_qelem *);
|
||||||
extern double lnd_pathcost(struct lndstr *, double);
|
extern double lnd_pathcost(struct lndstr *, double);
|
||||||
extern int lnd_mobtype(struct lndstr *);
|
extern int lnd_mobtype(struct lndstr *);
|
||||||
extern double lnd_mobcost(struct lndstr *, struct sctstr *);
|
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 attack_val(int, struct lndstr *);
|
||||||
extern double defense_val(struct lndstr *);
|
extern double defense_val(struct lndstr *);
|
||||||
|
|
|
@ -664,7 +664,6 @@ extern void show_news(int);
|
||||||
extern void shp_sel(struct nstr_item *, struct emp_qelem *);
|
extern void shp_sel(struct nstr_item *, struct emp_qelem *);
|
||||||
extern void shp_nav(struct emp_qelem *, double *, double *, int *, natid);
|
extern void shp_nav(struct emp_qelem *, double *, double *, int *, natid);
|
||||||
extern int shp_sweep(struct emp_qelem *, int, 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 shp_check_nav(struct sctstr *, struct shpstr *);
|
||||||
extern int sect_has_dock(struct sctstr *);
|
extern int sect_has_dock(struct sctstr *);
|
||||||
extern int shp_hardtarget(struct shpstr *);
|
extern int shp_hardtarget(struct shpstr *);
|
||||||
|
|
|
@ -44,3 +44,4 @@ struct ulist {
|
||||||
|
|
||||||
extern void unit_list(struct emp_qelem *);
|
extern void unit_list(struct emp_qelem *);
|
||||||
extern void unit_put(struct emp_qelem *list, natid actor);
|
extern void unit_put(struct emp_qelem *list, natid actor);
|
||||||
|
extern char *unit_path(int, struct empobj *, char *);
|
||||||
|
|
|
@ -94,13 +94,8 @@ do_unit_move(struct emp_qelem *ulist, int *together,
|
||||||
|
|
||||||
if (player->argp[2]) {
|
if (player->argp[2]) {
|
||||||
strcpy(buf, player->argp[2]);
|
strcpy(buf, player->argp[2]);
|
||||||
if (type == EF_SHIP) {
|
if (!(cp = unit_path(*together, leader, buf)))
|
||||||
if (!(cp = shp_path(*together, (struct shpstr *)leader, buf)))
|
cp = player->argp[2];
|
||||||
cp = player->argp[2];
|
|
||||||
} else {
|
|
||||||
if (!(cp = lnd_path(*together, (struct lndstr *)leader, buf)))
|
|
||||||
cp = player->argp[2];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*pt = '\0';
|
*pt = '\0';
|
||||||
|
@ -161,15 +156,8 @@ do_unit_move(struct emp_qelem *ulist, int *together,
|
||||||
stopping = 1;
|
stopping = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (type == EF_SHIP) {
|
if (!(cp = unit_path(*together, leader, buf)))
|
||||||
if (!(cp = shp_path(*together, (struct shpstr *)leader,
|
cp = buf;
|
||||||
buf)))
|
|
||||||
cp = buf;
|
|
||||||
} else {
|
|
||||||
if (!(cp = lnd_path(*together, (struct lndstr *)leader,
|
|
||||||
buf)))
|
|
||||||
cp = buf;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (type == EF_SHIP) {
|
if (type == EF_SHIP) {
|
||||||
radmapnopr(leader->x, leader->y, (int)leader->effic,
|
radmapnopr(leader->x, leader->y, (int)leader->effic,
|
||||||
|
|
|
@ -1205,41 +1205,6 @@ lnd_support(natid victim, natid attacker, coord x, coord y, int defending)
|
||||||
}
|
}
|
||||||
return (int)dam;
|
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
|
int
|
||||||
lnd_can_attack(struct lndstr *lp)
|
lnd_can_attack(struct lndstr *lp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -950,35 +950,6 @@ shp_missile_defense(coord dx, coord dy, natid bombown, int hardtarget)
|
||||||
return 0; /* all attempts failed */
|
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 */
|
/* Fire missiles at a ship which has fired shells */
|
||||||
void
|
void
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include "empobj.h"
|
#include "empobj.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
#include "player.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "unit.h"
|
#include "unit.h"
|
||||||
|
|
||||||
|
@ -125,4 +126,53 @@ unit_put(struct emp_qelem *list, natid actor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue