From 28f6c800df6bc63658b9c79e803bf81ac282aa1d Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Sun, 8 Nov 2009 14:23:03 +0100 Subject: Split map knowledge and FPROPs. map_cell no longer has the field "properties", which has been replaced by the unsigned long array env.pgrid. env.map has been renamed to env.map_knowledge. It should really be moved into player. --- crawl-ref/source/abyss.cc | 6 +- crawl-ref/source/acr.cc | 9 +- crawl-ref/source/beam.cc | 9 +- crawl-ref/source/chardump.cc | 4 +- crawl-ref/source/cloud.cc | 3 +- crawl-ref/source/dbg-maps.cc | 7 +- crawl-ref/source/delay.cc | 3 +- crawl-ref/source/directn.cc | 3 +- crawl-ref/source/dungeon.cc | 23 +-- crawl-ref/source/effects.cc | 29 ++-- crawl-ref/source/enum.h | 14 -- crawl-ref/source/env.h | 6 +- crawl-ref/source/envmap.cc | 331 -------------------------------------- crawl-ref/source/envmap.h | 83 ---------- crawl-ref/source/exclude.cc | 7 +- crawl-ref/source/fight.cc | 3 +- crawl-ref/source/files.cc | 2 +- crawl-ref/source/fprop.cc | 25 +++ crawl-ref/source/fprop.h | 23 +++ crawl-ref/source/initfile.cc | 1 + crawl-ref/source/item_use.cc | 3 +- crawl-ref/source/l_debug.cc | 2 +- crawl-ref/source/makefile.obj | 3 +- crawl-ref/source/map_knowledge.cc | 313 +++++++++++++++++++++++++++++++++++ crawl-ref/source/map_knowledge.h | 96 +++++++++++ crawl-ref/source/mapcell.h | 29 ---- crawl-ref/source/mapdef.cc | 2 +- crawl-ref/source/mapdef.h | 1 + crawl-ref/source/misc.cc | 11 +- crawl-ref/source/mon-abil.cc | 3 +- crawl-ref/source/mon-act.cc | 3 +- crawl-ref/source/mon-behv.cc | 11 +- crawl-ref/source/mon-cast.cc | 3 +- crawl-ref/source/mon-util.cc | 3 +- crawl-ref/source/monplace.cc | 3 +- crawl-ref/source/monster.cc | 2 +- crawl-ref/source/monstuff.cc | 3 +- crawl-ref/source/overmap.cc | 3 +- crawl-ref/source/player.cc | 7 +- crawl-ref/source/religion.cc | 7 +- crawl-ref/source/showsymb.cc | 9 +- crawl-ref/source/spells2.cc | 17 +- crawl-ref/source/spells3.cc | 13 +- crawl-ref/source/spl-cast.cc | 3 +- crawl-ref/source/tags.cc | 21 +-- crawl-ref/source/teleport.cc | 3 +- crawl-ref/source/terrain.cc | 19 +-- crawl-ref/source/tilepick.cc | 7 +- crawl-ref/source/tilereg.cc | 3 +- crawl-ref/source/tilesdl.cc | 11 +- crawl-ref/source/traps.cc | 5 +- crawl-ref/source/travel.cc | 13 +- crawl-ref/source/view.cc | 41 ++--- crawl-ref/source/viewmap.cc | 27 ++-- crawl-ref/source/wiz-mon.cc | 3 +- crawl-ref/source/xom.cc | 3 +- 56 files changed, 670 insertions(+), 627 deletions(-) delete mode 100644 crawl-ref/source/envmap.cc delete mode 100644 crawl-ref/source/envmap.h create mode 100644 crawl-ref/source/fprop.cc create mode 100644 crawl-ref/source/fprop.h create mode 100644 crawl-ref/source/map_knowledge.cc create mode 100644 crawl-ref/source/map_knowledge.h delete mode 100644 crawl-ref/source/mapcell.h diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc index 398c5b8ff5..126ba384ab 100644 --- a/crawl-ref/source/abyss.cc +++ b/crawl-ref/source/abyss.cc @@ -180,7 +180,7 @@ static void _generate_area(const coord_def& topleft, dungeon_feature_type replaced[5]; // Nuke map. - env.map.init(map_cell()); + env.map_knowledge.init(map_cell()); // Generate level composition vector. for (int i = 0; i < 5; i++) @@ -427,7 +427,7 @@ void area_shift(void) for (radius_iterator ri(you.pos(), LOS_RADIUS); ri; ++ri) { - fprops(you.pos() - *ri + los_delta) = env.map(*ri).property; + fprops(you.pos() - *ri + los_delta) = env.pgrid(*ri); if (env.sanctuary_pos == *ri && env.sanctuary_time > 0) { sanct_pos = *ri - you.pos(); @@ -526,7 +526,7 @@ void area_shift(void) _xom_check_nearness(); for (radius_iterator ri(you.pos(), LOS_RADIUS); ri; ++ri) - env.map(*ri).property = fprops(you.pos() - *ri + los_delta); + env.pgrid(*ri) = fprops(you.pos() - *ri + los_delta); if (sanct_shifted) env.sanctuary_pos = sanct_pos + you.pos(); diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index be571cd77d..3ff8fe146c 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -64,7 +64,8 @@ #include "directn.h" #include "dungeon.h" #include "effects.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "fight.h" #include "files.h" #include "food.h" @@ -3318,7 +3319,7 @@ static void _open_door(coord_def move, bool check_confused) // door! if (is_terrain_seen(dc)) { - set_envmap_obj(dc, DNGN_OPEN_DOOR); + set_map_knowledge_obj(dc, DNGN_OPEN_DOOR); #ifdef USE_TILE env.tile_bk_bg(dc) = TILE_DNGN_OPEN_DOOR; #endif @@ -3478,7 +3479,7 @@ static void _close_door(coord_def move) // want the entire door to be updated. if (is_terrain_seen(dc)) { - set_envmap_obj(dc, DNGN_CLOSED_DOOR); + set_map_knowledge_obj(dc, DNGN_CLOSED_DOOR); #ifdef USE_TILE env.tile_bk_bg(dc) = TILE_DNGN_CLOSED_DOOR; #endif @@ -3549,7 +3550,7 @@ static bool _initialise(void) igrd.init(NON_ITEM); mgrd.init(NON_MONSTER); - env.map.init(map_cell()); + env.map_knowledge.init(map_cell()); you.unique_creatures.init(false); you.unique_items.init(UNIQ_NOT_EXISTS); diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 3218c0ba30..916e47176a 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -33,7 +33,8 @@ #include "dgnevent.h" #include "effects.h" #include "enum.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "fight.h" #include "item_use.h" #include "it_use2.h" @@ -1721,7 +1722,7 @@ void bolt::digging_wall_effect() // Blood does not transfer onto floor. if (is_bloodcovered(pos())) - env.map(pos()).property &= ~(FPROP_BLOODY); + env.pgrid(pos()) &= ~(FPROP_BLOODY); if (!msg_generated) { @@ -1814,7 +1815,7 @@ void bolt::nuke_wall_effect() { // Blood does not transfer onto floor. if (is_bloodcovered(pos())) - env.map(pos()).property &= ~(FPROP_BLOODY); + env.pgrid(pos()) &= ~(FPROP_BLOODY); grd(pos()) = DNGN_FLOOR; if (player_can_hear(pos())) @@ -1829,7 +1830,7 @@ void bolt::nuke_wall_effect() // Blood does not transfer onto floor. if (is_bloodcovered(pos())) - env.map(pos()).property &= ~(FPROP_BLOODY); + env.pgrid(pos()) &= ~(FPROP_BLOODY); if (player_can_hear(pos())) { diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index f1ccd1edcb..fbbeb77e76 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -1289,7 +1289,7 @@ void dump_map(FILE *fp, bool debug) for (int i = X_BOUND_1; i <= X_BOUND_2; i++) for (int j = Y_BOUND_1; j <= Y_BOUND_2; j++) - if (env.map[i][j].known()) + if (env.map_knowledge[i][j].known()) { if (i > max_x) max_x = i; if (i < min_x) min_x = i; @@ -1300,7 +1300,7 @@ void dump_map(FILE *fp, bool debug) for (int y = min_y; y <= max_y; ++y) { for (int x = min_x; x <= max_x; ++x) - fputc( env.map[x][y].glyph(), fp ); + fputc( env.map_knowledge[x][y].glyph(), fp ); fputc('\n', fp); } diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc index 65e6ae3c80..84afecf6e0 100644 --- a/crawl-ref/source/cloud.cc +++ b/crawl-ref/source/cloud.cc @@ -16,7 +16,8 @@ #include "cloud.h" #include "colour.h" #include "coord.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "mapmark.h" #include "ouch.h" #include "player.h" diff --git a/crawl-ref/source/dbg-maps.cc b/crawl-ref/source/dbg-maps.cc index e8f1187da7..cf565712dd 100644 --- a/crawl-ref/source/dbg-maps.cc +++ b/crawl-ref/source/dbg-maps.cc @@ -12,7 +12,8 @@ #include "chardump.h" #include "coord.h" #include "dungeon.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "initfile.h" #include "maps.h" #include "message.h" @@ -59,7 +60,7 @@ static bool _mg_region_flood(const coord_def &c, int region, bool flag) if (flag) { - env.map(c).flags = 0; + env.map_knowledge(c).flags = 0; set_terrain_mapped(c.x, c.y); } @@ -188,7 +189,7 @@ static bool mg_do_build_level(int niters) coord_def c; for (c.y = 0; c.y < GYM; ++c.y) for (c.x = 0; c.x < GXM; ++c.x) - set_envmap_obj(c, grd(c)); + set_map_knowledge_obj(c, grd(c)); dump_map(fp); diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index 09b88514fc..a3b1e8553e 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -22,7 +22,8 @@ #include "describe.h" #include "directn.h" #include "enum.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "exclude.h" #include "food.h" #include "invent.h" diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index f4a9a8d535..d27201f8b4 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -32,7 +32,8 @@ #include "debug.h" #include "describe.h" #include "dungeon.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "initfile.h" #include "invent.h" #include "itemname.h" diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index e9d13706b5..ce6e72487c 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -22,7 +22,8 @@ #include "defines.h" #include "effects.h" #include "enum.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "externs.h" #include "options.h" #include "dbg-maps.h" @@ -961,7 +962,7 @@ void dgn_reset_level() // Blank level with DNGN_ROCK_WALL. grd.init(DNGN_ROCK_WALL); env.grid_colours.init(BLACK); - env.map.init(map_cell()); + env.map_knowledge.init(map_cell()); // Delete all traps. for (int i = 0; i < MAX_TRAPS; i++) @@ -5182,7 +5183,7 @@ static void _replace_area( const coord_def& p1, const coord_def& p2, grd(*ri) = feature; if (needs_update && is_terrain_seen(*ri)) { - set_envmap_obj(*ri, feature); + set_map_knowledge_obj(*ri, feature); #ifdef USE_TILE env.tile_bk_bg(*ri) = feature; #endif @@ -6674,9 +6675,9 @@ static void _labyrinth_add_blood_trail(const dgn_region ®ion) if (path.size() < 10) continue; - env.map(start).property |= FPROP_BLOODY; + env.pgrid(start) |= FPROP_BLOODY; #ifdef WIZARD - env.map(start).property |= FPROP_HIGHLIGHT; + env.pgrid(start) |= FPROP_HIGHLIGHT; #endif bleed_onto_floor(start, MONS_HUMAN, 150, true, false); @@ -6687,10 +6688,10 @@ static void _labyrinth_add_blood_trail(const dgn_region ®ion) if (step < 2 || step < 12 && coinflip() || step >= 12 && one_chance_in(step/4)) { - env.map(pos).property |= FPROP_BLOODY; + env.pgrid(pos) |= FPROP_BLOODY; } #ifdef WIZARD - env.map(pos).property |= FPROP_HIGHLIGHT; + env.pgrid(pos) |= FPROP_HIGHLIGHT; #endif if (step >= 10 && one_chance_in(7)) @@ -6761,14 +6762,14 @@ static void _vitrify_wall_neighbours(const coord_def pos) continue; // Don't vitrify vault grids - if (testbits(env.map(p).property, FPROP_VAULT)) + if (testbits(env.pgrid(p), FPROP_VAULT)) continue; if (grd(p) == DNGN_ROCK_WALL || grd(p) == DNGN_STONE_WALL) { grd(p) = static_cast(grd(p) + clear_plus); #ifdef WIZARD - env.map(p).property |= FPROP_HIGHLIGHT; + env.pgrid(p) |= FPROP_HIGHLIGHT; #endif if (one_chance_in(3) || _grid_has_wall_neighbours(p, dirs[i])) _vitrify_wall_neighbours(p); @@ -6797,7 +6798,7 @@ static void _labyrinth_add_glass_walls(const dgn_region ®ion) grd(pos) = static_cast(grd(pos) + clear_plus); #ifdef WIZARD - env.map(pos).property |= FPROP_HIGHLIGHT; + env.pgrid(pos) |= FPROP_HIGHLIGHT; #endif _vitrify_wall_neighbours(pos); } @@ -8388,7 +8389,7 @@ void vault_placement::apply_grid() dungeon_terrain_changed(*ri, newgrid, true, true); env.markers.remove_markers_at(*ri, MAT_ANY); } - env.map(*ri).property |= FPROP_VAULT; + env.pgrid(*ri) |= FPROP_VAULT; } map.map.apply_overlays(pos); diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index feabc71add..1c1f87e35c 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -27,7 +27,8 @@ #include "delay.h" #include "directn.h" #include "dgnevent.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "food.h" #include "hiscores.h" #include "invent.h" @@ -3112,7 +3113,7 @@ void change_labyrinth(bool msg) continue; // Skip on grids inside vaults so as not to disrupt them. - if (testbits(env.map(*ri).property, FPROP_VAULT)) + if (testbits(env.pgrid(*ri), FPROP_VAULT)) continue; // Make sure we don't accidentally create "ugly" dead-ends. @@ -3153,7 +3154,7 @@ void change_labyrinth(bool msg) #ifdef WIZARD // Remove old highlighted areas to make place for the new ones. for (rectangle_iterator ri(1); ri; ++ri) - env.map(*ri).property &= ~(FPROP_HIGHLIGHT); + env.pgrid(*ri) &= ~(FPROP_HIGHLIGHT); #endif // How many switches we'll be doing. @@ -3254,8 +3255,8 @@ void change_labyrinth(bool msg) } #ifdef WIZARD // Highlight the switched grids. - env.map(c).property |= FPROP_HIGHLIGHT; - env.map(p).property |= FPROP_HIGHLIGHT; + env.pgrid(c) |= FPROP_HIGHLIGHT; + env.pgrid(p) |= FPROP_HIGHLIGHT; #endif // Shift blood some of the time. @@ -3271,15 +3272,15 @@ void change_labyrinth(bool msg) if (old_adj != c && !is_bloodcovered(old_adj)) { - env.map(old_adj).property |= FPROP_BLOODY; - env.map(c).property &= (~FPROP_BLOODY); + env.pgrid(old_adj) |= FPROP_BLOODY; + env.pgrid(c) &= (~FPROP_BLOODY); } } } else if (one_chance_in(500)) { // Rarely add blood randomly, accumulating with time... - env.map(c).property |= FPROP_BLOODY; + env.pgrid(c) |= FPROP_BLOODY; } // Rather than use old_grid directly, replace with an adjacent @@ -3323,15 +3324,15 @@ void change_labyrinth(bool msg) if (new_adj != p && !is_bloodcovered(new_adj)) { - env.map(new_adj).property |= FPROP_BLOODY; - env.map(p).property &= (~FPROP_BLOODY); + env.pgrid(new_adj) |= FPROP_BLOODY; + env.pgrid(p) &= (~FPROP_BLOODY); } } } else if (one_chance_in(100)) { // Occasionally add blood randomly, accumulating with time... - env.map(p).property |= FPROP_BLOODY; + env.pgrid(p) |= FPROP_BLOODY; } } @@ -4251,16 +4252,16 @@ static void _maybe_restart_fountain_flow(const coord_def& where, - (DNGN_DRY_FOUNTAIN_BLUE - DNGN_FOUNTAIN_BLUE)); if (is_terrain_seen(where)) - set_envmap_obj(where, grd(where)); + set_map_knowledge_obj(where, grd(where)); // Clean bloody floor. if (is_bloodcovered(where)) - env.map(where).property &= ~(FPROP_BLOODY); + env.pgrid(where) &= ~(FPROP_BLOODY); // Chance of cleaning adjacent squares. for (adjacent_iterator ai(where); ai; ++ai) if (is_bloodcovered(*ai) && one_chance_in(5)) - env.map(*ai).property &= ~(FPROP_BLOODY); + env.pgrid(*ai) &= ~(FPROP_BLOODY); break; } diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 8229e7aa17..4cfbd9030b 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -879,20 +879,6 @@ enum level_flag_type LFLAG_NO_MAGIC_MAP = (1 << 2) // Level can't be magic mapped. }; -enum feature_property_type -{ - FPROP_NONE = 0, - FPROP_SANCTUARY_1 = (1 << 0), - FPROP_SANCTUARY_2 = (1 << 2), - FPROP_BLOODY = (1 << 3), - FPROP_VAULT = (1 << 4), - FPROP_HIGHLIGHT = (1 << 5), // Highlight grids on the X map for debugging. - // NOTE: Bloody floor and sanctuary are exclusive. - FPROP_FORCE_EXCLUDE = (1 << 6), - FPROP_NO_CLOUD_GEN = (1 << 7), - FPROP_NO_RTELE_INTO = (1 << 8) -}; - // NOTE: The order of these is very important to their usage! // [dshaligram] If adding/removing from this list, also update view.cc! enum dungeon_char_type diff --git a/crawl-ref/source/env.h b/crawl-ref/source/env.h index ff51dbe2cb..85bb53ad6b 100644 --- a/crawl-ref/source/env.h +++ b/crawl-ref/source/env.h @@ -1,7 +1,7 @@ #ifndef ENV_H #define ENV_H -#include "mapcell.h" +#include "map_knowledge.h" #include "monster.h" #include "show.h" @@ -17,12 +17,14 @@ public: FixedVector< monsters, MAX_MONSTERS > mons; // monster list feature_grid grid; // terrain grid + FixedArray< unsigned long, GXM, GYM > pgrid; // terrain properties FixedArray< unsigned short, GXM, GYM > mgrid; // monster grid FixedArray< int, GXM, GYM > igrid; // item grid FixedArray< unsigned short, GXM, GYM > cgrid; // cloud grid FixedArray< unsigned short, GXM, GYM > grid_colours; // colour overrides - FixedArray< map_cell, GXM, GYM > map; // discovered terrain + // Player-remembered terrain. TODO: move to class player. + FixedArray< map_cell, GXM, GYM > map_knowledge; // Objects that are in LOS, used for drawing. show_def show; diff --git a/crawl-ref/source/envmap.cc b/crawl-ref/source/envmap.cc deleted file mode 100644 index b52a7dfea0..0000000000 --- a/crawl-ref/source/envmap.cc +++ /dev/null @@ -1,331 +0,0 @@ -/* - * File: envmap.cc - * Summary: Functions dealing with env.map. - */ - -#include "AppHdr.h" - -#include "envmap.h" - -#include "coord.h" -#include "coordit.h" -#include "dgnevent.h" -#include "directn.h" -#include "env.h" -#include "notes.h" -#include "overmap.h" -#include "showsymb.h" -#include "stuff.h" -#include "terrain.h" -#include "view.h" - -// These are hidden from the rest of the world... use the functions -// below to get information about the map grid. -#define MAP_MAGIC_MAPPED_FLAG 0x01 -#define MAP_SEEN_FLAG 0x02 -#define MAP_CHANGED_FLAG 0x04 -#define MAP_DETECTED_MONSTER 0x08 -#define MAP_DETECTED_ITEM 0x10 -#define MAP_GRID_KNOWN 0xFF - -unsigned map_cell::glyph() const -{ - if (!object) - return (' '); - return get_symbol(object, NULL, !(flags & MAP_SEEN_FLAG)); -} - -bool map_cell::known() const -{ - return (object && (flags & MAP_GRID_KNOWN)); -} - -bool map_cell::seen() const -{ - return (object && (flags & MAP_SEEN_FLAG)); -} - -unsigned get_envmap_char(int x, int y) -{ - return env.map[x][y].glyph(); -} - -show_type get_envmap_obj(int x, int y) -{ - return (env.map[x][y].object); -} - -void set_envmap_detected_item(int x, int y, bool detected) -{ - if (detected) - env.map[x][y].flags |= MAP_DETECTED_ITEM; - else - env.map[x][y].flags &= ~MAP_DETECTED_ITEM; -} - -bool is_envmap_detected_item(int x, int y) -{ - return (env.map[x][y].flags & MAP_DETECTED_ITEM); -} - -void set_envmap_detected_mons(int x, int y, bool detected) -{ - if (detected) - env.map[x][y].flags |= MAP_DETECTED_MONSTER; - else - env.map[x][y].flags &= ~MAP_DETECTED_MONSTER; -} - -bool is_envmap_detected_mons(int x, int y) -{ - return (env.map[x][y].flags & MAP_DETECTED_MONSTER); -} - -void set_envmap_glyph(int x, int y, show_type object, int col) -{ - map_cell &c = env.map[x][y]; - c.object = object; - c.colour = col; -#ifdef USE_TILE - tiles.update_minimap(x, y); -#endif -} - -void set_envmap_glyph(const coord_def& c, show_type object, int col) -{ - set_envmap_glyph(c.x, c.y, object, col); -} - -void set_envmap_obj(const coord_def& where, show_type obj) -{ - env.map(where).object = obj; -#ifdef USE_TILE - tiles.update_minimap(where.x, where.y); -#endif -} - -void set_envmap_col( int x, int y, int colour ) -{ - env.map[x][y].colour = colour; -} - -bool is_sanctuary(const coord_def& p) -{ - if (!map_bounds(p)) - return (false); - return (testbits(env.map(p).property, FPROP_SANCTUARY_1) - || testbits(env.map(p).property, FPROP_SANCTUARY_2)); -} - -bool is_bloodcovered(const coord_def& p) -{ - return (testbits(env.map(p).property, FPROP_BLOODY)); -} - -bool is_envmap_item(int x, int y) -{ - return (env.map[x][y].object.cls == SH_ITEM); -} - -bool is_envmap_mons(int x, int y) -{ - return (env.map[x][y].object.cls == SH_MONSTER); -} - -int get_envmap_col(const coord_def& p) -{ - return (env.map[p.x][p.y].colour); -} - -bool is_terrain_known( int x, int y ) -{ - return (env.map[x][y].known()); -} - -bool is_terrain_known(const coord_def &p) -{ - return (env.map(p).known()); -} - -bool is_terrain_seen( int x, int y ) -{ - return (env.map[x][y].flags & MAP_SEEN_FLAG); -} - -bool is_terrain_changed( int x, int y ) -{ - return (env.map[x][y].flags & MAP_CHANGED_FLAG); -} - -bool is_terrain_mapped(const coord_def &p) -{ - return (env.map(p).flags & MAP_MAGIC_MAPPED_FLAG); -} - -// Used to mark dug out areas, unset when terrain is seen or mapped again. -void set_terrain_changed( int x, int y ) -{ - env.map[x][y].flags |= MAP_CHANGED_FLAG; - - dungeon_events.fire_position_event(DET_FEAT_CHANGE, coord_def(x, y)); -} - -void set_terrain_mapped( int x, int y ) -{ - env.map[x][y].flags &= (~MAP_CHANGED_FLAG); - env.map[x][y].flags |= MAP_MAGIC_MAPPED_FLAG; -#ifdef USE_TILE - tiles.update_minimap(x, y); -#endif -} - -int count_detected_mons() -{ - int count = 0; - for (rectangle_iterator ri(BOUNDARY_BORDER - 1); ri; ++ri) - { - // Don't expose new dug out areas: - // Note: assumptions are being made here about how - // terrain can change (eg it used to be solid, and - // thus monster/item free). - if (is_terrain_changed(*ri)) - continue; - - if (is_envmap_detected_mons(*ri)) - count++; - } - - return (count); -} - -void clear_map(bool clear_detected_items, bool clear_detected_monsters) -{ - for (rectangle_iterator ri(BOUNDARY_BORDER - 1); ri; ++ri) - { - const coord_def p = *ri; - // Don't expose new dug out areas: - // Note: assumptions are being made here about how - // terrain can change (eg it used to be solid, and - // thus monster/item free). - - // This reasoning doesn't make sense when it comes to *clearing* - // the map! (jpeg) - - if (get_envmap_char(p) == 0) - continue; - - if (is_envmap_item(p)) - continue; - - if (!clear_detected_items && is_envmap_detected_item(p)) - continue; - - if (!clear_detected_monsters && is_envmap_detected_mons(p)) - continue; - -#ifdef USE_TILE - if (is_terrain_mapped(p) && !is_envmap_detected_mons(p)) - continue; -#endif - - set_envmap_obj(p, show_type(is_terrain_seen(p) || is_terrain_mapped(p) - ? grd(p) : DNGN_UNSEEN)); - set_envmap_detected_mons(p, false); - set_envmap_detected_item(p, false); - -#ifdef USE_TILE - if (is_terrain_mapped(p)) - { - dungeon_feature_type feature = grd(p); - - unsigned int feat_symbol; - unsigned short feat_colour; - get_show_symbol(show_type(feature), &feat_symbol, &feat_colour); - - unsigned int fg; - unsigned int bg; - tileidx_unseen(fg, bg, feat_symbol, p); - env.tile_bk_bg(p) = bg; - env.tile_bk_fg(p) = fg; - } - else - { - env.tile_bk_bg(p) = is_terrain_seen(p) ? - tile_idx_unseen_terrain(p.x, p.y, grd(p)) : - tileidx_feature(DNGN_UNSEEN, p.x, p.y); - env.tile_bk_fg(p) = 0; - } -#endif - } -} - -static void _automap_from( int x, int y, int mutated ) -{ - if (mutated) - magic_mapping(8 * mutated, 25, true, false, - true, true, coord_def(x,y)); -} - -void reautomap_level( ) -{ - int passive = player_mutation_level(MUT_PASSIVE_MAPPING); - - for (int x = X_BOUND_1; x <= X_BOUND_2; ++x) - for (int y = Y_BOUND_1; y <= Y_BOUND_2; ++y) - if (env.map[x][y].flags & MAP_SEEN_FLAG) - _automap_from(x, y, passive); -} - -void set_terrain_seen( int x, int y ) -{ - const dungeon_feature_type feat = grd[x][y]; - - // First time we've seen a notable feature. - if (!(env.map[x][y].flags & MAP_SEEN_FLAG)) - { - _automap_from(x, y, player_mutation_level(MUT_PASSIVE_MAPPING)); - - const bool boring = !is_notable_terrain(feat) - // A portal deeper into the Zigguart is boring. - || (feat == DNGN_ENTER_PORTAL_VAULT - && you.level_type == LEVEL_PORTAL_VAULT) - // Altars in the temple are boring. - || (feat_is_altar(feat) - && player_in_branch(BRANCH_ECUMENICAL_TEMPLE)) - // Only note the first entrance to the Abyss/Pan/Hell - // which is found. - || ((feat == DNGN_ENTER_ABYSS || feat == DNGN_ENTER_PANDEMONIUM - || feat == DNGN_ENTER_HELL) - && overmap_knows_num_portals(feat) > 1) - // There are at least three Zot entrances, and they're always - // on D:27, so ignore them. - || feat == DNGN_ENTER_ZOT; - - if (!boring) - { - coord_def pos(x, y); - std::string desc = - feature_description(pos, false, DESC_NOCAP_A); - - take_note(Note(NOTE_SEEN_FEAT, 0, 0, desc.c_str())); - } - } - -#ifdef USE_TILE - env.map[x][y].flags &= ~(MAP_DETECTED_ITEM); - env.map[x][y].flags &= ~(MAP_DETECTED_MONSTER); -#endif - - env.map[x][y].flags &= (~MAP_CHANGED_FLAG); - env.map[x][y].flags |= MAP_SEEN_FLAG; -} - -void clear_envmap_grid( const coord_def& p ) -{ - env.map(p).clear(); -} - -void clear_envmap_grid( int x, int y ) -{ - env.map[x][y].clear(); -} diff --git a/crawl-ref/source/envmap.h b/crawl-ref/source/envmap.h deleted file mode 100644 index f7352eab8d..0000000000 --- a/crawl-ref/source/envmap.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef ENVMAP_H -#define ENVMAP_H - -#include "show.h" - -struct coord_def; - -void set_envmap_obj(const coord_def& where, show_type object); -unsigned get_envmap_char(int x, int y); -inline unsigned get_envmap_char(const coord_def& c) { - return get_envmap_char(c.x, c.y); -} -show_type get_envmap_obj(int x, int y); -inline show_type get_envmap_obj(const coord_def& c) { - return get_envmap_obj(c.x, c.y); -} -void set_envmap_detected_item(int x, int y, bool detected = true); -inline void set_envmap_detected_item(const coord_def& c, bool detected = true) { - set_envmap_detected_item(c.x, c.y, detected); -} - -void set_envmap_detected_mons(int x, int y, bool detected = true); -inline void set_envmap_detected_mons(const coord_def& c, bool detected = true) { - set_envmap_detected_mons(c.x, c.y, detected); -} -void set_envmap_col( int x, int y, int colour, int flags ); -void set_envmap_col( int x, int y, int colour ); -bool is_sanctuary( const coord_def& p ); -bool is_bloodcovered( const coord_def& p ); - -bool is_envmap_detected_item(int x, int y); -inline bool is_envmap_detected_item(const coord_def& c) { - return is_envmap_detected_item(c.x, c.y); -} - -bool is_envmap_detected_mons(int x, int y); -inline bool is_envmap_detected_mons(const coord_def& c) { - return is_envmap_detected_mons(c.x, c.y); -} -bool is_envmap_item(int x, int y); -inline bool is_envmap_item(const coord_def& c) { - return is_envmap_item(c.x, c.y); -} -void set_terrain_mapped( int x, int y ); -inline void set_terrain_mapped( const coord_def& c ) { - set_terrain_mapped(c.x,c.y); -} -void set_terrain_seen( int x, int y ); -inline void set_terrain_seen( const coord_def& c ) { - set_terrain_seen(c.x, c.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 ); -inline bool is_terrain_changed( const coord_def& c ) { - return is_terrain_changed(c.x,c.y); -} -bool is_terrain_known(const coord_def &p); -bool is_terrain_mapped(const coord_def &p); -bool is_notable_terrain(dungeon_feature_type ftype); - -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); -} - -int count_detected_mons(void); -void clear_map(bool clear_items = true, bool clear_mons = true); - -int get_envmap_col(const coord_def& p); - -void set_envmap_glyph(const coord_def& c, show_type object, int col); - -void clear_envmap_grid(const coord_def& p); - -#endif - diff --git a/crawl-ref/source/exclude.cc b/crawl-ref/source/exclude.cc index 228a8fcf67..6fbd185e11 100644 --- a/crawl-ref/source/exclude.cc +++ b/crawl-ref/source/exclude.cc @@ -8,7 +8,8 @@ #include "exclude.h" #include "coord.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "mon-util.h" #include "options.h" #include "overmap.h" @@ -96,8 +97,8 @@ struct opacity_excl : opacity_func return OPC_CLEAR; else if (!is_terrain_changed(p)) return _feat_opacity(env.grid(p)); - else if (env.map(p).object.cls == SH_FEATURE) - return _feat_opacity(env.map(p).object.feat); + else if (env.map_knowledge(p).object.cls == SH_FEATURE) + return _feat_opacity(env.map_knowledge(p).object.feat); else { // If you have seen monsters, items or clouds there, diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 7403f3c3f6..e3086a1f90 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -28,7 +28,8 @@ #include "debug.h" #include "delay.h" #include "effects.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "food.h" #include "goditem.h" #include "invent.h" diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 38673237d8..a9c5484777 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -1014,7 +1014,7 @@ static void _close_level_gates() static void _clear_env_map() { - env.map.init(map_cell()); + env.map_knowledge.init(map_cell()); } static void _clear_clouds() diff --git a/crawl-ref/source/fprop.cc b/crawl-ref/source/fprop.cc new file mode 100644 index 0000000000..50023409d0 --- /dev/null +++ b/crawl-ref/source/fprop.cc @@ -0,0 +1,25 @@ +/* + * File: envmap.cc + * Summary: Functions dealing with env.map_knowledge. + */ + +#include "AppHdr.h" + +#include "fprop.h" + +#include "coord.h" +#include "env.h" +#include "stuff.h" + +bool is_sanctuary(const coord_def& p) +{ + if (!map_bounds(p)) + return (false); + return (testbits(env.pgrid(p), FPROP_SANCTUARY_1) + || testbits(env.pgrid(p), FPROP_SANCTUARY_2)); +} + +bool is_bloodcovered(const coord_def& p) +{ + return (testbits(env.pgrid(p), FPROP_BLOODY)); +} diff --git a/crawl-ref/source/fprop.h b/crawl-ref/source/fprop.h new file mode 100644 index 0000000000..cd8abcf51e --- /dev/null +++ b/crawl-ref/source/fprop.h @@ -0,0 +1,23 @@ +#ifndef FPROP_H +#define FPROP_H + +struct coord_def; + +bool is_sanctuary( const coord_def& p ); +bool is_bloodcovered( const coord_def& p ); + +enum feature_property_type +{ + FPROP_NONE = 0, + FPROP_SANCTUARY_1 = (1 << 0), + FPROP_SANCTUARY_2 = (1 << 2), + FPROP_BLOODY = (1 << 3), + FPROP_VAULT = (1 << 4), + FPROP_HIGHLIGHT = (1 << 5), // Highlight grids on the X map for debugging. + // NOTE: Bloody floor and sanctuary are exclusive. + FPROP_FORCE_EXCLUDE = (1 << 6), + FPROP_NO_CLOUD_GEN = (1 << 7), + FPROP_NO_RTELE_INTO = (1 << 8) +}; + +#endif diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 85b3105c38..8908f11765 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -22,6 +22,7 @@ #include "directn.h" #include "kills.h" #include "files.h" +#include "fprop.h" #include "defines.h" #ifdef USE_TILE #include "tilereg.h" diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 6bcfb9a3ac..b4d0457fd2 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -28,7 +28,8 @@ #include "describe.h" #include "directn.h" #include "effects.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "fight.h" #include "food.h" #include "godabil.h" diff --git a/crawl-ref/source/l_debug.cc b/crawl-ref/source/l_debug.cc index 1e788c2478..1e961152fa 100644 --- a/crawl-ref/source/l_debug.cc +++ b/crawl-ref/source/l_debug.cc @@ -45,7 +45,7 @@ LUAFN(debug_flush_map_memory) LUAFN(debug_generate_level) { no_messages mx; - env.map.init(map_cell()); + env.map_knowledge.init(map_cell()); #ifdef USE_TILE tile_init_default_flavour(); tile_clear_flavour(); diff --git a/crawl-ref/source/makefile.obj b/crawl-ref/source/makefile.obj index 30e1a78ab0..a7d3f4dd6f 100644 --- a/crawl-ref/source/makefile.obj +++ b/crawl-ref/source/makefile.obj @@ -34,13 +34,13 @@ directn.o \ dlua.o \ dungeon.o \ effects.o \ -envmap.o \ exclude.o \ feature.o \ fight.o \ files.o \ food.o \ format.o \ +fprop.o \ geom2d.o \ ghost.o \ godabil.o \ @@ -88,6 +88,7 @@ losparam.o \ luaterp.o \ macro.o \ makeitem.o \ +map_knowledge.o \ mapdef.o \ mapmark.o \ maps.o \ diff --git a/crawl-ref/source/map_knowledge.cc b/crawl-ref/source/map_knowledge.cc new file mode 100644 index 0000000000..0e04f7046c --- /dev/null +++ b/crawl-ref/source/map_knowledge.cc @@ -0,0 +1,313 @@ +#include "AppHdr.h" + +#include "map_knowledge.h" + +#include "coord.h" +#include "coordit.h" +#include "dgnevent.h" +#include "directn.h" +#include "env.h" +#include "notes.h" +#include "overmap.h" +#include "showsymb.h" +#include "stuff.h" +#include "terrain.h" +#include "view.h" + +// These are hidden from the rest of the world... use the functions +// below to get information about the map grid. +#define MAP_MAGIC_MAPPED_FLAG 0x01 +#define MAP_SEEN_FLAG 0x02 +#define MAP_CHANGED_FLAG 0x04 +#define MAP_DETECTED_MONSTER 0x08 +#define MAP_DETECTED_ITEM 0x10 +#define MAP_GRID_KNOWN 0xFF + +unsigned map_cell::glyph() const +{ + if (!object) + return (' '); + return get_symbol(object, NULL, !(flags & MAP_SEEN_FLAG)); +} + +bool map_cell::known() const +{ + return (object && (flags & MAP_GRID_KNOWN)); +} + +bool map_cell::seen() const +{ + return (object && (flags & MAP_SEEN_FLAG)); +} + +unsigned get_map_knowledge_char(int x, int y) +{ + return env.map_knowledge[x][y].glyph(); +} + +show_type get_map_knowledge_obj(int x, int y) +{ + return (env.map_knowledge[x][y].object); +} + +void set_map_knowledge_detected_item(int x, int y, bool detected) +{ + if (detected) + env.map_knowledge[x][y].flags |= MAP_DETECTED_ITEM; + else + env.map_knowledge[x][y].flags &= ~MAP_DETECTED_ITEM; +} + +bool is_map_knowledge_detected_item(int x, int y) +{ + return (env.map_knowledge[x][y].flags & MAP_DETECTED_ITEM); +} + +void set_map_knowledge_detected_mons(int x, int y, bool detected) +{ + if (detected) + env.map_knowledge[x][y].flags |= MAP_DETECTED_MONSTER; + else + env.map_knowledge[x][y].flags &= ~MAP_DETECTED_MONSTER; +} + +bool is_map_knowledge_detected_mons(int x, int y) +{ + return (env.map_knowledge[x][y].flags & MAP_DETECTED_MONSTER); +} + +void set_map_knowledge_glyph(int x, int y, show_type object, int col) +{ + map_cell &c = env.map_knowledge[x][y]; + c.object = object; + c.colour = col; +#ifdef USE_TILE + tiles.update_minimap(x, y); +#endif +} + +void set_map_knowledge_glyph(const coord_def& c, show_type object, int col) +{ + set_map_knowledge_glyph(c.x, c.y, object, col); +} + +void set_map_knowledge_obj(const coord_def& where, show_type obj) +{ + env.map_knowledge(where).object = obj; +#ifdef USE_TILE + tiles.update_minimap(where.x, where.y); +#endif +} + +void set_map_knowledge_col( int x, int y, int colour ) +{ + env.map_knowledge[x][y].colour = colour; +} + +bool is_map_knowledge_item(int x, int y) +{ + return (env.map_knowledge[x][y].object.cls == SH_ITEM); +} + +bool is_map_knowledge_mons(int x, int y) +{ + return (env.map_knowledge[x][y].object.cls == SH_MONSTER); +} + +int get_map_knowledge_col(const coord_def& p) +{ + return (env.map_knowledge[p.x][p.y].colour); +} + +bool is_terrain_known( int x, int y ) +{ + return (env.map_knowledge[x][y].known()); +} + +bool is_terrain_known(const coord_def &p) +{ + return (env.map_knowledge(p).known()); +} + +bool is_terrain_seen( int x, int y ) +{ + return (env.map_knowledge[x][y].flags & MAP_SEEN_FLAG); +} + +bool is_terrain_changed( int x, int y ) +{ + return (env.map_knowledge[x][y].flags & MAP_CHANGED_FLAG); +} + +bool is_terrain_mapped(const coord_def &p) +{ + return (env.map_knowledge(p).flags & MAP_MAGIC_MAPPED_FLAG); +} + +// Used to mark dug out areas, unset when terrain is seen or mapped again. +void set_terrain_changed( int x, int y ) +{ + env.map_knowledge[x][y].flags |= MAP_CHANGED_FLAG; + + dungeon_events.fire_position_event(DET_FEAT_CHANGE, coord_def(x, y)); +} + +void set_terrain_mapped( int x, int y ) +{ + env.map_knowledge[x][y].flags &= (~MAP_CHANGED_FLAG); + env.map_knowledge[x][y].flags |= MAP_MAGIC_MAPPED_FLAG; +#ifdef USE_TILE + tiles.update_minimap(x, y); +#endif +} + +int count_detected_mons() +{ + int count = 0; + for (rectangle_iterator ri(BOUNDARY_BORDER - 1); ri; ++ri) + { + // Don't expose new dug out areas: + // Note: assumptions are being made here about how + // terrain can change (eg it used to be solid, and + // thus monster/item free). + if (is_terrain_changed(*ri)) + continue; + + if (is_map_knowledge_detected_mons(*ri)) + count++; + } + + return (count); +} + +void clear_map(bool clear_detected_items, bool clear_detected_monsters) +{ + for (rectangle_iterator ri(BOUNDARY_BORDER - 1); ri; ++ri) + { + const coord_def p = *ri; + // Don't expose new dug out areas: + // Note: assumptions are being made here about how + // terrain can change (eg it used to be solid, and + // thus monster/item free). + + // This reasoning doesn't make sense when it comes to *clearing* + // the map! (jpeg) + + if (get_map_knowledge_char(p) == 0) + continue; + + if (is_map_knowledge_item(p)) + continue; + + if (!clear_detected_items && is_map_knowledge_detected_item(p)) + continue; + + if (!clear_detected_monsters && is_map_knowledge_detected_mons(p)) + continue; + +#ifdef USE_TILE + if (is_terrain_mapped(p) && !is_map_knowledge_detected_mons(p)) + continue; +#endif + + set_map_knowledge_obj(p, show_type(is_terrain_seen(p) || is_terrain_mapped(p) + ? grd(p) : DNGN_UNSEEN)); + set_map_knowledge_detected_mons(p, false); + set_map_knowledge_detected_item(p, false); + +#ifdef USE_TILE + if (is_terrain_mapped(p)) + { + dungeon_feature_type feature = grd(p); + + unsigned int feat_symbol; + unsigned short feat_colour; + get_show_symbol(show_type(feature), &feat_symbol, &feat_colour); + + unsigned int fg; + unsigned int bg; + tileidx_unseen(fg, bg, feat_symbol, p); + env.tile_bk_bg(p) = bg; + env.tile_bk_fg(p) = fg; + } + else + { + env.tile_bk_bg(p) = is_terrain_seen(p) ? + tile_idx_unseen_terrain(p.x, p.y, grd(p)) : + tileidx_feature(DNGN_UNSEEN, p.x, p.y); + env.tile_bk_fg(p) = 0; + } +#endif + } +} + +static void _automap_from( int x, int y, int mutated ) +{ + if (mutated) + magic_mapping(8 * mutated, 25, true, false, + true, true, coord_def(x,y)); +} + +void reautomap_level( ) +{ + int passive = player_mutation_level(MUT_PASSIVE_MAPPING); + + for (int x = X_BOUND_1; x <= X_BOUND_2; ++x) + for (int y = Y_BOUND_1; y <= Y_BOUND_2; ++y) + if (env.map_knowledge[x][y].flags & MAP_SEEN_FLAG) + _automap_from(x, y, passive); +} + +void set_terrain_seen( int x, int y ) +{ + const dungeon_feature_type feat = grd[x][y]; + + // First time we've seen a notable feature. + if (!(env.map_knowledge[x][y].flags & MAP_SEEN_FLAG)) + { + _automap_from(x, y, player_mutation_level(MUT_PASSIVE_MAPPING)); + + const bool boring = !is_notable_terrain(feat) + // A portal deeper into the Zigguart is boring. + || (feat == DNGN_ENTER_PORTAL_VAULT + && you.level_type == LEVEL_PORTAL_VAULT) + // Altars in the temple are boring. + || (feat_is_altar(feat) + && player_in_branch(BRANCH_ECUMENICAL_TEMPLE)) + // Only note the first entrance to the Abyss/Pan/Hell + // which is found. + || ((feat == DNGN_ENTER_ABYSS || feat == DNGN_ENTER_PANDEMONIUM + || feat == DNGN_ENTER_HELL) + && overmap_knows_num_portals(feat) > 1) + // There are at least three Zot entrances, and they're always + // on D:27, so ignore them. + || feat == DNGN_ENTER_ZOT; + + if (!boring) + { + coord_def pos(x, y); + std::string desc = + feature_description(pos, false, DESC_NOCAP_A); + + take_note(Note(NOTE_SEEN_FEAT, 0, 0, desc.c_str())); + } + } + +#ifdef USE_TILE + env.map_knowledge[x][y].flags &= ~(MAP_DETECTED_ITEM); + env.map_knowledge[x][y].flags &= ~(MAP_DETECTED_MONSTER); +#endif + + env.map_knowledge[x][y].flags &= (~MAP_CHANGED_FLAG); + env.map_knowledge[x][y].flags |= MAP_SEEN_FLAG; +} + +void clear_map_knowledge_grid( const coord_def& p ) +{ + env.map_knowledge(p).clear(); +} + +void clear_map_knowledge_grid( int x, int y ) +{ + env.map_knowledge[x][y].clear(); +} diff --git a/crawl-ref/source/map_knowledge.h b/crawl-ref/source/map_knowledge.h new file mode 100644 index 0000000000..4c9a6954f9 --- /dev/null +++ b/crawl-ref/source/map_knowledge.h @@ -0,0 +1,96 @@ +#ifndef MAP_KNOWLEDGE_H +#define MAP_KNOWLEDGE_H + +#include "show.h" + +/* + * A map_cell stores what the player knows about a cell. + * These go in env.map_knowledge_knowledge. + */ +struct map_cell +{ + show_type object; // The object: monster, item, feature, or cloud. + unsigned short flags; // Flags describing the mappedness of this square. + unsigned short colour; + + map_cell() : object(), flags(0), colour(0) { } + void clear() { flags = colour = 0; object = show_type(); } + + unsigned glyph() const; + bool known() const; + bool seen() const; +}; + +void set_map_knowledge_obj(const coord_def& where, show_type object); +unsigned get_map_knowledge_char(int x, int y); +inline unsigned get_map_knowledge_char(const coord_def& c) { + return get_map_knowledge_char(c.x, c.y); +} +show_type get_map_knowledge_obj(int x, int y); +inline show_type get_map_knowledge_obj(const coord_def& c) { + return get_map_knowledge_obj(c.x, c.y); +} +void set_map_knowledge_detected_item(int x, int y, bool detected = true); +inline void set_map_knowledge_detected_item(const coord_def& c, bool detected = true) { + set_map_knowledge_detected_item(c.x, c.y, detected); +} + +void set_map_knowledge_detected_mons(int x, int y, bool detected = true); +inline void set_map_knowledge_detected_mons(const coord_def& c, bool detected = true) { + set_map_knowledge_detected_mons(c.x, c.y, detected); +} +void set_map_knowledge_col( int x, int y, int colour, int flags ); +void set_map_knowledge_col( int x, int y, int colour ); + +bool is_map_knowledge_detected_item(int x, int y); +inline bool is_map_knowledge_detected_item(const coord_def& c) { + return is_map_knowledge_detected_item(c.x, c.y); +} + +bool is_map_knowledge_detected_mons(int x, int y); +inline bool is_map_knowledge_detected_mons(const coord_def& c) { + return is_map_knowledge_detected_mons(c.x, c.y); +} +bool is_map_knowledge_item(int x, int y); +inline bool is_map_knowledge_item(const coord_def& c) { + return is_map_knowledge_item(c.x, c.y); +} +void set_terrain_mapped( int x, int y ); +inline void set_terrain_mapped( const coord_def& c ) { + set_terrain_mapped(c.x,c.y); +} +void set_terrain_seen( int x, int y ); +inline void set_terrain_seen( const coord_def& c ) { + set_terrain_seen(c.x, c.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 ); +inline bool is_terrain_changed( const coord_def& c ) { + return is_terrain_changed(c.x,c.y); +} +bool is_terrain_known(const coord_def &p); +bool is_terrain_mapped(const coord_def &p); +bool is_notable_terrain(dungeon_feature_type ftype); + +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); +} + +int count_detected_mons(void); +void clear_map(bool clear_items = true, bool clear_mons = true); + +int get_map_knowledge_col(const coord_def& p); + +void set_map_knowledge_glyph(const coord_def& c, show_type object, int col); + +void clear_map_knowledge_grid(const coord_def& p); + +#endif diff --git a/crawl-ref/source/mapcell.h b/crawl-ref/source/mapcell.h deleted file mode 100644 index 336735a911..0000000000 --- a/crawl-ref/source/mapcell.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef MAPCELL_H -#define MAPCELL_H - -#include "show.h" - -/* - * A map_cell stores what the player knows about a cell. - * These go in env.map. - * - * TODO: Remove property -- that should go in env.grid. - */ - -struct map_cell -{ - show_type object; // The object: monster, item, feature, or cloud. - unsigned short flags; // Flags describing the mappedness of this square. - unsigned short colour; - unsigned long property; // Flags for blood, sanctuary, ... - - map_cell() : object(), flags(0), colour(0), property(0) { } - void clear() { flags = colour = 0; object = show_type(); } - - unsigned glyph() const; - bool known() const; - bool seen() const; -}; - -#endif - diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index d047238bf6..a9bff3cf52 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -493,7 +493,7 @@ void map_lines::apply_grid_overlay(const coord_def &c) set_exclude(gc, 0, false, true); else if (property >= FPROP_BLOODY) // Over-ride whatever property is already there. - env.map(gc).property |= property; + env.pgrid(gc) |= property; #ifdef USE_TILE const int floor = (*overlay)(x, y).floortile; if (floor) diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h index a94eaeab65..c70c16cece 100644 --- a/crawl-ref/source/mapdef.h +++ b/crawl-ref/source/mapdef.h @@ -20,6 +20,7 @@ #include "enum.h" #include "externs.h" #include "fixary.h" +#include "fprop.h" #include "makeitem.h" #include "stuff.h" #include "travel.h" diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 3c96ec0319..39271c1592 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -43,7 +43,8 @@ #include "dgnevent.h" #include "directn.h" #include "dungeon.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "fight.h" #include "files.h" #include "food.h" @@ -1107,7 +1108,7 @@ static void _maybe_bloodify_square(const coord_def& where, int amount, where.x, where.y, amount); #endif if (allow_bleeding_on_square(where)) - env.map(where).property |= FPROP_BLOODY; + env.pgrid(where) |= FPROP_BLOODY; if (smell_alert) blood_smell(12, where); @@ -1194,7 +1195,7 @@ static void _spatter_neighbours(const coord_def& where, int chance) if (one_chance_in(chance)) { - env.map(*ai).property |= FPROP_BLOODY; + env.pgrid(*ai) |= FPROP_BLOODY; _spatter_neighbours(*ai, chance+1); } } @@ -1234,7 +1235,7 @@ void generate_random_blood_spatter_on_level() startprob = min_prob + random2(max_prob); if (allow_bleeding_on_square(c)) - env.map(c).property |= FPROP_BLOODY; + env.pgrid(c) |= FPROP_BLOODY; _spatter_neighbours(c, startprob); } @@ -3021,7 +3022,7 @@ static void apply_environment_effect(const coord_def &c) { const dungeon_feature_type grid = grd(c); // Don't apply if if the feature doesn't want it. - if (testbits(env.map(c).property, FPROP_NO_CLOUD_GEN)) + if (testbits(env.pgrid(c), FPROP_NO_CLOUD_GEN)) return; if (grid == DNGN_LAVA) check_place_cloud(CLOUD_BLACK_SMOKE, c, random_range(4, 8), KC_OTHER); diff --git a/crawl-ref/source/mon-abil.cc b/crawl-ref/source/mon-abil.cc index d200148fa2..ea3c87dc18 100644 --- a/crawl-ref/source/mon-abil.cc +++ b/crawl-ref/source/mon-abil.cc @@ -18,7 +18,8 @@ #include "beam.h" #include "colour.h" #include "directn.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "ghost.h" #include "misc.h" #include "mon-act.h" diff --git a/crawl-ref/source/mon-act.cc b/crawl-ref/source/mon-act.cc index cba2447734..62301ab0bd 100644 --- a/crawl-ref/source/mon-act.cc +++ b/crawl-ref/source/mon-act.cc @@ -17,7 +17,8 @@ #include "dbg-scan.h" #include "delay.h" #include "directn.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "fight.h" #include "itemname.h" #include "itemprop.h" diff --git a/crawl-ref/source/mon-behv.cc b/crawl-ref/source/mon-behv.cc index f9c97804fb..270e006d9a 100644 --- a/crawl-ref/source/mon-behv.cc +++ b/crawl-ref/source/mon-behv.cc @@ -12,7 +12,8 @@ #include "coord.h" #include "coordit.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "exclude.h" #include "los.h" #include "monplace.h" @@ -429,7 +430,7 @@ static bool _find_siren_water_target(monsters *mon) #ifdef WIZARD // Remove old highlighted areas to make place for the new ones. for (rectangle_iterator ri(1); ri; ++ri) - env.map(*ri).property &= ~(FPROP_HIGHLIGHT); + env.pgrid(*ri) &= ~(FPROP_HIGHLIGHT); #endif if (mp.init_pathfind(mon, best_target)) @@ -440,7 +441,7 @@ static bool _find_siren_water_target(monsters *mon) { #ifdef WIZARD for (unsigned int i = 0; i < mon->travel_path.size(); i++) - env.map(mon->travel_path[i]).property |= FPROP_HIGHLIGHT; + env.pgrid(mon->travel_path[i]) |= FPROP_HIGHLIGHT; #endif #ifdef DEBUG_PATHFIND mprf("Found a path to (%d, %d) with %d surrounding water squares", @@ -521,7 +522,7 @@ static bool _find_wall_target(monsters *mon) #ifdef WIZARD // Remove old highlighted areas to make place for the new ones. for (rectangle_iterator ri(1); ri; ++ri) - env.map(*ri).property &= ~(FPROP_HIGHLIGHT); + env.pgrid(*ri) &= ~(FPROP_HIGHLIGHT); #endif if (mp.init_pathfind(mon, best_target)) @@ -532,7 +533,7 @@ static bool _find_wall_target(monsters *mon) { #ifdef WIZARD for (unsigned int i = 0; i < mon->travel_path.size(); i++) - env.map(mon->travel_path[i]).property |= FPROP_HIGHLIGHT; + env.pgrid(mon->travel_path[i]) |= FPROP_HIGHLIGHT; #endif #ifdef DEBUG_PATHFIND mprf("Found a path to (%d, %d)", best_target.x, best_target.y); diff --git a/crawl-ref/source/mon-cast.cc b/crawl-ref/source/mon-cast.cc index f5773bd9cd..01b3435d1d 100644 --- a/crawl-ref/source/mon-cast.cc +++ b/crawl-ref/source/mon-cast.cc @@ -14,7 +14,8 @@ #include "colour.h" #include "database.h" #include "effects.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "fight.h" #include "ghost.h" #include "los.h" diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 46583632f9..51d2b98505 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -15,7 +15,8 @@ #include "colour.h" #include "database.h" #include "directn.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "fight.h" #include "ghost.h" #include "goditem.h" diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 0f56d02749..ceeb613caf 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -13,7 +13,8 @@ #include "arena.h" #include "branch.h" #include "directn.h" // for the Compass -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "externs.h" #include "options.h" #include "ghost.h" diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index 43dfcb65ce..5016684fb2 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -5366,7 +5366,7 @@ void monsters::apply_location_effects(const coord_def &oldpos) behaviour_event(this, ME_EVAL); } - unsigned long &prop = env.map(pos()).property; + unsigned long &prop = env.pgrid(pos()); if (prop & FPROP_BLOODY) { diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 5e11ded4fd..c4983788f5 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -23,7 +23,8 @@ #include "delay.h" #include "dgnevent.h" #include "directn.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "files.h" #include "food.h" #include "godabil.h" diff --git a/crawl-ref/source/overmap.cc b/crawl-ref/source/overmap.cc index f2161dc56e..e7c5c49631 100644 --- a/crawl-ref/source/overmap.cc +++ b/crawl-ref/source/overmap.cc @@ -25,7 +25,8 @@ #include "dgnevent.h" #include "directn.h" #include "dungeon.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "feature.h" #include "files.h" #include "initfile.h" diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index f54082c9cf..bdabea3756 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -29,7 +29,8 @@ #include "delay.h" #include "dgnevent.h" #include "effects.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "fight.h" #include "food.h" #include "godabil.h" @@ -2449,9 +2450,9 @@ void forget_map(unsigned char chance_forgotten, bool force) && (force || x_chance_in_y(chance_forgotten, 100) || use_lab_check && (you.pos()-*ri).abs() > radius)) { - env.map(*ri).clear(); + env.map_knowledge(*ri).clear(); #ifdef USE_TILE - set_envmap_obj(*ri, DNGN_UNSEEN); + set_map_knowledge_obj(*ri, DNGN_UNSEEN); tiles.update_minimap(ri->x, ri->y); env.tile_bk_fg(*ri) = 0; env.tile_bk_bg(*ri) = tileidx_feature(DNGN_UNSEEN, ri->x, ri->y); diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 36fdfa265c..057824e1b0 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -34,7 +34,8 @@ #include "describe.h" #include "effects.h" #include "enum.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "fight.h" #include "files.h" #include "food.h" @@ -4287,7 +4288,7 @@ static bool _bless_weapon(god_type god, brand_type brand, int colour) // Un-bloodify surrounding squares. for (radius_iterator ri(you.pos(), 3, true, true); ri; ++ri) if (is_bloodcovered(*ri)) - env.map(*ri).property &= ~(FPROP_BLOODY); + env.pgrid(*ri) &= ~(FPROP_BLOODY); } if (god == GOD_KIKUBAAQUDGHA) @@ -4297,7 +4298,7 @@ static bool _bless_weapon(god_type god, brand_type brand, int colour) // Bloodify surrounding squares (75% chance). for (radius_iterator ri(you.pos(), 2, true, true); ri; ++ri) if (!is_bloodcovered(*ri) && !one_chance_in(4)) - env.map(*ri).property |= FPROP_BLOODY; + env.pgrid(*ri) |= FPROP_BLOODY; } #ifndef USE_TILE diff --git a/crawl-ref/source/showsymb.cc b/crawl-ref/source/showsymb.cc index 332c283a37..0a069fad85 100644 --- a/crawl-ref/source/showsymb.cc +++ b/crawl-ref/source/showsymb.cc @@ -14,7 +14,8 @@ #include "colour.h" #include "env.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "halo.h" #include "mon-util.h" #include "monster.h" @@ -71,9 +72,9 @@ static unsigned short _feat_colour(const coord_def &where, } else if (feat >= DNGN_MINMOVE && is_sanctuary(where)) { - if (testbits(env.map(where).property, FPROP_SANCTUARY_1)) + if (testbits(env.pgrid(where), FPROP_SANCTUARY_1)) colour = YELLOW; - else if (testbits(env.map(where).property, FPROP_SANCTUARY_2)) + else if (testbits(env.pgrid(where), FPROP_SANCTUARY_2)) { if (!one_chance_in(4)) colour = WHITE; // 3/4 @@ -273,7 +274,7 @@ unsigned get_screen_glyph(const coord_def& p) unsigned ch; if (!object) - return get_envmap_char(p.x, p.y); + return get_map_knowledge_char(p.x, p.y); get_symbol(p, object, &ch, &colour); return (ch); diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 0ec3313248..040e7a9e09 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -23,7 +23,8 @@ #include "directn.h" #include "dungeon.h" #include "effects.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "ghost.h" #include "goditem.h" #include "invent.h" @@ -69,7 +70,7 @@ int detect_traps(int pow) { traps_found++; trap.reveal(); - set_envmap_obj(trap.pos, show_type(grd(trap.pos))); + set_map_knowledge_obj(trap.pos, show_type(grd(trap.pos))); set_terrain_mapped(trap.pos); } } @@ -92,12 +93,12 @@ int detect_items(int pow) continue; if (igrd(*ri) != NON_ITEM - && (!get_envmap_obj(*ri) || !is_envmap_item(*ri))) + && (!get_map_knowledge_obj(*ri) || !is_map_knowledge_item(*ri))) { items_found++; - set_envmap_obj(*ri, show_type(SHOW_ITEM_DETECTED)); - set_envmap_detected_item(*ri); + set_map_knowledge_obj(*ri, show_type(SHOW_ITEM_DETECTED)); + set_map_knowledge_detected_item(*ri); #ifdef USE_TILE // Don't replace previously seen items with an unseen one. if (!is_terrain_seen(*ri) && !is_terrain_mapped(*ri)) @@ -154,7 +155,7 @@ static bool _mark_detected_creature(coord_def where, const monsters *mon, continue; // Try not to overwrite another detected monster. - if (is_envmap_detected_mons(place)) + if (is_map_knowledge_detected_mons(place)) continue; // Don't print monsters on terrain they cannot pass through, @@ -171,8 +172,8 @@ static bool _mark_detected_creature(coord_def where, const monsters *mon, where = place; } - set_envmap_obj(where, show_type(mon)); - set_envmap_detected_mons(where); + set_map_knowledge_obj(where, show_type(mon)); + set_map_knowledge_detected_mons(where); #ifdef USE_TILE tile_place_monster(where.x, where.y, idx, false, true); diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index bd4df15d81..12ba4f2df9 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -25,7 +25,8 @@ #include "debug.h" #include "delay.h" #include "effects.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "food.h" #include "goditem.h" #include "itemname.h" @@ -1579,7 +1580,7 @@ static bool _teleport_player(bool allow_control, bool new_abyss_area) || monster_at(newpos) || env.cgrid(newpos) != EMPTY_CLOUD || need_distance_check && (newpos - centre).abs() < 34*34 - || testbits(env.map(newpos).property, FPROP_NO_RTELE_INTO)); + || testbits(env.pgrid(newpos), FPROP_NO_RTELE_INTO)); if (newpos == you.pos()) mpr("Your surroundings flicker for a moment."); @@ -1732,7 +1733,7 @@ static int _inside_circle(const coord_def& where, int radius) static void _remove_sanctuary_property(const coord_def& where) { - env.map(where).property &= ~(FPROP_SANCTUARY_1 | FPROP_SANCTUARY_2); + env.pgrid(where) &= ~(FPROP_SANCTUARY_1 | FPROP_SANCTUARY_2); } bool remove_sanctuary(bool did_attack) @@ -1862,7 +1863,7 @@ bool cast_sanctuary(const int power) continue; const coord_def pos = *ri; - if (testbits(env.map(pos).property, FPROP_BLOODY) && observe_cell(pos)) + if (testbits(env.pgrid(pos), FPROP_BLOODY) && observe_cell(pos)) blood_count++; if (trap_def* ptrap = find_trap(pos)) @@ -1898,10 +1899,10 @@ bool cast_sanctuary(const int power) break; } - env.map(pos).property |= (in_yellow ? FPROP_SANCTUARY_1 + env.pgrid(pos) |= (in_yellow ? FPROP_SANCTUARY_1 : FPROP_SANCTUARY_2); - env.map(pos).property &= ~(FPROP_BLOODY); + env.pgrid(pos) &= ~(FPROP_BLOODY); // Scare all attacking monsters inside sanctuary, and make // all friendly monsters inside sanctuary stop attacking and diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 18a84c5e5a..7f92310aff 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -19,7 +19,8 @@ #include "coordit.h" #include "describe.h" #include "effects.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "food.h" #include "format.h" #include "godabil.h" diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 7ba129ed01..9dbe2fced8 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -64,7 +64,8 @@ #include "describe.h" #include "dungeon.h" #include "enum.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "externs.h" #include "files.h" #include "ghost.h" @@ -1716,10 +1717,10 @@ static void tag_construct_level(writer &th) for (int count_y = 0; count_y < GYM; count_y++) { marshallByte(th, grd[count_x][count_y]); - marshallShowtype(th, env.map[count_x][count_y].object); - marshallShort(th, env.map[count_x][count_y].colour); - marshallShort(th, env.map[count_x][count_y].flags); - marshallLong(th, env.map[count_x][count_y].property); + marshallShowtype(th, env.map_knowledge[count_x][count_y].object); + marshallShort(th, env.map_knowledge[count_x][count_y].colour); + marshallShort(th, env.map_knowledge[count_x][count_y].flags); + marshallLong(th, env.pgrid[count_x][count_y]); marshallShort(th, env.cgrid[count_x][count_y]); } @@ -2097,10 +2098,10 @@ static void tag_read_level( reader &th, char minorVersion ) static_cast( static_cast(unmarshallByte(th)) ); - env.map[i][j].object = unmarshallShowtype(th); - env.map[i][j].colour = unmarshallShort(th); - env.map[i][j].flags = unmarshallShort(th); - env.map[i][j].property = unmarshallLong(th); + env.map_knowledge[i][j].object = unmarshallShowtype(th); + env.map_knowledge[i][j].colour = unmarshallShort(th); + env.map_knowledge[i][j].flags = unmarshallShort(th); + env.pgrid[i][j] = unmarshallLong(th); mgrd[i][j] = NON_MONSTER; env.cgrid[i][j] = (unsigned short) unmarshallShort(th); @@ -2439,7 +2440,7 @@ static void tag_missing_level_tiles() { coord_def gc(i, j); unsigned int fg, bg; - tileidx_unseen(fg, bg, get_envmap_char(i, j), gc); + tileidx_unseen(fg, bg, get_map_knowledge_char(i, j), gc); env.tile_bk_fg[i][j] = fg; env.tile_bk_bg[i][j] = bg; } diff --git a/crawl-ref/source/teleport.cc b/crawl-ref/source/teleport.cc index 07c91667c7..ba60707388 100644 --- a/crawl-ref/source/teleport.cc +++ b/crawl-ref/source/teleport.cc @@ -10,7 +10,8 @@ #include "cloud.h" #include "coord.h" #include "env.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "los.h" #include "player.h" #include "random.h" diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc index a094d03537..1d4fe0b75b 100644 --- a/crawl-ref/source/terrain.cc +++ b/crawl-ref/source/terrain.cc @@ -15,7 +15,8 @@ #include "cloud.h" #include "dgnevent.h" #include "directn.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "godabil.h" #include "itemprop.h" #include "items.h" @@ -663,7 +664,7 @@ static void _dgn_check_terrain_blood(const coord_def &pos, dungeon_feature_type old_feat, dungeon_feature_type new_feat) { - if (!testbits(env.map(pos).property, FPROP_BLOODY)) + if (!testbits(env.pgrid(pos), FPROP_BLOODY)) return; if (new_feat == DNGN_UNSEEN) @@ -671,7 +672,7 @@ static void _dgn_check_terrain_blood(const coord_def &pos, // Caller has already changed the grid, and old_feat is actually // the new feat. if (old_feat != DNGN_FLOOR && !feat_is_solid(old_feat)) - env.map(pos).property &= ~(FPROP_BLOODY); + env.pgrid(pos) &= ~(FPROP_BLOODY); } else { @@ -679,7 +680,7 @@ static void _dgn_check_terrain_blood(const coord_def &pos, || feat_is_water(new_feat) || feat_destroys_items(new_feat) || is_critical_feature(new_feat)) { - env.map(pos).property &= ~(FPROP_BLOODY); + env.pgrid(pos) &= ~(FPROP_BLOODY); } } } @@ -850,8 +851,8 @@ bool swap_features(const coord_def &pos1, const coord_def &pos2, const unsigned short col1 = env.grid_colours(pos1); const unsigned short col2 = env.grid_colours(pos2); - const unsigned long prop1 = env.map(pos1).property; - const unsigned long prop2 = env.map(pos2).property; + const unsigned long prop1 = env.pgrid(pos1); + const unsigned long prop2 = env.pgrid(pos2); trap_def* trap1 = find_trap(pos1); trap_def* trap2 = find_trap(pos2); @@ -894,13 +895,13 @@ bool swap_features(const coord_def &pos1, const coord_def &pos2, env.markers.move(pos1, temp); dungeon_events.move_listeners(pos1, temp); grd(pos1) = DNGN_UNSEEN; - env.map(pos1).property = 0; + env.pgrid(pos1) = 0; (void) move_notable_thing(pos2, pos1); env.markers.move(pos2, pos1); dungeon_events.move_listeners(pos2, pos1); - env.map(pos1).property = prop2; - env.map(pos2).property = prop1; + env.pgrid(pos1) = prop2; + env.pgrid(pos2) = prop1; (void) move_notable_thing(temp, pos2); env.markers.move(temp, pos2); diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc index f75357d994..5c26dcebc8 100644 --- a/crawl-ref/source/tilepick.cc +++ b/crawl-ref/source/tilepick.cc @@ -13,7 +13,8 @@ #include "coord.h" #include "coordit.h" #include "directn.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "externs.h" #include "options.h" #include "food.h" @@ -86,8 +87,8 @@ int tile_unseen_flag(const coord_def& gc) return TILE_FLAG_UNSEEN; else if (is_terrain_known(gc) && !is_terrain_seen(gc) - || is_envmap_detected_item(gc) - || is_envmap_detected_mons(gc)) + || is_map_knowledge_detected_item(gc) + || is_map_knowledge_detected_mons(gc)) { return TILE_FLAG_MM_UNSEEN; } diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index 7500cd0950..d5751cdd30 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -11,7 +11,8 @@ #include "cio.h" #include "coord.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "debug.h" #include "describe.h" #include "files.h" diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index f9b903114b..3f164a7bea 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -5,7 +5,8 @@ #include "artefact.h" #include "cio.h" #include "coord.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "itemname.h" #include "items.h" #include "itemprop.h" @@ -454,7 +455,7 @@ void TilesFramework::load_dungeon(const coord_def &cen) fg = env.tile_bk_fg(gc); bg = env.tile_bk_bg(gc); if (!fg && !bg) - tileidx_unseen(fg, bg, get_envmap_char(gc), gc); + tileidx_unseen(fg, bg, get_map_knowledge_char(gc), gc); bg |= tile_unseen_flag(gc); } else @@ -1312,7 +1313,7 @@ void TilesFramework::update_minimap(int gx, int gy) if (!player_in_mappable_area()) return; - show_type object = env.map[gx][gy].object; + show_type object = env.map_knowledge[gx][gy].object; map_feature f = (object.cls == SH_MONSTER) ? MF_MONS_HOSTILE : get_feature_def(object).minimap; @@ -1353,8 +1354,8 @@ void TilesFramework::update_minimap(int gx, int gy, map_feature f) if (f == MF_WALL || f == MF_FLOOR) { if (is_terrain_known(gx, gy) && !is_terrain_seen(gx, gy) - || is_envmap_detected_item(gx, gy) - || is_envmap_detected_mons(gx, gy)) + || is_map_knowledge_detected_item(gx, gy) + || is_map_knowledge_detected_mons(gx, gy)) { f = (f == MF_WALL) ? MF_MAP_WALL : MF_MAP_FLOOR; } diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index 35cdabc2dd..09740d196e 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -18,7 +18,8 @@ #include "delay.h" #include "describe.h" #include "directn.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "itemname.h" #include "itemprop.h" #include "items.h" @@ -120,7 +121,7 @@ void trap_def::reveal() { const dungeon_feature_type cat = this->category(); grd(this->pos) = cat; - set_envmap_obj(this->pos, cat); + set_map_knowledge_obj(this->pos, cat); } std::string trap_def::name(description_level_type desc) const diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 191f7d480a..32d2241173 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -22,7 +22,8 @@ #include "describe.h" #include "dgnevent.h" #include "directn.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "exclude.h" #include "godabil.h" #include "itemname.h" @@ -352,7 +353,7 @@ bool is_travelsafe_square(const coord_def& c, bool ignore_hostile, // Also make note of what's displayed on the level map for // plant/fungus checks. - const show_type levelmap_object = get_envmap_obj(c); + const show_type levelmap_object = get_map_knowledge_obj(c); // Travel will not voluntarily cross squares blocked by immobile monsters. if (!ignore_hostile @@ -550,7 +551,7 @@ bool prompt_stop_explore(int es_why) // Adds interesting stuff on (x, y) to explore_discoveries. // -// NOTE: These are env.map coords, add +1 to get grid coords. +// NOTE: These are env.map_knowledge coords, add +1 to get grid coords. inline static void _check_interesting_square(int x, int y, explore_discoveries &ed) { @@ -876,7 +877,7 @@ command_type travel() if (discoveries.prompt_stop()) stop_running(); - mapshadow = env.map; + mapshadow = env.map_knowledge; } if (you.running.is_explore()) @@ -2810,7 +2811,7 @@ void start_explore(bool grab_items) } // Clone shadow array off map - mapshadow = env.map; + mapshadow = env.map_knowledge; you.running.pos.reset(); _start_running(); @@ -3324,7 +3325,7 @@ void LevelInfo::get_stairs(std::vector &st) for (rectangle_iterator ri(1); ri; ++ri) { const dungeon_feature_type feat = grd(*ri); - const int envc = env.map(*ri).object; + const int envc = env.map_knowledge(*ri).object; if ((*ri == you.pos() || envc) && feat_is_travelable_stair(feat) diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index bf861ab8cd..b0b78f0ec3 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -21,7 +21,8 @@ #include "externs.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "viewchar.h" #include "viewgeom.h" #include "viewmap.h" @@ -906,7 +907,7 @@ bool magic_mapping(int map_radius, int proportion, bool suppress_msg, } if (is_terrain_changed(*ri)) - clear_envmap_grid(*ri); + clear_map_knowledge_grid(*ri); if (!wizard_map && (is_terrain_seen(*ri) || is_terrain_mapped(*ri))) continue; @@ -934,8 +935,8 @@ bool magic_mapping(int map_radius, int proportion, bool suppress_msg, if (open) { - if (wizard_map || !get_envmap_obj(*ri)) - set_envmap_obj(*ri, grd(*ri)); + if (wizard_map || !get_map_knowledge_obj(*ri)) + set_map_knowledge_obj(*ri, grd(*ri)); if (wizard_map) { @@ -944,7 +945,7 @@ bool magic_mapping(int map_radius, int proportion, bool suppress_msg, set_terrain_seen(*ri); #ifdef USE_TILE - // Can't use set_envmap_obj because that would + // Can't use set_map_knowledge_obj because that would // overwrite the gmap. env.tile_bk_bg(*ri) = tile_idx_unseen_terrain(ri->x, ri->y, grd(*ri)); @@ -1054,7 +1055,7 @@ std::string screenshot(bool fullscreen) int ch = (!map_bounds(gc)) ? 0 : - (!crawl_view.in_grid_los(gc)) ? get_envmap_char(gc.x, gc.y) : + (!crawl_view.in_grid_los(gc)) ? get_map_knowledge_char(gc.x, gc.y) : (gc == you.pos()) ? you.symbol : get_screen_glyph(gc.x, gc.y); @@ -1323,7 +1324,7 @@ void viewwindow(bool draw_it, bool do_updates) else if (!crawl_view.in_grid_los(gc)) { // Outside the env.show area. - buffy[bufcount] = get_envmap_char(gc); + buffy[bufcount] = get_map_knowledge_char(gc); buffy[bufcount + 1] = DARKGREY; if (Options.colour_map) @@ -1336,7 +1337,7 @@ void viewwindow(bool draw_it, bool do_updates) unsigned int bg = env.tile_bk_bg(gc); unsigned int fg = env.tile_bk_fg(gc); if (bg == 0 && fg == 0) - tileidx_unseen(fg, bg, get_envmap_char(gc), gc); + tileidx_unseen(fg, bg, get_map_knowledge_char(gc), gc); tileb[bufcount] = fg; tileb[bufcount + 1] = bg | tile_unseen_flag(gc); @@ -1352,13 +1353,13 @@ void viewwindow(bool draw_it, bool do_updates) if (map) { - set_envmap_glyph(gc, object, colour); + set_map_knowledge_glyph(gc, object, colour); if (is_terrain_changed(gc) || !is_terrain_seen(gc)) update_excludes.push_back(gc); set_terrain_seen(gc); - set_envmap_detected_mons(gc, false); - set_envmap_detected_item(gc, false); + set_map_knowledge_detected_mons(gc, false); + set_map_knowledge_detected_item(gc, false); } #ifdef USE_TILE if (map) @@ -1413,9 +1414,9 @@ void viewwindow(bool draw_it, bool do_updates) update_excludes.push_back(gc); set_terrain_seen(gc); - set_envmap_glyph(gc, object, colour ); - set_envmap_detected_mons(gc, false); - set_envmap_detected_item(gc, false); + set_map_knowledge_glyph(gc, object, colour ); + set_map_knowledge_detected_mons(gc, false); + set_map_knowledge_detected_item(gc, false); #ifdef USE_TILE // We remove any references to mcache when // writing to the background. @@ -1434,7 +1435,7 @@ void viewwindow(bool draw_it, bool do_updates) // Check if we're looking to clean_map... // but don't touch the buffer to clean it, - // instead we modify the env.map itself so + // instead we modify the env.map_knowledge itself so // that the map stays clean as it moves out // of the env.show radius. // @@ -1448,23 +1449,23 @@ void viewwindow(bool draw_it, bool do_updates) && is_terrain_seen(gc)) { get_symbol(gc, env.show.get_backup(ep), &ch, &colour); - set_envmap_glyph(gc, env.show.get_backup(ep), colour); + set_map_knowledge_glyph(gc, env.show.get_backup(ep), colour); } // Now we get to filling in both the unseen // grids in the env.show radius area as // well doing the clean_map. The clean_map - // is done by having the env.map set to the + // is done by having the env.map_knowledge set to the // backup character above, and down here we // procede to override that character if it's // out of LoS! If it wasn't, buffy would have // already been set (but we'd still have - // clobbered env.map... which is important + // clobbered env.map_knowledge... which is important // to do for when we move away from the area!) if (buffy[bufcount] == 0) { // Show map. - buffy[bufcount] = get_envmap_char(gc); + buffy[bufcount] = get_map_knowledge_char(gc); buffy[bufcount + 1] = DARKGREY; if (Options.colour_map) @@ -1485,7 +1486,7 @@ void viewwindow(bool draw_it, bool do_updates) { tileidx_unseen(tileb[bufcount], tileb[bufcount+1], - get_envmap_char(gc), + get_map_knowledge_char(gc), gc); } #endif diff --git a/crawl-ref/source/viewmap.cc b/crawl-ref/source/viewmap.cc index 2ceb2a1a76..bf33c711f4 100644 --- a/crawl-ref/source/viewmap.cc +++ b/crawl-ref/source/viewmap.cc @@ -13,7 +13,8 @@ #include "command.h" #include "coord.h" #include "env.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "exclude.h" #include "feature.h" #include "files.h" @@ -49,7 +50,7 @@ unsigned get_magicmap_char(dungeon_feature_type feat) // 5. Anything else will look for the exact same character in the level map. bool is_feature(int feature, const coord_def& where) { - if (!env.map(where).object && !observe_cell(where)) + if (!env.map_knowledge(where).object && !observe_cell(where)) return (false); dungeon_feature_type grid = grd(where); @@ -172,13 +173,13 @@ bool is_feature(int feature, const coord_def& where) return (false); } default: - return get_envmap_char(where.x, where.y) == (unsigned) feature; + return get_map_knowledge_char(where.x, where.y) == (unsigned) feature; } } static bool _is_feature_fudged(int feature, const coord_def& where) { - if (!env.map(where).object) + if (!env.map_knowledge(where).object) return (false); if (is_feature(feature, where)) @@ -424,12 +425,12 @@ static void _draw_level_map(int start_x, int start_y, bool travel_mode, on_level); buffer2[bufcount2 + 1] = colour; - buffer2[bufcount2] = env.map(c).glyph(); + buffer2[bufcount2] = env.map_knowledge(c).glyph(); if (c == you.pos() && !crawl_state.arena_suspended && on_level) { // [dshaligram] Draw the @ symbol on the level-map. It's no - // longer saved into the env.map, so we need to draw it + // longer saved into the env.map_knowledge, so we need to draw it // directly. buffer2[bufcount2 + 1] = WHITE; buffer2[bufcount2] = you.symbol; @@ -565,7 +566,7 @@ void show_map( level_pos &spec_place, bool travel_mode, bool allow_esc ) for (j = 0; j < GYM; j++) for (i = 0; i < GXM; i++) { - if (env.map[i][j].known()) + if (env.map_knowledge[i][j].known()) { if (!found_y) { @@ -1099,7 +1100,7 @@ screen_buffer_t colour_code_map(const coord_def& p, bool item_colour, #ifdef WIZARD if (travel_colour && you.wizard - && testbits(env.map(p).property, FPROP_HIGHLIGHT)) + && testbits(env.pgrid(p), FPROP_HIGHLIGHT)) { return (LIGHTGREEN); } @@ -1108,17 +1109,17 @@ screen_buffer_t colour_code_map(const coord_def& p, bool item_colour, dungeon_feature_type feat_value = grd(p); if (!observe_cell(p)) { - const show_type remembered = get_envmap_obj(p); + const show_type remembered = get_map_knowledge_obj(p); if (remembered.cls == SH_FEATURE) feat_value = remembered.feat; } unsigned tc = travel_colour ? _get_travel_colour(p) : DARKGREY; - if (is_envmap_detected_item(p)) + if (is_map_knowledge_detected_item(p)) return real_colour(Options.detected_item_colour); - if (is_envmap_detected_mons(p)) + if (is_map_knowledge_detected_mons(p)) { tc = Options.detected_monster_colour; return real_colour(tc); @@ -1129,8 +1130,8 @@ screen_buffer_t colour_code_map(const coord_def& p, bool item_colour, if (is_waypoint(p) || travel_point_distance[p.x][p.y] == PD_EXCLUDED) return real_colour(tc); - if (item_colour && is_envmap_item(p)) - return get_envmap_col(p); + if (item_colour && is_map_knowledge_item(p)) + return get_map_knowledge_col(p); int feature_colour = DARKGREY; const bool terrain_seen = is_terrain_seen(p); diff --git a/crawl-ref/source/wiz-mon.cc b/crawl-ref/source/wiz-mon.cc index 57cac91a34..269032a152 100644 --- a/crawl-ref/source/wiz-mon.cc +++ b/crawl-ref/source/wiz-mon.cc @@ -12,7 +12,8 @@ #include "colour.h" #include "dbg-util.h" #include "delay.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "ghost.h" #include "invent.h" #include "items.h" diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index e74bcb0da0..87b4ff7ce6 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -15,7 +15,8 @@ #include "delay.h" #include "directn.h" #include "effects.h" -#include "envmap.h" +#include "map_knowledge.h" +#include "fprop.h" #include "feature.h" #include "goditem.h" #include "it_use2.h" -- cgit v1.2.3-54-g00ecf