]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/ldump.c
License upgrade to GPL version 3 or later
[empserver] / src / lib / commands / ldump.c
index 61466920b89ea13218b03f262d4c56788aa213f9..d63330f16285216faf70a53793c29582c74b8cac 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2005, 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,
  *  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/>.
  *
  *  ---
  *
- *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- *  related information and legal notices. It is expected that any future
- *  projects/authors will amend these files as needed.
+ *  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.
  *
  *  ---
  *
  *  ldump.c: Dump land unit information
- * 
+ *
  *  Known contributors to this file:
  *     John Yockey, 1997
  *     Steve McClure, 1998
  */
 
-#include "misc.h"
-#include "player.h"
-#include "xy.h"
-#include "sect.h"
+#include <config.h>
+
+#include "commands.h"
 #include "land.h"
-#include "nat.h"
-#include "nsc.h"
-#include "file.h"
 #include "optlist.h"
-#include "commands.h"
 
 int
 ldump(void)
@@ -54,13 +48,13 @@ ldump(void)
     struct natstr *np;
     time_t now;
 
-    if (!snxtitem(&ni, EF_LAND, player->argp[1]))
+    if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
     prdate();
     nunits = 0;
 
     if (!player->argp[2]) {
-       for (n = 1; n <= 39; n++)
+       for (n = 1; n <= 41; n++)
            field[n - 1] = n;
        field[n - 1] = 0;
     } else {
@@ -145,6 +139,10 @@ ldump(void)
                field[i++] = 38;
            } else if (!strcmp("aaf", player->argp[n])) {
                field[i++] = 39;
+           } else if (!strcmp("uw", player->argp[n])) {
+               field[i++] = 40;
+           } else if (!strcmp("civ", player->argp[n])) {
+               field[i++] = 41;
            } else {
                pr("Unrecognized field %s\n", player->argp[n]);
            }
@@ -283,6 +281,12 @@ ldump(void)
        case 39:
            pr(" aaf");
            break;
+       case 40:
+           pr(" uw");
+           break;
+       case 41:
+           pr(" civ");
+           break;
        }
        n++;
     }
@@ -294,13 +298,6 @@ ldump(void)
            continue;
        if (!player->owner && !player->god)
            continue;
-       if (land.lnd_type < 0 || land.lnd_type > lnd_maxno) {
-           pr("bad unit type %d (#%d)\n", land.lnd_type, ni.cur);
-           continue;
-       }
-       count_land_planes(&land);
-       lnd_count_units(&land);
-
        nunits++;
        if (player->god)
            pr("%d ", land.lnd_own);
@@ -318,16 +315,13 @@ ldump(void)
                pr(" %d", yrel(np, land.lnd_y));
                break;
            case 4:
-               if (land.lnd_army == ' ')
-                   pr(" ~");
-               else
-                   pr(" %c", land.lnd_army);
+               pr(" %c", land.lnd_army ? land.lnd_army : '~');
                break;
            case 5:
                pr(" %d", land.lnd_effic);
                break;
            case 6:
-               pr(" %d", lnd_getmil(&land));
+               pr(" %d", land.lnd_item[I_MILIT]);
                break;
            case 7:
                pr(" %d", land.lnd_harden);
@@ -339,10 +333,7 @@ ldump(void)
                pr(" %d", land.lnd_item[I_FOOD]);
                break;
            case 10:
-               if (opt_FUEL)
-                   pr(" %d", land.lnd_fuel);
-               else
-                   pr(" 0");
+               pr(" 0");
                break;
            case 11:
                pr(" %d", land.lnd_tech);
@@ -351,13 +342,13 @@ ldump(void)
                pr(" %d", land.lnd_retreat);
                break;
            case 13:
-               pr(" %d", land.lnd_rad_max);
+               pr(" 0");
                break;
            case 14:
-               pr(" %d", land.lnd_nxlight);
+               pr(" %d", lnd_nxlight(&land));
                break;
            case 15:
-               pr(" %d", land.lnd_nland);
+               pr(" %d", lnd_nland(&land));
                break;
            case 16:
                pr(" %d", land.lnd_land);
@@ -396,40 +387,46 @@ ldump(void)
                pr(" %d", land.lnd_item[I_RAD]);
                break;
            case 28:
-               pr(" %1.2f", land.lnd_att);
+               pr(" %1.2f", lnd_att(&land));
                break;
            case 29:
-               pr(" %1.2f", land.lnd_def);
+               pr(" %1.2f", lnd_def(&land));
                break;
            case 30:
-               pr(" %d", land.lnd_vul);
+               pr(" %d", lnd_vul(&land));
                break;
            case 31:
-               pr(" %d", land.lnd_spd);
+               pr(" %d", lnd_spd(&land));
                break;
            case 32:
-               pr(" %d", land.lnd_vis);
+               pr(" %d", lnd_vis(&land));
                break;
            case 33:
-               pr(" %d", land.lnd_spy);
+               pr(" %d", lchr[land.lnd_type].l_spy);
                break;
            case 34:
-               pr(" %d", land.lnd_rad);
+               pr(" %d", lchr[land.lnd_type].l_rad);
                break;
            case 35:
-               pr(" %d", land.lnd_frg);
+               pr(" %d", lnd_frg(&land));
                break;
            case 36:
-               pr(" %d", land.lnd_acc);
+               pr(" %d", lnd_acc(&land));
                break;
            case 37:
-               pr(" %d", land.lnd_dam);
+               pr(" %d", lnd_dam(&land));
                break;
            case 38:
-               pr(" %d", land.lnd_ammo);
+               pr(" %d", lchr[land.lnd_type].l_ammo);
                break;
            case 39:
-               pr(" %d", land.lnd_aaf);
+               pr(" %d", lnd_aaf(&land));
+               break;
+           case 40:
+               pr(" %d", land.lnd_item[I_UW]);
+               break;
+           case 41:
+               pr(" %d", land.lnd_item[I_CIVIL]);
                break;
            }
        }