]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/unitsub.c
Collect path-related stuff in path.h
[empserver] / src / lib / subs / unitsub.c
index 1d6da175d49ebfd658a5c13615c54e65764882e2..fa986c0675fb3a31ce34dd4cac421486c3aca0c6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  *
  *  Known contributors to this file:
  *     Ron Koenderink, 2007
- *     Markus Armbruster, 2008
+ *     Markus Armbruster, 2009
  */
 
 #include <config.h>
 
 #include "empobj.h"
 #include "file.h"
+#include "path.h"
 #include "player.h"
 #include "optlist.h"
 #include "prototypes.h"
@@ -56,14 +57,14 @@ unit_list(struct emp_qelem *unit_list)
        return;
     qp = unit_list->q_back;
     ulp = (struct ulist *)qp;
-    type = ulp->unit.ef_type;
+    type = ulp->unit.gen.ef_type;
     if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP))
        return;
 
     if (type == EF_LAND)
        pr("lnd#     land type       x,y    a  eff  sh gun xl  mu tech retr\n");
     else
-        pr("shp#     ship type       x,y   fl  eff mil  sh gun pn he xl ln mob tech\n");
+       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;
@@ -75,7 +76,7 @@ unit_list(struct emp_qelem *unit_list)
            continue;
        pr("%4d ", unit->uid);
        pr("%-16.16s ", empobj_chr_name(unit));
-       prxy("%4d,%-4d ", unit->x, unit->y, unit->own);
+       prxy("%4d,%-4d ", unit->x, unit->y);
        pr("%1.1s", &unit->group);
        pr("%4d%%", unit->effic);
        if (type == EF_LAND) {
@@ -116,7 +117,7 @@ unit_put(struct emp_qelem *list, natid actor)
            continue;
        if (actor) {
            mpr(actor, "%s stopped at %s\n", obj_nameof(unit),
-               xyas(unit->x, unit->y, unit->own));
+               xyas(unit->x, unit->y, actor));
            if (unit->ef_type == EF_LAND) {
                if (ulp->mobil < -127)
                    ulp->mobil = -127;
@@ -147,22 +148,22 @@ unit_path(int together, struct empobj *unit, char *buf)
        return NULL;
 
     if (!sarg_xy(buf, &destx, &desty))
-       return 0;
+       return NULL;
     if (!together) {
        pr("Cannot go to a destination sector if not all starting in the same sector\n");
-       return 0;
+       return NULL;
     }
     if (!getsect(destx, desty, &d_sect)) {
        pr("%d,%d is not a sector\n", destx, desty);
-       return 0;
+       return NULL;
     }
     if (unit->ef_type == EF_SHIP) {
        cp = BestShipPath(buf, unit->x, unit->y,
                          d_sect.sct_x, d_sect.sct_y, player->cnum);
        if (!cp || unit->mobil <= 0) {
            pr("Can't get to '%s' right now.\n",
-               xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
-           return 0;
+              xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
+           return NULL;
        }
     } else {
        getsect(unit->x, unit->y, &sect);
@@ -173,7 +174,7 @@ unit_path(int together, struct empobj *unit, char *buf)
               mtype == MOB_RAIL ? "railway" : "path",
               xyas(unit->x, unit->y, player->cnum),
               xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
-           return 0;
+           return NULL;
        }
        pr("Using path '%s'\n", cp);
     }
@@ -191,18 +192,18 @@ unit_view(struct emp_qelem *list)
     for (qp = list->q_back; qp != list; qp = next) {
        next = qp->q_back;
        ulp = (struct ulist *)qp;
-       if (CANT_HAPPEN(!(ef_flags(ulp->unit.ef_type) & EFF_XY)))
+       if (CANT_HAPPEN(!(ef_flags(ulp->unit.gen.ef_type) & EFF_XY)))
            continue;
        getsect(ulp->unit.gen.x, ulp->unit.gen.y, &sect);
-       if (ulp->unit.ef_type == EF_SHIP) {
+       if (ulp->unit.gen.ef_type == EF_SHIP) {
            if (((struct mchrstr *)ulp->chrp)->m_flags & M_FOOD)
                pr("[fert:%d] ", sect.sct_fertil);
            if (((struct mchrstr *)ulp->chrp)->m_flags & M_OIL)
                pr("[oil:%d] ", sect.sct_oil);
        }
        pr("%s @ %s %d%% %s\n", obj_nameof(&ulp->unit.gen),
-           xyas(ulp->unit.gen.x, ulp->unit.gen.y, player->cnum),
-           sect.sct_effic, dchr[sect.sct_type].d_name);
+          xyas(ulp->unit.gen.x, ulp->unit.gen.y, player->cnum),
+          sect.sct_effic, dchr[sect.sct_type].d_name);
     }
 }
 
@@ -353,7 +354,6 @@ unit_wipe_orders(struct empobj *unit)
        lp->lnd_retreat = morale_base;
        lp->lnd_rflags = 0;
        lp->lnd_rpath[0] = 0;
-       lp->lnd_rad_max = 0;
        break;
     case EF_NUKE:
        break;