diff options
author | shennetsind <ind@henn.et> | 2013-11-09 17:06:32 -0200 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-11-09 17:06:45 -0200 |
commit | 1be53db78a321436d0ebe6093595b769f10874b6 (patch) | |
tree | bb76bc0cfc48402e8f0b60b4abf667d73be3d7e1 /src/map/map.c | |
parent | 8ed38f98894fb04b4403b44dc0f36281cfd36326 (diff) | |
download | hercules-1be53db78a321436d0ebe6093595b769f10874b6.tar.gz hercules-1be53db78a321436d0ebe6093595b769f10874b6.tar.bz2 hercules-1be53db78a321436d0ebe6093595b769f10874b6.tar.xz hercules-1be53db78a321436d0ebe6093595b769f10874b6.zip |
HPM Support for plugin-implemented "--args" (options)
As a necessary measure for the upcoming bot that will keep .sql files in sync with their .txt counterparts.
Special Thanks to Haruna
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/map.c')
-rw-r--r-- | src/map/map.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/src/map/map.c b/src/map/map.c index cd192b7d4..1d47d196e 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5215,6 +5215,7 @@ void map_helpscreen(bool do_exit) ShowInfo(" --grf-path <file>\t\tAlternative GRF path configuration.\n"); ShowInfo(" --inter-config <file>\t\tAlternative inter-server configuration.\n"); ShowInfo(" --log-config <file>\t\tAlternative logging configuration.\n"); + HPM->arg_help();/* display help for commands implemented thru HPM */ if( do_exit ) exit(EXIT_SUCCESS); } @@ -5257,10 +5258,11 @@ void do_shutdown(void) } } -bool map_arg_next_value(const char* option, int i, int argc) +bool map_arg_next_value(const char* option, int i, int argc, bool must) { if( i >= argc-1 ) { - ShowWarning("Missing value for option '%s'.\n", option); + if( must ) + ShowWarning("Missing value for option '%s'.\n", option); return false; } @@ -5377,6 +5379,8 @@ void map_hp_symbols(void) { } void map_load_defaults(void) { + map_defaults(); + /* */ atcommand_defaults(); battle_defaults(); battleground_defaults(); @@ -5426,17 +5430,23 @@ int do_init(int argc, char *argv[]) #ifdef GCOLLECT GC_enable_incremental(); #endif + + map_load_defaults(); - map_defaults(); - - rnd_init(); - + HPM->load_sub = HPM_map_plugin_load_sub; + HPM->symbol_defaults_sub = map_hp_symbols; + HPM->config_read(); + + HPM->event(HPET_PRE_INIT); + for( i = 1; i < argc ; i++ ) { const char* arg = argv[i]; if( arg[0] != '-' && ( arg[0] != '/' || arg[1] == '-' ) ) {// -, -- and / ShowError("Unknown option '%s'.\n", argv[i]); exit(EXIT_FAILURE); + } else if ( HPM->parse_arg(arg,&i,argv,map->arg_next_value(arg, i, argc, false)) ) { + continue; /* HPM Triggered */ } else if( (++arg)[0] == '-' ) {// long option arg++; @@ -5445,35 +5455,35 @@ int do_init(int argc, char *argv[]) } else if( strcmp(arg, "version") == 0 ) { map->versionscreen(true); } else if( strcmp(arg, "map-config") == 0 ) { - if( map->arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc, true) ) map->MAP_CONF_NAME = argv[++i]; } else if( strcmp(arg, "battle-config") == 0 ) { - if( map->arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc, true) ) map->BATTLE_CONF_FILENAME = argv[++i]; } else if( strcmp(arg, "atcommand-config") == 0 ) { - if( map->arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc, true) ) map->ATCOMMAND_CONF_FILENAME = argv[++i]; } else if( strcmp(arg, "script-config") == 0 ) { - if( map->arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc, true) ) map->SCRIPT_CONF_NAME = argv[++i]; } else if( strcmp(arg, "msg-config") == 0 ) { - if( map->arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc, true) ) map->MSG_CONF_NAME = argv[++i]; } else if( strcmp(arg, "grf-path-file") == 0 ) { - if( map->arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc, true) ) map->GRF_PATH_FILENAME = argv[++i]; } else if( strcmp(arg, "inter-config") == 0 ) { - if( map->arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc, true) ) map->INTER_CONF_NAME = argv[++i]; } else if( strcmp(arg, "log-config") == 0 ) { - if( map->arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc, true) ) map->LOG_CONF_NAME = argv[++i]; } else if( strcmp(arg, "run-once") == 0 ) { // close the map-server as soon as its done.. for testing [Celest] runflag = CORE_ST_STOP; } else if( strcmp(arg, "script-check") == 0 ) { minimal = true; runflag = CORE_ST_STOP; - if( map->arg_next_value(arg, i, argc) ) + if( map->arg_next_value(arg, i, argc, true) ) scriptcheck = argv[++i]; } else { ShowError("Unknown option '%s'.\n", argv[i]); @@ -5495,7 +5505,6 @@ int do_init(int argc, char *argv[]) } } - map_load_defaults(); if (!minimal) { map->config_read(map->MAP_CONF_NAME); CREATE(map->list,struct map_data,map->count); @@ -5580,9 +5589,6 @@ int do_init(int argc, char *argv[]) timer->add_func_list(map->removemobs_timer, "map_removemobs_timer"); timer->add_interval(timer->gettick()+1000, map->freeblock_timer, 0, 0, 60*1000); - HPM->load_sub = HPM_map_plugin_load_sub; - HPM->symbol_defaults_sub = map_hp_symbols; - HPM->config_read(); HPM->event(HPET_INIT); } |