use mkhash for aliases too

This commit is contained in:
joonicks 2025-11-10 22:39:10 +01:00
parent 3280df62f5
commit 8229117911
2 changed files with 9 additions and 8 deletions

View File

@ -270,13 +270,14 @@ void do_alias(COMMAND_ARGS)
set_mallocdoer(do_alias);
alias = (Alias*)Calloc(sizeof(Alias)+strlen(cmd));
stringcpy(alias->alias,cmd);
alias->hash = mkhash(cmd);
set_mallocdoer(do_alias);
alias->format = stringdup(rest);
alias->next = aliaslist;
aliaslist = alias;
to_user(from,"Added alias: %s --> %s",cmd,rest);
#ifdef DEBUG
debug("(do_alias) Added alias: %s --> %s\n",cmd,rest);
debug("(do_alias) Added alias: %s [#%i] --> %s\n",cmd,alias->hash,rest);
#endif
}

View File

@ -394,7 +394,7 @@ void on_msg(char *from, char *to, char *rest)
uchar *p1,*p2;
int has_cc,has_bang;
int uaccess;
int i,j,h;
int i,j,command_hash;
/*
* No line sent to this routine should be longer than MSGLEN
@ -475,15 +475,15 @@ void on_msg(char *from, char *to, char *rest)
command++;
}
command_hash = mkhash(command);
#ifdef ALIAS
arec = 0;
recheck_alias:
#endif /* ALIAS */
#ifdef ALIAS
for(alias=aliaslist;alias;alias=alias->next)
{
if (!stringcasecmp(alias->alias,command))
if (command_hash == alias->hash && stringcasecmp(alias->alias,command) == 0)
{
unchop(command,rest);
afmt(amem,alias->format,command);
@ -527,10 +527,10 @@ recheck_alias:
if (i) return;
#endif /* SCRIPTING */
h = mkhash(command);
i = hashmap[h];
command_hash = mkhash(command);
i = hashmap[command_hash];
#ifdef DEBUG
debug("(on_msg) %s = hash %i, mapped to %i %s\n",command,h,i,(i==255)?"(no match)":mcmd[i].name);
debug("(on_msg) %s = hash %i, mapped to %i %s\n",command,command_hash,i,(i==255)?"(no match)":mcmd[i].name);
#endif /* DEBUG */
if (i == 255)
goto public_msg;