From: Ari Johnson Date: Fri, 17 Dec 2010 19:42:04 +0000 (+0000) Subject: New alias_flag() HC function X-Git-Tag: 0.73p2~18 X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=4b484faa48b507c3aaeeba20e803df89a9a90028;p=cobramush.git New alias_flag() HC function (cherry picked from commit 99fe1e485fae331d227918c94980fbb6c4e8d205) --- diff --git a/src/flags.c b/src/flags.c index b303a2d..0691252 100644 --- a/src/flags.c +++ b/src/flags.c @@ -2292,16 +2292,44 @@ do_flag_alias(dbref player, const char *name, const char *alias) do_flag_info("FLAG", player, f->name); } else { /* Insert the flag in the ptab by the given alias */ - ptab_start_inserts(n->tab); - ptab_insert(n->tab, alias, f); - ptab_end_inserts(n->tab); - if ((f = match_flag_ns(n, alias))) + if (alias_flag(name, alias)) do_flag_info("FLAG", player, alias); else notify(player, T("Unknown failure adding alias.")); } } + /** Add a new alias for a flag. + * \param ns name of the flagspace to use. + * \param name name of the flag + * \param alias new alias for the flag + * \retval 1 alias added successfully + * \retval 0 failed to add alias + */ +int +alias_flag_generic(const char *ns, const char *name, const char *alias) +{ + FLAG *f; + FLAGSPACE *n; + + Flagspace_Lookup(n, ns); + + f = match_flag_ns(n, name); + if (!f) { + return 0; /* no such flag 'name' */ + } + + if (ptab_find_exact(n->tab, strupper(alias))) { + return 0; /* a flag called 'alias' already exists */ + } + + ptab_start_inserts(n->tab); + ptab_insert(n->tab, strupper(alias), f); + ptab_end_inserts(n->tab); + return ((f = match_flag_ns(n, alias)) ? 1 : 0); +} + + /** Change a flag's alias. * \param player the enactor. * \param name name of the flag.