diff -r 85581fc21354 src/cmd2.c --- a/src/cmd2.c Sun Jul 25 11:10:51 2010 -0700 +++ b/src/cmd2.c Sun Jul 25 11:12:41 2010 -0700 @@ -51,7 +51,7 @@ p_ptr->create_down_stair = TRUE; /* Change level */ - dungeon_change_level(p_ptr->depth - 1); + dungeon_compress_change_level(p_ptr->depth - 1); } @@ -78,7 +78,7 @@ p_ptr->create_down_stair = FALSE; /* Change level */ - dungeon_change_level(p_ptr->depth + 1); + dungeon_compress_change_level(p_ptr->depth + 1); } diff -r 85581fc21354 src/dungeon.c --- a/src/dungeon.c Sun Jul 25 11:10:51 2010 -0700 +++ b/src/dungeon.c Sun Jul 25 11:12:41 2010 -0700 @@ -21,6 +21,37 @@ #include "game-event.h" +/* + * Change dungeon level in a way that compresses the normal 128 levels into + * a much shorter dungeon, as defined by dungeon_level_map in tables.c. + */ + +void dungeon_compress_change_level(int dlev) +{ + /* Find the current range in dungeon_level_map that the player's depth maps + * to. + */ + int curDepthIndex; + for (curDepthIndex = 0; + p_ptr->depth > dungeon_level_map[curDepthIndex].second; + ++curDepthIndex) + { + // Do nothing + } + /* Determine direction of travel */ + int direction = p_ptr->depth - dlev; + if (direction > 0) // Traveling up + { + if (curDepthIndex != 0) { + dungeon_change_level(dungeon_level_map[curDepthIndex - 1].second); + } + } + else + { + dungeon_change_level(dungeon_level_map[curDepthIndex + 1].second); + } +} + /* * Change dungeon level - e.g. by going up stairs or with WoR. */ diff -r 85581fc21354 src/effects.c --- a/src/effects.c Sun Jul 25 11:10:51 2010 -0700 +++ b/src/effects.c Sun Jul 25 11:12:41 2010 -0700 @@ -1069,7 +1069,7 @@ if (target_depth > p_ptr->depth) { message(MSG_TPLEVEL, 0, "You sink through the floor..."); - dungeon_change_level(target_depth); + dungeon_compress_change_level(target_depth); *ident = TRUE; } diff -r 85581fc21354 src/externs.h --- a/src/externs.h Sun Jul 25 11:10:51 2010 -0700 +++ b/src/externs.h Sun Jul 25 11:12:41 2010 -0700 @@ -56,6 +56,7 @@ extern const char *window_flag_desc[32]; extern const char *inscrip_text[]; extern const grouper object_text_order[]; +extern const intpair dungeon_level_map[]; /* variable.c */ extern cptr copyright; @@ -314,6 +315,7 @@ void death_screen(void); /* dungeon.c */ +extern void dungeon_compress_change_level(int dlev); extern void dungeon_change_level(int dlev); extern void play_game(void); extern int value_check_aux1(const object_type *o_ptr); diff -r 85581fc21354 src/spells1.c --- a/src/spells1.c Sun Jul 25 11:10:51 2010 -0700 +++ b/src/spells1.c Sun Jul 25 11:12:41 2010 -0700 @@ -279,7 +279,6 @@ */ void teleport_player_level(void) { - if (is_quest(p_ptr->depth) || (p_ptr->depth >= MAX_DEPTH-1)) { if (OPT(adult_ironman)) @@ -290,44 +289,26 @@ message(MSG_TPLEVEL, 0, "You rise up through the ceiling."); - /* New depth */ - p_ptr->depth--; - - /* Leaving */ - p_ptr->leaving = TRUE; + dungeon_compress_change_level(p_ptr->depth - 1); } else if ((!p_ptr->depth) || (OPT(adult_ironman))) { message(MSG_TPLEVEL, 0, "You sink through the floor."); - /* New depth */ - p_ptr->depth++; - - /* Leaving */ - p_ptr->leaving = TRUE; + dungeon_compress_change_level(p_ptr->depth + 1); } else if (randint0(100) < 50) { message(MSG_TPLEVEL, 0, "You rise up through the ceiling."); - - /* New depth */ - p_ptr->depth--; - - /* Leaving */ - p_ptr->leaving = TRUE; + dungeon_compress_change_level(p_ptr->depth - 1); } else { message(MSG_TPLEVEL, 0, "You sink through the floor."); - - /* New depth */ - p_ptr->depth++; - - /* Leaving */ - p_ptr->leaving = TRUE; + dungeon_compress_change_level(p_ptr->depth + 1); } } diff -r 85581fc21354 src/tables.c --- a/src/tables.c Sun Jul 25 11:10:51 2010 -0700 +++ b/src/tables.c Sun Jul 25 11:12:41 2010 -0700 @@ -1423,3 +1423,18 @@ {TV_JUNK, "Junk" }, {0, NULL } }; + +/* Maps "actual" dungeon levels to "available" dungeon levels. + */ +const intpair dungeon_level_map[] = { + {0, 0}, // Map town to town + {1, 2}, // Combine the first two levels as dungeon level 2 + {3, 8}, // Combine the third through eighth level as dungeon level 8, etc. + {9, 16}, + {17, 30}, + {31, 40}, + {41, 80}, + {81, 98}, + {99, 99}, // Quest level + {100, 127}, +}; diff -r 85581fc21354 src/trap.c --- a/src/trap.c Sun Jul 25 11:10:51 2010 -0700 +++ b/src/trap.c Sun Jul 25 11:12:41 2010 -0700 @@ -144,7 +144,7 @@ wieldeds_notice_flag(2, TR2_FEATHER); /* New depth */ - dungeon_change_level(p_ptr->depth + 1); + dungeon_compress_change_level(p_ptr->depth + 1); break; } diff -r 85581fc21354 src/types.h --- a/src/types.h Sun Jul 25 11:10:51 2010 -0700 +++ b/src/types.h Sun Jul 25 11:12:41 2010 -0700 @@ -194,6 +194,13 @@ } grouper; +/* Defines a (int, int) pairing. */ +typedef struct +{ + int first; + int second; +} intpair; + /* Information for object auto-inscribe */ struct autoinscription {