summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/los_def.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-07 09:14:53 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-07 09:26:05 +0100
commit5026a1be87655357367b9ae66db018c08899e572 (patch)
tree4ffc8668983e69339aecb5424f0e8092f1f2341d /crawl-ref/source/los_def.cc
parentdc74095a578a338bb926cfea2db14c2b90c2a633 (diff)
downloadcrawl-ref-5026a1be87655357367b9ae66db018c08899e572.tar.gz
crawl-ref-5026a1be87655357367b9ae66db018c08899e572.zip
Split los_def implementation out into los_def.cc.
Diffstat (limited to 'crawl-ref/source/los_def.cc')
-rw-r--r--crawl-ref/source/los_def.cc79
1 files changed, 79 insertions, 0 deletions
diff --git a/crawl-ref/source/los_def.cc b/crawl-ref/source/los_def.cc
new file mode 100644
index 0000000000..08144fe23b
--- /dev/null
+++ b/crawl-ref/source/los_def.cc
@@ -0,0 +1,79 @@
+/*
+ * File: los_def.cc
+ * Summary: LOS wrapper class.
+ */
+
+#include "AppHdr.h"
+
+#include "los.h"
+
+los_def::los_def()
+ : show(0), opc(opc_default.clone()), bds(bds_default.clone())
+{
+}
+
+los_def::los_def(const coord_def& c, const opacity_func &o,
+ const bounds_func &b)
+ : show(0), center(c), opc(o.clone()), bds(b.clone())
+{
+}
+
+los_def::los_def(const los_def& los)
+ : show(los.show), center(los.center),
+ opc(los.opc->clone()), bds(los.bds->clone())
+{
+}
+
+los_def& los_def::operator=(const los_def& los)
+{
+ init(los.center, *los.opc, *los.bds);
+ show = los.show;
+ return (*this);
+}
+
+void los_def::init(const coord_def &c, const opacity_func &o,
+ const bounds_func &b)
+{
+ show.init(0);
+ set_center(c);
+ set_opacity(o);
+ set_bounds(b);
+}
+
+los_def::~los_def()
+{
+ delete opc;
+ delete bds;
+}
+
+void los_def::update()
+{
+ losight(show, center, *opc, *bds);
+}
+
+void los_def::set_center(const coord_def& c)
+{
+ center = c;
+}
+
+void los_def::set_opacity(const opacity_func &o)
+{
+ delete opc;
+ opc = o.clone();
+}
+
+void los_def::set_bounds(const bounds_func &b)
+{
+ delete bds;
+ bds = b.clone();
+}
+
+bool los_def::in_bounds(const coord_def& p) const
+{
+ return ((*bds)(p));
+}
+
+bool los_def::see_cell(const coord_def& p) const
+{
+ return (::see_cell(show, center, p));
+}