]> git.pond.sub.org Git - empserver/commitdiff
(unit_list): New, create by combining shp_list() and lnd_list().
authorRon Koenderink <rkoenderink@yahoo.ca>
Tue, 23 Jan 2007 01:41:37 +0000 (01:41 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Tue, 23 Jan 2007 01:41:37 +0000 (01:41 +0000)
(do_unit_move): Replace call to shp_list() and lnd_list() with unit_list().
(shp_list, lnd_list): Remove, not needed, replaced by unit_list().

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 [new file with mode: 0644]

index 0f7992a3e2952454626c9ea549e275de358b2cf2..8af468b6b45094722141633a04c860dd1b66917c 100644 (file)
@@ -207,7 +207,6 @@ extern void count_units(struct shpstr *);
 extern void lnd_count_units(struct lndstr *);
 extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
 extern void lnd_put(struct emp_qelem *, natid);
-extern void lnd_list(struct emp_qelem *);
 extern int lnd_hardtarget(struct lndstr *);
 extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int);
 extern int lnd_support(natid, natid, coord, coord, int);
index 154900067886b0078153e1776cb99ff6c123be71..26fa3193e686a17a32fd3215669d2c97b2c5db6f 100644 (file)
@@ -666,7 +666,6 @@ 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 void shp_put(struct emp_qelem *, natid);
-extern void shp_list(struct emp_qelem *);
 extern int shp_check_nav(struct sctstr *, struct shpstr *);
 extern int sect_has_dock(struct sctstr *);
 extern int shp_hardtarget(struct shpstr *);
index 83512971173e59470d8ac1de16803605e210036f..6209bdcea1488c62e8edcbbad64fb6749626ac92 100644 (file)
@@ -42,4 +42,4 @@ struct ulist {
     int supplied;              /* LAND only */
 };
 
-
+extern void unit_list(struct emp_qelem *);
index c10fda1052a30c072e017ee3d2ca1d8bfbbd069e..fc496aafa8b14cc64b226f99caaa41bdbe4bd81c 100644 (file)
@@ -227,10 +227,7 @@ do_unit_move(struct emp_qelem *ulist, int *together,
            }
            continue;
        case 'i':
-           if (type == EF_SHIP)
-               shp_list(ulist);
-           else
-               lnd_list(ulist);
+           unit_list(ulist);
            continue;
        case 'm':
            if (type == EF_SHIP)
index d359a4010328be2eaedd9d5a0a3dc08db5c3d5a6..00c5cdd358db4de48bbdc24ae397d52c74bccc01 100644 (file)
@@ -742,36 +742,6 @@ lnd_check_mines(struct emp_qelem *land_list)
     return stopping;
 }
 
-void
-lnd_list(struct emp_qelem *land_list)
-{
-    struct emp_qelem *qp;
-    struct emp_qelem *next;
-    struct ulist *llp;
-    struct lndstr *lnd;
-
-    pr("lnd#     land type       x,y    a  eff  sh gun xl  mu tech retr fuel\n");
-
-    for (qp = land_list->q_back; qp != land_list; qp = next) {
-       next = qp->q_back;
-       llp = (struct ulist *)qp;
-       lnd = &llp->unit.land;
-       pr("%4d ", lnd->lnd_uid);
-       pr("%-16.16s ", ((struct lchrstr *)llp->chrp)->l_name);
-       prxy("%4d,%-4d ", lnd->lnd_x, lnd->lnd_y, llp->unit.land.lnd_own);
-       pr("%1.1s", &lnd->lnd_army);
-       pr("%4d%%", lnd->lnd_effic);
-       pr("%4d", lnd->lnd_item[I_SHELL]);
-       pr("%4d", lnd->lnd_item[I_GUN]);
-       count_land_planes(lnd);
-       pr("%3d", lnd->lnd_nxlight);
-       pr("%4d", lnd->lnd_mobil);
-       pr("%4d", lnd->lnd_tech);
-       pr("%4d%%", lnd->lnd_retreat);
-       pr("%5d\n", lnd->lnd_fuel);
-    }
-}
-
 static void
 lnd_mess(char *str, struct ulist *llp)
 {
index 2e6fb0cf0e5d0980174c3d5166f2a57dab76a931..679a119527ddf78055c7b9011bd75eb3359809d2 100644 (file)
@@ -318,38 +318,6 @@ shp_check_mines(struct emp_qelem *ship_list)
     return stopping;
 }
 
