From 70008c1b9f19ae6395616a00e954cfb1db014855 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 15 Sep 2017 16:58:10 +0200 Subject: [PATCH] tend: Fail more nicely when target can't take more commodities 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 --- src/lib/commands/tend.c | 8 ++++++-- tests/load-tend/journal.log | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/commands/tend.c b/src/lib/commands/tend.c index 516e4861..d8c14c93 100644 --- a/src/lib/commands/tend.c +++ b/src/lib/commands/tend.c @@ -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) { diff --git a/tests/load-tend/journal.log b/tests/load-tend/journal.log index 994002fb..71733323 100644 --- a/tests/load-tend/journal.log +++ b/tests/load-tend/journal.log @@ -2250,7 +2250,9 @@ 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