]> git.pond.sub.org Git - empserver/commitdiff
Combined struct llist and struct mlist into superset struct ulist.
authorRon Koenderink <rkoenderink@yahoo.ca>
Mon, 25 Sep 2006 03:29:06 +0000 (03:29 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Mon, 25 Sep 2006 03:29:06 +0000 (03:29 +0000)
(assa, set_leader, switch_leader, set_flagship, switch_flagship,
take_move_in_mob, get_land, ask_olist, att_get_defense,
get_dlist, get_ototal, get_dtotal, kill_land, att_infect_units,
put_land, att_reacting_units, count_bodies, att_fight,
send_reacting_units_home, take_def, ask_move_in, move_in_land,
lnd_print, lnd_delete, lnd_take_casualty, lnd_takemob,
lnd_sel, lnd_mar, lnd_put, lnd_sweep, contains_engineer,
lnd_check_mines, lnd_list, lnd_mess,
lnd_damage, lnd_easiest_target, lnd_mar_one_sector, shp_sel,
shp_nav, shp_put, shp_sweep, shp_check_one_mines, shp_check_mines,
shp_list, shp_mess, shp_count, shp_damage_one, shp_damage,
shp_contains, most_valuable_ship, shp_easiest_target,
shp_missile_interdiction, notify_coastguard,
shp_view, shp_nav_one_sector, shp_missdef, nav_ship,
fltp_to_list): Switch to struct ulist from either struct mlist
or struct llist.

include/land.h
include/ship.h
include/unit.h [new file with mode: 0644]
src/lib/commands/assa.c
src/lib/commands/marc.c
src/lib/commands/navi.c
src/lib/subs/attsub.c
src/lib/subs/lndsub.c
src/lib/subs/shpsub.c
src/lib/update/nav_ship.c
src/lib/update/sail.c

index e94fb040b4630d0b63c8462c0bf751770ff2923a..c308102f4796230e1f962af490f8ef548b6e04d7 100644 (file)
@@ -179,16 +179,6 @@ struct lchrstr {
 
 extern struct lchrstr lchr[LND_TYPE_MAX + 2];
 
-struct llist {
-    struct emp_qelem queue;    /* list of units */
-    coord x, y;                        /* x,y it came from */
-    struct lchrstr *lcp;       /* pointer to desc of land unit */
-    struct lndstr land;                /* struct land unit */
-    int eff;
-    double mobil;
-    int supplied;
-};
-
 enum {
     LND_AIROPS_EFF = 50                /* min. efficiency for air ops */
 };
@@ -205,9 +195,9 @@ extern char *lnd_path(int, struct lndstr *, char *);
 
 extern double attack_val(int, struct lndstr *);
 extern double defense_val(struct lndstr *);
-extern void lnd_print(struct llist *, char *);
-extern void lnd_delete(struct llist *, char *);
-extern int lnd_take_casualty(int, struct llist *, int);
+extern void lnd_print(struct ulist *, char *);
+extern void lnd_delete(struct ulist *, char *);
+extern int lnd_take_casualty(int, struct ulist *, int);
 extern void lnd_submil(struct lndstr *, int);
 extern void lnd_takemob(struct emp_qelem *, double);
 extern int lnd_spyval(struct lndstr *);
index c93b3339b5d388a5d2dbd65ef09cc79db2292e4e..d09d8cc93a2047ae77a162a064367a78b0b0946f 100644 (file)
@@ -185,13 +185,6 @@ struct mchrstr {
 
 extern struct mchrstr mchr[SHP_TYPE_MAX + 2];
 
-struct mlist {
-    struct emp_qelem queue;    /* list of ships */
-    struct mchrstr *mcp;       /* pointer to desc of ship */
-    struct shpstr ship;                /* struct ship */
-    double mobil;              /* how much mobility the ship has left */
-};
-
 #define SHP_DEF(b, t) (t ? (b * (logx(t, 40.0) < 1.0 ? 1.0 : \
                                 logx(t, 40.0))) : b)
 #define SHP_SPD(b, t) (t ? (b * (logx(t, 35.0) < 1.0 ? 1.0 : \
diff --git a/include/unit.h b/include/unit.h
new file mode 100644 (file)
index 0000000..cca6cd6
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  Empire - A multi-player, client/server Internet based war game.
+ *  Copyright (C) 1986-2006, 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.
+ *
+ *  ---
+ *
+ *  unit.h: Generalize unit data structures and functions.
+ * 
+ *  Known contributors to this file:
+ *     Ron Koenderink, 2006
+ *     Markus Armbruster, 2006
+ */
+struct ulist {
+    struct emp_qelem queue;    /* list of units */
+    double mobil;              /* how much mobility the unit has left */
+    struct empobj_chr *chrp;   /* pointer to characteristics unit */
+    union empobj_storage unit; /* unit */
+    coord x, y;                        /* x,y it came from LAND only */
+    int eff;                   /* LAND only */
+    int supplied;              /* LAND only */
+};
+
+
index 40c82c77ed048c96ba55462b6f6d7083d2424c29..16e27e5ffb6846f161eeb200b9f2228fc49d86b4 100644 (file)
 
 #include "combat.h"
 #include "commands.h"
-#include "land.h"
 #include "mission.h"
 #include "path.h"
-#include "ship.h"
+#include "empobj.h"
+#include "unit.h"
 
 int
 assa(void)
@@ -59,7 +59,7 @@ assa(void)
     int n;
     int ourtotal;
     struct emp_qelem *qp, *next;
-    struct llist *llp;
+    struct ulist *llp;
     int rel;
 
     att_combat_init(off, EF_SHIP);
@@ -149,8 +149,8 @@ assa(void)
     }
     for (qp = olist.q_forw; qp != &olist; qp = next) {
        next = qp->q_forw;
-       llp = (struct llist *)qp;
-       if (lchr[(int)llp->land.lnd_type].l_flags & L_SPY)
+       llp = (struct ulist *)qp;
+       if (lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY)
            continue;
        ourtotal++;
     }
@@ -163,34 +163,34 @@ assa(void)
 
        for (qp = olist.q_forw; qp != &olist; qp = next) {
            next = qp->q_forw;
-           llp = (struct llist *)qp;
+           llp = (struct ulist *)qp;
            rel = getrel(getnatp(def->own), player->cnum);
            if (chance(0.10) || rel == ALLIED || !def->own) {
-               pr("%s made it on shore safely.\n", prland(&llp->land));
-               llp->land.lnd_x = def->x;
-               llp->land.lnd_y = def->y;
-               llp->land.lnd_ship = -1;
-               putland(llp->land.lnd_uid, &llp->land);
+               pr("%s made it on shore safely.\n", prland(&llp->unit.land));
+               llp->unit.land.lnd_x = def->x;
+               llp->unit.land.lnd_y = def->y;
+               llp->unit.land.lnd_ship = -1;
+               putland(llp->unit.land.lnd_uid, &llp->unit.land);
            } else {
-               pr("%s was spotted", prland(&llp->land));
+               pr("%s was spotted", prland(&llp->unit.land));
                if (rel == HOSTILE || rel == AT_WAR || rel == SITZKRIEG ||
                    rel == MOBILIZATION) {
                    wu(0, def->own, "%s spy shot and killed in %s.\n",
                       cname(player->cnum), xyas(def->x, def->y,
                                                 def->own));
                    pr(" and was killed in the attempt.\n");
-                   llp->land.lnd_effic = 0;
-                   putland(llp->land.lnd_uid, &llp->land);
+                   llp->unit.land.lnd_effic = 0;
+                   putland(llp->unit.land.lnd_uid, &llp->unit.land);
                    lnd_delete(llp, "");
                } else {
                    wu(0, def->own, "%s spy spotted in %s.\n",
                       cname(player->cnum), xyas(def->x, def->y,
                                                 def->own));
                    pr(" but made it ok.\n");
-                   llp->land.lnd_x = def->x;
-                   llp->land.lnd_y = def->y;
-                   llp->land.lnd_ship = -1;
-                   putland(llp->land.lnd_uid, &llp->land);
+                   llp->unit.land.lnd_x = def->x;
+                   llp->unit.land.lnd_y = def->y;
+                   llp->unit.land.lnd_ship = -1;
+                   putland(llp->unit.land.lnd_uid, &llp->unit.land);
                }
            }
        }
index 3f1c2e602eea07333ae47ec1e41da566d54a2b21..74f61729d5e7d88263bb6734cf8a7795437e344a 100644 (file)
 #include <ctype.h>
 #include "commands.h"
 #include "file.h"
-#include "land.h"
 #include "map.h"
 #include "path.h"
+#include "empobj.h"
+#include "unit.h"
 
 static int set_leader(struct emp_qelem *list, struct lndstr **leaderp);
 static void switch_leader(struct emp_qelem *list, int land_uid);
@@ -187,16 +188,16 @@ march(void)
 static int
 set_leader(struct emp_qelem *list, struct lndstr **leaderp)
 {
-    struct llist *llp = (struct llist *)(list->q_back);
+    struct ulist *llp = (struct ulist *)(list->q_back);
 
     if (!*leaderp)
        pr("Leader is ");
-    else if ((*leaderp)->lnd_uid != llp->land.lnd_uid)
+    else if ((*leaderp)->lnd_uid != llp->unit.land.lnd_uid)
        pr("Changing leader to ");
     else
        return 0;
-    *leaderp = &llp->land;
-    pr("%s\n", prland(&llp->land));
+    *leaderp = &llp->unit.land;
+    pr("%s\n", prland(&llp->unit.land));
     return 1;
 }
 
@@ -204,7 +205,7 @@ static void
 switch_leader(struct emp_qelem *list, int land_uid)
 {
     struct emp_qelem *qp, *save;
-    struct llist *llp;
+    struct ulist *llp;
 
     if (QEMPTY(list))
        return;
@@ -214,8 +215,8 @@ switch_leader(struct emp_qelem *list, int land_uid)
         emp_remque(qp);
         emp_insque(qp, list);
         qp = list->q_back;
-        llp = (struct llist *)qp;
-        if (llp->land.lnd_uid == land_uid || land_uid == -1)
+        llp = (struct ulist *)qp;
+        if (llp->unit.land.lnd_uid == land_uid || land_uid == -1)
             break;
     } while (list->q_back != save);
 }
index c76c3810f280f5b25888213695129cf0619290f5..ba576b9c19b94b38a61c9128f9d1f46ea06125e9 100644 (file)
@@ -38,7 +38,8 @@
 #include "map.h"
 #include "optlist.h"
 #include "path.h"
-#include "ship.h"
+#include "empobj.h"
+#include "unit.h"
 
 static int set_flagship(struct emp_qelem *list, struct shpstr **flagshipp);
 static void switch_flagship(struct emp_qelem *list, int ship_uid);
@@ -288,16 +289,16 @@ nav_map(int x, int y, int show_designations)
 static int
 set_flagship(struct emp_qelem *list, struct shpstr **flagshipp)
 {
-    struct mlist *mlp = (struct mlist *)(list->q_back);
+    struct ulist *mlp = (struct ulist *)(list->q_back);
 
     if (!*flagshipp)
        pr("Flagship is ");
-    else if ((*flagshipp)->shp_uid != mlp->ship.shp_uid)
+    else if ((*flagshipp)->shp_uid != mlp->unit.ship.shp_uid)
        pr("Changing flagship to ");
     else
        return 0;
-    *flagshipp = &mlp->ship;
-    pr("%s\n", prship(&mlp->ship));
+    *flagshipp = &mlp->unit.ship;
+    pr("%s\n", prship(&mlp->unit.ship));
     return 1;
 }
 
