From 778facb21f822cea549939c8dbee886e1cd342aa Mon Sep 17 00:00:00 2001 From: shennetsind Date: Wed, 6 Nov 2013 15:06:00 -0200 Subject: Modified @command loading So that HPM plugins are able to override default commands, thanks to Akkarin for bringing it up. Signed-off-by: shennetsind --- src/map/atcommand.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/map/atcommand.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 0ba977ff4..2abdb5925 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -9564,7 +9564,7 @@ void atcommand_basecommands(void) { int i; for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) { - if(!atcommand->add(atcommand_base[i].command,atcommand_base[i].func)) { // Should not happen if atcommand_base[] array is OK + if(!atcommand->add(atcommand_base[i].command,atcommand_base[i].func,false)) { // Should not happen if atcommand_base[] array is OK ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command); continue; } @@ -9576,21 +9576,22 @@ void atcommand_basecommands(void) { return; } -bool atcommand_add(char *name,AtCommandFunc func) { +bool atcommand_add(char *name,AtCommandFunc func, bool replace) { AtCommandInfo* cmd; - if(atcommand->exists(name)) //caller will handle/display on false - return false; - - CREATE(cmd, AtCommandInfo, 1); + if( (cmd = atcommand->exists(name)) ) { //caller will handle/display on false + if( !replace ) + return false; + } else { + CREATE(cmd, AtCommandInfo, 1); + strdb_put(atcommand->db, name, cmd); + } safestrncpy(cmd->command, name, sizeof(cmd->command)); cmd->func = func; cmd->help = NULL; cmd->log = true; - - strdb_put(atcommand->db, cmd->command, cmd); - + return true; } -- cgit v1.2.3-70-g09d2