ltend: Reject zero amount more nicely
Unlike tend, ltend does nothing silently when asked to tend zero commodities. This may leave the player guessing why the command did nothing. Report the reason and fail the command, just like tend does. While there, improve the prompt to match tend's. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
70008c1b9f
commit
7d2c09668c
3 changed files with 19 additions and 6 deletions
|
@ -63,6 +63,7 @@ ltend(void)
|
|||
int transfer;
|
||||
int total;
|
||||
char *p;
|
||||
char prompt[512];
|
||||
char buf[1024];
|
||||
|
||||
if (!(ip = whatitem(player->argp[1], "Transfer what commodity? ")))
|
||||
|
@ -76,12 +77,19 @@ ltend(void)
|
|||
pr("You don't own ship #%d!\n", tender.shp_uid);
|
||||
continue;
|
||||
}
|
||||
if (!(p = getstarg(player->argp[3], "Amount to transfer? ", buf)))
|
||||
sprintf(prompt, "Number of %s to tend from %s? ",
|
||||
ip->i_name, prship(&tender));
|
||||
if (!(p = getstarg(player->argp[3], prompt, buf)))
|
||||
return RET_FAIL;
|
||||
if (!*p)
|
||||
continue;
|
||||
if (!check_ship_ok(&tender))
|
||||
return RET_FAIL;
|
||||
if ((amt = atoi(p)) == 0)
|
||||
break;
|
||||
amt = atoi(p);
|
||||
if (!amt) {
|
||||
pr("Amount must be non-zero!\n");
|
||||
return RET_SYN;
|
||||
}
|
||||
ontender = tender.shp_item[ip->i_uid];
|
||||
if (ontender == 0 && amt > 0) {
|
||||
pr("No %s on %s\n", ip->i_name, prship(&tender));
|
||||
|
|
|
@ -41,7 +41,7 @@ ltend c 200/201 1 350/352
|
|||
ltend h 200/201 1 350/352
|
||||
| zero amount:
|
||||
ltend f 200/201 0 350/351//352
|
||||
| usability: does nothing silently
|
||||
__cmd added 0 -1 0
|
||||
| more than the ship has
|
||||
ltend s 200/201 5 350/351/352
|
||||
| more than the land can hold
|
||||
|
|
|
@ -2572,6 +2572,11 @@
|
|||
Play#1 output Play#1 6 0 368
|
||||
Play#1 input ltend f 200/201 0 350/351//352
|
||||
Play#1 command ltend
|
||||
Play#1 output Play#1 1 Amount must be non-zero!
|
||||
Play#1 output Play#1 1 Usage: ltend <COMM> <tender-SHIPS> <NUM> <UNITS>
|
||||
Play#1 output Play#1 6 0 368
|
||||
Play#1 input __cmd added 0 -1 0
|
||||
Play#1 command __cmd
|
||||
Play#1 output Play#1 6 0 367
|
||||
Play#1 input ltend s 200/201 5 350/351/352
|
||||
Play#1 command ltend
|
||||
|
@ -2647,12 +2652,12 @@
|
|||
Play#1 input f
|
||||
Play#1 output Play#1 4 Tender(s)?
|
||||
Play#1 input 200/201
|
||||
Play#1 output Play#1 4 Amount to transfer?
|
||||
Play#1 output Play#1 4 Number of food to tend from cs cargo ship (#200)?
|
||||
Play#1 input 1
|
||||
Play#1 output Play#1 4 Units to be tended?
|
||||
Play#1 input 350/351
|
||||
Play#1 output Play#1 1 2 total food transferred off of cs cargo ship (#200)
|
||||
Play#1 output Play#1 4 Amount to transfer?
|
||||
Play#1 output Play#1 4 Number of food to tend from cs cargo ship (#201)?
|
||||
Play#1 input -1
|
||||
Play#1 output Play#1 4 Units to be tended?
|
||||
Play#1 input 350
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue