summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/files.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-26 16:57:36 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-26 16:57:36 +0000
commit9d1463d7bdca2b485c5f8caa9b86782f29e30f8c (patch)
treedeeaa2d0b2a05d8ba346b941e9d47fcc3e40e95d /crawl-ref/source/files.cc
parent5f2f20b49792c771ebd67442042f97344e2a6a56 (diff)
downloadcrawl-ref-9d1463d7bdca2b485c5f8caa9b86782f29e30f8c.tar.gz
crawl-ref-9d1463d7bdca2b485c5f8caa9b86782f29e30f8c.zip
Added support for a validation hook for maps to check if they're A-Ok.
Tweaked savefile format (breaks saves) to allow the game to perform emergency saves if level-generation fails (followers are lost, needs to be fixed). [1743698] Re-refixed SP_ELF stub (Eino). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1659 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/files.cc')
-rw-r--r--crawl-ref/source/files.cc54
1 files changed, 34 insertions, 20 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index aa14cfe8a8..fdbc137f94 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -939,9 +939,13 @@ static void grab_followers(std::vector<follower>& followers)
}
}
-bool load( int stair_taken, load_mode_type load_mode, bool was_a_labyrinth,
- int old_level, branch_type old_branch )
+bool load( dungeon_feature_type stair_taken, load_mode_type load_mode,
+ bool was_a_labyrinth, int old_level, branch_type old_branch )
{
+ unwind_var<dungeon_feature_type> stair(
+ you.transit_stair, stair_taken, DNGN_UNSEEN);
+ unwind_bool ylev(you.entering_level, true, false);
+
std::vector<follower> followers;
bool just_created_level = false;
@@ -971,7 +975,7 @@ bool load( int stair_taken, load_mode_type load_mode, bool was_a_labyrinth,
clear_clouds();
// This block is to grab followers and save the old level to disk.
- if (load_mode == LOAD_ENTER_LEVEL)
+ if (load_mode == LOAD_ENTER_LEVEL && old_level != -1)
{
grab_followers(followers);
@@ -1039,13 +1043,12 @@ bool load( int stair_taken, load_mode_type load_mode, bool was_a_labyrinth,
if (load_mode != LOAD_RESTART_GAME)
clear_clouds();
- if (load_mode != LOAD_RESTART_GAME && you.level_type != LEVEL_ABYSS)
- {
- place_player_on_stair(old_branch, stair_taken);
- }
- else if (load_mode != LOAD_RESTART_GAME && you.level_type == LEVEL_ABYSS)
+ if (load_mode != LOAD_RESTART_GAME)
{
- you.moveto(45, 35);
+ if (you.level_type != LEVEL_ABYSS)
+ place_player_on_stair(old_branch, stair_taken);
+ else
+ you.moveto(45, 35);
}
crawl_view.set_player_at(you.pos(), true);
@@ -1149,7 +1152,8 @@ void save_game(bool leave_game, const char *farewellmsg)
/* Stashes */
std::string stashFile = get_savedir_filename( you.your_name, "", "st" );
FILE *stashf = fopen(stashFile.c_str(), "wb");
- if (stashf) {
+ if (stashf)
+ {
stashes.save(stashf);
fclose(stashf);
DO_CHMOD_PRIVATE(stashFile.c_str());
@@ -1166,7 +1170,8 @@ void save_game(bool leave_game, const char *farewellmsg)
/* kills */
std::string killFile = get_savedir_filename( you.your_name, "", "kil" );
FILE *killf = fopen(killFile.c_str(), "wb");
- if (killf) {
+ if (killf)
+ {
you.kills.save(killf);
fclose(killf);
DO_CHMOD_PRIVATE(killFile.c_str());
@@ -1175,7 +1180,8 @@ void save_game(bool leave_game, const char *farewellmsg)
/* travel cache */
std::string travelCacheFile = get_savedir_filename(you.your_name,"","tc");
FILE *travelf = fopen(travelCacheFile.c_str(), "wb");
- if (travelf) {
+ if (travelf)
+ {
travel_cache.save(travelf);
fclose(travelf);
DO_CHMOD_PRIVATE(travelCacheFile.c_str());
@@ -1184,7 +1190,8 @@ void save_game(bool leave_game, const char *farewellmsg)
/* notes */
std::string notesFile = get_savedir_filename(you.your_name, "", "nts");
FILE *notesf = fopen(notesFile.c_str(), "wb");
- if (notesf) {
+ if (notesf)
+ {
save_notes(notesf);
fclose(notesf);
DO_CHMOD_PRIVATE(notesFile.c_str());
@@ -1194,7 +1201,8 @@ void save_game(bool leave_game, const char *farewellmsg)
std::string tutorFile = get_savedir_filename(you.your_name, "", "tut");
FILE *tutorf = fopen(tutorFile.c_str(), "wb");
- if (tutorf) {
+ if (tutorf)
+ {
save_tutorial(tutorf);
fclose(tutorf);
DO_CHMOD_PRIVATE(tutorFile.c_str());
@@ -1216,7 +1224,8 @@ void save_game(bool leave_game, const char *farewellmsg)
return;
// must be exiting -- save level & goodbye!
- save_level(you.your_level, you.level_type, you.where_are_you);
+ if (!you.entering_level)
+ save_level(you.your_level, you.level_type, you.where_are_you);
clrscr();
@@ -1347,7 +1356,8 @@ void restore_game(void)
std::string stashFile = get_savedir_filename( you.your_name, "", "st" );
FILE *stashf = fopen(stashFile.c_str(), "rb");
- if (stashf) {
+ if (stashf)
+ {
stashes.load(stashf);
fclose(stashf);
}
@@ -1359,21 +1369,24 @@ void restore_game(void)
std::string killFile = get_savedir_filename( you.your_name, "", "kil" );
FILE *killf = fopen(killFile.c_str(), "rb");
- if (killf) {
+ if (killf)
+ {
you.kills.load(killf);
fclose(killf);
}
std::string travelCacheFile = get_savedir_filename(you.your_name,"","tc");
FILE *travelf = fopen(travelCacheFile.c_str(), "rb");
- if (travelf) {
+ if (travelf)
+ {
travel_cache.load(travelf);
fclose(travelf);
}
std::string notesFile = get_savedir_filename(you.your_name, "", "nts");
FILE *notesf = fopen(notesFile.c_str(), "rb");
- if (notesf) {
+ if (notesf)
+ {
load_notes(notesf);
fclose(notesf);
}
@@ -1382,7 +1395,8 @@ void restore_game(void)
std::string tutorFile = get_savedir_filename(you.your_name, "", "tut");
FILE *tutorf = fopen(tutorFile.c_str(), "rb");
- if (tutorf) {
+ if (tutorf)
+ {
load_tutorial(tutorf);
fclose(tutorf);
}