]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/satmap.c
Update copyright notice
[empserver] / src / lib / subs / satmap.c
index 002388c4763e9c8fba804a30a4a90dd09e02dfc6..e32d2bec8457a602be02e4850fd444979e35b39c 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2017, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
  *
  *  Known contributors to this file:
  *     Steve McClure, 2000
+ *     Markus Armbruster, 2004-2013
  */
 
 #include <config.h>
 
 #include <stdlib.h>
-#include "file.h"
+#include "chance.h"
 #include "land.h"
 #include "map.h"
 #include "misc.h"
 static char **rad;
 static char *radbuf;
 
-void
+int
 satmap(int x, int y, int eff, int range, int flags, int type)
 {
     struct sctstr sect;
     struct shpstr ship;
     struct lndstr land;
-    int count;
+    int count, crackle;
     struct nstr_item ni;
     struct nstr_sect ns;
     int rx, ry;
     int row;
     int n;
     int changed = 0;
-    long crackle;
     signed char noise[100];
-    char selection[1024];
 
     if (!eff)
-       return;
+       return RET_OK;
 
     if (!radbuf)
        radbuf = malloc(WORLD_Y * MAPWIDTH(1));
@@ -83,7 +81,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
 
     if (!radbuf || !rad) {
        pr("Memory error in satmap, tell the deity.\n");
-       return;
+       return RET_FAIL;
     }
 
     range = range * (eff / 100.0);
@@ -96,15 +94,10 @@ satmap(int x, int y, int eff, int range, int flags, int type)
            noise[100 * n / (100 - eff)] = 1;
     }
 
-    /* Have to convert to player coords, since it gets converted
-       back from there */
-    sprintf(selection, "@%s:%d", xyas(x, y, player->cnum), range);
-
     if (type == EF_BAD || type == EF_SECTOR) {
-       if (type == EF_SECTOR)  /* Use ?conditionals */
-           snxtsct(&ns, selection);
-       else
-           snxtsct_dist(&ns, x, y, range);
+       snxtsct_dist(&ns, x, y, range);
+       if (type == EF_SECTOR && !snxtsct_use_condarg(&ns))
+           return RET_SYN;
 
        blankfill(radbuf, &ns.range, 1);
        if (flags & P_S) {
@@ -144,16 +137,15 @@ 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, NULL);
-       else
-           snxtitem_dist(&ni, EF_SHIP, x, y, range);
+       snxtitem_dist(&ni, EF_SHIP, x, y, range);
+       if (type == EF_SHIP && !snxtitem_use_condarg(&ni))
+           return RET_SYN;
 
        crackle = count = 0;
        if (flags & P_S) {
            pr("Satellite ship report\n");
            prdate();
-           pr(" own  shp# ship type                                  sector   eff\n");
+           pr(" own shp# ship type                                   sector   eff\n");
        }
        while (nxtitem(&ni, &ship)) {
            if (ship.shp_own == 0)
@@ -189,16 +181,15 @@ 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, NULL);
-       else
-           snxtitem_dist(&ni, EF_LAND, x, y, range);
+       snxtitem_dist(&ni, EF_LAND, x, y, range);
+       if (type == EF_LAND && !snxtitem_use_condarg(&ni))
+           return RET_SYN;
 
        crackle = count = 0;
        if (flags & P_S) {
            pr("Satellite unit report\n");
            prdate();
-           pr(" own  lnd# unit type         sector   eff\n");
+           pr(" own lnd# unit type         sector   eff\n");
        }
        while (nxtitem(&ni, &land)) {
            if (land.lnd_own == 0)
@@ -215,7 +206,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
                pr("%4d %4d %-16.16s ",
                   land.lnd_own, land.lnd_uid,
                   lchr[(int)land.lnd_type].l_name);
-               prxy("%4d,%-4d", land.lnd_x, land.lnd_y);
+               prxy("%4d,%-4d ", land.lnd_x, land.lnd_y);
                pr("%3d%%\n", land.lnd_effic);
                ++count;
                if (opt_HIDDEN)
@@ -248,6 +239,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
            pr("%s\n", rad[row]);
        pr("\n(c) 1989 Imaginative Images Inc.\n");
     }
+    return RET_OK;
 }
 
 void
@@ -292,7 +284,7 @@ satdisp_units(coord x, coord y)
        if (mchr[(int)ship.shp_type].m_flags & M_SUB)
            continue;
        if (first) {
-           pr("\t own  shp# ship type                                  sector   eff\n");
+           pr("\t own shp# ship type                                   sector   eff\n");
            first = 0;
        }
        pr("\t%4d %4d %-16.16s %-25.25s ",
@@ -319,7 +311,7 @@ satdisp_units(coord x, coord y)
            continue;
 
        if (first) {
-           pr("\t own  lnd# unit type       sector   eff\n");
+           pr("\t own lnd# unit type         sector   eff\n");
            first = 0;
        }