From 3bf2d17e2cd80151257589b3cbdc8fa523e0826f Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 08:53:13 +0300 Subject: [PATCH] Unify iron ball unwielding --- include/extern.h | 1 + src/ball.c | 29 ++++++++++++++++++----------- src/do.c | 12 ++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/extern.h b/include/extern.h index 406ae8c13..05f7aa244 100644 --- a/include/extern.h +++ b/include/extern.h @@ -119,6 +119,7 @@ E void FDECL(uchangealign, (int,int)); /* ### ball.c ### */ +E void FDECL(ballrelease, (boolean)); E void NDECL(ballfall); E void NDECL(placebc); E void NDECL(unplacebc); diff --git a/src/ball.c b/src/ball.c index b3513f7b5..e1fa4b72a 100644 --- a/src/ball.c +++ b/src/ball.c @@ -10,6 +10,23 @@ STATIC_DCL int NDECL(bc_order); STATIC_DCL void NDECL(litter); +void +ballrelease(showmsg) +boolean showmsg; +{ + if (carried(uball)) { + if (showmsg) pline("Startled, you drop the iron ball."); + if (uwep == uball) + setuwep((struct obj *)0); + if (uswapwep == uball) + setuswapwep((struct obj *)0); + if (uquiver == uball) + setuqwep((struct obj *)0);; + if (uwep != uball) + freeinv(uball); + } +} + void ballfall() { @@ -17,17 +34,7 @@ ballfall() gets_hit = (((uball->ox != u.ux) || (uball->oy != u.uy)) && ((uwep == uball)? FALSE : (boolean)rn2(5))); - if (carried(uball)) { - pline("Startled, you drop the iron ball."); - if (uwep == uball) - setuwep((struct obj *)0); - if (uswapwep == uball) - setuswapwep((struct obj *)0); - if (uquiver == uball) - setuqwep((struct obj *)0);; - if (uwep != uball) - freeinv(uball); - } + ballrelease(TRUE); if(gets_hit){ int dmg = rn1(7,25); pline_The("iron ball falls on your %s.", diff --git a/src/do.c b/src/do.c index 03edbb6f1..e3fe47c79 100644 --- a/src/do.c +++ b/src/do.c @@ -1282,16 +1282,8 @@ boolean at_stairs, falling, portal; Punished || Fumbling) { You("fall down the %s.", at_ladder ? "ladder" : "stairs"); if (Punished) { - drag_down(); - if (carried(uball)) { - if (uwep == uball) - setuwep((struct obj *)0); - if (uswapwep == uball) - setuswapwep((struct obj *)0); - if (uquiver == uball) - setuqwep((struct obj *)0); - freeinv(uball); - } + drag_down(); + ballrelease(FALSE); } /* falling off steed has its own losehp() call */ if (u.usteed)