summaryrefslogtreecommitdiffstats
path: root/grid.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-01-08 21:52:05 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-01-08 21:52:05 +0000
commit10c4a6dc337b331372a7aa3f89d9404d4752a16b (patch)
tree728dfdb53d3baaac384f05cc066245017c274594 /grid.c
parent4ebb85aae8b5d931228151ccf62b768dd5a2ff8c (diff)
Don't die when out of bounds if non-DEBUG. Stops people hitting me when bugs kill their long-running sessions in release versions.
Diffstat (limited to 'grid.c')
-rw-r--r--grid.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/grid.c b/grid.c
index 35ebf975..93217e06 100644
--- a/grid.c
+++ b/grid.c
@@ -1,4 +1,4 @@
-/* $Id: grid.c,v 1.3 2008-09-28 20:34:22 nicm Exp $ */
+/* $Id: grid.c,v 1.4 2009-01-08 21:52:05 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -37,15 +37,30 @@
/* Default grid cell data. */
const struct grid_cell grid_default_cell = { ' ', 0, 0, 8, 8 };
+
+#ifdef DEBUG
#define grid_check_x(gd, px) do { \
if ((px) >= (gd)->sx) \
log_fatalx("x out of range: %u", px); \
} while (0)
-
#define grid_check_y(gd, py) do { \
if ((py) >= (gd)->hsize + (gd)->sy) \
log_fatalx("y out of range: %u", py); \
} while (0)
+#else
+#define grid_check_x(gd, px) do { \
+ if ((px) >= (gd)->sx) { \
+ log_debug("x out of range: %u", px); \
+ return; \
+ } \
+} while (0)
+#define grid_check_y(gd, py) do { \
+ if ((py) >= (gd)->hsize + (gd)->sy) { \
+ log_debug("y out of range: %u", py); \
+ return; \
+ } \
+} while (0)
+#endif
#define grid_put_cell(gd, px, py, gc) do { \
memcpy(&gd->data[py][px], gc, sizeof gd->data[py][px]); \