-void
-shp_list(struct emp_qelem *ship_list)
-{
-    struct emp_qelem *qp;
-    struct emp_qelem *next;
-    struct ulist *mlp;
-    struct shpstr *shp;
-
-    pr("shp#     ship type       x,y   fl  eff mil  sh gun pn he xl ln mob tech\n");
-
-    for (qp = ship_list->q_back; qp != ship_list; qp = next) {
-       next = qp->q_back;
-       mlp = (struct ulist *)qp;
-       shp = &mlp->unit.ship;
-       pr("%4d ", shp->shp_uid);
-       pr("%-16.16s ", ((struct mchrstr *)mlp->chrp)->m_name);
-       prxy("%4d,%-4d ", shp->shp_x, shp->shp_y, mlp->unit.ship.shp_own);
-       pr("%1.1s", &shp->shp_fleet);
-       pr("%4d%%", shp->shp_effic);
-       pr("%4d", shp->shp_item[I_MILIT]);
-       pr("%4d", shp->shp_item[I_SHELL]);
-       pr("%4d", shp->shp_item[I_GUN]);
-       count_planes(shp);
-       pr("%3d", shp->shp_nplane);
-       pr("%3d", shp->shp_nchoppers);
-       pr("%3d", shp->shp_nxlight);
-       count_units(shp);
-       pr("%3d", shp->shp_nland);
-       pr("%4d", shp->shp_mobil);
-       pr("%4d\n", shp->shp_tech);
-    }
-}
 
 static void
 shp_mess(char *str, struct ulist *mlp)
diff --git a/src/lib/subs/unitsub.c b/src/lib/subs/unitsub.c
new file mode 100644 (file)
index 0000000..e19e9b9
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ *  Empire - A multi-player, client/server Internet based war game.
+ *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                           Ken Stevens, Steve McClure
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  ---
+ *
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
+ *
+ *  ---
+ *
+ *  unitsub.c: Common subroutines for multiple type of units
+ * 
+ *  Known contributors to this file:
+ *     Ron Koenderink, 2007
+ */
+
+#include <config.h>
+
+#include "empobj.h"
+#include "file.h"
+#include "prototypes.h"
+#include "unit.h"
+
+void
+unit_list(struct emp_qelem *unit_list)
+{
+    struct emp_qelem *qp;
+    struct emp_qelem *next;
+    struct ulist *ulp;
+    struct empobj *unit;
+    struct lndstr *lnd;
+    struct shpstr *shp;
+
+    CANT_HAPPEN(QEMPTY(unit_list));
+
+    qp = unit_list->q_back;
+    ulp = (struct ulist *)qp;
+
+    if (ulp->unit.ef_type == EF_LAND)
+       pr("lnd#     land type       x,y    a  eff  sh gun xl  mu tech retr fuel\n");
+    else
+        pr("shp#     ship type       x,y   fl  eff mil  sh gun pn he xl ln mob tech\n");
+
+    for (; qp != unit_list; qp = next) {
+       next = qp->q_back;
+       ulp = (struct ulist *)qp;
+       lnd = &ulp->unit.land;
+       shp = &ulp->unit.ship;
+       unit = &ulp->unit.gen;
+       pr("%4d ", unit->uid);
+       pr("%-16.16s ", emp_obj_chr_name(unit));
+       prxy("%4d,%-4d ", unit->x, unit->y, unit->own);
+       pr("%1.1s", &unit->group);
+       pr("%4d%%", unit->effic);
+       if (unit->ef_type == EF_LAND) {
+           pr("%4d", lnd->lnd_item[I_SHELL]);
+           pr("%4d", lnd->lnd_item[I_GUN]);
+           count_land_planes(lnd);
+           pr("%3d", lnd->lnd_nxlight);
+       } else {
+           pr("%4d", shp->shp_item[I_MILIT]);
+           pr("%4d", shp->shp_item[I_SHELL]);
+           pr("%4d", shp->shp_item[I_GUN]);
+           count_planes(shp);
+           pr("%3d", shp->shp_nplane);
+           pr("%3d", shp->shp_nchoppers);
+           pr("%3d", shp->shp_nxlight);
+           count_units(shp);
+           pr("%3d", shp->shp_nland);
+       }
+       pr("%4d", unit->mobil);
+       pr("%4d", unit->tech);
+       if (unit->ef_type == EF_LAND) {
+           pr("%4d%%", lnd->lnd_retreat);
+           pr("%5d", lnd->lnd_fuel);
+       }
+       pr("\n");
+    }
+}