summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/terrain.cc
diff options
context:
space:
mode:
authorShmuale Mark <shm.mark@gmail.com>2014-07-14 08:41:57 -0400
committerShmuale Mark <shm.mark@gmail.com>2014-07-14 09:23:57 -0400
commit3676b4b6280aff0966867792c2d1b1ffa0647b48 (patch)
tree0bc376e913f13757f51724a26c86e3ba04f4827c /crawl-ref/source/terrain.cc
parent3ee8b5ad95f6fc8d8eaf38521ae25b1fcdf256b4 (diff)
downloadcrawl-ref-3676b4b6280aff0966867792c2d1b1ffa0647b48.tar.gz
crawl-ref-3676b4b6280aff0966867792c2d1b1ffa0647b48.zip
Move more feature name data to feature-data.h.
Diffstat (limited to 'crawl-ref/source/terrain.cc')
-rw-r--r--crawl-ref/source/terrain.cc179
1 files changed, 38 insertions, 141 deletions
diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc
index b8ff2eef2b..ebc0798d40 100644
--- a/crawl-ref/source/terrain.cc
+++ b/crawl-ref/source/terrain.cc
@@ -1503,146 +1503,27 @@ string stair_climb_verb(dungeon_feature_type feat)
return "pass through";
}
-static const char *dngn_feature_names[] =
-{
-"unseen", "closed_door", "runed_door", "sealed_door",
-"tree", "metal_wall", "green_crystal_wall", "rock_wall",
-"slimy_wall", "stone_wall", "permarock_wall",
-"clear_rock_wall", "clear_stone_wall", "clear_permarock_wall", "iron_grate",
-"open_sea", "endless_lava", "orcish_idol",
-"granite_statue", "malign_gateway", "", "", "", "", "", "", "", "", "", "",
-
-// DNGN_MINMOVE
-"lava", "deep_water",
-
-// DNGN_MINWALK
-"shallow_water", "floor", "open_door",
-"trap_mechanical", "trap_teleport", "shaft", "trap_web",
-"undiscovered_trap", "enter_shop", "abandoned_shop",
-
-"stone_stairs_down_i", "stone_stairs_down_ii",
-"stone_stairs_down_iii", "escape_hatch_down", "stone_stairs_up_i",
-"stone_stairs_up_ii", "stone_stairs_up_iii", "escape_hatch_up",
-
-"enter_dis", "enter_gehenna", "enter_cocytus",
-"enter_tartarus", "enter_abyss", "exit_abyss",
-#if TAG_MAJOR_VERSION > 34
-"abyssal_stair",
-#endif
-"stone_arch", "enter_pandemonium", "exit_pandemonium",
-"transit_pandemonium", "exit_dungeon", "exit_through_abyss",
-"exit_hell", "enter_hell", "enter_labyrinth",
-"teleporter",
-#if TAG_MAJOR_VERSION == 34
-"enter_portal_vault", "exit_portal_vault",
-#endif
-"expired_portal",
-
-#if TAG_MAJOR_VERSION == 34
-"enter_dwarven_hall",
-#endif
-"enter_orcish_mines", "enter_lair",
-"enter_slime_pits", "enter_vaults", "enter_crypt",
-#if TAG_MAJOR_VERSION == 34
-"enter_hall_of_blades",
-#endif
-"enter_zot", "enter_temple",
-"enter_snake_pit", "enter_elven_halls", "enter_tomb",
-"enter_swamp", "enter_shoals", "enter_spider_nest",
-#if TAG_MAJOR_VERSION == 34
-"enter_forest",
-#endif
-"enter_depths",
-
-#if TAG_MAJOR_VERSION == 34
-"return_from_dwarven_hall",
-#endif
-"return_from_orcish_mines",
-"return_from_lair", "return_from_slime_pits",
-"return_from_vaults", "return_from_crypt",
-#if TAG_MAJOR_VERSION == 34
-"return_from_hall_of_blades",
-#endif
-"return_from_zot",
-"return_from_temple", "return_from_snake_pit",
-"return_from_elven_halls", "return_from_tomb",
-"return_from_swamp", "return_from_shoals", "return_from_spider_nest",
-#if TAG_MAJOR_VERSION == 34
-"return_from_forest",
-#endif
-"return_from_depths",
-
-"altar_zin", "altar_the_shining_one", "altar_kikubaaqudgha",
-"altar_yredelemnul", "altar_xom", "altar_vehumet",
-"altar_okawaru", "altar_makhleb", "altar_sif_muna", "altar_trog",
-"altar_nemelex_xobeh", "altar_elyvilon", "altar_lugonu",
-"altar_beogh", "altar_jiyva", "altar_fedhas", "altar_cheibriados",
-"altar_ashenzari", "altar_dithmenos",
-#if TAG_MAJOR_VERSION > 34
-"altar_gozag", "altar_qazlal", "", "", "", "", "", "",
-#endif
-
-"fountain_blue", "fountain_sparkling", "fountain_blood",
-#if TAG_MAJOR_VERSION == 34
-"non-fountain_blue", "non-fountain_sparkling", "non-fountain_blood",
-#endif
-"dry_fountain",
-
-"explore_horizon",
-"unknown_altar", "unknown_portal",
-
-#if TAG_MAJOR_VERSION == 34
-"abyssal_stair",
-"badly_sealed_door",
-#endif
-
-"sealed_stair_up",
-"sealed_stair_down",
-
-"trap_alarm",
-"trap_zot",
-"passage_of_golubria",
-
-"enter_ziggurat",
-"enter_bazaar",
-"enter_trove",
-"enter_sewer",
-"enter_ossuary",
-"enter_bailey",
-"enter_ice_cave",
-"enter_volcano",
-"enter_wizlab",
-"enter_unused",
-"exit_ziggurat",
-"exit_bazaar",
-"exit_trove",
-"exit_sewer",
-"exit_ossuary",
-"exit_bailey",
-"exit_ice_cave",
-"exit_volcano",
-"exit_wizlab",
-"exit_labyrinth",
-"exit_unused",
-
-#if TAG_MAJOR_VERSION == 34
-"altar_gozag",
-"altar_qazlal",
-#endif
-};
-
+/** Find the feature with this name.
+ *
+ * @param name The name (not the user-visible one) to be matched.
+ * @returns DNGN_UNSEEN if name is "", DNGN_FLOOR if the name is for a
+ * dead/forbidden god, and the first entry in the enum with a
+ * matching name otherwise.
+ */
dungeon_feature_type dungeon_feature_by_name(const string &name)
{
- COMPILE_CHECK(ARRAYSZ(dngn_feature_names) == NUM_FEATURES);
-
if (name.empty())
return DNGN_UNSEEN;
- for (unsigned i = 0; i < ARRAYSZ(dngn_feature_names); ++i)
+ for (unsigned i = 0; i < NUM_FEATURES; ++i)
{
- if (dngn_feature_names[i] == name)
+ dungeon_feature_type feat = static_cast<dungeon_feature_type>(i);
+
+ if (!is_valid_feature_type(feat))
+ continue;
+
+ if (get_feature_def(feat).vaultname == name)
{
- dungeon_feature_type feat = static_cast<dungeon_feature_type>(i);
if (feat_is_altar(feat)
&& is_unavailable_god(feat_altar_god(feat)))
@@ -1657,29 +1538,45 @@ dungeon_feature_type dungeon_feature_by_name(const string &name)
return DNGN_UNSEEN;
}
+/** Find feature names that contain this name.
+ *
+ * @param name The string to be matched.
+ * @returns a list of matching names.
+ */
vector<string> dungeon_feature_matches(const string &name)
{
vector<string> matches;
- COMPILE_CHECK(ARRAYSZ(dngn_feature_names) == NUM_FEATURES);
if (name.empty())
return matches;
- for (unsigned i = 0; i < ARRAYSZ(dngn_feature_names); ++i)
- if (strstr(dngn_feature_names[i], name.c_str()))
- matches.push_back(dngn_feature_names[i]);
+ for (unsigned i = 0; i < NUM_FEATURES; ++i)
+ {
+ dungeon_feature_type feat = static_cast<dungeon_feature_type>(i);
+
+ if (!is_valid_feature_type(feat))
+ continue;
+
+ const char *featname = get_feature_def(feat).vaultname;
+ if (strstr(featname, name.c_str()))
+ matches.push_back(featname);
+ }
return matches;
}
+/** Get the lua/wizmode name for a feature.
+ *
+ * @param rfeat The feature type to be found.
+ * @returns NULL if rfeat is not defined, the vaultname of the corresponding
+ * feature_def otherwise.
+ */
const char *dungeon_feature_name(dungeon_feature_type rfeat)
{
- const unsigned feat = rfeat;
-
- if (feat >= ARRAYSZ(dngn_feature_names))
+ if (!is_valid_feature_type(rfeat))
return NULL;
- return dngn_feature_names[feat];
+ return get_feature_def(rfeat).vaultname;
}
void destroy_wall(const coord_def& p)