]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/satmap.c
Update copyright notice
[empserver] / src / lib / subs / satmap.c
index b1167692085bdf6cb7b45de99331c4a057bca32f..a14810fcb8201b531841de1c39bdb808349329fe 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  *  ---
  *
  *  satmap.c: Do a satellite map given an x,y location, effic and other
- * 
+ *
  *  Known contributors to this file:
  *     Steve McClure, 2000
  */
 
 #include <config.h>
 
+#include <stdlib.h>
+#include "file.h"
+#include "land.h"
+#include "map.h"
 #include "misc.h"
+#include "nat.h"
+#include "nsc.h"
+#include "optlist.h"
+#include "plane.h"
 #include "player.h"
-#include "xy.h"
+#include "prototypes.h"
 #include "sect.h"
 #include "ship.h"
-#include "land.h"
-#include "plane.h"
-#include "nsc.h"
-#include "nat.h"
-#include "file.h"
-#include "prototypes.h"
-#include "optlist.h"
+#include "xy.h"
 
 static char **rad;
 static char *radbuf;
@@ -52,7 +54,6 @@ static char *radbuf;
 void
 satmap(int x, int y, int eff, int range, int flags, int type)
 {
-    int acc;
     struct sctstr sect;
     struct shpstr ship;
     struct lndstr land;
@@ -71,7 +72,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
        return;
 
     if (!radbuf)
-       radbuf = malloc(WORLD_Y * (WORLD_X + 1));
+       radbuf = malloc(WORLD_Y * MAPWIDTH(1));
     if (!rad) {
        rad = malloc(WORLD_Y * sizeof(char *));
        if (rad && radbuf) {
@@ -110,7 +111,6 @@ satmap(int x, int y, int eff, int range, int flags, int type)
            pr("Satellite sector report\n");
            prdate();
            sathead();
-           acc = (flags & P_I) ? 5 : 50;
        }
        crackle = count = 0;
        while (nxtsct(&ns, &sect)) {
@@ -120,7 +120,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
                continue;
            if (flags & P_S) {
                if (sect.sct_own && sect.sct_own != player->cnum) {
-                   satdisp_sect(&sect, acc);
+                   satdisp_sect(&sect, (flags & P_I) ? 5 : 50);
                    ++count;
                    if (opt_HIDDEN)
                        setcont(player->cnum, sect.sct_own, FOUND_FLY);
@@ -143,7 +143,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
     if ((type == EF_BAD || type == EF_SHIP) &&
        (flags & P_S || flags & P_I)) {
        if (type == EF_SHIP)
-           snxtitem(&ni, EF_SHIP, selection);
+           snxtitem(&ni, EF_SHIP, selection, NULL);
        else
            snxtitem_dist(&ni, EF_SHIP, x, y, range);
 
@@ -175,15 +175,8 @@ satmap(int x, int y, int eff, int range, int flags, int type)
            }
            /* If we are imaging *and* drawing the map */
            if ((flags & P_I) && (type == EF_BAD)) {
-               /* Figure out where to put the ship */
-               /* First, figure out the distance from the two */
-               rx = diffx((int)ship.shp_x, x);
-               ry = diffy((int)ship.shp_y, y);
-               /* Next, determine which direction to add it to the center */
-               /* We can only do this if imaging and we have gotten the center
-                  up above by imaging the sectors. */
-               rx = deltax(x, ns.range.lx) + rx;
-               ry = deltay(y, ns.range.ly) + ry;
+               rx = deltx(&ns.range, ship.shp_x);
+               ry = delty(&ns.range, ship.shp_y);
                /* &~0x20 makes it a cap letter */
                rad[ry][rx] = (*mchr[(int)ship.shp_type].m_name) & ~0x20;
            }
@@ -195,7 +188,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
     if ((type == EF_BAD || type == EF_LAND) &&
        (flags & P_S || flags & P_I)) {
        if (type == EF_LAND)
-           snxtitem(&ni, EF_LAND, selection);
+           snxtitem(&ni, EF_LAND, selection, NULL);
        else
            snxtitem_dist(&ni, EF_LAND, x, y, range);
 
@@ -228,15 +221,8 @@ satmap(int x, int y, int eff, int range, int flags, int type)
            }
            /* If we are imaging *and* drawing the map */
            if ((flags & P_I) && (type == EF_BAD)) {
-               /* Figure out where to put the unit */
-               /* First, figure out the distance from the two */
-               rx = diffx((int)land.lnd_x, x);
-               ry = diffy((int)land.lnd_y, y);
-               /* Next, determine which direction to add it to the center */
-               /* We can only do this if imaging and we have gotten the center
-                  up above by imaging the sectors. */
-               rx = deltax(x, ns.range.lx) + rx;
-               ry = deltay(y, ns.range.ly) + ry;
+               rx = deltx(&ns.range, land.lnd_x);
+               ry = delty(&ns.range, land.lnd_y);
                /* &~0x20 makes it a cap letter */
                rad[ry][rx] = (*lchr[(int)land.lnd_type].l_name) & ~0x20;
            }
@@ -252,16 +238,10 @@ satmap(int x, int y, int eff, int range, int flags, int type)
         * We have to make the center a '0' for ve
         * ve needs a garbage line to terminate the map
         */
-       rad[deltay(y, ns.range.ly)][deltax(x, ns.range.lx)] = '0';
+       rad[delty(&ns.range, y)][deltx(&ns.range, y)] = '0';
 
        pr("Satellite radar report\n");
-#ifdef HAY
-       /* This is wrong for small, hitech worlds. */
-       n = deltay(ns.range.hy, ns.range.ly);
-#else
-       /* This is already available, so why not use it. */
        n = ns.range.height;
-#endif
        for (row = 0; row < n; row++)
            pr("%s\n", rad[row]);
        pr("\n(c) 1989 Imaginative Images Inc.\n");
@@ -283,7 +263,7 @@ satdisp_sect(struct sctstr *sp, int acc)
        dchr[sp->sct_type].d_mnem,
        sp->sct_own, roundintby((int)sp->sct_effic, acc / 2),
        roundintby((int)sp->sct_road, acc / 2),
-       roundintby((int)sp->sct_rail, acc / 2),
+       opt_RAILWAYS ? !!sct_rail_track(sp) : roundintby(sp->sct_rail, acc / 2),
        roundintby((int)sp->sct_defense, acc / 2),
        roundintby(sp->sct_item[I_CIVIL], acc),
        roundintby(sp->sct_item[I_MILIT], acc),