From 550af32eec0e42c1c8e3228221914934d20c3244 Mon Sep 17 00:00:00 2001 From: Jude Brown Date: Sat, 14 Nov 2009 19:03:54 +1000 Subject: Allow portal vaults to specify fill and border glyph. Also move dungeon_feature_by_name into terrain.cc, as it does not make sense it being in l_dgngrd.cc. The Lua function "set_border_fill_type(feature)" will replace the default DNGN_ROCK_WALL fill of a portal vault with the specified feature. This could be abused, and should probably only be limited to floor, water and sea, different types of walls, trees and lava; there are no sanity checks for endless traps, statues, stairs, etc. Finally, apply this to the island Trove, giving endless water effect. --- crawl-ref/source/dat/trove.des | 1 + crawl-ref/source/dungeon.cc | 6 +++ crawl-ref/source/l_dgn.cc | 16 +++++++ crawl-ref/source/l_dgngrd.cc | 93 ----------------------------------------- crawl-ref/source/mapdef.cc | 17 ++++---- crawl-ref/source/mapdef.h | 2 + crawl-ref/source/terrain.cc | 95 ++++++++++++++++++++++++++++++++++++++++++ crawl-ref/source/terrain.h | 5 +++ 8 files changed, 134 insertions(+), 101 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/dat/trove.des b/crawl-ref/source/dat/trove.des index 4dab15dde1..224cc528d8 100644 --- a/crawl-ref/source/dat/trove.des +++ b/crawl-ref/source/dat/trove.des @@ -561,6 +561,7 @@ ITEM: any jewellery good_item / any good_item ITEM: acquire weapon / acquire armour / any good_item ITEM: potion of cure mutation : trove_setup_features(_G) +: set_border_fill_type("deep_water") MAP wwwwwwwwwwwwwwwwwwwwwwwwwwwww wwwwwwwwwwwwwwwwwwwwwwwwwwwww diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 7d9f9de8e5..05a924cb8c 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -2620,7 +2620,13 @@ static void _portal_vault_level(int level_number) vault = random_map_for_tag(level_name, false); if (vault) + { + // XXX: This is pretty hackish, I confess. + if (vault->border_fill_type != DNGN_ROCK_WALL) + _replace_area(0, 0, GXM-1, GYM-1, DNGN_ROCK_WALL, vault->border_fill_type); + _ensure_vault_placed( _build_vaults(level_number, vault), true ); + } else { _plan_main(level_number, 0); diff --git a/crawl-ref/source/l_dgn.cc b/crawl-ref/source/l_dgn.cc index 86fee24781..39a12b9051 100644 --- a/crawl-ref/source/l_dgn.cc +++ b/crawl-ref/source/l_dgn.cc @@ -896,6 +896,21 @@ static int lua_dgn_set_lt_callback(lua_State *ls) return (0); } +static int lua_dgn_set_border_fill_type (lua_State *ls) +{ + MAP(ls, 1, map); + if (lua_gettop(ls) != 2) + luaL_error(ls, "set_border_fill_type requires a feature."); + + dungeon_feature_type fill_type = + dungeon_feature_by_name(luaL_checkstring(ls, 2)); + + if (fill_type != DNGN_UNSEEN) + map->border_fill_type = fill_type; + + return (0); +} + static int dgn_fixup_stairs(lua_State *ls) { const dungeon_feature_type up_feat = @@ -1612,6 +1627,7 @@ const struct luaL_reg dgn_dlib[] = { "change_floor_colour", dgn_change_floor_colour }, { "change_rock_colour", dgn_change_rock_colour }, { "set_lt_callback", lua_dgn_set_lt_callback }, +{ "set_border_fill_type", lua_dgn_set_border_fill_type }, { "fixup_stairs", dgn_fixup_stairs }, { "floor_halo", dgn_floor_halo }, { "random_walk", dgn_random_walk }, diff --git a/crawl-ref/source/l_dgngrd.cc b/crawl-ref/source/l_dgngrd.cc index 90657819cd..84d2d00cfc 100644 --- a/crawl-ref/source/l_dgngrd.cc +++ b/crawl-ref/source/l_dgngrd.cc @@ -16,99 +16,6 @@ #include "religion.h" #include "terrain.h" -const char *dngn_feature_names[] = -{ -"unseen", "closed_door", "detected_secret_door", "secret_door", -"wax_wall", "metal_wall", "green_crystal_wall", "rock_wall", "stone_wall", -"permarock_wall", -"clear_rock_wall", "clear_stone_wall", "clear_permarock_wall", "trees", -"open_sea", "orcish_idol", "", "", "", "", "", -"granite_statue", "statue_reserved_1", "statue_reserved_2", -"", "", "", "", "", "", "", "", -"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", -"", "", "", "", "", "", "", "", "", "", "", "", "", "lava", -"deep_water", "", "", "shallow_water", "water_stuck", "floor", -"floor_special", "floor_reserved", "exit_hell", "enter_hell", -"open_door", "", "", "trap_mechanical", "trap_magical", "trap_natural", -"undiscovered_trap", "", "enter_shop", "enter_labyrinth", -"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", "stone_arch", -"enter_pandemonium", "exit_pandemonium", "transit_pandemonium", -"", "", "", "builder_special_wall", "builder_special_floor", "", -"", "", "enter_orcish_mines", "enter_hive", "enter_lair", -"enter_slime_pits", "enter_vaults", "enter_crypt", -"enter_hall_of_blades", "enter_zot", "enter_temple", -"enter_snake_pit", "enter_elven_halls", "enter_tomb", -"enter_swamp", "enter_shoals", "enter_reserved_2", -"enter_reserved_3", "enter_reserved_4", "", "", "", -"return_from_orcish_mines", "return_from_hive", -"return_from_lair", "return_from_slime_pits", -"return_from_vaults", "return_from_crypt", -"return_from_hall_of_blades", "return_from_zot", -"return_from_temple", "return_from_snake_pit", -"return_from_elven_halls", "return_from_tomb", -"return_from_swamp", "return_from_shoals", "return_reserved_2", -"return_reserved_3", "return_reserved_4", "", "", "", "", "", "", -"", "", "", "", "", "", "", "enter_portal_vault", "exit_portal_vault", -"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", -"", "", "altar_zin", "altar_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", "", "", "", -"fountain_blue", "fountain_sparkling", "fountain_blood", -"dry_fountain_blue", "dry_fountain_sparkling", "dry_fountain_blood", -"permadry_fountain", "abandoned_shop" -}; - -dungeon_feature_type dungeon_feature_by_name(const std::string &name) -{ - COMPILE_CHECK(ARRAYSZ(dngn_feature_names) == NUM_FEATURES, c1); - if (name.empty()) - return (DNGN_UNSEEN); - - for (unsigned i = 0; i < ARRAYSZ(dngn_feature_names); ++i) - { - if (dngn_feature_names[i] == name) - { - if (jiyva_is_dead() && name == "altar_jiyva") - return (DNGN_FLOOR); - - return (static_cast(i)); - } - } - - return (DNGN_UNSEEN); -} - -std::vector dungeon_feature_matches(const std::string &name) -{ - std::vector matches; - - COMPILE_CHECK(ARRAYSZ(dngn_feature_names) == NUM_FEATURES, c1); - 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]); - - return (matches); -} - -const char *dungeon_feature_name(dungeon_feature_type rfeat) -{ - const unsigned feat = rfeat; - - if (feat >= ARRAYSZ(dngn_feature_names)) - return (NULL); - - return dngn_feature_names[feat]; -} - static int dgn_feature_number(lua_State *ls) { const std::string &name = luaL_checkstring(ls, 1); diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index 0ff5a83843..1482387fed 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -413,13 +413,13 @@ void map_lines::init_from(const map_lines &map) // Markers have to be regenerated, they will not be copied. clear_markers(); overlay.reset(NULL); - lines = map.lines; - map_width = map.map_width; - solid_north = map.solid_north; - solid_east = map.solid_east; - solid_south = map.solid_south; - solid_west = map.solid_west; - solid_checked = map.solid_checked; + lines = map.lines; + map_width = map.map_width; + solid_north = map.solid_north; + solid_east = map.solid_east; + solid_south = map.solid_south; + solid_west = map.solid_west; + solid_checked = map.solid_checked; } template @@ -1480,7 +1480,7 @@ map_def::map_def() mapchunk("dlmapchunk"), main("dlmain"), validate("dlvalidate"), veto("dlveto"), rock_colour(BLACK), floor_colour(BLACK), rock_tile(0), floor_tile(0), - index_only(false), cache_offset(0L) + border_fill_type(DNGN_ROCK_WALL), index_only(false), cache_offset(0L) { init(); } @@ -1513,6 +1513,7 @@ void map_def::reinit() rock_colour = floor_colour = BLACK; rock_tile = floor_tile = 0; + border_fill_type = DNGN_ROCK_WALL; // Chance of using this level. Nonzero chance should be used // sparingly. When selecting vaults for a place, first those diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h index 791a929b10..e8ceafabda 100644 --- a/crawl-ref/source/mapdef.h +++ b/crawl-ref/source/mapdef.h @@ -368,6 +368,7 @@ private: private: std::vector markers; std::vector lines; + struct overlay_def { overlay_def() : colour(0), rocktile(0), floortile(0), property(0) {} @@ -722,6 +723,7 @@ public: unsigned char rock_colour, floor_colour; int rock_tile, floor_tile; + dungeon_feature_type border_fill_type; private: // This map has been loaded from an index, and not fully realised. bool index_only; diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc index ce3beb1c7d..c86014197d 100644 --- a/crawl-ref/source/terrain.cc +++ b/crawl-ref/source/terrain.cc @@ -29,6 +29,7 @@ #include "overmap.h" #include "player.h" #include "random.h" +#include "religion.h" #include "spells3.h" #include "stuff.h" #include "transfor.h" @@ -1253,3 +1254,97 @@ std::string stair_climb_verb(dungeon_feature_type feat) else return "pass through"; } + +const char *dngn_feature_names[] = +{ +"unseen", "closed_door", "detected_secret_door", "secret_door", +"wax_wall", "metal_wall", "green_crystal_wall", "rock_wall", "stone_wall", +"permarock_wall", +"clear_rock_wall", "clear_stone_wall", "clear_permarock_wall", "trees", +"open_sea", "orcish_idol", "", "", "", "", "", +"granite_statue", "statue_reserved_1", "statue_reserved_2", +"", "", "", "", "", "", "", "", +"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", +"", "", "", "", "", "", "", "", "", "", "", "", "", "lava", +"deep_water", "", "", "shallow_water", "water_stuck", "floor", +"floor_special", "floor_reserved", "exit_hell", "enter_hell", +"open_door", "", "", "trap_mechanical", "trap_magical", "trap_natural", +"undiscovered_trap", "", "enter_shop", "enter_labyrinth", +"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", "stone_arch", +"enter_pandemonium", "exit_pandemonium", "transit_pandemonium", +"", "", "", "builder_special_wall", "builder_special_floor", "", +"", "", "enter_orcish_mines", "enter_hive", "enter_lair", +"enter_slime_pits", "enter_vaults", "enter_crypt", +"enter_hall_of_blades", "enter_zot", "enter_temple", +"enter_snake_pit", "enter_elven_halls", "enter_tomb", +"enter_swamp", "enter_shoals", "enter_reserved_2", +"enter_reserved_3", "enter_reserved_4", "", "", "", +"return_from_orcish_mines", "return_from_hive", +"return_from_lair", "return_from_slime_pits", +"return_from_vaults", "return_from_crypt", +"return_from_hall_of_blades", "return_from_zot", +"return_from_temple", "return_from_snake_pit", +"return_from_elven_halls", "return_from_tomb", +"return_from_swamp", "return_from_shoals", "return_reserved_2", +"return_reserved_3", "return_reserved_4", "", "", "", "", "", "", +"", "", "", "", "", "", "", "enter_portal_vault", "exit_portal_vault", +"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", +"", "", "altar_zin", "altar_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", "", "", "", +"fountain_blue", "fountain_sparkling", "fountain_blood", +"dry_fountain_blue", "dry_fountain_sparkling", "dry_fountain_blood", +"permadry_fountain", "abandoned_shop" +}; + +dungeon_feature_type dungeon_feature_by_name(const std::string &name) +{ + COMPILE_CHECK(ARRAYSZ(dngn_feature_names) == NUM_FEATURES, c1); + if (name.empty()) + return (DNGN_UNSEEN); + + for (unsigned i = 0; i < ARRAYSZ(dngn_feature_names); ++i) + { + if (dngn_feature_names[i] == name) + { + if (jiyva_is_dead() && name == "altar_jiyva") + return (DNGN_FLOOR); + + return (static_cast(i)); + } + } + + return (DNGN_UNSEEN); +} + +std::vector dungeon_feature_matches(const std::string &name) +{ + std::vector matches; + + COMPILE_CHECK(ARRAYSZ(dngn_feature_names) == NUM_FEATURES, c1); + 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]); + + return (matches); +} + +const char *dungeon_feature_name(dungeon_feature_type rfeat) +{ + const unsigned feat = rfeat; + + if (feat >= ARRAYSZ(dngn_feature_names)) + return (NULL); + + return dngn_feature_names[feat]; +} + diff --git a/crawl-ref/source/terrain.h b/crawl-ref/source/terrain.h index 2bb3fb5d1e..86bec075f1 100644 --- a/crawl-ref/source/terrain.h +++ b/crawl-ref/source/terrain.h @@ -84,4 +84,9 @@ bool is_critical_feature(dungeon_feature_type feat); void init_feat_desc_cache(); dungeon_feature_type feat_by_desc(std::string desc); + +dungeon_feature_type dungeon_feature_by_name(const std::string &name); +std::vector dungeon_feature_matches(const std::string &name); +const char *dungeon_feature_name(dungeon_feature_type rfeat); + #endif -- cgit v1.2.3-54-g00ecf