From de52d8d669ebe9a0a7fad14aa252f5c772b7167c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Feb 2018 11:46:05 +0100 Subject: [PATCH] BUG 2419: add a spell alias. --- src/attributes/seenspell.c | 2 +- src/kernel/spell.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/attributes/seenspell.c b/src/attributes/seenspell.c index 170cc33b4..6c78d19f4 100644 --- a/src/attributes/seenspell.c +++ b/src/attributes/seenspell.c @@ -94,7 +94,7 @@ static int read_seenspell(variant *var, void *owner, struct gamedata *data) } sp = find_spell(token); if (!sp) { - log_info("read_seenspell: could not find spell '%s'\n", token); + log_error("read_seenspell: could not find spell '%s'\n", token); return AT_READ_FAIL; } var->v = sp; diff --git a/src/kernel/spell.c b/src/kernel/spell.c index ca97bf1f0..785f270b3 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -135,6 +135,7 @@ spell * create_spell(const char * name) } static const char *sp_aliases[][2] = { + { "create_potion_p14", "create_potion_healing" }, { "gwyrrdfamiliar", "summon_familiar" }, { "illaunfamiliar", "summon_familiar" }, { "draigfamiliar", "summon_familiar" }, @@ -150,16 +151,20 @@ static const char *sp_alias(const char *zname) if (strcmp(sp_aliases[i][0], zname) == 0) return sp_aliases[i][1]; } - return zname; + return NULL; } spell *find_spell(const char *name) { const char * match; spell * sp = 0; - const char * alias = sp_alias(name); - - match = cb_find_str(&cb_spells, alias); + match = cb_find_str(&cb_spells, name); + if (!match) { + const char * alias = sp_alias(name); + if (alias) { + match = cb_find_str(&cb_spells, alias); + } + } if (match) { cb_get_kv(match, &sp, sizeof(sp)); }