Change key binds from array to linked list
Key bindings were stored as a fixed-size array, indexed by the input character, pointing to the extended commands. This changes that into a linked list of an intermediary struct Cmd_bind, storing the input key and the pointer to the command. This is just code cleanup for future enhancements, and should have no effect on gameplay.
This commit is contained in:
@@ -240,6 +240,7 @@ struct instance_globals_c {
|
||||
/* decl.c */
|
||||
char chosen_windowtype[WINTYPELEN];
|
||||
int cmd_key; /* parse() / rhack() */
|
||||
struct Cmd_bind *cmd_bind;
|
||||
cmdcount_nht command_count;
|
||||
/* some objects need special handling during destruction or placement */
|
||||
struct obj *current_wand; /* wand currently zapped/applied */
|
||||
|
||||
@@ -370,6 +370,7 @@ extern void change_palette(void);
|
||||
|
||||
/* ### cmd.c ### */
|
||||
|
||||
extern void cmdbind_freeall(void);
|
||||
extern void set_move_cmd(int, int);
|
||||
extern int do_move_west(void);
|
||||
extern int do_move_northwest(void);
|
||||
@@ -447,7 +448,7 @@ extern int doextlist(void);
|
||||
extern int extcmd_via_menu(void);
|
||||
extern int enter_explore_mode(void);
|
||||
extern boolean bind_mousebtn(int, const char *);
|
||||
extern boolean bind_key(uchar, const char *);
|
||||
extern boolean bind_key(uchar, const char *, boolean);
|
||||
extern void dokeylist(void);
|
||||
extern int xytodir(int, int);
|
||||
extern void dirtocoord(coord *, int);
|
||||
|
||||
@@ -29,6 +29,14 @@
|
||||
#define ECM_EXACTMATCH 0x02 /* needs exact match of findstr */
|
||||
#define ECM_NO1CHARCMD 0x04 /* ignore commands like '?' and '#' */
|
||||
|
||||
/* a key bound to ext_func_tab */
|
||||
struct Cmd_bind {
|
||||
uchar key;
|
||||
boolean userbind; /* added by user */
|
||||
const struct ext_func_tab *cmd;
|
||||
struct Cmd_bind *next;
|
||||
};
|
||||
|
||||
struct ext_func_tab {
|
||||
uchar key;
|
||||
const char *ef_txt, *ef_desc;
|
||||
|
||||
@@ -252,7 +252,7 @@ struct cmd {
|
||||
boolean swap_yz; /* QWERTZ keyboards; use z to move NW, y to zap */
|
||||
const char *dirchars; /* current movement/direction characters */
|
||||
const char *alphadirchars; /* same as dirchars if !numpad */
|
||||
const struct ext_func_tab *commands[256]; /* indexed by input character */
|
||||
struct Cmd_bind *cmdbinds;
|
||||
const struct ext_func_tab *mousebtn[NUM_MOUSE_BUTTONS];
|
||||
char spkeys[NUM_NHKF];
|
||||
char extcmd_char; /* key that starts an extended command ('#') */
|
||||
|
||||
Reference in New Issue
Block a user