From 8229117911eb1ddf17a323c4033da4c402a69e44 Mon Sep 17 00:00:00 2001 From: joonicks Date: Mon, 10 Nov 2025 22:39:10 +0100 Subject: [PATCH] use mkhash for aliases too --- src/alias.c | 3 ++- src/ons.c | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/alias.c b/src/alias.c index e600922..38f79a5 100644 --- a/src/alias.c +++ b/src/alias.c @@ -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 } diff --git a/src/ons.c b/src/ons.c index c118be7..1224783 100644 --- a/src/ons.c +++ b/src/ons.c @@ -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;