diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-07-28 08:42:47 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-07-28 08:42:47 +0000 |
commit | 5549c15ba74e62433508e9bbaa23d117610f81e2 (patch) | |
tree | 8f462e0f7b7f516629af0b773fc5a7a176060f4e /crawl-ref/source | |
parent | 9b909453a2e070df3ac33277d0a7f07deb6e9132 (diff) | |
download | crawl-ref-5549c15ba74e62433508e9bbaa23d117610f81e2.tar.gz crawl-ref-5549c15ba74e62433508e9bbaa23d117610f81e2.zip |
Added wizmode &L command to place a map on the current level by name. This
only really works for non-encompass vaults, and dungeon fixups are not applied
(so random deep water -> shallow water conversion, auto-placement of water
creatures, etc. will not happen).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1942 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/acr.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/command.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/debug.cc | 38 | ||||
-rw-r--r-- | crawl-ref/source/debug.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/dungeon.cc | 190 | ||||
-rw-r--r-- | crawl-ref/source/dungeon.h | 24 | ||||
-rw-r--r-- | crawl-ref/source/maps.cc | 42 | ||||
-rw-r--r-- | crawl-ref/source/maps.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 17 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 12 | ||||
-rw-r--r-- | crawl-ref/source/view.h | 6 |
11 files changed, 272 insertions, 72 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index efa025d4fc..d36672a62a 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -644,6 +644,10 @@ static void handle_wizard_command( void ) grd[you.x_pos][you.y_pos] = DNGN_ENTER_LABYRINTH; break; + case 'L': + debug_place_map(); + break; + case 'i': mpr( "You feel a rush of knowledge." ); for (i = 0; i < ENDOFPACK; i++) diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 2103084a76..9b7e362467 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -1087,6 +1087,7 @@ static void list_wizard_commands() "h/H : heal yourself (super-Heal)\n" "i/I : identify/unidentify inventory\n" "l : make entrance to labyrinth\n" + "L : place a vault by name\n" "m/M : create monster by number/name\n" "o/% : create an object\n" "p : make entrance to pandemonium\n" @@ -1094,11 +1095,11 @@ static void list_wizard_commands() "s : gain 20000 skill points\n" "S : set skill to level\n" "t : tweak object properties\n" - "T : make a trap\n" - "v : show gold value of an item\n", + "T : make a trap\n", true, true); cols.add_formatted(1, + "v : show gold value of an item\n" "x : gain an experience level\n" "Ctrl-X : change experience level\n" "X : make Xom do something now\n" @@ -1119,7 +1120,6 @@ static void list_wizard_commands() "? : list wizard commands\n" "| : make unrand/fixed artefacts\n" "+ : make randart from item\n" - "= : sum skill points\n" "@ : set Str Int Dex\n" "\\ : make a shop\n", true, true); diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 2b8dc05f17..64843bc131 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -2188,6 +2188,44 @@ void debug_set_xl() debug_uptick_xl(newxl); } +static void debug_load_map_by_name(const std::string &name) +{ + level_clear_vault_memory(); + const int map = find_map_by_name(name); + if (map == -1) + { + mprf("Can't find map named '%s'.", name.c_str()); + return; + } + + if (dgn_place_map(map, false, true)) + mprf("Successfully placed %s.", map_by_index(map)->name.c_str()); + else + mprf("Failed to place %s.", map_by_index(map)->name.c_str()); +} + +void debug_place_map() +{ + char what_to_make[100]; + mesclr(); + mprf(MSGCH_PROMPT, "Enter map name: "); + if (cancelable_get_line(what_to_make, sizeof what_to_make)) + { + canned_msg(MSG_OK); + return; + } + + std::string what = what_to_make; + trim_string(what); + if (what.empty()) + { + canned_msg(MSG_OK); + return; + } + + debug_load_map_by_name(what); +} + #endif #ifdef DEBUG_DIAGNOSTICS diff --git a/crawl-ref/source/debug.h b/crawl-ref/source/debug.h index 62ca22d53a..964965ea30 100644 --- a/crawl-ref/source/debug.h +++ b/crawl-ref/source/debug.h @@ -153,6 +153,7 @@ void debug_list_monsters(); void debug_card(); void debug_set_xl(); +void debug_place_map(); #ifdef DEBUG_DIAGNOSTICS void generate_map_stats(); diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 1738b6483f..6a77697fef 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -59,6 +59,7 @@ #include "stuff.h" #include "tags.h" #include "travel.h" +#include "view.h" #define MAX_PIT_MONSTERS 10 @@ -193,11 +194,16 @@ static void beehive(spec_room &sr); static void jelly_pit(int level_number, spec_room &sr); // VAULT FUNCTIONS -static bool build_secondary_vault(int level_number, int vault, int rune_subst = -1); +static bool build_secondary_vault(int level_number, int vault, + int rune_subst = -1, + bool generating_level = true, + bool clobber = false); static bool build_vaults(int level_number, int vault_number, int rune_subst = -1, bool build_only = false, - bool check_vault_place = false); + bool check_vault_place = false, + bool generating_level = true, bool clobber = false); static bool build_minivaults(int level_number, int force_vault, + bool level_builder = true, bool clobber = false, coord_def where = coord_def() ); static int vault_grid( vault_placement &, int level_number, int vx, int vy, int altar_count, @@ -221,7 +227,6 @@ typedef std::list<coord_def> coord_list; map_mask dgn_map_mask; std::vector<vault_placement> level_vaults; -static dgn_region_list vault_zones; static int vault_chance = 9; static int minivault_chance = 3; static bool dgn_level_vetoed = false; @@ -289,6 +294,12 @@ void level_welcome_messages() } } +void level_clear_vault_memory() +{ + level_vaults.clear(); + dgn_map_mask.init(0); +} + static void dgn_register_vault(const map_def &map) { if (map.has_tag("uniq")) @@ -494,9 +505,7 @@ static bool valid_dungeon_level(int level_number, int level_type) static void reset_level() { - dgn_map_mask.init(0); - level_vaults.clear(); - vault_zones.clear(); + level_clear_vault_memory(); vault_chance = 9; minivault_chance = 3; use_random_maps = true; @@ -1090,7 +1099,7 @@ static void prepare_shoals(int level_number) } while ( vaultidx == -1 || !map_by_index(vaultidx)->has_tag("has_rune") ); - build_minivaults( level_number, vaultidx, + build_minivaults( level_number, vaultidx, true, false, centres[1] - coord_def(3,3) ); for ( int i = 2; i < num_islands; ++i ) @@ -1100,7 +1109,7 @@ static void prepare_shoals(int level_number) vaultidx = dgn_random_map_for_place(true); } while ( vaultidx == -1 || map_by_index(vaultidx)->has_tag("has_rune") ); - build_minivaults( level_number, vaultidx, + build_minivaults( level_number, vaultidx, true, false, centres[i] - coord_def(3,3) ); } } @@ -2868,7 +2877,8 @@ static void beehive(spec_room &sr) } // end beehive() static bool safe_minivault_place(int v1x, int v1y, - const vault_placement &place) + const vault_placement &place, + bool clobber) { const bool water_ok = place.map.has_tag("water_ok"); const std::vector<std::string> &lines = place.map.map.get_lines(); @@ -2881,16 +2891,22 @@ static bool safe_minivault_place(int v1x, int v1y, if (dgn_map_mask[vx][vy]) return (false); + + const dungeon_feature_type dfeat = grd[vx][vy]; - if ((grd[vx][vy] != DNGN_FLOOR - && grd[vx][vy] != DNGN_ROCK_WALL - && grd[vx][vy] != DNGN_CLOSED_DOOR - && grd[vx][vy] != DNGN_SECRET_DOOR - && (!water_ok || - (grd[vx][vy] != DNGN_DEEP_WATER - && grd[vx][vy] != DNGN_SHALLOW_WATER))) - || igrd[vx][vy] != NON_ITEM - || mgrd[vx][vy] != NON_MONSTER) + if ((dfeat != DNGN_FLOOR + && dfeat != DNGN_ROCK_WALL + && dfeat != DNGN_CLOSED_DOOR + && dfeat != DNGN_SECRET_DOOR + && (!water_ok + || (dfeat != DNGN_DEEP_WATER + && dfeat != DNGN_SHALLOW_WATER)) + && (!clobber + || (!grid_is_solid(dfeat) && dfeat != DNGN_LAVA + && !grid_is_watery(dfeat)))) + || (!clobber + && (igrd[vx][vy] != NON_ITEM + || mgrd[vx][vy] != NON_MONSTER))) { return (false); } @@ -2925,7 +2941,7 @@ static bool connected_minivault_place(int v1x, int v1y, } static bool find_minivault_place(const vault_placement &place, - int &v1x, int &v1y) + int &v1x, int &v1y, bool clobber) { // [ds] The margin around the edges of the map where the minivault // won't be placed. Purely arbitrary as far as I can see. @@ -2937,7 +2953,7 @@ static bool find_minivault_place(const vault_placement &place, v1x = random_range( margin, GXM - margin - place.width ); v1y = random_range( margin, GYM - margin - place.height ); - if (!safe_minivault_place( v1x, v1y, place )) + if (!safe_minivault_place( v1x, v1y, place, clobber )) continue; if (connected_minivault_place(v1x, v1y, place)) @@ -2947,6 +2963,7 @@ static bool find_minivault_place(const vault_placement &place, } static bool build_minivaults(int level_number, int force_vault, + bool building_level, bool clobber, coord_def where) { // for some weird reason can't put a vault on level 1, because monster equip @@ -2978,17 +2995,13 @@ static bool build_minivaults(int level_number, int force_vault, v1x = where.x; v1y = where.y; } - else if (!find_minivault_place(place, v1x, v1y)) + else if (!find_minivault_place(place, v1x, v1y, clobber)) return (false); place.x = v1x; place.y = v1y; - place.map.map.apply_markers(coord_def(v1x, v1y)); - level_vaults.push_back(place); - vault_zones.push_back( - dgn_region(place.x, place.y, place.width, place.height)); #ifdef DEBUG_DIAGNOSTICS if (crawl_state.map_stat_gen) @@ -3010,14 +3023,25 @@ static bool build_minivaults(int level_number, int force_vault, const int feat = vgrid[vy - v1y][vx - v1x]; if (feat == ' ') continue; + const dungeon_feature_type oldgrid = grd[vx][vy]; altar_count = vault_grid( place, level_number, vx, vy, altar_count, acq_item_class, feat, target_connections, num_runes ); + if (!building_level) + { + link_items(); + const dungeon_feature_type newgrid = grd[vx][vy]; + grd[vx][vy] = oldgrid; + dungeon_terrain_changed(coord_def(vx, vy), newgrid); + env_remove_markers_at(coord_def(vx, vy), MAT_ANY); + } } } + place.map.map.apply_markers(coord_def(v1x, v1y)); + if (target_connections.empty() && place.map.has_tag("mini_float")) pick_float_exits(place, target_connections); @@ -3351,13 +3375,97 @@ static void connect_vault(const vault_placement &vp) } } +static dungeon_feature_type dgn_find_rune_subst(const std::string &tag) +{ + const std::string suffix("_entry"); + const std::string::size_type psuffix = tag.find(suffix); + if (psuffix == std::string::npos) + return (DNGN_FLOOR); + const std::string key = tag.substr(0, psuffix); + if (key == "bzr") + return (DNGN_ENTER_PORTAL_VAULT); + else if (key == "lab") + return (DNGN_ENTER_LABYRINTH); + else if (key == "hell") + return (DNGN_ENTER_HELL); + else if (key == "pan") + return (DNGN_ENTER_PANDEMONIUM); + else if (key == "abyss") + return (DNGN_ENTER_ABYSS); + else + { + for (int i = 0; i < NUM_BRANCHES; ++i) + { + if (branches[i].entry_stairs != NUM_FEATURES + && !strcasecmp(branches[i].abbrevname, key.c_str())) + { + return (branches[i].entry_stairs); + } + } + } + return (DNGN_FLOOR); +} + +static dungeon_feature_type dgn_find_rune_subst_tags(const std::string &tags) +{ + std::vector<std::string> words = split_string(" ", tags); + for (int i = 0, size = words.size(); i < size; ++i) + { + const dungeon_feature_type feat = dgn_find_rune_subst(words[i]); + if (feat != DNGN_FLOOR) + return (feat); + } + return (DNGN_FLOOR); +} + +bool dgn_place_map(int map, bool generating_level, bool clobber) +{ + const map_def *mdef = map_by_index(map); + bool did_map = false; + + if (mdef->is_minivault()) + did_map = + build_minivaults(you.your_level, map, generating_level, clobber); + else + { + dungeon_feature_type rune_subst = DNGN_FLOOR; + if (mdef->has_tag_suffix("_entry")) + rune_subst = dgn_find_rune_subst_tags(mdef->tags); + did_map = build_secondary_vault(you.your_level, map, rune_subst, + generating_level, clobber); + } + + // Activate any markers within the map. + if (did_map) + { + const vault_placement &vp = level_vaults[level_vaults.size() - 1]; + for (int y = vp.y; y < vp.y + vp.height; ++y) + { + for (int x = vp.x; x < vp.x + vp.width; ++x) + { + std::vector<map_marker *> markers = + env_get_markers(coord_def(x, y)); + for (int i = 0, size = markers.size(); i < size; ++i) + markers[i]->activate(); + + if (!see_grid(x, y)) + set_terrain_changed(x, y); + } + } + } + return (did_map); +} + /* * Places a vault somewhere in an already built level if possible. * Returns true if the vault was successfully placed. */ -static bool build_secondary_vault(int level_number, int vault, int rune_subst) +static bool build_secondary_vault(int level_number, int vault, + int rune_subst, bool generating_level, + bool clobber) { - if (build_vaults(level_number, vault, rune_subst, true, true)) + if (build_vaults(level_number, vault, rune_subst, true, true, + generating_level, clobber)) { const vault_placement &vp = level_vaults[ level_vaults.size() - 1 ]; connect_vault(vp); @@ -3368,7 +3476,8 @@ static bool build_secondary_vault(int level_number, int vault, int rune_subst) } static bool build_vaults(int level_number, int force_vault, int rune_subst, - bool build_only, bool check_collisions) + bool build_only, bool check_collisions, + bool generating_level, bool clobber) { int altar_count = 0; FixedVector < char, 10 > stair_exist; @@ -3392,13 +3501,12 @@ static bool build_vaults(int level_number, int force_vault, int rune_subst, vault_placement place; std::vector<coord_def> &target_connections = place.exits; - const int gluggy = vault_main(vgrid, place, force_vault, check_collisions); + const int gluggy = vault_main(vgrid, place, force_vault, + check_collisions, clobber); if (gluggy == MAP_NONE || !gluggy) return (false); - place.map.map.apply_markers(coord_def(place.x, place.y)); - int vx, vy; int num_runes = 0; @@ -3411,6 +3519,8 @@ static bool build_vaults(int level_number, int force_vault, int rune_subst, { if (vgrid[vy][vx] == ' ') continue; + + const dungeon_feature_type oldgrid = grd[vx][vy]; altar_count = vault_grid( place, level_number, vx, vy, altar_count, acq_item_class, @@ -3418,9 +3528,20 @@ static bool build_vaults(int level_number, int force_vault, int rune_subst, target_connections, num_runes, rune_subst ); + if (!generating_level) + { + // Have to link items each square at a time, or + // dungeon_terrain_changed could blow up. + link_items(); + const dungeon_feature_type newgrid = grd[vx][vy]; + grd[vx][vy] = oldgrid; + dungeon_terrain_changed(coord_def(vx, vy), newgrid); + env_remove_markers_at(coord_def(vx, vy), MAT_ANY); + } } } + place.map.map.apply_markers(coord_def(place.x, place.y)); register_place(place); if (gluggy == MAP_FLOAT && target_connections.empty()) @@ -3429,8 +3550,6 @@ static bool build_vaults(int level_number, int force_vault, int rune_subst, // Must do this only after target_connections is finalised, or the vault // exits will not be correctly set. level_vaults.push_back(place); - vault_zones.push_back( - dgn_region(place.x, place.y, place.width, place.height)); #ifdef DEBUG_DIAGNOSTICS if (crawl_state.map_stat_gen) @@ -4125,10 +4244,11 @@ static bool join_the_dots( { join_count++; - if (early_exit && at != from && grd(at) == DNGN_FLOOR) + const dungeon_feature_type feat = grd(at); + if (early_exit && at != from && is_traversable(feat)) return (true); - if (unforbidden(at, MMT_VAULT)) + if (unforbidden(at, MMT_VAULT) && !is_traversable(feat)) grd(at) = DNGN_FLOOR; if (join_count > 10000) // just insurance diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h index 530226554d..9561e587b5 100644 --- a/crawl-ref/source/dungeon.h +++ b/crawl-ref/source/dungeon.h @@ -20,6 +20,7 @@ #include "misc.h" #include "travel.h" #include "stuff.h" +#include <vector> const int MAKE_GOOD_ITEM = 351; @@ -111,16 +112,6 @@ struct dgn_region bool overlaps(const map_mask &dgn_map_mask) const; }; -bool builder(int level_number, int level_type); -void level_welcome_messages(); -void define_zombie(int mid, int ztype, int cs, int power); -bool is_wall(int feature); -bool place_specific_trap(int spec_x, int spec_y, trap_type spec_type); -void place_spec_shop(int level_number, int shop_x, int shop_y, - int force_s_type, bool representative = false); -bool unforbidden(const coord_def &c, unsigned mask); -coord_def dgn_find_nearby_stair(int stair_to_find, bool find_closest); - ////////////////////////////////////////////////////////////////////////// template <typename fgrd, typename bound_check> class flood_find : public travel_pathfind @@ -279,4 +270,17 @@ bool flood_find<fgrd, bound_check>::path_flood( } ////////////////////////////////////////////////////////////////////////// + +bool builder(int level_number, int level_type); +bool dgn_place_map(int map, bool generating_level, bool clobber); +void level_clear_vault_memory(); +void level_welcome_messages(); +void define_zombie(int mid, int ztype, int cs, int power); +bool is_wall(int feature); +bool place_specific_trap(int spec_x, int spec_y, trap_type spec_type); +void place_spec_shop(int level_number, int shop_x, int shop_y, + int force_s_type, bool representative = false); +bool unforbidden(const coord_def &c, unsigned mask); +coord_def dgn_find_nearby_stair(int stair_to_find, bool find_closest); + #endif diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc index 4cecac9884..8599c2efe2 100644 --- a/crawl-ref/source/maps.cc +++ b/crawl-ref/source/maps.cc @@ -30,12 +30,12 @@ static int write_vault(map_def &mdef, map_type mt, vault_placement &, - bool check_place); + bool check_place, bool clobber); static int apply_vault_definition( map_def &def, map_type map, vault_placement &, - bool check_place); + bool check_place, bool clobber); static bool resolve_map(map_def &def, const map_def &original); @@ -58,7 +58,8 @@ int vault_main( map_type vgrid, vault_placement &place, int which_vault, - bool check_place) + bool check_place, + bool clobber) { #ifdef DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "Generating level: %s", @@ -80,12 +81,13 @@ int vault_main( // Return value of zero forces dungeon.cc to regenerate the level, except // for branch entry vaults where dungeon.cc just rejects the vault and // places a vanilla entry. - return (write_vault( vdefs[which_vault], vgrid, place, check_place )); + return (write_vault( vdefs[which_vault], vgrid, place, + check_place, clobber )); } static int write_vault(map_def &mdef, map_type map, vault_placement &place, - bool check_place) + bool check_place, bool clobber) { mdef.load(); @@ -104,7 +106,7 @@ static int write_vault(map_def &mdef, map_type map, continue; place.orient = apply_vault_definition(place.map, map, - place, check_place); + place, check_place, clobber); if (place.orient != MAP_NONE) break; @@ -157,7 +159,7 @@ static bool resolve_map(map_def &map, const map_def &original) // is a bad place to build a vault. static bool bad_map_place(const map_def &map, int sx, int sy, int width, int height, - bool check_place) + bool check_place, bool clobber) { if (!check_place) return (false); @@ -173,7 +175,8 @@ static bool bad_map_place(const map_def &map, if (dgn_map_mask[x][y]) return (true); - if (igrd[x][y] != NON_ITEM || mgrd[x][y] != NON_MONSTER) + if (!clobber + && (igrd[x][y] != NON_ITEM || mgrd[x][y] != NON_MONSTER)) return (true); const dungeon_feature_type grid = grd[x][y]; @@ -186,6 +189,11 @@ static bool bad_map_place(const map_def &map, && grid != DNGN_OPEN_DOOR && grid != DNGN_SECRET_DOOR) { +#ifdef DEBUG_DIAGNOSTICS + mprf(MSGCH_DIAGNOSTICS, + "Rejecting place because of %s at (%d,%d)", + dungeon_feature_name(grid), x, y); +#endif return (true); } } @@ -196,7 +204,7 @@ static bool bad_map_place(const map_def &map, static bool apply_vault_grid(map_def &def, map_type map, vault_placement &place, - bool check_place) + bool check_place, bool clobber) { const map_lines &ml = def.map; const int orient = def.orient; @@ -235,7 +243,8 @@ static bool apply_vault_grid(map_def &def, map_type map, starty = where.y; } - if (bad_map_place(def, startx, starty, width, height, check_place)) + if (bad_map_place(def, startx, starty, width, height, check_place, + clobber)) { #ifdef DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "Bad vault place: (%d,%d) dim (%d,%d)", @@ -268,9 +277,10 @@ static int apply_vault_definition( map_def &def, map_type map, vault_placement &place, - bool check_place) + bool check_place, + bool clobber) { - if (!apply_vault_grid(def, map, place, check_place)) + if (!apply_vault_grid(def, map, place, check_place, clobber)) return (MAP_NONE); int orient = def.orient; @@ -299,6 +309,14 @@ static bool vault_unforbidden(const map_def &map) you.uniq_map_tags.end())); } +int find_map_by_name(const std::string &name) +{ + for (unsigned i = 0, size = vdefs.size(); i < size; ++i) + if (vdefs[i].name == name) + return (i); + return (-1); +} + // Returns a map for which PLACE: matches the given place. int random_map_for_place(const level_id &place, bool want_minivault) { diff --git a/crawl-ref/source/maps.h b/crawl-ref/source/maps.h index 0d9df7319b..fd347f6a64 100644 --- a/crawl-ref/source/maps.h +++ b/crawl-ref/source/maps.h @@ -37,10 +37,12 @@ struct vault_placement int vault_main(map_type vgrid, vault_placement &vp, int vault_force, - bool check_place = false); + bool check_place = false, + bool clobber = false); const map_def *map_by_index(int index); int map_count(); +int find_map_by_name(const std::string &name); int random_map_for_place(const level_id &place, bool mini = false); int random_map_in_depth(const level_id &lid, bool want_minivault = false); int random_map_for_tag(const std::string &tag, bool want_minivault, diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 13ef4ef37f..dfe32abfe5 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -4270,6 +4270,13 @@ static bool is_trap_safe(const monsters *monster, const trap_struct &trap) return (!mechanical || mons_flies(monster)); } +static void mons_open_door(const coord_def &pos) +{ + if (grd(pos) == DNGN_SECRET_DOOR && !see_grid(pos)) + set_terrain_changed(pos); + grd(pos) = DNGN_OPEN_DOOR; +} + static void monster_move(monsters *monster) { FixedArray < bool, 3, 3 > good_move; @@ -4512,10 +4519,11 @@ static void monster_move(monsters *monster) } } // now we know where we _can_ move. + const coord_def newpos = monster->pos() + coord_def(mmov_x, mmov_y); // normal/smart monsters know about secret doors (they _live_ in the // dungeon!) - if (grd[monster->x + mmov_x][monster->y + mmov_y] == DNGN_CLOSED_DOOR - || (grd[monster->x + mmov_x][monster->y + mmov_y] == DNGN_SECRET_DOOR + if (grd(newpos) == DNGN_CLOSED_DOOR + || (grd(newpos) == DNGN_SECRET_DOOR && (mons_intel(monster_index(monster)) == I_HIGH || mons_intel(monster_index(monster)) == I_NORMAL))) { @@ -4530,13 +4538,13 @@ static void monster_move(monsters *monster) // for zombies, monster type is kept in mon->number if (mons_itemuse(monster->number) >= MONUSE_OPEN_DOORS) { - grd[monster->x + mmov_x][monster->y + mmov_y] = DNGN_OPEN_DOOR; + mons_open_door(newpos); return; } } else if (mons_itemuse(monster->type) >= MONUSE_OPEN_DOORS) { - grd[monster->x + mmov_x][monster->y + mmov_y] = DNGN_OPEN_DOOR; + mons_open_door(newpos); return; } } // endif - secret/closed doors @@ -4698,6 +4706,7 @@ forget_it: && good_move[mmov_x + 1][mmov_y + 1] == true) { grd[monster->x + mmov_x][monster->y + mmov_y] = DNGN_FLOOR; + set_terrain_changed(monster->pos() + coord_def(mmov_x, mmov_y)); if (!silenced(you.x_pos, you.y_pos)) mpr("You hear a grinding noise.", MSGCH_SOUND); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 0024465eb2..2dc27b5047 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -3015,6 +3015,7 @@ bool magic_mapping(int map_radius, int proportion, bool force) const int pfar = (map_radius * 7) / 10; const int very_far = (map_radius * 9) / 10; + const bool wizard_map = map_radius == 1000 && you.wizard; for (i = you.x_pos - map_radius; i < you.x_pos + map_radius; i++) { for (j = you.y_pos - map_radius; j < you.y_pos + map_radius; j++) @@ -3036,7 +3037,7 @@ bool magic_mapping(int map_radius, int proportion, bool force) if (is_terrain_changed(i, j)) clear_envmap_grid(i, j); - if (is_terrain_known(i, j)) + if (!wizard_map && is_terrain_known(i, j)) continue; empty_count = 8; @@ -3065,17 +3066,14 @@ bool magic_mapping(int map_radius, int proportion, bool force) if (empty_count > 0) { - if (!get_envmap_obj(i, j)) + if (wizard_map || !get_envmap_obj(i, j)) set_envmap_obj(i, j, grd[i][j]); // Hack to give demonspawn Pandemonium mutation the ability // to detect exits magically. if ((you.mutation[MUT_PANDEMONIUM] > 1 - && grd[i][j] == DNGN_EXIT_PANDEMONIUM) -#ifdef WIZARD - || (map_radius == 1000 && you.wizard) -#endif - ) + && grd[i][j] == DNGN_EXIT_PANDEMONIUM) + || wizard_map) { set_terrain_seen( i, j ); } diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h index a5357ce218..a3965502aa 100644 --- a/crawl-ref/source/view.h +++ b/crawl-ref/source/view.h @@ -120,6 +120,7 @@ bool is_envmap_detected_item(int x, int y); bool is_envmap_detected_mons(int x, int y); void set_terrain_mapped( int x, int y ); void set_terrain_seen( int x, int y ); +void set_terrain_changed( int x, int y ); bool is_terrain_known( int x, int y ); bool is_terrain_seen( int x, int y ); bool is_terrain_changed( int x, int y ); @@ -131,6 +132,11 @@ inline bool is_terrain_seen(const coord_def &c) return (is_terrain_seen(c.x, c.y)); } +inline void set_terrain_changed(const coord_def &c) +{ + set_terrain_changed(c.x, c.y); +} + void clear_feature_overrides(); void add_feature_override(const std::string &text); void clear_cset_overrides(); |