mirror of
https://github.com/EnergyMech/energymech.git
synced 2025-12-17 15:36:50 +00:00
use mkhash for aliases too
This commit is contained in:
parent
3280df62f5
commit
8229117911
@ -270,13 +270,14 @@ void do_alias(COMMAND_ARGS)
|
|||||||
set_mallocdoer(do_alias);
|
set_mallocdoer(do_alias);
|
||||||
alias = (Alias*)Calloc(sizeof(Alias)+strlen(cmd));
|
alias = (Alias*)Calloc(sizeof(Alias)+strlen(cmd));
|
||||||
stringcpy(alias->alias,cmd);
|
stringcpy(alias->alias,cmd);
|
||||||
|
alias->hash = mkhash(cmd);
|
||||||
set_mallocdoer(do_alias);
|
set_mallocdoer(do_alias);
|
||||||
alias->format = stringdup(rest);
|
alias->format = stringdup(rest);
|
||||||
alias->next = aliaslist;
|
alias->next = aliaslist;
|
||||||
aliaslist = alias;
|
aliaslist = alias;
|
||||||
to_user(from,"Added alias: %s --> %s",cmd,rest);
|
to_user(from,"Added alias: %s --> %s",cmd,rest);
|
||||||
#ifdef DEBUG
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
src/ons.c
14
src/ons.c
@ -394,7 +394,7 @@ void on_msg(char *from, char *to, char *rest)
|
|||||||
uchar *p1,*p2;
|
uchar *p1,*p2;
|
||||||
int has_cc,has_bang;
|
int has_cc,has_bang;
|
||||||
int uaccess;
|
int uaccess;
|
||||||
int i,j,h;
|
int i,j,command_hash;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No line sent to this routine should be longer than MSGLEN
|
* 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++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
command_hash = mkhash(command);
|
||||||
|
|
||||||
#ifdef ALIAS
|
#ifdef ALIAS
|
||||||
arec = 0;
|
arec = 0;
|
||||||
recheck_alias:
|
recheck_alias:
|
||||||
#endif /* ALIAS */
|
|
||||||
|
|
||||||
#ifdef ALIAS
|
|
||||||
for(alias=aliaslist;alias;alias=alias->next)
|
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);
|
unchop(command,rest);
|
||||||
afmt(amem,alias->format,command);
|
afmt(amem,alias->format,command);
|
||||||
@ -527,10 +527,10 @@ recheck_alias:
|
|||||||
if (i) return;
|
if (i) return;
|
||||||
#endif /* SCRIPTING */
|
#endif /* SCRIPTING */
|
||||||
|
|
||||||
h = mkhash(command);
|
command_hash = mkhash(command);
|
||||||
i = hashmap[h];
|
i = hashmap[command_hash];
|
||||||
#ifdef DEBUG
|
#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 */
|
#endif /* DEBUG */
|
||||||
if (i == 255)
|
if (i == 255)
|
||||||
goto public_msg;
|
goto public_msg;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user