diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/char/char.c | 2 | ||||
-rw-r--r-- | src/common/HPM.c | 9 | ||||
-rw-r--r-- | src/common/HPM.h | 2 | ||||
-rw-r--r-- | src/login/login.c | 2 | ||||
-rw-r--r-- | src/map/map.c | 23 |
5 files changed, 31 insertions, 7 deletions
diff --git a/src/char/char.c b/src/char/char.c index a42524444..bf19a0012 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -5393,7 +5393,7 @@ int do_init(int argc, char **argv) { online_char_db = idb_alloc(DB_OPT_RELEASE_DATA); HPM->share(sql_handle,"sql_handle"); - HPM->config_read(); + HPM->config_read(NULL, 0); HPM->event(HPET_INIT); mmo_char_sql_init(); diff --git a/src/common/HPM.c b/src/common/HPM.c index a25a17782..971eb83bd 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -269,11 +269,12 @@ void hplugin_unload(struct hplugin* plugin) { } } -void hplugins_config_read(void) { +void hplugins_config_read(const char * const *extra_plugins, int extra_plugins_count) { config_t plugins_conf; config_setting_t *plist = NULL; const char *config_filename = "conf/plugins.conf"; // FIXME hardcoded name FILE *fp; + int i; // uncomment once login/char support is wrapped up // if( !HPM->DataCheck ) { @@ -294,9 +295,13 @@ void hplugins_config_read(void) { HPM->symbol_defaults_sub(); plist = libconfig->lookup(&plugins_conf, "plugins_list"); + for (i = 0; i < extra_plugins_count; i++) { + config_setting_t *entry = libconfig->setting_add(plist, NULL, CONFIG_TYPE_STRING); + config_setting_set_string(entry, extra_plugins[i]); + } if (plist != NULL) { - int length = libconfig->setting_length(plist), i; + int length = libconfig->setting_length(plist); char filename[60]; for(i = 0; i < length; i++) { if( !strcmpi(libconfig->setting_get_string_elem(plist,i),"HPMHooking") ) {//must load it first diff --git a/src/common/HPM.h b/src/common/HPM.h index 52ad24a03..b466cb4f3 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -131,7 +131,7 @@ struct HPM_interface { void *(*import_symbol) (char *name, unsigned int pID); void (*share) (void *, char *); void (*symbol_defaults) (void); - void (*config_read) (void); + void (*config_read) (const char * const *extra_plugins, int extra_plugins_count); bool (*populate) (struct hplugin *plugin,const char *filename); void (*symbol_defaults_sub) (void);//TODO drop char *(*pid2name) (unsigned int pid); diff --git a/src/login/login.c b/src/login/login.c index 252031bb8..cb30de2f3 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1821,7 +1821,7 @@ int do_init(int argc, char** argv) } HPM->share(account_db_sql_up(accounts),"sql_handle"); - HPM->config_read(); + HPM->config_read(NULL, 0); HPM->event(HPET_INIT); // server port open & binding diff --git a/src/map/map.c b/src/map/map.c index a7e83cae3..b2d50292e 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5356,6 +5356,7 @@ void map_helpscreen(bool do_exit) ShowInfo(" --inter-config <file> Alternative inter-server configuration.\n"); ShowInfo(" --log-config <file> Alternative logging configuration.\n"); ShowInfo(" --script-check <file> Tests a script for errors, without running the server.\n"); + ShowInfo(" --load-plugin <name> Loads an additional plugin (can be repeated).\n"); HPM->arg_help();/* display help for commands implemented thru HPM */ if( do_exit ) exit(EXIT_SUCCESS); @@ -5566,7 +5567,8 @@ int do_init(int argc, char *argv[]) { bool minimal = false; char *scriptcheck = NULL; - int i; + int i, extra_plugins_count = 0; + const char **extra_plugins = NULL; #ifdef GCOLLECT GC_enable_incremental(); @@ -5579,7 +5581,21 @@ int do_init(int argc, char *argv[]) HPM->load_sub = HPM_map_plugin_load_sub; HPM->symbol_defaults_sub = map_hp_symbols; HPM->grabHPDataSub = HPM_map_grabHPData; - HPM->config_read(); + for( i = 1; i < argc; i++ ) { + const char* arg = argv[i]; + if( strcmp(arg, "--load-plugin") == 0 ) { + if( map->arg_next_value(arg, i, argc, true) ) { + RECREATE(extra_plugins, const char *, ++extra_plugins_count); + extra_plugins[extra_plugins_count-1] = argv[++i]; + } + } + } + HPM->config_read(extra_plugins, extra_plugins_count); + if (extra_plugins) { + aFree(extra_plugins); + extra_plugins = NULL; + extra_plugins_count = 0; + } HPM->event(HPET_PRE_INIT); @@ -5629,6 +5645,9 @@ int do_init(int argc, char *argv[]) runflag = CORE_ST_STOP; if( map->arg_next_value(arg, i, argc, true) ) scriptcheck = argv[++i]; + } else if( strcmp(arg, "load-plugin") == 0 ) { + if( map->arg_next_value(arg, i, argc, true) ) + i++; } else { ShowError("Unknown option '%s'.\n", argv[i]); exit(EXIT_FAILURE); |