From d1c3529009756a9847ad120f500d72df5030d578 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 20 Jan 2014 23:12:31 +0100 Subject: [PATCH] retreat: Don't retreat the current player's ships or land units The retreat code happily retreats anything, without considering who owns it. It reports retreat to the owner by bulletin, even when the owner is the current player. Commands shouldn't report to the current player by bulletin, they should print directly. Fixable. However, your ships and land units retreating from your own actions makes little sense. Suppress it. Signed-off-by: Markus Armbruster --- src/lib/subs/retreat.c | 5 +++++ tests/retreat/01-retreat-1 | 4 ++-- tests/retreat/final.xdump | 4 ++-- tests/retreat/journal.log | 15 +++++---------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/lib/subs/retreat.c b/src/lib/subs/retreat.c index 9a3860fed..dad5db670 100644 --- a/src/lib/subs/retreat.c +++ b/src/lib/subs/retreat.c @@ -45,6 +45,7 @@ #include "nsc.h" #include "optlist.h" #include "path.h" +#include "player.h" #include "prototypes.h" #include "retreat.h" #include "sect.h" @@ -98,6 +99,8 @@ retreat_ship(struct shpstr *sp, char code) if (sp->shp_effic < SHIP_MINEFF || CANT_HAPPEN(!sp->shp_own)) return; + if (sp->shp_own == player->cnum) + return; retreat_ship1(sp, code, 1); if (sp->shp_rpath[0] == 0) @@ -345,6 +348,8 @@ retreat_land(struct lndstr *lp, char code) if (lp->lnd_effic < LAND_MINEFF || CANT_HAPPEN(!lp->lnd_own)) return; + if (lp->lnd_own == player->cnum) + return; retreat_land1(lp, code, 1); if (lp->lnd_rpath[0] == 0) diff --git a/tests/retreat/01-retreat-1 b/tests/retreat/01-retreat-1 index cfda8bf87..ad55e03aa 100644 --- a/tests/retreat/01-retreat-1 +++ b/tests/retreat/01-retreat-1 @@ -61,7 +61,7 @@ fire se -2,2 10 fire se -2,2 10 | nj into friendly harbor fire se -2,2 10 -|| own ship +|| own ship stays put fire se -2,2 2 || ships retreating from gun fire | injured covered above @@ -185,7 +185,7 @@ bomb 30 . p -2,2 ujjh l 10 | BUG: can't enter allied sector -| own land unit +| own land unit stays put bomb 30 . p -3,1 h l 2 diff --git a/tests/retreat/final.xdump b/tests/retreat/final.xdump index 818b4e94c..9e0a39011 100644 --- a/tests/retreat/final.xdump +++ b/tests/retreat/final.xdump @@ -149,7 +149,7 @@ config ship uid owner xloc yloc type effic mobil off tech opx opy mission radius fleet xstart xend ystart yend cargostart(0) cargostart(1) cargostart(2) cargostart(3) cargostart(4) cargostart(5) cargoend(0) cargoend(1) cargoend(2) cargoend(3) cargoend(4) cargoend(5) amtstart(0) amtstart(1) amtstart(2) amtstart(3) amtstart(4) amtstart(5) amtend(0) amtend(1) amtend(2) amtend(3) amtend(4) amtend(5) autonav civil milit shell gun petrol iron dust bar food oil lcm hcm uw rad pstage ptime access mquota path follow name xbuilt ybuilt builder rflags rpath 0 1 -3 1 2 100 127 0 20 0 0 none 0 "a" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 0 "" -3 1 1 (injured) "garbage" 1 1 -3 1 2 100 127 0 20 0 0 none 0 "a" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 1 "" -3 1 1 () "" -2 1 -6 2 2 91 81 0 20 0 0 none 0 "" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 2 "" -3 1 1 (injured torped sonared helpless bombed depth-charged boarded) "yujnbgy" +2 1 -3 1 2 91 115 0 20 0 0 none 0 "" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 2 "" -3 1 1 (injured torped sonared helpless bombed depth-charged boarded) "bgyujnbgy" 3 1 -3 1 2 100 127 0 20 0 0 none 0 "a" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 3 "" -3 1 1 () "" 4 1 -3 1 2 100 127 0 20 0 0 none 0 "a" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 4 "" -3 1 1 (group helpless) "b" 5 1 -5 1 17 96 63 0 70 0 0 none 0 "a" 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 31 1 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 5 "" -3 1 1 () "" @@ -355,7 +355,7 @@ config land uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship harden retreat rflags rpath civil milit shell gun petrol iron dust bar food oil lcm hcm uw rad pstage ptime land access 0 1 -3 1 2 100 127 0 50 0 0 none 0 "a" -1 127 42 (injured) "garbage" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 1 1 -3 1 2 100 127 0 50 0 0 none 0 "a" -1 127 42 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 -2 1 -3 -1 2 89 85 0 50 0 0 none 0 "" -1 127 42 (injured helpless bombed) "jnbgyuj" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 +2 1 -3 1 2 89 113 0 50 0 0 none 0 "" -1 127 42 (injured helpless bombed) "yujnbgyuj" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 3 1 -3 1 2 100 127 0 50 0 0 none 0 "a" -1 127 42 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 4 1 -3 1 2 100 127 0 50 0 0 none 0 "a" -1 127 42 (group helpless) "b" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 5 0 0 0 0 0 127 0 0 0 0 none 0 "" -1 127 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 diff --git a/tests/retreat/journal.log b/tests/retreat/journal.log index 2aa8edf11..40ec27344 100644 --- a/tests/retreat/journal.log +++ b/tests/retreat/journal.log @@ -223,7 +223,6 @@ Play#1 output Play#1 1 \007Kaboom!!! Play#1 output Play#1 1 Shells hit cs cargo ship (#2) in -3,1 for 11 damage. Play#1 output Play#1 1 cs cargo ship (#2) takes 9 - Play#1 output Play#1 1 You have a new telegram waiting ... Play#1 output Play#1 6 0 616 Play#1 input fire se -2,2 11 Play#1 command fire @@ -1152,7 +1151,6 @@ Play#1 output Play#1 1 1 pinpoint bombing raid did 36 damage to inf infantry #2 Play#1 output Play#1 1 inf infantry #2 takes 11 Play#1 output Play#1 1 -3,1 takes 4% collateral damage - Play#1 output Play#1 1 You have a new telegram waiting ... Play#1 output Play#1 6 0 545 Play#1 input bomb 20/21/22/23/24 . p -2,2 uuh Play#1 command bomb @@ -1255,10 +1253,7 @@ Play#0 output Play#0 6 0 640 Play#0 input read 1 Play#0 command read - Play#0 output Play#0 1 - Play#0 output Play#0 1 > BULLETIN from POGO, (#0) dated Thu Jan 1 00:00:00 1970 - Play#0 output Play#0 1 cs cargo ship (#2) was damaged, and retreated to -6,2 - Play#0 output Play#0 1 inf infantry #2 was damaged, and retreated to -3,-1 + Play#0 output Play#0 1 No telegrams for 1 at the moment... Play#0 output Play#0 6 0 640 Play#0 input read 2 Play#0 command read @@ -1488,7 +1483,7 @@ Play#0 input ship * ?fleet#a Play#0 command ship Play#0 output Play#0 1 own shp# ship type x,y fl eff civ mil uw fd pn he xl ln mob tech - Play#0 output Play#0 1 1 2 cs cargo ship -6,2 91% 0 9 0 0 0 0 0 0 81 20 + Play#0 output Play#0 1 1 2 cs cargo ship -3,1 91% 0 9 0 0 0 0 0 0 115 20 Play#0 output Play#0 1 2 10 cs cargo ship 4,4 83% 0 8 0 0 0 0 0 0 22 20 Play#0 output Play#0 1 2 11 cs cargo ship 1,3 91% 0 9 0 0 0 0 0 0 99 20 Play#0 output Play#0 1 2 20 cs cargo ship -3,1 95% 0 9 0 0 0 0 0 0 121 20 @@ -1533,7 +1528,7 @@ Play#0 input retr * ?fleet#a Play#0 command retreat Play#0 output Play#0 1 own shp# ship type x,y fl path as flt? flags - Play#0 output Play#0 1 1 2 cs cargo ship -6,2 yujnbgy itshbdu + Play#0 output Play#0 1 1 2 cs cargo ship -3,1 bgyujnbgy itshbdu Play#0 output Play#0 1 2 10 cs cargo ship 4,4 Play#0 output Play#0 1 2 11 cs cargo ship 1,3 Play#0 output Play#0 1 2 20 cs cargo ship -3,1 u h @@ -1583,7 +1578,7 @@ Play#0 input land * ?army#a Play#0 command land Play#0 output Play#0 1 own # unit type x,y a eff mil frt mu fd tch retr xl ln carry - Play#0 output Play#0 1 1 2 inf infantry -3,-1 89% 9 127 85 0 50 42% 0 0 + Play#0 output Play#0 1 1 2 inf infantry -3,1 89% 9 127 113 0 50 42% 0 0 Play#0 output Play#0 1 2 9 tra train 1,1 93% 10 127 119 0 50 42% 0 1 Play#0 output Play#0 1 2 10 cav cavalry 4,0 61% 6 127 45 0 50 42% 0 0 Play#0 output Play#0 1 2 31 cav cavalry 0,2 99% 10 127 126 0 50 42% 0 0 35S @@ -1606,7 +1601,7 @@ Play#0 input lretr * ?army#a Play#0 command lretreat Play#0 output Play#0 1 own lnd# unit type x,y ar path as army? flags - Play#0 output Play#0 1 1 2 inf infantry -3,-1 jnbgyuj ihb + Play#0 output Play#0 1 1 2 inf infantry -3,1 yujnbgyuj ihb Play#0 output Play#0 1 2 9 tra train 1,1 Play#0 output Play#0 1 2 10 cav cavalry 4,0 Play#0 output Play#0 1 2 31 cav cavalry 0,2 j b -- 2.43.0