summaryrefslogtreecommitdiff
path: root/src/wizard2.cc
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2015-02-23 09:11:57 +0100
committerBardur Arantsson <bardur@scientician.net>2015-02-23 09:11:57 +0100
commit987fe8afd5245232ef347ad2e1559bf36fd12d44 (patch)
tree9152a63c8d98b043839b34ac03c318fd2ba8c188 /src/wizard2.cc
parentc4446a2b2cac8166827d0c505b290487a47aaafd (diff)
Reduce ridiculous number of test_monster_name usages
Diffstat (limited to 'src/wizard2.cc')
-rw-r--r--src/wizard2.cc20
1 files changed, 16 insertions, 4 deletions
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;
}