Skip to content

Commit 9003175

Browse files
committed
Add migration for renamed hotkeys
Relates to #758
1 parent a1c1a74 commit 9003175

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

src/core/hotkey_config.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ static const char *ini_keys[] = {
2626
"decrease_game_speed",
2727
"rotate_map_left",
2828
"rotate_map_right",
29-
"build_clear_land",
30-
"build_vacant_house",
29+
"build_clear",
30+
"build_house",
3131
"build_road",
3232
"build_plaza",
3333
"build_gardens",
@@ -227,6 +227,15 @@ static void load_defaults(void)
227227
}
228228
}
229229

230+
static void add_mapping(int hotkey_id, const char *value)
231+
{
232+
hotkey_mapping mapping;
233+
if (key_combination_from_name(value, &mapping.key, &mapping.modifiers)) {
234+
mapping.action = hotkey_id;
235+
hotkey_config_add_mapping(&mapping);
236+
}
237+
}
238+
230239
static void load_file(void)
231240
{
232241
hotkey_config_clear();
@@ -250,14 +259,16 @@ static void load_file(void)
250259
char *value = &equals[1];
251260
for (int i = 0; i < HOTKEY_MAX_ITEMS; i++) {
252261
if (strcmp(ini_keys[i], line) == 0) {
253-
hotkey_mapping mapping;
254-
if (key_combination_from_name(value, &mapping.key, &mapping.modifiers)) {
255-
mapping.action = i;
256-
hotkey_config_add_mapping(&mapping);
257-
}
262+
add_mapping(i, value);
258263
break;
259264
}
260265
}
266+
// Migrate changed keys
267+
if (strcmp("build_clear_land", line) == 0) {
268+
add_mapping(HOTKEY_BUILD_VACANT_HOUSE, value);
269+
} else if (strcmp("build_vacant_house", line) == 0) {
270+
add_mapping(HOTKEY_BUILD_CLEAR_LAND, value);
271+
}
261272
}
262273
file_close(fp);
263274
}

0 commit comments

Comments
 (0)