forked from github/server
BUG 2419: add a spell alias.
This commit is contained in:
parent
f9fcc01829
commit
de52d8d669
2 changed files with 10 additions and 5 deletions
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue