src/lib/commands/leve.c

Go to the documentation of this file.
00001 /*
00002  *  Empire - A multi-player, client/server Internet based war game.
00003  *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
00004  *                           Ken Stevens, Steve McClure
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  *  ---
00021  *
00022  *  See files README, COPYING and CREDITS in the root of the source
00023  *  tree for related information and legal notices.  It is expected
00024  *  that future projects/authors will amend these files as needed.
00025  *
00026  *  ---
00027  *
00028  *  leve.c: Do a distribution threshold level report
00029  * 
00030  *  Known contributors to this file:
00031  *     David Muir Sharnoff, 1987
00032  */
00033 
00034 #include <config.h>
00035 
00036 #include "commands.h"
00037 #include "path.h"
00038 
00039 int
00040 leve(void)
00041 {
00042     struct sctstr sect;
00043     int nsect;
00044     struct nstr_sect nstr;
00045 
00046     if (!snxtsct(&nstr, player->argp[1]))
00047         return RET_SYN;
00048     prdate();
00049     nsect = 0;
00050     while (nxtsct(&nstr, &sect)) {
00051         if (!player->owner)
00052             continue;
00053         if (nsect++ == 0) {
00054             pr("DISTRIBUTION LEVELS\n");
00055             if (player->god)
00056                 pr("own");
00057             pr("  sect      dst    civ mil  uw food  sh gun pet iron dust bar oil lcm hcm rad\n");
00058         }
00059         if (player->god)
00060             pr("%2d ", sect.sct_own);
00061         prxy("%3d,%-3d", nstr.x, nstr.y, player->cnum);
00062         pr(" %c ", dchr[sect.sct_type].d_mnem);
00063         prxy("%3d,%-3d", sect.sct_dist_x, sect.sct_dist_y, player->cnum);
00064         pr(" %4d", sect.sct_dist[I_CIVIL]);
00065         pr("%4d", sect.sct_dist[I_MILIT]);
00066         pr("%4d", sect.sct_dist[I_UW]);
00067         pr("%5d", sect.sct_dist[I_FOOD]);
00068         pr("%4d", sect.sct_dist[I_SHELL]);
00069         pr("%4d", sect.sct_dist[I_GUN]);
00070         pr("%4d", sect.sct_dist[I_PETROL]);
00071         pr("%5d", sect.sct_dist[I_IRON]);
00072         pr("%5d", sect.sct_dist[I_DUST]);
00073         pr("%4d", sect.sct_dist[I_BAR]);
00074         pr("%4d", sect.sct_dist[I_OIL]);
00075         pr("%4d", sect.sct_dist[I_LCM]);
00076         pr("%4d", sect.sct_dist[I_HCM]);
00077         pr("%4d", sect.sct_dist[I_RAD]);
00078         pr("\n");
00079     }
00080     if (nsect == 0) {
00081         if (player->argp[1])
00082             pr("%s: No sector(s)\n", player->argp[1]);
00083         else
00084             pr("%s: No sector(s)\n", "");
00085         return RET_FAIL;
00086     } else
00087         pr("%d sector%s\n", nsect, splur(nsect));
00088     return 0;
00089 }

Generated on Fri Mar 28 11:01:12 2008 for empserver by  doxygen 1.5.2