From 82ae06c617b38794937630bed21f95ffcddf3af2 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Tue, 3 Feb 2009 01:45:05 +0000 Subject: [PATCH] yet more monpolycontrol (trunk only) Factor out a few lines of common code instead of duplicating them. --- src/mon.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/mon.c b/src/mon.c index b066134a6..88b1bf674 100644 --- a/src/mon.c +++ b/src/mon.c @@ -2734,24 +2734,18 @@ struct monst *mon; break; } mndx = name_to_mon(buf); - if (mndx >= LOW_PM) { - /* got a specific type of monster; use it if we can, - otherwise drop down to "can"t" and try again */ - if (validvamp(mon, &mndx, monclass)) break; - /* revert to random in case we exhaust tryct */ - mndx = NON_PM; - } else { + if (mndx == NON_PM) { /* didn't get a type, so check whether it's a class - (single letter or text match with def_monsyms[]); - text match might already force a specific type, - otherwise pick something from within the class */ + (single letter or text match with def_monsyms[]) */ monclass = name_to_monclass(buf, &mndx); if (monclass && mndx == NON_PM) mndx = mkclass_poly(monclass); - if (mndx >= LOW_PM) { - if (validvamp(mon, &mndx, monclass)) break; - mndx = NON_PM; /* revert to random */ - } + } + if (mndx >= LOW_PM) { + /* got a specific type of monster; use it if we can */ + if (validvamp(mon, &mndx, monclass)) break; + /* can't; revert to random in case we exhaust tryct */ + mndx = NON_PM; } pline("It can't become that.");