From cd6d12c4fbd5835ee15f414a2b4392dac009d4e1 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 4 May 2008 19:02:15 +0200 Subject: [PATCH] Make depth charges work with just one shell Commit a3ad623b (v4.3.12) made depth charging fail when there's just one shell. This let players find all submarine uids. It basically reopened the loophole closed in commit aa26c53e (v4.2.20). Fix by making shp_dchrg() with just one shell succeed and return damage like fire from one gun. --- src/lib/subs/landgun.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/subs/landgun.c b/src/lib/subs/landgun.c index 44cea955..151679a4 100644 --- a/src/lib/subs/landgun.c +++ b/src/lib/subs/landgun.c @@ -135,7 +135,7 @@ shp_fire(struct shpstr *sp) int shp_dchrg(struct shpstr *sp) { - int shells; + int shells, dchrgs; if (sp->shp_effic < 60 || (mchr[sp->shp_type].m_flags & M_DCH) == 0) return -1; @@ -144,10 +144,11 @@ shp_dchrg(struct shpstr *sp) shells = sp->shp_item[I_SHELL]; shells += supply_commod(sp->shp_own, sp->shp_x, sp->shp_y, I_SHELL, 2 - shells); - if (shells < 2) + if (shells == 0) return -1; - sp->shp_item[I_SHELL] = shells - 2; - return (int)seagun(sp->shp_effic, 3); + dchrgs = MIN(2, shells); + sp->shp_item[I_SHELL] = shells - dchrgs; + return (int)seagun(sp->shp_effic, 2 * dchrgs - 1); } /*