2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * stop.c: Stop a sector or unit from producing
30 * Known contributors to this file:
31 * Thomas Ruschak, 1992
33 * Markus Armbruster, 2006-2009
43 static int start_stop(int);
44 static int start_stop_sector(char *, int);
45 static void start_stop_hdr(int);
46 static void proff(int);
47 static int start_stop_unit(int, char *, int);
48 static void start_stop_unit_hdr(int);
65 static int sct_or_unit[] = {
66 EF_SECTOR, EF_SHIP, EF_PLANE, EF_LAND, EF_NUKE, EF_BAD
72 if (player->argp[1] && !isalpha(*player->argp[1])) {
73 /* accept legacy syntax */
75 arg = player->argp[1];
77 p = getstarg(player->argp[1],
78 "Sector, ship, plane, land unit or nuke? ", buf);
81 type = ef_byname_from(p, sct_or_unit);
83 pr("Sectors, ships, planes, land units or nukes only!\n");
86 arg = player->argp[2];
89 if (type == EF_SECTOR)
90 return start_stop_sector(arg, off);
91 return start_stop_unit(type, arg, off);
95 start_stop_sector(char *arg, int off)
99 struct nstr_sect nstr;
101 if (!snxtsct(&nstr, arg))
105 while (nxtsct(&nstr, §)) {
108 if (!sect.sct_off == !off)
113 pr("%3d ", sect.sct_own);
114 prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
115 pr(" %c", dchr[sect.sct_type].d_mnem);
116 if (sect.sct_newtype != sect.sct_type)
117 pr("%c", dchr[sect.sct_newtype].d_mnem);
120 pr("%4d%%", sect.sct_effic);
126 pr("%s: No sector(s)\n", arg ? arg : "");
129 pr("%d sector%s\n", nsect, splur(nsect));
134 start_stop_hdr(int off)
138 pr("PRODUCTION %s\n", off ? "STOPPAGE" : "STARTING");
148 pr(" will not produce or gain efficiency.\n");
150 pr(" will be updated normally.\n");
154 start_stop_unit(int type, char *arg, int off)
156 union empobj_storage unit;
158 struct nstr_item nstr;
160 if (!snxtitem(&nstr, type, arg, NULL))
164 while (nxtitem(&nstr, &unit)) {
167 if (!unit.gen.off == !off)
170 start_stop_unit_hdr(off);
172 pr("%3d ", unit.gen.own);
173 pr("%4d %-4.4s ", nstr.cur, empobj_chr_name(&unit.gen));
174 prxy("%4d,%-4d", unit.gen.x, unit.gen.y, player->cnum);
175 pr("%4d%%", unit.gen.effic);
178 ef_write(type, nstr.cur, &unit);
181 pr("%s: No %s(s)\n", arg ? arg : "", ef_nameof(type));
184 pr("%d %s%s\n", nunit, ef_nameof(type), splur(nunit));
189 start_stop_unit_hdr(int off)
193 pr("PRODUCTION %s\n", off ? "STOPPAGE" : "STARTING");