From: Christian Heller Date: Sat, 6 Dec 2014 06:12:37 +0000 (+0100) Subject: Client: Drop now redundant map centering systems. X-Git-Tag: tce~573 X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%22https:/validator.w3.org/tasks?a=commitdiff_plain;h=5efc409a3640bcc8b2b4d5310a7e09c1e22afeba;p=plomrogue Client: Drop now redundant map centering systems. --- diff --git a/confclient/commands b/confclient/commands index e64bdf5..70c61b5 100644 --- a/confclient/commands +++ b/confclient/commands @@ -158,9 +158,6 @@ DESCRIPTION 'map left' COMMAND map_r DESCRIPTION 'map right' -COMMAND map_c -DESCRIPTION 'map center player' - COMMAND to_inv DESCRIPTION 'window inventory' @@ -185,8 +182,5 @@ DESCRIPTION 'window geometry keys' COMMAND to_wk_keywin DESCRIPTION 'window keybinding keys' -COMMAND to_autofocus -DESCRIPTION 'toggle auto-center' - COMMAND to_look DESCRIPTION 'toggle look mode' diff --git a/confclient/interface_conf b/confclient/interface_conf index 2cc3648..69dac92 100644 --- a/confclient/interface_conf +++ b/confclient/interface_conf @@ -109,6 +109,4 @@ KEY 259 map_u KEY 258 map_d KEY 260 map_l KEY 261 map_r -KEY 46 map_c -KEY 70 to_autofocus KEY 108 to_look diff --git a/confclient/single_wins/info b/confclient/single_wins/info index 78a63f9..462f6a7 100644 --- a/confclient/single_wins/info +++ b/confclient/single_wins/info @@ -24,10 +24,8 @@ KEY 99 move_c KEY 120 move_x KEY 115 move_s KEY 119 move_w -KEY 46 map_c KEY 68 drop KEY 117 use -KEY 70 to_autofocus KEYBINDINGS 'wingeom' KEY 258 shift_f diff --git a/confclient/single_wins/inventory b/confclient/single_wins/inventory index b831f50..2a24b67 100644 --- a/confclient/single_wins/inventory +++ b/confclient/single_wins/inventory @@ -24,10 +24,8 @@ KEY 99 move_c KEY 120 move_x KEY 115 move_s KEY 119 move_w -KEY 46 map_c KEY 68 drop KEY 117 use -KEY 70 to_autofocus KEYBINDINGS 'wingeom' KEY 258 shift_f diff --git a/confclient/single_wins/log b/confclient/single_wins/log index 40b9be4..0b92f77 100644 --- a/confclient/single_wins/log +++ b/confclient/single_wins/log @@ -24,10 +24,8 @@ KEY 99 move_c KEY 120 move_x KEY 115 move_s KEY 119 move_w -KEY 46 map_c KEY 68 drop KEY 117 use -KEY 70 to_autofocus KEYBINDINGS 'wingeom' KEY 258 shift_f diff --git a/confclient/single_wins/map b/confclient/single_wins/map index 56e7f34..6d6a399 100644 --- a/confclient/single_wins/map +++ b/confclient/single_wins/map @@ -24,10 +24,8 @@ KEY 99 move_c KEY 120 move_x KEY 115 move_s KEY 119 move_w -KEY 46 map_c KEY 68 drop KEY 117 use -KEY 70 to_autofocus KEYBINDINGS 'wingeom' KEY 258 shift_f diff --git a/confclient/single_wins/things_here b/confclient/single_wins/things_here index ea87f9f..4936331 100644 --- a/confclient/single_wins/things_here +++ b/confclient/single_wins/things_here @@ -25,10 +25,8 @@ KEY 99 move_c KEY 120 move_x KEY 115 move_s KEY 119 move_w -KEY 46 map_c KEY 68 drop KEY 117 use -KEY 70 to_autofocus KEYBINDINGS 'wingeom' KEY 258 shift_f diff --git a/src/client/control.c b/src/client/control.c index 76d69ac..13e57dd 100644 --- a/src/client/control.c +++ b/src/client/control.c @@ -17,9 +17,7 @@ #include "keybindings.h" /* get_command_to_keycode(), get_keycode_to_command(), * mod_selected_keyb(), move_keyb_selection() */ -#include "map.h" /* map_scroll(), map_center(), toggle_autofocus(), - * toggle_lookmode(), lookmode_nav() - */ +#include "map.h" /* map_scroll(),toggle_lookmode(),lookmode_nav()*/ #include "wincontrol.h" /* shift_active_win(), resize_active_win(), * toggle_win_size_type(), toggle_window(), * cycle_active_win(), scroll_v_screen(), @@ -136,9 +134,7 @@ static uint8_t try_kb_manip(char * command) static uint8_t try_client_commands(struct Command * command) { - return ( try_0args(command, "map_c", map_center) - || try_0args(command, "to_autofocus", toggle_autofocus) - || try_1args(command, "map_u", map_scroll, '8') + return ( try_1args(command, "map_u", map_scroll, '8') || try_1args(command, "map_d", map_scroll, '2') || try_1args(command, "map_r", map_scroll, '6') || try_1args(command, "map_l", map_scroll, '4') diff --git a/src/client/interface_conf.c b/src/client/interface_conf.c index 343302a..679f6c7 100644 --- a/src/client/interface_conf.c +++ b/src/client/interface_conf.c @@ -24,7 +24,6 @@ #include "cleanup.h" /* set_cleanup_flag() */ #include "command_db.h" /* get_command() */ #include "keybindings.h" /* KeyBinding, KeyBindingDB, get_command_to_keycode()*/ -#include "map.h" /* map_center() */ #include "parse.h" /* EDIT_STARTED, parse_file(), parse_flagval(), * parse_and_reduce_to_readyflag(), parse_id_uniq() * parsetest_defcontext(), parse_unknown_arg(), @@ -481,6 +480,5 @@ extern void reload_interface_conf() { unload_interface_conf(); load_interface_conf(); - map_center(); world.winDB.v_screen_offset = 0; } diff --git a/src/client/interface_conf.h b/src/client/interface_conf.h index 36bc029..1d1c44c 100644 --- a/src/client/interface_conf.h +++ b/src/client/interface_conf.h @@ -19,8 +19,7 @@ extern void obey_argv(int argc, char * argv[]); * data, world.wins.pad (initialized before opening any windows to the height of * the terminal screen and a width of 1) and window chains. * - * Note that reload_interface_conf() also calls map_center() and re-sets - * world.winDB.v_screen_offset to zero. + * reload_interface_conf() also re-sets world.winDB.v_screen_offset to zero. */ extern void save_interface_conf(); extern void load_interface_conf(); diff --git a/src/client/io.c b/src/client/io.c index 45a1de7..d1fffc0 100644 --- a/src/client/io.c +++ b/src/client/io.c @@ -25,9 +25,12 @@ * read_file_into_queue(), * get_message_from_queue(), */ +#include "../common/yx_uint8.h" /* yx_uint8 */ #include "control.h" /* try_key() */ -#include "map.h" /* map_center() */ -#include "windows.h" /* reset_windows_on_winch(), draw_all_wins() */ +#include "map.h" /* query_mapcell() */ +#include "windows.h" /* Win, reset_windows_on_winch(), draw_all_wins(), + * get_win_by_id() + */ #include "world.h" /* world global */ @@ -69,9 +72,6 @@ static FILE * changed_worldstate_file(char * path); * world in a hard-coded serialization format. Returns 1 on success, or 0 if the * out file wasn't read for supposedly not having changed since a last * read_worldstate() call. - * - * map_center() is triggered by either, the first successful read_worldstate() - * (thus on client start), or on turn 1 (thus on world start). */ static uint8_t read_worldstate(); @@ -178,7 +178,6 @@ static uint8_t read_worldstate() { char * path = "server/worldstate"; char * quit_msg = "No worldstate file found to read. Server may be down."; - static uint8_t first_read = 1; exit_err(access(path, F_OK), quit_msg); FILE * file = changed_worldstate_file(path); if (!file) @@ -192,11 +191,6 @@ static uint8_t read_worldstate() read_inventory(read_buf, linemax, file); world.player_pos.y = read_value_from_line(read_buf, linemax, file); world.player_pos.x = read_value_from_line(read_buf, linemax, file); - if (1 == world.turn || first_read) - { - map_center(); - first_read = 0; - } world.map.length = read_value_from_line(read_buf, linemax, file); read_map_cells(file, &world.map.cells); read_map_cells(file, &world.mem_map); @@ -324,7 +318,6 @@ extern char * io_loop() world.halfdelay = 1; /* Ensure server is polled only 10 times */ halfdelay(world.halfdelay); /* a second during user inactivity. */ uint8_t change_in_client = 0; - uint16_t last_focused_turn = world.turn; while (1) { test_and_poll_server(); @@ -336,11 +329,10 @@ extern char * io_loop() } if (change_in_client || read_worldstate() || read_queue()) { - if (world.turn != last_focused_turn && world.autofocus) - { - last_focused_turn = world.turn; - map_center(); - } + struct Win * win_map = get_win_by_id('m'); + struct yx_uint8 pos = world.look? world.look_pos : world.player_pos; + win_map->center.y = pos.y; + win_map->center.x = pos.x * 2 + (pos.y % 2); draw_all_wins(); } change_in_client = 0; diff --git a/src/client/io.h b/src/client/io.h index 041ed67..12a56c0 100644 --- a/src/client/io.h +++ b/src/client/io.h @@ -30,10 +30,10 @@ extern void send(char * msg); * appropriate quit message to write to stdout when the client winds down. Call * reset_windows() on receiving a SIGWINCH. Abort on assumed server death if the * server's out file does not get updated, even on PING requests. Re-focus map - * view on player if world.autofocus is set. Messages from the out file are put - * together on the queue first, from which only complete (\n-delimited) messages - * are read. Queues of messages are worked through completely / emptied before - * any re-drawing or further server polling happens. + * view on player. Messages from the out file are put together on the queue + * first, from which only complete (\n-delimited) messages are read. Queues of + * messages are worked through completely / emptied before any re-drawing or + * further server polling happens. */ extern char * io_loop(); diff --git a/src/client/main.c b/src/client/main.c index acb592b..c40d745 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -56,7 +56,6 @@ int main(int argc, char * argv[]) keypad(world.winDB.t_screen, TRUE); init_command_db(); /* The command DB needs to be initialized before */ load_interface_conf(); /* the interface, whose keybindings depend on it. */ - world.autofocus = 1; /* Set handler for terminal window resizing. */ struct sigaction act; diff --git a/src/client/map.c b/src/client/map.c index 75dd6de..f8ff061 100644 --- a/src/client/map.c +++ b/src/client/map.c @@ -12,7 +12,7 @@ #include /* strlen(), strncmp() */ #include "../common/try_malloc.h" /* try_malloc() */ #include "../common/rexit.h" /* exit_trouble() */ -#include "../common/yx_uint8.h" /* yx_uint8 */ +//#include "../common/yx_uint8.h" /* yx_uint8 */ #include "io.h" /* send() */ #include "windows.h" /* struct Win, center_offset(), get_win_by_id() */ #include "world.h" /* for global world */ @@ -21,7 +21,6 @@ extern void map_scroll(char d) { - world.autofocus = 0; struct Win * win = get_win_by_id('m'); uint16_t offset; if (('8' == d || '2' == d) && world.map.length > win->frame_size.y) @@ -52,23 +51,6 @@ extern void map_scroll(char d) -extern void map_center() -{ - struct Win * win_map = get_win_by_id('m'); - struct yx_uint8 pos = world.look ? world.look_pos : world.player_pos; - win_map->center.y = pos.y; - win_map->center.x = pos.x * 2 + (pos.y % 2); -} - - - -extern void toggle_autofocus() -{ - world.autofocus = world.autofocus ? 0 : 1; -} - - - extern void toggle_lookmode() { if (!world.look) @@ -128,7 +110,6 @@ extern uint8_t lookmode_nav(char * command) { return 0; } - map_center(); query_mapcell(); return 1; } diff --git a/src/client/map.h b/src/client/map.h index 4b1eb8d..cfba067 100644 --- a/src/client/map.h +++ b/src/client/map.h @@ -18,12 +18,6 @@ */ extern void map_scroll(char d); -/* Center map window on player (even if it is non-visible). */ -extern void map_center(); - -/* Toggle world.focus_each_turn (auto-centering of map on player each turn). */ -extern void toggle_autofocus(); - /* Toggle world.look (moving look cursor instead of player over map). */ extern void toggle_lookmode(); diff --git a/src/client/world.h b/src/client/world.h index 19497d2..c8b8580 100644 --- a/src/client/world.h +++ b/src/client/world.h @@ -46,7 +46,6 @@ struct World uint8_t player_inventory_select; /* index of selected item in inventory */ uint8_t player_lifepoints; /* how alive the player is */ uint8_t winch; /* if set, SIGWINCH was registered; trigger reset_windows()*/ - uint8_t autofocus; /* if !0, re-focus map each new turn / look focus move */ uint8_t look; /* if set, move look cursor over map intead of player */ };