]> git.pond.sub.org Git - empserver/commitdiff
tend ltend: Fix to skip dead ships and land units for deities
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 15 Sep 2017 07:49:01 +0000 (09:49 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 5 Jan 2021 06:25:17 +0000 (07:25 +0100)
Tending to a dead ship destroys, and tending from a dead ship revives.
Has always been that way.  Not actually a problem for ltend anymore,
because the dead can't carry or be carried since commit 64a53c90f0,
v4.3.17.

Fix by checking !own in addition to !player->owner

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

index 0825ab73974841741abe469b9c1d0b3e73a7ece8..03eac0354a08eb59fdcb4d5c395142dd6f01271b 100644 (file)
@@ -71,7 +71,7 @@ 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 || !tender.shp_own) {
            if (tenders.sel == NS_LIST)
                pr("You don't own ship #%d!\n", tender.shp_uid);
            continue;
@@ -100,7 +100,7 @@ ltend(void)
            return RET_FAIL;
        total = 0;
        while (nxtitem(&targets, &target)) {
-           if (!player->owner) {
+           if (!player->owner || !target.lnd_own) {
                if (targets.sel == NS_LIST)
                    pr("You don't own land unit #%d!\n", target.lnd_uid);
                continue;
index f88db9a64ffc89fba36c071eb6116debf6478c2d..a009c6597ca438dce2a5f32b62f57a5ff850f14f 100644 (file)
@@ -85,7 +85,7 @@ tend(void)
        return RET_SYN;
 
     while (nxtitem(&tenders, &tender)) {
-       if (!player->owner) {
+       if (!player->owner || !tender.shp_own) {
            if (tenders.sel == NS_LIST)
                pr("You don't own ship #%d!\n", tender.shp_uid);
            continue;
@@ -195,6 +195,8 @@ tend(void)
 static int
 can_tend_to(struct shpstr *from, struct shpstr *to)
 {
+    if (!to->shp_own)
+       return 0;
     if (to->shp_own != player->cnum && !player->god
        && relations_with(to->shp_own, player->cnum) < FRIENDLY)
        return 0;
@@ -227,7 +229,7 @@ tend_land(struct shpstr *tenderp, char *units)
        return RET_SYN;
 
     while (nxtitem(&lni, &land)) {
-       if (!player->owner) {
+       if (!player->owner || !land.lnd_own) {
            if (lni.sel == NS_LIST)
                pr("You don't own land unit #%d!\n", land.lnd_uid);
            continue;
index 027349a268ccb1862cad8f8e5223c364f460ae7f..7ae28331e4ad16cbac0cce31e5551362f14180f5 100644 (file)
@@ -7,7 +7,6 @@
 | #160 unowned, #164 neutral to #166: #164 works
 tend m 160/164 1 166
 tend f 166 1 160/164
-| BUG: #160 works
 | same for civilians doesn't work
 tend c 160/164 1 166
 tend c 166 1 160/164
@@ -17,4 +16,3 @@ tend c 166 1 160/164
 tend land 163/164 313/314 166
 | #160 unowned
 tend land 162 312 160
-| BUG: tend to unowned works, and destroys
index 8d55fe0004deaa273dafbf9dd09687e3e97208be..a70d137af5c0a5b85881d4f8060f1972f9eb242e 100644 (file)
@@ -97,12 +97,12 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius fleet civil
 152 1 1 -1 2 100 90 0 145 1 -1 none 0 "t" 22 22 0 39 0 0 0 0 20 0 0 0 18 0 healthy 0 0 "" 0 0 1 () ""
 153 1 1 -1 2 100 90 0 145 1 -1 none 0 "t" 22 22 0 50 0 0 0 0 21 0 0 0 18 0 healthy 0 0 "" 0 0 1 () ""
 154 1 1 -1 2 100 90 0 145 1 -1 none 0 "t" 22 22 0 42 0 0 0 0 19 0 0 0 18 0 healthy 0 0 "" 0 0 1 () ""
-160 0 0 -2 2 0 0 0 145 0 -2 none 0 "u" 20 19 7 42 0 0 0 0 21 0 0 0 20 0 healthy 0 0 "" 0 0 1 () ""
+160 0 0 -2 2 0 0 0 145 0 -2 none 0 "u" 20 20 7 42 0 0 0 0 20 0 0 0 20 0 healthy 0 0 "" 0 0 1 () ""
 162 2 0 -2 2 100 90 0 145 0 -2 none 0 "u" 20 20 7 42 0 0 0 0 25 0 0 0 20 0 healthy 0 0 "" 0 0 1 () ""
 163 3 0 -2 2 100 90 0 145 0 -2 none 0 "u" 20 20 7 42 0 0 0 0 25 0 0 0 20 0 healthy 0 0 "" 0 0 1 () ""
 164 4 0 -2 2 100 90 0 145 0 -2 none 0 "u" 20 19 7 42 0 0 0 0 21 0 0 0 20 0 healthy 0 0 "" 0 0 1 () ""
 165 1 1 -1 23 100 90 0 145 1 -1 none 0 "" 0 20 7 1 0 0 0 0 20 0 0 0 0 0 healthy 0 0 "" 0 0 1 () ""
-166 1 0 -2 2 100 90 0 145 0 -2 none 0 "" 20 22 7 42 0 0 0 0 8 0 0 0 20 0 healthy 0 0 "" 0 0 1 () ""
+166 1 0 -2 2 100 90 0 145 0 -2 none 0 "" 20 21 7 42 0 0 0 0 9 0 0 0 20 0 healthy 0 0 "" 0 0 1 () ""
 170 1 1 -1 6 100 90 0 145 1 -1 none 0 "" 0 20 7 2 0 0 0 0 20 0 0 0 0 0 healthy 0 0 "" 0 0 1 () ""
 171 1 1 -1 18 100 90 0 145 1 -1 none 0 "" 0 20 7 2 0 0 0 0 20 0 0 0 0 0 healthy 0 0 "" 0 0 1 () ""
 172 1 1 -1 2 100 90 0 145 1 -1 none 0 "" 0 20 7 2 0 0 0 0 20 0 0 0 0 0 healthy 0 0 "" 0 0 1 () ""
@@ -452,7 +452,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h
 302 1 1 -1 1 100 60 0 50 1 -1 none 0 "t" 170 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 303 1 1 -1 1 100 60 0 50 1 -1 none 0 "t" 153 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 304 1 1 -1 13 100 60 0 100 1 -1 none 0 "t" 154 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-312 0 0 -2 1 0 60 0 50 0 0 none 0 "" -1 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
+312 2 0 -2 1 100 60 0 50 0 -2 none 0 "u" 162 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 313 1 0 -2 1 100 60 0 50 0 0 none 0 "" 166 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 314 1 0 -2 1 100 60 0 50 0 0 none 0 "" 166 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
 315 1 1 -1 1 100 60 0 40 1 -1 none 0 "" 165 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
@@ -539,7 +539,6 @@ timestamp owner type id x y
 0 1 3 331 0 -2
 0 3 3 313 0 -2
 0 4 3 314 0 -2
-0 2 3 312 0 -2
 /config
 config realm
 cnum realm xl xh yl yh
index 82658f9dd80ac40b85c01891c112ca59e941cc65..d46a85a322ce2e123acc2c61903de555d6327430 100644 (file)
     Play#0 output Play#0 6 0 640
     Play#0 input tend m 160/164 1 166
     Play#0 command tend
-    Play#0 output Play#0 1 1 total military transferred off of cs   cargo ship (#160)
+    Play#0 output Play#0 1 You don't own ship #160!
     Play#0 output Play#0 1 1 total military transferred off of cs   cargo ship (#164)
     Play#0 output Play#0 6 0 639
     Play#0 input tend f 166 1 160/164
     Play#0 command tend
-    Play#0 output Play#0 1 2 total food transferred off of cs   cargo ship (#166)
+    Play#0 output Play#0 1 1 total food transferred off of cs   cargo ship (#166)
     Play#0 output Play#0 6 0 638
     Play#0 input tend c 160/164 1 166
     Play#0 command tend
-    Play#0 output Play#0 1 0 total civilians transferred off of cs   cargo ship (#160)
+    Play#0 output Play#0 1 You don't own ship #160!
     Play#0 output Play#0 1 0 total civilians transferred off of cs   cargo ship (#164)
     Play#0 output Play#0 6 0 637
     Play#0 input tend c 166 1 160/164
     Play#0 output Play#0 6 0 635
     Play#0 input tend land 162 312 160
     Play#0 command tend
-    Play#0 output Play#0 1 linf light infantry #312 transferred from cs   cargo ship (#162) to cs   cargo ship (#160)
     Play#0 output Play#0 6 0 634
     Play#0 input ctld
     Play#0 output Play#0 1 Bye-bye
     Play#0 output Play#0 6 0 640
     Play#0 input ltend m 160 1 310
     Play#0 command ltend
-    Play#0 output Play#0 1 cav  cavalry #310 is not on cs   cargo ship (#160)!
-    Play#0 output Play#0 1 0 total military transferred off of cs   cargo ship (#160)
+    Play#0 output Play#0 1 You don't own ship #160!
     Play#0 output Play#0 6 0 639
     Play#0 input ltend m 200 1 350
     Play#0 command ltend
     Play#0 output Play#0 1   1  152 cs   cargo ship     1,-1   t  100%  22  22  18  20  0  0  0  0  90  145
     Play#0 output Play#0 1   1  153 cs   cargo ship     1,-1   t  100%  22  22  18  21  0  0  0  1  90  145
     Play#0 output Play#0 1   1  154 cs   cargo ship     1,-1   t  100%  22  22  18  19  0  0  0  1  90  145
-    Play#0 output Play#0 1   2  162 cs   cargo ship     0,-2   u  100%  20  20  20  25  0  0  0  1  90  145
+    Play#0 output Play#0 1   2  162 cs   cargo ship     0,-2   u  100%  20  20  20  25  0  0  0  2  90  145
     Play#0 output Play#0 1   3  163 cs   cargo ship     0,-2   u  100%  20  20  20  25  0  0  0  1  90  145
     Play#0 output Play#0 1   4  164 cs   cargo ship     0,-2   u  100%  20  19  20  21  0  0  0  0  90  145
     Play#0 output Play#0 1   1  165 ls   landing shi    1,-1      100%   0  20   0  20  0  0  0  3  90  145
-    Play#0 output Play#0 1   1  166 cs   cargo ship     0,-2      100%  20  22  20   8  0  0  0  2  90  145
+    Play#0 output Play#0 1   1  166 cs   cargo ship     0,-2      100%  20  21  20   9  0  0  0  2  90  145
     Play#0 output Play#0 1   1  170 frg  frigate        1,-1      100%   0  20   0  20  0  0  0  2  90  145
     Play#0 output Play#0 1   1  171 sb   submarine      1,-1      100%   0  20   0  20  0  0  0  1  90  145
     Play#0 output Play#0 1   1  172 cs   cargo ship     1,-1      100%   0  20   0  20  0  0  0  1  90  145
     Play#0 output Play#0 1  163 cs      0,-2   u 100%  20  20  20   7  42   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  164 cs      0,-2   u 100%  20  19  20   7  42   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  165 ls      1,-1     100%   0  20   0   7   1   0   0   0   0   0   0   0   0
-    Play#0 output Play#0 1  166 cs      0,-2     100%  20  22  20   7  42   0   0   0   0   0   0   0   0
+    Play#0 output Play#0 1  166 cs      0,-2     100%  20  21  20   7  42   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  170 frg     1,-1     100%   0  20   0   7   2   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  171 sb      1,-1     100%   0  20   0   7   2   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  172 cs      1,-1     100%   0  20   0   7   2   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1   1  302 linf light infa    1,-1   t  100%   0   0  60   0  50  42%  0  0  170S
     Play#0 output Play#0 1   1  303 linf light infa    1,-1   t  100%   0   0  60   0  50  42%  0  0  153S
     Play#0 output Play#0 1   1  304 hat  hvy artill    1,-1   t  100%   0   0  60   0 100  42%  0  0  154S
+    Play#0 output Play#0 1   2  312 linf light infa    0,-2   u  100%   0   0  60   0  50  42%  0  0  162S
     Play#0 output Play#0 1   1  313 linf light infa    0,-2      100%   0   0  60   0  50  42%  0  0  166S
     Play#0 output Play#0 1   1  314 linf light infa    0,-2      100%   0   0  60   0  50  42%  0  0  166S
     Play#0 output Play#0 1   1  315 linf light infa    1,-1      100%   0   0  60   0  40  42%  0  0  165S
     Play#0 output Play#0 1   1  350 sup  supply        1,-1      100%   1   0  60   1  50  42%  0  0  200S
     Play#0 output Play#0 1   1  351 sup  supply        1,-1      100%  20   0  60   1  50  42%  0  0  200S
     Play#0 output Play#0 1   1  352 sup  supply        1,-1      100%   0   0  60   0  50  42%  0  0  201S
-    Play#0 output Play#0 1 142 units
+    Play#0 output Play#0 1 143 units
     Play#0 output Play#0 6 0 640
     Play#0 input lcarg *
     Play#0 command lcargo
     Play#0 output Play#0 1  302 linf    1,-1   t  100%   0   0   0   0   0   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  303 linf    1,-1   t  100%   0   0   0   0   0   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  304 hat     1,-1   t  100%   0   0   0   0   0   0   0   0   0   0   0   0   0
+    Play#0 output Play#0 1  312 linf    0,-2   u  100%   0   0   0   0   0   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  313 linf    0,-2      100%   0   0   0   0   0   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  314 linf    0,-2      100%   0   0   0   0   0   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  315 linf    1,-1      100%   0   0   0   0   0   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  350 sup     1,-1      100%   0   1   0   5   9   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  351 sup     1,-1      100%   0  20   0   0   0   0   0   0   0   0   0   0   0
     Play#0 output Play#0 1  352 sup     1,-1      100%   0   0   0   0  10   0   0   0   0   0   0   0   0
-    Play#0 output Play#0 1 142 units
+    Play#0 output Play#0 1 143 units
     Play#0 output Play#0 6 0 640
     Play#0 input read 0
     Play#0 command read
     Play#0 output Play#0 1 POGO linf light infantry #34 loaded on your tra  train #54 at 8,0
     Play#0 output Play#0 1 POGO linf light infantry #254 unloaded in your harbor at 0,0
     Play#0 output Play#0 1 POGO tended 1 military to cs   cargo ship (#166)
-    Play#0 output Play#0 1 POGO tended 1 military to cs   cargo ship (#166)
     Play#0 output Play#0 1 POGO linf light infantry #313 loaded on your cs   cargo ship (#166) at 0,-2
     Play#0 output Play#0 1 POGO linf light infantry #314 loaded on your cs   cargo ship (#166) at 0,-2
     Play#0 output Play#0 6 0 640