Make spell menu work with repeat command

This commit is contained in:
Pasi Kallinen
2023-11-05 13:48:19 +02:00
parent f720e1e548
commit 8dc7a4882a
2 changed files with 21 additions and 2 deletions

View File

@@ -1274,6 +1274,7 @@ digging down on a magical trap causes it to explode
thrown potion of sickness now bypasses target's innate magic resistance but thrown potion of sickness now bypasses target's innate magic resistance but
only affects current hit points, no longer also reducing maximum HP only affects current hit points, no longer also reducing maximum HP
lightning has a small chance of melting iron bars lightning has a small chance of melting iron bars
make spell menu work with repeat
Fixes to 3.7.0-x General Problems Exposed Via git Repository Fixes to 3.7.0-x General Problems Exposed Via git Repository

View File

@@ -695,6 +695,7 @@ getspell(int* spell_no)
{ {
int nspells, idx; int nspells, idx;
char ilet, lets[BUFSZ], qbuf[QBUFSZ]; char ilet, lets[BUFSZ], qbuf[QBUFSZ];
struct _cmd_queue cq, *cmdq;
if (spellid(0) == NO_SPELL) { if (spellid(0) == NO_SPELL) {
You("don't know any spells right now."); You("don't know any spells right now.");
@@ -703,6 +704,21 @@ getspell(int* spell_no)
if (rejectcasting()) if (rejectcasting())
return FALSE; /* no spell chosen */ return FALSE; /* no spell chosen */
if ((cmdq = cmdq_pop()) != 0) {
cq = *cmdq;
free(cmdq);
if (cq.typ == CMDQ_KEY) {
nspells = num_spells();
idx = spell_let_to_idx(cq.key);
if (idx < 0 || idx >= nspells)
return FALSE;
*spell_no = idx;
return TRUE;
} else {
return FALSE;
}
}
if (flags.menu_style == MENU_TRADITIONAL) { if (flags.menu_style == MENU_TRADITIONAL) {
/* we know there is at least 1 known spell */ /* we know there is at least 1 known spell */
nspells = num_spells(); nspells = num_spells();
@@ -777,9 +793,11 @@ docast(void)
{ {
int spell_no; int spell_no;
if (getspell(&spell_no)) if (getspell(&spell_no)) {
cmdq_add_key(CQ_REPEAT, spellet(spell_no));
return spelleffects(gs.spl_book[spell_no].sp_id, FALSE, FALSE); return spelleffects(gs.spl_book[spell_no].sp_id, FALSE, FALSE);
return ECMD_OK; }
return ECMD_FAIL;
} }
static const char * static const char *