]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/radmap.c
Fix trailing whitespace
[empserver] / src / lib / subs / radmap.c
index 0ab3c12b3fc678f2a64e863e7bd4a47560ce2d08..5461e582af91c3265fa6262819afc76fe86f74dc 100644 (file)
@@ -26,7 +26,7 @@
  *  ---
  *
  *  radmap.c: Do a radar map given an x,y location, effic, and other
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1989
  */
@@ -91,9 +91,9 @@ radmap2(int owner,
     int changed = 0;
 
     if (!radbuf)
-       radbuf = malloc(WORLD_Y * (WORLD_X + 1));
+       radbuf = malloc(WORLD_Y * MAPWIDTH(1));
     if (!visbuf)
-       visbuf = malloc(WORLD_Y * (WORLD_X + 1));
+       visbuf = malloc(WORLD_Y * MAPWIDTH(1));
     if (!rad) {
        rad = malloc(WORLD_Y * sizeof(char *));
        if (rad && radbuf) {
@@ -171,44 +171,40 @@ radmap2(int owner,
            rad[y][x] = (*mchr[(int)ship.shp_type].m_name) & ~0x20;
        }
     }
-    /* 
+    /*
      * make the center of the display 0
      * so ve et al can find it.
      */
-    rad[deltay(cy, ns.range.ly)][deltax(cx, ns.range.lx)] = '0';
-    /* won't work for radar maps > WORLD_Y/2 */
-#ifdef HAY
-    /* This is not correct for small, hitech worlds. */
-    n = deltay(ns.range.hy, ns.range.ly);
-#else
-    /* This is already available, so why not use it. */
+    rad[delty(&ns.range, cy)][deltx(&ns.range, cx)] = '0';
+
     n = ns.range.height;
-#endif
     for (row = 0; row < n; row++)
        pr("%s\n", rad[row]);
     pr("\n");
 }
 
+/*
+ * Return distance from left edge of R to X.
+ * Value is between 0 (inclusive) and WORLD_X (exclusive).
+ * X must be normalized.
+ */
 int
 deltx(struct range *r, coord x)
 {
-    if (r->lx < r->hx)
-       return x - r->lx;
-
     if (x >= r->lx)
        return x - r->lx;
-
     return x + WORLD_X - r->lx;
 }
 
+/*
+ * Return distance from top edge of R to Y.
+ * Value is between 0 (inclusive) and WORLD_Y (exclusive).
+ * Y must be normalized.
+ */
 int
 delty(struct range *r, coord y)
 {
-    if (r->ly < r->hy)
-       return y - r->ly;
-
     if (y >= r->ly)
        return y - r->ly;
-
     return y + WORLD_Y - r->ly;
 }