From 29a6baca6d58fde2ceff0ad485085d0d209f4b9c Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 27 Sep 2009 15:07:57 -0400 Subject: [PATCH] Simplify plane selection for drop, fly, recon and sweep Plane flying commands first select the planes to fly the mission and their escorts, then equip them. They all fail when no planes to fly the mission can be equipped. Unlike bomb and paradrop, commands drop, fly, recon and sweep had an additional check that made them fail when no planes to fly the mission could be selected. Because "none selected" implies "none equipped", the additional check is redundant. Remove it. While there, break lines in calls of pln_sel() more tastefully. --- src/lib/commands/bomb.c | 8 ++++---- src/lib/commands/drop.c | 12 ++++-------- src/lib/commands/fly.c | 12 ++++-------- src/lib/commands/para.c | 8 ++++---- src/lib/commands/reco.c | 13 +++++-------- 5 files changed, 21 insertions(+), 32 deletions(-) diff --git a/src/lib/commands/bomb.c b/src/lib/commands/bomb.c index 387b3f24..2a8bbeb2 100644 --- a/src/lib/commands/bomb.c +++ b/src/lib/commands/bomb.c @@ -126,10 +126,10 @@ bomb(void) /* * select planes within range */ - pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, - 2, P_B | P_T, P_M | P_O); - pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, - 2, P_ESC | P_F, P_M | P_O); + pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, 2, + P_B | P_T, P_M | P_O); + pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 2, + P_ESC | P_F, P_M | P_O); /* * now arm and equip the bombers, transports, whatever. */ diff --git a/src/lib/commands/drop.c b/src/lib/commands/drop.c index 308fa8e2..3bcf2c79 100644 --- a/src/lib/commands/drop.c +++ b/src/lib/commands/drop.c @@ -99,14 +99,10 @@ drop(void) /* * select planes within range */ - pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, - 2, wantflags, P_M | P_O); - if (QEMPTY(&bomb_list)) { - pr("No planes could be equipped for the mission.\n"); - return RET_FAIL; - } - pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, - 2, P_ESC | P_F, P_M | P_O); + pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, 2, + wantflags, P_M | P_O); + pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 2, + P_ESC | P_F, P_M | P_O); /* * now arm and equip the bombers, transports, whatever. */ diff --git a/src/lib/commands/fly.c b/src/lib/commands/fly.c index 297b3898..0fb78467 100644 --- a/src/lib/commands/fly.c +++ b/src/lib/commands/fly.c @@ -94,14 +94,10 @@ fly(void) /* * select planes within range */ - pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, - 1, wantflags, P_M | P_O); - if (QEMPTY(&bomb_list)) { - pr("No planes could be equipped for the mission.\n"); - return RET_FAIL; - } - pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, - 1, wantflags | P_ESC | P_F, P_M | P_O); + pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, 1, + wantflags, P_M | P_O); + pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 1, + wantflags | P_ESC | P_F, P_M | P_O); if (cno >= 0 && !pln_oneway_to_carrier_ok(&bomb_list, &esc_list, cno)) { pr("Not enough room on ship #%d!\n", cno); return RET_FAIL; diff --git a/src/lib/commands/para.c b/src/lib/commands/para.c index bb2e952d..33faa339 100644 --- a/src/lib/commands/para.c +++ b/src/lib/commands/para.c @@ -85,10 +85,10 @@ para(void) /* * select planes within range */ - pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, - 2, P_P | P_C, P_M | P_O); - pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, - 2, P_ESC | P_F, P_M | P_O); + pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, 2, + P_P | P_C, P_M | P_O); + pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 2, + P_ESC | P_F, P_M | P_O); /* * now arm and equip the bombers, transports, whatever. */ diff --git a/src/lib/commands/reco.c b/src/lib/commands/reco.c index 17163286..3f6b044f 100644 --- a/src/lib/commands/reco.c +++ b/src/lib/commands/reco.c @@ -81,14 +81,11 @@ reco(void) /* * select planes within range */ - pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, - 1, wantflags | (mission_flags & PM_S ? P_SWEEP : 0), P_M | P_O); - if (QEMPTY(&bomb_list)) { - pr("No planes could be equipped for the mission.\n"); - return RET_FAIL; - } - pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, - 1, wantflags | P_ESC | P_F, P_M | P_O); + pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, 1, + wantflags | (mission_flags & PM_S ? P_SWEEP : 0), + P_M | P_O); + pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, 1, + wantflags | P_ESC | P_F, P_M | P_O); if (cno >= 0 && !pln_oneway_to_carrier_ok(&bomb_list, &esc_list, cno)) { pr("Not enough room on ship #%d!\n", cno); return RET_FAIL;