Hide some differences between 0-origin and 1-origin addressing.
[super-star-trek.git] / sst.h
diff --git a/sst.h b/sst.h
index 78596102d81c987fcc8c7018ac48fe7f5c2336e3..203a1690473f8b777861e89c5da8a7ca7ea3297c 100644 (file)
--- a/sst.h
+++ b/sst.h
 #define QUADSIZE (10)
 #define BASEMAX        (6)
 
+/*
+ * These macros hide the difference between 0-origin and 1-origin addressing.
+ * They're a step towards de-FORTRANizing the code.
+ */
+#define VALID_QUADRANT(x, y)   ((x)>=1 && (x)<=GALSIZE && (y)>=1 && (y)<=GALSIZE)
+#define VALID_SECTOR(x, y)     ((x)>=1 && (x)<=QUADSIZE && (y)>=1 && (y)<=QUADSIZE)
+#define for_quadrants(i)       for (i = 1; i < GALSIZE+1; i++)
+#define for_sectors(i)         for (i = 1; i < QUADSIZE+1; i++)
+
 typedef struct {
     int x;     /* Quadrant location of planet */
     int y;