]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/trdsub.c
Clean up superfluous includes
[empserver] / src / lib / subs / trdsub.c
index 96aa2d902d8f375c17ff87daf72d2b1afb5254c1..f851512281edf7e069e1f9bd2f43ec6c49d65895 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire 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
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  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
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
@@ -26,7 +25,7 @@
  *  ---
  *
  *  trdsub.c: Trade helper functions
- * 
+ *
  *  Known contributors to this file:
  *     St Phil, 1989
  *     Pat Loney, 1992
 
 #include <config.h>
 
-#include "misc.h"
-#include "player.h"
-#include "sect.h"
-#include "nat.h"
+#include "empobj.h"
+#include "file.h"
 #include "item.h"
-#include "ship.h"
 #include "land.h"
+#include "loan.h"
+#include "misc.h"
+#include "nat.h"
+#include "nsc.h"
 #include "nuke.h"
 #include "plane.h"
+#include "prototypes.h"
+#include "sect.h"
+#include "ship.h"
 #include "trade.h"
 #include "xy.h"
-#include "nsc.h"
-#include "file.h"
-#include "loan.h"
-#include "prototypes.h"
-#include "optlist.h"
 
 int
 trade_check_ok(struct trdstr *tp, union empobj_storage *tgp)
@@ -107,6 +105,7 @@ trade_desc(struct trdstr *tp, union empobj_storage *tgp)
     struct nstr_item ni;
     struct plnstr plane;
     struct lndstr land;
+    struct nukstr nuke;
 
     switch (tp->trd_type) {
     case EF_NUKE:
@@ -127,42 +126,31 @@ trade_desc(struct trdstr *tp, union empobj_storage *tgp)
                pr("%c:%d ", ichr[it].i_mnem, sp->shp_item[it]);
        }
        pr("] #%d", tp->trd_unitid);
-       if (opt_SHOWPLANE) {
-           snxtitem_all(&ni, EF_PLANE);
-           while (nxtitem(&ni, &plane)) {
-               if (plane.pln_ship == sp->shp_uid && plane.pln_own != 0) {
+       snxtitem_cargo(&ni, EF_PLANE, EF_SHIP, sp->shp_uid);
+       while (nxtitem(&ni, &plane)) {
+           pr("\n\t\t\t\t    tech %3d %3d%% %s #%d",
+              plane.pln_tech,
+              plane.pln_effic,
+              plchr[(int)plane.pln_type].pl_name, plane.pln_uid);
+           if (getnuke(nuk_on_plane(&plane), &nuke))
+               pr("(%s)", nchr[nuke.nuk_type].n_name);
+       }
+       snxtitem_cargo(&ni, EF_LAND, EF_SHIP, sp->shp_uid);
+       while (nxtitem(&ni, &land)) {
+           pr("\n\t\t\t\t    tech %3d %3d%% %s #%d",
+              land.lnd_tech,
+              land.lnd_effic,
+              lchr[(int)land.lnd_type].l_name, land.lnd_uid);
+           if (pln_first_on_land(&land) >= 0) {
+               snxtitem_cargo(&ni, EF_PLANE, EF_LAND, land.lnd_uid);
+               while (nxtitem(&ni, &plane)) {
                    pr("\n\t\t\t\t    tech %3d %3d%% %s #%d",
                       plane.pln_tech,
                       plane.pln_effic,
-                      plchr[(int)plane.pln_type].pl_name, plane.pln_uid);
-                   if (plane.pln_nuketype != -1) {
-                       pr("(%s)", nchr[(int)plane.pln_nuketype].n_name);
-                   }
-               }
-           }
-           snxtitem_all(&ni, EF_LAND);
-           while (nxtitem(&ni, &land)) {
-               if (land.lnd_ship == sp->shp_uid && land.lnd_own != 0) {
-                   pr("\n\t\t\t\t    tech %3d %3d%% %s #%d",
-                      land.lnd_tech,
-                      land.lnd_effic,
-                      lchr[(int)land.lnd_type].l_name, land.lnd_uid);
-                   if (land.lnd_nxlight) {
-                       snxtitem_all(&ni, EF_PLANE);
-                       while (nxtitem(&ni, &plane)) {
-                           if (plane.pln_land == land.lnd_uid) {
-                               pr("\n\t\t\t\t    tech %3d %3d%% %s #%d",
-                                  plane.pln_tech,
-                                  plane.pln_effic,
-                                  plchr[(int)plane.pln_type].pl_name,
-                                  plane.pln_uid);
-                               if (plane.pln_nuketype != -1) {
-                                   pr("(%s)",
-                                      nchr[(int)plane.pln_nuketype].n_name);
-                               }
-                           }
-                       }
-                   }
+                      plchr[(int)plane.pln_type].pl_name,
+                      plane.pln_uid);
+                   if (getnuke(nuk_on_plane(&plane), &nuke))
+                       pr("(%s)", nchr[nuke.nuk_type].n_name);
                }
            }
        }
@@ -184,21 +172,6 @@ trade_desc(struct trdstr *tp, union empobj_storage *tgp)
                pr("%c:%d ", ichr[it].i_mnem, lp->lnd_item[it]);
        }
        pr("] #%d", tp->trd_unitid);
-       if (opt_SHOWPLANE) {
-           snxtitem_all(&ni, EF_PLANE);
-           while (nxtitem(&ni, &plane)) {
-               if (plane.pln_land == lp->lnd_uid && plane.pln_own != 0) {
-                   pr("\n\t\t\t\t    tech %3d %3d%% %s #%d",
-                      plane.pln_tech,
-                      plane.pln_effic,
-                      plchr[(int)plane.pln_type].pl_name, plane.pln_uid);
-                   if (plane.pln_nuketype != -1) {
-                       pr("(%s)", nchr[(int)plane.pln_nuketype].n_name);
-                   }
-               }
-           }
-       }
-       getsect(lp->lnd_x, lp->lnd_y, &sect);
        break;
     case EF_PLANE:
        pp = &tgp->plane;
@@ -208,9 +181,8 @@ trade_desc(struct trdstr *tp, union empobj_storage *tgp)
           pp->pln_tech,
           pp->pln_effic,
           plchr[(int)pp->pln_type].pl_name, tp->trd_unitid);
-       if (pp->pln_nuketype != -1) {
-           pr("(%s)", nchr[(int)pp->pln_nuketype].n_name);
-       }
+       if (getnuke(nuk_on_plane(pp), &nuke))
+           pr("(%s)", nchr[nuke.nuk_type].n_name);
        break;
     default:
        pr("flaky unit type %d", tp->trd_type);