00001 #ifndef EXCLUDE_H
00002 #define EXCLUDE_H
00003
00004 #include "los_def.h"
00005
00006 bool need_auto_exclude(const monster* mon, bool sleepy = false);
00007 void set_auto_exclude(const monster* mon);
00008 void remove_auto_exclude(const monster* mon, bool sleepy = false);
00009
00010 void init_exclusion_los();
00011 void update_exclusion_los(std::vector<coord_def> changed);
00012 void deferred_exclude_update();
00013
00014 bool is_exclude_root(const coord_def &p);
00015 int get_exclusion_radius(const coord_def &p);
00016 std::string get_exclusion_desc(const coord_def &p);
00017 void cycle_exclude_radius(const coord_def &p);
00018 void del_exclude(const coord_def &p);
00019 void set_exclude(const coord_def &p, int radius = LOS_RADIUS,
00020 bool autoexcl = false, bool vaultexcl = false,
00021 bool defer_updates = false);
00022 void maybe_remove_autoexclusion(const coord_def &p);
00023 void clear_excludes();
00024
00025 class travel_exclude
00026 {
00027 public:
00028 coord_def pos;
00029 int radius;
00030 los_def los;
00031 bool uptodate;
00032 bool autoex;
00033 std::string desc;
00034 bool vault;
00035
00036 travel_exclude(const coord_def &p, int r = LOS_RADIUS,
00037 bool autoex = false, std::string desc = "",
00038 bool vault = false);
00039
00040 travel_exclude();
00041
00042 int radius_sq() const;
00043 bool in_bounds(const coord_def& p) const;
00044 bool affects(const coord_def& p) const;
00045
00046 private:
00047 void set_los();
00048
00049 friend class exclude_set;
00050 };
00051
00052 class exclude_set
00053 {
00054 public:
00055 exclude_set();
00056
00057 typedef std::map<coord_def, travel_exclude> exclmap;
00058 typedef exclmap::iterator iterator;
00059 typedef exclmap::const_iterator const_iterator;
00060
00061 void clear();
00062
00063 void erase(const coord_def &p);
00064 void add_exclude(travel_exclude &ex);
00065 void add_exclude(const coord_def &p, int radius = LOS_RADIUS,
00066 bool autoexcl = false,
00067 std::string desc = "",
00068 bool vaultexcl = false);
00069
00070 void update_excluded_points(bool recompute_los = false);
00071 void recompute_excluded_points(bool recompute_los = false);
00072
00073 travel_exclude* get_exclude_root(const coord_def &p);
00074
00075 bool is_excluded(const coord_def &p) const;
00076 bool is_exclude_root(const coord_def &p) const;
00077 std::string get_exclusion_desc();
00078
00079 size_t size() const;
00080 bool empty() const;
00081
00082 const_iterator begin() const;
00083 const_iterator end() const;
00084
00085 iterator begin();
00086 iterator end();
00087
00088 private:
00089 typedef std::set<coord_def> exclset;
00090
00091 exclmap exclude_roots;
00092 exclset exclude_points;
00093
00094 private:
00095 void add_exclude_points(travel_exclude& ex);
00096 };
00097
00098 extern exclude_set curr_excludes;
00099
00100 bool is_excluded(const coord_def &p, const exclude_set &exc = curr_excludes);
00101
00102 class writer;
00103 class reader;
00104 void marshallExcludes(writer& outf, const exclude_set& excludes);
00105 void unmarshallExcludes(reader& inf, int minorVersion, exclude_set& excludes);
00106
00107 #endif