From: Markus Armbruster Date: Sun, 17 Sep 2017 04:53:37 +0000 (+0200) Subject: unload lunload: Fail early when carrier can't carry land units X-Git-Tag: v4.4.1~177 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=585e9540cee72f89eef87f3043a9ec9ad29bc43b unload lunload: Fail early when carrier can't carry land units Attempting to unload land units from a carrier that can't carry any prompts for land units to unload, while attempting to unload planes or load land units or planes fails without prompting. Fix this inconsistency by making unload and lunload fail early for land units, just like they do for planes. Signed-off-by: Markus Armbruster --- diff --git a/src/lib/commands/load.c b/src/lib/commands/load.c index 3fc96ba15..56001d486 100644 --- a/src/lib/commands/load.c +++ b/src/lib/commands/load.c @@ -494,6 +494,12 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy, char buf[1024]; int load_spy = 0; + if (!mchr[(int)sp->shp_type].m_nland + && !(mchr[sp->shp_type].m_flags & M_SUB)) { + if (noisy) + pr("%s cannot carry land units!\n", prship(sp)); + return 0; + } if (loading) { if ((mchr[(int)sp->shp_type].m_flags & M_SUB) && (mchr[(int)sp->shp_type].m_nland == 0)) { @@ -506,11 +512,8 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy, } if (!load_spy && shp_nland(sp) >= mchr[sp->shp_type].m_nland) { if (noisy) { - if (mchr[(int)sp->shp_type].m_nland) - pr("%s doesn't have room for any more land units!\n", - prship(sp)); - else - pr("%s cannot carry land units!\n", prship(sp)); + pr("%s doesn't have room for any more land units!\n", + prship(sp)); } return 0; } @@ -874,14 +877,15 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy, char prompt[512]; char buf[1024]; + if (!lchr[lp->lnd_type].l_nland) { + if (noisy) + pr("%s cannot carry land units!\n", prland(lp)); + return 0; + } if (loading && lnd_nland(lp) >= lchr[lp->lnd_type].l_nland) { - if (noisy) { - if (lchr[lp->lnd_type].l_nland) - pr("%s doesn't have room for any more land units!\n", - prland(lp)); - else - pr("%s cannot carry land units!\n", prland(lp)); - } + if (noisy) + pr("%s doesn't have room for any more land units!\n", + prland(lp)); return 0; } sprintf(prompt, "Land unit(s) to %s %s? ", diff --git a/tests/load-tend/01-load-1 b/tests/load-tend/01-load-1 index 92f4c42dd..8aa01eead 100644 --- a/tests/load-tend/01-load-1 +++ b/tests/load-tend/01-load-1 @@ -520,8 +520,6 @@ unload land b B | not capable load land 25 unload land 25 -* -| odd: prompts for lands, unlike unload plane | no room load land 115 | @@ -577,8 +575,6 @@ lunload land b D | not capable lload land 0 lunload land 0 -* -| odd: prompts for lands, unlike unload plane | while on a ship or land | TODO need a non-heavy land that can carry lands to test this | no room diff --git a/tests/load-tend/journal.log b/tests/load-tend/journal.log index 826e0f21c..3be7b4613 100644 --- a/tests/load-tend/journal.log +++ b/tests/load-tend/journal.log @@ -1705,8 +1705,7 @@ Play#1 output Play#1 6 0 456 Play#1 input unload land 25 Play#1 command unload - Play#1 output Play#1 4 Land unit(s) to unload from fb fishing boat (#25)? - Play#1 input * + Play#1 output Play#1 1 fb fishing boat (#25) cannot carry land units! Play#1 output Play#1 1 No ships affected Play#1 output Play#1 6 0 455 Play#1 input load land 115 @@ -1843,8 +1842,7 @@ Play#1 output Play#1 6 0 434 Play#1 input lunload land 0 Play#1 command lunload - Play#1 output Play#1 4 Land unit(s) to unload from linf light infantry #0? - Play#1 input * + Play#1 output Play#1 1 linf light infantry #0 cannot carry land units! Play#1 output Play#1 1 No units affected Play#1 output Play#1 6 0 433 Play#1 input lload land 115