2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire 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 3 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, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * stop.c: Stop a sector or unit from producing
29 * Known contributors to this file:
30 * Thomas Ruschak, 1992
32 * Markus Armbruster, 2006-2010
42 static int start_stop(int);
43 static int start_stop_sector(char *, int);
44 static void start_stop_hdr(int);
45 static void proff(int);
46 static int start_stop_unit(int, char *, int);
47 static void start_stop_unit_hdr(int);
64 static int sct_or_unit[] = {
65 EF_SECTOR, EF_SHIP, EF_PLANE, EF_LAND, EF_NUKE, EF_BAD
71 if (player->argp[1] && !isalpha(*player->argp[1])) {
72 /* accept legacy syntax */
74 arg = player->argp[1];
76 p = getstarg(player->argp[1],
77 "Sector, ship, plane, land unit or nuke? ", buf);
80 type = ef_byname_from(p, sct_or_unit);
82 pr("Sectors, ships, planes, land units or nukes only!\n");
85 arg = player->argp[2];
88 if (type == EF_SECTOR)
89 return start_stop_sector(arg, off);
90 return start_stop_unit(type, arg, off);
94 start_stop_sector(char *arg, int off)
98 struct nstr_sect nstr;
100 if (!snxtsct(&nstr, arg))
104 while (nxtsct(&nstr, §)) {
107 if (!sect.sct_off == !off)
112 pr("%3d ", sect.sct_own);
113 prxy("%4d,%-4d", nstr.x, nstr.y);
114 pr(" %c", dchr[sect.sct_type].d_mnem);
115 if (sect.sct_newtype != sect.sct_type)
116 pr("%c", dchr[sect.sct_newtype].d_mnem);
119 pr("%4d%%", sect.sct_effic);
125 pr("%s: No sector(s)\n", arg ? arg : "");
128 pr("%d sector%s\n", nsect, splur(nsect));
133 start_stop_hdr(int off)
137 pr("PRODUCTION %s\n", off ? "STOPPAGE" : "STARTING");
147 pr(" will not produce or gain efficiency.\n");
149 pr(" will be updated normally.\n");
153 start_stop_unit(int type, char *arg, int off)
155 union empobj_storage unit;
157 struct nstr_item nstr;
159 if (!snxtitem(&nstr, type, arg, NULL))
163 while (nxtitem(&nstr, &unit)) {
166 if (!unit.gen.off == !off)
169 start_stop_unit_hdr(off);
171 pr("%3d ", unit.gen.own);
172 pr("%4d %-4.4s ", nstr.cur, empobj_chr_name(&unit.gen));
173 prxy("%4d,%-4d", unit.gen.x, unit.gen.y);
174 pr("%4d%%", unit.gen.effic);
177 ef_write(type, nstr.cur, &unit);
180 pr("%s: No %s(s)\n", arg ? arg : "", ef_nameof(type));
183 pr("%d %s%s\n", nunit, ef_nameof(type), splur(nunit));
188 start_stop_unit_hdr(int off)
192 pr("PRODUCTION %s\n", off ? "STOPPAGE" : "STARTING");