From 75e7d837e618b530146edaf83bd32c4aa53fc92b Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 09:16:49 +0300 Subject: [PATCH] Unify food-related conducts when eating a monster --- include/extern.h | 1 + src/eat.c | 24 +++++++++++++----------- src/uhitm.c | 10 ++-------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/include/extern.h b/include/extern.h index d5d6bbb47..b5648f0bf 100644 --- a/include/extern.h +++ b/include/extern.h @@ -607,6 +607,7 @@ E void NDECL(vomit); E int FDECL(eaten_stat, (int,struct obj *)); E void FDECL(food_disappears, (struct obj *)); E void FDECL(food_substitution, (struct obj *,struct obj *)); +E void FDECL(eating_conducts, (struct permonst *)); E int FDECL(eat_brains, (struct monst *,struct monst *,BOOLEAN_P,int *)); E void NDECL(fix_petrification); E void FDECL(consume_oeaten, (struct obj *,int)); diff --git a/src/eat.c b/src/eat.c index 2226a7b37..5e12876f5 100644 --- a/src/eat.c +++ b/src/eat.c @@ -431,6 +431,17 @@ boolean message; context.victual.fullwarn = context.victual.eating = context.victual.doreset = FALSE; } +void +eating_conducts(pd) +struct permonst *pd; +{ + u.uconduct.food++; + if (!vegan(pd)) + u.uconduct.unvegan++; + if (!vegetarian(pd)) + violated_vegetarian(); +} + /* handle side-effects of mind flayer's tentacle attack */ int eat_brains(magr, mdef, visflag, dmg_p) @@ -483,11 +494,7 @@ int *dmg_p; /* for dishing out extra damage in lieu of Int loss */ /* * player mind flayer is eating something's brain */ - u.uconduct.food++; - if (!vegan(pd)) - u.uconduct.unvegan++; - if (!vegetarian(pd)) - violated_vegetarian(); + eating_conducts(pd); if (mindless(pd)) { /* (cannibalism not possible here) */ pline("%s doesn't notice.", Monnam(mdef)); /* all done; no extra harm inflicted upon target */ @@ -1270,12 +1277,7 @@ const char *mesg; You("consume %s %s.", tintxts[r].txt, mons[mnum].mname); - /* KMH, conduct */ - u.uconduct.food++; - if (!vegan(&mons[mnum])) - u.uconduct.unvegan++; - if (!vegetarian(&mons[mnum])) - violated_vegetarian(); + eating_conducts(&mons[mnum]); tin->dknown = tin->known = 1; cprefx(mnum); diff --git a/src/uhitm.c b/src/uhitm.c index 50c0523f6..19361c261 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -1809,14 +1809,8 @@ register struct attack *mattk; (mattk->adtyp == AD_DGST && (is_rider(pd) || (pd == &mons[PM_MEDUSA] && !Stone_resistance))); - if ((mattk->adtyp == AD_DGST && !Slow_digestion) || fatal_gulp) { - /* KMH, conduct */ - u.uconduct.food++; - if (!vegan(pd)) - u.uconduct.unvegan++; - if (!vegetarian(pd)) - violated_vegetarian(); - } + if ((mattk->adtyp == AD_DGST && !Slow_digestion) || fatal_gulp) + eating_conducts(pd); if (fatal_gulp && !is_rider(pd)) { /* petrification */ char kbuf[BUFSZ];