]> git.pond.sub.org Git - empserver/commitdiff
retreat: Don't retreat the current player's ships or land units
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 20 Jan 2014 22:12:31 +0000 (23:12 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 16 Feb 2014 12:19:26 +0000 (13:19 +0100)
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 <armbru@pond.sub.org>
src/lib/subs/retreat.c
tests/retreat/01-retreat-1
tests/retreat/final.xdump
tests/retreat/journal.log

index 9a3860fedd487e2af11c532eb507fcb141ff5e88..dad5db6700aa6d50c0e104e9cb8dc54a444a2277 100644 (file)
@@ -45,6 +45,7 @@
 #include "nsc.h"
 #include "optlist.h"
 #include "path.h"
 #include "nsc.h"
 #include "optlist.h"
 #include "path.h"
+#include "player.h"
 #include "prototypes.h"
 #include "retreat.h"
 #include "sect.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_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)
 
     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_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)
 
     retreat_land1(lp, code, 1);
     if (lp->lnd_rpath[0] == 0)
index cfda8bf87b1f7d775e023c15489266a6423633d9..ad55e03aa89d4d0fd591c5517f0157ab5e106b18 100644 (file)
@@ -61,7 +61,7 @@ fire se -2,2 10
 fire se -2,2 10
 | nj into friendly harbor
 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
 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
 l
 10
 | BUG: can't enter allied sector
-| own land unit
+| own land unit stays put
 bomb 30 . p -3,1 h
 l
 2
 bomb 30 . p -3,1 h
 l
 2
index 818b4e94c1dfe286f63083df21ccc496b86d67f1..9e0a390117a62b47f81c9cc09939ab4c5fc91d4c 100644 (file)
@@ -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 () ""
 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 () ""
 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
 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
 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
index 2aa8edf11e5e9bced7ed40de58fd903e2f0ad7b2..40ec27344c04691bf5c1d3a26d86209bbd185eea 100644 (file)
     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 \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
     Play#1 output Play#1 6 0 616
     Play#1 input fire se -2,2 11
     Play#1 command fire
     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 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
     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
     Play#0 output Play#0 6 0 640
     Play#0 input read 1
     Play#0 command read
     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
     Play#0 output Play#0 6 0 640
     Play#0 input read 2
     Play#0 command read
     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 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
     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
     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 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
     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
     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 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
     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
     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 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
     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