]> git.pond.sub.org Git - empserver/commitdiff
(unit_path): New, create by combining shp_path() and lnd_path().
authorRon Koenderink <rkoenderink@yahoo.ca>
Wed, 24 Jan 2007 23:24:37 +0000 (23:24 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Wed, 24 Jan 2007 23:24:37 +0000 (23:24 +0000)
(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.

include/land.h
include/prototypes.h
include/unit.h
src/lib/commands/navi.c
src/lib/subs/lndsub.c
src/lib/subs/shpsub.c
src/lib/subs/unitsub.c

index 8be609a5469e9bff209926aabba579f05d41a6ce..58a8837c14c7999ce0a88b38c88e9d917db1a875 100644 (file)
@@ -191,7 +191,6 @@ extern int lnd_check_mines(struct emp_qelem *);
 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 *);
index 77078d079c17855d44253bf5024a66fde3f94aa9..71d2b91761e8c6bfa26223ffa47cffc12c29b153 100644 (file)
@@ -664,7 +664,6 @@ extern void show_news(int);
 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 *);
index 913532b2fa255dd466cc1886441e1e52f13e3ed5..7f21b9a6c7949409c80911658c32e1ef3da8aece 100644 (file)
@@ -44,3 +44,4 @@ struct ulist {
 
 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 *);
index fc496aafa8b14cc64b226f99caaa41bdbe4bd81c..b017a0543440da1ab8f07562e1c5aa602d599e9d 100644 (file)
@@ -94,13 +94,8 @@ do_unit_move(struct emp_qelem *ulist, int *together,
 
     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';
@@ -161,15 +156,8 @@ do_unit_move(struct emp_qelem *ulist, int *together,
                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,
index 0b34c97bf5d7655dc432b9fdbad1966c0f230353..2db626d05621fb5c7530c585f041a962a0e84ff2 100644 (file)
@@ -1205,41 +1205,6 @@ lnd_support(natid victim, natid attacker, coord x, coord y, int defending)
     }
     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, &sect);
-    mtype = lnd_mobtype(lp);
-    cp = BestLandPath(buf, &sect, &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)
 {
index 0d8c48ff6ae16651d37e5e8bf51732c80a276588..cc990f33af2bb3d3513b995fd0e11a62dabf0ca0 100644 (file)
@@ -950,35 +950,6 @@ shp_missile_defense(coord dx, coord dy, natid bombown, int hardtarget)
     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
index e69459c1633958047c1a4753c2787f46e4a4dc3d..3afed19c7d67e78e9835f1f1ec26fdbdf4cabb78 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "empobj.h"
 #include "file.h"
+#include "player.h"
 #include "prototypes.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, &sect);
+       mtype = lnd_mobtype((struct lndstr *)unit);
+       cp = BestLandPath(buf, &sect, &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;
+}