if (old) {
/* Old alias - we're allowed to change to a different case */
strcpy(tbuf1, atr_value(old));
- if (s && (!*s || (strcasecmp(s, tbuf1)
- && !ok_player_alias(s, player, thing)))) {
- notify_format(player, T("'%s' is not a valid alias."), s);
- return -1;
+ if (s && !*s) {
+ notify_format(player, T("'%s' is not a valid alias."), s);
+ return -1;
+ }
+ if (s && strcasecmp(s, tbuf1)) {
+ int opae_res = ok_player_alias(s, player, thing);
+ switch (opae_res) {
+ case OPAE_INVALID:
+ notify_format(player, T("'%s' is not a valid alias."), s);
+ break;
+ case OPAE_TOOMANY:
+ notify_format(player, T("'%s' contains too many aliases."), s);
+ break;
+ case OPAE_NULL:
+ notify_format(player, T("Null aliases are not valid."));
+ break;
+ }
+ if (opae_res != OPAE_SUCCESS)
+ return -1;
}
} else {
/* No old alias */
- if (s && *s && !ok_player_alias(s, player, thing)) {
- notify_format(player, T("'%s' is not a valid alias."), s);
- return -1;
+ if (s && *s) {
+ int opae_res = ok_player_alias(s, player, thing);
+ switch (opae_res) {
+ case OPAE_INVALID:
+ notify_format(player, T("'%s' is not a valid alias."), s);
+ break;
+ case OPAE_TOOMANY:
+ notify_format(player, T("'%s' contains too many aliases."), s);
+ break;
+ case OPAE_NULL:
+ notify_format(player, T("Null aliases are not valid."));
+ break;
+ }
+ if (opae_res != OPAE_SUCCESS)
+ return -1;
}
}
} else if (s && *s && (!strcmp(name, "FORWARDLIST")
* \param thing player who is being aliased.
* \retval 1 alias is valid for players.
* \retval 0 alias is not valid for players.
+ * \return One of the OPAE_* constants defined in hdrs/attrib.h
*/
int
ok_player_alias(const char *alias, dbref player, dbref thing)
int cnt = 0;
if (!alias || !*alias)
- return 0;
+ return OPAE_NULL;
strncpy(tbuf1, alias, BUFFER_LEN - 1);
tbuf1[BUFFER_LEN - 1] = '\0';
while (sp && *sp && *sp == ' ')
sp++;
if (!sp || !*sp)
- return 0; /* No null aliases */
+ return OPAE_NULL; /* No null aliases */
if (!ok_player_name(sp, player, thing))
- return 0;
+ return OPAE_INVALID;
cnt++;
}
- return ((cnt <= MAX_ALIASES) || Director(player));
+ if (Director(player))
+ return OPAE_SUCCESS;
+ if (cnt > MAX_ALIASES)
+ return OPAE_TOOMANY;
+ return OPAE_SUCCESS;
}