summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-24 10:10:35 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-24 11:05:13 +0100
commite022aaa532c3c4b5cd43b1ea7d43e1e2e4e7aa91 (patch)
tree2dd3d2702c6afb0c2143ffed1c4e9305b10311ea /crawl-ref/source
parent6728050e3e412aa0c335a3f7439657288c79d4c5 (diff)
downloadcrawl-ref-e022aaa532c3c4b5cd43b1ea7d43e1e2e4e7aa91.tar.gz
crawl-ref-e022aaa532c3c4b5cd43b1ea7d43e1e2e4e7aa91.zip
Move player2grid and grid2player to coord.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/coord.cc11
-rw-r--r--crawl-ref/source/coord.h6
-rw-r--r--crawl-ref/source/l_moninf.cc11
3 files changed, 18 insertions, 10 deletions
diff --git a/crawl-ref/source/coord.cc b/crawl-ref/source/coord.cc
index 576c71bd27..c4f1a5ec64 100644
--- a/crawl-ref/source/coord.cc
+++ b/crawl-ref/source/coord.cc
@@ -97,4 +97,15 @@ coord_def random_in_bounds()
random_range(MAPGEN_BORDER, GYM - MAPGEN_BORDER - 1));
}
+// Coordinate system conversions.
+
+coord_def player2grid(const coord_def &pc)
+{
+ return (pc + you.pos());
+}
+
+coord_def grid2player(const coord_def &gc)
+{
+ return (gc - you.pos());
+}
diff --git a/crawl-ref/source/coord.h b/crawl-ref/source/coord.h
index 685718ca8e..1baee51bee 100644
--- a/crawl-ref/source/coord.h
+++ b/crawl-ref/source/coord.h
@@ -32,4 +32,10 @@ int distance( const coord_def& p1, const coord_def& p2 );
int distance( int x, int y, int x2, int y2);
bool adjacent( const coord_def& p1, const coord_def& p2 );
+// Conversion between different coordinate systems.
+// XXX: collect all of these here?
+
+coord_def player2grid(const coord_def& pc);
+coord_def grid2player(const coord_def& pc);
+
#endif
diff --git a/crawl-ref/source/l_moninf.cc b/crawl-ref/source/l_moninf.cc
index 102e71213c..9fdacf73ff 100644
--- a/crawl-ref/source/l_moninf.cc
+++ b/crawl-ref/source/l_moninf.cc
@@ -8,6 +8,7 @@
#include "l_libs.h"
#include "cluautil.h"
+#include "coord.h"
#include "env.h"
#include "mon-info.h"
@@ -58,16 +59,6 @@ bool in_show_bounds(const coord_def &s)
return (s.rdist() <= ENV_SHOW_OFFSET);
}
-coord_def player2grid(const coord_def &s)
-{
- return (you.pos() + s);
-}
-
-coord_def grid2player(const coord_def &g)
-{
- return (g - you.pos());
-}
-
LUAFN(mi_get_monster_at)
{
COORDSHOW(s, 1, 2)