]> git.pond.sub.org Git - empserver/commitdiff
tend ltend: Reject foreign tenders and land units more nicely
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 13 Sep 2017 16:41:00 +0000 (18:41 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 5 Jan 2021 06:25:17 +0000 (07:25 +0100)
We silently ignore foreign ships and land units.  This may leave the
player guessing why the command did nothing.  Report explicitly named
ones like this

    You don't own ship #160!

except for tend's target ships.  Nice reporting is a bit more involved
there, because you can tend to foreign target ships as long as they're
friendly.  Left for later.

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

index a770f4c4ccda5a7e77a976bcbef942eb1da7b4c1..f5df960d6e2f3e85af67d62233a967b5269286b2 100644 (file)
@@ -71,8 +71,11 @@ ltend(void)
     if (!snxtitem(&tenders, EF_SHIP, player->argp[2], "Tender(s)? "))
        return RET_SYN;
     while (nxtitem(&tenders, &tender)) {
-       if (!player->owner)
+       if (!player->owner) {
+           if (tenders.sel == NS_LIST)
+               pr("You don't own ship #%d!\n", tender.shp_uid);
            continue;
+       }
        if (!(p = getstarg(player->argp[3], "Amount to transfer? ", buf)))
            return RET_FAIL;
        if (!check_ship_ok(&tender))
@@ -98,8 +101,11 @@ ltend(void)
            return RET_FAIL;
        total = 0;
        while (nxtitem(&targets, &target)) {
-           if (!player->owner)
+           if (!player->owner) {
+               if (targets.sel == NS_LIST)
+                   pr("You don't own land unit #%d!\n", target.lnd_uid);
                continue;
+           }
            if (target.lnd_ship != tender.shp_uid) {
                if (targets.sel == NS_LIST)
                    pr("%s is not on %s!\n",
index a8d9c4b44108ccd45a9a8ecc4ae9f98fec9c92ad..25a054dc5c2f807310e40298b353cf007b571af0 100644 (file)
@@ -84,8 +84,11 @@ tend(void)
        return RET_SYN;
 
     while (nxtitem(&tenders, &tender)) {
-       if (!player->owner)
+       if (!player->owner) {
+           if (tenders.sel == NS_LIST)
+               pr("You don't own ship #%d!\n", tender.shp_uid);
            continue;
+       }
        if (type == EF_LAND) {
            sprintf(prompt, "Land unit(s) to tend from %s? ",
                    prship(&tender));
@@ -214,8 +217,11 @@ tend_land(struct shpstr *tenderp, char *units)
        return RET_SYN;
 
     while (nxtitem(&lni, &land)) {
-       if (!player->owner)
+       if (!player->owner) {
+           if (lni.sel == NS_LIST)
+               pr("You don't own land unit #%d!\n", land.lnd_uid);
            continue;
+       }
        if (land.lnd_ship != tenderp->shp_uid) {
            if (lni.sel == NS_LIST)
                pr("%s is not on %s!\n", prland(&land), prship(tenderp));
index 9d012e0f7f696849da373cfa54a27605a2e57b2c..c51b8d81955f9e43358fa41d39732376e580c0fd 100644 (file)
@@ -31,7 +31,6 @@ tend f -1
 tend f n
 | foreign tender
 tend f 160/162/163/164
-| usability: does nothing silently
 | invalid amount
 | impossible, as crap is mapped to zero
 | invalid target
@@ -129,7 +128,6 @@ f
 tend land -1
 | foreign tender
 tend land 160/162/163/164
-| usability: does nothing silently
 | invalid land
 tend land 150 -1
 | invalid target
index 987a54c4497dd8bbf3fb3701c9c75bb8d1b6656b..bc0bb0f7fa5aed76064a31d11d477b0e893afa51 100644 (file)
@@ -20,7 +20,6 @@ ltend f -1
 ltend f n
 | foreign tender
 ltend f 212
-| usability: does nothing silently
 | invalid amount
 | impossible, as crap is mapped to zero
 | invalid target
index c1d558b32ce4ded526acd51155de9258c37ebc87..c5f61807d0230d8c093e3c68bd3d08584d3b0496 100644 (file)
     Play#1 output Play#1 6 0 423
     Play#1 input tend f 160/162/163/164
     Play#1 command tend
+    Play#1 output Play#1 1 You don't own ship #160!
+    Play#1 output Play#1 1 You don't own ship #162!
+    Play#1 output Play#1 1 You don't own ship #163!
+    Play#1 output Play#1 1 You don't own ship #164!
     Play#1 output Play#1 6 0 422
     Play#1 input tend f 150 1 -1
     Play#1 command tend
     Play#1 output Play#1 6 0 409
     Play#1 input tend f 160/162/163/164 -1 166
     Play#1 command tend
+    Play#1 output Play#1 1 You don't own ship #160!
+    Play#1 output Play#1 1 You don't own ship #162!
+    Play#1 output Play#1 1 You don't own ship #163!
+    Play#1 output Play#1 1 You don't own ship #164!
     Play#1 output Play#1 6 0 408
     Play#1 input tend f 166 -1 160/162/163/164
     Play#1 command tend
     Play#1 output Play#1 6 0 396
     Play#1 input tend land 160/162/163/164
     Play#1 command tend
+    Play#1 output Play#1 1 You don't own ship #160!
+    Play#1 output Play#1 1 You don't own ship #162!
+    Play#1 output Play#1 1 You don't own ship #163!
+    Play#1 output Play#1 1 You don't own ship #164!
     Play#1 output Play#1 6 0 395
     Play#1 input tend land 150 -1
     Play#1 command tend
     Play#1 output Play#1 6 0 376
     Play#1 input ltend f 212
     Play#1 command ltend
+    Play#1 output Play#1 1 You don't own ship #212!
     Play#1 output Play#1 6 0 375
     Play#1 input tend f 200 1 -1
     Play#1 command tend
     Play#1 output Play#1 6 0 373
     Play#1 input ltend f 200 1 26
     Play#1 command ltend
+    Play#1 output Play#1 1 You don't own land unit #26!
     Play#1 output Play#1 1 0 total food transferred off of cs   cargo ship (#200)
     Play#1 output Play#1 6 0 372
     Play#1 input ltend f 200 1 0