summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-03-04 20:09:24 +0100
committerBardur Arantsson <bardur@scientician.net>2012-03-29 20:41:39 +0200
commitcbf8457017b6c92fba7853066af8a90c870e6c8f (patch)
tree29a511f7ea262910031e89306cc9d3f062667166 /src
parent4d6770696a172bae4ef18a00cb1e59f06e641faf (diff)
Refactor: Remove duplicate keymap handling code.
Diffstat (limited to 'src')
-rw-r--r--src/cmd4.c27
-rw-r--r--src/externs.h1
-rw-r--r--src/util.c39
3 files changed, 21 insertions, 46 deletions
diff --git a/src/cmd4.c b/src/cmd4.c
index ce5e6d58..c022dde3 100644
--- a/src/cmd4.c
+++ b/src/cmd4.c
@@ -1638,18 +1638,8 @@ static errr keymap_dump(cptr fname)
int mode;
- /* Roguelike */
- if (rogue_like_commands)
- {
- mode = KEYMAP_MODE_ROGUE;
- }
-
- /* Original */
- else
- {
- mode = KEYMAP_MODE_ORIG;
- }
-
+ /* Keymap mode */
+ mode = get_keymap_mode();
/* Build the filename */
path_build(buf, 1024, ANGBAND_DIR_USER, fname);
@@ -1725,17 +1715,8 @@ void do_cmd_macros(void)
int mode;
- /* Roguelike */
- if (rogue_like_commands)
- {
- mode = KEYMAP_MODE_ROGUE;
- }
-
- /* Original */
- else
- {
- mode = KEYMAP_MODE_ORIG;
- }
+ /* Keymap mode */
+ mode = get_keymap_mode();
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
diff --git a/src/externs.h b/src/externs.h
index 42ac1612..08ef2d38 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -1513,6 +1513,7 @@ extern int test_item_name(cptr name);
extern char msg_box(cptr text, int y, int x);
extern timer_type *new_timer(cptr callback, s32b delay);
extern void del_timer(timer_type *t_ptr);
+extern int get_keymap_mode();
/* main.c */
extern bool_ private_check_user_directory(cptr dirpath);
diff --git a/src/util.c b/src/util.c
index 34084d71..546d11d8 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3648,18 +3648,8 @@ void request_command(int shopping)
cptr act;
- /* Roguelike */
- if (rogue_like_commands)
- {
- mode = KEYMAP_MODE_ROGUE;
- }
-
- /* Original */
- else
- {
- mode = KEYMAP_MODE_ORIG;
- }
-
+ /* Keymap mode */
+ mode = get_keymap_mode();
/* No command yet */
command_cmd = 0;
@@ -3978,17 +3968,8 @@ int get_keymap_dir(char ch)
}
else
{
- /* Roguelike */
- if (rogue_like_commands)
- {
- mode = KEYMAP_MODE_ROGUE;
- }
-
- /* Original */
- else
- {
- mode = KEYMAP_MODE_ORIG;
- }
+ /* Keymap mode */
+ mode = get_keymap_mode();
/* Extract the action (if any) */
act = keymap_act[mode][(byte)(ch)];
@@ -4730,3 +4711,15 @@ void del_timer(timer_type *t_ptr)
else
cmsg_print(TERM_VIOLET, "Unknown timer!");
}
+
+int get_keymap_mode()
+{
+ if (rogue_like_commands)
+ {
+ return KEYMAP_MODE_ROGUE;
+ }
+ else
+ {
+ return KEYMAP_MODE_ORIG;
+ }
+}