diff options
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/abyss.cc | 12 | ||||
-rw-r--r-- | crawl-ref/source/acr.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/direct.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/dungeon.cc | 18 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 10 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 41 | ||||
-rw-r--r-- | crawl-ref/source/files.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/it_use3.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/luadgn.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/mapdef.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/mapmark.cc | 147 | ||||
-rw-r--r-- | crawl-ref/source/mapmark.h | 30 | ||||
-rw-r--r-- | crawl-ref/source/message.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/monplace.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/tags.cc | 16 | ||||
-rw-r--r-- | crawl-ref/source/travel.cc | 9 |
17 files changed, 209 insertions, 111 deletions
diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc index 45ff746ddd..5d1302cfb7 100644 --- a/crawl-ref/source/abyss.cc +++ b/crawl-ref/source/abyss.cc @@ -377,7 +377,7 @@ void abyss_teleport( bool new_area ) static void place_corruption_seed(const coord_def &pos, int duration) { - env_add_marker(new map_corruption_marker(pos, duration)); + env.markers.add(new map_corruption_marker(pos, duration)); } static void initialise_level_corrupt_seeds(int power) @@ -398,7 +398,7 @@ static void initialise_level_corrupt_seeds(int power) do where = coord_def(random2(GXM), random2(GYM)); while (!in_bounds(where) || grd(where) != DNGN_FLOOR - || env_find_marker(where, MAT_ANY)); + || env.markers.find(where, MAT_ANY)); place_corruption_seed(where, random_range(low, high, 2)); } @@ -453,13 +453,13 @@ static void apply_corruption_effect( } cmark->duration -= duration; if (cmark->duration < 1) - env_remove_marker(cmark); + env.markers.remove(cmark); } void run_corruption_effects(int duration) { std::vector<map_marker*> markers = - env_get_all_markers(MAT_CORRUPTION_NEXUS); + env.markers.get_all(MAT_CORRUPTION_NEXUS); for (int i = 0, size = markers.size(); i < size; ++i) { @@ -581,7 +581,7 @@ static void corrupt_level_features(const crawl_environment &oenv) { std::vector<coord_def> corrupt_seeds; std::vector<map_marker*> corrupt_markers = - env_get_all_markers(MAT_CORRUPTION_NEXUS); + env.markers.get_all(MAT_CORRUPTION_NEXUS); for (int i = 0, size = corrupt_markers.size(); i < size; ++i) corrupt_seeds.push_back(corrupt_markers[i]->pos); @@ -616,7 +616,7 @@ static bool is_level_corrupted() || player_in_branch(BRANCH_VESTIBULE_OF_HELL)) return (true); - return (!!env_find_marker(MAT_CORRUPTION_NEXUS)); + return (!!env.markers.find(MAT_CORRUPTION_NEXUS)); } static bool is_level_incorruptible() diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 7a329b6e7a..aefa1b1d2b 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -242,7 +242,7 @@ int main( int argc, char *argv[] ) // Activate markers only after the welcome message, so the // player can see any resulting messages. - env_activate_markers(); + env.markers.activate_all(); // Starting messages can go here as this should only happen // at the start of a new game -- bwr diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc index 3e67d2d591..9389a0837b 100644 --- a/crawl-ref/source/direct.cc +++ b/crawl-ref/source/direct.cc @@ -1476,7 +1476,7 @@ std::string raw_feature_description(dungeon_feature_type grid, static std::string marker_feature_description(const coord_def &p) { - std::vector<map_marker*> markers = env_get_markers(p); + std::vector<map_marker*> markers = env.markers.get_markers_at(p); for (int i = 0, size = markers.size(); i < size; ++i) { const std::string desc = markers[i]->feature_description(); @@ -1751,7 +1751,7 @@ static void describe_cell(int mx, int my) std::string feature_desc = feature_description(mx, my); #ifdef DEBUG_DIAGNOSTICS std::string marker; - if (map_marker *mark = env_find_marker(coord_def(mx, my), MAT_ANY)) + if (map_marker *mark = env.markers.find(coord_def(mx, my), MAT_ANY)) { std::string desc = mark->debug_describe(); if (desc.empty()) diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index d40049a76c..2bf5e3b0ea 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -537,7 +537,7 @@ static void reset_level() env.shop[shcount].type = SHOP_UNASSIGNED; // clear all markers - env_clear_markers(); + env.markers.clear(); } static void build_layout_skeleton(int level_number, int level_type, @@ -651,7 +651,7 @@ static void fixup_branch_stairs() && grd[x][y] <= DNGN_ROCK_STAIRS_UP) { if (grd[x][y] == DNGN_STONE_STAIRS_UP_I) - env_add_marker( + env.markers.add( new map_feature_marker(coord_def(x,y), grd[x][y])); grd[x][y] = exit; @@ -1424,7 +1424,7 @@ static void fixup_bazaar_stairs() else { grd[x][y] = DNGN_STONE_ARCH; - env_add_marker( + env.markers.add( new map_feature_marker( coord_def(x, y), DNGN_STONE_ARCH)); @@ -3092,7 +3092,7 @@ static bool build_minivaults(int level_number, int force_vault, grd[vx][vy] = oldgrid; dungeon_terrain_changed(coord_def(vx, vy), newgrid, true, true); - env_remove_markers_at(coord_def(vx, vy), MAT_ANY); + env.markers.remove_markers_at(coord_def(vx, vy), MAT_ANY); } } } @@ -3531,7 +3531,7 @@ bool dgn_place_map(int map, bool generating_level, bool clobber) for (int x = vp.x; x < vp.x + vp.width; ++x) { std::vector<map_marker *> markers = - env_get_markers(coord_def(x, y)); + env.markers.get_markers_at(coord_def(x, y)); for (int i = 0, size = markers.size(); i < size; ++i) markers[i]->activate(); @@ -3544,7 +3544,7 @@ bool dgn_place_map(int map, bool generating_level, bool clobber) if (fixup) { link_items(); - env_activate_markers(); + env.markers.activate_all(); // Force teleport to place the player somewhere sane. you_teleport_now(false, false); @@ -3636,7 +3636,7 @@ static bool build_vaults(int level_number, int force_vault, int rune_subst, grd[vx][vy] = oldgrid; dungeon_terrain_changed(coord_def(vx, vy), newgrid, true, true); - env_remove_markers_at(coord_def(vx, vy), MAT_ANY); + env.markers.remove_markers_at(coord_def(vx, vy), MAT_ANY); } } } @@ -5715,7 +5715,7 @@ static void labyrinth_place_entry_point(const dgn_region ®ion, { const coord_def p = labyrinth_find_entry_point(region, pos); if (in_bounds(p)) - env_add_marker(new map_feature_marker(pos, DNGN_ENTER_LABYRINTH)); + env.markers.add(new map_feature_marker(pos, DNGN_ENTER_LABYRINTH)); } static void labyrinth_level(int level_number) @@ -6882,7 +6882,7 @@ static coord_def dgn_find_closest_to_stone_stairs() static coord_def dgn_find_feature_marker(dungeon_feature_type feat) { - std::vector<map_marker*> markers = env_get_all_markers(); + std::vector<map_marker*> markers = env.markers.get_all(); for (int i = 0, size = markers.size(); i < size; ++i) { map_marker *mark = markers[i]; diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index bea9e7d856..6138e0bc0e 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -1778,6 +1778,16 @@ enum load_mode_type LOAD_ENTER_LEVEL }; +// Can't change this order without breaking saves. +enum map_marker_type +{ + MAT_FEATURE, // Stock marker. + MAT_LUA_MARKER, + MAT_CORRUPTION_NEXUS, + NUM_MAP_MARKER_TYPES, + MAT_ANY +}; + // [dshaligram] Maps can be mirrored; for every orientation, there must be // a suitable mirror. enum map_section_type // see maps.cc and dungeon.cc {dlb} diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index c1431105f0..fe553974a4 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1243,10 +1243,43 @@ struct map_cell bool seen() const; }; -typedef FixedArray<dungeon_feature_type, GXM, GYM> feature_grid; class map_marker; -typedef std::multimap<coord_def, map_marker *> dgn_marker_map; -typedef std::pair<coord_def, map_marker *> dgn_pos_marker; +class tagHeader; +class map_markers +{ +public: + map_markers(); + map_markers(const map_markers &); + map_markers &operator = (const map_markers &); + ~map_markers(); + + void activate_all(); + void add(map_marker *marker); + void remove(map_marker *marker); + void remove_markers_at(const coord_def &c, map_marker_type type = MAT_ANY); + map_marker *find(const coord_def &c, map_marker_type type = MAT_ANY); + map_marker *find(map_marker_type type); + void move(const coord_def &from, const coord_def &to); + std::vector<map_marker*> get_all(map_marker_type type = MAT_ANY); + std::vector<map_marker*> get_markers_at(const coord_def &c); + std::string property_at(const coord_def &c, map_marker_type type, + const std::string &key); + void clear(); + + void write(tagHeader &th) const; + void read(tagHeader &); + +private: + typedef std::multimap<coord_def, map_marker *> dgn_marker_map; + typedef std::pair<coord_def, map_marker *> dgn_pos_marker; + + void init_from(const map_markers &); + +private: + dgn_marker_map markers; +}; + +typedef FixedArray<dungeon_feature_type, GXM, GYM> feature_grid; struct crawl_environment { @@ -1277,7 +1310,7 @@ public: FixedVector< trap_struct, MAX_TRAPS > trap; // trap list FixedVector< int, 20 > mons_alloc; - dgn_marker_map markers; + map_markers markers; double elapsed_time; // used during level load diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index bc9704669f..1627aecbd6 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -742,7 +742,7 @@ static void close_level_gates() if (grid_sealable_portal(grd[i][j])) { grd[i][j] = DNGN_STONE_ARCH; - env_remove_markers_at(coord_def(i,j), MAT_ANY); + env.markers.remove_markers_at(coord_def(i,j), MAT_ANY); } } } @@ -947,8 +947,8 @@ bool load( dungeon_feature_type stair_taken, load_mode_type load_mode, // Activate markers that want activating, but only when // entering a new level in an existing game. If we're starting // a new game, or reloading an existing game, - // env_activate_markers() is done in acr.cc. - env_activate_markers(); + // markers are activated in acr.cc. + env.markers.activate_all(); // update corpses and fountains if (env.elapsed_time != 0.0) diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc index 68d39d60fe..5b363a44ba 100644 --- a/crawl-ref/source/it_use3.cc +++ b/crawl-ref/source/it_use3.cc @@ -572,15 +572,15 @@ bool evoke_wielded( void ) opened_gates++; map_marker *marker = - env_find_marker(coord_def(count_x, count_y), - MAT_FEATURE); + env.markers.find(coord_def(count_x, count_y), + MAT_FEATURE); if (marker) { map_feature_marker *featm = dynamic_cast<map_feature_marker*>(marker); grd[count_x][count_y] = featm->feat; - env_remove_marker(marker); + env.markers.remove(marker); } } } diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc index eea7ac1121..e15cc68b7a 100644 --- a/crawl-ref/source/luadgn.cc +++ b/crawl-ref/source/luadgn.cc @@ -980,7 +980,7 @@ static int dgn_remove_listener(lua_State *ls) static int dgn_remove_marker(lua_State *ls) { MAPMARKER(ls, 1, mark); - env_remove_marker(mark); + env.markers.remove(mark); return (0); } diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index 32f3afeb15..057809689f 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -390,7 +390,7 @@ void map_lines::apply_markers(const coord_def &c) for (int i = 0, size = markers.size(); i < size; ++i) { markers[i]->pos += c; - env_add_marker(markers[i]); + env.markers.add(markers[i]); } // *not* clear_markers() since we've offloaded marker ownership to // the crawl env. diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc index 52fcfab17a..ea8325f264 100644 --- a/crawl-ref/source/mapmark.cc +++ b/crawl-ref/source/mapmark.cc @@ -119,6 +119,11 @@ void map_feature_marker::read(tagHeader &inf) feat = static_cast<dungeon_feature_type>(unmarshallShort(inf)); } +map_marker *map_feature_marker::clone() const +{ + return new map_feature_marker(pos, feat); +} + map_marker *map_feature_marker::read(tagHeader &inf, map_marker_type) { map_marker *mapf = new map_feature_marker(); @@ -176,6 +181,14 @@ map_lua_marker::~map_lua_marker() } } +map_marker *map_lua_marker::clone() const +{ + map_lua_marker *copy = new map_lua_marker(); + if (get_table()) + copy->check_register_table(); + return copy; +} + void map_lua_marker::check_register_table() { if (!lua_istable(dlua, -1)) @@ -395,6 +408,13 @@ map_marker *map_corruption_marker::read(tagHeader &th, map_marker_type) return (mc); } +map_marker *map_corruption_marker::clone() const +{ + map_corruption_marker *mark = new map_corruption_marker(pos, duration); + mark->radius = radius; + return (mark); +} + std::string map_corruption_marker::debug_describe() const { return make_stringf("Lugonu corrupt (%d)", duration); @@ -403,65 +423,98 @@ std::string map_corruption_marker::debug_describe() const ////////////////////////////////////////////////////////////////////////// // Map markers in env. -void env_activate_markers() +map_markers::map_markers() : markers() +{ +} + +map_markers::map_markers(const map_markers &c) : markers() +{ + init_from(c); +} + +map_markers &map_markers::operator = (const map_markers &c) { - for (dgn_marker_map::iterator i = env.markers.begin(); - i != env.markers.end(); ++i) + if (this != &c) + { + clear(); + init_from(c); + } + return (*this); +} + +map_markers::~map_markers() +{ + clear(); +} + +void map_markers::init_from(const map_markers &c) +{ + for (dgn_marker_map::const_iterator i = c.markers.begin(); + i != c.markers.end(); ++i) + { + add( i->second->clone() ); + } +} + +void map_markers::activate_all() +{ + for (dgn_marker_map::iterator i = markers.begin(); + i != markers.end(); ++i) { i->second->activate(); } } -void env_add_marker(map_marker *marker) +void map_markers::add(map_marker *marker) { - env.markers.insert(dgn_pos_marker(marker->pos, marker)); + markers.insert(dgn_pos_marker(marker->pos, marker)); } -void env_remove_marker(map_marker *marker) +void map_markers::remove(map_marker *marker) { std::pair<dgn_marker_map::iterator, dgn_marker_map::iterator> - els = env.markers.equal_range(marker->pos); + els = markers.equal_range(marker->pos); for (dgn_marker_map::iterator i = els.first; i != els.second; ++i) { if (i->second == marker) { - env.markers.erase(i); + markers.erase(i); break; } } delete marker; } -void env_remove_markers_at(const coord_def &c, - map_marker_type type) +void map_markers::remove_markers_at(const coord_def &c, + map_marker_type type) { std::pair<dgn_marker_map::iterator, dgn_marker_map::iterator> - els = env.markers.equal_range(c); + els = markers.equal_range(c); for (dgn_marker_map::iterator i = els.first; i != els.second; ) { dgn_marker_map::iterator todel = i++; if (type == MAT_ANY || todel->second->get_type() == type) { delete todel->second; - env.markers.erase(todel); + markers.erase(todel); } } } -map_marker *env_find_marker(const coord_def &c, map_marker_type type) +map_marker *map_markers::find(const coord_def &c, map_marker_type type) { std::pair<dgn_marker_map::const_iterator, dgn_marker_map::const_iterator> - els = env.markers.equal_range(c); + els = markers.equal_range(c); for (dgn_marker_map::const_iterator i = els.first; i != els.second; ++i) if (type == MAT_ANY || i->second->get_type() == type) return (i->second); return (NULL); } -map_marker *env_find_marker(map_marker_type type) +map_marker *map_markers::find(map_marker_type type) { - for (dgn_marker_map::const_iterator i = env.markers.begin(); - i != env.markers.end(); ++i) + for (dgn_marker_map::const_iterator i = markers.begin(); + i != markers.end(); ++i) { if (type == MAT_ANY || i->second->get_type() == type) return (i->second); @@ -469,32 +522,32 @@ map_marker *env_find_marker(map_marker_type type) return (NULL); } -void env_move_markers(const coord_def &from, const coord_def &to) +void map_markers::move(const coord_def &from, const coord_def &to) { std::pair<dgn_marker_map::iterator, dgn_marker_map::iterator> - els = env.markers.equal_range(from); + els = markers.equal_range(from); - std::list<map_marker*> markers; + std::list<map_marker*> tmarkers; for (dgn_marker_map::iterator i = els.first; i != els.second; ) { dgn_marker_map::iterator curr = i++; - markers.push_back(curr->second); - env.markers.erase(curr); + tmarkers.push_back(curr->second); + markers.erase(curr); } - for (std::list<map_marker*>::iterator i = markers.begin(); - i != markers.end(); ++i) + for (std::list<map_marker*>::iterator i = tmarkers.begin(); + i != tmarkers.end(); ++i) { (*i)->pos = to; - env_add_marker(*i); + add(*i); } } -std::vector<map_marker*> env_get_all_markers(map_marker_type mat) +std::vector<map_marker*> map_markers::get_all(map_marker_type mat) { std::vector<map_marker*> rmarkers; - for (dgn_marker_map::const_iterator i = env.markers.begin(); - i != env.markers.end(); ++i) + for (dgn_marker_map::const_iterator i = markers.begin(); + i != markers.end(); ++i) { if (mat == MAT_ANY || i->second->get_type() == mat) rmarkers.push_back(i->second); @@ -502,21 +555,21 @@ std::vector<map_marker*> env_get_all_markers(map_marker_type mat) return (rmarkers); } -std::vector<map_marker*> env_get_markers(const coord_def &c) +std::vector<map_marker*> map_markers::get_markers_at(const coord_def &c) { std::pair<dgn_marker_map::const_iterator, dgn_marker_map::const_iterator> - els = env.markers.equal_range(c); + els = markers.equal_range(c); std::vector<map_marker*> rmarkers; for (dgn_marker_map::const_iterator i = els.first; i != els.second; ++i) rmarkers.push_back(i->second); return (rmarkers); } -std::string env_property_at(const coord_def &c, map_marker_type type, - const std::string &key) +std::string map_markers::property_at(const coord_def &c, map_marker_type type, + const std::string &key) { std::pair<dgn_marker_map::const_iterator, dgn_marker_map::const_iterator> - els = env.markers.equal_range(c); + els = markers.equal_range(c); for (dgn_marker_map::const_iterator i = els.first; i != els.second; ++i) { const std::string prop = i->second->property(key); @@ -526,10 +579,30 @@ std::string env_property_at(const coord_def &c, map_marker_type type, return (""); } -void env_clear_markers() +void map_markers::clear() { - for (dgn_marker_map::iterator i = env.markers.begin(); - i != env.markers.end(); ++i) + for (dgn_marker_map::iterator i = markers.begin(); + i != markers.end(); ++i) delete i->second; - env.markers.clear(); + markers.clear(); +} + +void map_markers::write(tagHeader &th) const +{ + // how many markers + marshallShort(th, markers.size()); + for (dgn_marker_map::const_iterator i = markers.begin(); + i != markers.end(); ++i) + { + i->second->write(th); + } +} + +void map_markers::read(tagHeader &th) +{ + clear(); + const int nmarkers = unmarshallShort(th); + for (int i = 0; i < nmarkers; ++i) + if (map_marker *mark = map_marker::read_marker(th)) + add(mark); } diff --git a/crawl-ref/source/mapmark.h b/crawl-ref/source/mapmark.h index cc7e2ee5ee..af4c40e536 100644 --- a/crawl-ref/source/mapmark.h +++ b/crawl-ref/source/mapmark.h @@ -9,16 +9,6 @@ ////////////////////////////////////////////////////////////////////////// // Map markers -// Can't change this order without breaking saves. -enum map_marker_type -{ - MAT_FEATURE, // Stock marker. - MAT_LUA_MARKER, - MAT_CORRUPTION_NEXUS, - NUM_MAP_MARKER_TYPES, - MAT_ANY -}; - class map_marker { public: @@ -27,6 +17,7 @@ public: map_marker_type get_type() const { return type; } + virtual map_marker *clone() const = 0; virtual void activate(); virtual void write(tagHeader &) const; virtual void read(tagHeader &); @@ -61,6 +52,7 @@ public: void write(tagHeader &) const; void read(tagHeader &); std::string debug_describe() const; + map_marker *clone() const; static map_marker *read(tagHeader &, map_marker_type); static map_marker *parse(const std::string &s, const std::string &) throw (std::string); @@ -77,7 +69,7 @@ public: void write(tagHeader &) const; void read(tagHeader &); - + map_marker *clone() const; std::string debug_describe() const; static map_marker *read(tagHeader &, map_marker_type); @@ -98,12 +90,13 @@ public: void write(tagHeader &) const; void read(tagHeader &); + map_marker *clone() const; std::string debug_describe() const; std::string feature_description() const; std::string property(const std::string &pname) const; void notify_dgn_event(const dgn_event &e); - + static map_marker *read(tagHeader &, map_marker_type); static map_marker *parse(const std::string &s, const std::string &) throw (std::string); @@ -117,17 +110,4 @@ private: std::string call_str_fn(const char *fn) const; }; -void env_activate_markers(); -void env_add_marker(map_marker *); -void env_remove_marker(map_marker *); -void env_remove_markers_at(const coord_def &c, map_marker_type); -std::vector<map_marker*> env_get_all_markers(map_marker_type = MAT_ANY); -map_marker *env_find_marker(const coord_def &c, map_marker_type); -map_marker *env_find_marker(map_marker_type type); -std::vector<map_marker*> env_get_markers(const coord_def &c); -void env_clear_markers(); -std::string env_property_at(const coord_def &c, map_marker_type, - const std::string &key); -void env_move_markers(const coord_def &from, const coord_def &to); - #endif diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index f7bc4bda04..4a9f190eaa 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -670,6 +670,13 @@ void mesclr( bool force ) void more(void) { +#ifdef DEBUG_DIAGNOSTICS + if (you.running) + { + mesclr(); + return; + } +#endif if (Options.show_more_prompt && !suppress_messages) { char keypress = 0; diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 0749ec3637..d265432a02 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -533,7 +533,7 @@ static bool is_feature_shift_target(const coord_def &pos) static bool dgn_shift_feature(const coord_def &pos) { const dungeon_feature_type dfeat = grd(pos); - if (!is_critical_feature(dfeat) && !env_find_marker(pos, MAT_ANY)) + if (!is_critical_feature(dfeat) && !env.markers.find(pos, MAT_ANY)) return (false); const coord_def dest = @@ -550,7 +550,7 @@ static bool dgn_shift_feature(const coord_def &pos) s->y = dest.y; } } - env_move_markers(pos, dest); + env.markers.move(pos, dest); dungeon_events.move_listeners(pos, dest); } return (true); @@ -856,7 +856,7 @@ static void leaving_level_now() // Note the name ahead of time because the events may cause // markers to be discarded. const std::string newtype = - env_property_at(you.pos(), MAT_ANY, "dst"); + env.markers.property_at(you.pos(), MAT_ANY, "dst"); dungeon_events.fire_position_event(DET_PLAYER_CLIMBS, you.pos()); dungeon_events.fire_event(DET_LEAVING_LEVEL); diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 8b895fae7c..5e687fe4fb 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -874,7 +874,7 @@ static band_type choose_band( int mon_type, int power, int &band_size ) case MONS_PANDEMONIUM_DEMON: band = BAND_PANDEMONIUM_DEMON; - band_size = random_range(4, 8); + band_size = random_range(1, 3); break; case MONS_HELLWING: diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index f90f9a6fee..057682d004 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -1429,13 +1429,7 @@ static void tag_construct_level(struct tagHeader &th) marshallByte(th, env.shop[i].level); } - // how many markers - marshallShort(th, env.markers.size()); - for (dgn_marker_map::const_iterator i = env.markers.begin(); - i != env.markers.end(); ++i) - { - i->second->write(th); - } + env.markers.write(th); } static void marshall_item(tagHeader &th, const item_def &item) @@ -1660,13 +1654,7 @@ static void tag_read_level( struct tagHeader &th, char minorVersion ) env.shop[i].level = unmarshallByte(th); } - env_clear_markers(); - const int nmarkers = unmarshallShort(th); - for (int i = 0; i < nmarkers; ++i) - { - if (map_marker *mark = map_marker::read_marker(th)) - env_add_marker(mark); - } + env.markers.read(th); } static void tag_read_level_items(struct tagHeader &th, char minorVersion) diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 3ef549ec0e..9f6525ebbb 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -2488,9 +2488,16 @@ static int find_transtravel_stair( const level_id &cur, static bool loadlev_populate_stair_distances(const level_pos &target) { + // Copy the current crawl_environment. Note that this is a shallow + // copy so tmp holds references to map markers. std::auto_ptr<crawl_environment> tmp(new crawl_environment(env)); + + // Clear markers. The tmp env still points at the markers, so we + // don't leak. XXX: Make crawl_environment fully assignable. + env.markers.clear(); + if (!travel_load_map(target.id.branch, - absdungeon_depth(target.id.branch, target.id.depth))) + absdungeon_depth(target.id.branch, target.id.depth))) { env = *tmp; return false; |