2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2006, 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
56 static int start_stop(int);
57 static int start_stop_sector(char *, int);
58 static void start_stop_hdr(int);
59 static void proff(int);
60 static int start_stop_unit(int, char *, int);
61 static void start_stop_unit_hdr(int);
62 static char *unit_type_name(union item_u *);
79 static int sct_or_unit[] = {
80 EF_SECTOR, EF_SHIP, EF_PLANE, EF_LAND, EF_NUKE, EF_BAD
86 if (player->argp[1] && !isalpha(*player->argp[1])) {
87 /* accept legacy syntax */
89 arg = player->argp[1];
91 p = getstarg(player->argp[1],
92 "Sector, ship, plane, land unit or nuke? ", buf);
95 type = ef_byname_from(p, sct_or_unit);
97 pr("Sectors, ships, planes, land units or nukes only!\n");
100 arg = player->argp[2];
103 if (type == EF_SECTOR)
104 return start_stop_sector(arg, off);
105 return start_stop_unit(type, arg, off);
109 start_stop_sector(char *arg, int off)
113 struct nstr_sect nstr;
115 if (!snxtsct(&nstr, arg))
119 while (nxtsct(&nstr, §)) {
122 if (!sect.sct_off == !off)
127 pr("%3d ", sect.sct_own);
128 prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
129 pr(" %c", dchr[sect.sct_type].d_mnem);
130 if (sect.sct_newtype != sect.sct_type)
131 pr("%c", dchr[sect.sct_newtype].d_mnem);
134 pr("%4d%%", sect.sct_effic);
140 pr("%s: No sector(s)\n", arg ? arg : "");
143 pr("%d sector%s\n", nsect, splur(nsect));
148 start_stop_hdr(int off)
152 pr("PRODUCTION %s\n", off ? "STOPPAGE" : "STARTING");
162 pr(" will not produce or gain efficiency.\n");
164 pr(" will be updated normally.\n");
168 start_stop_unit(int type, char *arg, int off)
172 struct nstr_item nstr;
174 if (!snxtitem(&nstr, type, arg))
178 while (nxtitem(&nstr, &unit)) {
181 if (!unit.gen.off == !off)
184 start_stop_unit_hdr(off);
186 pr("%3d ", unit.gen.own);
187 pr("%4d %-4.4s ", nstr.cur, unit_type_name(&unit));
188 prxy("%4d,%-4d", unit.gen.x, unit.gen.y, player->cnum);
189 pr("%4d%%", unit.gen.effic);
192 ef_write(type, nstr.cur, &unit);
195 pr("%s: No %s(s)\n", arg ? arg : "", ef_nameof(type));
198 pr("%d %s%s\n", nunit, ef_nameof(type), splur(nunit));
203 start_stop_unit_hdr(int off)
207 pr("PRODUCTION %s\n", off ? "STOPPAGE" : "STARTING");
214 unit_type_name(union item_u *unit)
216 int type = unit->gen.type;
218 switch (unit->gen.ef_type) {
220 return mchr[type].m_name;
222 return plchr[type].pl_name;
224 return lchr[type].l_name;
226 return nchr[type].n_name;