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 <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2017-09-17 06:53:37 +02:00
parent 8de59d0014
commit 585e9540ce
3 changed files with 18 additions and 20 deletions

View file

@ -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? ",

View file

@ -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

View file

@ -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