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:
Markus Armbruster 2006-05-29 21:11:14 +00:00
parent 520446ef39
commit eb1512d75f
22 changed files with 218 additions and 179 deletions

View file

@ -50,6 +50,7 @@ struct genitem {
signed char type;
signed char effic;
signed char mobil;
unsigned char off;
short tech;
char group;
coord opx, opy;

View file

@ -57,6 +57,7 @@ struct lndstr {
signed char lnd_type; /* index in lchr[] */
signed char lnd_effic; /* 0% to 100% */
signed char lnd_mobil; /* mobility units */
unsigned char lnd_off; /* repairs stopped? */
short lnd_tech; /* tech level ship was built at */
char lnd_army; /* group membership */
coord lnd_opx, lnd_opy; /* Op sector coords */

View file

@ -46,6 +46,7 @@ struct nukstr {
signed char nuk_type; /* index in plchr[] */
signed char nuk_effic; /* unused, always 100% */
signed char nuk_mobil; /* unused, always 0 */
unsigned char nuk_off; /* repairs stopped? (unused) */
short nuk_tech; /* nuke's tech level */
char nuk_stockpile; /* group membership, unused */
coord nuk_opx, nuk_opy; /* Op sector coords, unused */

View file

@ -42,10 +42,6 @@
#define N_MAXPLANE 40
#define PLANE_MINEFF 10
/*
* some routines assume that from pln_x to pln_wing remains
* exactly equivalent with shp_x to shp_fleet
*/
struct plnstr {
/* initial part must match struct genitem */
short ef_type;
@ -56,6 +52,7 @@ struct plnstr {
signed char pln_type; /* index in plchr[] */
signed char pln_effic; /* actually "training" */
signed char pln_mobil; /* plane mobility */
unsigned char pln_off; /* repairs stopped? */
short pln_tech; /* plane's tech level */
char pln_wing; /* like fleet */
coord pln_opx; /* Op sector coords */

View file

@ -69,6 +69,7 @@ struct shpstr {
signed char shp_type; /* index in mchr[] */
signed char shp_effic; /* 0% to 100% */
signed char shp_mobil; /* mobility units */
unsigned char shp_off; /* repairs stopped? */
short shp_tech; /* tech level ship was built at */
char shp_fleet; /* group membership */
coord shp_opx, shp_opy; /* Op sector coords */

View file

@ -6,10 +6,10 @@ The land unit report command is a census of your land units. For
example:
.EX land *
.NF
# unit type x,y a eff mil frt mu fd tch retr rd xl ln carry
0 cav cavalry 1,-1 100% 10 0 127 12 992 75% 3 0 0
1 cav cavalry 0,0 100% 0 0 127 12 968 75% 3 0 0
2 cav cavalry 0,0 100% 10 0 127 12 40 75% 3 0 0
# unit type x,y a eff mil frt mu fd tch retr rd xl ln carry
0 cav cavalry 1,-1 100% 10 0 127 12 992 75% 3 0 0
1 cav cavalry 0,0 100% 0 0 127 12 968 75% 3 0 0
2 cav cavalry 0,0 100% 10 0 127 12 40 75% 3 0 0
3 units
.FI
.s1
@ -25,7 +25,7 @@ the land unit's current location,
.L a
the army designation letter (set by \*Qarmy\*U command),
.L eff
the land unit's efficiency,
the land unit's efficiency, prefixed by \*Q=\*U if stopped,
.L mil
the number of mil currently in the land unit,
.L frt

View file

@ -2,13 +2,12 @@
.NA nuke "Report status of nukes"
.LV Expert
.SY "nuke <NUKES>"
The nuke report command is a census of your nuke and lists all the
info available in readable format. For example:
The nuke report command is a census of your nukes. For example:
.EX nuke *
.NF
# nuke type x,y s eff tech carry burst
0 10kt fission -24,-4 100% 296 19P air
2 15kt fission -19,-1 100% 296
# nuke type x,y s eff tech carry burst
0 10kt fission -24,-4 100% 296 19P air
2 15kt fission -19,-1 100% 296
2 nukes
.FI
.s1
@ -24,13 +23,13 @@ the nuke's current location,
.L s
the \*Qstockpile\*U designation letter,
.L eff
the nuke's efficiency,
the nuke's efficiency, prefixed by \*Q=\*U if stopped,
.L tech
the tech level at which it was created,
.L carry
the plane the nuke is on, if any,
.L burst
whether the nuke is programmed to air- or groundburst.
whether the nuke is programmed for air or ground burst.
.in
.s1
.SA "arm, build, launch, transport, Planes"

View file

@ -2,14 +2,14 @@
.NA plane "Report status of planes"
.LV Basic
.SY "plane <PLANES>"
The plane report command is a census of your planes and lists all the
information available in readable format. For example:
The plane report command is a census of your planes and lists. For
example:
.EX plane *
.NF
# type x,y w eff mu def tech ran hard carry special
0 f2 P-51 Mustang 1,-1 100% 90 5 110 11 0
1 f2 P-51 Mustang 1,-1 100% 90 5 110 11 0
3 lb TBD-1 Devastato 1,-1 100% 90 4 120 11 0
# type x,y w eff mu def tech ran hard carry special
0 f2 P-51 Mustang 1,-1 100% 90 5 110 11 0
1 f2 P-51 Mustang 1,-1 100% 90 5 110 11 0
3 lb TBD-1 Devastato 1,-1 100% 90 4 120 11 0
3 planes
.FI
.s1
@ -21,11 +21,11 @@ the plane number
.L type
the type of plane; \*Qfighter 1\*U, \*Qjet hvy bomber\*U, etc.,
.L x,y
the plane's current location
the plane's current location,
.L w
the \*Qair wing\*U designation letter (set by \*Qwingadd\*U command),
.L eff
the plane's efficiency,
the plane's efficiency, prefixed by \*Q=\*U if stopped,
.L mu
the number of mobility points the plane has,
.L def
@ -35,7 +35,7 @@ the tech level at which it was created,
.L range
and the range (in sectors) it can fly in one sortie,
.L carry
the ship or land unit the plane is on
the ship or land unit the carrying the plane, if any,
.L special
shows \*Qorbit\*U or \*Qgeosync\*U for satellites in (geo-synchronous)
orbit, else nuclear armament type and programming (\*QA\*U for

View file

@ -5,9 +5,9 @@
The ship report command is a census of your ships. For example:
.EX ship *
.NF
shp# ship type x,y fl eff civ mil uw fd pn he xl ln mob tech
0 dd destroyer 1,1 100% 0 0 0 0 0 0 0 0 127 140
1 bb battleship 1,1 100% 0 0 0 0 0 0 0 0 120 200
shp# ship type x,y fl eff civ mil uw fd pn he xl ln mob tech
0 dd destroyer 1,1 100% 0 0 0 0 0 0 0 0 127 140
1 bb battleship 1,1 100% 0 0 0 0 0 0 0 0 120 200
2 ships
.FI
.s1
@ -23,7 +23,7 @@ the ship's current location,
.L flt
the fleet designation letter (set by \*Qfleetadd\*U command),
.L eff
the ship's efficiency,
the ship's efficiency, prefixed by \*Q=\*U if stopped,
.L civ
the number of civilians on board,
.L mil

View file

@ -1,11 +1,10 @@
.TH Command START
.NA start "Turn sector production on"
.NA start "Resume production and repairs"
.LV Basic
.SY "start <SECTS>"
The start command orders a sector to start producing for an update.
This counteracts the stop command.
.SY "start <TYPE> <SECTS|SHIPS|PLANES|UNITS|NUKES>"
The start command orders stopped production and repairs to resume.
.s1
.EX start 2,0
.EX start se 2,0
.NF
Wed Jan 20 21:37:22 1993
PRODUCTION STARTING

View file

@ -1,15 +1,23 @@
.TH Command STOP
.NA stop "Stop sector production"
.NA stop "Stop production and repairs"
.LV Expert
.SY "stop <SECTS>"
The stop command orders a sector to stop producing for an update.
After the update, the sector will return to normal.
.SY "stop <TYPE> <SECTS|SHIPS|PLANES|UNITS|NUKES>"
The stop command stops production and repairs for one update.
.s1
The sector will still distribute, etc, but will not gain in efficiency or
produce anything. Ships, planes, and units in the sector will
not gain efficiency.
Stopped sectors don't gain in efficiency, don't produce anything, and
don't work on ships, planes or units there, but otherwise function
normally: they still pay tax, distribute goods and so forth.
.s1
.EX stop 2,0
Stopping ships, planes and land units works just the same: they don't
gain in efficiency, they don't produce anything (if applicable), and
they don't work on embarked land units or planes.
.s1
Stopping nukes doesn't do anything in particular, right now.
.s1
Conquering a sector stops it automatically. Stop orders expire at the
update. Use the start command to countermand them manually.
.s1
.EX stop se 2,0
.NF
Wed Jan 20 21:35:34 1993
PRODUCTION STOPPAGE

View file

@ -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);

View file

@ -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",

View file

@ -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);

View file

@ -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]);

View file

@ -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, &sect)) {
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(&sect);
}
}
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");
}

