Avoid polluting preferences file with null commands (Bug #21969)

Only save non-default hot-keys to the preferences file if the hot-key is active (ie command != 'null').

Clearing hot-keys in memory (via the hot-key functions in the game) only sets the command to 'null', which currently gets written to the preferences file if it is a custom, ie non-default, hot-key. Over time, creating and clearing hot-keys results in a lot of redundant hot-key entries. The nice thing about this update is that it will remove redundant command='null' entries for existing preferences files as well as prevent it from being included in future ones..

I am making this change against the sdl2 branch instead of master because the sdl2 branch already contains a lot of rewriting of the hot-key functionality. Testing against master was also hopeless because hot-key handling is still rather broken building against SDL 1.2.
This commit is contained in:
Wedge009 2015-10-18 00:59:52 +11:00
parent d5b20f9c21
commit 798a99b27a

View file

@ -462,7 +462,7 @@ void save_hotkeys(config& cfg)
cfg.clear_children("hotkey");
BOOST_FOREACH(hotkey_ptr item, hotkeys_) {
if (!item->is_default()) {
if (!item->is_default() && item->active()) {
item->save(cfg.add_child("hotkey"));
}
}