summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-11-06 15:06:00 -0200
committershennetsind <ind@henn.et>2013-11-06 15:06:00 -0200
commit778facb21f822cea549939c8dbee886e1cd342aa (patch)
treefb4252f79ab8c25f38c94039cd0c60f54261f0c5 /src
parent4d860972e973b02a3a8b691206abd659f9651a21 (diff)
downloadhercules-778facb21f822cea549939c8dbee886e1cd342aa.tar.gz
hercules-778facb21f822cea549939c8dbee886e1cd342aa.tar.bz2
hercules-778facb21f822cea549939c8dbee886e1cd342aa.tar.xz
hercules-778facb21f822cea549939c8dbee886e1cd342aa.zip
Modified @command loading
So that HPM plugins are able to override default commands, thanks to Akkarin for bringing it up. Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src')
-rw-r--r--src/map/HPMmap.c5
-rw-r--r--src/map/atcommand.c19
-rw-r--r--src/map/atcommand.h2
3 files changed, 12 insertions, 14 deletions
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c
index ca4a7a2e8..8a69cba97 100644
--- a/src/map/HPMmap.c
+++ b/src/map/HPMmap.c
@@ -142,10 +142,7 @@ void HPM_map_atcommands(void) {
unsigned int i;
for(i = 0; i < atcommand_list_items; i++) {
- if( !atcommand->add(atcommand_list[i].name,atcommand_list[i].func) ) {
- ShowDebug("HPM_map_atcommands: duplicate command '%s', skipping...\n", atcommand_list[i].name);
- continue;
- }
+ atcommand->add(atcommand_list[i].name,atcommand_list[i].func,true);
}
}
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;
}
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index 63c38e4d1..e4c66df40 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -110,7 +110,7 @@ struct atcommand_interface {
int (*cmd_db_clear_sub) (DBKey key, DBData *data, va_list args);
void (*doload) (void);
void (*base_commands) (void);
- bool (*add) (char *name, AtCommandFunc func);
+ bool (*add) (char *name, AtCommandFunc func, bool replace);
};
struct atcommand_interface *atcommand;