boolean pneumatic_hammer_sound;
/* internal variables, used during the game. private data :) */
- GdElement* (*getp) (const struct _gd_cave*, int x, int y); /* returns a pointer to the element at x, y. this points to a perfect border or a line shifting get function. */
+
+ /* returns range corrected x/y position (points to perfect or line shifting get function) */
+ int (*getx) (const struct _gd_cave*, int x, int y);
+ int (*gety) (const struct _gd_cave*, int x, int y);
+
+ /* returns pointer to element at x, y (points to perfect border or a line shifting get function) */
+ GdElement* (*getp) (const struct _gd_cave*, int x, int y);
boolean hatched; /* hatching has happened. (timers may run, ...) */
boolean gate_open; /* self-explaining */
}
}
+static inline int getx(const GdCave *cave, const int x, const int y)
+{
+ return cave->getx(cave, x, y);
+}
+
+static inline int gety(const GdCave *cave, const int x, const int y)
+{
+ return cave->gety(cave, x, y);
+}
+
+/* perfect (non-lineshifting) GET x/y functions; returns range corrected x/y position */
+static inline int getx_perfect(const GdCave *cave, const int x, const int y)
+{
+ return (x + cave->w) % cave->w;
+}
+
+static inline int gety_perfect(const GdCave *cave, const int x, const int y)
+{
+ return (y + cave->h) % cave->h;
+}
+
+/* line shifting GET x/y function; returns range corrected x/y position */
+static inline int getx_shift(const GdCave *cave, int x, int y)
+{
+ return (x + cave->w) % cave->w;
+}
+
+static inline int gety_shift(const GdCave *cave, int x, int y)
+{
+ return ((x < 0 ? y - 1 : x >= cave->w ? y + 1 : y) + cave->h) % cave->h;
+}
+
static inline GdElement *getp(const GdCave *cave, const int x, const int y)
{
return cave->getp(cave, x, y);
/* set cave get function; to implement perfect or lineshifting borders */
if (cave->lineshift)
+ {
cave->getp = getp_shift;
+ cave->getx = getx_shift;
+ cave->gety = gety_shift;
+ }
else
+ {
cave->getp = getp_perfect;
+ cave->getx = getx_perfect;
+ cave->gety = gety_perfect;
+ }
/* increment this. if the scan routine comes across player, clears it (sets to zero). */
if (cave->player_seen_ago < 100)