@@ -305,7 +306,7 @@ static void
 switch_flagship(struct emp_qelem *list, int ship_uid)
 {
     struct emp_qelem *qp, *save;
-    struct mlist *mlp;
+    struct ulist *mlp;
 
     if (QEMPTY(list))
        return;
@@ -315,8 +316,8 @@ switch_flagship(struct emp_qelem *list, int ship_uid)
         emp_remque(qp);
         emp_insque(qp, list);
         qp = list->q_back;
-        mlp = (struct mlist *)qp;
-        if (mlp->ship.shp_uid == ship_uid || ship_uid == -1)
+        mlp = (struct ulist *)qp;
+        if (mlp->unit.ship.shp_uid == ship_uid || ship_uid == -1)
             break;
     } while (list->q_back != save);
 }
index ed6f0b592558cd139d2f411bbc1123497ca05547..d8c229f0450e8d168f90f22d6a14733c2a027496 100644 (file)
 #include <math.h>
 #include "combat.h"
 #include "file.h"
-#include "item.h"
-#include "land.h"
-#include "lost.h"
 #include "map.h"
 #include "misc.h"
 #include "mission.h"
-#include "nat.h"
-#include "news.h"
 #include "nsc.h"
 #include "optlist.h"
 #include "path.h"
 #include "plague.h"
 #include "player.h"
 #include "prototypes.h"
-#include "sect.h"
-#include "ship.h"
-#include "treaty.h"
 #include "xy.h"
+#include "empobj.h"
+#include "unit.h"
 
 #define CASUALTY_LUMP  1       /* How big casualty chunks should be */
 
 static void ask_olist(int combat_mode, struct combat *off,
                      struct combat *def, struct emp_qelem *olist,
                      char *land_answer, int *a_spyp, int *a_engineerp);
