summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-13 03:12:21 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-13 03:12:21 -0800
commita228636066120596757c3d395fdb802ba107063f (patch)
tree5a523f9eea0ba72f7781e3151a840ec8721dd943 /crawl-ref
parentada5301a6dd6ba6d713a7aeb566d1ef14a000eb1 (diff)
downloadcrawl-ref-a228636066120596757c3d395fdb802ba107063f.tar.gz
crawl-ref-a228636066120596757c3d395fdb802ba107063f.zip
Don't remove marker while it's being activated
Removing a marker while it's being activated leads to memory weirdness, so instead while activating all markers see if each marker has the "post_activate_remove" set, and afterwards remove those that do.
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/dat/clua/lm_mon_prop.lua14
-rw-r--r--crawl-ref/source/mapmark.cc7
2 files changed, 20 insertions, 1 deletions
diff --git a/crawl-ref/source/dat/clua/lm_mon_prop.lua b/crawl-ref/source/dat/clua/lm_mon_prop.lua
index 6bc3dd6de9..f005a4b0d9 100644
--- a/crawl-ref/source/dat/clua/lm_mon_prop.lua
+++ b/crawl-ref/source/dat/clua/lm_mon_prop.lua
@@ -38,7 +38,19 @@ function MonPropsMarker:activate(marker)
mon.set_prop(k, v)
end
- dgn.remove_marker(marker)
+ -- NOTE: do *not* call dgn.remove_marker() right now; removing a marker
+ -- while it's being activated causes memory problems. We'll be
+ -- removed after activation is done with the "post_activate_remove"
+ -- property.
+ self.want_remove = true
+end
+
+function MonPropsMarker:property(marker, pname)
+ if self.want_remove and pname == "post_activate_remove" then
+ return "true"
+ end
+
+ return ""
end
function MonPropsMarker:write(marker, th)
diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc
index e7d3abf65a..b0f27d40b6 100644
--- a/crawl-ref/source/mapmark.cc
+++ b/crawl-ref/source/mapmark.cc
@@ -596,11 +596,18 @@ void map_markers::init_from(const map_markers &c)
void map_markers::activate_all(bool verbose)
{
+ std::vector<map_marker*> to_remove;
+
for (dgn_marker_map::iterator i = markers.begin();
i != markers.end(); ++i)
{
i->second->activate(verbose);
+ if (i->second->property("post_activate_remove") != "")
+ to_remove.push_back(i->second);
}
+
+ for (unsigned int i = 0; i < to_remove.size(); i++)
+ remove(to_remove[i]);
}
void map_markers::add(map_marker *marker)