summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd2.c16
-rw-r--r--src/cmd6.c16
-rw-r--r--src/dungeon.c15
-rw-r--r--src/externs.h1
-rw-r--r--src/files.c14
-rw-r--r--src/powers.c9
-rw-r--r--src/spells1.c32
-rw-r--r--src/spells2.c16
-rw-r--r--src/traps.c7
-rw-r--r--src/wizard2.c16
10 files changed, 33 insertions, 109 deletions
diff --git a/src/cmd2.c b/src/cmd2.c
index ba6bee63..aefe8a7a 100644
--- a/src/cmd2.c
+++ b/src/cmd2.c
@@ -196,13 +196,7 @@ void do_cmd_go_up(void)
else
msg_print("You enter a maze of up staircases.");
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
if (p_ptr->inside_quest)
{
@@ -433,13 +427,7 @@ void do_cmd_go_down(void)
msg_print("You enter a maze of down staircases.");
}
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
/* Go down */
if (go_down)
diff --git a/src/cmd6.c b/src/cmd6.c
index febaa029..db89c465 100644
--- a/src/cmd6.c
+++ b/src/cmd6.c
@@ -4632,13 +4632,7 @@ int ring_of_power()
msg_print("The power of the ring destroys the world!");
msg_print("The world changes!");
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
/* Leaving */
p_ptr->leaving = TRUE;
@@ -5496,13 +5490,7 @@ const char *activation_aux(object_type * o_ptr, bool_ doit, int item)
{
if (get_check("Leave this level? "))
{
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
/* Leaving */
p_ptr->leaving = TRUE;
diff --git a/src/dungeon.c b/src/dungeon.c
index c45a5b2e..8a54329e 100644
--- a/src/dungeon.c
+++ b/src/dungeon.c
@@ -465,13 +465,7 @@ static void pattern_teleport(void)
/* Accept request */
msg_format("You teleport to dungeon level %d.", command_arg);
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
/* Change level */
dun_level = command_arg;
@@ -3089,12 +3083,9 @@ static void process_world(void)
* The player is yanked up/down as soon as
* he loads the autosaved game.
*/
- if (autosave_l && (p_ptr->word_recall == 1))
+ if (p_ptr->word_recall == 1)
{
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
+ autosave_checkpoint();
}
/* Make SURE that persistent levels are saved
diff --git a/src/externs.h b/src/externs.h
index dba293d1..4808a46f 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -901,6 +901,7 @@ extern void process_player_name(bool_ sf);
extern void get_name(void);
extern void do_cmd_suicide(void);
extern void do_cmd_save_game(void);
+extern void autosave_checkpoint();
extern long total_points(void);
extern void display_scores(int from, int to);
extern errr predict_score(void);
diff --git a/src/files.c b/src/files.c
index d1b3d4f9..ea331a15 100644
--- a/src/files.c
+++ b/src/files.c
@@ -4239,7 +4239,19 @@ void do_cmd_save_game(void)
(void)strcpy(died_from, "(alive and well)");
}
-
+/*
+ * Auto-save depending on whether the auto save flag is set.
+ */
+void autosave_checkpoint()
+{
+ if (autosave_l)
+ {
+ is_autosave = TRUE;
+ msg_print("Autosaving the game...");
+ do_cmd_save_game();
+ is_autosave = FALSE;
+ }
+}
/*
* Hack -- Calculates the total number of points earned -JWT-
diff --git a/src/powers.c b/src/powers.c
index b38b671f..afaf7431 100644
--- a/src/powers.c
+++ b/src/powers.c
@@ -651,13 +651,8 @@ static void power_activate(int power)
case PWR_WRECK_WORLD:
msg_print("The power of Eru Iluvatar flows through you!");
msg_print("The world changes!");
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+
+ autosave_checkpoint();
/* Leaving */
p_ptr->leaving = TRUE;
break;
diff --git a/src/spells1.c b/src/spells1.c
index fa2a846f..53686c5a 100644
--- a/src/spells1.c
+++ b/src/spells1.c
@@ -858,13 +858,7 @@ void teleport_player_level(void)
{
msg_print("You sink through the floor.");
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
dun_level++;
@@ -875,13 +869,7 @@ void teleport_player_level(void)
{
msg_print("You rise up through the ceiling.");
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
dun_level--;
@@ -892,13 +880,7 @@ void teleport_player_level(void)
{
msg_print("You rise up through the ceiling.");
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
dun_level--;
@@ -909,13 +891,7 @@ void teleport_player_level(void)
{
msg_print("You sink through the floor.");
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
dun_level++;
diff --git a/src/spells2.c b/src/spells2.c
index 924c5b39..d9b53e56 100644
--- a/src/spells2.c
+++ b/src/spells2.c
@@ -7659,13 +7659,7 @@ void change_wild_mode(void)
p_ptr->wild_mode = !p_ptr->wild_mode;
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
/* Leaving */
p_ptr->leaving = TRUE;
@@ -7676,13 +7670,7 @@ void alter_reality(void)
{
msg_print("The world changes!");
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
/* Leaving */
p_ptr->leaving = TRUE;
diff --git a/src/traps.c b/src/traps.c
index ed93aabe..1c8e36c9 100644
--- a/src/traps.c
+++ b/src/traps.c
@@ -848,12 +848,9 @@ bool_ player_activate_trap_type(s16b y, s16b x, object_type *i_ptr, s16b item)
}
/* Still alive and autosave enabled */
- if (autosave_l && (p_ptr->chp >= 0))
+ if (p_ptr->chp >= 0)
{
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
+ autosave_checkpoint();
}
if (dungeon_flags1 & DF1_TOWER) dun_level--;
diff --git a/src/wizard2.c b/src/wizard2.c
index f606fd72..e8a13b45 100644
--- a/src/wizard2.c
+++ b/src/wizard2.c
@@ -56,13 +56,7 @@ void teleport_player_town(int town)
{
int x = 0, y = 0;
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
/* Change town */
dun_level = 0;
@@ -1446,13 +1440,7 @@ static void do_cmd_wiz_jump(void)
/* Accept request */
msg_format("You jump to dungeon level %d.", command_arg);
- if (autosave_l)
- {
- is_autosave = TRUE;
- msg_print("Autosaving the game...");
- do_cmd_save_game();
- is_autosave = FALSE;
- }
+ autosave_checkpoint();
/* Change level */
dun_level = command_arg;