summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-20 20:08:15 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-20 20:08:15 +0000
commitebe5e29212f88a4db612ffe5707c08aaa01f818e (patch)
treefb0a90f1ae4f92250010ffca50f3300797b49379 /crawl-ref
parent1aabb3c12726b02bce39e5f9ec843e18640b1fdd (diff)
downloadcrawl-ref-ebe5e29212f88a4db612ffe5707c08aaa01f818e.tar.gz
crawl-ref-ebe5e29212f88a4db612ffe5707c08aaa01f818e.zip
Refactored out branches into branch.h and branch.cc.
NOTE: This commit is *buggy*; the final Hell vaults contain buggy runes now. Will fix later; this is a benchmark, since hopefully everything else works. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@682 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/acr.cc16
-rw-r--r--crawl-ref/source/branch.cc184
-rw-r--r--crawl-ref/source/branch.h39
-rw-r--r--crawl-ref/source/dungeon.cc179
-rw-r--r--crawl-ref/source/enum.h55
-rw-r--r--crawl-ref/source/files.cc2
-rw-r--r--crawl-ref/source/files.h5
-rw-r--r--crawl-ref/source/hiscores.cc33
-rw-r--r--crawl-ref/source/makefile.obj1
-rw-r--r--crawl-ref/source/misc.cc423
-rw-r--r--crawl-ref/source/misc.h3
-rw-r--r--crawl-ref/source/mon-pick.cc251
-rw-r--r--crawl-ref/source/mon-pick.h37
-rw-r--r--crawl-ref/source/newgame.cc60
-rw-r--r--crawl-ref/source/notes.cc22
-rw-r--r--crawl-ref/source/ouch.cc2
-rw-r--r--crawl-ref/source/overmap.cc21
-rw-r--r--crawl-ref/source/spells3.cc7
-rw-r--r--crawl-ref/source/tags.cc19
-rw-r--r--crawl-ref/source/travel.cc298
20 files changed, 571 insertions, 1086 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 2c025b9267..6695a63e00 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -70,6 +70,7 @@
#include "abl-show.h"
#include "abyss.h"
+#include "branch.h"
#include "chardump.h"
#include "cloud.h"
#include "clua.h"
@@ -670,16 +671,11 @@ static void handle_wizard_command( void )
case ':':
j = 0;
- for (i = 0; i < 20; i++)
- {
- if (you.branch_stairs[i] == 0)
- continue;
-
- snprintf( info, INFO_SIZE, "Branch %2d is on level %2d",
- i, you.branch_stairs[i] + 1 );
-
- mpr(info);
- }
+ for (i = 0; i < NUM_BRANCHES; i++)
+ if (branches[i].startdepth != - 1)
+ mprf(MSGCH_DIAGNOSTICS, "Branch %d (%s) is on level %d of %s",
+ i, branches[i].longname, branches[i].startdepth,
+ branches[branches[i].parent_branch].abbrevname);
break;
case '{':
diff --git a/crawl-ref/source/branch.cc b/crawl-ref/source/branch.cc
new file mode 100644
index 0000000000..a6178217de
--- /dev/null
+++ b/crawl-ref/source/branch.cc
@@ -0,0 +1,184 @@
+/*
+ * Modified for Crawl Reference by $Author: haranp $ on $Date: 2006-12-10 22:28:21 +0200 (Sun, 10 Dec 2006) $
+ */
+
+#include "AppHdr.h"
+#include "branch.h"
+#include "mon-pick.h"
+
+Branch branches[] = {
+
+ { BRANCH_MAIN_DUNGEON, BRANCH_MAIN_DUNGEON, 27, -1,
+ NUM_FEATURES, NUM_FEATURES, // sentinel values
+ "Dungeon", "the Dungeon", "D",
+ NULL,
+ LIGHTGREY, BROWN,
+ mons_standard_rare, mons_standard_level, NULL,
+ 8, 'D'
+ },
+
+ { BRANCH_ECUMENICAL_TEMPLE, BRANCH_MAIN_DUNGEON, 1, 5,
+ DNGN_ENTER_TEMPLE, DNGN_RETURN_FROM_TEMPLE,
+ "Temple", "the Ecumenical Temple", "Temple",
+ NULL,
+ LIGHTGREY, LIGHTGREY, mons_standard_rare, mons_standard_level, NULL,
+ 0, 'T' },
+
+ { BRANCH_ORCISH_MINES, BRANCH_MAIN_DUNGEON, 4, 6,
+ DNGN_ENTER_ORCISH_MINES, DNGN_RETURN_FROM_ORCISH_MINES,
+ "Orcish Mines", "the Orcish Mines", "Orc",
+ NULL,
+ BROWN, BROWN,
+ mons_mineorc_rare, mons_mineorc_level, NULL,
+ 20, 'O' },
+
+ { BRANCH_ELVEN_HALLS, BRANCH_ORCISH_MINES, 7, 4,
+ DNGN_ENTER_ELVEN_HALLS, DNGN_RETURN_FROM_ELVEN_HALLS,
+ "Elven Halls", "the Elven Halls", "Elf",
+ NULL,
+ DARKGREY, LIGHTGREY, mons_hallelf_rare, mons_hallelf_level, NULL,
+ 8, 'E' },
+
+ { BRANCH_LAIR, BRANCH_MAIN_DUNGEON, 10, 8,
+ DNGN_ENTER_LAIR, DNGN_RETURN_FROM_LAIR,
+ "Lair", "the Lair of Beasts", "Lair",
+ NULL,
+ GREEN, BROWN, mons_lair_rare, mons_lair_level, NULL,
+ 5, 'L' },
+
+ { BRANCH_SWAMP, BRANCH_LAIR, 5, 3,
+ DNGN_ENTER_SWAMP, DNGN_RETURN_FROM_SWAMP,
+ "Swamp", "the Swamp", "Swamp",
+ NULL,
+ BROWN, BROWN, mons_swamp_rare, mons_swamp_level, NULL,
+ 0, 'S' },
+
+ { BRANCH_SLIME_PITS, BRANCH_LAIR, 6, 4,
+ DNGN_ENTER_SLIME_PITS, DNGN_RETURN_FROM_SLIME_PITS,
+ "Slime Pits", "the Pits of Slime", "Slime",
+ NULL,
+ GREEN, LIGHTGREEN, mons_pitslime_rare, mons_pitslime_level, NULL,
+ 5, 'M' },
+
+ { BRANCH_SNAKE_PIT, BRANCH_LAIR, 5, 7,
+ DNGN_ENTER_SNAKE_PIT, DNGN_RETURN_FROM_SNAKE_PIT,
+ "Snake Pit", "the Snake Pit", "Snake",
+ NULL,
+ LIGHTGREEN, YELLOW, mons_pitsnake_rare, mons_pitsnake_level, NULL,
+ 10, 'P' },
+
+ { BRANCH_HIVE, BRANCH_MAIN_DUNGEON, 4, 15,
+ DNGN_ENTER_HIVE, DNGN_RETURN_FROM_HIVE,
+ "Hive", "the Hive", "Hive",
+ "You hear a buzzing sound coming from all directions.",
+ YELLOW, BROWN, mons_hive_rare, mons_hive_level, NULL,
+ 0, 'H' },
+
+ { BRANCH_VAULTS, BRANCH_MAIN_DUNGEON, 8, 17,
+ DNGN_ENTER_VAULTS, DNGN_RETURN_FROM_VAULTS,
+ "Vaults", "the Vaults", "Vault",
+ NULL,
+ LIGHTGREY, BROWN, mons_standard_rare, mons_standard_level, NULL,
+ 5, 'V' },
+
+
+ { BRANCH_HALL_OF_BLADES, BRANCH_VAULTS, 1, 4,
+ DNGN_ENTER_HALL_OF_BLADES, DNGN_RETURN_FROM_HALL_OF_BLADES,
+ "Hall of Blades", "the Hall of Blades", "Blade",
+ NULL,
+ LIGHTGREY, LIGHTGREY, mons_hallblade_rare, mons_hallblade_level, NULL,
+ 0, 'B' },
+
+ { BRANCH_CRYPT, BRANCH_VAULTS, 5, 3,
+ DNGN_ENTER_CRYPT, DNGN_RETURN_FROM_CRYPT,
+ "Crypt", "the Crypt", "Crypt",
+ NULL,
+ LIGHTGREY, LIGHTGREY, mons_crypt_rare, mons_crypt_level, NULL,
+ 5, 'C' },
+
+ { BRANCH_TOMB, BRANCH_CRYPT, 3, 5,
+ DNGN_ENTER_TOMB, DNGN_RETURN_FROM_TOMB,
+ "Tomb", "the Tomb of the Ancients", "Tomb",
+ NULL,
+ YELLOW, LIGHTGREY, mons_tomb_rare, mons_tomb_level, NULL,
+ 0, 'G' },
+
+ { BRANCH_VESTIBULE_OF_HELL, BRANCH_MAIN_DUNGEON, 1, -1,
+ DNGN_ENTER_HELL, NUM_FEATURES, // sentinel
+ "Hell", "The Vestibule of Hell", "Hell",
+ NULL,
+ LIGHTGREY, LIGHTGREY,
+ mons_standard_rare, mons_standard_level, NULL,
+ 0, 'U'
+ },
+
+ { BRANCH_DIS, BRANCH_VESTIBULE_OF_HELL, 7, -1,
+ DNGN_ENTER_DIS, NUM_FEATURES, // sentinel
+ "Dis", "the Iron City of Dis", "Dis",
+ NULL,
+ CYAN, CYAN,
+ mons_dis_rare, mons_dis_level, NULL,
+ 0, 'I'
+ },
+
+ { BRANCH_GEHENNA, BRANCH_VESTIBULE_OF_HELL, 7, -1,
+ DNGN_ENTER_GEHENNA, NUM_FEATURES, // sentinel
+ "Gehenna", "Gehenna", "Geh",
+ NULL,
+ DARKGREY, RED,
+ mons_gehenna_rare, mons_gehenna_level, NULL,
+ 0, 'N'
+ },
+
+ { BRANCH_COCYTUS, BRANCH_VESTIBULE_OF_HELL, 7, -1,
+ DNGN_ENTER_COCYTUS, NUM_FEATURES, // sentinel
+ "Cocytus", "Cocytus", "Coc",
+ NULL,
+ LIGHTBLUE, LIGHTCYAN,
+ mons_cocytus_rare, mons_cocytus_level, NULL,
+ 0, 'X'
+ },
+
+ { BRANCH_TARTARUS, BRANCH_VESTIBULE_OF_HELL, 7, -1,
+ DNGN_ENTER_TARTARUS, NUM_FEATURES, // sentinel
+ "Tartarus", "Tartarus", "Tar",
+ NULL,
+ DARKGREY, DARKGREY,
+ mons_tartarus_rare, mons_tartarus_level, NULL,
+ 0, 'Y'
+ },
+
+ { BRANCH_INFERNO, BRANCH_MAIN_DUNGEON, -1, -1,
+ NUM_FEATURES, NUM_FEATURES,
+ NULL, NULL, NULL,
+ NULL,
+ BLACK, BLACK,
+ NULL, NULL, NULL,
+ 0, 'R'
+ },
+
+ { BRANCH_THE_PIT, BRANCH_MAIN_DUNGEON, -1, -1,
+ NUM_FEATURES, NUM_FEATURES,
+ NULL, NULL, NULL,
+ NULL,
+ BLACK, BLACK,
+ NULL, NULL, NULL,
+ 0, '0'
+ },
+
+ { BRANCH_HALL_OF_ZOT, BRANCH_MAIN_DUNGEON, 5, 27,
+ DNGN_ENTER_ZOT, DNGN_RETURN_FROM_ZOT,
+ "Zot", "the Realm of Zot", "Zot",
+ NULL,
+ BLACK, BLACK, mons_hallzot_rare, mons_hallzot_level, NULL,
+ 1, 'Z' },
+
+ { BRANCH_CAVERNS, BRANCH_MAIN_DUNGEON, -1, -1,
+ NUM_FEATURES, NUM_FEATURES,
+ NULL, NULL, NULL,
+ NULL,
+ BLACK, BLACK,
+ NULL, NULL, NULL,
+ 0, 0
+ }
+};
diff --git a/crawl-ref/source/branch.h b/crawl-ref/source/branch.h
new file mode 100644
index 0000000000..1cb0cfc997
--- /dev/null
+++ b/crawl-ref/source/branch.h
@@ -0,0 +1,39 @@
+/*
+ * File: branch.h
+ * Summary: Dungeon branch classes
+ * Written by: Haran Pilpel
+ *
+ * Modified for Crawl Reference by $Author: haranp $ on $Date: 2006-11-29 13:12:52 -0500 (Wed, 29 Nov 2006) $
+ *
+ */
+
+#ifndef BRANCH_H
+#define BRANCH_H
+
+#include "enum.h"
+
+struct Branch
+{
+ branch_type id;
+ branch_type parent_branch;
+ int depth;
+ int startdepth; // which level of the parent branch,
+ // 1 for first level
+ dungeon_feature_type entry_stairs;
+ dungeon_feature_type exit_stairs;
+ const char* shortname; // "Slime Pits"
+ const char* longname; // "The Pits of Slime"
+ const char* abbrevname; // "Slime"
+ const char* entry_message;
+ char floor_colour; // Zot needs special handling
+ char rock_colour;
+ int (*mons_rarity_function)(int);
+ int (*mons_level_function)(int);
+ void (*level_builder_function)(int);
+ int altar_chance; // in percent
+ int travel_shortcut; // which key to press for travel
+};
+
+extern Branch branches[];
+
+#endif
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 7d7682df0d..ec9ea36d71 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -32,6 +32,7 @@
#include "AppHdr.h"
#include "abyss.h"
+#include "branch.h"
#include "defines.h"
#include "enum.h"
#include "externs.h"
@@ -179,56 +180,24 @@ static bool got_curare_roll(const int item_level)
static void place_altars()
{
- int altar_chances[][2] = {
- // These are percentages
- { BRANCH_MAIN_DUNGEON, 8 },
- { BRANCH_DIS, 0 },
- { BRANCH_GEHENNA, 0 },
- { BRANCH_VESTIBULE_OF_HELL, 0 },
- { BRANCH_COCYTUS, 0 },
- { BRANCH_TARTARUS, 0 },
- { BRANCH_INFERNO, 0 },
- { BRANCH_THE_PIT, 0 },
- { BRANCH_ORCISH_MINES, 20 },
- { BRANCH_HIVE, 0 },
- { BRANCH_LAIR, 5 },
- { BRANCH_SLIME_PITS, 5 },
- { BRANCH_VAULTS, 5 },
- { BRANCH_CRYPT, 5 },
- { BRANCH_HALL_OF_BLADES, 0 },
- { BRANCH_HALL_OF_ZOT, 1 },
- { BRANCH_ECUMENICAL_TEMPLE, 0 },
- { BRANCH_SNAKE_PIT, 10 },
- { BRANCH_ELVEN_HALLS, 8 },
- { BRANCH_TOMB, 0 },
- { BRANCH_SWAMP, 0 },
- { BRANCH_CAVERNS, 0 },
- { -1, -1 }
- };
-
// No altars before level 5.
if (you.your_level < 4)
return;
- for (int i = 0; altar_chances[i][0] != -1; ++i)
+ if ( you.level_type == LEVEL_DUNGEON )
{
- if (player_in_branch( altar_chances[i][0] ))
+ int prob = branches[(int)you.where_are_you].altar_chance;
+ while (prob)
{
- int prob = altar_chances[i][1];
- while (prob)
- {
- if (random2(100) >= prob)
- break;
+ if (random2(100) >= prob)
+ break;
#ifdef DEBUG_DIAGNOSTICS
- mprf(MSGCH_DIAGNOSTICS, "Placing an altar");
+ mprf(MSGCH_DIAGNOSTICS, "Placing an altar");
#endif
- place_altar();
-
- // Reduce the chance and try to place another.
- prob /= 5;
- }
- break;
+ place_altar();
+ // Reduce the chance and try to place another.
+ prob /= 5;
}
}
}
@@ -270,9 +239,7 @@ void builder(int level_number, char level_type)
// reset all shops
for (unsigned char shcount = 0; shcount < 5; shcount++)
- {
env.shop[shcount].type = SHOP_UNASSIGNED;
- }
int skip_build;
@@ -392,18 +359,16 @@ void builder(int level_number, char level_type)
if (player_in_branch( BRANCH_VAULTS ))
{
vault_wall = DNGN_ROCK_WALL;
+ const int bdepth = player_branch_depth();
- if (level_number > you.branch_stairs[STAIRS_VAULTS] + 2)
+ if ( bdepth > 2 )
vault_wall = DNGN_STONE_WALL;
- if (level_number > you.branch_stairs[STAIRS_VAULTS] + 4)
+ if ( bdepth > 4 )
vault_wall = DNGN_METAL_WALL;
- if (level_number > you.branch_stairs[STAIRS_VAULTS] + 6
- && one_chance_in(10))
- {
+ if ( bdepth > 6 && one_chance_in(10))
vault_wall = DNGN_GREEN_CRYSTAL_WALL;
- }
}
else if (player_in_branch( BRANCH_CRYPT ))
{
@@ -415,48 +380,24 @@ void builder(int level_number, char level_type)
// Top level of branch levels - replaces up stairs
// with stairs back to dungeon or wherever:
- for (i = 0; i< 30; i++)
+ if ( branches[(int)you.where_are_you].exit_stairs != NUM_FEATURES &&
+ player_branch_depth() == 1 )
{
- if (you.branch_stairs[i] == 0)
- break;
-
- if (level_number == you.branch_stairs[i] + 1
- && level_type == LEVEL_DUNGEON
- && you.where_are_you == BRANCH_ORCISH_MINES + i)
- {
- for (x = 1; x < GXM; x++)
- {
- for (y = 1; y < GYM; y++)
- {
- if (grd[x][y] >= DNGN_STONE_STAIRS_UP_I
- && grd[x][y] <= DNGN_ROCK_STAIRS_UP)
- {
- grd[x][y] = DNGN_RETURN_FROM_ORCISH_MINES + i;
- }
- }
- }
- }
+ for (x = 1; x < GXM; x++)
+ for (y = 1; y < GYM; y++)
+ if (grd[x][y] >= DNGN_STONE_STAIRS_UP_I
+ && grd[x][y] <= DNGN_ROCK_STAIRS_UP)
+ grd[x][y] = branches[(int)you.where_are_you].exit_stairs;
}
// bottom level of branch - replaces down stairs with up ladders:
- for (i = 0; i < 30; i++)
+ if ( player_branch_depth() == branches[(int)you.where_are_you].depth )
{
- if (level_number == you.branch_stairs[i] + branch_depth(i)
- && level_type == LEVEL_DUNGEON
- && you.where_are_you == BRANCH_ORCISH_MINES + i)
- {
- for (x = 1; x < GXM; x++)
- {
- for (y = 1; y < GYM; y++)
- {
- if (grd[x][y] >= DNGN_STONE_STAIRS_DOWN_I
- && grd[x][y] <= DNGN_ROCK_STAIRS_DOWN)
- {
- grd[x][y] = DNGN_ROCK_STAIRS_UP;
- }
- }
- }
- }
+ for (x = 1; x < GXM; x++)
+ for (y = 1; y < GYM; y++)
+ if (grd[x][y] >= DNGN_STONE_STAIRS_DOWN_I
+ && grd[x][y] <= DNGN_ROCK_STAIRS_DOWN)
+ grd[x][y] = DNGN_ROCK_STAIRS_UP;
}
if (player_in_branch( BRANCH_CRYPT ))
@@ -3794,7 +3735,7 @@ static int random_map_for_dlevel(int level_number, bool wantmini = false)
// This dodge allows designers to specify PLACE: as Elf:$ or Slime:$ or
// whatever:$ to say "last level in branch 'whatever'".
- if (subdepth == branch_depth( branch_stair(you.where_are_you) ))
+ if (subdepth == branches[(int)you.where_are_you].depth)
altname = level_name(0);
int vault = random_map_for_place(name, wantmini);
@@ -4225,8 +4166,6 @@ static void place_specific_stair(unsigned char stair)
static void place_branch_entrances(int dlevel, char level_type)
{
- unsigned char stair;
- unsigned char entrance;
int sx, sy;
if (!level_type == LEVEL_DUNGEON)
@@ -4264,62 +4203,20 @@ static void place_branch_entrances(int dlevel, char level_type)
}
// place actual branch entrances
- for (int branch = 0; branch < 30; branch++)
+ for (int i = 0; i < NUM_BRANCHES; ++i)
{
- stair = 0;
- entrance = 100;
-
- if (you.branch_stairs[branch] == 100) // set in newgame
- break;
-
- if (you.branch_stairs[branch] != dlevel)
- continue;
-
- // decide if this branch leaves from this level
- switch(branch)
+ if ( branches[i].entry_stairs != NUM_FEATURES &&
+ player_in_branch(branches[i].parent_branch) &&
+ player_branch_depth() == branches[i].startdepth )
{
- case STAIRS_ORCISH_MINES:
- case STAIRS_HIVE:
- case STAIRS_LAIR:
- case STAIRS_VAULTS:
- case STAIRS_ECUMENICAL_TEMPLE:
- entrance = BRANCH_MAIN_DUNGEON;
- break;
-
- case STAIRS_SLIME_PITS:
- case STAIRS_SWAMP:
- case STAIRS_SNAKE_PIT:
- entrance = BRANCH_LAIR;
- break;
-
- case STAIRS_ELVEN_HALLS:
- entrance = BRANCH_ORCISH_MINES;
- break;
-
- case STAIRS_CRYPT:
- case STAIRS_HALL_OF_BLADES:
- entrance = BRANCH_VAULTS;
- break;
-
- case STAIRS_TOMB:
- entrance = BRANCH_CRYPT;
- break;
-
- default:
- entrance = 100;
- break;
- }
-
- if (you.where_are_you != entrance)
- continue;
-
- stair = branch + DNGN_ENTER_ORCISH_MINES;
- place_specific_stair(stair);
+ // place a stair
#ifdef DEBUG_DIAGNOSTICS
- mprf(MSGCH_DIAGNOSTICS, "Placing stair: %s",
- feature_description(stair).c_str());
+ mprf(MSGCH_DIAGNOSTICS, "Placing stair to %s",
+ branches[i].shortname);
#endif
- } // end loop - possible branch entrances
+ place_specific_stair(branches[i].entry_stairs);
+ }
+ }
}
static void make_trail(int xs, int xr, int ys, int yr, int corrlength,
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 9726ea4b0e..b4ec68e2f8 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -439,48 +439,31 @@ enum book_type
NUM_BOOKS
};
-enum branch_type // you.where_are_you
+enum branch_type // you.where_are_you
{
- BRANCH_MAIN_DUNGEON, // 0
- BRANCH_DIS,
- BRANCH_GEHENNA,
- BRANCH_VESTIBULE_OF_HELL,
- BRANCH_COCYTUS,
- BRANCH_TARTARUS, // 5
- BRANCH_INFERNO, // unimplemented
- BRANCH_THE_PIT, // 7 // unimplemented
- BRANCH_ORCISH_MINES = 10, // 10
- BRANCH_HIVE,
+ BRANCH_MAIN_DUNGEON, // 0
+ BRANCH_ECUMENICAL_TEMPLE,
+ BRANCH_ORCISH_MINES,
+ BRANCH_ELVEN_HALLS,
BRANCH_LAIR,
+ BRANCH_SWAMP,
BRANCH_SLIME_PITS,
+ BRANCH_SNAKE_PIT,
+ BRANCH_HIVE,
BRANCH_VAULTS,
- BRANCH_CRYPT, // 15
BRANCH_HALL_OF_BLADES,
- BRANCH_HALL_OF_ZOT,
- BRANCH_ECUMENICAL_TEMPLE,
- BRANCH_SNAKE_PIT,
- BRANCH_ELVEN_HALLS, // 20
+ BRANCH_CRYPT,
BRANCH_TOMB,
- BRANCH_SWAMP,
- BRANCH_CAVERNS
-};
-
-enum branch_stair_type // you.branch_stairs[] - 10 less than BRANCHES {dlb}
-{
- STAIRS_ORCISH_MINES, // 0
- STAIRS_HIVE,
- STAIRS_LAIR,
- STAIRS_SLIME_PITS,
- STAIRS_VAULTS,
- STAIRS_CRYPT, // 5
- STAIRS_HALL_OF_BLADES,
- STAIRS_HALL_OF_ZOT,
- STAIRS_ECUMENICAL_TEMPLE,
- STAIRS_SNAKE_PIT,
- STAIRS_ELVEN_HALLS, // 10
- STAIRS_TOMB,
- STAIRS_SWAMP,
- STAIRS_CAVERNS
+ BRANCH_VESTIBULE_OF_HELL,
+ BRANCH_DIS,
+ BRANCH_GEHENNA,
+ BRANCH_COCYTUS,
+ BRANCH_TARTARUS,
+ BRANCH_INFERNO, // unimplemented
+ BRANCH_THE_PIT, // unimplemented
+ BRANCH_HALL_OF_ZOT,
+ BRANCH_CAVERNS, // unimplemented
+ NUM_BRANCHES
};
enum burden_state_type // you.burden_state
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index 2c1ffb7486..f975b53552 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -813,7 +813,7 @@ void load( unsigned char stair_taken, int load_mode, bool was_a_labyrinth,
&& where_were_you2 == BRANCH_VESTIBULE_OF_HELL
&& stair_taken == DNGN_STONE_STAIRS_UP_I)
{
- // leaving hell - look for entry potal first
+ // leaving hell - look for entry portal first
stair_taken = DNGN_ENTER_HELL;
find_first = false;
}
diff --git a/crawl-ref/source/files.h b/crawl-ref/source/files.h
index e5cb6b6a6f..b87e4f9bea 100644
--- a/crawl-ref/source/files.h
+++ b/crawl-ref/source/files.h
@@ -22,12 +22,9 @@
// referenced in files - newgame - ouch - overmap:
#define MAX_LEVELS 50
-// referenced in files - newgame - ouch - overmap:
-#define MAX_BRANCHES 30 // there must be a way this can be extracted from other data
-
// referenced in files - newgame - ouch:
-extern FixedArray<bool, MAX_LEVELS, MAX_BRANCHES> tmp_file_pairs;
+extern FixedArray<bool, MAX_LEVELS, NUM_BRANCHES> tmp_file_pairs;
std::string datafile_path(const std::string &basename);
diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc
index 27031e7337..61020d5e11 100644
--- a/crawl-ref/source/hiscores.cc
+++ b/crawl-ref/source/hiscores.cc
@@ -1034,7 +1034,7 @@ static void hs_search_where(char *inbuf, struct scorefile_entry &se)
if (se.level_type != LEVEL_DUNGEON)
return;
- // check for vestible
+ // check for vestibule
if (strstr(inbuf, "in the Vestibule") != NULL)
{
se.branch = BRANCH_VESTIBULE_OF_HELL;
@@ -1332,36 +1332,7 @@ void scorefile_entry::init()
}
// main dungeon: level is simply level
- dlvl = you.your_level + 1;
- switch (you.where_are_you)
- {
- case BRANCH_ORCISH_MINES:
- case BRANCH_HIVE:
- case BRANCH_LAIR:
- case BRANCH_SLIME_PITS:
- case BRANCH_VAULTS:
- case BRANCH_CRYPT:
- case BRANCH_HALL_OF_BLADES:
- case BRANCH_HALL_OF_ZOT:
- case BRANCH_ECUMENICAL_TEMPLE:
- case BRANCH_SNAKE_PIT:
- case BRANCH_ELVEN_HALLS:
- case BRANCH_TOMB:
- case BRANCH_SWAMP:
- dlvl = you.your_level - you.branch_stairs[you.where_are_you - 10];
- break;
-
- case BRANCH_DIS:
- case BRANCH_GEHENNA:
- case BRANCH_VESTIBULE_OF_HELL:
- case BRANCH_COCYTUS:
- case BRANCH_TARTARUS:
- case BRANCH_INFERNO:
- case BRANCH_THE_PIT:
- dlvl = you.your_level - 26;
- break;
- }
-
+ dlvl = player_branch_depth();
branch = you.where_are_you; // no adjustments necessary.
level_type = you.level_type; // pandemonium, labyrinth, dungeon..
diff --git a/crawl-ref/source/makefile.obj b/crawl-ref/source/makefile.obj
index 2b811f1c56..da61c5d0d2 100644
--- a/crawl-ref/source/makefile.obj
+++ b/crawl-ref/source/makefile.obj
@@ -5,6 +5,7 @@ abl-show.o \
abyss.o \
acr.o \
beam.o \
+branch.o \
chardump.o \
cloud.o \
command.o \
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 0c4f83934e..a01640aede 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -35,6 +35,7 @@
#include "externs.h"
+#include "branch.h"
#include "cloud.h"
#include "delay.h"
#include "fight.h"
@@ -611,39 +612,19 @@ void up_stairs(void)
you.your_level = 27;
}
- switch (stair_find)
+ // did we take a branch stair?
+ for ( i = 0; i < NUM_BRANCHES; ++i )
{
- case DNGN_RETURN_FROM_ORCISH_MINES:
- case DNGN_RETURN_FROM_HIVE:
- case DNGN_RETURN_FROM_LAIR:
- case DNGN_RETURN_FROM_VAULTS:
- case DNGN_RETURN_FROM_TEMPLE:
- case DNGN_RETURN_FROM_ZOT:
- mpr("Welcome back to the Dungeon!");
- you.where_are_you = BRANCH_MAIN_DUNGEON;
- break;
- case DNGN_RETURN_FROM_SLIME_PITS:
- case DNGN_RETURN_FROM_SNAKE_PIT:
- case DNGN_RETURN_FROM_SWAMP:
- mpr("Welcome back to the Lair of Beasts!");
- you.where_are_you = BRANCH_LAIR;
- break;
- case DNGN_RETURN_FROM_CRYPT:
- case DNGN_RETURN_FROM_HALL_OF_BLADES:
- mpr("Welcome back to the Vaults!");
- you.where_are_you = BRANCH_VAULTS;
- break;
- case DNGN_RETURN_FROM_TOMB:
- mpr("Welcome back to the Crypt!");
- you.where_are_you = BRANCH_CRYPT;
- break;
- case DNGN_RETURN_FROM_ELVEN_HALLS:
- mpr("Welcome back to the Orcish Mines!");
- you.where_are_you = BRANCH_ORCISH_MINES;
- break;
+ if ( branches[i].exit_stairs == stair_find )
+ {
+ mprf("Welcome back to %s!",
+ branches[branches[i].parent_branch].longname);
+ you.where_are_you = branches[i].parent_branch;
+ break;
+ }
}
- unsigned char stair_taken = stair_find;
+ const unsigned char stair_taken = stair_find;
if (player_is_levitating())
{
@@ -856,96 +837,25 @@ void down_stairs( bool remove_stairs, int old_level, bool force )
if (!you.running)
more();
- you.your_level = 26; // = 59;
+ you.your_level = 26;
}
- if ((stair_find >= DNGN_ENTER_DIS
- && stair_find <= DNGN_ENTER_TARTARUS)
- || (stair_find >= DNGN_ENTER_ORCISH_MINES
- && stair_find < DNGN_RETURN_FROM_ORCISH_MINES))
+ // welcome message
+ // try to find a branch stair
+ for ( i = 0; i < NUM_BRANCHES; ++i )
{
- // no idea why such a huge switch and not 100-grd[][]
- // planning ahead for reorganizing grd[][] values - 13jan2000 {dlb}
- strcpy( info, "Welcome to " );
- switch (stair_find)
+ if ( branches[i].entry_stairs == stair_find )
{
- case DNGN_ENTER_DIS:
- strcat(info, "the Iron City of Dis!");
- you.where_are_you = BRANCH_DIS;
- you.your_level = 26;
- break;
- case DNGN_ENTER_GEHENNA:
- strcat(info, "Gehenna!");
- you.where_are_you = BRANCH_GEHENNA;
- you.your_level = 26;
- break;
- case DNGN_ENTER_COCYTUS:
- strcat(info, "Cocytus!");
- you.where_are_you = BRANCH_COCYTUS;
- you.your_level = 26;
- break;
- case DNGN_ENTER_TARTARUS:
- strcat(info, "Tartarus!");
- you.where_are_you = BRANCH_TARTARUS;
- you.your_level = 26;
- break;
- case DNGN_ENTER_ORCISH_MINES:
- strcat(info, "the Orcish Mines!");
- you.where_are_you = BRANCH_ORCISH_MINES;
- break;
- case DNGN_ENTER_HIVE:
- strcpy(info, "You hear a buzzing sound coming from all directions.");
- you.where_are_you = BRANCH_HIVE;
- break;
- case DNGN_ENTER_LAIR:
- strcat(info, "the Lair of Beasts!");
- you.where_are_you = BRANCH_LAIR;
- break;
- case DNGN_ENTER_SLIME_PITS:
- strcat(info, "the Pits of Slime!");
- you.where_are_you = BRANCH_SLIME_PITS;
- break;
- case DNGN_ENTER_VAULTS:
- strcat(info, "the Vaults!");
- you.where_are_you = BRANCH_VAULTS;
- break;
- case DNGN_ENTER_CRYPT:
- strcat(info, "the Crypt!");
- you.where_are_you = BRANCH_CRYPT;
- break;
- case DNGN_ENTER_HALL_OF_BLADES:
- strcat(info, "the Hall of Blades!");
- you.where_are_you = BRANCH_HALL_OF_BLADES;
- break;
- case DNGN_ENTER_ZOT:
- strcat(info, "the Hall of Zot!");
- you.where_are_you = BRANCH_HALL_OF_ZOT;
- break;
- case DNGN_ENTER_TEMPLE:
- strcat(info, "the Ecumenical Temple!");
- you.where_are_you = BRANCH_ECUMENICAL_TEMPLE;
- break;
- case DNGN_ENTER_SNAKE_PIT:
- strcat(info, "the Snake Pit!");
- you.where_are_you = BRANCH_SNAKE_PIT;
- break;
- case DNGN_ENTER_ELVEN_HALLS:
- strcat(info, "the Elven Halls!");
- you.where_are_you = BRANCH_ELVEN_HALLS;
- break;
- case DNGN_ENTER_TOMB:
- strcat(info, "the Tomb!");
- you.where_are_you = BRANCH_TOMB;
- break;
- case DNGN_ENTER_SWAMP:
- strcat(info, "the Swamp!");
- you.where_are_you = BRANCH_SWAMP;
+ if ( branches[i].entry_message )
+ mpr(branches[i].entry_message);
+ else
+ mprf("Welcome to %s!", branches[i].longname);
+ you.where_are_you = branches[i].id;
break;
}
-
- mpr(info);
}
- else if (stair_find == DNGN_ENTER_LABYRINTH)
+
+ if (stair_find == DNGN_ENTER_LABYRINTH)
{
// no longer a feature
unnotice_labyrinth_portal();
@@ -1004,10 +914,8 @@ void down_stairs( bool remove_stairs, int old_level, bool force )
int stair_taken = stair_find;
- //unsigned char save_old = 1;
-
if (you.level_type == LEVEL_LABYRINTH || you.level_type == LEVEL_ABYSS)
- stair_taken = DNGN_FLOOR; //81;
+ stair_taken = DNGN_FLOOR;
if (you.level_type == LEVEL_PANDEMONIUM)
stair_taken = DNGN_TRANSIT_PANDEMONIUM;
@@ -1150,53 +1058,38 @@ void init_new_level(bool transit)
stash_init_new_level();
}
+static char fix_colour(char incol )
+{
+ if ( incol == BLACK )
+ return LIGHTGREY;
+ else
+ return incol;
+}
+
void new_level(void)
{
- int curr_subdungeon_level = you.your_level + 1;
+ const int curr_subdungeon_level = player_branch_depth();
textcolor(LIGHTGREY);
- // maybe last part better expresssed as <= PIT {dlb}
- if (player_in_hell() || player_in_branch( BRANCH_VESTIBULE_OF_HELL ))
- curr_subdungeon_level = you.your_level - 26;
-
- /* Remember, must add this to the death_string in ouch */
- if (you.where_are_you >= BRANCH_ORCISH_MINES
- && you.where_are_you <= BRANCH_SWAMP)
- {
- curr_subdungeon_level = you.your_level
- - you.branch_stairs[you.where_are_you - 10];
- }
-
gotoxy(46, 12);
#if DEBUG_DIAGNOSTICS
cprintf( "(%d) ", you.your_level + 1 );
#endif
- env.floor_colour = LIGHTGREY;
- env.rock_colour = BROWN;
-
take_note(Note(NOTE_DUNGEON_LEVEL_CHANGE));
if (you.level_type == LEVEL_PANDEMONIUM)
{
cprintf("- Pandemonium ");
-
- env.floor_colour = (mcolour[env.mons_alloc[9]] == BLACK)
- ? LIGHTGREY : mcolour[env.mons_alloc[9]];
-
- env.rock_colour = (mcolour[env.mons_alloc[8]] == BLACK)
- ? LIGHTGREY : mcolour[env.mons_alloc[8]];
+ env.floor_colour = fix_colour(mcolour[env.mons_alloc[9]]);
+ env.rock_colour = fix_colour(mcolour[env.mons_alloc[8]]);
}
else if (you.level_type == LEVEL_ABYSS)
{
cprintf("- The Abyss ");
-
- env.floor_colour = (mcolour[env.mons_alloc[9]] == BLACK)
- ? LIGHTGREY : mcolour[env.mons_alloc[9]];
-
- env.rock_colour = (mcolour[env.mons_alloc[8]] == BLACK)
- ? LIGHTGREY : mcolour[env.mons_alloc[8]];
+ env.floor_colour = fix_colour(mcolour[env.mons_alloc[9]]);
+ env.rock_colour = fix_colour(mcolour[env.mons_alloc[8]]);
}
else if (you.level_type == LEVEL_LABYRINTH)
{
@@ -1205,144 +1098,34 @@ void new_level(void)
else
{
// level_type == LEVEL_DUNGEON
- if (!player_in_branch( BRANCH_VESTIBULE_OF_HELL ))
- cprintf( "%d", curr_subdungeon_level );
+ const int youbranch = you.where_are_you;
+ if ( branches[youbranch].depth == 1 )
+ cprintf( "- %s", branches[youbranch].longname );
+ else
+ cprintf( "%d of %s", curr_subdungeon_level,
+ branches[youbranch].longname );
- switch (you.where_are_you)
- {
- case BRANCH_MAIN_DUNGEON:
- cprintf(" of the Dungeon ");
- break;
- case BRANCH_DIS:
- env.floor_colour = CYAN;
- env.rock_colour = CYAN;
- cprintf(" of Dis ");
- break;
- case BRANCH_GEHENNA:
- env.floor_colour = DARKGREY;
- env.rock_colour = RED;
- cprintf(" of Gehenna ");
- break;
- case BRANCH_VESTIBULE_OF_HELL:
- env.floor_colour = LIGHTGREY;
- env.rock_colour = LIGHTGREY;
- cprintf("- the Vestibule of Hell ");
- break;
- case BRANCH_COCYTUS:
- env.floor_colour = LIGHTBLUE;
- env.rock_colour = LIGHTCYAN;
- cprintf(" of Cocytus ");
- break;
- case BRANCH_TARTARUS:
- env.floor_colour = DARKGREY;
- env.rock_colour = DARKGREY;
- cprintf(" of Tartarus ");
- break;
- case BRANCH_INFERNO:
- env.floor_colour = LIGHTRED;
- env.rock_colour = RED;
- cprintf(" of the Inferno ");
- break;
- case BRANCH_THE_PIT:
- env.floor_colour = RED;
- env.rock_colour = DARKGREY;
- cprintf(" of the Pit ");
- break;
- case BRANCH_ORCISH_MINES:
- env.floor_colour = BROWN;
- env.rock_colour = BROWN;
- cprintf(" of the Orcish Mines ");
- break;
- case BRANCH_HIVE:
- env.floor_colour = YELLOW;
- env.rock_colour = BROWN;
- cprintf(" of the Hive ");
- break;
- case BRANCH_LAIR:
- env.floor_colour = GREEN;
- env.rock_colour = BROWN;
- cprintf(" of the Lair ");
- break;
- case BRANCH_SLIME_PITS:
- env.floor_colour = GREEN;
- env.rock_colour = LIGHTGREEN;
- cprintf(" of the Slime Pits ");
- break;
- case BRANCH_VAULTS:
- env.floor_colour = LIGHTGREY;
- env.rock_colour = BROWN;
- cprintf(" of the Vaults ");
- break;
- case BRANCH_CRYPT:
- env.floor_colour = LIGHTGREY;
- env.rock_colour = LIGHTGREY;
- cprintf(" of the Crypt ");
- break;
- case BRANCH_HALL_OF_BLADES:
- env.floor_colour = LIGHTGREY;
- env.rock_colour = LIGHTGREY;
- cprintf(" of the Hall of Blades ");
- break;
+ env.floor_colour = branches[youbranch].floor_colour;
+ env.rock_colour = branches[youbranch].rock_colour;
- case BRANCH_HALL_OF_ZOT:
- if (you.your_level - you.branch_stairs[7] <= 1)
- {
- env.floor_colour = LIGHTGREY;
- env.rock_colour = LIGHTGREY;
- }
+ // Zot is multicoloured
+ if ( you.where_are_you == BRANCH_HALL_OF_ZOT )
+ {
+ const char floorcolours_zot[] = { LIGHTGREY, LIGHTGREY, BLUE,
+ LIGHTBLUE, MAGENTA };
+ const char rockcolours_zot[] = { LIGHTGREY, BLUE, LIGHTBLUE,
+ MAGENTA, LIGHTMAGENTA };
+ if ( curr_subdungeon_level > 5 || curr_subdungeon_level < 1 )
+ mpr("Odd colouring!");
else
{
- switch (you.your_level - you.branch_stairs[7])
- {
- case 2:
- env.rock_colour = LIGHTGREY;
- env.floor_colour = BLUE;
- break;
- case 3:
- env.rock_colour = BLUE;
- env.floor_colour = LIGHTBLUE;
- break;
- case 4:
- env.rock_colour = LIGHTBLUE;
- env.floor_colour = MAGENTA;
- break;
- case 5:
- env.rock_colour = MAGENTA;
- env.floor_colour = LIGHTMAGENTA;
- break;
- }
+ env.floor_colour = floorcolours_zot[curr_subdungeon_level-1];
+ env.rock_colour = rockcolours_zot[curr_subdungeon_level-1];
}
- cprintf(" of the Realm of Zot ");
- break;
-
- case BRANCH_ECUMENICAL_TEMPLE:
- env.floor_colour = LIGHTGREY;
- env.rock_colour = LIGHTGREY;
- cprintf(" of the Temple ");
- break;
- case BRANCH_SNAKE_PIT:
- env.floor_colour = LIGHTGREEN;
- env.rock_colour = YELLOW;
- cprintf(" of the Snake Pit ");
- break;
- case BRANCH_ELVEN_HALLS:
- env.floor_colour = DARKGREY;
- env.rock_colour = LIGHTGREY;
- cprintf(" of the Elven Halls ");
- break;
- case BRANCH_TOMB:
- env.floor_colour = YELLOW;
- env.rock_colour = LIGHTGREY;
- cprintf(" of the Tomb ");
- break;
- case BRANCH_SWAMP:
- env.floor_colour = BROWN;
- env.rock_colour = BROWN;
- cprintf(" of the Swamp ");
- break;
}
- } // end else
-} // end new_level()
+ }
+ clear_to_end_of_line();
+}
static void dart_trap( bool trap_known, int trapped, struct bolt &pbolt,
bool poison )
@@ -2035,37 +1818,6 @@ bool single_level_branch( int branch )
branch == BRANCH_ECUMENICAL_TEMPLE;
}
-std::string branch_name( int branch, bool terse )
-{
- const char* names[][2] = {
- { "The Dungeon", "D" },
- { "The Iron City of Dis", "Dis" },
- { "Gehenna", "Geh" },
- { "The Vestibule of Hell", "Hell" },
- { "Cocytus", "Coc" },
- { "Tartarus", "Tar" },
- { "Inferno", "Inf" },
- { "The Pit", "Pit" },
- { "", "" },
- { "", "" },
- { "The Orcish Mines", "Orc" },
- { "The Hive", "Hive" },
- { "The Lair", "Lair" },
- { "The Slime Pits", "Slime" },
- { "The Vaults", "Vault" },
- { "The Crypt", "Crypt" },
- { "The Hall of Blades", "Blade" },
- { "The Hall of Zot", "Zot" },
- { "The Ecumenical Temple", "Temple" },
- { "The Snake Pit", "Snake" },
- { "The Elven Halls", "Elf" },
- { "The Tomb", "Tomb" },
- { "The Swamp", "Swamp" },
- { "The Caverns", "Cav" }
- };
- return names[branch][terse];
-}
-
std::string place_name( unsigned short place, bool long_name,
bool include_number ) {
@@ -2088,25 +1840,25 @@ std::string place_name( unsigned short place, bool long_name,
}
}
- result = branch_name(branch, !long_name);
+ result = (long_name ?
+ branches[branch].longname : branches[branch].abbrevname);
- if ( include_number && !single_level_branch(branch) ) {
+ if ( include_number && branches[branch].depth != 1 )
+ {
char buf[200];
- if ( long_name ) {
+ if ( long_name )
+ {
// decapitalize 'the'
if ( result.find("The") == 0 )
result[0] = 't';
snprintf( buf, sizeof buf, "Level %d of %s",
lev, result.c_str() );
}
- else if (lev) {
- snprintf( buf, sizeof buf, "%s:%d",
- result.c_str(), lev );
- }
- else {
- snprintf( buf, sizeof buf, "%s:$",
- result.c_str() );
- }
+ else if (lev)
+ snprintf( buf, sizeof buf, "%s:%d", result.c_str(), lev );
+ else
+ snprintf( buf, sizeof buf, "%s:$", result.c_str() );
+
result = buf;
}
return result;
@@ -2140,29 +1892,28 @@ std::string prep_branch_level_name()
int absdungeon_depth(unsigned char branch, int subdepth)
{
- int realdepth = subdepth - 1;
-
- if (branch >= BRANCH_ORCISH_MINES && branch <= BRANCH_SWAMP)
- realdepth = subdepth + you.branch_stairs[branch - 10];
-
- if (branch >= BRANCH_DIS && branch <= BRANCH_THE_PIT)
- realdepth = subdepth + 26;
-
- return realdepth;
+ if (branch >= BRANCH_VESTIBULE_OF_HELL && branch <= BRANCH_THE_PIT)
+ return subdepth + 27;
+ else
+ {
+ --subdepth;
+ while ( branch != BRANCH_MAIN_DUNGEON )
+ {
+ subdepth += branches[branch].startdepth;
+ branch = branches[branch].parent_branch;
+ }
+ }
+ return subdepth;
}
int subdungeon_depth(unsigned char branch, int depth)
{
- int curr_subdungeon_level = depth + 1;
-
- if (branch >= BRANCH_DIS && branch <= BRANCH_THE_PIT)
- curr_subdungeon_level = depth - 26;
-
- if (branch >= BRANCH_ORCISH_MINES && branch <= BRANCH_SWAMP)
- curr_subdungeon_level = depth
- - you.branch_stairs[branch - 10];
+ return depth - absdungeon_depth(branch, 0);
+}
- return curr_subdungeon_level;
+int player_branch_depth()
+{
+ return subdungeon_depth(you.where_are_you, you.your_level);
}
////////////////////////////////////////////////////////////////////////////
diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h
index 0b543df2a0..fd9e7d34de 100644
--- a/crawl-ref/source/misc.h
+++ b/crawl-ref/source/misc.h
@@ -177,6 +177,9 @@ std::string prep_branch_level_name();
// depth.
int subdungeon_depth(unsigned char branch, int depth);
+// Get displayable depth in the current branch.
+int player_branch_depth();
+
// Get absolute depth given the displayable depth in the branch.
int absdungeon_depth(unsigned char branch, int subdepth);
//////////////////////////////////////////////////////////////////////
diff --git a/crawl-ref/source/mon-pick.cc b/crawl-ref/source/mon-pick.cc
index d660cb6ef3..74455c17a1 100644
--- a/crawl-ref/source/mon-pick.cc
+++ b/crawl-ref/source/mon-pick.cc
@@ -15,180 +15,35 @@
#include "mon-pick.h"
#include "externs.h"
-
-static int mons_cocytus_level(int mcls);
-static int mons_cocytus_rare(int mcls);
-static int mons_crypt_level(int mcls);
-static int mons_crypt_rare(int mcls);
-static int mons_dis_level(int mcls);
-static int mons_dis_rare(int mcls);
-static int mons_gehenna_level(int mcls);
-static int mons_gehenna_rare(int mcls);
-static int mons_hallblade_level(int mcls);
-static int mons_hallblade_rare(int mcls);
-static int mons_hallelf_level(int mcls);
-static int mons_hallelf_rare(int mcls);
-static int mons_hallzot_level(int mcls);
-static int mons_hallzot_rare(int mcls);
-static int mons_hive_level(int mcls);
-static int mons_hive_rare(int mcls);
-static int mons_lair_level(int mcls);
-static int mons_lair_rare(int mcls);
-static int mons_mineorc_level(int mcls);
-static int mons_mineorc_rare(int mcls);
-static int mons_pitslime_level(int mcls);
-static int mons_pitslime_rare(int mcls);
-static int mons_pitsnake_level(int mcls);
-static int mons_pitsnake_rare(int mcls);
-static int mons_standard_level(int mcls);
-static int mons_standard_rare(int mcls);
-static int mons_swamp_level(int mcls);
-static int mons_swamp_rare(int mcls);
-static int mons_tartarus_level(int mcls);
-static int mons_tartarus_rare(int mcls);
-static int mons_tomb_level(int mcls);
-static int mons_tomb_rare(int mcls);
-static int mons_caverns_level(int mcls);
-static int mons_caverns_rare(int mcls);
-
-/* ******************* BEGIN EXTERNAL FUNCTIONS ******************* */
-int branch_depth(int branch)
-{
- switch (branch)
- {
- case STAIRS_LAIR:
- return 10;
-
- case STAIRS_VAULTS:
- return 8;
-
- case STAIRS_ELVEN_HALLS:
- return 7;
-
- case STAIRS_SLIME_PITS:
- return 6;
-
- case STAIRS_CRYPT:
- case STAIRS_HALL_OF_ZOT:
- case STAIRS_SNAKE_PIT:
- case STAIRS_SWAMP:
- return 5;
-
- case STAIRS_HIVE:
- case STAIRS_ORCISH_MINES:
- return 4;
-
- case STAIRS_TOMB:
- return 3;
-
- case STAIRS_ECUMENICAL_TEMPLE:
- case STAIRS_HALL_OF_BLADES:
- return 1;
-
- default:
- return 0;
- }
-} // end branch_depth()
-
-int branch_stair(int branch)
-{
- switch (branch)
- {
- case BRANCH_ORCISH_MINES: return STAIRS_ORCISH_MINES;
- case BRANCH_HIVE: return STAIRS_HIVE;
- case BRANCH_LAIR: return STAIRS_LAIR;
- case BRANCH_SLIME_PITS: return STAIRS_SLIME_PITS;
- case BRANCH_VAULTS: return STAIRS_VAULTS;
- case BRANCH_CRYPT: return STAIRS_CRYPT;
- case BRANCH_HALL_OF_BLADES: return STAIRS_HALL_OF_BLADES;
- case BRANCH_HALL_OF_ZOT: return STAIRS_HALL_OF_ZOT;
- case BRANCH_ECUMENICAL_TEMPLE: return STAIRS_ECUMENICAL_TEMPLE;
- case BRANCH_SNAKE_PIT: return STAIRS_SNAKE_PIT;
- case BRANCH_ELVEN_HALLS: return STAIRS_ELVEN_HALLS;
- case BRANCH_TOMB: return STAIRS_TOMB;
- case BRANCH_SWAMP: return STAIRS_SWAMP;
- default:
- return -1;
- }
-}
+#include "branch.h"
+#include "misc.h"
// NB - When adding new branches or levels above 50, you must
// change pre-game deletion routine in new_game in newgame.cc
-
int mons_level(int mcls)
{
int monster_level = 0;
- int (*fnc_level) (int) = 0;
if (you.level_type == LEVEL_ABYSS)
monster_level = ((mons_abyss(mcls)) ? 51 : 0);
else if (you.level_type == LEVEL_PANDEMONIUM)
monster_level = ((mons_pan(mcls)) ? 52 : 0);
else
- {
- fnc_level =
- ((you.where_are_you == BRANCH_DIS) ? mons_dis_level :
- (you.where_are_you == BRANCH_GEHENNA) ? mons_gehenna_level :
- (you.where_are_you == BRANCH_COCYTUS) ? mons_cocytus_level :
- (you.where_are_you == BRANCH_TARTARUS) ? mons_tartarus_level :
- (you.where_are_you == BRANCH_ORCISH_MINES) ? mons_mineorc_level :
- (you.where_are_you == BRANCH_HIVE) ? mons_hive_level :
- (you.where_are_you == BRANCH_LAIR) ? mons_lair_level :
- (you.where_are_you == BRANCH_SLIME_PITS) ? mons_pitslime_level :
- (you.where_are_you == BRANCH_CRYPT) ? mons_crypt_level :
- (you.where_are_you == BRANCH_HALL_OF_BLADES)?mons_hallblade_level :
- (you.where_are_you == BRANCH_HALL_OF_ZOT) ? mons_hallzot_level :
- (you.where_are_you == BRANCH_SNAKE_PIT) ? mons_pitsnake_level :
- (you.where_are_you == BRANCH_ELVEN_HALLS) ? mons_hallelf_level :
- (you.where_are_you == BRANCH_TOMB) ? mons_tomb_level :
- (you.where_are_you == BRANCH_SWAMP) ? mons_swamp_level :
- (you.where_are_you == BRANCH_VAULTS) ? mons_standard_level :
- (you.where_are_you == BRANCH_CAVERNS) ? mons_caverns_level
- : mons_standard_level);
-
- monster_level = fnc_level(mcls);
- }
+ monster_level = branches[you.where_are_you].mons_level_function(mcls);
- return (monster_level);
-} // end mons_level()
+ return monster_level;
+}
// higher values returned means the monster is "more common"
// a return value of zero means the monster will never appear {dlb}
int mons_rarity(int mcls)
{
- int monster_rarity = 0;
- int (*fnc_rarity) (int) = 0;
-
// now, what about pandemonium ??? {dlb}
if (you.level_type == LEVEL_ABYSS)
return mons_rare_abyss(mcls);
else
- {
- fnc_rarity =
- ((you.where_are_you == BRANCH_DIS) ? mons_dis_rare :
- (you.where_are_you == BRANCH_GEHENNA) ? mons_gehenna_rare :
- (you.where_are_you == BRANCH_COCYTUS) ? mons_cocytus_rare :
- (you.where_are_you == BRANCH_TARTARUS) ? mons_tartarus_rare :
- (you.where_are_you == BRANCH_ORCISH_MINES) ? mons_mineorc_rare :
- (you.where_are_you == BRANCH_HIVE) ? mons_hive_rare :
- (you.where_are_you == BRANCH_LAIR) ? mons_lair_rare :
- (you.where_are_you == BRANCH_SLIME_PITS) ? mons_pitslime_rare :
- (you.where_are_you == BRANCH_CRYPT) ? mons_crypt_rare :
- (you.where_are_you == BRANCH_HALL_OF_BLADES)?mons_hallblade_rare :
- (you.where_are_you == BRANCH_HALL_OF_ZOT) ? mons_hallzot_rare :
- (you.where_are_you == BRANCH_SNAKE_PIT) ? mons_pitsnake_rare :
- (you.where_are_you == BRANCH_ELVEN_HALLS) ? mons_hallelf_rare :
- (you.where_are_you == BRANCH_TOMB) ? mons_tomb_rare :
- (you.where_are_you == BRANCH_SWAMP) ? mons_swamp_rare :
- (you.where_are_you == BRANCH_VAULTS) ? mons_standard_rare :
- (you.where_are_you == BRANCH_CAVERNS) ? mons_caverns_rare
- : mons_standard_rare);
-
- monster_rarity = fnc_rarity(mcls);
- }
-
- return (monster_rarity);
-} // end mons_rarity()
+ return branches[you.where_are_you].mons_rarity_function(mcls);
+}
bool mons_abyss(int mcls)
{
@@ -559,7 +414,7 @@ bool mons_pan(int mcls)
/* ******************** END EXTERNAL FUNCTIONS ******************** */
-static int mons_dis_level(int mcls)
+int mons_dis_level(int mcls)
{
int mlev = 26;
@@ -632,7 +487,7 @@ static int mons_dis_level(int mcls)
return (mlev);
} // end mons_dis_level()
-static int mons_dis_rare(int mcls)
+int mons_dis_rare(int mcls)
{
switch (mcls)
{
@@ -719,7 +574,7 @@ static int mons_dis_rare(int mcls)
}
} // end mons_dis_rare()
-static int mons_gehenna_level(int mcls)
+int mons_gehenna_level(int mcls)
{
int mlev = 26;
@@ -785,7 +640,7 @@ static int mons_gehenna_level(int mcls)
return (mlev);
} // end mons_gehenna_level()
-static int mons_gehenna_rare(int mcls)
+int mons_gehenna_rare(int mcls)
{
switch (mcls)
{
@@ -872,7 +727,7 @@ static int mons_gehenna_rare(int mcls)
}
} // end mons_gehenna_rare()
-static int mons_cocytus_level(int mcls)
+int mons_cocytus_level(int mcls)
{
int mlev = 26;
@@ -933,7 +788,7 @@ static int mons_cocytus_level(int mcls)
return (mlev);
} // end mons_cocytus_level()
-static int mons_cocytus_rare(int mcls)
+int mons_cocytus_rare(int mcls)
{
switch (mcls)
{
@@ -1008,7 +863,7 @@ static int mons_cocytus_rare(int mcls)
}
} // end mons_cocytus_rare()
-static int mons_tartarus_level(int mcls)
+int mons_tartarus_level(int mcls)
{
int mlev = 26;
@@ -1077,7 +932,7 @@ static int mons_tartarus_level(int mcls)
return (mlev);
} // end mons_tartarus_level()
-static int mons_tartarus_rare(int mcls)
+int mons_tartarus_rare(int mcls)
{
switch (mcls)
{
@@ -1175,9 +1030,9 @@ static int mons_tartarus_rare(int mcls)
}
}
-static int mons_mineorc_level(int mcls)
+int mons_mineorc_level(int mcls)
{
- int mlev = you.branch_stairs[STAIRS_ORCISH_MINES] + 1;
+ int mlev = absdungeon_depth(BRANCH_ORCISH_MINES, 1);
switch (mcls)
{
@@ -1219,7 +1074,7 @@ static int mons_mineorc_level(int mcls)
return (mlev);
} // end mons_mineorc_level()
-static int mons_mineorc_rare(int mcls)
+int mons_mineorc_rare(int mcls)
{
switch (mcls)
{
@@ -1268,9 +1123,9 @@ static int mons_mineorc_rare(int mcls)
}
} // end mons_mineorc_rare()
-static int mons_hive_level(int mcls)
+int mons_hive_level(int mcls)
{
- int mlev = you.branch_stairs[STAIRS_HIVE] + 1;
+ int mlev = absdungeon_depth(BRANCH_HIVE, 1);
switch (mcls)
{
@@ -1290,7 +1145,7 @@ static int mons_hive_level(int mcls)
return (mlev);
} // end mons_hive_level()
-static int mons_hive_rare(int mcls)
+int mons_hive_rare(int mcls)
{
switch (mcls)
{
@@ -1308,9 +1163,9 @@ static int mons_hive_rare(int mcls)
}
} // end mons_hive_rare()
-static int mons_lair_level(int mcls)
+int mons_lair_level(int mcls)
{
- int mlev = you.branch_stairs[STAIRS_LAIR] + 1;
+ int mlev = absdungeon_depth(BRANCH_LAIR, 1);
switch (mcls)
{
@@ -1410,7 +1265,7 @@ static int mons_lair_level(int mcls)
return (mlev);
} // end mons_lair_level()
-static int mons_lair_rare(int mcls)
+int mons_lair_rare(int mcls)
{
switch (mcls)
{
@@ -1530,9 +1385,9 @@ static int mons_lair_rare(int mcls)
}
} // end mons_lair_rare()
-static int mons_pitslime_level(int mcls)
+int mons_pitslime_level(int mcls)
{
- int mlev = you.branch_stairs[STAIRS_SLIME_PITS] + 1;
+ int mlev = absdungeon_depth(BRANCH_SLIME_PITS, 1);
switch (mcls)
@@ -1577,7 +1432,7 @@ static int mons_pitslime_level(int mcls)
return (mlev);
} // end mons_pitslime_level()
-static int mons_pitslime_rare(int mcls)
+int mons_pitslime_rare(int mcls)
{
switch (mcls)
{
@@ -1619,9 +1474,9 @@ static int mons_pitslime_rare(int mcls)
}
} // end mons_pitslime_rare()
-static int mons_crypt_level(int mcls)
+int mons_crypt_level(int mcls)
{
- int mlev = you.branch_stairs[STAIRS_CRYPT] + 1;
+ int mlev = absdungeon_depth(BRANCH_CRYPT, 1);
switch (mcls)
{
@@ -1681,7 +1536,7 @@ static int mons_crypt_level(int mcls)
return (mlev);
} // end mons_crypt_level()
-static int mons_crypt_rare(int mcls)
+int mons_crypt_rare(int mcls)
{
switch (mcls)
{
@@ -1761,9 +1616,9 @@ static int mons_crypt_rare(int mcls)
}
} // end mons_crypt_rare()
-static int mons_pitsnake_level(int mcls)
+int mons_pitsnake_level(int mcls)
{
- int mlev = you.branch_stairs[STAIRS_SNAKE_PIT] + 1;
+ int mlev = absdungeon_depth(BRANCH_SNAKE_PIT, 1);
switch (mcls)
{
@@ -1800,7 +1655,7 @@ static int mons_pitsnake_level(int mcls)
return (mlev);
} // end mons_pitsnake_level()
-static int mons_pitsnake_rare(int mcls)
+int mons_pitsnake_rare(int mcls)
{
switch (mcls)
{
@@ -1832,9 +1687,9 @@ static int mons_pitsnake_rare(int mcls)
}
} // end mons_pitsnake_rare()
-static int mons_hallelf_level(int mcls)
+int mons_hallelf_level(int mcls)
{
- int mlev = you.branch_stairs[STAIRS_ELVEN_HALLS] + 1;
+ int mlev = absdungeon_depth(BRANCH_ELVEN_HALLS, 1);
switch (mcls)
{
@@ -1886,7 +1741,7 @@ static int mons_hallelf_level(int mcls)
return (mlev);
} // end mons_hallelf_level()
-static int mons_hallelf_rare(int mcls)
+int mons_hallelf_rare(int mcls)
{
switch (mcls)
{
@@ -1943,9 +1798,9 @@ static int mons_hallelf_rare(int mcls)
}
} // end mons_hallelf_rare()
-static int mons_tomb_level(int mcls)
+int mons_tomb_level(int mcls)
{
- int mlev = you.branch_stairs[STAIRS_CRYPT] + 1;
+ int mlev = absdungeon_depth(BRANCH_TOMB, 1);
switch (mcls)
{
@@ -1980,7 +1835,7 @@ static int mons_tomb_level(int mcls)
return (mlev);
} // end mons_tomb_level()
-static int mons_tomb_rare(int mcls)
+int mons_tomb_rare(int mcls)
{
switch (mcls)
{
@@ -2019,9 +1874,9 @@ static int mons_tomb_rare(int mcls)
}
} // end mons_tomb_rare()
-static int mons_swamp_level(int mcls)
+int mons_swamp_level(int mcls)
{
- int mlev = you.branch_stairs[STAIRS_SWAMP] + 1;
+ int mlev = absdungeon_depth(BRANCH_SWAMP, 1);
switch (mcls)
{
@@ -2079,7 +1934,7 @@ static int mons_swamp_level(int mcls)
return (mlev);
} // end mons_swamp_level()
-static int mons_swamp_rare(int mcls)
+int mons_swamp_rare(int mcls)
{
switch (mcls)
{
@@ -2165,15 +2020,15 @@ static int mons_swamp_rare(int mcls)
}
} // end mons_swamp_rare()
-static int mons_hallblade_level(int mcls)
+int mons_hallblade_level(int mcls)
{
if (mcls == MONS_DANCING_WEAPON)
- return (you.branch_stairs[STAIRS_HALL_OF_BLADES] + 1);
+ return absdungeon_depth(BRANCH_HALL_OF_BLADES, 1);
else
return 0;
} // end mons_hallblade_level
-static int mons_hallblade_rare(int mcls)
+int mons_hallblade_rare(int mcls)
{
return ((mcls == MONS_DANCING_WEAPON) ? 1000 : 0);
} // end mons_hallblade_rare()
@@ -2187,9 +2042,9 @@ static int mons_hallblade_rare(int mcls)
// - ouch ouch.cc (death message)
// - and here...
-static int mons_hallzot_level(int mcls)
+int mons_hallzot_level(int mcls)
{
- int mlev = you.branch_stairs[STAIRS_HALL_OF_ZOT];
+ int mlev = absdungeon_depth(BRANCH_HALL_OF_ZOT, 0);
switch (mcls)
{
@@ -2242,7 +2097,7 @@ static int mons_hallzot_level(int mcls)
return (mlev);
} // end mons_hallzot_level()
-static int mons_hallzot_rare(int mcls)
+int mons_hallzot_rare(int mcls)
{
switch (mcls)
{
@@ -2293,10 +2148,10 @@ static int mons_hallzot_rare(int mcls)
}
} // end mons_hallzot_rare()
-static int mons_caverns_level( int mcls )
+int mons_caverns_level( int mcls )
{
- int mlev = you.branch_stairs[STAIRS_CAVERNS] + 1;
+ int mlev = absdungeon_depth(BRANCH_CAVERNS, 1);
switch (mcls)
{
@@ -2329,7 +2184,7 @@ static int mons_caverns_level( int mcls )
return (mlev);
}
-static int mons_caverns_rare( int mcls )
+int mons_caverns_rare( int mcls )
{
switch (mcls)
{
@@ -2355,7 +2210,7 @@ static int mons_caverns_rare( int mcls )
}
}
-static int mons_standard_level(int mcls)
+int mons_standard_level(int mcls)
{
switch (mcls)
{
@@ -2604,7 +2459,7 @@ static int mons_standard_level(int mcls)
}
} // end mons_standard_level()
-static int mons_standard_rare(int mcls)
+int mons_standard_rare(int mcls)
{
switch (mcls)
{
diff --git a/crawl-ref/source/mon-pick.h b/crawl-ref/source/mon-pick.h
index 880efa2550..47d047f0cd 100644
--- a/crawl-ref/source/mon-pick.h
+++ b/crawl-ref/source/mon-pick.h
@@ -47,8 +47,39 @@ int mons_rare_abyss(int mcls);
* *********************************************************************** */
bool mons_pan(int mcls);
-// [ds] Why in the name of all that's holy are these in mon-pick.cc?
-int branch_depth(int branch);
-int branch_stair(int branch);
+int mons_cocytus_level(int mcls);
+int mons_cocytus_rare(int mcls);
+int mons_crypt_level(int mcls);
+int mons_crypt_rare(int mcls);
+int mons_dis_level(int mcls);
+int mons_dis_rare(int mcls);
+int mons_gehenna_level(int mcls);
+int mons_gehenna_rare(int mcls);
+int mons_hallblade_level(int mcls);
+int mons_hallblade_rare(int mcls);
+int mons_hallelf_level(int mcls);
+int mons_hallelf_rare(int mcls);
+int mons_hallzot_level(int mcls);
+int mons_hallzot_rare(int mcls);
+int mons_hive_level(int mcls);
+int mons_hive_rare(int mcls);
+int mons_lair_level(int mcls);
+int mons_lair_rare(int mcls);
+int mons_mineorc_level(int mcls);
+int mons_mineorc_rare(int mcls);
+int mons_pitslime_level(int mcls);
+int mons_pitslime_rare(int mcls);
+int mons_pitsnake_level(int mcls);
+int mons_pitsnake_rare(int mcls);
+int mons_standard_level(int mcls);
+int mons_standard_rare(int mcls);
+int mons_swamp_level(int mcls);
+int mons_swamp_rare(int mcls);
+int mons_tartarus_level(int mcls);
+int mons_tartarus_rare(int mcls);
+int mons_tomb_level(int mcls);
+int mons_tomb_rare(int mcls);
+int mons_caverns_level(int mcls);
+int mons_caverns_rare(int mcls);
#endif
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index 21cabb3540..516899dc95 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -70,6 +70,7 @@
#include "externs.h"
#include "abl-show.h"
+#include "branch.h"
#include "dungeon.h"
#include "files.h"
#include "fight.h"
@@ -344,6 +345,23 @@ static unsigned char random_potion_description()
return (unsigned char) desc;
}
+// Determine starting depths of branches
+static void initialise_branch_depths()
+{
+ branches[BRANCH_ECUMENICAL_TEMPLE].startdepth = 3 + random2(4);
+ branches[BRANCH_ORCISH_MINES].startdepth = 5 + random2(6);
+ branches[BRANCH_ELVEN_HALLS].startdepth = coinflip() ? 4 : 3;
+ branches[BRANCH_LAIR].startdepth = 7 + random2(6);
+ branches[BRANCH_HIVE].startdepth = 10 + random2(6);
+ branches[BRANCH_SLIME_PITS].startdepth = 3 + random2(4);
+ branches[BRANCH_SWAMP].startdepth = 2 + random2(6);
+ branches[BRANCH_SNAKE_PIT].startdepth = coinflip() ? 7 : 6;
+ branches[BRANCH_VAULTS].startdepth = 13 + random2(6);
+ branches[BRANCH_CRYPT].startdepth = 2 + random2(3);
+ branches[BRANCH_HALL_OF_BLADES].startdepth = 4;
+ branches[BRANCH_TOMB].startdepth = coinflip() ? 3 : 2;
+}
+
bool new_game(void)
{
int i, j; // loop variables {dlb}
@@ -774,52 +792,14 @@ bool new_game(void)
// tmpfile purging removed in favour of marking
for (int lvl = 0; lvl < MAX_LEVELS; lvl++)
{
- for (int dng = 0; dng < MAX_BRANCHES; dng++)
+ for (int dng = 0; dng < NUM_BRANCHES; dng++)
{
tmp_file_pairs[lvl][dng] = false;
}
}
give_basic_mutations(you.species);
-
- // places staircases to the branch levels:
- for (i = 0; i < 30; i++)
- {
- you.branch_stairs[i] = 100;
- }
-
- you.branch_stairs[STAIRS_ECUMENICAL_TEMPLE] = 3 + random2(4); // avg: 4.5
-
- you.branch_stairs[STAIRS_ORCISH_MINES] = 5 + random2(6); // avg: 7.5
-
- you.branch_stairs[STAIRS_ELVEN_HALLS] =
- you.branch_stairs[STAIRS_ORCISH_MINES] + (coinflip() ? 4 : 3); // 11.0
-
- you.branch_stairs[STAIRS_LAIR] = 7 + random2(6); // avg: 9.5
-
- you.branch_stairs[STAIRS_HIVE] = 10 + random2(6); // avg: 12.5
-
- you.branch_stairs[STAIRS_SLIME_PITS] =
- you.branch_stairs[STAIRS_LAIR] + 3 + random2(4); // avg: 14.0
-
- you.branch_stairs[STAIRS_SWAMP] =
- you.branch_stairs[STAIRS_LAIR] + 2 + random2(6); // avg: 14.0
-
- you.branch_stairs[STAIRS_SNAKE_PIT] =
- you.branch_stairs[STAIRS_LAIR] + (coinflip() ? 7 : 6); // avg: 16.0
-
- you.branch_stairs[STAIRS_VAULTS] = 13 + random2(6); // avg: 15.5
-
- you.branch_stairs[STAIRS_CRYPT] =
- you.branch_stairs[STAIRS_VAULTS] + 2 + random2(3); // avg: 18.5
-
- you.branch_stairs[STAIRS_HALL_OF_BLADES] =
- you.branch_stairs[STAIRS_VAULTS] + 4; // avg: 19.5
-
- you.branch_stairs[STAIRS_TOMB] =
- you.branch_stairs[STAIRS_CRYPT] + ((coinflip()) ? 3 : 2); // avg: 20.0
-
- you.branch_stairs[STAIRS_HALL_OF_ZOT] = 26; // always 26
+ initialise_branch_depths();
save_newgame_options();
return (true);
diff --git a/crawl-ref/source/notes.cc b/crawl-ref/source/notes.cc
index 9f645fa807..a7c16bfe6c 100644
--- a/crawl-ref/source/notes.cc
+++ b/crawl-ref/source/notes.cc
@@ -7,6 +7,7 @@
#include "AppHdr.h"
#include "notes.h"
+#include "branch.h"
#include "files.h"
#include "Kills.h"
#include "message.h"
@@ -58,24 +59,9 @@ static bool is_noteworthy_hp( int hp, int maxhp ) {
}
static int dungeon_branch_depth( unsigned char branch ) {
- if ( branch > BRANCH_CAVERNS ) // last branch
- return -1;
- switch ( branch ) {
- case BRANCH_MAIN_DUNGEON:
- return 27;
- case BRANCH_DIS:
- case BRANCH_GEHENNA:
- case BRANCH_COCYTUS:
- case BRANCH_TARTARUS:
- return 7;
- case BRANCH_VESTIBULE_OF_HELL:
- return 1;
- case BRANCH_INFERNO:
- case BRANCH_THE_PIT:
- return -1;
- default:
- return branch_depth( branch - 10 );
- }
+ if ( branch >= NUM_BRANCHES )
+ return -1;
+ return branches[branch].depth;
}
static bool is_noteworthy_dlevel( unsigned short place ) {
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index a4e0360e24..80a4b63cd6 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -844,7 +844,7 @@ void end_game( struct scorefile_entry &se )
// clean all levels that we think we have ever visited
for (int level = 0; level < MAX_LEVELS; level++)
{
- for (int dungeon = 0; dungeon < MAX_BRANCHES; dungeon++)
+ for (int dungeon = 0; dungeon < NUM_BRANCHES; dungeon++)
{
if (tmp_file_pairs[level][dungeon])
{
diff --git a/crawl-ref/source/overmap.cc b/crawl-ref/source/overmap.cc
index ab61669d1c..8252d33580 100644
--- a/crawl-ref/source/overmap.cc
+++ b/crawl-ref/source/overmap.cc
@@ -25,6 +25,7 @@
#include "externs.h"
+#include "branch.h"
#include "direct.h"
// for #definitions of MAX_BRANCHES & MAX_LEVELS
#include "files.h"
@@ -210,27 +211,13 @@ std::string overview_description_string()
std::string disp;
bool seen_anything = false;
- // better put this somewhere central
- const branch_type list_order[] =
- {
- BRANCH_MAIN_DUNGEON,
- BRANCH_ECUMENICAL_TEMPLE,
- BRANCH_ORCISH_MINES, BRANCH_ELVEN_HALLS,
- BRANCH_LAIR, BRANCH_SWAMP, BRANCH_SLIME_PITS, BRANCH_SNAKE_PIT,
- BRANCH_HIVE,
- BRANCH_VAULTS, BRANCH_HALL_OF_BLADES, BRANCH_CRYPT, BRANCH_TOMB,
- BRANCH_VESTIBULE_OF_HELL,
- BRANCH_DIS, BRANCH_GEHENNA, BRANCH_COCYTUS, BRANCH_TARTARUS,
- BRANCH_HALL_OF_ZOT
- };
-
disp += " <white>Overview of the Dungeon</white>\n" ;
// print branches
int branchcount = 0;
- for (unsigned int i = 1; i < sizeof(list_order)/sizeof(branch_type); ++i)
+ for (int i = 0; i < NUM_BRANCHES; ++i)
{
- const branch_type branch = list_order[i];
+ const branch_type branch = branches[i].id;
if ( stair_level.find(branch) != stair_level.end() )
{
if ( !branchcount )
@@ -242,7 +229,7 @@ std::string overview_description_string()
++branchcount;
snprintf(buffer, sizeof buffer, "<yellow>%-6s</yellow>: %-7s",
- branch_name(branch, true).c_str(),
+ branches[branch].abbrevname,
stair_level[branch].describe(false, true).c_str());
disp += buffer;
if ( (branchcount % 4) == 0 )
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 26581cf9e8..67caf85995 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -23,6 +23,7 @@
#include "abyss.h"
#include "beam.h"
+#include "branch.h"
#include "cloud.h"
#include "direct.h"
#include "debug.h"
@@ -564,8 +565,7 @@ bool allow_control_teleport( bool silent )
case BRANCH_ELVEN_HALLS:
// Cannot raid the elven halls vaults until fountain drained
- if (you.branch_stairs[STAIRS_ELVEN_HALLS] +
- branch_depth(STAIRS_ELVEN_HALLS) == you.your_level)
+ if (player_branch_depth() == branches[BRANCH_ELVEN_HALLS].depth)
{
for (int x = 5; x < GXM - 5; x++)
{
@@ -580,8 +580,7 @@ bool allow_control_teleport( bool silent )
case BRANCH_HALL_OF_ZOT:
// Cannot control teleport until the Orb is picked up
- if (you.branch_stairs[STAIRS_HALL_OF_ZOT] +
- branch_depth(STAIRS_HALL_OF_ZOT) == you.your_level
+ if (player_branch_depth() == branches[BRANCH_HALL_OF_ZOT].depth
&& you.char_direction != DIR_ASCENDING)
{
ret = false;
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index 834bef02dd..e2d1f13b55 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -68,6 +68,7 @@
#include "AppHdr.h"
#include "abl-show.h"
+#include "branch.h"
#include "enum.h"
#include "externs.h"
#include "files.h"
@@ -92,7 +93,7 @@ extern std::map<level_pos, god_type> altars_present;
extern std::map<level_pos, portal_type> portals_present;
// temp file pairs used for file level cleanup
-FixedArray < bool, MAX_LEVELS, MAX_BRANCHES > tmp_file_pairs;
+FixedArray < bool, MAX_LEVELS, NUM_BRANCHES > tmp_file_pairs;
// static helpers
static void tag_construct_you(struct tagHeader &th);
@@ -871,13 +872,13 @@ static void tag_construct_you_dungeon(struct tagHeader &th)
marshallByte(th,you.unique_creatures[j]); /* unique beasties */
// how many branches?
- marshallByte(th, MAX_BRANCHES);
- for (j = 0; j < 30; ++j)
- marshallByte(th,you.branch_stairs[j]);
+ marshallByte(th, NUM_BRANCHES);
+ for (j = 0; j < NUM_BRANCHES; ++j)
+ marshallLong(th, branches[j].startdepth);
marshallShort(th, MAX_LEVELS);
for (i = 0; i < MAX_LEVELS; ++i)
- for (j = 0; j < MAX_BRANCHES; ++j)
+ for (j = 0; j < NUM_BRANCHES; ++j)
marshallBoolean(th, tmp_file_pairs[i][j]);
marshallMap(th, stair_level,
@@ -1164,12 +1165,18 @@ static void tag_read_you_dungeon(struct tagHeader &th)
// how many branches?
count_c = unmarshallByte(th);
for (j = 0; j < count_c; ++j)
- you.branch_stairs[j] = unmarshallByte(th);
+ branches[j].startdepth = unmarshallLong(th);
+
+ cprintf("found %d branches\n", (int)count_c);
count_s = unmarshallShort(th);
+ cprintf("found %d maxlevel\n", (int)count_s);
for (i = 0; i < count_s; ++i)
+ {
+// cprintf("i = %d\n", i);
for (j = 0; j < count_c; ++j)
tmp_file_pairs[i][j] = unmarshallBoolean(th);
+ }
unmarshallMap(th, stair_level,
unmarshall_long_as<branch_type>, unmarshall_level_id);
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 92687f4d7d..6045729661 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -12,6 +12,7 @@
#include "AppHdr.h"
#include "files.h"
#include "FixAry.h"
+#include "branch.h"
#include "clua.h"
#include "delay.h"
#include "describe.h"
@@ -20,6 +21,7 @@
#include "items.h"
#include "misc.h"
#include "mon-util.h"
+#include "overmap.h"
#include "player.h"
#include "stash.h"
#include "stuff.h"
@@ -1372,43 +1374,13 @@ void find_travel_pos(int youx, int youy,
}
}
-// Mappings of which branches spring from which other branches, essential to
-// walk backwards up the tree.
-static int branch_backout[][2] =
-{
- { BRANCH_SWAMP, BRANCH_LAIR },
- { BRANCH_SLIME_PITS, BRANCH_LAIR },
- { BRANCH_SNAKE_PIT, BRANCH_LAIR },
-
- { BRANCH_HALL_OF_BLADES, BRANCH_VAULTS },
- { BRANCH_CRYPT, BRANCH_VAULTS },
-
- { BRANCH_TOMB, BRANCH_CRYPT },
-
- { BRANCH_ELVEN_HALLS, BRANCH_ORCISH_MINES },
-
- { BRANCH_ORCISH_MINES, BRANCH_MAIN_DUNGEON },
- { BRANCH_HIVE, BRANCH_MAIN_DUNGEON },
- { BRANCH_LAIR, BRANCH_MAIN_DUNGEON },
- { BRANCH_VAULTS, BRANCH_MAIN_DUNGEON },
- { BRANCH_HALL_OF_ZOT, BRANCH_MAIN_DUNGEON },
- { BRANCH_ECUMENICAL_TEMPLE, BRANCH_MAIN_DUNGEON },
-};
-
/*
* Given a branch id, returns the parent branch. If the branch id is not found,
* returns BRANCH_MAIN_DUNGEON.
*/
int find_parent_branch(int br)
{
- for (unsigned i = 0;
- i < sizeof(branch_backout) / sizeof(branch_backout[0]);
- i++)
- {
- if (branch_backout[i][0] == br)
- return branch_backout[i][1];
- }
- return 0;
+ return branches[br].parent_branch;
}
extern std::map<branch_type, level_id> stair_level;
@@ -1421,11 +1393,13 @@ void find_parent_branch(int br, int depth,
{
*pb = 0;
*pd = 0; // Check depth before using *pb.
- return ;
}
-
- *pb = find_parent_branch(stair_level[bran].branch);
- *pd = stair_level[bran].depth;
+ else
+ {
+ // XXX XXX FIXME Just read this from our data...
+ *pb = find_parent_branch(stair_level[bran].branch);
+ *pd = stair_level[bran].depth;
+ }
}
// Appends the passed in branch/depth to the given vector, then attempts to
@@ -1542,96 +1516,25 @@ int level_distance(level_id first, level_id second)
return distance;
}
-static struct
-{
- const char *branch_name, *full_name;
- char hotkey;
-} branches [] =
-{
- { "Dungeon", "the Main Dungeon", 'D' },
- { "Dis", "Dis", 'I' },
- { "Gehenna", "Gehenna", 'N' },
- { "Hell", "Hell", 'U' },
- { "Cocytus", "Cocytus", 'X' },
- { "Tartarus", "Tartarus", 'Y' },
- { "Inferno", "", 'R' },
- { "The Pit", "", '0' },
- { "------------", "", '-' },
- { "------------", "", '-' },
- { "Orcish Mines", "the Orcish Mines", 'O' },
- { "Hive", "the Hive", 'H' },
- { "Lair", "the Lair", 'L' },
- { "Slime Pits", "the Slime Pits", 'M' },
- { "Vaults", "the Vaults", 'V' },
- { "Crypt", "the Crypt", 'C' },
- { "Hall of Blades", "the Hall of Blades", 'B' },
- { "Zot", "the Realm of Zot", 'Z' },
- { "Temple", "the Ecumenical Temple", 'T' },
- { "Snake Pit", "the Snake Pit", 'P' },
- { "Elven Halls", "the Elven Halls", 'E' },
- { "Tomb", "the Tomb", 'G' },
- { "Swamp", "the Swamp", 'S' }
-};
-
-static struct
-{
- const char *abbr;
- unsigned char branch;
-} branch_abbrvs[] =
-{
- { "D", BRANCH_MAIN_DUNGEON },
- { "Dis", BRANCH_DIS },
- { "Geh", BRANCH_GEHENNA },
- { "Hell", BRANCH_VESTIBULE_OF_HELL },
- { "Coc", BRANCH_COCYTUS },
- { "Tar", BRANCH_TARTARUS },
- { "inf", BRANCH_INFERNO },
- { "pit", BRANCH_THE_PIT },
- { "Orc", BRANCH_ORCISH_MINES },
- { "Hive", BRANCH_HIVE },
- { "Lair", BRANCH_LAIR },
- { "Slime", BRANCH_SLIME_PITS },
- { "Vault", BRANCH_VAULTS },
- { "Crypt", BRANCH_CRYPT },
- { "Blades", BRANCH_HALL_OF_BLADES },
- { "Zot", BRANCH_HALL_OF_ZOT },
- { "Temple", BRANCH_ECUMENICAL_TEMPLE },
- { "Snake", BRANCH_SNAKE_PIT },
- { "Elf", BRANCH_ELVEN_HALLS },
- { "Tomb", BRANCH_TOMB },
- { "Swamp", BRANCH_SWAMP },
-};
-
void set_trans_travel_dest(char *buffer, int maxlen, const level_pos &target)
{
if (!buffer) return;
- const char *branch = NULL;
- for (unsigned i = 0; i < sizeof(branch_abbrvs) / sizeof(branch_abbrvs[0]);
- ++i)
- {
- if (branch_abbrvs[i].branch == target.id.branch)
- {
- branch = branch_abbrvs[i].abbr;
- break;
- }
- }
+ const int branch_id = target.id.branch;
+ const char *branch = branches[branch_id].abbrevname;
if (!branch) return;
- unsigned char branch_id = target.id.branch;
// Show level+depth information and tack on an @(x,y) if the player
// wants to go to a specific square on the target level. We don't use
// actual coordinates since that will give away level information we
// don't want the player to have.
- if (branch_id != BRANCH_ECUMENICAL_TEMPLE
- && branch_id != BRANCH_HALL_OF_BLADES
- && branch_id != BRANCH_VESTIBULE_OF_HELL)
+ if ( branches[branch_id].depth != 1 )
snprintf(buffer, maxlen, "%s:%d%s", branch, target.id.depth,
- target.pos.x != -1? " @ (x,y)" : "");
+ target.pos.x != -1? " @ (x,y)" : "");
else
snprintf(buffer, maxlen, "%s%s", branch,
- target.pos.x != -1? " @ (x,y)" : "");
+ target.pos.x != -1? " @ (x,y)" : "");
}
// Returns the level on the given branch that's closest to the player's
@@ -1669,7 +1572,7 @@ static char trans_travel_dest[30];
// Returns true if the player character knows of the existence of the given
// branch (which would make the branch a valid target for interlevel travel).
-static bool is_known_branch(unsigned char branch)
+static bool is_known_branch(int branch)
{
// The main dungeon is always known.
if (branch == BRANCH_MAIN_DUNGEON) return true;
@@ -1677,48 +1580,32 @@ static bool is_known_branch(unsigned char branch)
// If we're in the branch, it darn well is known.
if (you.where_are_you == branch) return true;
- // If the overmap knows the stairs to this branch, we know the branch.
- return ( stair_level.find(static_cast<branch_type>(branch)) != stair_level.end() );
-
- // Doing this to check for the reachability of a branch is slow enough to
- // be noticeable.
-
- // Ask interlevel travel if it knows how to go there. If it knows how to
- // get (partway) there, return true.
+ // The Vestibule is special: there are no stairs to it, just
+ // a portal
+ if (branch == BRANCH_VESTIBULE_OF_HELL)
+ {
+ // XXX There must be a better way to do this...
+ std::vector<stash_search_result> tmp;
+ get_matching_features(text_pattern("gateway to Hell"), tmp);
+ return !tmp.empty();
+ }
- // level_pos pos;
- // pos.id.branch = branch;
- // pos.id.depth = 1;
-
- // return find_transtravel_square(pos, false) != 0;
+ // If the overmap knows the stairs to this branch, we know the branch.
+ return ( stair_level.find(static_cast<branch_type>(branch)) !=
+ stair_level.end() );
}
/*
* Returns a list of the branches that the player knows the location of the
* stairs to, in the same order as overmap.cc lists them.
*/
-static std::vector<unsigned char> get_known_branches()
+static std::vector<branch_type> get_known_branches()
{
- // Lifted from overmap.cc. XXX: Move this to a better place?
- const unsigned char list_order[] =
- {
- BRANCH_MAIN_DUNGEON,
- BRANCH_ECUMENICAL_TEMPLE,
- BRANCH_ORCISH_MINES, BRANCH_ELVEN_HALLS,
- BRANCH_LAIR, BRANCH_SWAMP, BRANCH_SLIME_PITS, BRANCH_SNAKE_PIT,
- BRANCH_HIVE,
- BRANCH_VAULTS, BRANCH_HALL_OF_BLADES, BRANCH_CRYPT, BRANCH_TOMB,
- BRANCH_VESTIBULE_OF_HELL,
- BRANCH_DIS, BRANCH_GEHENNA, BRANCH_COCYTUS, BRANCH_TARTARUS,
- BRANCH_HALL_OF_ZOT
- };
+ std::vector<branch_type> result;
- std::vector<unsigned char> result;
- for (unsigned i = 0; i < sizeof list_order / sizeof(*list_order); ++i)
- {
- if (is_known_branch(list_order[i]))
- result.push_back(list_order[i]);
- }
+ for (int i = 0; i < NUM_BRANCHES; ++i)
+ if (is_known_branch(branches[i].id))
+ result.push_back(branches[i].id);
return result;
}
@@ -1726,7 +1613,7 @@ static std::vector<unsigned char> get_known_branches()
static int prompt_travel_branch()
{
unsigned char branch = BRANCH_MAIN_DUNGEON; // Default
- std::vector<unsigned char> br = get_known_branches();
+ std::vector<branch_type> br = get_known_branches();
// Don't kill the prompt even if the only branch we know is the main dungeon
// This keeps things consistent for the player.
@@ -1751,8 +1638,9 @@ static int prompt_travel_branch()
mpr(line.c_str());
line = "";
}
- snprintf(buf, sizeof buf, "(%c) %-14s ", branches[br[i]].hotkey,
- branches[br[i]].branch_name);
+ snprintf(buf, sizeof buf, "(%c) %-14s ",
+ branches[br[i]].travel_shortcut,
+ branches[br[i]].shortname);
line += buf;
}
if (line.length())
@@ -1802,7 +1690,7 @@ static int prompt_travel_branch()
// Is this a branch hotkey?
for (int i = 0, count = br.size(); i < count; ++i)
{
- if (toupper(keyin) == branches[br[i]].hotkey)
+ if (toupper(keyin) == branches[br[i]].travel_shortcut)
return (br[i]);
}
@@ -1815,19 +1703,17 @@ static int prompt_travel_branch()
}
}
-static int prompt_travel_depth(unsigned char branch)
+static int prompt_travel_depth(int branch)
{
// Handle one-level branches by not prompting.
- if (branch == BRANCH_ECUMENICAL_TEMPLE ||
- branch == BRANCH_VESTIBULE_OF_HELL ||
- branch == BRANCH_HALL_OF_BLADES)
+ if ( branches[branch].depth == 1 )
return 1;
char buf[100];
int depth = get_nearest_level_depth(branch);
snprintf(buf, sizeof buf, "What level of %s do you want to go to? "
- "[default %d] ", branches[branch].full_name, depth);
+ "[default %d] ", branches[branch].longname, depth);
mesclr();
mpr(buf, MSGCH_PROMPT);
@@ -2424,9 +2310,25 @@ level_id level_id::current()
level_id level_id::get_next_level_id(const coord_def &pos)
{
- short gridc = grd[pos.x][pos.y];
+ unsigned char gridc = grd[pos.x][pos.y];
level_id id = current();
+ for ( int i = 0; i < NUM_BRANCHES; ++i )
+ {
+ if ( gridc == branches[i].entry_stairs )
+ {
+ id.branch = i;
+ id.depth = 1;
+ break;
+ }
+ if ( gridc == branches[i].exit_stairs )
+ {
+ id.branch = branches[i].parent_branch;
+ id.depth = branches[i].startdepth;
+ break;
+ }
+ }
+
switch (gridc)
{
case DNGN_STONE_STAIRS_DOWN_I: case DNGN_STONE_STAIRS_DOWN_II:
@@ -2437,91 +2339,7 @@ level_id level_id::get_next_level_id(const coord_def &pos)
case DNGN_STONE_STAIRS_UP_III: case DNGN_ROCK_STAIRS_UP:
id.depth--;
break;
- case DNGN_ENTER_HELL:
- id.branch = BRANCH_VESTIBULE_OF_HELL;
- id.depth = 1;
- break;
- case DNGN_ENTER_DIS:
- id.branch = BRANCH_DIS;
- id.depth = 1;
- break;
- case DNGN_ENTER_GEHENNA:
- id.branch = BRANCH_GEHENNA;
- id.depth = 1;
- break;
- case DNGN_ENTER_COCYTUS:
- id.branch = BRANCH_COCYTUS;
- id.depth = 1;
- break;
- case DNGN_ENTER_TARTARUS:
- id.branch = BRANCH_TARTARUS;
- id.depth = 1;
- break;
- case DNGN_ENTER_ORCISH_MINES:
- id.branch = BRANCH_ORCISH_MINES;
- id.depth = 1;
- break;
- case DNGN_ENTER_HIVE:
- id.branch = BRANCH_HIVE;
- id.depth = 1;
- break;
- case DNGN_ENTER_LAIR:
- id.branch = BRANCH_LAIR;
- id.depth = 1;
- break;
- case DNGN_ENTER_SLIME_PITS:
- id.branch = BRANCH_SLIME_PITS;
- id.depth = 1;
- break;
- case DNGN_ENTER_VAULTS:
- id.branch = BRANCH_VAULTS;
- id.depth = 1;
- break;
- case DNGN_ENTER_CRYPT:
- id.branch = BRANCH_CRYPT;
- id.depth = 1;
- break;
- case DNGN_ENTER_HALL_OF_BLADES:
- id.branch = BRANCH_HALL_OF_BLADES;
- id.depth = 1;
- break;
- case DNGN_ENTER_ZOT:
- id.branch = BRANCH_HALL_OF_ZOT;
- id.depth = 1;
- break;
- case DNGN_ENTER_TEMPLE:
- id.branch = BRANCH_ECUMENICAL_TEMPLE;
- id.depth = 1;
- break;
- case DNGN_ENTER_SNAKE_PIT:
- id.branch = BRANCH_SNAKE_PIT;
- id.depth = 1;
- break;
- case DNGN_ENTER_ELVEN_HALLS:
- id.branch = BRANCH_ELVEN_HALLS;
- id.depth = 1;
- break;
- case DNGN_ENTER_TOMB:
- id.branch = BRANCH_TOMB;
- id.depth = 1;
- break;
- case DNGN_ENTER_SWAMP:
- id.branch = BRANCH_SWAMP;
- id.depth = 1;
- break;
- case DNGN_RETURN_FROM_ORCISH_MINES: case DNGN_RETURN_FROM_HIVE:
- case DNGN_RETURN_FROM_LAIR: case DNGN_RETURN_FROM_SLIME_PITS:
- case DNGN_RETURN_FROM_VAULTS: case DNGN_RETURN_FROM_CRYPT:
- case DNGN_RETURN_FROM_HALL_OF_BLADES: case DNGN_RETURN_FROM_ZOT:
- case DNGN_RETURN_FROM_TEMPLE: case DNGN_RETURN_FROM_SNAKE_PIT:
- case DNGN_RETURN_FROM_ELVEN_HALLS: case DNGN_RETURN_FROM_TOMB:
- case DNGN_RETURN_FROM_SWAMP:
- find_parent_branch(id.branch, id.depth, &id.branch, &id.depth);
- if (!id.depth)
- {
- id.branch = find_parent_branch(you.where_are_you);
- id.depth = -1;
- }
+ default:
break;
}
return id;