edit: Factor print_items() out of print_land(), print_ship()

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2017-08-27 12:33:02 +02:00
parent 60429028e7
commit 6e320cc625

View file

@ -31,7 +31,7 @@
* Chad Zabel, 1994 * Chad Zabel, 1994
* Steve McClure, 1998-2000 * Steve McClure, 1998-2000
* Ron Koenderink, 2003-2009 * Ron Koenderink, 2003-2009
* Markus Armbruster, 2003-2016 * Markus Armbruster, 2003-2017
*/ */
#include <config.h> #include <config.h>
@ -264,6 +264,27 @@ print_plane(struct plnstr *plane)
pr("Land Unit <y>: %d\n", plane->pln_land); pr("Land Unit <y>: %d\n", plane->pln_land);
} }
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");
}
static void static void
print_land(struct lndstr *land) print_land(struct lndstr *land)
{ {
@ -282,22 +303,7 @@ print_land(struct lndstr *land)
pr("Retreat percentage <Z>: %d\n", land->lnd_retreat); pr("Retreat percentage <Z>: %d\n", land->lnd_retreat);
pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n", pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
land->lnd_rpath, land->lnd_rflags); land->lnd_rpath, land->lnd_rflags);
pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n"); print_items(land->lnd_item);
pr(" c m u f s g p i d o l h r\n");
pr("%3d", land->lnd_item[I_CIVIL]);
pr("%4d", land->lnd_item[I_MILIT]);
pr("%4d", land->lnd_item[I_UW]);
pr("%5d", land->lnd_item[I_FOOD]);
pr("%4d", land->lnd_item[I_SHELL]);
pr("%4d", land->lnd_item[I_GUN]);
pr("%5d", land->lnd_item[I_PETROL]);
pr("%5d", land->lnd_item[I_IRON]);
pr("%5d", land->lnd_item[I_DUST]);
pr("%5d", land->lnd_item[I_OIL]);
pr("%5d", land->lnd_item[I_LCM]);
pr("%5d", land->lnd_item[I_HCM]);
pr("%4d", land->lnd_item[I_RAD]);
pr("\n");
} }
static void static void
@ -316,22 +322,7 @@ print_ship(struct shpstr *ship)
ship->shp_rpath, ship->shp_rflags); 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("Plague Time <b>: %d\n", ship->shp_ptime);
pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n"); print_items(ship->shp_item);
pr(" c m u f s g p i d o l h r\n");
pr("%3d", ship->shp_item[I_CIVIL]);
pr("%4d", ship->shp_item[I_MILIT]);
pr("%4d", ship->shp_item[I_UW]);
pr("%5d", ship->shp_item[I_FOOD]);
pr("%4d", ship->shp_item[I_SHELL]);
pr("%4d", ship->shp_item[I_GUN]);
pr("%5d", ship->shp_item[I_PETROL]);
pr("%5d", ship->shp_item[I_IRON]);
pr("%5d", ship->shp_item[I_DUST]);
pr("%5d", ship->shp_item[I_OIL]);
pr("%5d", ship->shp_item[I_LCM]);
pr("%5d", ship->shp_item[I_HCM]);
pr("%4d", ship->shp_item[I_RAD]);
pr("\n");
} }
static void static void