From 6e320cc625838b353ce87374f35c4b08bbf3ca21 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 27 Aug 2017 12:33:02 +0200 Subject: [PATCH] edit: Factor print_items() out of print_land(), print_ship() Signed-off-by: Markus Armbruster --- src/lib/commands/edit.c | 57 +++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index 5c2cb6336..6d60e753c 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -31,7 +31,7 @@ * Chad Zabel, 1994 * Steve McClure, 1998-2000 * Ron Koenderink, 2003-2009 - * Markus Armbruster, 2003-2016 + * Markus Armbruster, 2003-2017 */ #include @@ -264,6 +264,27 @@ print_plane(struct plnstr *plane) pr("Land Unit : %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 print_land(struct lndstr *land) { @@ -282,22 +303,7 @@ print_land(struct lndstr *land) pr("Retreat percentage : %d\n", land->lnd_retreat); pr("Retreat path : '%s'\t\tRetreat Flags : %d\n", land->lnd_rpath, land->lnd_rflags); - 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", 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"); + print_items(land->lnd_item); } static void @@ -316,22 +322,7 @@ print_ship(struct shpstr *ship) ship->shp_rpath, ship->shp_rflags); pr("Plague Stage : %d\t\t", ship->shp_pstage); pr("Plague Time : %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("%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"); + print_items(ship->shp_item); } static void -- 2.43.0