/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2018, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
* Chad Zabel, 1994
* Steve McClure, 1998-2000
* Ron Koenderink, 2003-2009
- * Markus Armbruster, 2003-2017
+ * Markus Armbruster, 2003-2018
*/
#include <config.h>
static int edit_nuke(struct nukstr *, char *, char *);
int
-edit(void)
+c_edit(void)
{
union empobj_storage item;
char *what;
static void
print_items(short item[])
{
- 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("%3d", item[I_CIVIL]);
- pr("%4d", item[I_MILIT]);
- pr("%4d", item[I_UW]);
- pr("%5d", item[I_FOOD]);
- pr("%4d", item[I_SHELL]);
- pr("%4d", item[I_GUN]);
- pr("%5d", item[I_PETROL]);
- pr("%5d", item[I_IRON]);
- pr("%5d", item[I_DUST]);
- pr("%5d", item[I_OIL]);
- pr("%5d", item[I_LCM]);
- pr("%5d", item[I_HCM]);
- pr("%4d", item[I_RAD]);
- pr("\n");
+ pr(" civ mil uw food sh gun pet iron dust bar oil lcm hcm rad\n"
+ " c m u f s g p i d B o l h r\n"
+ "%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d\n",
+ item[I_CIVIL],
+ item[I_MILIT],
+ item[I_UW],
+ item[I_FOOD],
+ item[I_SHELL],
+ item[I_GUN],
+ item[I_PETROL],
+ item[I_IRON],
+ item[I_DUST],
+ item[I_BAR],
+ item[I_OIL],
+ item[I_LCM],
+ item[I_HCM],
+ item[I_RAD]);
}
static void
item[ip->i_uid] = arg;
}
+static void
+edit_unit_item(struct empobj *unit, short item[], char *key, int arg,
+ short lim[])
+{
+ char lowkey[2];
+
+ lowkey[0] = tolower(*key);
+ lowkey[1] = 0;
+ edit_item(unit, item, item_by_name(lowkey), arg, lim);
+}
+
static void
limit_item(struct empobj *unit, short item[], short lim[])
{
case 'p':
case 'i':
case 'd':
+ case 'B':
case 'o':
case 'l':
case 'h':
case 'r':
- edit_item((struct empobj *)ship, ship->shp_item, item_by_name(key),
- arg, mcp->m_item);
+ edit_unit_item((struct empobj *)ship, ship->shp_item, key, arg,
+ mcp->m_item);
break;
default:
pr("huh? (%s)\n", key);
break;
case 'F':
arg = LIMIT_TO(arg, 0, 127);
+ if (land->lnd_ship >= 0 || land->lnd_land >= 0)
+ arg = 0;
divine_unit_change((struct empobj *)land, "Fortification",
arg != land->lnd_harden, arg - land->lnd_harden,
"from %d to %d", land->lnd_harden, arg);
case 'p':
case 'i':
case 'd':
+ case 'B':
case 'o':
case 'l':
case 'h':
case 'r':
- edit_item((struct empobj *)land, land->lnd_item, item_by_name(key),
- arg, lcp->l_item);
+ edit_unit_item((struct empobj *)land, land->lnd_item, key, arg,
+ lcp->l_item);
break;
default:
pr("huh? (%s)\n", key);
"from %d to %d", plane->pln_tech, arg);
pln_set_tech(plane, arg);
break;
+ case 'F':
+ arg = LIMIT_TO(arg, 0, 127);
+ if (!(pcp->pl_flags & P_M)
+ || plane->pln_ship >= 0 || plane->pln_land >= 0)
+ arg = 0;
+ divine_unit_change((struct empobj *)plane, "Fortification",
+ arg != plane->pln_harden, arg - plane->pln_harden,
+ "from %d to %d", plane->pln_harden, arg);
+ plane->pln_harden = arg;
+ break;
case 'r':
arg = LIMIT_TO(arg, 0, pl_range(pcp, plane->pln_tech));
divine_unit_change((struct empobj *)plane, "Range",
divine_flag_change((struct empobj *)plane, "Flags",
plane->pln_flags, arg, plane_flags);
plane->pln_flags = arg;
+ if (pln_is_in_orbit(plane))
+ plane->pln_ship = plane->pln_land = -1;
break;
default:
pr("huh? (%s)\n", key);