summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/exclude.cc
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-13 06:01:47 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-13 06:02:15 -0800
commitcc0860dfeac4c0f9917d3e96fd9b709df1fafff2 (patch)
tree4168997754fa1501774580ba65bb12c22fd1ba27 /crawl-ref/source/exclude.cc
parent86b2a07772af036bd6f6d3252ba18af0d6a3cd71 (diff)
downloadcrawl-ref-cc0860dfeac4c0f9917d3e96fd9b709df1fafff2.tar.gz
crawl-ref-cc0860dfeac4c0f9917d3e96fd9b709df1fafff2.zip
exclude.cc: revert _find_exclude_root() speed-up
Was causing memory problems.
Diffstat (limited to 'crawl-ref/source/exclude.cc')
-rw-r--r--crawl-ref/source/exclude.cc29
1 files changed, 6 insertions, 23 deletions
diff --git a/crawl-ref/source/exclude.cc b/crawl-ref/source/exclude.cc
index 6b7e3a9ae7..73f99b167f 100644
--- a/crawl-ref/source/exclude.cc
+++ b/crawl-ref/source/exclude.cc
@@ -19,9 +19,6 @@
#include "tutorial.h"
#include "view.h"
-typedef std::map<coord_def, travel_exclude*> exclmap;
-static exclmap _curr_excludes_map;
-
static bool _mon_needs_auto_exclude(const monsters *mon, bool sleepy = false)
{
if (mons_is_stationary(mon))
@@ -157,27 +154,20 @@ bool travel_exclude::in_bounds(const coord_def &p) const
void _mark_excludes_non_updated(const coord_def &p)
{
- _curr_excludes_map.clear();
-
- for (exclvec::iterator it = curr_excludes.begin();
+ for (exclvec::iterator it = curr_excludes.begin();
it != curr_excludes.end(); ++it)
{
it->uptodate = it->uptodate && it->in_bounds(p);
- _curr_excludes_map[it->pos] = &(*it);
- }
+ }
}
-static void _update_exclusion_los(bool all=false)
+void _update_exclusion_los(bool all=false)
{
- _curr_excludes_map.clear();
-
for (exclvec::iterator it = curr_excludes.begin();
it != curr_excludes.end(); ++it)
{
if (all || !it->uptodate)
it->set_los();
-
- _curr_excludes_map[it->pos] = &(*it);
}
}
@@ -212,11 +202,9 @@ bool is_excluded(const coord_def &p, const exclvec &exc)
static travel_exclude *_find_exclude_root(const coord_def &p)
{
- exclmap::iterator it = _curr_excludes_map.find(p);
-
- if (it !=_curr_excludes_map.end())
- return it->second;
-
+ for (unsigned int i = 0; i < curr_excludes.size(); ++i)
+ if (curr_excludes[i].pos == p)
+ return (&curr_excludes[i]);
return (NULL);
}
@@ -271,7 +259,6 @@ void clear_excludes()
#endif
curr_excludes.clear();
- _curr_excludes_map.clear();
clear_level_exclusion_annotation();
_exclude_update();
@@ -300,7 +287,6 @@ void del_exclude(const coord_def &p)
if (curr_excludes[i].pos == p)
{
curr_excludes.erase(curr_excludes.begin() + i);
- _curr_excludes_map.erase(p);
break;
}
_exclude_update(p);
@@ -331,7 +317,6 @@ void set_exclude(const coord_def &p, int radius, bool autoexcl, bool vaultexcl)
curr_excludes.push_back(travel_exclude(p, radius, autoexcl,
montype, vaultexcl));
- _curr_excludes_map[p] = &curr_excludes.back();
}
_exclude_update(p);
@@ -406,7 +391,6 @@ void marshallExcludes(writer& outf, const exclvec& excludes)
void unmarshallExcludes(reader& inf, char minorVersion, exclvec &excludes)
{
excludes.clear();
- _curr_excludes_map.clear();
int nexcludes = unmarshallShort(inf);
if (nexcludes)
{
@@ -423,7 +407,6 @@ void unmarshallExcludes(reader& inf, char minorVersion, exclvec &excludes)
mon = static_cast<monster_type>(unmarshallShort(inf));
}
excludes.push_back(travel_exclude(c, radius, autoexcl, mon));
- _curr_excludes_map[c] = &curr_excludes.back();
}
}
}