diff options
author | Neil Moore <neil@s-z.org> | 2013-05-26 15:30:54 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2013-05-26 15:39:18 -0400 |
commit | d8c861177ea69ba141ddfa227ac6e658efc2859a (patch) | |
tree | e38b2d0f273dc0c7c6c8562df1a2deaf8f07fa7d | |
parent | 7ec7b53325a43d426a44aeac3541654087cbe2e4 (diff) | |
download | crawl-ref-d8c861177ea69ba141ddfa227ac6e658efc2859a.tar.gz crawl-ref-d8c861177ea69ba141ddfa227ac6e658efc2859a.zip |
Make list_opt = foo reset the list, not append.
We have been warning of the impending change since 0.11.
Also remove the warn_list_append list and associated lua function,
since it was used only to implement the aforementioned warning.
-rw-r--r-- | crawl-ref/docs/options_guide.txt | 39 | ||||
-rw-r--r-- | crawl-ref/source/dat/clua/runrest.lua | 18 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 101 | ||||
-rw-r--r-- | crawl-ref/source/initfile.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/l_crawl.cc | 13 |
5 files changed, 46 insertions, 126 deletions
diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index fb54a15519..84710d76d5 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -240,25 +240,14 @@ It is possible to reset, add items to, or remove items from such an option. drop_filter ^= rotting Remove values from the list (exact match only): drop_filter -= enchant - Reset (empty) the list: + Reset the list: + drop_filter = bad_item, dangerous_item + Empty the list: drop_filter = -The meaning of the "listopt = value" syntax is in flux. Currently it is a -synonym for "+=", adding items to the list. In future versions of Crawl, it -will first reset the list before adding values. If you use "=" in a way that is -expected to change meaning (appending to an option that already has at least -one value), you will receive a warning at startup; in this case you can change -your syntax to obtain either the current or the future behaviour: - Old syntax: - drop_filter = useless - Change to (for old meaning): - drop_filter += useless - Change to (for future meaning): - drop_filter = - drop_filter += useless - -A few list options already have the future behaviour for "opt = value"; these -options are flagged as "Overriding list options" in their descriptions. +The "listopt = value" syntax first clears the list, then adds values. In +previous versions of Crawl it was a synonym for +=, and only bare +"listopt =" cleared the list. For many options, such as drop_filter, there is effectively no difference between appending and prepending. However, other options, such as @@ -805,7 +794,7 @@ explore_greedy = true explore_stop = items,stairs,shops,altars,portals,branches,runed_doors explore_stop += greedy_pickup_smart,greedy_visited_item_stack explore_stop += greedy_sacrificeable - (Overriding list option) + (List option) Explore will stop for one of these conditions. Whatever you set this option to, anything that stops travel will also stop explore. @@ -1285,18 +1274,18 @@ mp_warning = 0 percentage of their maximum (use 0 to turn off these messages). hp_colour = 50:yellow, 25:red - (Overriding list option) + (List option) hp_colour colours your Health appropriately in the status display. In the default setting, your health will appear in red if at less than 25%, yellow if at less than 50%, and in the default colour otherwise. mp_colour = 50:yellow, 25:red - (Overriding list option) + (List option) mp_colour does to Magic what hp_colour does to Health. stat_colour = 1:lightred, 3:red - (Overriding list option) + (List option) stat_colour colours your stats if they drop below a given value, in the order of their definition. This check takes place before the ones for e.g. Might or degeneration. @@ -1533,7 +1522,7 @@ skill_focus = true monster_list_colour += <key>:<colour>, <key>:<colour> monster_list_colour -= <key> - (Overriding list option) + (List option) Change the colours used to display monster names in the monster list. Valid keys, and their default colours, are: @@ -1566,7 +1555,7 @@ fire_items_start = a fire_order = launcher, return fire_order += javelin / dart / stone / rock / spear / net / handaxe / dagger fire_order += inscribed - (Overriding ordered list option) + (Ordered list option) Controls the order of items autoselected for firing. Items should be separated by commas and items that appear first get higher priority. @@ -1878,7 +1867,7 @@ tile_show_demon_tier = true builds. tile_layout_priority = minimap, inventory, gold_turn, command, spell, monster - (Overriding ordered list option) + (Ordered list option) This option allows you to control the order in which elements are placed on the right of the screen, below the stat area. On small resolution, there won't be enough room for everything, so only the @@ -1957,7 +1946,7 @@ dump_message_count = 20 dump_order = header,hiscore,stats,misc,notes,inventory, dump_order += skills,spells,overview,mutations,messages,screenshot, dump_order += monlist,kills,action_counts - (Overriding ordered list option) + (Ordered list option) Controls the order of sections in the dump. Two optional dump sections are "turns_by_place" and diff --git a/crawl-ref/source/dat/clua/runrest.lua b/crawl-ref/source/dat/clua/runrest.lua index 750c9b58e8..3fcff89506 100644 --- a/crawl-ref/source/dat/clua/runrest.lua +++ b/crawl-ref/source/dat/clua/runrest.lua @@ -124,15 +124,14 @@ end function rr_message_adder(v) local function rr_add_messages(key, value, mode) - if mode == 0 and value == "" then + if mode == 0 then -- Clear list for k in pairs (g_rr_ignored) do g_rr_ignored[k] = nil end - return - elseif mode == 0 and table.getn(g_rr_ignored) > 0 then - -- listopt = foo will reset listopt in 0.12, warn. - crawl.warn_list_append(key) + if value == "" then + return + end end local segs = crawl.split(value, ',', mode > 1) @@ -196,16 +195,15 @@ function rr_add_monsters(key, value, mode) return end - if mode == 0 and value == "" then + if mode == 0 then -- Clear list for k in pairs (mons_table[1]) do mons_table[1][k] = nil mons_table[2][k] = nil end - return - elseif mode == 0 and table.getn(mons_table[1]) > 0 then - -- listopt = foo will reset listopt in 0.12, warn. - crawl.warn_list_append(key) + if value == "" then + return + end end local segs = crawl.split(value, ',', mode > 1) diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 7c0c1c8363..399210d52e 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -69,11 +69,6 @@ const string game_options::interrupt_prefix = "interrupt_"; system_environment SysEnv; game_options Options; -// A list of keys used as "key = foo" but meaning "append to a list", -// where the list was non-empty. Such settings will reset the list and -// thus have different behaviour in 0.12, so warn about them now. -set<string> warn_list_append; - template <class L, class E> static L& remove_matching(L& lis, const E& entry) { @@ -1499,20 +1494,6 @@ string read_init_file(bool runscript) Options.basefilename = get_base_filename(init_file_name); Options.line_num = -1; - if (!warn_list_append.empty()) - { - string warn = - "Your configuration uses = to append to a list option. This " - "syntax will override the option in a future version. Use += " - "instead to append. Affected options are: "; - warn += comma_separated_line(warn_list_append.begin(), - warn_list_append.end()); - - // Can't use Options.report_error() as that prevents webtiles from - // starting the game. - mpr(warn, MSGCH_ERROR); - } - return ""; } @@ -2133,21 +2114,14 @@ static bool _first_greater(const pair<int, int> &l, const pair<int, int> &r) return l.first > r.first; } -// Returns true if the semantics of this call are expected to change: -// that is, if old_semantics is true, add and subtract are both false, -// and field is non-empty. T must be convertible to from a string. +// T must be convertible to from a string. template <class T> -static bool _handle_list(bool old_semantics, vector<T> &value_list, - string field, bool append, bool prepend, - bool subtract) +static void _handle_list(vector<T> &value_list, string field, + bool append, bool prepend, bool subtract) { - bool needs_warning = false; if (!append && !prepend && !subtract) { - if (!old_semantics || field.empty()) - value_list.clear(); - else if (!value_list.empty()) - needs_warning = true; + value_list.clear(); } vector<T> new_entries; @@ -2164,8 +2138,6 @@ static bool _handle_list(bool old_semantics, vector<T> &value_list, new_entries.push_back(*part); } _merge_lists(value_list, new_entries, prepend); - - return needs_warning; } void game_options::read_option_line(const string &str, bool runscript) @@ -2211,16 +2183,11 @@ void game_options::read_option_line(const string &str, bool runscript) #define INT_OPTION(_opt, _min_val, _max_val) \ INT_OPTION_NAMED(#_opt, _opt, _min_val, _max_val) -#define LIST_OPTION_NAMED(_opt_str, _opt_var, old) \ - if (key == _opt_str) do { \ - if (_handle_list(old, _opt_var, field, plus_equal, \ - caret_equal, minus_equal)) \ - { \ - warn_list_append.insert(key); \ - } \ +#define LIST_OPTION_NAMED(_opt_str, _opt_var) \ + if (key == _opt_str) do { \ + _handle_list(_opt_var, field, plus_equal, caret_equal, minus_equal); \ } while (false) -#define LIST_OPTION(_opt) LIST_OPTION_NAMED(#_opt, _opt, false) -#define OLD_LIST_OPTION(_opt) LIST_OPTION_NAMED(#_opt, _opt, true) +#define LIST_OPTION(_opt) LIST_OPTION_NAMED(#_opt, _opt) string key = ""; string subkey = ""; string field = ""; @@ -2669,8 +2636,8 @@ void game_options::read_option_line(const string &str, bool runscript) else BOOL_OPTION(show_game_turns); else INT_OPTION(hp_warning, 0, 100); else INT_OPTION_NAMED("mp_warning", magic_point_warning, 0, 100); - else OLD_LIST_OPTION(note_monsters); - else OLD_LIST_OPTION(note_messages); + else LIST_OPTION(note_monsters); + else LIST_OPTION(note_messages); else INT_OPTION(note_hp_percent, 0, 100); #ifndef DGAMELAUNCH // If DATA_DIR_PATH is set, don't set crawl_dir from .crawlrc. @@ -2800,7 +2767,7 @@ void game_options::read_option_line(const string &str, bool runscript) } else if (key == "ban_pickup") { - if (plain && field.empty()) + if (plain) { // Only remove negative, not positive, exceptions. force_autopickup.erase(remove_if(force_autopickup.begin(), @@ -2808,12 +2775,6 @@ void game_options::read_option_line(const string &str, bool runscript) _is_autopickup_ban), force_autopickup.end()); } - else if (plain && !count_if(force_autopickup.begin(), - force_autopickup.end(), - _is_autopickup_ban)) - { - warn_list_append.insert(key); - } vector<pair<text_pattern, bool> > new_entries; vector<string> args = split_string(",", field); @@ -2834,10 +2795,8 @@ void game_options::read_option_line(const string &str, bool runscript) } else if (key == "autopickup_exceptions") { - if (plain && field.empty()) + if (plain) force_autopickup.clear(); - else if (plain && !force_autopickup.empty()) - warn_list_append.insert(key); vector<pair<text_pattern, bool> > new_entries; vector<string> args = split_string(",", field); @@ -2863,7 +2822,7 @@ void game_options::read_option_line(const string &str, bool runscript) } _merge_lists(force_autopickup, new_entries, caret_equal); } - else OLD_LIST_OPTION(note_items); + else LIST_OPTION(note_items); #ifndef _MSC_VER // break if-else chain on broken Microsoft compilers with stupid nesting limits else @@ -2871,10 +2830,8 @@ void game_options::read_option_line(const string &str, bool runscript) if (key == "autoinscribe") { - if (plain && field.empty()) + if (plain) autoinscriptions.clear(); - else if (plain && !autoinscriptions.empty()) - warn_list_append.insert(key); const size_t first = field.find_first_of(':'); const size_t last = field.find_last_of(':'); @@ -3101,10 +3058,8 @@ void game_options::read_option_line(const string &str, bool runscript) } else if (key == "spell_slot") { - if (plain && field.empty()) + if (plain) auto_spell_letters.clear(); - else if (plain && !auto_spell_letters.empty()) - warn_list_append.insert(key); vector<string> thesplit = split_string(":", field); if (thesplit.size() != 2) @@ -3126,8 +3081,8 @@ void game_options::read_option_line(const string &str, bool runscript) #ifdef WIZARD else if (key == "fsim_mode") fsim_mode = field; - else OLD_LIST_OPTION(fsim_scale); - else OLD_LIST_OPTION(fsim_kit); + else LIST_OPTION(fsim_scale); + else LIST_OPTION(fsim_kit); else if (key == "fsim_rounds") { fsim_rounds = atol(field.c_str()); @@ -3190,10 +3145,8 @@ void game_options::read_option_line(const string &str, bool runscript) else BOOL_OPTION(show_player_species); else if (key == "force_more_message") { - if (plain && field.empty()) + if (plain) force_more_message.clear(); - else if (plain && !force_more_message.empty()) - warn_list_append.insert(key); vector<message_filter> new_entries; vector<string> fragments = split_string(",", field); @@ -3223,7 +3176,7 @@ void game_options::read_option_line(const string &str, bool runscript) } _merge_lists(force_more_message, new_entries, caret_equal); } - else OLD_LIST_OPTION(drop_filter); + else LIST_OPTION(drop_filter); else if (key == "travel_avoid_terrain") { // TODO: allow resetting (need reset_forbidden_terrain()) @@ -3244,7 +3197,7 @@ void game_options::read_option_line(const string &str, bool runscript) tc_dangerous = str_to_colour(field, tc_dangerous); else if (key == "tc_disconnected") tc_disconnected = str_to_colour(field, tc_disconnected); - else OLD_LIST_OPTION(auto_exclude); + else LIST_OPTION(auto_exclude); else BOOL_OPTION(easy_exit_menu); else BOOL_OPTION(dos_use_background_intensity); else if (key == "item_stack_summary_minimum") @@ -3270,7 +3223,7 @@ void game_options::read_option_line(const string &str, bool runscript) else explore_stop_prompt |= new_conditions; } - else OLD_LIST_OPTION(explore_stop_pickup_ignore); + else LIST_OPTION(explore_stop_pickup_ignore); else if (key == "explore_item_greed") { explore_item_greed = atoi(field.c_str()); @@ -3303,10 +3256,8 @@ void game_options::read_option_line(const string &str, bool runscript) } else if (key == "sound") { - if (plain && field.empty()) + if (plain) sound_mappings.clear(); - else if (plain && !sound_mappings.empty()) - warn_list_append.insert(key); vector<sound_mapping> new_entries; vector<string> seg = split_string(",", field); @@ -3333,10 +3284,8 @@ void game_options::read_option_line(const string &str, bool runscript) #endif if (key == "menu_colour" || key == "menu_color") { - if (plain && field.empty()) + if (plain) menu_colour_mappings.clear(); - else if (plain && !menu_colour_mappings.empty()) - warn_list_append.insert(key); vector<colour_mapping> new_entries; vector<string> seg = split_string(",", field); @@ -3377,10 +3326,8 @@ void game_options::read_option_line(const string &str, bool runscript) else if (key == "message_colour" || key == "message_color") { // TODO: support -= here. - if (plain && field.empty()) + if (plain) message_colour_mappings.clear(); - else if (plain && !message_colour_mappings.empty()) - warn_list_append.insert(key); add_message_colour_mappings(field, caret_equal, minus_equal); } diff --git a/crawl-ref/source/initfile.h b/crawl-ref/source/initfile.h index 3aeddceb6f..cdab79aef2 100644 --- a/crawl-ref/source/initfile.h +++ b/crawl-ref/source/initfile.h @@ -71,7 +71,6 @@ public: }; extern system_environment SysEnv; -extern set<string> warn_list_append; bool parse_args(int argc, char **argv, bool rc_only); diff --git a/crawl-ref/source/l_crawl.cc b/crawl-ref/source/l_crawl.cc index 56149d2c65..4afb17f319 100644 --- a/crawl-ref/source/l_crawl.cc +++ b/crawl-ref/source/l_crawl.cc @@ -927,18 +927,6 @@ static int crawl_tutorial_msg(lua_State *ls) return 0; } -/* ---- Warn about listopt = value when the semantics are slated to change. -function l_warn_list_append(key) */ -static int crawl_warn_list_append(lua_State *ls) -{ - const char *key = luaL_checkstring(ls, 1); - if (!key) - return 0; - warn_list_append.insert(key); - return 0; -} - LUAWRAP(crawl_dump_char, dump_char(you.your_name, true)) #ifdef WIZARD @@ -1055,7 +1043,6 @@ static const struct luaL_reg crawl_clib[] = { "get_command", crawl_get_command }, { "endgame", crawl_endgame }, { "tutorial_msg", crawl_tutorial_msg }, - { "warn_list_append", crawl_warn_list_append }, { "dump_char", crawl_dump_char }, #ifdef WIZARD { "call_dlua", crawl_call_dlua }, |