summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-09-17 09:58:14 +0200
committerBardur Arantsson <bardur@scientician.net>2016-09-17 09:58:14 +0200
commit7f147b21e23662c89bd28479ea67ee7c6a94fc0c (patch)
treee1b5305dff75899690ca15f2d72f4106004d2123 /src
parent55729f1d5e1c656fa909e9c18275107d206aedea (diff)
Factor out "confirm_stairs" option handling
Diffstat (limited to 'src')
-rw-r--r--src/cmd2.cc63
1 files changed, 29 insertions, 34 deletions
diff --git a/src/cmd2.cc b/src/cmd2.cc
index fd31b564..7f57bd08 100644
--- a/src/cmd2.cc
+++ b/src/cmd2.cc
@@ -134,6 +134,29 @@ static bool_ stair_hooks(stairs_direction direction)
return (!out.allow);
}
+/*
+ * Ask for confirmation before leaving level; based
+ * on whether the 'confirm_stairs' option is set.
+ */
+static bool ask_leave()
+{
+ if (confirm_stairs)
+ {
+ if (get_check("Really leave the level? "))
+ {
+ return true; // Leave
+ }
+ else
+ {
+ return false; // Don't leave
+ }
+ }
+ else
+ {
+ return true; // Leave
+ }
+}
+
/*
* Go up one level
@@ -169,11 +192,7 @@ void do_cmd_go_up(void)
{
go_up = get_check("Leave this unique level forever? ");
}
- else if (confirm_stairs)
- {
- go_up = get_check("Really leave the level? ");
- }
- else
+ else if (ask_leave())
{
go_up = TRUE;
}
@@ -190,11 +209,7 @@ void do_cmd_go_up(void)
{
go_up = get_check("Leave this unique level forever? ");
}
- else if (confirm_stairs)
- {
- go_up_many = get_check("Really leave the level? ");
- }
- else
+ else if (ask_leave())
{
go_up_many = TRUE;
}
@@ -232,12 +247,7 @@ void do_cmd_go_up(void)
prob_traveling = TRUE;
- if (confirm_stairs)
- {
- if (get_check("Really leave the level? "))
- go_up = TRUE;
- }
- else
+ if (ask_leave())
{
go_up = TRUE;
}
@@ -399,12 +409,7 @@ void do_cmd_go_down(void)
}
else
{
- if (confirm_stairs)
- {
- if (get_check("Really leave the level? "))
- go_down_many = TRUE;
- }
- else
+ if (ask_leave())
{
go_down_many = TRUE;
}
@@ -428,12 +433,7 @@ void do_cmd_go_down(void)
}
else
{
- if (confirm_stairs)
- {
- if (get_check("Really leave the level? "))
- go_down = TRUE;
- }
- else
+ if (ask_leave())
{
go_down = TRUE;
}
@@ -462,12 +462,7 @@ void do_cmd_go_down(void)
prob_traveling = TRUE;
- if (confirm_stairs)
- {
- if (get_check("Really leave the level? "))
- go_down = TRUE;
- }
- else
+ if (ask_leave())
{
go_down = TRUE;
}