From 90ac0755a3ded561037b612fa7adbf293887e050 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Thu, 10 May 2007 16:38:57 +0000 Subject: Level-files are now saved with subdungeon depths rather than absolute depths. Breaks save compatibility resoundingly. The advantage of the change is that ghosts dying in a branch will always be reloaded at the same depth in the branch. Fixed minor bug that could result in branch stairs taking you to different places on successive visits. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1446 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/files.cc | 21 +++++++++++++-------- crawl-ref/source/files.h | 4 ++-- crawl-ref/source/ouch.cc | 13 ++++++++----- 3 files changed, 23 insertions(+), 15 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index b9c14f74b3..ce75807379 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -481,13 +481,15 @@ std::string get_prefs_filename() return get_savedir_filename("start", "ns", "prf"); } -static std::string get_level_suffix(int level, int where, level_area_type lt) +static std::string get_level_suffix(int level, branch_type where, + level_area_type lt) { switch (lt) { default: case LEVEL_DUNGEON: - return (make_stringf("%02d%c", level, where + 'a')); + return (make_stringf("%02d%c", subdungeon_depth(where, level), + where + 'a')); case LEVEL_LABYRINTH: return ("lab"); case LEVEL_ABYSS: @@ -497,7 +499,7 @@ static std::string get_level_suffix(int level, int where, level_area_type lt) } } -std::string make_filename( const char *prefix, int level, int where, +std::string make_filename( const char *prefix, int level, branch_type where, level_area_type ltype, bool isGhost ) { return get_savedir_filename( prefix, "", @@ -533,7 +535,7 @@ static void write_tagged_file( FILE *dataFile, char majorVersion, } } -bool travel_load_map( char branch, int absdepth ) +bool travel_load_map( branch_type branch, int absdepth ) { // Try to open level savefile. FILE *levelFile = fopen(make_filename(you.your_name, absdepth, branch, @@ -603,11 +605,14 @@ static coord_def find_nearby_stair(int stair_to_find, bool find_closest) if (grd[xpos][ypos] == stair_to_find) { found++; - if (find_closest && dist < best_dist) + if (find_closest) { - best_dist = dist; - result.x = xpos; - result.y = ypos; + if (dist < best_dist) + { + best_dist = dist; + result.x = xpos; + result.y = ypos; + } } else if (one_chance_in( found )) { diff --git a/crawl-ref/source/files.h b/crawl-ref/source/files.h index 1e480ba90e..9ac67b5093 100644 --- a/crawl-ref/source/files.h +++ b/crawl-ref/source/files.h @@ -32,7 +32,7 @@ std::string datafile_path(const std::string &basename, std::string get_parent_directory(const std::string &filename); bool check_dir(const std::string &what, std::string &dir); -bool travel_load_map( char branch, int absdepth ); +bool travel_load_map( branch_type branch, int absdepth ); std::vector find_saved_characters(); @@ -74,7 +74,7 @@ void save_ghost( bool force = false ); /* *********************************************************************** * called from: files hiscores * *********************************************************************** */ -std::string make_filename( const char *prefix, int level, int branch, +std::string make_filename( const char *prefix, int level, branch_type branch, level_area_type lt, bool isGhost ); void writeShort(FILE *file, short s); diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 8e05aed8a8..fdac3faa45 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -845,17 +845,20 @@ void end_game( struct scorefile_entry &se ) { if (tmp_file_pairs[level][dungeon]) { - unlink(make_filename( you.your_name, level, dungeon, - LEVEL_DUNGEON, false ).c_str()); + unlink( + make_filename( you.your_name, level, + static_cast(dungeon), + LEVEL_DUNGEON, false ).c_str() ); } } } // temp levels, if any - unlink( make_filename( you.your_name, 0, 0, LEVEL_ABYSS, false ).c_str() ); - unlink( make_filename( you.your_name, 0, 0, + unlink( make_filename( you.your_name, 0, BRANCH_MAIN_DUNGEON, + LEVEL_ABYSS, false ).c_str() ); + unlink( make_filename( you.your_name, 0, BRANCH_MAIN_DUNGEON, LEVEL_PANDEMONIUM, false ).c_str() ); - unlink( make_filename( you.your_name, 0, 0, + unlink( make_filename( you.your_name, 0, BRANCH_MAIN_DUNGEON, LEVEL_LABYRINTH, false ).c_str() ); // create base file name -- cgit v1.2.3-54-g00ecf