2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2021, 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-2013
41 static int start_stop(int);
42 static int start_stop_sector(char *, int);
43 static void start_stop_hdr(int);
44 static void proff(int);
45 static int start_stop_unit(int, char *, int);
46 static void start_stop_unit_hdr(int);
63 static int sct_or_unit[] = {
64 EF_SECTOR, EF_SHIP, EF_PLANE, EF_LAND, EF_NUKE, EF_BAD
70 if (player->argp[1] && !isalpha(*player->argp[1])) {
71 /* accept legacy syntax */
73 arg = player->argp[1];
75 p = getstarg(player->argp[1],
76 "Sector, ship, plane, land unit or nuke? ", buf);
79 type = ef_byname_from(p, sct_or_unit);
81 pr("Sectors, ships, planes, land units or nukes only!\n");
84 arg = player->argp[2];
87 if (type == EF_SECTOR)
88 return start_stop_sector(arg, off);
89 return start_stop_unit(type, arg, off);
93 start_stop_sector(char *arg, int off)
97 struct nstr_sect nstr;
99 if (!snxtsct(&nstr, arg))
103 while (nxtsct(&nstr, §)) {
106 if (!sect.sct_off == !off)
111 pr("%3d ", sect.sct_own);
112 prxy("%4d,%-4d", nstr.x, nstr.y);
113 pr(" %c", dchr[sect.sct_type].d_mnem);
114 if (sect.sct_newtype != sect.sct_type)
115 pr("%c", dchr[sect.sct_newtype].d_mnem);
118 pr("%4d%%", sect.sct_effic);
124 pr("%s: No sector(s)\n", arg ? arg : "");
127 pr("%d sector%s\n", nsect, splur(nsect));
132 start_stop_hdr(int off)
136 pr("PRODUCTION %s\n", off ? "STOPPAGE" : "STARTING");
146 pr(" will not produce or gain efficiency.\n");
148 pr(" will be updated normally.\n");
152 start_stop_unit(int type, char *arg, int off)
154 union empobj_storage unit;
156 struct nstr_item nstr;
158 if (!snxtitem(&nstr, type, arg, NULL))
162 while (nxtitem(&nstr, &unit)) {
163 if (!player->owner || !unit.gen.own)
165 if (!unit.gen.off == !off)
168 start_stop_unit_hdr(off);
170 pr("%3d ", unit.gen.own);
171 pr("%4d %-4.4s ", nstr.cur, empobj_chr_name(&unit.gen));
172 prxy("%4d,%-4d", unit.gen.x, unit.gen.y);
173 pr("%4d%%", unit.gen.effic);
176 ef_write(type, nstr.cur, &unit);
179 pr("%s: No %s(s)\n", arg ? arg : "", ef_nameof(type));
182 pr("%d %s%s\n", nunit, ef_nameof(type), splur(nunit));
187 start_stop_unit_hdr(int off)
191 pr("PRODUCTION %s\n", off ? "STOPPAGE" : "STARTING");