View file

@ -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, &sect)) {
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(&sect);
}
proff(off);
sect.sct_off = off;
putsect(&sect);
}
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 "?";
}

View file

@ -196,6 +196,7 @@ struct castr dchr_ca[] = {
{ NSC_TYPEID, 0, 0, fldoff(genitem, type), "type", ef_chr}, \
{ NSC_CHAR, 0, 0, fldoff(genitem, effic), "effic", EF_BAD}, \
{ NSC_CHAR , 0, 0, fldoff(genitem, mobil), "mobil", EF_BAD}, \
{ NSC_UCHAR , 0, 0, fldoff(genitem, off), "off", EF_BAD}, \
{ NSC_SHORT, 0, 0, fldoff(genitem, tech), "tech", EF_BAD}, \
{ NSC_STRINGY, NSC_EXTRA, 1, fldoff(genitem, group), "group", EF_BAD}, \
{ NSC_XCOORD, 0, 0, fldoff(genitem, opx), "opx", EF_BAD}, \

View file

@ -237,9 +237,9 @@ struct cmndstr player_coms[] = {
{"sorder <SHIPS>", 0, sorde, C_MOD, NORM + CAP},
{"spy <SECTS>", 1, spy, C_MOD, NORM + CAP},
{"sstat <SHIPS>", 0, sstat, 0, NORM},
{"start <SECTS>", 1, start, C_MOD, NORM + CAP},
{"start <TYPE> <SECTS|PLANES|SHIPS|UNITS>", 1, start, C_MOD, NORM + CAP},
{"starvation [<SECTS>|l <UNITS>|s <SHIPS>]", 0, starve, 0, NORM},
{"stop <SECTS>", 1, stop, C_MOD, NORM + CAP},
{"stop <TYPE> <SECTS|PLANES|SHIPS|UNITS>", 1, stop, C_MOD, NORM + CAP},
{"strength <SECTS>", 1, stre, C_MOD, NORM},
{"supply <LAND UNITS>", 1, supp, C_MOD, NORM + CAP},
{"survey <SELECTOR> <SECTS>", 0, surv, 0, NORM + CAP},

View file

@ -132,8 +132,9 @@ upd_land(struct lndstr *lp, int etus,
lcp = &lchr[(int)lp->lnd_type];
if (build == 1) {
if (np->nat_money >= 0)
if (!lp->lnd_off && np->nat_money >= 0)
landrepair(lp, np, bp, etus);
lp->lnd_off = 0;
} else {
mult = 1;
if (np->nat_level[NAT_TLEV] < lp->lnd_tech * 0.85)

View file

@ -102,8 +102,9 @@ upd_plane(struct plnstr *pp, int etus,
int mult, cost, eff;
if (build == 1) {
if (np->nat_money >= 0)
if (!pp->pln_off && np->nat_money >= 0)
planerepair(pp, np, bp, etus);
pp->pln_off = 0;
} else {
mult = 1;
if (np->nat_level[NAT_TLEV] < pp->pln_tech * 0.85)
@ -151,6 +152,8 @@ planerepair(struct plnstr *pp, struct natstr *np, int *bp, int etus)
if (pp->pln_effic >= 80)
return;
carrier = getshipp(pp->pln_ship);
if (carrier->shp_off)
return;
if (CANT_HAPPEN(!carrier || carrier->shp_own != pp->pln_own))
return;
}

View file

@ -136,8 +136,9 @@ upd_ship(struct shpstr *sp, int etus,
mp = &mchr[(int)sp->shp_type];
if (build == 1) {
if (np->nat_money >= 0)
if (!sp->shp_off && np->nat_money >= 0)
shiprepair(sp, np, bp, etus);
sp->shp_off = 0;
} else {
mult = 1;
if (np->nat_level[NAT_TLEV] < sp->shp_tech * 0.85)