summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/map_knowledge.cc
diff options
context:
space:
mode:
authorLuca Barbieri <luca@luca-barbieri.com>2010-06-07 06:46:42 +0200
committerRobert Vollmert <rvollmert@gmx.net>2010-07-29 00:43:59 +0200
commitaf76f809d3f1679210469c3b194f1b06dc85536b (patch)
treeeadc06efba7cf8bb94ab139fa3b8e5d538e6ef10 /crawl-ref/source/map_knowledge.cc
parent7184b88d886d74490447b01699bd2f95dc9cc804 (diff)
downloadcrawl-ref-af76f809d3f1679210469c3b194f1b06dc85536b.tar.gz
crawl-ref-af76f809d3f1679210469c3b194f1b06dc85536b.zip
Make map_cell store feat+cloud+item+mons instead of only the topmost one (BREAKS SAVES) (v3)
Changes in v3 (rob): - update to current master - fix colouring of out-of-LOS clouds - fix reload crash due to env.cgrid Changes in v2: - Features and monsters should now be properly grayed Currently map_cell only stores the topmost "thing" in a cell. This is good enough for the console view, but not for more sophisticated clients (e.g. tiles). This commit refactors the code so that all player knowledge about a cell (including detailed monster and item information) is represented in map_cell, and so that map_cell is used to build the console view. Save compatibility is broken since the new map_cell is serialized instead of the old one. This will allow, for instance, to load console savegames in the tiles version, and still get proper tiles for the explored area. Furthermore, this new map_cell will be the basis of the Crawl protocol for the client/server split. Signed-off-by: Robert Vollmert <rvollmert@gmx.net>
Diffstat (limited to 'crawl-ref/source/map_knowledge.cc')
-rw-r--r--crawl-ref/source/map_knowledge.cc46
1 files changed, 12 insertions, 34 deletions
diff --git a/crawl-ref/source/map_knowledge.cc b/crawl-ref/source/map_knowledge.cc
index ee66525e18..c60982e4d3 100644
--- a/crawl-ref/source/map_knowledge.cc
+++ b/crawl-ref/source/map_knowledge.cc
@@ -27,18 +27,7 @@ void map_knowledge_forget_mons(const coord_def& c)
if (!env.map_knowledge(c).detected_monster())
return;
- env.map_knowledge(c).flags &= ~MAP_DETECTED_MONSTER;
- show_type* obj = &env.map_knowledge(c).object;
- if (obj->cls == SH_MONSTER)
- obj->cls = (obj->feat == DNGN_UNSEEN ? SH_NOTHING : SH_FEATURE);
-}
-
-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);
-#endif
+ env.map_knowledge(c).clear_monster();
}
// Used to mark dug out areas, unset when terrain is seen or mapped again.
@@ -57,7 +46,6 @@ void set_terrain_mapped( int x, int y )
map_cell* cell = &env.map_knowledge(gc);
cell->flags &= (~MAP_CHANGED_FLAG);
cell->flags |= MAP_MAGIC_MAPPED_FLAG;
- cell->object.colour = get_feature_def(cell->object).map_colour;
#ifdef USE_TILE
tiles.update_minimap(gc);
#endif
@@ -87,30 +75,16 @@ 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;
- if (!env.map_knowledge(p).known())
- continue;
- if (env.map_knowledge(p).item() != SHOW_ITEM_NONE)
- continue;
- if (!clear_detected_items && env.map_knowledge(p).detected_item())
- continue;
- if (!clear_detected_monsters && env.map_knowledge(p).detected_item())
+ map_cell& cell = env.map_knowledge(p);
+ if (!cell.known() || cell.visible())
continue;
- show_type plain = env.map_knowledge(p).object;
+ if (!clear_detected_items || !cell.detected_item())
+ cell.clear_item();
- // If it's an immobile monster or a feature, don't erase.
- if ((plain.cls != SH_MONSTER || plain.is_cleanable_monster())
- && plain.cls != SH_FEATURE)
- {
- plain = show_type(plain.feat);
-#ifdef USE_TILE
- tile_clear_map(p);
-#endif
- }
-
- set_map_knowledge_obj(p, plain);
- env.map_knowledge(p).set_detected_monster(false);
- env.map_knowledge(p).set_detected_item(false);
+ if ((!clear_detected_monsters || !cell.detected_monster())
+ && !mons_class_is_stationary(cell.monster()))
+ cell.clear_monster();
}
}
@@ -171,6 +145,10 @@ void set_terrain_seen( int x, int y )
cell->flags &= (~MAP_CHANGED_FLAG);
cell->flags |= MAP_SEEN_FLAG;
+
+#ifdef USE_TILE
+ tiles.update_minimap(x, y);
+#endif
}
void set_terrain_visible(const coord_def &c)