From 987fe8afd5245232ef347ad2e1559bf36fd12d44 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 23 Feb 2015 09:11:57 +0100 Subject: Reduce ridiculous number of test_monster_name usages --- src/wizard2.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/wizard2.cc') diff --git a/src/wizard2.cc b/src/wizard2.cc index 84ffddad..fa223ffe 100644 --- a/src/wizard2.cc +++ b/src/wizard2.cc @@ -1497,8 +1497,14 @@ static void do_cmd_wiz_named(int r_idx, bool_ slp) /* Place it (allow groups) */ m_allow_special[r_idx] = TRUE; - if (place_monster_aux(y, x, r_idx, slp, TRUE, MSTATUS_ENEMY)) break; + int m_idx = place_monster_aux(y, x, r_idx, slp, TRUE, MSTATUS_ENEMY); m_allow_special[r_idx] = FALSE; + + // If summoning succeeded, we stop. + if (m_idx) + { + break; + } } } @@ -1519,7 +1525,6 @@ void do_cmd_wiz_named_friendly(int r_idx, bool_ slp) if (r_idx >= max_r_idx) return; /* Try 10 times */ - m_allow_special[r_idx] = TRUE; for (i = 0; i < 10; i++) { int d = 1; @@ -1531,9 +1536,16 @@ void do_cmd_wiz_named_friendly(int r_idx, bool_ slp) if (!cave_empty_bold(y, x)) continue; /* Place it (allow groups) */ - if (place_monster_aux(y, x, r_idx, slp, TRUE, MSTATUS_PET)) break; + m_allow_special[r_idx] = TRUE; + int m_idx = place_monster_aux(y, x, r_idx, slp, TRUE, MSTATUS_PET); + m_allow_special[r_idx] = FALSE; + + // Stop if we succeeded + if (m_idx) + { + break; + } } - m_allow_special[r_idx] = FALSE; } -- cgit v1.2.1