Let players stop/start units:
(genitem, lndstr, nukstr, plnstr, shpstr): New members off, lnd_off, nuk_off, pln_off, shp_off. (NSC_GENITEM): New selector off. (land, nuke, plan, shi): Display efficiency prefixed by `=' when off. (start, stop, player_coms): Rewrite, new syntax. Print only objects that actually change. (start_hdr, stop_hdr, start_stop_hdr): Consolidate. (item_u, start_stop, start_stop_sector, proff, start_stop_unit) (start_stop_unit_hdr, unit_type_name): New. (upd_land, upd_plane, planerepair, upd_ship): Obey and clear stoppage.
This commit is contained in:
parent
520446ef39
commit
eb1512d75f
22 changed files with 218 additions and 179 deletions
|
@ -64,7 +64,7 @@ land(void)
|
|||
if (nunits++ == 0) {
|
||||
if (player->god)
|
||||
pr("own ");
|
||||
pr(" # unit type x,y a eff mil frt mu fd");
|
||||
pr(" # unit type x,y a eff mil frt mu fd");
|
||||
if (opt_FUEL)
|
||||
pr(" fl");
|
||||
pr(" tch retr rd xl ln carry\n");
|
||||
|
@ -75,7 +75,7 @@ land(void)
|
|||
pr("%-15.15s", lchr[(int)land.lnd_type].l_name);
|
||||
prxy(" %4d,%-4d", land.lnd_x, land.lnd_y, player->cnum);
|
||||
pr("%1.1s", &land.lnd_army);
|
||||
pr("%4d%%", land.lnd_effic);
|
||||
pr(" %c%3d%%", land.lnd_off ? '=' : ' ', land.lnd_effic);
|
||||
pr("%4d", land.lnd_item[I_MILIT]);
|
||||
pr("%4d", land.lnd_harden);
|
||||
pr("%4d", land.lnd_mobil);
|
||||
|
|
|
@ -61,14 +61,15 @@ nuke(void)
|
|||
if (nnukes++ == 0) {
|
||||
if (player->god)
|
||||
pr("own ");
|
||||
pr(" # nuke type x,y s eff tech carry burst\n");
|
||||
pr(" # nuke type x,y s eff tech carry burst\n");
|
||||
}
|
||||
if (player->god)
|
||||
pr("%-3d ", nuk.nuk_own);
|
||||
pr("%4d %-19.19s ", nstr.cur, nchr[(int)nuk.nuk_type].n_name);
|
||||
prxy("%4d,%-4d", nuk.nuk_x, nuk.nuk_y, player->cnum);
|
||||
pr(" %1.1s %3d%% %4d",
|
||||
&nuk.nuk_stockpile, nuk.nuk_effic, nuk.nuk_tech);
|
||||
pr(" %1.1s %c%3d%% %4d",
|
||||
&nuk.nuk_stockpile, nuk.nuk_off ? '=' : ' ', nuk.nuk_effic,
|
||||
nuk.nuk_tech);
|
||||
if (nuk.nuk_plane >= 0) {
|
||||
getplane(nuk.nuk_plane, &plane);
|
||||
pr("%5dP %s",
|
||||
|
|
|
@ -60,15 +60,15 @@ plan(void)
|
|||
if (nplanes++ == 0) {
|
||||
if (player->god)
|
||||
pr("own ");
|
||||
pr(" # type x,y w eff mu def tech ran hard carry special\n");
|
||||
pr(" # type x,y w eff mu def tech ran hard carry special\n");
|
||||
}
|
||||
if (player->god)
|
||||
pr("%3d ", plane.pln_own);
|
||||
pr("%4d %-19.19s ", np.cur, plchr[(int)plane.pln_type].pl_name);
|
||||
prxy("%4d,%-4d", plane.pln_x, plane.pln_y, player->cnum);
|
||||
pr(" %1.1s %3d%% %3d %3d %4d %3d %3d",
|
||||
&plane.pln_wing, plane.pln_effic, plane.pln_mobil,
|
||||
plane.pln_def, plane.pln_tech,
|
||||
pr(" %1.1s %c%3d%% %3d %3d %4d %3d %3d",
|
||||
&plane.pln_wing, plane.pln_off ? '=' : ' ', plane.pln_effic,
|
||||
plane.pln_mobil, plane.pln_def, plane.pln_tech,
|
||||
plane.pln_range, plane.pln_harden);
|
||||
if (plane.pln_ship >= 0)
|
||||
pr("%5dS", plane.pln_ship);
|
||||
|
|
|
@ -61,11 +61,8 @@ shi(void)
|
|||
if (nships++ == 0) {
|
||||
if (player->god)
|
||||
pr("own ");
|
||||
pr("shp# ship type x,y fl eff civ mil uw fd pn");
|
||||
pr(" he");
|
||||
pr(" xl");
|
||||
pr(" ln");
|
||||
pr(" mob");
|
||||
pr("shp# ship type x,y fl eff civ mil uw fd pn"
|
||||
" he xl ln mob");
|
||||
if (opt_FUEL)
|
||||
pr(" fuel");
|
||||
pr(" tech\n");
|
||||
|
@ -76,7 +73,7 @@ shi(void)
|
|||
pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
|
||||
prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
|
||||
pr("%1.1s", &ship.shp_fleet);
|
||||
pr("%4d%%", ship.shp_effic);
|
||||
pr(" %c%3d%%", ship.shp_off ? '=' : ' ', ship.shp_effic);
|
||||
|
||||
pr("%4d", ship.shp_item[I_CIVIL]);
|
||||
pr("%4d", ship.shp_item[I_MILIT]);
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
* Empire - A multi-player, client/server Internet based war game.
|
||||
* Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
|
||||
* Ken Stevens, Steve McClure
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* ---
|
||||
*
|
||||
* See files README, COPYING and CREDITS in the root of the source
|
||||
* tree for related information and legal notices. It is expected
|
||||
* that future projects/authors will amend these files as needed.
|
||||
*
|
||||
* ---
|
||||
*
|
||||
* star.c: Start a sector producing
|
||||
*
|
||||
* Known contributors to this file:
|
||||
* Thomas Ruschak, 1992
|
||||
* Steve McClure, 1998
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "misc.h"
|
||||
#include "player.h"
|
||||
#include "xy.h"
|
||||
#include "sect.h"
|
||||
#include "nsc.h"
|
||||
#include "nat.h"
|
||||
#include "path.h"
|
||||
#include "file.h"
|
||||
#include "commands.h"
|
||||
|
||||
static void start_hdr(void);
|
||||
|
||||
int
|
||||
start(void)
|
||||
{
|
||||
struct sctstr sect;
|
||||
int nsect;
|
||||
struct nstr_sect nstr;
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
prdate();
|
||||
nsect = 0;
|
||||
while (nxtsct(&nstr, §)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
if (nsect++ == 0)
|
||||
start_hdr();
|
||||
if (player->god)
|
||||
pr("%3d ", sect.sct_own);
|
||||
prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
|
||||
pr(" %c", dchr[sect.sct_type].d_mnem);
|
||||
if (sect.sct_newtype != sect.sct_type)
|
||||
pr("%c", dchr[sect.sct_newtype].d_mnem);
|
||||
else
|
||||
pr(" ");
|
||||
pr("%4d%%", sect.sct_effic);
|
||||
|
||||
pr(" will be updated normally.\n");
|
||||
if (sect.sct_off != 0) {
|
||||
sect.sct_off = 0;
|
||||
putsect(§);
|
||||
}
|
||||
}
|
||||
if (nsect == 0) {
|
||||
if (player->argp[1])
|
||||
pr("%s: No sector(s)\n", player->argp[1]);
|
||||
else
|
||||
pr("%s: No sector(s)\n", "");
|
||||
return RET_FAIL;
|
||||
} else
|
||||
pr("%d sector%s\n", nsect, splur(nsect));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
start_hdr(void)
|
||||
{
|
||||
if (player->god)
|
||||
pr(" ");
|
||||
pr("PRODUCTION STARTING\n");
|
||||
if (player->god)
|
||||
pr("own ");
|
||||
pr(" sect eff\n");
|
||||
}
|
|
@ -25,11 +25,12 @@
|
|||
*
|
||||
* ---
|
||||
*
|
||||
* stop.c: Stop a sector from producing
|
||||
* stop.c: Stop a sector or unit from producing
|
||||
*
|
||||
* Known contributors to this file:
|
||||
* Thomas Ruschak, 1992
|
||||
* Steve McClure, 1998
|
||||
* Markus Armbruster, 2006
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -44,24 +45,84 @@
|
|||
#include "file.h"
|
||||
#include "commands.h"
|
||||
|
||||
static void stop_hdr(void);
|
||||
union item_u {
|
||||
struct genitem gen;
|
||||
struct shpstr ship;
|
||||
struct plnstr plane;
|
||||
struct lndstr land;
|
||||
struct nukstr nuke;
|
||||
};
|
||||
|
||||
static int start_stop(int);
|
||||
static int start_stop_sector(char *, int);
|
||||
static void start_stop_hdr(int);
|
||||
static void proff(int);
|
||||
static int start_stop_unit(int, char *, int);
|
||||
static void start_stop_unit_hdr(int);
|
||||
static char *unit_type_name(union item_u *);
|
||||
|
||||
int
|
||||
start(void)
|
||||
{
|
||||
return start_stop(0);
|
||||
}
|
||||
|
||||
int
|
||||
stop(void)
|
||||
{
|
||||
return start_stop(1);
|
||||
}
|
||||
|
||||
static int
|
||||
start_stop(int off)
|
||||
{
|
||||
static int sct_or_unit[] = {
|
||||
EF_SECTOR, EF_SHIP, EF_PLANE, EF_LAND, EF_NUKE, EF_BAD
|
||||
};
|
||||
int type;
|
||||
char *arg, *p;
|
||||
char buf[1024];
|
||||
|
||||
if (player->argp[1] && !isalpha(*player->argp[1])) {
|
||||
/* accept legacy syntax */
|
||||
type = EF_SECTOR;
|
||||
arg = player->argp[1];
|
||||
} else {
|
||||
p = getstarg(player->argp[1],
|
||||
"Sector, ship, plane, land unit or nuke? ", buf);
|
||||
if (p == 0)
|
||||
return RET_SYN;
|
||||
type = ef_byname_from(p, sct_or_unit);
|
||||
if (type < 0) {
|
||||
pr("Sectors, ships, planes, land units or nukes only!");
|
||||
return RET_SYN;
|
||||
}
|
||||
arg = player->argp[2];
|
||||
}
|
||||
|
||||
if (type == EF_SECTOR)
|
||||
return start_stop_sector(arg, off);
|
||||
return start_stop_unit(type, arg, off);
|
||||
}
|
||||
|
||||
static int
|
||||
start_stop_sector(char *arg, int off)
|
||||
{
|
||||
struct sctstr sect;
|
||||
int nsect;
|
||||
struct nstr_sect nstr;
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
if (!snxtsct(&nstr, arg))
|
||||
return RET_SYN;
|
||||
prdate();
|
||||
nsect = 0;
|
||||
while (nxtsct(&nstr, §)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
if (!sect.sct_off == !off)
|
||||
continue;
|
||||
if (nsect++ == 0)
|
||||
stop_hdr();
|
||||
start_stop_hdr(off);
|
||||
if (player->god)
|
||||
pr("%3d ", sect.sct_own);
|
||||
prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
|
||||
|
@ -71,18 +132,12 @@ stop(void)
|
|||
else
|
||||
pr(" ");
|
||||
pr("%4d%%", sect.sct_effic);
|
||||
|
||||
pr(" will not produce or gain efficiency.\n");
|
||||
if (sect.sct_off != 1) {
|
||||
sect.sct_off = 1;
|
||||
putsect(§);
|
||||
}
|
||||
proff(off);
|
||||
sect.sct_off = off;
|
||||
putsect(§);
|
||||
}
|
||||
if (nsect == 0) {
|
||||
if (player->argp[1])
|
||||
pr("%s: No sector(s)\n", player->argp[1]);
|
||||
else
|
||||
pr("%s: No sector(s)\n", "");
|
||||
pr("%s: No sector(s)\n", arg ? arg : "");
|
||||
return RET_FAIL;
|
||||
} else
|
||||
pr("%d sector%s\n", nsect, splur(nsect));
|
||||
|
@ -90,12 +145,86 @@ stop(void)
|
|||
}
|
||||
|
||||
static void
|
||||
stop_hdr(void)
|
||||
start_stop_hdr(int off)
|
||||
{
|
||||
if (player->god)
|
||||
pr(" ");
|
||||
pr("PRODUCTION STOPPAGE\n");
|
||||
pr("PRODUCTION %s\n", off ? "STOPPAGE" : "STARTING");
|
||||
if (player->god)
|
||||
pr("own ");
|
||||
pr(" sect eff\n");
|
||||
}
|
||||
|
||||
static void
|
||||
proff(int off)
|
||||
{
|
||||
if (off)
|
||||
pr(" will not produce or gain efficiency.\n");
|
||||
else
|
||||
pr(" will be updated normally.\n");
|
||||
}
|
||||
|
||||
static int
|
||||
start_stop_unit(int type, char *arg, int off)
|
||||
{
|
||||
union item_u unit;
|
||||
int nunit;
|
||||
struct nstr_item nstr;
|
||||
|
||||
if (!snxtitem(&nstr, type, arg))
|
||||
return RET_SYN;
|
||||
prdate();
|
||||
nunit = 0;
|
||||
while (nxtitem(&nstr, &unit)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
if (!unit.gen.off == !off)
|
||||
continue;
|
||||
if (nunit++ == 0)
|
||||
start_stop_unit_hdr(off);
|
||||
if (player->god)
|
||||
pr("%3d ", unit.gen.own);
|
||||
pr("%4d %-4.4s ", nstr.cur, unit_type_name(&unit));
|
||||
prxy("%4d,%-4d", unit.gen.x, unit.gen.y, player->cnum);
|
||||
pr("%4d%%", unit.gen.effic);
|
||||
proff(off);
|
||||
unit.gen.off = off;
|
||||
ef_write(type, nstr.cur, &unit);
|
||||
}
|
||||
if (nunit == 0) {
|
||||
pr("%s: No %s(s)\n", arg ? arg : "", ef_nameof(type));
|
||||
return RET_FAIL;
|
||||
} else
|
||||
pr("%d %s%s\n", nunit, ef_nameof(type), splur(nunit));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
start_stop_unit_hdr(int off)
|
||||
{
|
||||
if (player->god)
|
||||
pr(" ");
|
||||
pr("PRODUCTION %s\n", off ? "STOPPAGE" : "STARTING");
|
||||
if (player->god)
|
||||
pr("own ");
|
||||
pr(" # x,y eff\n");
|
||||
}
|
||||
|
||||
static char *
|
||||
unit_type_name(union item_u *unit)
|
||||
{
|
||||
int type = unit->gen.type;
|
||||
|
||||
switch (unit->gen.ef_type) {
|
||||
case EF_SHIP:
|
||||
return mchr[type].m_name;
|
||||
case EF_PLANE:
|
||||
return plchr[type].pl_name;
|
||||
case EF_LAND:
|
||||
return lchr[type].l_name;
|
||||
case EF_NUKE:
|
||||
return nchr[type].n_name;
|
||||
}
|
||||
CANT_REACH();
|
||||
return "?";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue