diff --git a/src/config.cpp b/src/config.cpp index c716421..7e3091f 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -52,7 +52,7 @@ Config::Config() pathCache(true) {} -void Config::read() +void Config::read(int argc, char *argv[]) { #define PO_DESC_ALL \ PO_DESC(debugMode, bool) \ @@ -82,22 +82,31 @@ void Config::read() po::options_description podesc; podesc.add_options() PO_DESC_ALL - ("RTP", po::value()) + ("RTP", po::value()->composing()) ; + po::variables_map vm; + + /* Parse command line options */ + po::parsed_options cmdPo = + po::command_line_parser(argc, argv).options(podesc) + .allow_unregistered() + .run(); + + GUARD_ALL( po::store(cmdPo, vm); ) + + /* Parse configuration file (mkxp.conf) */ std::ifstream confFile; confFile.open("mkxp.conf"); - po::variables_map vm; - if (confFile) { GUARD_ALL( po::store(po::parse_config_file(confFile, podesc, true), vm); ) - po::notify(vm); } confFile.close(); + po::notify(vm); #undef PO_DESC #define PO_DESC(key, type) GUARD_ALL( key = vm[#key].as< type >(); ) diff --git a/src/config.h b/src/config.h index 5a7e954..411ce51 100644 --- a/src/config.h +++ b/src/config.h @@ -62,7 +62,7 @@ struct Config Config(); - void read(); + void read(int argc, char *argv[]); void readGameINI(); }; diff --git a/src/main.cpp b/src/main.cpp index 2bf606d..13bd599 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -224,7 +224,7 @@ int rgssThreadFun(void *userdata) return 0; } -int main(int, char *argv[]) +int main(int argc, char *argv[]) { /* initialize SDL first */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) @@ -253,7 +253,7 @@ int main(int, char *argv[]) /* now we load the config */ Config conf; - conf.read(); + conf.read(argc, argv); conf.readGameINI(); int imgFlags = IMG_INIT_PNG | IMG_INIT_JPG;