summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2011-03-31 01:18:50 +0200
committerBardur Arantsson <bardur@scientician.net>2012-03-29 19:53:56 +0200
commitf9c459680ef61af4387edb352b899c43399698c6 (patch)
treec9cbd16c856facc7372374004f15c18ec7683953 /src
parentf4b63ea835e9deafa2fb60270c6b53f8a3698256 (diff)
Files: Remove panic saves.
It is NOT a good idea to save the game when memory may already be corrupted.
Diffstat (limited to 'src')
-rw-r--r--src/birth.c3
-rw-r--r--src/config.h5
-rw-r--r--src/externs.h4
-rw-r--r--src/files.c69
-rw-r--r--src/loadsave.c156
-rw-r--r--src/main-gcu.c4
-rw-r--r--src/variable.c1
-rw-r--r--src/wizard2.c5
8 files changed, 10 insertions, 237 deletions
diff --git a/src/birth.c b/src/birth.c
index 5f4eac5a..4b865172 100644
--- a/src/birth.c
+++ b/src/birth.c
@@ -975,9 +975,6 @@ static void player_wipe(void)
total_winner = 0;
has_won = FALSE;
- /* Assume no panic save */
- panic_save = 0;
-
/* Assume no cheating */
noscore = 0;
wizard = 0;
diff --git a/src/config.h b/src/config.h
index a2f3b61e..fc87c6ca 100644
--- a/src/config.h
+++ b/src/config.h
@@ -395,11 +395,6 @@
/* #define ALLOW_QUITTING */
/*
- * Panic saves have a different name
- */
-#define SAFER_PANICS
-
-/*
* Allow makefiles to override the default file mode
*/
#ifndef FILE_MODE
diff --git a/src/externs.h b/src/externs.h
index 5155d3fe..6c1bf5f7 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -156,7 +156,6 @@ extern bool_ use_bigtile;
extern byte graphics_mode;
extern u16b total_winner;
extern u16b has_won;
-extern u16b panic_save;
extern u16b noscore;
extern s16b signal_count;
extern bool_ inkey_base;
@@ -550,9 +549,6 @@ extern bool_ fast_autoroller;
extern bool_ joke_monsters;
extern bool_ munchkin_multipliers;
extern bool_ center_player;
-#ifdef SAFER_PANICS
-extern bool_ panicload;
-#endif
extern s16b plots[MAX_PLOTS];
extern random_quest random_quests[MAX_RANDOM_QUEST];
extern bool_ exp_need;
diff --git a/src/files.c b/src/files.c
index 43ff614e..6cbb5a8a 100644
--- a/src/files.c
+++ b/src/files.c
@@ -4354,8 +4354,6 @@ void remove_cave_view(bool_ remove)
*/
void do_cmd_save_game(void)
{
- panic_save = 0; /* Fixes an apparently long-lived bug */
-
remove_cave_view(TRUE);
/* Save the current level if in a persistent level */
@@ -5896,49 +5894,6 @@ void close_game(void)
/*
- * Handle abrupt death of the visual system
- *
- * This routine is called only in very rare situations, and only
- * by certain visual systems, when they experience fatal errors.
- *
- * XXX XXX Hack -- clear the death flag when creating a HANGUP
- * save file so that player can see tombstone when restart.
- */
-void exit_game_panic(void)
-{
- /* If nothing important has happened, just quit */
- if (!character_generated || character_saved) quit("panic");
-
- /* Mega-Hack -- see "msg_print()" */
- msg_flag = FALSE;
-
- /* Clear the top line */
- prt("", 0, 0);
-
- /* Hack -- turn off some things */
- disturb(1, 0);
-
- /* Mega-Hack -- Delay death */
- if (p_ptr->chp < 0) death = FALSE;
-
- /* Hardcode panic save */
- panic_save = 1;
-
- /* Forbid suspend */
- signals_ignore_tstp();
-
- /* Indicate panic save */
- (void)strcpy(died_from, "(panic save)");
-
- /* Panic save, or get worried */
- if (!save_player()) quit("panic save failed!");
-
- /* Successful panic save */
- quit("panic save succeeded!");
-}
-
-
-/*
* Grab a randomly selected line in lib/file/file_name
*/
errr get_rnd_line(char *file_name, char *output)
@@ -6368,30 +6323,6 @@ static void handle_signal_abort(int sig)
/* Flush output */
Term_fresh();
- /* Panic Save */
- panic_save = 1;
-
- /* Panic save */
- (void)strcpy(died_from, "(panic save)");
-
- /* Forbid suspend */
- signals_ignore_tstp();
-
- /* Attempt to save */
- if (save_player())
- {
- Term_putstr(45, 23, -1, TERM_RED, "Panic save succeeded!");
- }
-
- /* Save failed */
- else
- {
- Term_putstr(45, 23, -1, TERM_RED, "Panic save failed!");
- }
-
- /* Flush output */
- Term_fresh();
-
/* Quit */
quit(format("software bug %d %d", p_ptr->px, p_ptr->py));
}
diff --git a/src/loadsave.c b/src/loadsave.c
index f72c8c61..40f2e13c 100644
--- a/src/loadsave.c
+++ b/src/loadsave.c
@@ -37,10 +37,6 @@ static void skip_ver_byte(u32b, int);
errr rd_savefile(void);
-#ifdef SAFER_PANICS
-bool_ panicload;
-#endif
-
static FILE *fff; /* Local savefile ptr */
/*
@@ -682,7 +678,6 @@ static bool_ do_extra(int flag)
do_u32b(&dummy32u, flag); /* Load-compatibility with old savefiles. */
/* Special stuff */
- do_u16b(&panic_save, flag);
do_u16b(&total_winner, flag);
do_u16b(&has_won, flag);
do_u16b(&noscore, flag);
@@ -829,37 +824,6 @@ bool_ save_player(void)
{
int result = FALSE;
char safe[1024];
-#ifdef SAFER_PANICS
- char panicsave[1024];
-#endif /* SAFER PANICS */
-
-
-#ifdef SAFER_PANICS
- if (panic_save)
- {
- /*
- * Not sure how to do this so it's nicely portable to brain-damaged
- * OS's with short filenames
- */
- strcpy(panicsave, savefile);
- strcat(panicsave, ".pnc");
-
- /* Grab permission */
- if (savefile_setuid) safe_setuid_grab();
-
- /* Remove any old panic saves */
- fd_kill(panicsave);
-
- /* Drop permission */
- if (savefile_setuid) safe_setuid_drop();
-
- /* Save character */
- save_player_aux(panicsave);
-
- return TRUE;
- }
-#endif /* SAFER_PANICS */
-
/* New savefile */
strcpy(safe, savefile);
@@ -977,31 +941,12 @@ bool_ load_player(void)
errr err = 0;
-#ifdef SAFER_PANICS
- char panic_fname[1024]; /* Filename for panic savefiles */
- int testfd = -1;
-#endif /* SAFER_PANICS */
-
#ifdef VERIFY_TIMESTAMP
struct stat statbuf;
#endif /* VERIFY_TIMESTAMP */
cptr what = "generic";
-#ifdef SAFER_PANICS
- panicload = FALSE;
- strncpy(panic_fname, savefile, 1024);
- strcat(panic_fname, ".pnc"); /* This might concievably cause a buffer
- overflow, but the rest of the code
- in this file does likewise. If someone
- ever audits pernband for security
- problems, well, don't blame me. The rest
- of the code was like this before I even
- got here -- Pat */
-
-#endif /* SAFER_PANICS */
-
-
/* Paranoia */
turn = 0;
@@ -1016,11 +961,7 @@ bool_ load_player(void)
/* XXX XXX XXX Fix this */
/* Verify the existance of the savefile */
- if ((!file_exist(savefile))
-#ifdef SAFER_PANICS
- && (!file_exist(panic_fname))
-#endif /* SAFER_PANICS */
- )
+ if (!file_exist(savefile))
{
/* Give a message */
msg_format("Savefile does not exist: %s", savefile);
@@ -1105,43 +1046,6 @@ bool_ load_player(void)
if (err) what = "Cannot open savefile";
}
-#ifdef SAFER_PANICS
-
- /* Grab permission */
- if (savefile_setuid) safe_setuid_grab();
-
- /* Open panic save file */
- testfd = fd_open(panic_fname, O_RDONLY);
-
- /* Drop permission */
- if (savefile_setuid) safe_setuid_drop();
-
- fd_close(testfd);
-
- /* A panic save exists, which is not normally the case */
- if (testfd > 0)
- {
- panicload = 1;
-
- /* Close the normal save file */
- fd_close(fd);
-
- /* Grab permission */
- if (savefile_setuid) safe_setuid_grab();
-
- /* Prefer panic saves over real saves */
- fd = fd_open(panic_fname, O_RDONLY);
-
- /* Drop permission */
- if (savefile_setuid) safe_setuid_drop();
-
- /* This is not the error if we're at this pt */
- what = "";
- err = 0;
- }
-
-#endif /* SAFER_PANICS */
-
/* Process file */
if (!err)
{
@@ -1271,24 +1175,6 @@ bool_ load_player(void)
(void)strcpy(died_from, "(alive and well)");
}
-#ifdef SAFER_PANICS
- if (panicload)
- {
- /* Grab permission */
- if (savefile_setuid) safe_setuid_grab();
-
- /*
- * Done loading, it'll either immediately panic and re-save, or
- * we don't need the panicsave file anymore. Either way, it's safe
- * to zap the original panicsave
- */
- fd_kill(panic_fname);
-
- /* Drop permission */
- if (savefile_setuid) safe_setuid_drop();
- }
-#endif /* SAFER_PANICS */
-
/* Success */
return (TRUE);
}
@@ -3290,40 +3176,14 @@ errr rd_savefile(void)
{
errr err = 0;
-#ifdef SAFER_PANICS
- char panic_fname[1024];
- if (!panicload)
- {
-#endif /* SAFER_PANICS */
-
- /* Grab permission */
- if (savefile_setuid) safe_setuid_grab();
-
- /* The savefile is a binary file */
- fff = my_fopen(savefile, "rb");
-
- /* Drop permission */
- if (savefile_setuid) safe_setuid_drop();
-
-#ifdef SAFER_PANICS
- }
- else
- {
- strcpy(panic_fname, savefile);
- strcat(panic_fname, ".pnc");
-
- /* Grab permission */
- if (savefile_setuid) safe_setuid_grab();
-
- /* Open panic save file */
- fff = my_fopen(panic_fname, "rb");
-
- /* Drop permission */
- if (savefile_setuid) safe_setuid_drop();
-
- }
+ /* Grab permission */
+ if (savefile_setuid) safe_setuid_grab();
-#endif /* SAFER_PANICS */
+ /* The savefile is a binary file */
+ fff = my_fopen(savefile, "rb");
+
+ /* Drop permission */
+ if (savefile_setuid) safe_setuid_drop();
/* Paranoia */
if (!fff) return ( -1);
diff --git a/src/main-gcu.c b/src/main-gcu.c
index 78768286..b762a6f0 100644
--- a/src/main-gcu.c
+++ b/src/main-gcu.c
@@ -589,8 +589,8 @@ static errr Term_xtra_gcu_event(int v)
for (k = 0; (k < 10) && (i == ERR); k++) i = getch();
/* Broken input is special */
- if (i == ERR) exit_game_panic();
- if (i == EOF) exit_game_panic();
+ if (i == ERR) abort();
+ if (i == EOF) abort();
}
/* Do not wait */
diff --git a/src/variable.c b/src/variable.c
index 66c59989..fdbf0648 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -131,7 +131,6 @@ byte graphics_mode; /* Current graphics mode */
u16b total_winner; /* Semi-Hack -- Game has been won */
u16b has_won; /* Semi-Hack -- Game has been won */
-u16b panic_save; /* Track some special "conditions" */
u16b noscore; /* Track various "cheating" conditions */
s16b signal_count; /* Hack -- Count interupts */
diff --git a/src/wizard2.c b/src/wizard2.c
index d7bde6eb..2d398905 100644
--- a/src/wizard2.c
+++ b/src/wizard2.c
@@ -1818,11 +1818,6 @@ void do_cmd_debug(void)
teleport_player(10);
break;
- /* Panic save the game */
- case 'P':
- exit_game_panic();
- break;
-
/* get a Quest */
case 'q':
{