/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
- * Ken Stevens, Steve McClure
+ * Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Ken Stevens, Steve McClure, Markus Armbruster
*
- * This program is free software; you can redistribute it and/or modify
+ * Empire 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
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ---
*
* David Muir Sharnoff
* Chad Zabel, 1994
* Steve McClure, 1998-2000
- * Ron Koenderink, 2003-2004
- * Markus Armbruster, 2003-2008
+ * Ron Koenderink, 2003-2009
+ * Markus Armbruster, 2003-2013
*/
#include <config.h>
#include "commands.h"
#include "item.h"
#include "land.h"
-#include "lost.h"
#include "news.h"
#include "optlist.h"
#include "plague.h"
#include "plane.h"
#include "ship.h"
-#define END -1
-
-static void benefit(natid, int);
-static int docountry(char, int, char *, struct natstr *);
-static int doland(char, int, char *, struct sctstr *);
-static int doplane(char, int, char *, struct plnstr *);
-static int doship(char, int, char *, struct shpstr *);
-static int dounit(char, int, char *, struct lndstr *);
+static void print_sect(struct sctstr *);
+static void print_nat(struct natstr *);
+static void print_plane(struct plnstr *);
+static void print_land(struct lndstr *);
+static void print_ship(struct shpstr *);
static int getin(char *, char **);
-static void noise(struct sctstr *, char *, int, int);
-static void pr_land(struct lndstr *);
-static void pr_plane(struct plnstr *);
-static void pr_ship(struct shpstr *);
-static void prnat(struct natstr *);
-static void prsect(struct sctstr *);
-
+static int edit_sect(struct sctstr *, char, int, char *);
+static int edit_nat(struct natstr *, char, int, char *);
+static int edit_ship(struct shpstr *, char, int, char *);
+static int edit_land(struct lndstr *, char, int, char *);
+static int edit_plane(struct plnstr *, char, int, char *);
int
edit(void)
char buf[1024];
char ewhat;
- if ((what = getstarg(player->argp[1],
- "Edit What (country, land, ship, plane, nuke, unit)? ",
- buf)) == 0)
+ what = getstarg(player->argp[1],
+ "Edit what (country, land, ship, plane, nuke, unit)? ",
+ buf);
+ if (!what)
return RET_SYN;
ewhat = what[0];
switch (ewhat) {
pr("huh?\n");
return RET_SYN;
}
- if (player->argp[3] == 0) {
+ if (!player->argp[3]) {
switch (ewhat) {
case 'l':
- prsect(§);
+ print_sect(§);
break;
case 'c':
- prnat(np);
+ print_nat(np);
break;
case 'p':
- pr_plane(&plane);
+ print_plane(&plane);
break;
case 's':
- pr_ship(&ship);
+ print_ship(&ship);
break;
case 'u':
- pr_land(&land);
+ print_land(&land);
break;
}
}
for (;;) {
- if (player->argp[arg_index] != 0) {
- if (player->argp[arg_index+1] != 0) {
+ if (player->argp[arg_index]) {
+ if (player->argp[arg_index+1]) {
thing = player->argp[arg_index++][0];
ptr = player->argp[arg_index++];
arg = atoi(ptr);
if (err == 0) {
switch (ewhat) {
case 'c':
- prnat(np);
+ print_nat(np);
break;
case 'l':
- prsect(§);
+ print_sect(§);
break;
case 's':
- pr_ship(&ship);
+ print_ship(&ship);
break;
case 'u':
- pr_land(&land);
+ print_land(&land);
break;
case 'p':
- pr_plane(&plane);
+ print_plane(&plane);
break;
}
return RET_OK;
switch (ewhat) {
case 'c':
- if ((err = docountry(thing, arg, ptr, np)) != RET_OK)
+ if ((err = edit_nat(np, thing, arg, ptr)) != RET_OK)
return err;
break;
case 'l':
if (!check_sect_ok(§))
return RET_FAIL;
- if ((err = doland(thing, arg, ptr, §)) != RET_OK)
+ if ((err = edit_sect(§, thing, arg, ptr)) != RET_OK)
return err;
if (!putsect(§))
return RET_FAIL;
case 's':
if (!check_ship_ok(&ship))
return RET_FAIL;
- if ((err = doship(thing, arg, ptr, &ship)) != RET_OK)
+ if ((err = edit_ship(&ship, thing, arg, ptr)) != RET_OK)
return err;
if (!ef_ensure_space(EF_SHIP, ship.shp_uid, 50))
return RET_FAIL;
case 'u':
if (!check_land_ok(&land))
return RET_FAIL;
- if ((err = dounit(thing, arg, ptr, &land)) != RET_OK)
+ if ((err = edit_land(&land, thing, arg, ptr)) != RET_OK)
return err;
if (!ef_ensure_space(EF_LAND, land.lnd_uid, 50))
return RET_FAIL;
case 'p':
if (!check_plane_ok(&plane))
return RET_FAIL;
- if ((err = doplane(thing, arg, ptr, &plane)) != RET_OK)
+ if ((err = edit_plane(&plane, thing, arg, ptr)) != RET_OK)
return err;
if (!ef_ensure_space(EF_PLANE, plane.pln_uid, 50))
return RET_FAIL;
}
static void
-prsect(struct sctstr *sect)
+print_sect(struct sctstr *sect)
{
pr("Location <L>: %s\t", xyas(sect->sct_x, sect->sct_y, player->cnum));
pr("Distribution sector <D>: %s\n",
pr("Defense %% <d>: %d\n", sect->sct_defense);
}
-
static void
-prnat(struct natstr *np)
+print_nat(struct natstr *np)
{
int i;
pr("Name <n>: %-20s\t", np->nat_cnam);
pr("Representative <r>: %-20s\n", np->nat_pnam);
pr("BTUs <b>: %3d\t\t\t", np->nat_btu);
- pr("Reserves <m>: %5ld\n", np->nat_reserve);
+ pr("Reserves <m>: %5d\n", np->nat_reserve);
pr("Capital <c>: %s\t\t",
xyas(np->nat_xcap, np->nat_ycap, player->cnum));
pr("Origin <o>: %3s\n",
pr("Research <R>: %.2f\n", np->nat_level[NAT_RLEV]);
pr("Education <E>: %.2f\t\t", np->nat_level[NAT_ELEV]);
pr("Happiness <H>: %.2f\n", np->nat_level[NAT_HLEV]);
- pr("Money <M>: $%6ld\n", np->nat_money);
+ pr("Money <M>: $%6d\n", np->nat_money);
pr("Telegrams <t>: %6d\n", np->nat_tgms);
if (opt_HIDDEN) {
pr("Countries contacted: ");
}
static void
-pr_plane(struct plnstr *plane)
+print_plane(struct plnstr *plane)
{
+ pr("%s %s\n", prnatid(plane->pln_own), prplane(plane));
pr("UID <U>: %d\t\t", plane->pln_uid);
pr("Owner <O>: %d\t\t", plane->pln_own);
pr("Location <l>: %s\n",
}
static void
-pr_land(struct lndstr *land)
+print_land(struct lndstr *land)
{
+ pr("%s %s\n", prnatid(land->lnd_own), prland(land));
pr("UID <U>: %d\n", land->lnd_uid);
pr("Owner <O>: %d\n", land->lnd_own);
pr("Location <L>: %s\n", xyas(land->lnd_x, land->lnd_y, player->cnum));
}
static void
-pr_ship(struct shpstr *ship)
+print_ship(struct shpstr *ship)
{
- struct natstr *natp;
-
- if ((natp = getnatp(ship->shp_own)) == 0)
- return;
- pr("%s (#%d) %s\n", natp->nat_cnam, ship->shp_own, prship(ship));
+ pr("%s %s\n", prnatid(ship->shp_own), prship(ship));
pr("UID <U>: %d\n", ship->shp_uid);
pr("Owner <O>: %d\t\t\t", ship->shp_own);
pr("Location <L>: %s\n", xyas(ship->shp_x, ship->shp_y, player->cnum));
pr("Fleet <F>: %.1s\n", &ship->shp_fleet);
pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
ship->shp_rpath, ship->shp_rflags);
- pr("Plague Stage <a>: %d\t\t",ship->shp_pstage);
+ pr("Plague Stage <a>: %d\t\t", ship->shp_pstage);
pr("Plague Time <b>: %d\n", ship->shp_ptime);
pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
pr(" c m u f s g p i d o l h r\n");
pr("\n");
}
-static int
-errcheck(int num, int min, int max)
-{
- if (num < min)
- return min;
- else if (num > max)
- return max;
- return num;
-}
-
static int
getin(char *buf, char **valp)
{
return thing;
}
+#if 0 /* not needed right now */
static void
warn_deprecated(char key)
{
pr("Key <%c> is deprecated and will go away in a future release\n", key);
}
+#endif
static int
-doland(char op, int arg, char *p, struct sctstr *sect)
+edit_sect(struct sctstr *sect, char op, int arg, char *p)
{
- natid newown, oldown;
coord newx, newy;
- int new, old;
- int des;
+ int new;
+
switch (op) {
case 'o':
- if (arg < 0)
+ if (arg < 0 || arg >= MAXNOC)
return RET_SYN;
- newown = (natid)errcheck(arg, 0, MAXNOC - 1);
- pr("Owner of %s changed from %s (#%d) to %s (#%d).\n",
+ pr("Owner of %s changed from %s to %s.\n",
xyas(sect->sct_x, sect->sct_y, player->cnum),
- cname(sect->sct_own), sect->sct_own, cname(newown), newown);
+ prnatid(sect->sct_own), prnatid(arg));
if (sect->sct_own) {
wu(player->cnum, sect->sct_own,
"Sector %s lost to deity intervention\n",
xyas(sect->sct_x, sect->sct_y, sect->sct_own));
}
benefit(sect->sct_own, 0);
- sect->sct_own = newown;
- if (newown) {
- wu(player->cnum, newown,
+ sect->sct_own = arg;
+ if (arg) {
+ wu(player->cnum, arg,
"Sector %s gained from deity intervention\n",
- xyas(sect->sct_x, sect->sct_y, sect->sct_own));
+ xyas(sect->sct_x, sect->sct_y, arg));
}
- benefit(newown, 1);
+ benefit(arg, 1);
break;
case 'O':
- if (arg < 0)
+ if (arg < 0 || arg >= MAXNOC)
return RET_SYN;
- oldown = (natid)errcheck(arg, 0, MAXNOC - 1);
- pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
+ pr("Old owner of %s changed from %s to %s.\n",
xyas(sect->sct_x, sect->sct_y, player->cnum),
- cname(sect->sct_oldown),
- sect->sct_oldown, cname(oldown), oldown);
- sect->sct_oldown = oldown;
+ prnatid(sect->sct_oldown), prnatid(arg));
+ sect->sct_oldown = arg;
break;
case 'e':
- new = errcheck(arg, 0, 100);
+ new = LIMIT_TO(arg, 0, 100);
noise(sect, "Efficiency", sect->sct_effic, new);
- sect->sct_effic = (unsigned char)new;
+ sect->sct_effic = new;
break;
case 'm':
- new = errcheck(arg, -127, 255);
+ new = LIMIT_TO(arg, -127, 255);
noise(sect, "Mobility", sect->sct_mobil, new);
sect->sct_mobil = new;
break;
case 'i':
- new = errcheck(arg, 0, 127);
+ new = LIMIT_TO(arg, 0, 127);
noise(sect, "Iron ore content", sect->sct_min, new);
sect->sct_min = (unsigned char)new;
break;
case 'g':
- new = errcheck(arg, 0, 127);
+ new = LIMIT_TO(arg, 0, 127);
noise(sect, "Gold content", sect->sct_gmin, new);
sect->sct_gmin = (unsigned char)new;
break;
case 'f':
- new = errcheck(arg, 0, 127);
+ new = LIMIT_TO(arg, 0, 127);
noise(sect, "Fertility", sect->sct_fertil, new);
sect->sct_fertil = (unsigned char)new;
break;
case 'c':
- new = errcheck(arg, 0, 127);
+ new = LIMIT_TO(arg, 0, 127);
noise(sect, "Oil content", sect->sct_oil, new);
sect->sct_oil = (unsigned char)new;
break;
case 'u':
- new = errcheck(arg, 0, 127);
+ new = LIMIT_TO(arg, 0, 127);
noise(sect, "Uranium content", sect->sct_uran, new);
sect->sct_uran = (unsigned char)new;
break;
case 'w':
- new = errcheck(arg, 0, 100);
+ new = LIMIT_TO(arg, 0, 100);
noise(sect, "Workforce percentage", sect->sct_work, new);
sect->sct_work = (unsigned char)new;
break;
case 'l':
- new = errcheck(arg, 0, 127);
- pr("Loyalty of %s changed from %d to %d%%\n",
+ new = LIMIT_TO(arg, 0, 127);
+ pr("Loyalty of %s changed from %d to %d\n",
xyas(sect->sct_x, sect->sct_y, player->cnum),
sect->sct_loyal, new);
sect->sct_loyal = (unsigned char)new;
break;
case 'x':
- old = sect->sct_che;
- new = errcheck(arg, 0, CHE_MAX);
+ new = LIMIT_TO(arg, 0, CHE_MAX);
pr("Guerillas in %s changed from %d to %d\n",
- xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
+ xyas(sect->sct_x, sect->sct_y, player->cnum),
+ sect->sct_che, new);
sect->sct_che = new;
break;
case 'X':
- old = sect->sct_che_target;
- new = errcheck(arg, 0, MAXNOC - 1);
- pr("Che target of %s changed from %s (#%d) to %s (#%d).\n",
+ if (arg < 0 || arg >= MAXNOC)
+ return RET_SYN;
+ pr("Che target of %s changed from %s to %s.\n",
xyas(sect->sct_x, sect->sct_y, player->cnum),
- cname(old), old, cname(new), new);
- sect->sct_che_target = new;
- if (new == 0)
+ prnatid(sect->sct_che_target), prnatid(arg));
+ sect->sct_che_target = arg;
+ if (arg == 0)
sect->sct_che = 0;
break;
case 'p':
- old = sect->sct_pstage;
- new = errcheck(arg, 0, PLG_EXPOSED);
- pr("Plague stage of %s changed from %d to %d%%\n",
- xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
+ new = LIMIT_TO(arg, 0, PLG_EXPOSED);
+ pr("Plague stage of %s changed from %d to %d\n",
+ xyas(sect->sct_x, sect->sct_y, player->cnum),
+ sect->sct_pstage, new);
sect->sct_pstage = new;
break;
case 't':
- old = sect->sct_ptime;
- new = errcheck(arg, 0, 255);
- pr("Plague time of %s changed from %d to %d%%\n",
- xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
+ new = LIMIT_TO(arg, 0, 255);
+ pr("Plague time of %s changed from %d to %d\n",
+ xyas(sect->sct_x, sect->sct_y, player->cnum),
+ sect->sct_ptime, new);
sect->sct_ptime = new;
break;
case 'F':
- old = sect->sct_fallout;
- new = errcheck(arg, 0, FALLOUT_MAX);
+ new = LIMIT_TO(arg, 0, FALLOUT_MAX);
pr("Fallout for sector %s changed from %d to %d\n",
- xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
+ xyas(sect->sct_x, sect->sct_y, player->cnum),
+ sect->sct_fallout, new);
sect->sct_fallout = new;
break;
case 'a':
- new = errcheck(arg, 0, 9999);
+ new = LIMIT_TO(arg, 0, 9999);
noise(sect, "Available workforce", sect->sct_avail, new);
sect->sct_avail = new;
break;
case 'M':
- new = errcheck(arg, 0, MINES_MAX);
+ new = LIMIT_TO(arg, 0, MINES_MAX);
sect->sct_mines = new;
pr("Mines changed to %d\n", new);
break;
case 'D':
if (!sarg_xy(p, &newx, &newy))
return RET_SYN;
- pr("Distribution Location for sector %s changed from %s to %s\n",
+ pr("Distribution location for sector %s changed from %s to %s\n",
xyas(sect->sct_x, sect->sct_y, player->cnum),
xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
xyas(newx, newy, player->cnum));
sect->sct_dist_y = newy;
break;
case 's':
- des = sct_typematch(p);
- if (des < 0)
+ new = sct_typematch(p);
+ if (new < 0)
return RET_SYN;
pr("Designation for sector %s changed from %c to %c\n",
xyas(sect->sct_x, sect->sct_y, player->cnum),
- dchr[sect->sct_type].d_mnem, dchr[des].d_mnem);
- set_coastal(sect, sect->sct_type, des);
- sect->sct_type = des;
+ dchr[sect->sct_type].d_mnem, dchr[new].d_mnem);
+ set_coastal(sect, sect->sct_type, new);
+ sect->sct_type = new;
break;
case 'S':
- des = sct_typematch(p);
- if (des < 0)
+ new = sct_typematch(p);
+ if (new < 0)
return RET_SYN;
- pr("New Designation for sector %s changed from %c to %c\n",
+ pr("New designation for sector %s changed from %c to %c\n",
xyas(sect->sct_x, sect->sct_y, player->cnum),
- dchr[sect->sct_newtype].d_mnem, dchr[des].d_mnem);
- sect->sct_newtype = des;
+ dchr[sect->sct_newtype].d_mnem, dchr[new].d_mnem);
+ sect->sct_newtype = new;
break;
case 'R':
- if (arg > 100)
- arg = 100;
- if (arg < 0)
- arg = 0;
- noise(sect, "Road percentage", sect->sct_road, arg);
- sect->sct_road = arg;
+ new = LIMIT_TO(arg, 0, 100);
+ noise(sect, "Road percentage", sect->sct_road, new);
+ sect->sct_road = new;
break;
case 'r':
- if (arg > 100)
- arg = 100;
- if (arg < 0)
- arg = 0;
- noise(sect, "Rail percentage", sect->sct_rail, arg);
- sect->sct_rail = arg;
+ new = LIMIT_TO(arg, 0, 100);
+ noise(sect, "Rail percentage", sect->sct_rail, new);
+ sect->sct_rail = new;
break;
case 'd':
- if (arg > 100)
- arg = 100;
- if (arg < 0)
- arg = 0;
- noise(sect, "Defense percentage", sect->sct_defense, arg);
- sect->sct_defense = arg;
+ new = LIMIT_TO(arg, 0, 100);
+ noise(sect, "Defense percentage", sect->sct_defense, new);
+ sect->sct_defense = new;
break;
default:
pr("huh? (%c)\n", op);
return RET_OK;
}
-
static int
-docountry(char op, int arg, char *p, struct natstr *np)
+edit_nat(struct natstr *np, char op, int arg, char *p)
{
coord newx, newy;
natid nat = np->nat_cnum;
switch (op) {
case 'n':
+ if (!check_nat_name(p, nat))
+ return RET_SYN;
pr("Country name changed from %s to %s\n", np->nat_cnam, p);
- strncpy(np->nat_cnam, p, sizeof(np->nat_cnam) - 1);
+ strcpy(np->nat_cnam, p);
break;
case 'r':
pr("Country representative changed from %s to %s\n",
np->nat_tgms = arg;
break;
case 'b':
- arg = errcheck(arg, 0, 1024);
+ arg = LIMIT_TO(arg, 0, 1024);
pr("BTU's changed from %d to %d\n", np->nat_btu, arg);
np->nat_btu = arg;
break;
case 'm':
benefit(nat, np->nat_reserve < arg);
- pr("Military Reserves changed from %ld to %d\n",
+ pr("Military reserves changed from %d to %d\n",
np->nat_reserve, arg);
wu(player->cnum, nat,
- "Military Reserves changed from %ld to %d by divine intervention.\n",
+ "Military reserves changed from %d to %d by divine intervention.\n",
np->nat_reserve, arg);
np->nat_reserve = arg;
break;
np->nat_yorg = newy;
break;
case 's':
- np->nat_stat = errcheck(arg, STAT_UNUSED, STAT_GOD);
+ np->nat_stat = LIMIT_TO(arg, STAT_UNUSED, STAT_GOD);
break;
case 'u':
- arg = errcheck(arg, 0, m_m_p_d * 60);
+ arg = LIMIT_TO(arg, 0, m_m_p_d * 60);
pr("Number of seconds used changed from %d to %d.\n",
np->nat_timeused, arg);
np->nat_timeused = arg;
break;
case 'M':
- pr("Money changed from %ld to %d\n", np->nat_money, arg);
+ pr("Money changed from %d to %d\n", np->nat_money, arg);
wu(player->cnum, nat,
- "Money changed from %ld to %d by divine intervention.\n",
+ "Money changed from %d to %d by divine intervention.\n",
np->nat_money, arg);
np->nat_money = arg;
break;
return RET_OK;
}
-
static int
-doship(char op, int arg, char *p, struct shpstr *ship)
+edit_ship(struct shpstr *ship, char op, int arg, char *p)
{
coord newx, newy;
ef_set_uid(EF_SHIP, ship, arg);
break;
case 'O':
+ if (arg < 0 || arg >= MAXNOC)
+ return RET_SYN;
if (ship->shp_own)
wu(player->cnum, ship->shp_own,
"%s taken from you by deity intervention!\n", prship(ship));
- if (arg && arg < MAXNOC) {
+ if (arg)
wu(player->cnum, (natid)arg,
"%s given to you by deity intervention!\n", prship(ship));
- ship->shp_own = (natid)arg;
- } else if (!arg)
- ship->shp_effic = 0;
+ ship->shp_own = arg;
break;
case 'L':
if (!sarg_xy(p, &newx, &newy))
ship->shp_y = newy;
break;
case 'T':
- shp_set_tech(ship,
- errcheck(arg,
- mchr[(int)ship->shp_type].m_tech, SHRT_MAX));
+ arg = LIMIT_TO(arg, mchr[(int)ship->shp_type].m_tech, SHRT_MAX);
+ shp_set_tech(ship, arg);
break;
case 'E':
- ship->shp_effic = errcheck(arg, SHIP_MINEFF, 100);
+ ship->shp_effic = LIMIT_TO(arg, SHIP_MINEFF, 100);
break;
case 'M':
ship->shp_mobil = arg;
break;
- case 'B':
- warn_deprecated(op);
- break;
case 'F':
if (p[0] == '~')
ship->shp_fleet = 0;
}
static int
-dounit(char op, int arg, char *p, struct lndstr *land)
+edit_land(struct lndstr *land, char op, int arg, char *p)
{
coord newx, newy;
ef_set_uid(EF_LAND, land, arg);
break;
case 'O':
+ if (arg < 0 || arg >= MAXNOC)
+ return RET_SYN;
if (land->lnd_own)
wu(player->cnum, land->lnd_own,
"%s taken from you by deity intervention!\n", prland(land));
-
- if (arg && arg < MAXNOC) {
+ if (arg)
wu(player->cnum, (natid)arg,
"%s given to you by deity intervention!\n", prland(land));
- land->lnd_own = (natid)arg;
- } else if (!arg)
- land->lnd_effic = 0;
+ land->lnd_own = arg;
break;
case 'L':
if (!sarg_xy(p, &newx, &newy))
land->lnd_y = newy;
break;
case 'e':
- land->lnd_effic = errcheck(arg, LAND_MINEFF, 100);
+ land->lnd_effic = LIMIT_TO(arg, LAND_MINEFF, 100);
break;
case 'M':
land->lnd_mobil = arg;
break;
case 't':
- lnd_set_tech(land,
- errcheck(arg,
- lchr[(int)land->lnd_type].l_tech, SHRT_MAX));
+ arg = LIMIT_TO(arg, lchr[(int)land->lnd_type].l_tech, SHRT_MAX);
+ lnd_set_tech(land, arg);
break;
case 'a':
if (p[0] == '~')
}
break;
case 'F':
- land->lnd_harden = errcheck(arg, 0, 255);
- break;
- case 'B':
- warn_deprecated(op);
+ land->lnd_harden = LIMIT_TO(arg, 0, 255);
break;
case 'S':
land->lnd_ship = arg;
break;
- case 'P':
- warn_deprecated(op);
- break;
case 'Z':
land->lnd_retreat = arg;
break;
return RET_OK;
}
-
-int
-doplane(char op, int arg, char *p, struct plnstr *plane)
+static int
+edit_plane(struct plnstr *plane, char op, int arg, char *p)
{
coord newx, newy;
switch (op) {
- case 'n':
- warn_deprecated(op);
- break;
case 'U':
ef_set_uid(EF_PLANE, plane, arg);
break;
plane->pln_y = newy;
break;
case 'O':
+ if (arg < 0 || arg >= MAXNOC)
+ return RET_SYN;
if (plane->pln_own)
wu(player->cnum, plane->pln_own,
"%s taken from you by deity intervention!\n",
prplane(plane));
- if (arg && arg < MAXNOC) {
- plane->pln_own = (natid)arg;
- wu(player->cnum, plane->pln_own,
+ if (arg)
+ wu(player->cnum, arg,
"%s given to you by deity intervention!\n", prplane(plane));
- } else if (!arg)
- plane->pln_effic = 0;
+ plane->pln_own = arg;
break;
case 'e':
- plane->pln_effic = errcheck(arg, PLANE_MINEFF, 100);
+ plane->pln_effic = LIMIT_TO(arg, PLANE_MINEFF, 100);
break;
case 'm':
- plane->pln_mobil = errcheck(arg, -127, 255);
+ plane->pln_mobil = LIMIT_TO(arg, -127, 255);
break;
case 't':
- pln_set_tech(plane,
- errcheck(arg,
- plchr[(int)plane->pln_type].pl_tech, SHRT_MAX));
+ arg = LIMIT_TO(arg, plchr[(int)plane->pln_type].pl_tech, SHRT_MAX);
+ pln_set_tech(plane, arg);
break;
case 'w':
if (p[0] == '~')