- else if (key == get_action_key(world.keybindings, "keys nav up") && world.keyswindata->select > 0) {
- world.keyswindata->select--;
- draw_all_windows (&win_meta); }
- else if (key == get_action_key(world.keybindings, "keys nav down") && world.keyswindata->select < world.keyswindata->max) {
- world.keyswindata->select++;
- draw_all_windows (&win_meta); }
- else if (key == get_action_key(world.keybindings, "keys mod")) {
- world.keyswindata->edit = 1;
- draw_all_windows (&win_meta);
- key = getch();
- if (key < 1000) // ensure maximum of three digits in key code field
- world.keybindings[world.keyswindata->select].key = key;
- world.keyswindata->edit = 0;
- draw_all_windows (&win_meta); }
- else if (key == get_action_key(world.keybindings, "map up") && map.offset_y > 0) {
- map.offset_y--;
- draw_all_windows (&win_meta); }
- else if (key == get_action_key(world.keybindings, "map down")) {
- map.offset_y++;
- draw_all_windows (&win_meta); }
- else if (key == get_action_key(world.keybindings, "map right")) {
- map.offset_x++;
- draw_all_windows (&win_meta); }
- else if (key == get_action_key(world.keybindings, "map left") && map.offset_x > 0) {
- map.offset_x--;
- draw_all_windows (&win_meta); }
- else if (key == get_action_key(world.keybindings, "player down") && map.player_y < map.height - 1) {
- update_info (&win_info);
- update_log (&win_log, "\nYou move south.");
- map.player_y++;
- draw_all_windows (&win_meta); }
- else if (key == get_action_key(world.keybindings, "player up") && map.player_y > 0) {
- update_info (&win_info);
- update_log (&win_log, "\nYou move north.");
- map.player_y--;
- draw_all_windows (&win_meta); }
- else if (key == get_action_key(world.keybindings, "player right") && map.player_x < map.width - 1) {
- update_info (&win_info);
- update_log (&win_log, "\nYou move east.");
- map.player_x++;
- draw_all_windows (&win_meta); }
- else if (key == get_action_key(world.keybindings, "player left") && map.player_x > 0) {
- update_info (&win_info);
- update_log (&win_log, "\nYou move west.");
- map.player_x--;
- draw_all_windows (&win_meta); }
- else if (key == get_action_key(world.keybindings, "wait") ) {
- update_info (&win_info);
- update_log (&win_log, "\nYou wait.");
- draw_all_windows(&win_meta); } }
+ else if (key == get_action_key(world.keybindings, "keys nav up"))
+ keyswin_move_selection (&world, 'u');
+ else if (key == get_action_key(world.keybindings, "keys nav down"))
+ keyswin_move_selection (&world, 'd');
+ else if (key == get_action_key(world.keybindings, "keys mod"))
+ keyswin_mod_key (&world, &win_meta);
+ else if (key == get_action_key(world.keybindings, "save seed"))
+ save_seed(seed);
+ else if (key == get_action_key(world.keybindings, "map up"))
+ map_scroll (&map, 'n');
+ else if (key == get_action_key(world.keybindings, "map down"))
+ map_scroll (&map, 's');
+ else if (key == get_action_key(world.keybindings, "map right"))
+ map_scroll (&map, 'e');
+ else if (key == get_action_key(world.keybindings, "map left"))
+ map_scroll (&map, 'w');
+ else if (key == get_action_key(world.keybindings, "player down"))
+ move_player(&world, 's');
+ else if (key == get_action_key(world.keybindings, "player up"))
+ move_player(&world, 'n');
+ else if (key == get_action_key(world.keybindings, "player right"))
+ move_player(&world, 'e');
+ else if (key == get_action_key(world.keybindings, "player left"))
+ move_player(&world, 'w');
+ else if (key == get_action_key(world.keybindings, "wait") )
+ player_wait (&world); }
+
+ free(map.cells);
+ for (key = 0; key <= world.keyswindata->max; key++)
+ free(world.keybindings[key].name);
+ free(world.keybindings);
+ free(world.keyswindata);
+ free(world.log);