-static void take_move_in_mob(int combat_mode, struct llist *llp,
+static void take_move_in_mob(int combat_mode, struct ulist *llp,
                             struct combat *off, struct combat *def);
 static void move_in_land(int combat_mode, struct combat *off,
                         struct emp_qelem *olist, struct combat *def);
@@ -90,7 +84,7 @@ static int take_def(int combat_mode, struct emp_qelem *list,
                    struct combat *off, struct combat *def);
 
 static int get_land(int combat_mode, struct combat *def, int uid,
-                   struct llist *llp, int victim_land);
+                   struct ulist *llp, int victim_land);
 
 char *att_mode[] = {
     /* must match combat types in combat.h */
@@ -984,7 +978,7 @@ ask_olist(int combat_mode, struct combat *off, struct combat *def,
     struct nstr_item ni;
     struct lndstr land;
     double mobcost;
-    struct llist *llp;
+    struct ulist *llp;
     struct lchrstr *lcp;
     double att_val;
     int count = 0;
@@ -1110,19 +1104,19 @@ ask_olist(int combat_mode, struct combat *off, struct combat *def,
                land_answer[(int)land.lnd_army] != 'Y')
                continue;
        }
-       if (!(llp = malloc(sizeof(struct llist)))) {
+       if (!(llp = malloc(sizeof(struct ulist)))) {
            logerror("Malloc failed in attack!\n");
            abort_attack();
            return;
        }
-       memset(llp, 0, sizeof(struct llist));
+       memset(llp, 0, sizeof(struct ulist));
        emp_insque(&llp->queue, olist);
        llp->mobil = mobcost;
        if (!get_land(combat_mode, def, land.lnd_uid, llp, 0))
            continue;
        if (lnd_spyval(&land) > *a_spyp)
            *a_spyp = lnd_spyval(&land);
-       if (llp->lcp->l_flags & L_ENGINEER)
+       if (((struct lchrstr *)llp->chrp)->l_flags & L_ENGINEER)
            ++*a_engineerp;
        if (def->type == EF_SHIP && ++count >= maxland)
            break;
@@ -1179,7 +1173,7 @@ att_get_defense(struct emp_qelem *olist, struct combat *def,
 {
     int d_spy = 0;
     struct emp_qelem *qp;
-    struct llist *llp;
+    struct ulist *llp;
     int dtotal;
     int old_dtotal;
 
@@ -1195,8 +1189,8 @@ att_get_defense(struct emp_qelem *olist, struct combat *def,
        att_reacting_units(def, dlist, a_spy, &d_spy, ototal);
 
     for (qp = olist->q_forw; qp != olist; qp = qp->q_forw) {
-       llp = (struct llist *)qp;
-       intelligence_report(def->own, &llp->land, d_spy,
+       llp = (struct ulist *)qp;
+       intelligence_report(def->own, &llp->unit.land, d_spy,
                            "Scouts report attacking unit:");
     }
 
@@ -1215,7 +1209,7 @@ get_dlist(struct combat *def, struct emp_qelem *list, int a_spy,
          int *d_spyp)
 {
     struct nstr_item ni;
-    struct llist *llp;
+    struct ulist *llp;
     struct lndstr land;
 
 /* In here is where you need to take out spies and trains from the defending
@@ -1240,12 +1234,12 @@ get_dlist(struct combat *def, struct emp_qelem *list, int a_spy,
                                "Scouts report defending unit:");
            continue;
        }
-       if (!(llp = malloc(sizeof(struct llist)))) {
+       if (!(llp = malloc(sizeof(struct ulist)))) {
            logerror("Malloc failed in attack!\n");
            abort_attack();
            return;
        }
-       memset(llp, 0, sizeof(struct llist));
+       memset(llp, 0, sizeof(struct ulist));
        emp_insque(&llp->queue, list);
        llp->supplied = has_supply(&land);
        if (!get_land(A_DEFEND, def, land.lnd_uid, llp, 1))
@@ -1263,7 +1257,7 @@ get_ototal(int combat_mode, struct combat *off, struct emp_qelem *olist,
 {
     double ototal = 0.0;
     struct emp_qelem *qp, *next;
-    struct llist *llp;
+    struct ulist *llp;
     int n, w;
 
     /*
@@ -1284,26 +1278,26 @@ get_ototal(int combat_mode, struct combat *off, struct emp_qelem *olist,
 
     for (qp = olist->q_forw; qp != olist; qp = next) {
        next = qp->q_forw;
-       llp = (struct llist *)qp;
-       if (check && !get_land(combat_mode, 0, llp->land.lnd_uid, llp, 0))
+       llp = (struct ulist *)qp;
+       if (check && !get_land(combat_mode, 0, llp->unit.land.lnd_uid, llp, 0))
            continue;
        if (combat_mode == A_ATTACK) {
            w = -1;
            for (n = 0; n <= off->last; ++n) {
                if (off[n].type == EF_BAD)
                    continue;
-               if ((off[n].x == llp->land.lnd_x) &&
-                   (off[n].y == llp->land.lnd_y))
+               if ((off[n].x == llp->unit.land.lnd_x) &&
+                   (off[n].y == llp->unit.land.lnd_y))
                    w = n;
            }
            if (w < 0) {
                lnd_delete(llp, "is in a sector not owned by you");
                continue;
            }
-           ototal += attack_val(combat_mode, &llp->land) *
+           ototal += attack_val(combat_mode, &llp->unit.land) *
                att_combat_eff(off + w);
        } else {
-           ototal += attack_val(combat_mode, &llp->land);
+           ototal += attack_val(combat_mode, &llp->unit.land);
        }
     }
     ototal *= osupport;
@@ -1319,7 +1313,7 @@ get_dtotal(struct combat *def, struct emp_qelem *list, double dsupport,
 {
     double dtotal = 0.0, eff = 1.0, d_unit;
     struct emp_qelem *qp, *next;
-    struct llist *llp;
+    struct ulist *llp;
 
     if (check && att_get_combat(def, 1) < 0)
        return 0;
@@ -1333,10 +1327,10 @@ get_dtotal(struct combat *def, struct emp_qelem *list, double dsupport,
 
     for (qp = list->q_forw; qp != list; qp = next) {
        next = qp->q_forw;
-       llp = (struct llist *)qp;
-       if (check && !get_land(A_DEFEND, def, llp->land.lnd_uid, llp, 1))
+       llp = (struct ulist *)qp;
+       if (check && !get_land(A_DEFEND, def, llp->unit.land.lnd_uid, llp, 1))
            continue;
-       d_unit = defense_val(&llp->land);
+       d_unit = defense_val(&llp->unit.land);
        if (!llp->supplied)
            d_unit /= 2.0;
        dtotal += d_unit * eff;
@@ -1353,18 +1347,18 @@ get_dtotal(struct combat *def, struct emp_qelem *list, double dsupport,
  */
 
 static int
-get_land(int combat_mode, struct combat *def, int uid, struct llist *llp,
+get_land(int combat_mode, struct combat *def, int uid, struct ulist *llp,
         int victim_land)
 {
-    struct lndstr *lp = &llp->land;
+    struct lndstr *lp = &llp->unit.land;
     char buf[512];
 
     getland(uid, lp);
 
-    if (!llp->lcp) {           /* first time */
-       llp->x = llp->land.lnd_x;
-       llp->y = llp->land.lnd_y;
-       llp->lcp = &lchr[(int)llp->land.lnd_type];
+    if (!llp->chrp) {          /* first time */
+       llp->x = llp->unit.land.lnd_x;
+       llp->y = llp->unit.land.lnd_y;
+       llp->chrp = (struct empobj_chr *)&lchr[(int)llp->unit.land.lnd_type];
     } else {                   /* not first time */
        if (lp->lnd_effic < LAND_MINEFF) {
            sprintf(buf, "was destroyed and is no longer a part of the %s",
@@ -1400,7 +1394,7 @@ get_land(int combat_mode, struct combat *def, int uid, struct llist *llp,
            }
        }
     }
-    llp->eff = llp->land.lnd_effic;
+    llp->eff = llp->unit.land.lnd_effic;
 
     return 1;
 }
@@ -1416,13 +1410,13 @@ static void
 kill_land(struct emp_qelem *list)
 {
     struct emp_qelem *qp, *next;
-    struct llist *llp;
+    struct ulist *llp;
 
     for (qp = list->q_forw; qp != list; qp = next) {
        next = qp->q_forw;
-       llp = (struct llist *)qp;
-       if (llp->land.lnd_ship >= 0) {
-           llp->land.lnd_effic = 0;
+       llp = (struct ulist *)qp;
+       if (llp->unit.land.lnd_ship >= 0) {
+           llp->unit.land.lnd_effic = 0;
            lnd_delete(llp, "cannot return to the ship, and dies!");
        }
     }
@@ -1432,15 +1426,15 @@ static void
 att_infect_units(struct emp_qelem *list, int plague)
 {
     struct emp_qelem *qp, *next;
-    struct llist *llp;
+    struct ulist *llp;
 
     if (!plague)
        return;
     for (qp = list->q_forw; qp != list; qp = next) {
        next = qp->q_forw;
-       llp = (struct llist *)qp;
-       if (llp->land.lnd_pstage == PLG_HEALTHY)
-           llp->land.lnd_pstage = PLG_EXPOSED;
+       llp = (struct ulist *)qp;
+       if (llp->unit.land.lnd_pstage == PLG_HEALTHY)
+           llp->unit.land.lnd_pstage = PLG_EXPOSED;
     }
 }
 
@@ -1448,21 +1442,21 @@ static void
 put_land(struct emp_qelem *list)
 {
     struct emp_qelem *qp, *next;
-    struct llist *llp;
+    struct ulist *llp;
 
     for (qp = list->q_forw; qp != list; qp = next) {
        next = qp->q_forw;
-       llp = (struct llist *)qp;
-       llp->land.lnd_mission = 0;
-       llp->land.lnd_harden = 0;
-       llp->land.lnd_mobil -= (int)llp->mobil;
+       llp = (struct ulist *)qp;
+       llp->unit.land.lnd_mission = 0;
+       llp->unit.land.lnd_harden = 0;
+       llp->unit.land.lnd_mobil -= (int)llp->mobil;
        llp->mobil = 0.0;
-       putland(llp->land.lnd_uid, &llp->land);
-       if (llp->land.lnd_own != player->cnum) {
+       putland(llp->unit.land.lnd_uid, &llp->unit.land);
+       if (llp->unit.land.lnd_own != player->cnum) {
            emp_remque((struct emp_qelem *)llp);
            free(llp);
        } else
-           get_land(A_ATTACK, 0, llp->land.lnd_uid, llp, 0);
+           get_land(A_ATTACK, 0, llp->unit.land.lnd_uid, llp, 0);
     }
 }
 
@@ -1478,7 +1472,7 @@ att_reacting_units(struct combat *def, struct emp_qelem *list, int a_spy,
     struct nstr_item ni;
     struct lndstr land;
     struct sctstr sect, dsect;
-    struct llist *llp;
+    struct ulist *llp;
     int dtotal;
     double new_land = 0;
     double mobcost;
@@ -1555,14 +1549,14 @@ att_reacting_units(struct combat *def, struct emp_qelem *list, int a_spy,
        wu(0, land.lnd_own, "%s reacts to %s.\n",
           prland(&land), xyas(land.lnd_x, land.lnd_y, land.lnd_own));
 
-       llp = malloc(sizeof(struct llist));
+       llp = malloc(sizeof(struct ulist));
 
-       memset(llp, 0, sizeof(struct llist));
+       memset(llp, 0, sizeof(struct ulist));
        llp->supplied = 1;
        llp->x = origx;
        llp->y = origy;
-       llp->lcp = &lchr[(int)land.lnd_type];
-       llp->land = land;
+       llp->chrp = (struct empobj_chr *)&lchr[(int)land.lnd_type];
+       llp->unit.land = land;
        emp_insque(&llp->queue, list);
        if (lnd_spyval(&land) > *d_spyp)
            *d_spyp = lnd_spyval(&land);
@@ -1766,13 +1760,13 @@ count_bodies(struct combat *off, struct emp_qelem *list)
     int n;
     int bodies = 0;
     struct emp_qelem *qp;
-    struct llist *llp;
+    struct ulist *llp;
 
     for (n = 0; n <= off->last; ++n)
        bodies += off[n].troops;
     for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
-       llp = (struct llist *)qp;
-       bodies += llp->land.lnd_item[I_MILIT];
+       llp = (struct ulist *)qp;
+       bodies += llp->unit.land.lnd_item[I_MILIT];
     }
     return bodies;
 }
@@ -2084,7 +2078,7 @@ take_casualty(int combat_mode, struct combat *off, struct emp_qelem *olist)
     int biggest_troops = 0, index = -1;
     int n, tot_troops = 0, biggest_mil, cas;
     struct emp_qelem *qp, *biggest;
-    struct llist *llp;
+    struct ulist *llp;
 
     for (n = 0; n <= off->last; ++n) {
        if (off[n].type != EF_BAD) {
@@ -2141,17 +2135,17 @@ take_casualty(int combat_mode, struct combat *off, struct emp_qelem *olist)
     biggest = NULL;
     biggest_mil = -1;
     for (qp = olist->q_forw; qp != olist; qp = qp->q_forw) {
-       llp = (struct llist *)qp;
+       llp = (struct ulist *)qp;
 
-       if (llp->land.lnd_item[I_MILIT] > biggest_mil) {
-           biggest_mil = llp->land.lnd_item[I_MILIT];
+       if (llp->unit.land.lnd_item[I_MILIT] > biggest_mil) {
+           biggest_mil = llp->unit.land.lnd_item[I_MILIT];
            biggest = qp;
        }
     }
     if (biggest == NULL)
        return CASUALTY_LUMP - to_take;
 
-    llp = (struct llist *)biggest;
+    llp = (struct ulist *)biggest;
     cas = lnd_take_casualty(combat_mode, llp, to_take);
     return CASUALTY_LUMP - (to_take - cas);
 }
@@ -2162,17 +2156,18 @@ static void
 send_reacting_units_home(struct emp_qelem *list)
 {
     struct emp_qelem *qp, *next;
-    struct llist *llp;
+    struct ulist *llp;
     char buf[1024];
 
     for (qp = list->q_forw; qp != list; qp = next) {
        next = qp->q_forw;
-       llp = (struct llist *)qp;
-       if ((llp->land.lnd_x != llp->x) || (llp->land.lnd_y != llp->y)) {
+       llp = (struct ulist *)qp;
+       if ((llp->unit.land.lnd_x != llp->x) ||
+           (llp->unit.land.lnd_y != llp->y)) {
            sprintf(buf, "returns to %s",
-                   xyas(llp->x, llp->y, llp->land.lnd_own));
-           llp->land.lnd_x = llp->x;
-           llp->land.lnd_y = llp->y;
+                   xyas(llp->x, llp->y, llp->unit.land.lnd_own));
+           llp->unit.land.lnd_x = llp->x;
+           llp->unit.land.lnd_y = llp->y;
            lnd_delete(llp, buf);
        }
     }
@@ -2207,7 +2202,7 @@ take_def(int combat_mode, struct emp_qelem *list, struct combat *off,
 {
     int n;
     int occuppied = 0;
-    struct llist *llp, *delete_me = 0;
+    struct ulist *llp, *delete_me = 0;
     char buf[1024];
     struct sctstr sect;
     struct shpstr ship;
@@ -2239,16 +2234,16 @@ take_def(int combat_mode, struct emp_qelem *list, struct combat *off,
                   pr_com(2, def, def->own));
            return 0;
        } else {
-           llp = (struct llist *)list->q_forw;
-           llp->land.lnd_x = def->x;
-           llp->land.lnd_y = def->y;
+           llp = (struct ulist *)list->q_forw;
+           llp->unit.land.lnd_x = def->x;
+           llp->unit.land.lnd_y = def->y;
            take_move_in_mob(combat_mode, llp, off, def);
            if (def->type == EF_SHIP) {
-               llp->land.lnd_ship = def->shp_uid;
+               llp->unit.land.lnd_ship = def->shp_uid;
                sprintf(buf, "boards %s", prcom(0, def));
                delete_me = llp;
            } else {
-               llp->land.lnd_ship = -1;
+               llp->unit.land.lnd_ship = -1;
                sprintf(buf, "moves in to occupy %s",
                        xyas(def->x, def->y, player->cnum));
                lnd_delete(llp, buf);
@@ -2289,7 +2284,7 @@ ask_move_in(struct combat *off, struct emp_qelem *olist,
 {
     int n;
     struct emp_qelem *qp, *next;
-    struct llist *llp;
+    struct ulist *llp;
     char buf[512];
     char prompt[512];
     char land_answer[256];
@@ -2308,29 +2303,30 @@ ask_move_in(struct combat *off, struct emp_qelem *olist,
     memset(land_answer, 0, sizeof(land_answer));
     for (qp = olist->q_forw; qp != olist; qp = next) {
        next = qp->q_forw;
-       llp = (struct llist *)qp;
-       answerp = &land_answer[(int)llp->land.lnd_army];
+       llp = (struct ulist *)qp;
+       answerp = &land_answer[(int)llp->unit.land.lnd_army];
        if (player->aborted || att_get_combat(def, 0) < 0)
            *answerp = 'N';
        if (*answerp == 'Y')
            continue;
        if (*answerp != 'N') {
-           if (!get_land(A_ATTACK, def, llp->land.lnd_uid, llp, 0))
+           if (!get_land(A_ATTACK, def, llp->unit.land.lnd_uid, llp, 0))
                continue;
            sprintf(prompt, "Move in with %s (%c %d%%) [ynYNq?] ",
-                   prland(&llp->land),
-                   llp->land.lnd_army ? llp->land.lnd_army :  '~',
-                   llp->land.lnd_effic);
-           *answerp = att_prompt(prompt, llp->land.lnd_army);
+                   prland(&llp->unit.land),
+                   llp->unit.land.lnd_army ? llp->unit.land.lnd_army :  '~',
+                   llp->unit.land.lnd_effic);
+           *answerp = att_prompt(prompt, llp->unit.land.lnd_army);
            if (player->aborted || att_get_combat(def, 0) < 0)
                *answerp = 'N';
-           if (!get_land(A_ATTACK, def, llp->land.lnd_uid, llp, 0))
+           if (!get_land(A_ATTACK, def, llp->unit.land.lnd_uid, llp, 0))
                continue;
        }
        if (*answerp == 'y' || *answerp == 'Y')
            continue;
        sprintf(buf, "stays in %s",
-               xyas(llp->land.lnd_x, llp->land.lnd_y, player->cnum));
+               xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y,
+                    player->cnum));
        lnd_delete(llp, buf);
     }
     if (QEMPTY(olist))
@@ -2338,11 +2334,12 @@ ask_move_in(struct combat *off, struct emp_qelem *olist,
     if (att_get_combat(def, 0) < 0) {
        for (qp = olist->q_forw; qp != olist; qp = next) {
            next = qp->q_forw;
-           llp = (struct llist *)qp;
-           if (!get_land(A_ATTACK, def, llp->land.lnd_uid, llp, 0))
+           llp = (struct ulist *)qp;
+           if (!get_land(A_ATTACK, def, llp->unit.land.lnd_uid, llp, 0))
                continue;
            sprintf(buf, "stays in %s",
-                   xyas(llp->land.lnd_x, llp->land.lnd_y, player->cnum));
+                   xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y,
+                        player->cnum));
            lnd_delete(llp, buf);
        }
        return;
@@ -2359,23 +2356,23 @@ move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist,
             struct combat *def)
 {
     struct emp_qelem *qp, *next;
-    struct llist *llp;
+    struct ulist *llp;
     char buf[512];
 
     if (QEMPTY(olist))
        return;
     for (qp = olist->q_forw; qp != olist; qp = next) {
        next = qp->q_forw;
-       llp = (struct llist *)qp;
-       if (!get_land(combat_mode, def, llp->land.lnd_uid, llp, 0))
+       llp = (struct ulist *)qp;
+       if (!get_land(combat_mode, def, llp->unit.land.lnd_uid, llp, 0))
            continue;
        take_move_in_mob(combat_mode, llp, off, def);
-       llp->land.lnd_x = def->x;
-       llp->land.lnd_y = def->y;
+       llp->unit.land.lnd_x = def->x;
+       llp->unit.land.lnd_y = def->y;
        if (def->type == EF_SHIP)
-           llp->land.lnd_ship = def->shp_uid;
+           llp->unit.land.lnd_ship = def->shp_uid;
        else
-           llp->land.lnd_ship = -1;
+           llp->unit.land.lnd_ship = -1;
     }
     if (QEMPTY(olist))
        return;
@@ -2392,7 +2389,7 @@ move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist,
        return;
     for (qp = olist->q_forw; qp != olist; qp = next) {
        next = qp->q_forw;
-       llp = (struct llist *)qp;
+       llp = (struct ulist *)qp;
        lnd_print(llp, buf);
     }
     if (QEMPTY(olist))
@@ -2523,7 +2520,7 @@ ask_move_in_off(struct combat *off, struct combat *def)
 /* Charge land units for moving into a sector or onto a ship */
 
 static void
-take_move_in_mob(int combat_mode, struct llist *llp, struct combat *off,
+take_move_in_mob(int combat_mode, struct ulist *llp, struct combat *off,
                 struct combat *def)
 {
     int mobcost;
@@ -2531,37 +2528,39 @@ take_move_in_mob(int combat_mode, struct llist *llp, struct combat *off,
 
     switch (combat_mode) {
     case A_ATTACK:
-       mobcost = lnd_pathcost(&llp->land,
+       mobcost = lnd_pathcost(&llp->unit.land,
                               att_mobcost(off->own, def,
-                                          lnd_mobtype(&llp->land)));
-       new = llp->land.lnd_mobil - mobcost;
+                                          lnd_mobtype(&llp->unit.land)));
+       new = llp->unit.land.lnd_mobil - mobcost;
        if (new < -127)
            new = -127;
-       llp->land.lnd_mobil = new;
+       llp->unit.land.lnd_mobil = new;
        break;
     case A_ASSAULT:
        if (off->shp_mcp->m_flags & M_LAND) {
-           if (llp->lcp->l_flags & L_MARINE)
-               llp->land.lnd_mobil -=
+           if (((struct lchrstr *)llp->chrp)->l_flags & L_MARINE)
+               llp->unit.land.lnd_mobil -=
                    (float)etu_per_update * land_mob_scale * 0.5;
            else
-               llp->land.lnd_mobil -= (float)etu_per_update * land_mob_scale;
+               llp->unit.land.lnd_mobil -= (float)etu_per_update *
+                   land_mob_scale;
        } else {
-           if (llp->lcp->l_flags & L_MARINE)
-               llp->land.lnd_mobil = 0;
+           if (((struct lchrstr *)llp->chrp)->l_flags & L_MARINE)
+               llp->unit.land.lnd_mobil = 0;
            else
-               llp->land.lnd_mobil = -(float)etu_per_update * land_mob_scale;
+               llp->unit.land.lnd_mobil = -(float)etu_per_update *
+                   land_mob_scale;
        }
        break;
     case A_BOARD:
        /* I arbitrarily chose the numbers 10 and 40 below -KHS */
-       if (llp->lcp->l_flags & L_MARINE)
-           llp->land.lnd_mobil -= 10;
+       if (((struct lchrstr *)llp->chrp)->l_flags & L_MARINE)
+           llp->unit.land.lnd_mobil -= 10;
        else
-           llp->land.lnd_mobil -= 40;
+           llp->unit.land.lnd_mobil -= 40;
        break;
     }
-    llp->land.lnd_harden = 0;
+    llp->unit.land.lnd_harden = 0;
 }
 
 static void
index 352485648cc990294fd9834a1d8f0b7b882a9ae1..02d62c80aea3b6d8af036b4311ea84c21330a644 100644 (file)
 #include "combat.h"
 #include "damage.h"
 #include "file.h"
-#include "land.h"
 #include "misc.h"
 #include "mission.h"
-#include "nat.h"
-#include "news.h"
 #include "nsc.h"
 #include "optlist.h"
 #include "path.h"
-#include "plane.h"
 #include "player.h"
 #include "prototypes.h"
-#include "sect.h"
-#include "ship.h"
 #include "xy.h"
+#include "empobj.h"
+#include "unit.h"
 
-static void lnd_mess(char *, struct llist *);
+static void lnd_mess(char *, struct ulist *);
 static int lnd_hit_mine(struct lndstr *, struct lchrstr *);
 
 double
@@ -128,26 +124,26 @@ defense_val(struct lndstr *lp)
 }
 
 void
-lnd_print(struct llist *llp, char *s)
+lnd_print(struct ulist *llp, char *s)
 {
-    if (llp->land.lnd_own == player->cnum)
-       pr("%s %s\n", prland(&llp->land), s);
+    if (llp->unit.land.lnd_own == player->cnum)
+       pr("%s %s\n", prland(&llp->unit.land), s);
     else
-       wu(0, llp->land.lnd_own, "%s %s\n", prland(&llp->land), s);
+       wu(0, llp->unit.land.lnd_own, "%s %s\n", prland(&llp->unit.land), s);
 }
 
 void
-lnd_delete(struct llist *llp, char *s)
+lnd_delete(struct ulist *llp, char *s)
 {
     if (s)
        lnd_print(llp, s);
-    putland(llp->land.lnd_uid, &llp->land);
+    putland(llp->unit.land.lnd_uid, &llp->unit.land);
     emp_remque((struct emp_qelem *)llp);
     free(llp);
 }
 
 int
-lnd_take_casualty(int combat_mode, struct llist *llp, int cas)
+lnd_take_casualty(int combat_mode, struct ulist *llp, int cas)
                        /* attacking or assaulting or paratrooping? */
                        /* number of casualties to take */
 {
@@ -168,49 +164,51 @@ lnd_take_casualty(int combat_mode, struct llist *llp, int cas)
     signed char orig;
     int mob;
 
-    taken = llp->land.lnd_item[I_MILIT];
+    taken = llp->unit.land.lnd_item[I_MILIT];
     /* Spies always die */
-    if (llp->lcp->l_flags & L_SPY) {
+    if (((struct lchrstr *)llp->chrp)->l_flags & L_SPY) {
        eff_eq = 100;
-       llp->land.lnd_effic = 0;
+       llp->unit.land.lnd_effic = 0;
     } else {
-       eff_eq = ldround(cas * 100.0 / llp->lcp->l_mil, 1);
-       llp->land.lnd_effic -= eff_eq;
-       lnd_submil(&llp->land, cas);
+       eff_eq = ldround(cas * 100.0 /
+           ((struct lchrstr *)llp->chrp)->l_mil, 1);
+       llp->unit.land.lnd_effic -= eff_eq;
+       lnd_submil(&llp->unit.land, cas);
     }
 
-    if (llp->land.lnd_effic < LAND_MINEFF) {
+    if (llp->unit.land.lnd_effic < LAND_MINEFF) {
        sprintf(buf, "dies %s %s!",
                combat_mode ? att_mode[combat_mode] : "defending",
-               xyas(llp->land.lnd_x, llp->land.lnd_y, llp->land.lnd_own));
+               xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y,
+                    llp->unit.land.lnd_own));
        lnd_delete(llp, buf);
        /* Since we killed the unit, we killed all the mil on it */
        return taken;
     } else {
        /* Ok, now, how many did we take off? (sould be the diff) */
-       taken = taken - llp->land.lnd_item[I_MILIT];
+       taken = taken - llp->unit.land.lnd_item[I_MILIT];
     }
 
-    if (llp->land.lnd_effic >= llp->land.lnd_retreat)
+    if (llp->unit.land.lnd_effic >= llp->unit.land.lnd_retreat)
        return taken;
 
     /* we're being boarded */
-    if (llp->land.lnd_ship >= 0 && combat_mode == A_DEFEND)
+    if (llp->unit.land.lnd_ship >= 0 && combat_mode == A_DEFEND)
        return taken;
 
     /* we're being boarded */
-    if (llp->land.lnd_land >= 0 && combat_mode == A_DEFEND)
+    if (llp->unit.land.lnd_land >= 0 && combat_mode == A_DEFEND)
        return taken;
 
     /* Have to make a retreat check */
 
-    ret_chance = llp->land.lnd_retreat - llp->land.lnd_effic;
+    ret_chance = llp->unit.land.lnd_retreat - llp->unit.land.lnd_effic;
     if (roll(100) < ret_chance) {
        pr("\n");
        lnd_print(llp, "fails morale check!");
-       llp->land.lnd_mission = 0;
-       llp->land.lnd_harden = 0;
-       if (llp->land.lnd_ship >= 0 || llp->land.lnd_land >= 0)
+       llp->unit.land.lnd_mission = 0;
+       llp->unit.land.lnd_harden = 0;
+       if (llp->unit.land.lnd_ship >= 0 || llp->unit.land.lnd_land >= 0)
            nowhere_to_go = 1;
        else if (combat_mode == A_DEFEND) {
            /*
@@ -222,14 +220,14 @@ lnd_take_casualty(int combat_mode, struct llist *llp, int cas)
            biggest = -1;
            nowned = 0;
            for (n = 1; n <= 6; ++n) {
-               ret_x = llp->land.lnd_x + diroff[n][0];
-               ret_y = llp->land.lnd_y + diroff[n][1];
+               ret_x = llp->unit.land.lnd_x + diroff[n][0];
+               ret_y = llp->unit.land.lnd_y + diroff[n][1];
                getsect(ret_x, ret_y, &sect);
-               if (sect.sct_own != llp->land.lnd_own)
+               if (sect.sct_own != llp->unit.land.lnd_own)
                    continue;
                if (sect.sct_type == SCT_MOUNT)
                    continue;
-               mobcost = lnd_mobcost(&llp->land, &rsect);
+               mobcost = lnd_mobcost(&llp->unit.land, &rsect);
                if (mobcost < 0)
                    continue;
                ++nowned;
@@ -245,38 +243,38 @@ lnd_take_casualty(int combat_mode, struct llist *llp, int cas)
                nowhere_to_go = 1;
            else {
                /* retreat to bx,by */
-               llp->land.lnd_x = bx;
-               llp->land.lnd_y = by;
+               llp->unit.land.lnd_x = bx;
+               llp->unit.land.lnd_y = by;
                /* FIXME landmines */
                getsect(bx, by, &rsect);
-               mob = llp->land.lnd_mobil - (int)bmcost;
+               mob = llp->unit.land.lnd_mobil - (int)bmcost;
                if (mob < -127)
                    mob = -127;
-               orig = llp->land.lnd_mobil;
-               llp->land.lnd_mobil = (signed char)mob;
-               if (llp->land.lnd_mobil > orig)
-                   llp->land.lnd_mobil = -127;
+               orig = llp->unit.land.lnd_mobil;
+               llp->unit.land.lnd_mobil = (signed char)mob;
+               if (llp->unit.land.lnd_mobil > orig)
+                   llp->unit.land.lnd_mobil = -127;
                sprintf(buf, "retreats at %d%% efficiency to %s!",
-                       llp->land.lnd_effic,
-                       xyas(bx, by, llp->land.lnd_own));
+                       llp->unit.land.lnd_effic,
+                       xyas(bx, by, llp->unit.land.lnd_own));
                lnd_delete(llp, buf);
            }
        } else {                /* attacking from a sector */
            sprintf(buf, "leaves the battlefield at %d%% efficiency",
-                   llp->land.lnd_effic);
-           if ((llp->land.lnd_mobil - (int)llp->mobil) < -127)
-               llp->land.lnd_mobil = -127;
+                   llp->unit.land.lnd_effic);
+           if ((llp->unit.land.lnd_mobil - (int)llp->mobil) < -127)
+               llp->unit.land.lnd_mobil = -127;
            else
-               llp->land.lnd_mobil -= (int)llp->mobil;
+               llp->unit.land.lnd_mobil -= (int)llp->mobil;
            llp->mobil = 0.0;
            lnd_delete(llp, buf);
        }
     }
     if (nowhere_to_go) {
        /* nowhere to go.. take more casualties */
-       llp->land.lnd_effic -= 10;
-       lnd_submil(&llp->land, llp->lcp->l_mil / 10);
-       if (llp->land.lnd_effic < LAND_MINEFF)
+       llp->unit.land.lnd_effic -= 10;
+       lnd_submil(&llp->unit.land, ((struct lchrstr *)llp->chrp)->l_mil / 10);
+       if (llp->unit.land.lnd_effic < LAND_MINEFF)
            lnd_delete(llp, "has nowhere to retreat, and dies!");
        else
            lnd_print(llp,
@@ -290,24 +288,24 @@ void
 lnd_takemob(struct emp_qelem *list, double loss)
 {
     struct emp_qelem *qp, *next;
-    struct llist *llp;
+    struct ulist *llp;
     int new;
     int mcost = ldround(combat_mob * loss, 1);
 
     for (qp = list->q_forw; qp != list; qp = next) {
        next = qp->q_forw;
-       llp = (struct llist *)qp;
+       llp = (struct ulist *)qp;
 /*
                if (chance(loss))
-                       use_supply(&llp->land);
-               if (llp->land.lnd_mission == MI_RESERVE)
-                       new = llp->land.lnd_mobil - mcost/2;
+                       use_supply(&llp->unit.land);
+               if (llp->unit.land.lnd_mission == MI_RESERVE)
+                       new = llp->unit.land.lnd_mobil - mcost/2;
                else
  */
-       new = llp->land.lnd_mobil - mcost;
+       new = llp->unit.land.lnd_mobil - mcost;
        if (new < -127)
            new = -127;
-       llp->land.lnd_mobil = (signed char)new;
+       llp->unit.land.lnd_mobil = (signed char)new;
     }
 }
 
@@ -478,7 +476,7 @@ lnd_sel(struct nstr_item *ni, struct emp_qelem *list)
 {
     struct lndstr land;
     struct lchrstr *lcp;
-    struct llist *llp;
+    struct ulist *llp;
     int this_mot;
     int mobtype = MOB_MOVE;    /* indeterminate */
 
@@ -518,9 +516,9 @@ lnd_sel(struct nstr_item *ni, struct emp_qelem *list)
        land.lnd_harden = 0;
        memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath));
        putland(land.lnd_uid, &land);
-       llp = malloc(sizeof(struct llist));
-       llp->lcp = lcp;
-       llp->land = land;
+       llp = malloc(sizeof(struct ulist));
+       llp->chrp = (struct empobj_chr *)lcp;
+       llp->unit.land = land;
        llp->mobil = land.lnd_mobil;
        emp_insque(&llp->queue, list);
     }
@@ -533,7 +531,7 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp,
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct llist *llp;
+    struct ulist *llp;
     struct sctstr sect;
     struct lndstr land;
     coord allx;
@@ -547,8 +545,8 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp,
     *togetherp = 1;
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       llp = (struct llist *)qp;
-       getland(llp->land.lnd_uid, &land);
+       llp = (struct ulist *)qp;
+       getland(llp->unit.land.lnd_uid, &land);
        if (land.lnd_own != actor) {
            mpr(actor, "%s was disbanded at %s\n",
                prland(&land), xyas(land.lnd_x, land.lnd_y, land.lnd_own));
@@ -568,15 +566,15 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp,
            lnd_mess("was sucked into the sky by a strange looking spaceland", llp);    /* heh -KHS */
            continue;
        }
-       if (!(lchr[(int)llp->land.lnd_type].l_flags & L_SPY) &&
-           !(lchr[(int)llp->land.lnd_type].l_flags & L_TRAIN) &&
-           llp->land.lnd_item[I_MILIT] == 0) {
+       if (!(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) &&
+           !(lchr[(int)llp->unit.land.lnd_type].l_flags & L_TRAIN) &&
+           llp->unit.land.lnd_item[I_MILIT] == 0) {
            lnd_mess("has no mil on it to guide it", llp);
            continue;
        }
        rel = getrel(getnatp(sect.sct_own), player->cnum);
        if (sect.sct_own != land.lnd_own && rel != ALLIED &&
-           !(lchr[(int)llp->land.lnd_type].l_flags & L_SPY) &&
+           !(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) &&
            sect.sct_own) {
            sprintf(mess, "has been kidnapped by %s", cname(sect.sct_own));
            lnd_mess(mess, llp);
@@ -596,7 +594,7 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp,
            *minmobp = llp->mobil;
        if (llp->mobil > *maxmobp)
            *maxmobp = llp->mobil;
-       llp->land = land;
+       llp->unit.land = land;
     }
 }
 
@@ -605,19 +603,20 @@ lnd_put(struct emp_qelem *list, natid actor)
 {
     struct emp_qelem *qp;
     struct emp_qelem *newqp;
-    struct llist *llp;
+    struct ulist *llp;
 
     qp = list->q_back;
     while (qp != list) {
-       llp = (struct llist *)qp;
+       llp = (struct ulist *)qp;
        if (actor) {
-           mpr(actor, "%s stopped at %s\n", prland(&llp->land),
-               xyas(llp->land.lnd_x, llp->land.lnd_y, llp->land.lnd_own));
+           mpr(actor, "%s stopped at %s\n", prland(&llp->unit.land),
+               xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y,
+                    llp->unit.land.lnd_own));
            if (llp->mobil < -127)
                llp->mobil = -127;
-           llp->land.lnd_mobil = llp->mobil;
+           llp->unit.land.lnd_mobil = llp->mobil;
        }
-       putland(llp->land.lnd_uid, &llp->land);
+       putland(llp->unit.land.lnd_uid, &llp->unit.land);
        newqp = qp->q_back;
        emp_remque(qp);
        free(qp);
@@ -631,16 +630,17 @@ lnd_sweep(struct emp_qelem *land_list, int verbose, int takemob,
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct llist *llp;
+    struct ulist *llp;
     struct sctstr sect;
     int mines, m, max, sshells, lshells;
 
     for (qp = land_list->q_back; qp != land_list; qp = next) {
        next = qp->q_back;
-       llp = (struct llist *)qp;
-       if (!(llp->lcp->l_flags & L_ENGINEER)) {
+       llp = (struct ulist *)qp;
+       if (!(((struct lchrstr *)llp->chrp)->l_flags & L_ENGINEER)) {
            if (verbose)
-               mpr(actor, "%s is not an engineer!\n", prland(&llp->land));
+               mpr(actor, "%s is not an engineer!\n",
+                   prland(&llp->unit.land));
            continue;
        }
        if (takemob && llp->mobil < 0.0) {
@@ -648,33 +648,33 @@ lnd_sweep(struct emp_qelem *land_list, int verbose, int takemob,
                lnd_mess("is out of mobility", llp);
            continue;
        }
-       getsect(llp->land.lnd_x, llp->land.lnd_y, &sect);
-       if (sect.sct_oldown == llp->land.lnd_own) {
+       getsect(llp->unit.land.lnd_x, llp->unit.land.lnd_y, &sect);
+       if (sect.sct_oldown == llp->unit.land.lnd_own) {
            if (verbose)
                mpr(actor,
                    "%s is in a sector completely owned by you.  Don't bother digging up mines there!\n",
-                   prland(&llp->land));
+                   prland(&llp->unit.land));
            continue;
        }
        if (sect.sct_type == SCT_BSPAN) {
            if (verbose)
                mpr(actor, "%s is on a bridge.  No mines there!\n",
-                   prland(&llp->land));
+                   prland(&llp->unit.land));
            continue;
        }
        if (takemob) {
-           llp->mobil -= lnd_pathcost(&llp->land, 0.2);
-           llp->land.lnd_mobil = (int)llp->mobil;
-           llp->land.lnd_harden = 0;
+           llp->mobil -= lnd_pathcost(&llp->unit.land, 0.2);
+           llp->unit.land.lnd_mobil = (int)llp->mobil;
+           llp->unit.land.lnd_harden = 0;
        }
-       putland(llp->land.lnd_uid, &llp->land);
+       putland(llp->unit.land.lnd_uid, &llp->unit.land);
        if (!(mines = sect.sct_mines))
            continue;
-       max = llp->lcp->l_item[I_SHELL];
-       lshells = llp->land.lnd_item[I_SHELL];
+       max = ((struct lchrstr *)llp->chrp)->l_item[I_SHELL];
+       lshells = llp->unit.land.lnd_item[I_SHELL];
        sshells = sect.sct_item[I_SHELL];
        for (m = 0; mines > 0 && m < max * 2; m++) {
-           if (chance(0.5 * llp->lcp->l_att)) {
+           if (chance(0.5 * ((struct lchrstr *)llp->chrp)->l_att)) {
                mpr(actor, "Sweep...\n");
                mines--;
                if (lshells < max)
@@ -684,9 +684,9 @@ lnd_sweep(struct emp_qelem *land_list, int verbose, int takemob,
            }
        }
        sect.sct_mines = mines;
-       llp->land.lnd_item[I_SHELL] = lshells;
+       llp->unit.land.lnd_item[I_SHELL] = lshells;
        sect.sct_item[I_SHELL] = sshells;
-       putland(llp->land.lnd_uid, &llp->land);
+       putland(llp->unit.land.lnd_uid, &llp->unit.land);
        putsect(&sect);
     }
 }
@@ -696,12 +696,12 @@ contains_engineer(struct emp_qelem *list)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct llist *llp;
+    struct ulist *llp;
 
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       llp = (struct llist *)qp;
-       if (llp->lcp->l_flags & L_ENGINEER)
+       llp = (struct ulist *)qp;
+       if (((struct lchrstr *)llp->chrp)->l_flags & L_ENGINEER)
            return 1;
     }
     return 0;
@@ -712,27 +712,27 @@ lnd_check_mines(struct emp_qelem *land_list)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct llist *llp;
+    struct ulist *llp;
     struct sctstr sect;
     int stopping = 0;
     int with_eng = contains_engineer(land_list);
 
     for (qp = land_list->q_back; qp != land_list; qp = next) {
        next = qp->q_back;
-       llp = (struct llist *)qp;
-       getsect(llp->land.lnd_x, llp->land.lnd_y, &sect);
-       if (sect.sct_oldown == llp->land.lnd_own)
+       llp = (struct ulist *)qp;
+       getsect(llp->unit.land.lnd_x, llp->unit.land.lnd_y, &sect);
+       if (sect.sct_oldown == llp->unit.land.lnd_own)
            continue;
        if (sect.sct_type == SCT_BSPAN)
            continue;
        if (!sect.sct_mines)
            continue;
        if (chance(DMINE_LHITCHANCE(sect.sct_mines) / (1 + 2 * with_eng))) {
-           lnd_hit_mine(&llp->land, llp->lcp);
+           lnd_hit_mine(&llp->unit.land, ((struct lchrstr *)llp->chrp));
            sect.sct_mines--;
            putsect(&sect);
-           putland(llp->land.lnd_uid, &llp->land);
-           if (!llp->land.lnd_own) {
+           putland(llp->unit.land.lnd_uid, &llp->unit.land);
+           if (!llp->unit.land.lnd_own) {
                stopping = 1;
                emp_remque(qp);
                free(qp);
@@ -747,18 +747,18 @@ lnd_list(struct emp_qelem *land_list)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct llist *llp;
+    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 llist *)qp;
-       lnd = &llp->land;
+       llp = (struct ulist *)qp;
+       lnd = &llp->unit.land;
        pr("%4d ", lnd->lnd_uid);
-       pr("%-16.16s ", llp->lcp->l_name);
-       prxy("%4d,%-4d ", lnd->lnd_x, lnd->lnd_y, llp->land.lnd_own);
+       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]);
@@ -773,15 +773,16 @@ lnd_list(struct emp_qelem *land_list)
 }
 
 static void
-lnd_mess(char *str, struct llist *llp)
+lnd_mess(char *str, struct ulist *llp)
 {
-    mpr(llp->land.lnd_own, "%s %s & stays in %s\n",
-       prland(&llp->land),
-       str, xyas(llp->land.lnd_x, llp->land.lnd_y, llp->land.lnd_own));
+    mpr(llp->unit.land.lnd_own, "%s %s & stays in %s\n",
+       prland(&llp->unit.land),
+       str, xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y,
+                 llp->unit.land.lnd_own));
     if (llp->mobil < -127)
        llp->mobil = -127;
-    llp->land.lnd_mobil = llp->mobil;
-    putland(llp->land.lnd_uid, &llp->land);
+    llp->unit.land.lnd_mobil = llp->mobil;
+    putland(llp->unit.land.lnd_uid, &llp->unit.land);
     emp_remque((struct emp_qelem *)llp);
     free(llp);
 }
@@ -791,12 +792,12 @@ lnd_count(struct emp_qelem *list)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct llist *llp;
+    struct ulist *llp;
     int count = 0;
 
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       llp = (struct llist *)qp;
+       llp = (struct ulist *)qp;
        ++count;
     }
     return count;
@@ -807,7 +808,7 @@ lnd_damage(struct emp_qelem *list, int totdam)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct llist *llp;
+    struct ulist *llp;
     int dam;
     int count;
 
@@ -816,12 +817,12 @@ lnd_damage(struct emp_qelem *list, int totdam)
     dam = ldround((double)totdam / count, 1);
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       llp = (struct llist *)qp;
+       llp = (struct ulist *)qp;
        /* have to get it again because of collateral damage */
-       getland(llp->land.lnd_uid, &llp->land);
-       landdamage(&llp->land, dam);
-       putland(llp->land.lnd_uid, &llp->land);
-       if (!llp->land.lnd_own) {
+       getland(llp->unit.land.lnd_uid, &llp->unit.land);
+       landdamage(&llp->unit.land, dam);
+       putland(llp->unit.land.lnd_uid, &llp->unit.land);
+       if (!llp->unit.land.lnd_own) {
            emp_remque(qp);
            free(qp);
        }
@@ -834,15 +835,15 @@ lnd_easiest_target(struct emp_qelem *list)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct llist *llp;
+    struct ulist *llp;
     int hard;
     int easiest = 9876;                /* things start great for victim */
     int count = 0;
 
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       llp = (struct llist *)qp;
-       hard = lnd_hardtarget(&llp->land);
+       llp = (struct ulist *)qp;
+       hard = lnd_hardtarget(&llp->unit.land);
        if (hard < easiest)
            easiest = hard;     /* things get worse for victim */
        ++count;
@@ -1029,7 +1030,7 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
     struct emp_qelem *qp;
     struct emp_qelem *qp2;
     struct emp_qelem *next;
-    struct llist *llp;
+    struct ulist *llp;
     struct emp_qelem cur, done;
     coord dx;
     coord dy;
@@ -1050,15 +1051,15 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
     dy = diroff[dir][1];
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       llp = (struct llist *)qp;
-       getsect(llp->land.lnd_x, llp->land.lnd_y, &osect);
+       llp = (struct ulist *)qp;
+       getsect(llp->unit.land.lnd_x, llp->unit.land.lnd_y, &osect);
        oldown = osect.sct_own;
-       newx = xnorm(llp->land.lnd_x + dx);
-       newy = ynorm(llp->land.lnd_y + dy);
+       newx = xnorm(llp->unit.land.lnd_x + dx);
+       newy = ynorm(llp->unit.land.lnd_y + dy);
        getsect(newx, newy, &sect);
        rel = getrel(getnatp(sect.sct_own), player->cnum);
        if ((sect.sct_own != actor && rel != ALLIED &&
-            !(lchr[(int)llp->land.lnd_type].l_flags & L_SPY) &&
+            !(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) &&
             sect.sct_own) || (sect.sct_type == SCT_WATER ||
                               sect.sct_type == SCT_SANCT ||
                               sect.sct_type == SCT_WASTE)) {
@@ -1072,7 +1073,7 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
            }
        }
        if ((!intrchr[INT_RAIL].in_enable || sect.sct_rail == 0)
-           && lnd_mobtype(&llp->land) == MOB_RAIL) {
+           && lnd_mobtype(&llp->unit.land) == MOB_RAIL) {
            if (together) {
                pr("no rail system in %s\n", xyas(newx, newy, actor));
                return 1;
@@ -1085,9 +1086,9 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
        }
        /* Note we check would_abandon first because we don't want
           to always have to do these checks */
-       if (would_abandon(&osect, I_CIVIL, 0, &llp->land)) {
+       if (would_abandon(&osect, I_CIVIL, 0, &llp->unit.land)) {
            stop = 0;
-           if (!want_to_abandon(&osect, I_CIVIL, 0, &llp->land)) {
+           if (!want_to_abandon(&osect, I_CIVIL, 0, &llp->unit.land)) {
                stop = 1;
            }
            /* now check stuff */
@@ -1096,7 +1097,7 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
            if (!check_sect_ok(&osect))
                return 1;
            for (qp2 = list->q_back; qp2 != list; qp2 = qp2->q_back) {
-               if (!check_land_ok(&((struct llist *)qp2)->land))
+               if (!check_land_ok(&((struct ulist *)qp2)->unit.land))
                    return 1;
            }
            if (stop) {
@@ -1108,12 +1109,12 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
            lnd_mess("is out of mobility", llp);
            continue;
        }
-       llp->land.lnd_x = newx;
-       llp->land.lnd_y = newy;
-       llp->mobil -= lnd_mobcost(&llp->land, &sect);
-       llp->land.lnd_mobil = (int)llp->mobil;
-       llp->land.lnd_harden = 0;
-       putland(llp->land.lnd_uid, &llp->land);
+       llp->unit.land.lnd_x = newx;
+       llp->unit.land.lnd_y = newy;
+       llp->mobil -= lnd_mobcost(&llp->unit.land, &sect);
+       llp->unit.land.lnd_mobil = (int)llp->mobil;
+       llp->unit.land.lnd_harden = 0;
+       putland(llp->unit.land.lnd_uid, &llp->unit.land);
        putsect(&osect);
        getsect(osect.sct_x, osect.sct_y, &osect);
        if (osect.sct_own != oldown && oldown == player->cnum) {
@@ -1123,20 +1124,20 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
        }
        if (rel != ALLIED && sect.sct_own != actor && sect.sct_own) {   /* must be a spy */
            /* Always a 10% chance of getting caught. */
-           if (chance(LND_SPY_DETECT_CHANCE(llp->land.lnd_effic))) {
+           if (chance(LND_SPY_DETECT_CHANCE(llp->unit.land.lnd_effic))) {
                if (rel == NEUTRAL || rel == FRIENDLY) {
                    wu(0, sect.sct_own,
                       "%s unit spotted in %s\n", cname(player->cnum),
                       xyas(sect.sct_x, sect.sct_y, sect.sct_own));
-                   setrel(sect.sct_own, llp->land.lnd_own, HOSTILE);
+                   setrel(sect.sct_own, llp->unit.land.lnd_own, HOSTILE);
                } else if (rel == HOSTILE || rel == AT_WAR ||
                           rel == SITZKRIEG || rel == MOBILIZATION) {
                    wu(0, sect.sct_own,
                       "%s spy shot in %s\n", cname(player->cnum),
                       xyas(sect.sct_x, sect.sct_y, sect.sct_own));
-                   pr("%s was shot and killed.\n", prland(&llp->land));
-                   llp->land.lnd_effic = 0;
-                   putland(llp->land.lnd_uid, &llp->land);
+                   pr("%s was shot and killed.\n", prland(&llp->unit.land));
+                   llp->unit.land.lnd_effic = 0;
+                   putland(llp->unit.land.lnd_uid, &llp->unit.land);
                    lnd_delete(llp, 0);
                }
            }
@@ -1153,18 +1154,18 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
     emp_initque(&cur);
     emp_initque(&done);
     while (!QEMPTY(list)) {
-       llp = (struct llist *)list->q_back;
-       newx = llp->land.lnd_x;
-       newy = llp->land.lnd_y;
+       llp = (struct ulist *)list->q_back;
+       newx = llp->unit.land.lnd_x;
+       newy = llp->unit.land.lnd_y;
        /* move units in NEWX,NEWY to cur */
        visible = 0;
        for (qp = list->q_back; qp != list; qp = next) {
            next = qp->q_back;
-           llp = (struct llist *)qp;
-           if (llp->land.lnd_x == newx && llp->land.lnd_y == newy) {
+           llp = (struct ulist *)qp;
+           if (llp->unit.land.lnd_x == newx && llp->unit.land.lnd_y == newy) {
                emp_remque(qp);
                emp_insque(qp, &cur);
-               if (!(lchr[(int)llp->land.lnd_type].l_flags & L_SPY))
+               if (!(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY))
                    visible = 1;
            }
        }
@@ -1174,7 +1175,7 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
        /* move survivors to done */
        for (qp = cur.q_back; qp != &cur; qp = next) {
            next = qp->q_back;
-           llp = (struct llist *)qp;
+           llp = (struct ulist *)qp;
            emp_remque(qp);
            emp_insque(qp, &done);
        }
index 4005e7fd0d9ee717808c85317c0b48737afb9af4..6301df173858496ea3e6be47a25b6f5d21adcc19 100644 (file)
 #include <stdlib.h>
 #include "damage.h"
 #include "file.h"
-#include "item.h"
-#include "land.h"
 #include "map.h"
 #include "misc.h"
 #include "mission.h"
-#include "nat.h"
-#include "news.h"
 #include "nsc.h"
 #include "optlist.h"
 #include "path.h"
-#include "plane.h"
 #include "player.h"
 #include "prototypes.h"
 #include "queue.h"
-#include "sect.h"
 #include "server.h"
-#include "ship.h"
 #include "xy.h"
+#include "empobj.h"
+#include "unit.h"
 
-static int shp_check_one_mines(struct mlist *);
+static int shp_check_one_mines(struct ulist *);
 static int shp_hit_mine(struct shpstr *, struct mchrstr *);
-static void shp_mess(char *, struct mlist *);
+static void shp_mess(char *, struct ulist *);
 
 void
 shp_sel(struct nstr_item *ni, struct emp_qelem *list)
@@ -72,7 +67,7 @@ shp_sel(struct nstr_item *ni, struct emp_qelem *list)
 {
     struct shpstr ship;
     struct mchrstr *mcp;
-    struct mlist *mlp;
+    struct ulist *mlp;
 
     emp_initque(list);
     while (nxtitem(ni, &ship)) {
@@ -107,9 +102,9 @@ shp_sel(struct nstr_item *ni, struct emp_qelem *list)
        ship.shp_rflags = 0;
        memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath));
        putship(ship.shp_uid, &ship);
-       mlp = malloc(sizeof(struct mlist));
-       mlp->mcp = mcp;
-       mlp->ship = ship;
+       mlp = malloc(sizeof(struct ulist));
+       mlp->chrp = (struct empobj_chr *)mcp;
+       mlp->unit.ship = ship;
        mlp->mobil = ship.shp_mobil;
        emp_insque(&mlp->queue, list);
     }
@@ -122,7 +117,7 @@ shp_nav(struct emp_qelem *list, double *minmobp, double *maxmobp,
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct mlist *mlp;
+    struct ulist *mlp;
     struct sctstr sect;
     struct shpstr ship;
     coord allx;
@@ -134,8 +129,8 @@ shp_nav(struct emp_qelem *list, double *minmobp, double *maxmobp,
     *togetherp = 1;
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       mlp = (struct mlist *)qp;
-       getship(mlp->ship.shp_uid, &ship);
+       mlp = (struct ulist *)qp;
+       getship(mlp->unit.ship.shp_uid, &ship);
        if (ship.shp_own != actor) {
            mpr(actor, "%s was sunk at %s\n",
                prship(&ship), xyas(ship.shp_x, ship.shp_y, actor));
@@ -187,7 +182,7 @@ shp_nav(struct emp_qelem *list, double *minmobp, double *maxmobp,
            *minmobp = mlp->mobil;
        if (mlp->mobil > *maxmobp)
            *maxmobp = mlp->mobil;
-       mlp->ship = ship;
+       mlp->unit.ship = ship;
     }
 }
 
@@ -196,15 +191,16 @@ shp_put(struct emp_qelem *list, natid actor)
 {
     struct emp_qelem *qp;
     struct emp_qelem *newqp;
-    struct mlist *mlp;
+    struct ulist *mlp;
 
     qp = list->q_back;
     while (qp != list) {
-       mlp = (struct mlist *)qp;
-       mpr(actor, "%s stopped at %s\n", prship(&mlp->ship),
-           xyas(mlp->ship.shp_x, mlp->ship.shp_y, mlp->ship.shp_own));
-       mlp->ship.shp_mobil = (int)mlp->mobil;
-       putship(mlp->ship.shp_uid, &mlp->ship);
+       mlp = (struct ulist *)qp;
+       mpr(actor, "%s stopped at %s\n", prship(&mlp->unit.ship),
+           xyas(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y,
+           mlp->unit.ship.shp_own));
+       mlp->unit.ship.shp_mobil = (int)mlp->mobil;
+       putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
        newqp = qp->q_back;
        emp_remque(qp);
        free(qp);
@@ -217,7 +213,7 @@ shp_sweep(struct emp_qelem *ship_list, int verbose, int takemob, natid actor)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct mlist *mlp;
+    struct ulist *mlp;
     struct sctstr sect;
     int mines, m, max, shells;
     int changed = 0;
@@ -225,34 +221,35 @@ shp_sweep(struct emp_qelem *ship_list, int verbose, int takemob, natid actor)
 
     for (qp = ship_list->q_back; qp != ship_list; qp = next) {
        next = qp->q_back;
-       mlp = (struct mlist *)qp;
-       if (!(mlp->mcp->m_flags & M_SWEEP)) {
+       mlp = (struct ulist *)qp;
+       if (!(((struct mchrstr *)mlp->chrp)->m_flags & M_SWEEP)) {
            if (verbose)
                mpr(actor, "%s doesn't have minesweeping capability!\n",
-                   prship(&mlp->ship));
+                   prship(&mlp->unit.ship));
            continue;
        }
        if (takemob && mlp->mobil <= 0.0) {
            if (verbose)
-               mpr(actor, "%s is out of mobility!\n", prship(&mlp->ship));
+               mpr(actor, "%s is out of mobility!\n",
+                   prship(&mlp->unit.ship));
            continue;
        }
-       getsect(mlp->ship.shp_x, mlp->ship.shp_y, &sect);
+       getsect(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, &sect);
        if (sect.sct_type != SCT_WATER) {
            if (verbose)
                mpr(actor, "%s is not at sea.  No mines there!\n",
-                   prship(&mlp->ship));
+                   prship(&mlp->unit.ship));
            continue;
        }
        if (takemob) {
-           mlp->mobil -= shp_mobcost(&mlp->ship);
-           mlp->ship.shp_mobil = (int)mlp->mobil;
+           mlp->mobil -= shp_mobcost(&mlp->unit.ship);
+           mlp->unit.ship.shp_mobil = (int)mlp->mobil;
        }
-       putship(mlp->ship.shp_uid, &mlp->ship);
+       putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
        if (!(mines = sect.sct_mines))
            continue;
-       max = mlp->mcp->m_item[I_SHELL];
-       shells = mlp->ship.shp_item[I_SHELL];
+       max = ((struct mchrstr *)mlp->chrp)->m_item[I_SHELL];
+       shells = mlp->unit.ship.shp_item[I_SHELL];
        for (m = 0; mines > 0 && m < 5; m++) {
            if (chance(0.66)) {
                mpr(actor, "Sweep...\n");
@@ -262,13 +259,13 @@ shp_sweep(struct emp_qelem *ship_list, int verbose, int takemob, natid actor)
            }
        }
        sect.sct_mines = mines;
-       mlp->ship.shp_item[I_SHELL] = shells;
+       mlp->unit.ship.shp_item[I_SHELL] = shells;
        if (shp_check_one_mines(mlp)) {
            stopping = 1;
            emp_remque(qp);
            free(qp);
        }
-       putship(mlp->ship.shp_uid, &mlp->ship);
+       putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
        putsect(&sect);
     }
     if (changed)
@@ -277,25 +274,25 @@ shp_sweep(struct emp_qelem *ship_list, int verbose, int takemob, natid actor)
 }
 
 static int
-shp_check_one_mines(struct mlist *mlp)
+shp_check_one_mines(struct ulist *mlp)
 {
     struct sctstr sect;
     int actor;
 
-    getsect(mlp->ship.shp_x, mlp->ship.shp_y, &sect);
+    getsect(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, &sect);
     if (sect.sct_type != SCT_WATER)
        return 0;
     if (!sect.sct_mines)
        return 0;
     if (chance(DMINE_HITCHANCE(sect.sct_mines))) {
-       actor = mlp->ship.shp_own;
-       shp_hit_mine(&mlp->ship, mlp->mcp);
+       actor = mlp->unit.ship.shp_own;
+       shp_hit_mine(&mlp->unit.ship, ((struct mchrstr *)mlp->chrp));
        sect.sct_mines--;
        if (map_set(actor, sect.sct_x, sect.sct_y, 'X', 0))
            writemap(actor);
        putsect(&sect);
-       putship(mlp->ship.shp_uid, &mlp->ship);
-       if (!mlp->ship.shp_own)
+       putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
+       if (!mlp->unit.ship.shp_own)
            return 1;
     }
     return 0;
@@ -306,12 +303,12 @@ shp_check_mines(struct emp_qelem *ship_list)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct mlist *mlp;
+    struct ulist *mlp;
     int stopping = 0;
 
     for (qp = ship_list->q_back; qp != ship_list; qp = next) {
        next = qp->q_back;
-       mlp = (struct mlist *)qp;
+       mlp = (struct ulist *)qp;
        if (shp_check_one_mines(mlp)) {
            stopping = 1;
            emp_remque(qp);
@@ -326,18 +323,18 @@ shp_list(struct emp_qelem *ship_list)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct mlist *mlp;
+    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 mlist *)qp;
-       shp = &mlp->ship;
+       mlp = (struct ulist *)qp;
+       shp = &mlp->unit.ship;
        pr("%4d ", shp->shp_uid);
-       pr("%-16.16s ", mlp->mcp->m_name);
-       prxy("%4d,%-4d ", shp->shp_x, shp->shp_y, mlp->ship.shp_own);
+       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]);
@@ -355,13 +352,14 @@ shp_list(struct emp_qelem *ship_list)
 }
 
 static void
-shp_mess(char *str, struct mlist *mlp)
+shp_mess(char *str, struct ulist *mlp)
 {
-    mpr(mlp->ship.shp_own, "%s %s & stays in %s\n",
-       prship(&mlp->ship),
-       str, xyas(mlp->ship.shp_x, mlp->ship.shp_y, mlp->ship.shp_own));
-    mlp->ship.shp_mobil = (int)mlp->mobil;
-    putship(mlp->ship.shp_uid, &mlp->ship);
+    mpr(mlp->unit.ship.shp_own, "%s %s & stays in %s\n",
+       prship(&mlp->unit.ship),
+       str, xyas(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y,
+                 mlp->unit.ship.shp_own));
+    mlp->unit.ship.shp_mobil = (int)mlp->mobil;
+    putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
     emp_remque((struct emp_qelem *)mlp);
     free(mlp);
 }
@@ -411,17 +409,19 @@ shp_count(struct emp_qelem *list, int wantflags, int nowantflags,
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct mlist *mlp;
+    struct ulist *mlp;
     int count = 0;
 
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       mlp = (struct mlist *)qp;
-       if (mlp->ship.shp_x != x || mlp->ship.shp_y != y)
+       mlp = (struct ulist *)qp;
+       if (mlp->unit.ship.shp_x != x || mlp->unit.ship.shp_y != y)
            continue;
-       if (wantflags && (mlp->mcp->m_flags & wantflags) != wantflags)
+       if (wantflags &&
+           (((struct mchrstr *)mlp->chrp)->m_flags & wantflags) != wantflags)
            continue;
-       if (nowantflags && mlp->mcp->m_flags & nowantflags)
+       if (nowantflags &&
+           ((struct mchrstr *)mlp->chrp)->m_flags & nowantflags)
            continue;
        ++count;
     }
@@ -429,11 +429,11 @@ shp_count(struct emp_qelem *list, int wantflags, int nowantflags,
 }
 
 static void
-shp_damage_one(struct mlist *mlp, int dam)
+shp_damage_one(struct ulist *mlp, int dam)
 {
-    shipdamage(&mlp->ship, dam);
-    putship(mlp->ship.shp_uid, &mlp->ship);
-    if (!mlp->ship.shp_own) {
+    shipdamage(&mlp->unit.ship, dam);
+    putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
+    if (!mlp->unit.ship.shp_own) {
        emp_remque((struct emp_qelem *)mlp);
        free(mlp);
     }
@@ -445,7 +445,7 @@ shp_damage(struct emp_qelem *list, int totdam, int wantflags,
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct mlist *mlp;
+    struct ulist *mlp;
     int dam;
     int count;
 
@@ -455,12 +455,14 @@ shp_damage(struct emp_qelem *list, int totdam, int wantflags,
     dam = ldround((double)totdam / count, 1);
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       mlp = (struct mlist *)qp;
-       if (mlp->ship.shp_x != x || mlp->ship.shp_y != y)
+       mlp = (struct ulist *)qp;
+       if (mlp->unit.ship.shp_x != x || mlp->unit.ship.shp_y != y)
            continue;
-       if (wantflags && (mlp->mcp->m_flags & wantflags) != wantflags)
+       if (wantflags &&
+           (((struct mchrstr *)mlp->chrp)->m_flags & wantflags) != wantflags)
            continue;
-       if (nowantflags && mlp->mcp->m_flags & nowantflags)
+       if (nowantflags &&
+           ((struct mchrstr *)mlp->chrp)->m_flags & nowantflags)
            continue;
        shp_damage_one(mlp, dam);
     }
@@ -473,47 +475,50 @@ shp_contains(struct emp_qelem *list, int newx, int newy, int wantflags,
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct mlist *mlp;
+    struct ulist *mlp;
 
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       mlp = (struct mlist *)qp;
+       mlp = (struct ulist *)qp;
 /* If the ship isn't in the requested sector, then continue */
-       if (newx != mlp->ship.shp_x || newy != mlp->ship.shp_y)
+       if (newx != mlp->unit.ship.shp_x || newy != mlp->unit.ship.shp_y)
            continue;
-       if (wantflags && (mlp->mcp->m_flags & wantflags) != wantflags)
+       if (wantflags &&
+           (((struct mchrstr *)mlp->chrp)->m_flags & wantflags) != wantflags)
            continue;
-       if (nowantflags && mlp->mcp->m_flags & nowantflags)
+       if (nowantflags &&
+           ((struct mchrstr *)mlp->chrp)->m_flags & nowantflags)
            continue;
        return 1;
     }
     return 0;
 }
 
-static struct mlist *
+static struct ulist *
 most_valuable_ship(struct emp_qelem *list)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct mlist *mlp;
-    struct mlist *mvs = 0;
+    struct ulist *mlp;
+    struct ulist *mvs = 0;
 
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       mlp = (struct mlist *)qp;
-       if (mlp->mcp->m_flags & M_SUB)
+       mlp = (struct ulist *)qp;
+       if (((struct mchrstr *)mlp->chrp)->m_flags & M_SUB)
            continue;
-       if (!mlp->mcp->m_nxlight &&
-           !mlp->mcp->m_nchoppers &&
-           mlp->mcp->m_cost < 1000 &&
-           !mlp->mcp->m_nplanes && !mlp->mcp->m_nland)
+       if (!((struct mchrstr *)mlp->chrp)->m_nxlight &&
+           !((struct mchrstr *)mlp->chrp)->m_nchoppers &&
+           ((struct mchrstr *)mlp->chrp)->m_cost < 1000 &&
+           !((struct mchrstr *)mlp->chrp)->m_nplanes &&
+           !((struct mchrstr *)mlp->chrp)->m_nland)
            continue;
        if (!mvs) {
            mvs = mlp;
            continue;
        }
-       if (mlp->mcp->m_cost * mlp->ship.shp_effic >
-           mvs->mcp->m_cost * mvs->ship.shp_effic)
+       if (((struct mchrstr *)mlp->chrp)->m_cost * mlp->unit.ship.shp_effic >
+           ((struct mchrstr *)mlp->chrp)->m_cost * mvs->unit.ship.shp_effic)
            mvs = mlp;
     }
     return mvs;
@@ -524,19 +529,21 @@ shp_easiest_target(struct emp_qelem *list, int wantflags, int nowantflags)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct mlist *mlp;
+    struct ulist *mlp;
     int hard;
     int easiest = 9876;                /* things start great for victim */
     int count = 0;
 
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       mlp = (struct mlist *)qp;
-       if (wantflags && (mlp->mcp->m_flags & wantflags) != wantflags)
+       mlp = (struct ulist *)qp;
+       if (wantflags &&
+           (((struct mchrstr *)mlp->chrp)->m_flags & wantflags) != wantflags)
            continue;
-       if (nowantflags && mlp->mcp->m_flags & nowantflags)
+       if (nowantflags &&
+           ((struct mchrstr *)mlp->chrp)->m_flags & nowantflags)
            continue;
-       hard = shp_hardtarget(&mlp->ship);
+       hard = shp_hardtarget(&mlp->unit.ship);
        if (hard < easiest)
            easiest = hard;     /* things get worse for victim */
        ++count;
@@ -552,16 +559,16 @@ shp_missile_interdiction(struct emp_qelem *list, coord newx, coord newy,
     int twotries;
     int stopping = 0;
     struct emp_qelem msl_list, *qp, *newqp;
-    struct mlist *mvs;
+    struct ulist *mvs;
     char what[512];
 
     msl_sel(&msl_list, newx, newy, victim, P_T | P_MAR, 0, MI_INTERDICT);
 
     twotries = 0;
     while (!QEMPTY(&msl_list) && (mvs = most_valuable_ship(list))) {
-       sprintf(what, "%s", prship(&mvs->ship));
+       sprintf(what, "%s", prship(&mvs->unit.ship));
        dam = msl_launch_mindam(&msl_list, newx, newy,
-                               shp_hardtarget(&mvs->ship),
+                               shp_hardtarget(&mvs->unit.ship),
                                EF_SHIP, 1, what, victim, MI_INTERDICT);
        if (dam) {
            mpr(victim,
@@ -594,7 +601,7 @@ notify_coastguard(struct emp_qelem *list, int trange, struct sctstr *sectp)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct mlist *mlp;
+    struct ulist *mlp;
     struct natstr *natp;
     int vrange;
 
@@ -611,17 +618,18 @@ notify_coastguard(struct emp_qelem *list, int trange, struct sctstr *sectp)
 
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       mlp = (struct mlist *)qp;
-       if (mlp->mcp->m_flags & M_SUB)
+       mlp = (struct ulist *)qp;
+       if (((struct mchrstr *)mlp->chrp)->m_flags & M_SUB)
            continue;
        if (natp->nat_flags & NF_COASTWATCH)
            wu(0, sectp->sct_own,
               "%s %s sighted at %s\n",
-              cname(mlp->ship.shp_own),
-              prship(&mlp->ship),
-              xyas(mlp->ship.shp_x, mlp->ship.shp_y, sectp->sct_own));
+              cname(mlp->unit.ship.shp_own),
+              prship(&mlp->unit.ship),
+              xyas(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y,
+                   sectp->sct_own));
        if (opt_HIDDEN)
-           setcont(sectp->sct_own, mlp->ship.shp_own, FOUND_COAST);
+           setcont(sectp->sct_own, mlp->unit.ship.shp_own, FOUND_COAST);
     }
 
     return 1;
@@ -787,19 +795,19 @@ shp_view(struct emp_qelem *list)
     struct sctstr sect;
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct mlist *mlp;
+    struct ulist *mlp;
 
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       mlp = (struct mlist *)qp;
-       getsect(mlp->ship.shp_x, mlp->ship.shp_y, &sect);
-       if (mlp->mcp->m_flags & M_FOOD)
-           mpr(mlp->ship.shp_own, "[fert:%d] ", sect.sct_fertil);
-       if (mlp->mcp->m_flags & M_OIL)
-           mpr(mlp->ship.shp_own, "[oil:%d] ", sect.sct_oil);
-       mpr(mlp->ship.shp_own, "%s @ %s %d%% %s\n",
-           prship(&mlp->ship),
-           xyas(mlp->ship.shp_x, mlp->ship.shp_y, player->cnum),
+       mlp = (struct ulist *)qp;
+       getsect(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, &sect);
+       if (((struct mchrstr *)mlp->chrp)->m_flags & M_FOOD)
+           mpr(mlp->unit.ship.shp_own, "[fert:%d] ", sect.sct_fertil);
+       if (((struct mchrstr *)mlp->chrp)->m_flags & M_OIL)
+           mpr(mlp->unit.ship.shp_own, "[oil:%d] ", sect.sct_oil);
+       mpr(mlp->unit.ship.shp_own, "%s @ %s %d%% %s\n",
+           prship(&mlp->unit.ship),
+           xyas(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y, player->cnum),
            sect.sct_effic, dchr[sect.sct_type].d_name);
     }
 }
@@ -811,7 +819,7 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor,
     struct sctstr sect;
     struct emp_qelem *qp;
     struct emp_qelem *next;
-    struct mlist *mlp;
+    struct ulist *mlp;
     struct emp_qelem done;
     coord dx;
     coord dy;
@@ -832,16 +840,16 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor,
     dy = diroff[dir][1];
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
-       mlp = (struct mlist *)qp;
-       newx = xnorm(mlp->ship.shp_x + dx);
-       newy = ynorm(mlp->ship.shp_y + dy);
+       mlp = (struct ulist *)qp;
+       newx = xnorm(mlp->unit.ship.shp_x + dx);
+       newy = ynorm(mlp->unit.ship.shp_y + dy);
        getsect(newx, newy, &sect);
-       navigate = shp_check_nav(&sect, &mlp->ship);
+       navigate = shp_check_nav(&sect, &mlp->unit.ship);
        if (navigate != CN_NAVIGABLE ||
            (sect.sct_own && actor != sect.sct_own &&
             getrel(getnatp(sect.sct_own), actor) < FRIENDLY)) {
            if (dchr[sect.sct_type].d_nav == NAV_CANAL &&
-               !(mlp->mcp->m_flags & M_CANAL) &&
+               !(((struct mchrstr *)mlp->chrp)->m_flags & M_CANAL) &&
                navigate == CN_LANDLOCKED)
                sprintf(dp,
                        "is too large to fit into the canal system at %s",
@@ -861,25 +869,27 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor,
            shp_mess("is out of mobility", mlp);
            continue;
        }
-       mobcost = shp_mobcost(&mlp->ship);
-       mlp->ship.shp_x = newx;
-       mlp->ship.shp_y = newy;
+       mobcost = shp_mobcost(&mlp->unit.ship);
+       mlp->unit.ship.shp_x = newx;
+       mlp->unit.ship.shp_y = newy;
        if (mlp->mobil - mobcost < -127) {
            mlp->mobil = -127;
        } else {
            mlp->mobil -= mobcost;
        }
-       mlp->ship.shp_mobil = (int)mlp->mobil;
-       putship(mlp->ship.shp_uid, &mlp->ship);
+       mlp->unit.ship.shp_mobil = (int)mlp->mobil;
+       putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
 
        /* Now update the map for this ship */
-       tech = techfact(mlp->ship.shp_tech, mlp->mcp->m_vrnge);
-       if (mlp->mcp->m_flags & M_SONAR)
-           tf = techfact(mlp->ship.shp_tech, 1.0);
+       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->ship.shp_own, mlp->ship.shp_x, mlp->ship.shp_y,
-                 (int)mlp->ship.shp_effic, (int)tech, tf);
+       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);
     }
     if (QEMPTY(list))
        return stopping;
@@ -893,15 +903,16 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor,
     /* interdict ships sector by sector */
     emp_initque(&done);
     while (!QEMPTY(list)) {
-       mlp = (struct mlist *)list->q_back;
-       newx = mlp->ship.shp_x;
-       newy = mlp->ship.shp_y;
+       mlp = (struct ulist *)list->q_back;
+       newx = mlp->unit.ship.shp_x;
+       newy = mlp->unit.ship.shp_y;
        stopping |= shp_interdict(list, newx, newy, actor);
        /* move survivors in this sector to done */
        for (qp = list->q_back; qp != list; qp = next) {
            next = qp->q_back;
-           mlp = (struct mlist *)qp;
-           if (mlp->ship.shp_x == newx && mlp->ship.shp_y == newy) {
+           mlp = (struct ulist *)qp;
+           if (mlp->unit.ship.shp_x == newx &&
+               mlp->unit.ship.shp_y == newy) {
                emp_remque(qp);
                emp_insque(qp, &done);
            }
@@ -1028,18 +1039,18 @@ void
 shp_missdef(struct shpstr *sp, natid victim)
 {
     struct emp_qelem list;
-    struct mlist *mlp;
+    struct ulist *mlp;
     int eff;
     char buf[512];
 
     emp_initque(&list);
 
-    mlp = malloc(sizeof(struct mlist));
-    mlp->mcp = &mchr[(int)sp->shp_type];
-    mlp->ship = *sp;
+    mlp = malloc(sizeof(struct ulist));
+    mlp->chrp = (struct empobj_chr *)&mchr[(int)sp->shp_type];
+    mlp->unit.ship = *sp;
     mlp->mobil = sp->shp_mobil;
     emp_insque(&mlp->queue, &list);
-    sprintf(buf, "%s", prship(&mlp->ship));
+    sprintf(buf, "%s", prship(&mlp->unit.ship));
 
     eff = sp->shp_effic;
     if (most_valuable_ship(&list)) {
index c0b72b41af383dddba8fb07a88773714c20f7d4b..5af549b9b7bf48615b19facc9d74642fe7d02b45 100644 (file)
 
 
 #include <ctype.h>
-#include "item.h"
 #include "nsc.h"
 #include "path.h"
-#include "ship.h"
 #include "update.h"
+#include "empobj.h"
+#include "unit.h"
 
 static void swap(struct shpstr *);
 
@@ -233,7 +233,7 @@ nav_ship(struct shpstr *sp)
     char buf[1024];
     struct emp_qelem ship_list;
     struct emp_qelem *qp, *newqp;
-    struct mlist *mlp;
+    struct ulist *mlp;
     int dummyint;
     double dummydouble;
     int dir;
@@ -249,9 +249,9 @@ nav_ship(struct shpstr *sp)
 
     /* Make a list of one ships so we can use the navi.c code */
     emp_initque(&ship_list);
-    mlp = malloc(sizeof(struct mlist));
-    mlp->mcp = mchr + sp->shp_type;
-    mlp->ship = *sp;
+    mlp = malloc(sizeof(struct ulist));
+    mlp->chrp = (struct empobj_chr *)(mchr + sp->shp_type);
+    mlp->unit.ship = *sp;
     mlp->mobil = sp->shp_mobil;
     emp_insque(&mlp->queue, &ship_list);
 
@@ -268,9 +268,10 @@ nav_ship(struct shpstr *sp)
            sectp = getsectp(sp->shp_x, sp->shp_y);
            if (opt_FUEL &&
                sectp->sct_own != 0 &&
-               sp->shp_fuel <= 0 && mlp->mcp->m_fuelu != 0)
+               sp->shp_fuel <= 0 &&
+               ((struct mchrstr *)mlp->chrp)->m_fuelu != 0)
                auto_fuel_ship(sp);
-           mlp->ship.shp_fuel = sp->shp_fuel;
+           mlp->unit.ship.shp_fuel = sp->shp_fuel;
 
            cp = BestShipPath(buf, sp->shp_x, sp->shp_y,
                              sp->shp_destx[0], sp->shp_desty[0],
index 66bea91b7f19cce5cd45335ba3052e18d2de8f8e..9df308ec3664928adf021727be47b20261e93d06 100644 (file)
@@ -39,8 +39,9 @@
 #include <math.h>
 #include "nsc.h"
 #include "path.h"
-#include "ship.h"
 #include "update.h"
+#include "empobj.h"
+#include "unit.h"
 
 static void fltp_to_list(struct fltheadstr *, struct emp_qelem *);
 
@@ -316,15 +317,15 @@ static void
 fltp_to_list(struct fltheadstr *fltp, struct emp_qelem *list)
 {
     struct fltelemstr *fe;
-    struct mlist *mlp;
+    struct ulist *mlp;
     struct shpstr *sp;
 
     emp_initque(list);
     for (fe = fltp->head; fe; fe = fe->next) {
-       mlp = malloc(sizeof(struct mlist));
+       mlp = malloc(sizeof(struct ulist));
        sp = getshipp(fe->num);
-       mlp->mcp = mchr + sp->shp_type;
-       mlp->ship = *sp;
+       mlp->chrp = (struct empobj_chr *)(mchr + sp->shp_type);
+       mlp->unit.ship = *sp;
        mlp->mobil = fe->mobil;
        emp_insque(&mlp->queue, list);
     }