From 55643423f6fdc361353e19aaf4ac0a5e57ba463d Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 15 Sep 2017 09:49:01 +0200 Subject: [PATCH] tend ltend: Fix to skip dead ships and land units for deities 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 --- src/lib/commands/lten.c | 4 ++-- src/lib/commands/tend.c | 6 ++++-- tests/load-tend/04-tend-POGO | 2 -- tests/load-tend/final.xdump | 7 +++---- tests/load-tend/journal.log | 23 +++++++++++------------ 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/lib/commands/lten.c b/src/lib/commands/lten.c index 0825ab73..03eac035 100644 --- a/src/lib/commands/lten.c +++ b/src/lib/commands/lten.c @@ -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; diff --git a/src/lib/commands/tend.c b/src/lib/commands/tend.c index f88db9a6..a009c659 100644 --- a/src/lib/commands/tend.c +++ b/src/lib/commands/tend.c @@ -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; diff --git a/tests/load-tend/04-tend-POGO b/tests/load-tend/04-tend-POGO index 027349a2..7ae28331 100644 --- a/tests/load-tend/04-tend-POGO +++ b/tests/load-tend/04-tend-POGO @@ -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 diff --git a/tests/load-tend/final.xdump b/tests/load-tend/final.xdump index 8d55fe00..a70d137a 100644 --- a/tests/load-tend/final.xdump +++ b/tests/load-tend/final.xdump @@ -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 diff --git a/tests/load-tend/journal.log b/tests/load-tend/journal.log index 82658f9d..d46a85a3 100644 --- a/tests/load-tend/journal.log +++ b/tests/load-tend/journal.log @@ -2450,16 +2450,16 @@ 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 @@ -2475,7 +2475,6 @@ 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 @@ -2656,8 +2655,7 @@ 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 @@ -2820,11 +2818,11 @@ 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 @@ -2900,7 +2898,7 @@ 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 @@ -3235,6 +3233,7 @@ 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 @@ -3248,7 +3247,7 @@ 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 @@ -3382,6 +3381,7 @@ 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 @@ -3395,7 +3395,7 @@ 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 @@ -3415,7 +3415,6 @@ 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