]> git.pond.sub.org Git - empserver/commitdiff
tend: Fail more nicely when target can't take more commodities
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 15 Sep 2017 14:58:10 +0000 (16:58 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 5 Jan 2021 06:25:17 +0000 (07:25 +0100)
We silently ignore target ships that can't take any more of the tended
commodity.  This may leave the player guessing why the command did
nothing.  Report the reason like this:

    cs   cargo ship (#150) can't hold more guns

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/tend.c
tests/load-tend/journal.log

index 516e4861acf72bcccbd7c51fde27443d5d50b01b..d8c14c93d226380a2a0081aced2b52b2e3121664 100644 (file)
@@ -159,6 +159,8 @@ tend(void)
                pr("%s out of %s\n", prship(&tender), ip->i_name);
                break;
            }
+           if (amt < 0 && tender.shp_item[ip->i_uid] == maxtender)
+               break;
        }
        pr("%d total %s transferred %s %s\n",
           total, ip->i_name, (amt > 0) ? "off of" : "to",
@@ -241,11 +243,13 @@ tend_comm_to(struct shpstr *from, struct ichrstr *ip, int amt,
        pr("No %s on %s\n", ip->i_name, prship(from));
        return 0;
     }
+    if (!can_take) {
+       pr("%s can't hold more %s\n", prship(to), ip->i_name);
+       return 0;
+    }
 
     transfer = MIN(can_give, amt);
     transfer = MIN(can_take, transfer);
-    if (transfer == 0)
-       return 0;
     from->shp_item[ip->i_uid] -= transfer;
     to->shp_item[ip->i_uid] += transfer;
     if (to->shp_own != player->cnum) {
index 994002fb36f53f943ca7754fbdecc10c4b29ed67..71733323c55b9800dc7fafc872f2dfd30a4958e7 100644 (file)
     Play#1 output Play#1 1 0 total guns transferred off of cs   cargo ship (#150)
     Play#1 output Play#1 1 5 total guns transferred off of cs   cargo ship (#151)
     Play#1 output Play#1 1 3 total guns transferred off of cs   cargo ship (#152)
+    Play#1 output Play#1 1 cs   cargo ship (#150) can't hold more guns
     Play#1 output Play#1 1 0 total guns transferred off of cs   cargo ship (#153)
+    Play#1 output Play#1 1 cs   cargo ship (#150) can't hold more guns
     Play#1 output Play#1 1 0 total guns transferred off of cs   cargo ship (#154)
     Play#1 output Play#1 6 0 398
     Play#1 input tend g 153 -40 t