]> git.pond.sub.org Git - empserver/commitdiff
unload lunload: Fail early when carrier can't carry land units
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 17 Sep 2017 04:53:37 +0000 (06:53 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 5 Jan 2021 06:25:18 +0000 (07:25 +0100)
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>
src/lib/commands/load.c
tests/load-tend/01-load-1
tests/load-tend/journal.log

index 3fc96ba153c00f38e9600c9217216177d2cf3ff0..56001d486eee0f37e199e6e8fc44a35efe142aae 100644 (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? ",
index 92f4c42ddab01a0cfe25be45868afeb7c0acdd7e..8aa01eead9680942f229aaf6cac15e4bbee8b981 100644 (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
index 826e0f21c074dbdd9160c2b61d198252cbf77029..3be7b4613e97e7eafcb291967ac32479d6757134 100644 (file)
     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
     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