From 9f1d3f9c27ae3dc717ec781e14fd44626f223641 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 7 Mar 2015 16:55:42 +0100 Subject: Move GRID, GRID_{X,Y} macros to spells1.cc --- src/spells1.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/spells1.cc') 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 -- cgit v1.2.1