BUG 2419: add a spell alias.

This commit is contained in:
Enno Rehling 2018-02-18 11:46:05 +01:00
parent f9fcc01829
commit de52d8d669
2 changed files with 10 additions and 5 deletions

View file

@ -94,7 +94,7 @@ static int read_seenspell(variant *var, void *owner, struct gamedata *data)
} }
sp = find_spell(token); sp = find_spell(token);
if (!sp) { 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; return AT_READ_FAIL;
} }
var->v = sp; var->v = sp;

View file

@ -135,6 +135,7 @@ spell * create_spell(const char * name)
} }
static const char *sp_aliases[][2] = { static const char *sp_aliases[][2] = {
{ "create_potion_p14", "create_potion_healing" },
{ "gwyrrdfamiliar", "summon_familiar" }, { "gwyrrdfamiliar", "summon_familiar" },
{ "illaunfamiliar", "summon_familiar" }, { "illaunfamiliar", "summon_familiar" },
{ "draigfamiliar", "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) if (strcmp(sp_aliases[i][0], zname) == 0)
return sp_aliases[i][1]; return sp_aliases[i][1];
} }
return zname; return NULL;
} }
spell *find_spell(const char *name) spell *find_spell(const char *name)
{ {
const char * match; const char * match;
spell * sp = 0; spell * sp = 0;
const char * alias = sp_alias(name); match = cb_find_str(&cb_spells, name);
if (!match) {
match = cb_find_str(&cb_spells, alias); const char * alias = sp_alias(name);
if (alias) {
match = cb_find_str(&cb_spells, alias);
}
}
if (match) { if (match) {
cb_get_kv(match, &sp, sizeof(sp)); cb_get_kv(match, &sp, sizeof(sp));
} }