summaryrefslogtreecommitdiff
path: root/src/spells1.cc
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2015-03-07 16:55:42 +0100
committerBardur Arantsson <bardur@scientician.net>2015-03-07 16:55:42 +0100
commit9f1d3f9c27ae3dc717ec781e14fd44626f223641 (patch)
tree4726ede75f4c1159237e027b99545a83a51b3866 /src/spells1.cc
parent45fac786776f6664727daf160919f22313061017 (diff)
Move GRID, GRID_{X,Y} macros to spells1.cc
Diffstat (limited to 'src/spells1.cc')
-rw-r--r--src/spells1.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/spells1.cc b/src/spells1.cc
index 180fdd75..a619c002 100644
--- a/src/spells1.cc
+++ b/src/spells1.cc
@@ -50,6 +50,23 @@ using std::chrono::milliseconds;
/* Maximum number of tries for teleporting */
#define MAX_TRIES 100
+/*
+ * Convert a "location" (Y,X) into a "grid" (G)
+ */
+#define GRID(Y,X) \
+ (256 * (Y) + (X))
+
+/*
+ * Convert a "grid" (G) into a "location" (Y)
+ */
+#define GRID_Y(G) \
+ ((int)((G) / 256U))
+
+/*
+ * Convert a "grid" (G) into a "location" (X)
+ */
+#define GRID_X(G) \
+ ((int)((G) % 256U))
/*
* Helper function -- return a "nearby" race for polymorphing