Anonymous | Login | 2024-04-20 03:58 CEST |
Main | My View | View Issues | Change Log | Wiki | Tavern | News |
Viewing Issue Simple Details [ Jump to Notes ] [ Wiki ] | [ View Advanced ] [ Issue History ] [ Print ] | ||||||
ID | Category | Severity | Reproducibility | Date Submitted | Last Update | ||
0006468 | [DCSS] Documentation | trivial | N/A | 2012-12-25 02:37 | 2014-04-03 15:39 | ||
Reporter | blackcustard | View Status | public | ||||
Assigned To | Medar | ||||||
Priority | normal | Resolution | done | ||||
Status | closed | Product Branch | 0.12 ancient branch | ||||
Summary | 0006468: Mistake in documentation in default config file on trunk | ||||||
Description |
Line 252+253 of the default config: "# You can change colours by using something like # $contaminated := magenta" https://gitorious.org/crawl/crawl/blobs/stone_soup-0.11/crawl-ref/settings/init.txt [^] This does NOT work. The options_guide shows how to do this correctly. Line 1455+1456: "If you want to colour all items that contain a certain prefix, use menu_colour ^= lightgreen:poisonous" http://gitorious.org/crawl/crawl/blobs/master/crawl-ref/docs/options_guide.txt [^] I've tested both versions, $poisonous := red and menu_colour ^= inventory:magenta:poisonous The second version works, the first does NOT. I think the default rc should be fixed. It doesn't have to document the correct way to do it, but it shouldn't document a way that doesn't work. |
||||||
Additional Information | |||||||
Tags | No tags attached. | ||||||
Attached Files |
0001-Changing-the-variables-used-by-the-default-options-f.patch [^] (8,813 bytes) 2013-03-23 23:12 [Show Content] [Hide Content]From fb5c201cc5714c9969c7492b2248af5f3e51863e Mon Sep 17 00:00:00 2001 From: blackcustard <peterwicksstringfield@gmail.com> Date: Sat, 23 Mar 2013 16:08:48 -0500 Subject: [PATCH] Changing the variables used by the default options files after they have loaded does nothing. So stop telling people to do it. Eliminate some default arguments. --- crawl-ref/docs/options_guide.txt | 5 ++++- crawl-ref/settings/init.txt | 24 ++++++++++++------------ crawl-ref/source/initfile.cc | 29 ++++++++++++++++++++++++----- crawl-ref/source/initfile.h | 3 +-- crawl-ref/source/l_crawl.cc | 2 +- crawl-ref/source/main.cc | 2 +- crawl-ref/source/options.h | 5 ++--- 7 files changed, 45 insertions(+), 25 deletions(-) diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index 455552b..5089d78 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -296,7 +296,10 @@ This is useful if you wish to prevent an included file from altering a variable. See settings/standard_colours.txt and settings/food_colouring.txt -for usage of aliases and variables. +for usage of aliases and variables. Note that changing the variables defined +in these files will only affect your own configuration file, as the default +options will have already been loaded. If you want to change them, you will +have to override the options themselves. 1- Starting Screen. diff --git a/crawl-ref/settings/init.txt b/crawl-ref/settings/init.txt index 101755e..1cecc5a 100644 --- a/crawl-ref/settings/init.txt +++ b/crawl-ref/settings/init.txt @@ -228,16 +228,16 @@ # # Food is colour coded by default as follows: # -# yellow = preferred food ($preferred) -# darkgrey = cannot be eaten at all ($inedible) -# lightred = causes rot ($rot-inducing) -# magenta = dangerous to use, mutagenic ($dangerous, $mutagenic) -# red = considered "evil" by your deity ($evil) -# lightgreen = poisonous ($poisonous) -# brown = contaminated, may cause nausea ($contaminated) +# yellow = preferred food +# darkgrey = cannot be eaten at all +# lightred = causes rot +# magenta = dangerous to use, mutagenic +# red = considered "evil" by your deity +# lightgreen = poisonous +# brown = contaminated, may cause nausea # # You can change colours by using something like -# $contaminated := magenta +# menu_colour ^= magenta:contaminated # You can redefine inventory items like this: # menu_colour ^= inventory:magenta:shillelagh @@ -247,10 +247,10 @@ # Colouring of messages # Messages are colour coded as follows: # -# lightred = really important messages ($danger) -# yellow = significant messages ($warning) -# lightred = item damaged/destroyed ($item_dmg [same as $danger]) -# darkgrey = boring, message clutter ($boring) +# lightred = really important messages +# yellow = significant messages +# lightred = item damaged/destroyed +# darkgrey = boring, message clutter # # Notes also use, quite misnamed, menu_colour: diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index f4be089..02d759e 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -1,6 +1,12 @@ /** * @file * @brief Simple reading of an init file and system variables + * @detailed read_init_file is the main function, but read_option_line does + * most of the work though. Read through read_init_file to get an overview of + * how Crawl loads options. This file also contains a large number of utility + * functions for setting particular options and converting between human + * readable strings and internal values. (E.g. str_to_enemy_hp_colour, + * _weapon_to_str). There is also some code dealing with sorting menus. **/ #include "AppHdr.h" @@ -1433,6 +1439,7 @@ string read_init_file(bool runscript) { Options.reset_options(); + // Load Lua builtins. #ifdef CLUA_BINDINGS if (runscript) { @@ -1444,10 +1451,12 @@ string read_init_file(bool runscript) } } + // Load default options. for (unsigned int i = 0; i < ARRAYSZ(config_defaults); ++i) Options.include(datafile_path(config_defaults[i]), false, runscript); #endif + // Load early binding extra options from the command line BEFORE init.txt. Options.filename = "extra opts first"; Options.basefilename = "extra opts first"; Options.line_num = 0; @@ -1457,6 +1466,7 @@ string read_init_file(bool runscript) Options.read_option_line(SysEnv.extra_opts_first[i], true); } + // Load init.txt. const string init_file_name(_find_crawlrc()); FileLineInput f(init_file_name.c_str()); @@ -1482,8 +1492,9 @@ string read_init_file(bool runscript) #else Options.basefilename = "init.txt"; #endif - Options.read_options(f, runscript); + Options.read_options(f, runscript, true); + // Load late binding extra options from the command line AFTER init.txt. Options.filename = "extra opts last"; Options.basefilename = "extra opts last"; Options.line_num = 0; @@ -1522,7 +1533,7 @@ newgame_def read_startup_prefs() return newgame_def(); game_options temp; - temp.read_options(fl, false); + temp.read_options(fl, false, true); return temp.game; #endif // !DISABLE_STICKY_STARTUP_OPTIONS @@ -1872,6 +1883,14 @@ int game_options::read_explore_stop_conditions(const string &field) const return conditions; } +// Note the distinction between: +// 1. aliases "ae := autopickup_exception" "ae += useless_item" +// stored in game_options.aliases. +// 2. variables "$slots := abc" "spell_slots += Dispel undead:$slots" +// stored in game_options.variables. +// 3. constant variables "$slots = abc", "constant = slots". +// stored in game_options.variables, but with an extra entry in +// game_options.constants. void game_options::add_alias(const string &key, const string &val) { if (key[0] == '$') @@ -2039,14 +2058,14 @@ void game_options::set_option_fragment(const string &s) { // Boolean option. if (s[0] == '!') - read_option_line(s.substr(1) + " = false"); + read_option_line(s.substr(1) + " = false", false); else - read_option_line(s + " = true"); + read_option_line(s + " = true", false); } else { // key:val option. - read_option_line(s.substr(0, st) + " = " + s.substr(st + 1)); + read_option_line(s.substr(0, st) + " = " + s.substr(st + 1), false); } } diff --git a/crawl-ref/source/initfile.h b/crawl-ref/source/initfile.h index 3aeddce..cf44b0c 100644 --- a/crawl-ref/source/initfile.h +++ b/crawl-ref/source/initfile.h @@ -28,8 +28,7 @@ string read_init_file(bool runscript = false); struct newgame_def; newgame_def read_startup_prefs(); -void read_options(const string &s, bool runscript = false, - bool clear_aliases = false); +void read_options(const string &s, bool runscript, bool clear_aliases); void get_system_environment(void); diff --git a/crawl-ref/source/l_crawl.cc b/crawl-ref/source/l_crawl.cc index 0a87710..a583991 100644 --- a/crawl-ref/source/l_crawl.cc +++ b/crawl-ref/source/l_crawl.cc @@ -420,7 +420,7 @@ static int crawl_setopt(lua_State *ls) if (s) { // Note that the conditional script can contain nested Lua[ ]Lua code. - read_options(s, true); + read_options(s, true, true); } return 0; diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc index 84a43fe..9b26d22 100644 --- a/crawl-ref/source/main.cc +++ b/crawl-ref/source/main.cc @@ -315,7 +315,7 @@ int main(int argc, char *argv[]) init_item_name_cache(); // Read the init file. - init_file_error = read_init_file(); + init_file_error = read_init_file(false); // Now parse the args again, looking for everything else. parse_args(argc, argv, false); diff --git a/crawl-ref/source/options.h b/crawl-ref/source/options.h index bdcd9a6..6e035be 100644 --- a/crawl-ref/source/options.h +++ b/crawl-ref/source/options.h @@ -79,9 +79,8 @@ public: game_options(); void reset_options(); - void read_option_line(const string &s, bool runscripts = false); - void read_options(LineInput &, bool runscripts, - bool clear_aliases = true); + void read_option_line(const string &s, bool runscripts); + void read_options(LineInput &, bool runscripts, bool clear_aliases); void include(const string &file, bool resolve, bool runscript); void report_error(PRINTF(1, )); -- 1.7.11.msysgit.1 0001-Read-constant-variables-in-rcs-before-any-other-opti.patch [^] (13,419 bytes) 2013-03-23 23:12 [Show Content] [Hide Content] From 14e228aa16a963bf7108f2d7e494200ccfe1751f Mon Sep 17 00:00:00 2001 From: blackcustard <peterwicksstringfield@gmail.com> Date: Sat, 23 Mar 2013 11:29:01 -0500 Subject: [PATCH] Read constant variables in rcs before any other options. Eliminate some default arguments. --- crawl-ref/source/initfile.cc | 143 +++++++++++++++++++++++++++++++++---------- crawl-ref/source/initfile.h | 4 +- crawl-ref/source/l_crawl.cc | 2 +- crawl-ref/source/main.cc | 2 +- crawl-ref/source/options.h | 9 ++- 5 files changed, 121 insertions(+), 39 deletions(-) diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index f4be089..724a4df 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -1,6 +1,12 @@ /** * @file * @brief Simple reading of an init file and system variables + * @detailed read_init_file is the main function, but read_option_line does + * most of the work though. Read through read_init_file to get an overview of + * how Crawl loads options. This file also contains a large number of utility + * functions for setting particular options and converting between human + * readable strings and internal values. (E.g. str_to_enemy_hp_colour, + * _weapon_to_str). There is also some code dealing with sorting menus. **/ #include "AppHdr.h" @@ -583,7 +589,7 @@ void game_options::set_default_activity_interrupts() }; for (int i = 0; default_activity_interrupts[i]; ++i) - read_option_line(default_activity_interrupts[i], false); + read_option_line(default_activity_interrupts[i], false, false); } void game_options::clear_activity_interrupts( @@ -1428,11 +1434,27 @@ static const char* config_defaults[] = "defaults/misc.txt", }; +// We need to do a double pass through init.txt, loading ONLY constants +// and then everything. On that first pass, we end up loading variables +// too, so we need to get rid of them. +void game_options::delete_variables() +{ + string_map constants_only; + set<string>::const_iterator x; + for (x = constants.begin(); x != constants.end(); ++x) + { + mprf("CONSTANT SAVED: %s", x->c_str()); + constants_only[*x] = variables[*x]; + } + variables = constants_only; +} + // Returns an error message if the init.txt was not found. string read_init_file(bool runscript) { Options.reset_options(); + // Load lua builtins. #ifdef CLUA_BINDINGS if (runscript) { @@ -1444,23 +1466,49 @@ string read_init_file(bool runscript) } } + // Read init.txt. + const string init_file_name(_find_crawlrc()); + FileLineInput init_file(init_file_name.c_str()); + bool error_loading_init_file = init_file.error(); + + // Slurp the contents into memory so we can make two passes over them. + string init_file_contents; + while (!init_file.eof()) + init_file_contents += init_file.get_line() + '\n'; + + // init.txt first pass to load all constant variables so they apply to the + // default options. + if (!error_loading_init_file) + { + Options.filename = init_file_name; + Options.basefilename = get_base_filename(init_file_name); + Options.line_num = 0; + read_options(init_file_contents, false, false, true); + } + // But note: we only want to load CONSTANTS. So get rid of the variables. + Options.delete_variables(); + + // Load the defaults. + Options.filename = "unknown"; + Options.basefilename = "unknown"; + Options.line_num = -1; for (unsigned int i = 0; i < ARRAYSZ(config_defaults); ++i) Options.include(datafile_path(config_defaults[i]), false, runscript); #endif + // Load the early binding options from the command line. These go BEFORE + // init.txt. Options.filename = "extra opts first"; Options.basefilename = "extra opts first"; Options.line_num = 0; for (unsigned int i = 0; i < SysEnv.extra_opts_first.size(); i++) { Options.line_num++; - Options.read_option_line(SysEnv.extra_opts_first[i], true); + Options.read_option_line(SysEnv.extra_opts_first[i], true, false); } - const string init_file_name(_find_crawlrc()); - - FileLineInput f(init_file_name.c_str()); - if (f.error()) + // If we could not load init.txt, then we stop here. + if (error_loading_init_file) { if (!init_file_name.empty()) { @@ -1475,22 +1523,23 @@ string read_init_file(bool runscript) #endif } + // init.txt second pass. Load it for real this time. Note that the + // constants we loaded in the first pass are still there, plus any new + // constants or variables from the defaults or early finding extra options. Options.filename = init_file_name; + Options.basefilename = get_base_filename(init_file_name); Options.line_num = 0; -#ifdef UNIX - Options.basefilename = "~/.crawlrc"; -#else - Options.basefilename = "init.txt"; -#endif - Options.read_options(f, runscript); + read_options(init_file_contents, runscript, false, false); + // Load the late binding options from the command line. These go AFTER + // init.txt. Options.filename = "extra opts last"; Options.basefilename = "extra opts last"; Options.line_num = 0; for (unsigned int i = 0; i < SysEnv.extra_opts_last.size(); i++) { Options.line_num++; - Options.read_option_line(SysEnv.extra_opts_last[i], false); + Options.read_option_line(SysEnv.extra_opts_last[i], false, false); } Options.filename = init_file_name; @@ -1522,7 +1571,7 @@ newgame_def read_startup_prefs() return newgame_def(); game_options temp; - temp.read_options(fl, false); + temp.read_options(fl, false, true, false); return temp.game; #endif // !DISABLE_STICKY_STARTUP_OPTIONS @@ -1597,10 +1646,11 @@ void save_player_name() #endif // !DISABLE_STICKY_STARTUP_OPTIONS } -void read_options(const string &s, bool runscript, bool clear_aliases) +void read_options(const string &s, bool runscript, bool clear_aliases, + bool early_alias_pass) { StringLineInput st(s); - Options.read_options(st, runscript, clear_aliases); + Options.read_options(st, runscript, clear_aliases, early_alias_pass); } game_options::game_options() @@ -1611,7 +1661,7 @@ game_options::game_options() } void game_options::read_options(LineInput &il, bool runscript, - bool clear_aliases) + bool clear_aliases, bool early_alias_pass) { unsigned int line = 0; @@ -1764,7 +1814,7 @@ void game_options::read_options(LineInput &il, bool runscript, continue; } - read_option_line(str, runscript); + read_option_line(str, runscript, early_alias_pass); } #ifdef CLUA_BINDINGS @@ -1872,6 +1922,14 @@ int game_options::read_explore_stop_conditions(const string &field) const return conditions; } +// Note the distinction between: +// 1. aliases "ae := autopickup_exception" "ae += useless_item" +// stored in game_options.aliases. +// 2. variables "$slots := abc" "spell_slots += Dispel undead:$slots" +// stored in game_options.variables. +// 3. constant variables "$slots = abc", "constant = slots". +// stored in game_options.variables, but with an extra entry in +// game_options.constants. void game_options::add_alias(const string &key, const string &val) { if (key[0] == '$') @@ -1881,6 +1939,7 @@ void game_options::add_alias(const string &key, const string &val) if (constants.find(name) != constants.end()) return; variables[name] = val; + mprf("ADD ALIAS: %s, %s", name.c_str(), val.c_str()); } else aliases[key] = val; @@ -2039,14 +2098,15 @@ void game_options::set_option_fragment(const string &s) { // Boolean option. if (s[0] == '!') - read_option_line(s.substr(1) + " = false"); + read_option_line(s.substr(1) + " = false", false, false); else - read_option_line(s + " = true"); + read_option_line(s + " = true", false, false); } else { // key:val option. - read_option_line(s.substr(0, st) + " = " + s.substr(st + 1)); + read_option_line(s.substr(0, st) + " = " + s.substr(st + 1), false, + false); } } @@ -2166,7 +2226,8 @@ static bool _handle_list(bool old_semantics, vector<T> &value_list, return needs_warning; } -void game_options::read_option_line(const string &str, bool runscript) +void game_options::read_option_line(const string &str, bool runscript, + bool early_alias_pass) { #define BOOL_OPTION_NAMED(_opt_str, _opt_var) \ if (key == _opt_str) do { \ @@ -2317,6 +2378,33 @@ void game_options::read_option_line(const string &str, bool runscript) lowercase(field); } + if (key == "constant") + { + // Do not throw errors during the early alias pass. They would show up + // twice. + if (variables.find(field) == variables.end()) + { + if (!early_alias_pass) + report_error("No variable named '%s' to make constant", + field.c_str()); + } + else if (constants.find(field) != constants.end()) + { + if (!early_alias_pass) + report_error("'%s' is already a constant", field.c_str()); + } + else + { + mprf("CONSTANT ADDED: %s", field.c_str()); + constants.insert(field); + } + } + + // We don't need to go any farther than this. If this line created an alias + // or made one constant then we have already figured it out. + if (early_alias_pass) + return; + if (key == "include") include(field, true, runscript); else if (key == "opt" || key == "option") @@ -3583,15 +3671,6 @@ void game_options::read_option_line(const string &str, bool runscript) else if (key == "bindkey") _bindkey(field); - else if (key == "constant") - { - if (variables.find(field) == variables.end()) - report_error("No variable named '%s' to make constant", field.c_str()); - else if (constants.find(field) != constants.end()) - report_error("'%s' is already a constant", field.c_str()); - else - constants.insert(field); - } else INT_OPTION(arena_delay, 0, INT_MAX); else BOOL_OPTION(arena_dump_msgs); else BOOL_OPTION(arena_dump_msgs_all); @@ -3719,7 +3798,7 @@ void game_options::include(const string &rawfilename, bool resolve, FileLineInput fl(include_file.c_str()); if (!fl.error()) - read_options(fl, runscript, false); + read_options(fl, runscript, false, false); } void game_options::report_error(const char* format, ...) diff --git a/crawl-ref/source/initfile.h b/crawl-ref/source/initfile.h index 3aeddce..7481986 100644 --- a/crawl-ref/source/initfile.h +++ b/crawl-ref/source/initfile.h @@ -28,8 +28,8 @@ string read_init_file(bool runscript = false); struct newgame_def; newgame_def read_startup_prefs(); -void read_options(const string &s, bool runscript = false, - bool clear_aliases = false); +void read_options(const string &s, bool runscript, bool clear_aliases, + bool early_alias_pass); void get_system_environment(void); diff --git a/crawl-ref/source/l_crawl.cc b/crawl-ref/source/l_crawl.cc index 0a87710..611dadc 100644 --- a/crawl-ref/source/l_crawl.cc +++ b/crawl-ref/source/l_crawl.cc @@ -420,7 +420,7 @@ static int crawl_setopt(lua_State *ls) if (s) { // Note that the conditional script can contain nested Lua[ ]Lua code. - read_options(s, true); + read_options(s, true, true, false); } return 0; diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc index 84a43fe..9b26d22 100644 --- a/crawl-ref/source/main.cc +++ b/crawl-ref/source/main.cc @@ -315,7 +315,7 @@ int main(int argc, char *argv[]) init_item_name_cache(); // Read the init file. - init_file_error = read_init_file(); + init_file_error = read_init_file(false); // Now parse the args again, looking for everything else. parse_args(argc, argv, false); diff --git a/crawl-ref/source/options.h b/crawl-ref/source/options.h index bdcd9a6..58c404b 100644 --- a/crawl-ref/source/options.h +++ b/crawl-ref/source/options.h @@ -79,9 +79,10 @@ public: game_options(); void reset_options(); - void read_option_line(const string &s, bool runscripts = false); - void read_options(LineInput &, bool runscripts, - bool clear_aliases = true); + void read_option_line(const string &s, bool runscripts, + bool early_alias_pass); + void read_options(LineInput &, bool runscripts, bool clear_aliases, + bool early_alias_pass); void include(const string &file, bool resolve, bool runscript); void report_error(PRINTF(1, )); @@ -477,6 +478,8 @@ public: // Fix option values if necessary, specifically file paths. void fixup_options(); + // Delete all non-constant variables. + void delete_variables(); private: string unalias(const string &key) const; -- 1.7.11.msysgit.1 0002-Changing-the-variables-used-by-the-default-options-f.patch [^] (2,954 bytes) 2013-03-29 19:05 [Show Content] [Hide Content] From ece1154a8b6900e2acb0d939b0f22d49fa63bbeb Mon Sep 17 00:00:00 2001 From: blackcustard <peterwicksstringfield@gmail.com> Date: Sat, 23 Mar 2013 15:38:59 -0500 Subject: [PATCH 2/2] Changing the variables used by the default options files after they have loaded does nothing. So stop telling people to do it. --- crawl-ref/docs/options_guide.txt | 5 ++++- crawl-ref/settings/init.txt | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index a6f5ce5..d943df9 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -296,7 +296,10 @@ This is useful if you wish to prevent an included file from altering a variable. See settings/standard_colours.txt and settings/food_colouring.txt -for usage of aliases and variables. +for usage of aliases and variables. Note that changing the variables defined +in these files will only affect your own configuration file, as the default +options will have already been loaded. If you want to change them, you will +have to override the options themselves. 1- Starting Screen. diff --git a/crawl-ref/settings/init.txt b/crawl-ref/settings/init.txt index 9c18630..22eaf32 100644 --- a/crawl-ref/settings/init.txt +++ b/crawl-ref/settings/init.txt @@ -228,16 +228,16 @@ # # Food is colour coded by default as follows: # -# yellow = preferred food ($preferred) -# darkgrey = cannot be eaten at all ($inedible) -# lightred = causes rot ($rot-inducing) -# magenta = dangerous to use, mutagenic ($dangerous, $mutagenic) -# red = considered "evil" by your deity ($evil) -# lightgreen = poisonous ($poisonous) -# brown = contaminated, may cause nausea ($contaminated) +# yellow = preferred food +# darkgrey = cannot be eaten at all +# lightred = causes rot +# magenta = dangerous to use, mutagenic +# red = considered "evil" by your deity +# lightgreen = poisonous +# brown = contaminated, may cause nausea # # You can change colours by using something like -# $contaminated := magenta +# menu_colour ^= magenta:contaminated # You can redefine inventory items like this: # menu_colour ^= inventory:magenta:shillelagh @@ -247,10 +247,10 @@ # Colouring of messages # Messages are colour coded as follows: # -# lightred = really important messages ($danger) -# yellow = significant messages ($warning) -# lightred = item damaged/destroyed ($item_dmg [same as $danger]) -# darkgrey = boring, message clutter ($boring) +# lightred = really important messages +# yellow = significant messages +# lightred = item damaged/destroyed +# darkgrey = boring, message clutter # # Notes also use, quite misnamed, menu_colour: -- 1.7.11.msysgit.1 0001-Document-initfile.cc-a-little-bit-better.patch [^] (2,942 bytes) 2013-03-29 19:05 [Show Content] [Hide Content] From 3ec3539fb4e56693b800769fbef0d79b85901921 Mon Sep 17 00:00:00 2001 From: blackcustard <peterwicksstringfield@gmail.com> Date: Sat, 23 Mar 2013 16:08:48 -0500 Subject: [PATCH 1/2] Document initfile.cc a little bit better. --- crawl-ref/source/initfile.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 437011b..a6c3289 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -1,6 +1,12 @@ /** * @file * @brief Simple reading of an init file and system variables + * @detailed read_init_file is the main function, but read_option_line does + * most of the work though. Read through read_init_file to get an overview of + * how Crawl loads options. This file also contains a large number of utility + * functions for setting particular options and converting between human + * readable strings and internal values. (E.g. str_to_enemy_hp_colour, + * _weapon_to_str). There is also some code dealing with sorting menus. **/ #include "AppHdr.h" @@ -1434,6 +1440,7 @@ string read_init_file(bool runscript) { Options.reset_options(); + // Load Lua builtins. #ifdef CLUA_BINDINGS if (runscript) { @@ -1445,10 +1452,12 @@ string read_init_file(bool runscript) } } + // Load default options. for (unsigned int i = 0; i < ARRAYSZ(config_defaults); ++i) Options.include(datafile_path(config_defaults[i]), false, runscript); #endif + // Load early binding extra options from the command line BEFORE init.txt. Options.filename = "extra opts first"; Options.basefilename = "extra opts first"; Options.line_num = 0; @@ -1458,6 +1467,7 @@ string read_init_file(bool runscript) Options.read_option_line(SysEnv.extra_opts_first[i], true); } + // Load init.txt. const string init_file_name(_find_crawlrc()); FileLineInput f(init_file_name.c_str()); @@ -1485,6 +1495,7 @@ string read_init_file(bool runscript) #endif Options.read_options(f, runscript); + // Load late binding extra options from the command line AFTER init.txt. Options.filename = "extra opts last"; Options.basefilename = "extra opts last"; Options.line_num = 0; @@ -1873,6 +1884,14 @@ int game_options::read_explore_stop_conditions(const string &field) const return conditions; } +// Note the distinction between: +// 1. aliases "ae := autopickup_exception" "ae += useless_item" +// stored in game_options.aliases. +// 2. variables "$slots := abc" "spell_slots += Dispel undead:$slots" +// stored in game_options.variables. +// 3. constant variables "$slots = abc", "constant = slots". +// stored in game_options.variables, but with an extra entry in +// game_options.constants. void game_options::add_alias(const string &key, const string &val) { if (key[0] == '$') -- 1.7.11.msysgit.1 |
||||||
|
Mantis 1.1.8[^] Copyright © 2000 - 2009 Mantis Group |