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 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'crawl-ref/source/files.cc') 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 )) { -- cgit v1.2.3-54-g00ecf