From 6d2244093af7a884d89311de7a95f1358dc6a080 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 8 Jan 2014 19:16:21 +0100 Subject: [PATCH] fire: Fix ship retreat when helpless Two bugs. First, multifire() checks the condition only for surface ships, not for submarines. Second, multifire() neglects to write back the ship after retreating it. The player is told the ship retreats, but it actually stays where it is. Broken since retreat was added in Chainsaw. Previous fixes (commit 8065fe8, v4.3.1 and commit de2651e, v4.3.19) "fixed" only the bulletin. Signed-off-by: Markus Armbruster --- src/lib/commands/mfir.c | 8 ++++---- tests/fire/final.xdump | 8 ++++---- tests/fire/journal.log | 34 ++++++++++++++++------------------ 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/lib/commands/mfir.c b/src/lib/commands/mfir.c index 9e76c1d3..5339108e 100644 --- a/src/lib/commands/mfir.c +++ b/src/lib/commands/mfir.c @@ -446,13 +446,13 @@ multifire(void) && (vship.shp_rflags & RET_DCHRGED) && !(vship.shp_rflags & RET_INJURED)) retreat_ship(&vship, 'd'); + else if (totaldefdam == 0 + && (vship.shp_rflags & RET_HELPLESS) + && !(vship.shp_rflags & RET_INJURED)) + retreat_ship(&vship, 'h'); putship(vship.shp_uid, &vship); break; } - if (totaldefdam == 0 && target == targ_ship - && (vship.shp_rflags & RET_HELPLESS) - && !(vship.shp_rflags & RET_INJURED)) - retreat_ship(&vship, 'h'); switch (attgp->ef_type) { case EF_SECTOR: putsect(&fsect); diff --git a/tests/fire/final.xdump b/tests/fire/final.xdump index ebdd4368..28d5c465 100644 --- a/tests/fire/final.xdump +++ b/tests/fire/final.xdump @@ -281,7 +281,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius fleet xstar 19 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () "" 20 0 2 2 2 0 0 0 20 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 78 78 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () "" 21 0 6 0 2 0 0 0 20 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 80 80 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () "" -22 2 2 2 2 58 74 0 20 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 59 58 0 0 healthy 0 0 0 "" 0 "" 0 0 0 (helpless depth-charged) "n" +22 2 3 3 2 58 65 0 20 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 59 58 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () "" 23 2 8 0 2 78 88 0 20 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 78 78 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () "" 24 2 6 0 2 32 40 0 20 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 32 32 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () "" 25 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 "" 0 "" 0 0 0 () "" @@ -334,12 +334,12 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius wing range 19 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 -1 -1 () 0 0.00000 20 0 2 2 27 0 127 0 180 0 0 none 0 "" 2 0 -1 -1 () 0 0.00000 21 0 6 0 27 0 127 0 180 0 0 none 0 "" 2 0 -1 -1 () 0 0.00000 -22 2 2 2 27 100 127 0 180 0 0 none 0 "" 2 0 22 -1 () 0 0.00000 +22 2 3 3 27 100 127 0 180 0 0 none 0 "" 2 0 22 -1 () 0 0.00000 23 2 8 0 27 100 127 0 180 0 0 none 0 "" 2 0 23 -1 () 0 0.00000 24 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 -1 -1 () 0 0.00000 25 0 2 2 27 0 127 0 180 0 0 none 0 "" 2 0 -1 -1 () 0 0.00000 26 0 6 0 27 0 127 0 180 0 0 none 0 "" 2 0 -1 -1 () 0 0.00000 -27 2 2 2 27 100 127 0 180 0 0 none 0 "" 2 0 -1 22 () 0 0.00000 +27 2 3 3 27 100 127 0 180 0 0 none 0 "" 2 0 -1 22 () 0 0.00000 28 2 8 0 27 100 127 0 180 0 0 none 0 "" 2 0 -1 23 () 0 0.00000 29 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 -1 -1 () 0 0.00000 30 0 1 3 27 0 127 0 180 0 0 none 0 "" 2 0 -1 -1 () 0 0.00000 @@ -387,7 +387,7 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius army ship h 19 0 0 0 0 0 0 0 0 0 0 none 0 "" -1 0 0 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 20 0 2 2 21 0 122 0 270 2 2 none 0 "" -1 0 0 () "" 0 9 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 21 0 6 0 21 0 127 0 270 6 0 none 0 "" -1 0 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 -22 2 2 2 21 97 124 0 270 2 2 none 0 "" 22 0 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 +22 2 3 3 21 97 124 0 270 3 3 none 0 "" 22 0 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 23 2 8 0 21 100 127 0 270 8 0 none 0 "" 23 0 0 () "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 24 0 0 0 0 0 0 0 0 0 0 none 0 "" -1 0 0 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 25 0 0 0 0 0 0 0 0 0 0 none 0 "" -1 0 0 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0 diff --git a/tests/fire/journal.log b/tests/fire/journal.log index 0e65ab83..ce3dcbb5 100644 --- a/tests/fire/journal.log +++ b/tests/fire/journal.log @@ -308,14 +308,14 @@ Play#1 output Play#1 1 Sector 2,0 ready to fire Play#1 output Play#1 1 range is 5.00 (4.50) Play#1 output Play#1 1 \007Kaboom!!! - Play#1 output Play#1 1 Shells hit cs cargo ship (#22) in 2,2 for 4 damage. + Play#1 output Play#1 1 Shells hit cs cargo ship (#22) in 3,3 for 4 damage. Play#1 output Play#1 6 0 597 Play#1 input fire se 4,0 22 Play#1 command fire Play#1 output Play#1 1 Sector 4,0 ready to fire Play#1 output Play#1 1 range is 5.00 (4.50) Play#1 output Play#1 1 \007Kaboom!!! - Play#1 output Play#1 1 Shells hit cs cargo ship (#22) in 2,2 for 49 damage. + Play#1 output Play#1 1 Shells hit cs cargo ship (#22) in 3,3 for 49 damage. Play#1 output Play#1 6 0 596 Play#1 input fire se 4,0 20 Play#1 command fire @@ -412,7 +412,7 @@ Play#0 output Play#0 1 1 9 cs cargo ship 3,1 98% 0 10 0 0 0 0 0 0 124 20 Play#0 output Play#0 1 2 10 sb submarine 2,2 20% 0 0 0 0 0 0 0 0 0 60 Play#0 output Play#0 1 2 11 sb submarine 6,0 20% 0 0 0 0 0 0 0 1 0 60 - Play#0 output Play#0 1 2 22 cs cargo ship 2,2 58% 0 3 0 0 0 0 1 1 74 20 + Play#0 output Play#0 1 2 22 cs cargo ship 3,3 58% 0 3 0 0 0 0 1 1 65 20 Play#0 output Play#0 1 2 23 cs cargo ship 8,0 78% 0 4 0 0 0 0 1 1 88 20 Play#0 output Play#0 1 8 ships Play#0 output Play#0 6 0 640 @@ -425,7 +425,7 @@ Play#0 output Play#0 1 9 cs 3,1 98% 0 10 0 10 9 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 10 sb 2,2 20% 0 0 0 0 0 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 11 sb 6,0 20% 0 0 0 0 0 0 0 0 0 0 0 0 0 - Play#0 output Play#0 1 22 cs 2,2 58% 0 3 0 0 0 0 0 0 0 0 59 58 0 + Play#0 output Play#0 1 22 cs 3,3 58% 0 3 0 0 0 0 0 0 0 0 59 58 0 Play#0 output Play#0 1 23 cs 8,0 78% 0 4 0 0 0 0 0 0 0 0 78 78 0 Play#0 output Play#0 1 8 ships Play#0 output Play#0 6 0 640 @@ -439,7 +439,7 @@ 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 1 hat hvy artill 3,1 39% 10 0 127 0 160 0% 0 0 Play#0 output Play#0 1 1 2 hat hvy artill 3,1 40% 10 0 127 0 160 0% 0 0 - Play#0 output Play#0 1 2 22 rad radar unit 2,2 97% 10 0 124 0 270 0% 1 0 22S + Play#0 output Play#0 1 2 22 rad radar unit 3,3 97% 10 0 124 0 270 0% 1 0 22S Play#0 output Play#0 1 2 32 tra train 2,2 94% 10 0 120 0 40 0% 1 1 Play#0 output Play#0 1 2 33 rad radar unit 2,2 97% 10 0 123 0 270 0% 1 0 32L Play#0 output Play#0 1 5 units @@ -449,7 +449,7 @@ Play#0 output Play#0 1 lnd# unit x,y a eff civ mil uw sh gun pet irn dst bar oil lcm hcm rad Play#0 output Play#0 1 1 hat 3,1 39% 0 10 0 80 12 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 2 hat 3,1 40% 0 10 0 80 12 0 0 0 0 0 0 0 0 - Play#0 output Play#0 1 22 rad 2,2 97% 0 10 0 0 0 0 0 0 0 0 0 0 0 + Play#0 output Play#0 1 22 rad 3,3 97% 0 10 0 0 0 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 32 tra 2,2 94% 0 10 0 0 0 0 0 0 0 0 94 94 0 Play#0 output Play#0 1 33 rad 2,2 97% 0 10 0 0 0 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 5 units @@ -920,7 +920,7 @@ Play#0 output Play#0 1 1 9 cs cargo ship 3,1 98% 0 10 0 0 0 0 0 0 124 20 Play#0 output Play#0 1 2 12 sb submarine 3,3 68% 0 4 0 0 0 0 0 0 62 60 Play#0 output Play#0 1 2 13 sb submarine 8,0 72% 0 4 0 0 0 0 0 1 67 60 - Play#0 output Play#0 1 2 22 cs cargo ship 2,2 58% 0 3 0 0 0 0 1 1 74 20 + Play#0 output Play#0 1 2 22 cs cargo ship 3,3 58% 0 3 0 0 0 0 1 1 65 20 Play#0 output Play#0 1 2 23 cs cargo ship 8,0 78% 0 4 0 0 0 0 1 1 88 20 Play#0 output Play#0 1 2 24 cs cargo ship 6,0 32% 0 1 0 0 0 0 0 0 40 20 Play#0 output Play#0 1 9 ships @@ -934,7 +934,7 @@ Play#0 output Play#0 1 9 cs 3,1 98% 0 10 0 10 9 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 12 sb 3,3 68% 0 4 0 0 0 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 13 sb 8,0 72% 0 4 0 0 0 0 0 0 0 0 0 0 0 - Play#0 output Play#0 1 22 cs 2,2 58% 0 3 0 0 0 0 0 0 0 0 59 58 0 + Play#0 output Play#0 1 22 cs 3,3 58% 0 3 0 0 0 0 0 0 0 0 59 58 0 Play#0 output Play#0 1 23 cs 8,0 78% 0 4 0 0 0 0 0 0 0 0 78 78 0 Play#0 output Play#0 1 24 cs 6,0 32% 0 1 0 0 0 0 0 0 0 0 32 32 0 Play#0 output Play#0 1 9 ships @@ -949,7 +949,7 @@ 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 1 hat hvy artill 3,1 39% 10 0 127 0 160 0% 0 0 Play#0 output Play#0 1 1 2 hat hvy artill 3,1 40% 10 0 127 0 160 0% 0 0 - Play#0 output Play#0 1 2 22 rad radar unit 2,2 97% 10 0 124 0 270 0% 1 0 22S + Play#0 output Play#0 1 2 22 rad radar unit 3,3 97% 10 0 124 0 270 0% 1 0 22S Play#0 output Play#0 1 2 32 tra train 2,2 94% 10 0 120 0 40 0% 1 1 Play#0 output Play#0 1 2 33 rad radar unit 2,2 97% 10 0 123 0 270 0% 1 0 32L Play#0 output Play#0 1 5 units @@ -959,7 +959,7 @@ Play#0 output Play#0 1 lnd# unit x,y a eff civ mil uw sh gun pet irn dst bar oil lcm hcm rad Play#0 output Play#0 1 1 hat 3,1 39% 0 10 0 80 12 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 2 hat 3,1 40% 0 10 0 80 12 0 0 0 0 0 0 0 0 - Play#0 output Play#0 1 22 rad 2,2 97% 0 10 0 0 0 0 0 0 0 0 0 0 0 + Play#0 output Play#0 1 22 rad 3,3 97% 0 10 0 0 0 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 32 tra 2,2 94% 0 10 0 0 0 0 0 0 0 0 94 94 0 Play#0 output Play#0 1 33 rad 2,2 97% 0 10 0 0 0 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 5 units @@ -1329,7 +1329,7 @@ Play#0 output Play#0 1 1 9 cs cargo ship 3,1 98% 0 10 0 0 0 0 0 0 124 20 Play#0 output Play#0 1 2 12 sb submarine 3,3 68% 0 4 0 0 0 0 0 0 62 60 Play#0 output Play#0 1 2 13 sb submarine 8,0 72% 0 4 0 0 0 0 0 1 67 60 - Play#0 output Play#0 1 2 22 cs cargo ship 2,2 58% 0 3 0 0 0 0 1 1 74 20 + Play#0 output Play#0 1 2 22 cs cargo ship 3,3 58% 0 3 0 0 0 0 1 1 65 20 Play#0 output Play#0 1 2 23 cs cargo ship 8,0 78% 0 4 0 0 0 0 1 1 88 20 Play#0 output Play#0 1 2 24 cs cargo ship 6,0 32% 0 1 0 0 0 0 0 0 40 20 Play#0 output Play#0 1 9 ships @@ -1343,7 +1343,7 @@ Play#0 output Play#0 1 9 cs 3,1 98% 0 10 0 10 9 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 12 sb 3,3 68% 0 4 0 0 0 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 13 sb 8,0 72% 0 4 0 0 0 0 0 0 0 0 0 0 0 - Play#0 output Play#0 1 22 cs 2,2 58% 0 3 0 0 0 0 0 0 0 0 59 58 0 + Play#0 output Play#0 1 22 cs 3,3 58% 0 3 0 0 0 0 0 0 0 0 59 58 0 Play#0 output Play#0 1 23 cs 8,0 78% 0 4 0 0 0 0 0 0 0 0 78 78 0 Play#0 output Play#0 1 24 cs 6,0 32% 0 1 0 0 0 0 0 0 0 0 32 32 0 Play#0 output Play#0 1 9 ships @@ -1358,7 +1358,7 @@ 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 1 hat hvy artill 3,1 39% 10 0 127 0 160 0% 0 0 Play#0 output Play#0 1 1 2 hat hvy artill 3,1 40% 10 0 127 0 160 0% 0 0 - Play#0 output Play#0 1 2 22 rad radar unit 2,2 97% 10 0 124 0 270 0% 1 0 22S + Play#0 output Play#0 1 2 22 rad radar unit 3,3 97% 10 0 124 0 270 0% 1 0 22S Play#0 output Play#0 1 2 32 tra train 2,2 94% 10 0 120 0 40 0% 1 1 Play#0 output Play#0 1 2 33 rad radar unit 2,2 97% 10 0 123 0 270 0% 1 0 32L Play#0 output Play#0 1 5 units @@ -1368,7 +1368,7 @@ Play#0 output Play#0 1 lnd# unit x,y a eff civ mil uw sh gun pet irn dst bar oil lcm hcm rad Play#0 output Play#0 1 1 hat 3,1 39% 0 10 0 80 12 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 2 hat 3,1 40% 0 10 0 76 12 0 0 0 0 0 0 0 0 - Play#0 output Play#0 1 22 rad 2,2 97% 0 10 0 0 0 0 0 0 0 0 0 0 0 + Play#0 output Play#0 1 22 rad 3,3 97% 0 10 0 0 0 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 32 tra 2,2 94% 0 10 0 0 0 0 0 0 0 0 94 94 0 Play#0 output Play#0 1 33 rad 2,2 97% 0 10 0 0 0 0 0 0 0 0 0 0 0 Play#0 output Play#0 1 5 units @@ -1433,12 +1433,10 @@ Play#0 output Play#0 1 sam Sea Sparrow #26 lost! Play#0 output Play#0 1 Country #1 shelled cs cargo ship (#22) in 2,2 for 0 damage. Play#0 output Play#0 1 cs cargo ship (#22) was fired upon with no one able to defend it, and retreated to 3,3 - Play#0 output Play#0 1 Country #1 shelled cs cargo ship (#22) in 2,2 for 4 damage. + Play#0 output Play#0 1 Country #1 shelled cs cargo ship (#22) in 3,3 for 4 damage. Play#0 output Play#0 1 cs cargo ship (#22) takes 3 - Play#0 output Play#0 1 cs cargo ship (#22) was fired upon with no one able to defend it, and retreated to 3,3 - Play#0 output Play#0 1 Country #1 shelled cs cargo ship (#22) in 2,2 for 49 damage. + Play#0 output Play#0 1 Country #1 shelled cs cargo ship (#22) in 3,3 for 49 damage. Play#0 output Play#0 1 cs cargo ship (#22) takes 40 - Play#0 output Play#0 1 cs cargo ship (#22) was fired upon with no one able to defend it, and retreated to 3,3 Play#0 output Play#0 1 Country #1 shelled cs cargo ship (#20) in 2,2 for 27 damage. Play#0 output Play#0 1 cs cargo ship (#20) takes 22 Play#0 output Play#0 1 cs cargo ship (#20) sunk!