From 440636cfb2a1d1304c976677e7571c917023d65c Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Sun, 22 Nov 2009 00:07:49 +0100 Subject: Add an option, -builddb, to build the database and exit. --- crawl-ref/source/initfile.cc | 11 +++++++++-- crawl-ref/source/main.cc | 3 +++ crawl-ref/source/state.cc | 2 +- crawl-ref/source/state.h | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 55a7a1f258..bc31bfdc33 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -3463,6 +3463,7 @@ enum commandline_option_type { CLO_MAPSTAT, CLO_ARENA, CLO_TEST, + CLO_BUILDDB, CLO_HELP, CLO_VERSION, CLO_EXTRA_OPT_FIRST, @@ -3474,8 +3475,8 @@ enum commandline_option_type { static const char *cmd_ops[] = { "scores", "name", "species", "job", "plain", "dir", "rc", "rcdir", "tscores", "vscores", "scorefile", "morgue", "macro", - "mapstat", "arena", "test", "help", "version", "extra-opt-first", - "extra-opt-last" + "mapstat", "arena", "test", "builddb", "help", "version", + "extra-opt-first", "extra-opt-last", }; const int num_cmd_ops = CLO_NOPS; @@ -3708,6 +3709,12 @@ bool parse_args( int argc, char **argv, bool rc_only ) } break; + case CLO_BUILDDB: + if (next_is_param) + return (false); + crawl_state.build_db = true; + break; + case CLO_MACRO: if (!next_is_param) return (false); diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc index 2bb5e2f881..0efc8cb662 100644 --- a/crawl-ref/source/main.cc +++ b/crawl-ref/source/main.cc @@ -3686,6 +3686,9 @@ static bool _initialise(void) // Read special levels and vaults. read_maps(); + if (crawl_state.build_db) + end(0); + cio_init(); // System initialisation stuff. diff --git a/crawl-ref/source/state.cc b/crawl-ref/source/state.cc index 59f5e1188a..7b3fca4988 100644 --- a/crawl-ref/source/state.cc +++ b/crawl-ref/source/state.cc @@ -27,7 +27,7 @@ game_state::game_state() : game_crashed(false), mouse_enabled(false), waiting_for_command(false), terminal_resized(false), io_inited(false), need_save(false), saving_game(false), updating_scores(false), seen_hups(0), - map_stat_gen(false), arena(false), arena_suspended(false), + map_stat_gen(false), arena(false), arena_suspended(false), build_db(false), unicode_ok(false), glyph2strfn(NULL), multibyte_strlen(NULL), terminal_resize_handler(NULL), terminal_resize_check(NULL), doing_prev_cmd_again(false), prev_cmd(CMD_NO_CMD), diff --git a/crawl-ref/source/state.h b/crawl-ref/source/state.h index c7d9529f8d..02af0a9190 100644 --- a/crawl-ref/source/state.h +++ b/crawl-ref/source/state.h @@ -50,6 +50,7 @@ struct game_state // suspended. bool test; // Set if we want to run self-tests and exit. + bool build_db; // Set if we want to rebuild the db and exit. std::vector tests_selected; // Tests to be run. bool unicode_ok; // Is unicode support available? -- cgit v1.2.3-54-g00ecf